akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, x, i, a[100001], ans=0, b;

    cin >> N >> x;

    for(i=1; i<=N; i++){
        cin >> a[i];
    }

    if(a[1]>x){
        ans += a[1]-x;
        a[1] = x;
    }

    for(i=2; i<=N; i++){
        if(a[i-1]+a[i] > x){
            ans += a[i-1]+a[i]-x;
            a[i] = x-a[i-1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
from math import ceil


N, D, A = map(int, input().split())
monsters = []
for i in range(N):
    x, h = map(int, input().split())
    monsters.append((x, h))
monsters.sort()


def problem_a(h):
    if h <= 0:
        return 0
    return ceil(h/A)


cnt_sum = 0
cnt = [0] * N
l = 0
for i in range(N):
    while monsters[l][0] + 2 * D < monsters[i][0]:
        cnt_sum -= cnt[l]
        l += 1
    already = cnt_sum * A
    cnt[i] = problem_a(monsters[i][1] - already)
    cnt_sum += cnt[i]

print(sum(cnt))



Measured memory_bytes: 38092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N,L;
    cin >> N >> L;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    ll last=-1;
    if (N==2&&a[0]+a[1]>=L){
        cout << "Possible" << endl << 1 << endl;
        return 0;
    }
    if (N==2){
        cout << "Impossible" << endl;
        return 0;
    }
    rep2(i,1,N-1){
        if (a[i]+a[i-1]>=L){
            last=i;
            break;
        }
        if (a[i]+a[i+1]>=L){
            last=i+1;
            break;
        }
        if (i==N-2&&last==-1){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    rep2(i,1,last){
        cout << i << endl;
    }
    for (int i=N-1;i>last;--i){
        cout << i << endl;
    }
    cout << last << endl;
}

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

int main() {
  
  int N, K;
  cin >> N >> K;
  
  vector<int> H(N);
  for(int i = 0; i < N; i++) {
    cin >> H.at(i); 
  }
  
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  
  long long ans = 0;
  
  if(K >= N) cout << 0 << endl;
  
  else {
    for(int i = K; i < N; i++) {
      ans += H.at(i); 
    }
    cout << ans << endl;   
  }
  
}

Measured memory_bytes: 4048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<int> dag[SIZE];
int dist[SIZE], inedge[SIZE];
set<pair<int,int> > added;

int main(){
  int n, m;

  scanf("%d%d", &n, &m);

  for(int i=0;i<n+m-1;i++){
    int u, v;
    scanf("%d%d", &u, &v);
    u--; v--;

    dag[u].push_back(v);
    inedge[v]++;
  }

  int root = 0;

  for(int i=0;i<n;i++){
    if(inedge[i] == 0) root = i;
  }

  queue<int> que;

  que.push(root);

  while(que.size()){
    int p = que.front();
    que.pop();

    for(int i=0;i<dag[p].size();i++){
      int to = dag[p][i];
      inedge[to]--;

      if(inedge[to] == 0){
        que.push(to);
      } else {
        added.insert({p, to});
      }
    }
  }

  int parent[SIZE] = {};

  for(int i=0;i<n;i++){
    for(int j=0;j<dag[i].size();j++){
      int p = i, q = dag[i][j];
      if(added.find({p, q}) == added.end()){
        parent[q] = p;
      }
    }
  }

  parent[root] = -1;

  for(int i=0;i<n;i++){
    printf("%d\n", parent[i]+1);
  }

  return 0;
}


Measured memory_bytes: 10880
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
m = map(int, raw_input().split())
nums = []

def func(i, p):
  if i != n:
    func(i+1, p)
    p += A[i]
    func(i+1, p)
  elif i == n:
    nums.append(p)

func(0, 0)

for i in range(q):
  if m[i] in nums:
    print("yes")
  else:
    print("no")

Measured memory_bytes: 36472
// https://atcoder.jp/contests/dp/tasks/dp_f

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    string s,t;
    cin >> s >> t;
    int n=s.length(),m=t.length();
    int dp[n+1][m+1];
    for(int i=0 ; i<=n ;i++)
    {
        for(int j=0 ; j<=m ; j++)
            dp[i][j] = 0;
    }
    for(int i=0 ; i<n ; i++)
    {
        for(int j=0 ; j<m ; j++)
        {
            if(s[i] == t[j])
                dp[i+1][j+1] = dp[i][j] + 1;
            else
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    string ans = "";
    int p=n,q=m;

    /*for(int i=0 ; i<=n ; i++)
    {
        for(int j=0 ; j<=m; j++)
            cout << dp[i][j] <<" ";
        cout << endl;
    }*/
    while(1)
    {
        if(p==0 || q==0)
            break;

        if(dp[p][q] == dp[p-1][q])
                p--;
        else if(dp[p][q] == dp[p][q-1])
                q--;
        else
        {
            ans = s[p-1] + ans;
            p--;
            q--;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 38776
#include<stdio.h>


void ire(int*,int*);
void sort(int*,int);
int c;
int main(){
  int s,i,su[100];
  scanf("%d",&s);
  for(i=0;i<s;i++){
    scanf("%d",&su[i]);
  }

sort(su,s);
 for (i=0; i < s; i++) {


   printf("%d",su[i]);
   if(i!=s-1)printf(" ");
 } 
  printf("\n");
  printf("%d\n",c);
  return 0;
}
void sort (int su[], int size) {
  int i, j;

  for (i = 0; i < size - 1; i++){
    for (j = size - 1; j >= i + 1; j--){   
      if (su[j] < su[j-1]) { ire(&su[j], &su[j-1]);c++; }
    }
  }
}


void ire (int *x, int *y) {
  int temp;    
  temp = *x;
  *x = *y;
  *y = temp;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  /* code */
  int N ;
  int K ;
  int ans = 0 ;
  string S ;
  cin >> N;
  cin >> K;
  cin >> S;

  if (S[0]==S[1] && S[0]=='R') {
    ans ++;
  }
  if (S[N-2]==S[N-1] && S[N-2]=='L') {
    ans ++;
  }

  for (int i = 1; i < N-1; i++) {
    if (S[i]==S[i+1] && S[i]=='R') {
      ans ++;
    }
    if (S[i]==S[i-1] && S[i]=='L') {
      ans ++;
    }
  }

  ans += 2*K;
  cout << min(ans, N-1) << "\n" ;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;
 
typedef pair<int, int> P;
typedef long long LL;
 
//-----Template---------
 
int main(){
    //cout<< fixed << setprecision(10);
    LL w,h;
    cin>>w>>h;
 
    vector<LL> p(w);
    vector<LL> q(h);
 
    for (int i = 0; i < w; ++i) cin>>p[i];
    for (int i = 0; i < h; ++i) cin>>q[i];
 
    vector<pair<LL,int>> hens;
    for (int i = 0; i < w; ++i)
        hens.emplace_back(p[i],0);  //x
 
    for (int i = 0; i < h; ++i)
        hens.emplace_back(q[i],1);  //y
 
    sort(hens.begin(),hens.end());
 
    LL sum=0;
    LL row=0,column=0; //row..x方向に舗装した数　column..y
    for(int i=0;i<hens.size();i++){
        LL a=hens[i].first;
        int t=hens[i].second;
        if(t==0){
            sum+=(h-column+1)*a;
            row++;
        }else{
            sum+=(w-row+1)*a;
            column++;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 6000
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int n,m,k;
	cin>>n>>m>>k;
	bool ok=false;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i*(m-j)+j*(n-i)==k)ok=true;
		}
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = (long long)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  long long n, k, h[110000];
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> h[i];
  long long dp[110000];
  for (long long i = 0; i < n; i++) dp[i] = INF;
  dp[0] = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j <= k; j++) {
      if (i + j >= n) break;
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      String S = sc.next();
      int K = Integer.parseInt(sc.next());
      
      char c = S.charAt(K-1);
      char[] Slist = S.toCharArray();
      
      for(int i=0; i<N; i++){
        if (Slist[i] != c) Slist[i] = '*';
      }
      String string = new String(Slist);
      System.out.println(string);
    }
}

Measured memory_bytes: 23636
#include<stdio.h>
int main(void)
{
	int a,b;

	scanf("%d %d",&a,&b);

	if(a < b)
	   puts("a < b");
	else if (a > b)
	   puts("a > b");
	else if (a == b)
	   puts("a == b");

	return 0;         
}

Measured memory_bytes: 580
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let v: Vec<_> = s.split(' ').collect();
    for c in v.iter() {
        print!("{}", c.chars().nth(0).unwrap());
    }
    println!();
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

vector<bool> prime;

void prime_table(ll n) {
  prime.resize(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(ll i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(ll j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
}


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

  prime_table(10000010);

  ll n; cin >> n;
  ll cnt = 0;
  FOR(i, 1, n+1) {
    for(int j=i;j<=n;j+=i) {
      cnt += j;
    }
  }
  cout << cnt << endl;

}








Measured memory_bytes: 4492
#include <bits/stdc++.h>
 
using namespace std;
 
//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 SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

LL xs[100010];
LL dfs(VVI& G, int u, int p){
  if(SZ(G[u]) == 1){
	return xs[u];
  }

  LL as = 0;
  vector<LL> ch;
  for(int to: G[u]){
	if(to == p) continue;
	LL tmp = dfs(G, to, u);
	if(tmp < 0) return -1;
	as += tmp;
	ch.PB(tmp);
  }
  LL res = 2*xs[u] - as;
  if(!(0 <= res && res <= xs[u])) return -1;

  SORT(ch);
  if(SZ(ch) == 1){
	return res == as? res: -1;
  }
  
  ch.back() -= res;
  return (xs[u]-res >= ch.back()? res: -1);
}

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

  int N;
  cin >> N;
  REP(i,N) cin >> xs[i];
  VVI G(N);
  REP(i,N-1){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].PB(v);
	G[v].PB(u);
  }
  if(N == 2){
	cout << (xs[0] == xs[1]? "YES": "NO") << endl;
	return 0;
  }

  int r = -1;
  REP(i,N) if(SZ(G[i]) > 1) r = i;

  cout << (dfs(G, r, -1) == 0? "YES": "NO") << endl;
  
  return 0;
}


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

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        for (int i = 1; i <= n; ++i)
        {
            if ((int)(i * 1.08) == n)
            {
                cout << i;
                return 0;
            }
        }
        cout << ":(";
    }
}

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

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

	if(a-b > 0)cout << "a > b" << endl;
	else if (b-a >0)cout << "a < b" << endl;
	else if (a-b ==0)cout << "a == b" << endl;

	return 0;
}

Measured memory_bytes: 1160
def main():
    H, W = map(int, input().split())

    y, x = map(int, input().split())
    start = (x+1, y+1)

    y, x = map(int, input().split())
    goal = (x+1, y+1)

    dist_table = [[-2] * (W+4)]
    dist_table.append([-2] * (W+4))
    for _ in range(H):
        row = '##' + input() + '##'
        row = [-1 if c == '.' else -2 for c in row]
        dist_table.append(row)
    dist_table.append([-2] * (W+4))
    dist_table.append([-2] * (W+4))



    sx, sy = start
    dist_table[sy][sx] = 0

    move1 = ((-1, 0), (1, 0), (0, 1), (0, -1))
    move2 = ((-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),\
            (-1, -2), (-1, -1), (-1, 1), (-1, 2),\
            (0, -2), (0, 2),\
            (1, -2), (1, -1), (1, 1), (1, 2),\
            (2, -2), (2, -1), (2, 0), (2, 1), (2, 2))

    queue1 = [start]
    queue2 = []

    while queue1:
        now_x, now_y = queue1.pop()
        if (now_x, now_y) == goal:
            break
        queue2.append((now_x, now_y))
        dist = dist_table[now_y][now_x]
        for dx, dy in move1:
            tx, ty = now_x + dx, now_y + dy
            if dist_table[ty][tx] == -1:
                dist_table[ty][tx] = dist
                queue1.append((tx, ty))
        if len(queue1) == 0:
            while queue2:
                now_x, now_y = queue2.pop()
                dist = dist_table[now_y][now_x]
                for dx, dy in move2:
                    tx, ty = now_x + dx, now_y + dy
                    if dist_table[ty][tx] == -1:
                        dist_table[ty][tx] = dist + 1
                        queue1.append((tx, ty))
    gx, gy = goal
    print(dist_table[gy][gx])

if __name__ == '__main__':
    main()


Measured memory_bytes: 23064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

const int MOD = 1000000007;
const int INF = 2000000000;
const ll LINF = 1000000000000000L;

ll ds[100000];
ll dt[100000];

struct edge {
    int to, yen, snuke;

    edge(int to, int yen, int snuke) {
        this->to = to;
        this->yen = yen;
        this->snuke = snuke;
    }
};

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;

    vector<edge> g[100000];
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        g[u - 1].pb(edge(v - 1, a, b));
        g[v - 1].pb(edge(u - 1, a, b));
    }

    priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > pqs;
    fill(ds, ds + n, LINF);
    ds[s] = 0;
    pqs.push(mp(0, s));

    while(!pqs.empty()) {
        pair<ll, int> p = pqs.top(); pqs.pop();
        int from = p.second;
        if(ds[from] < p.first) continue;
        for(edge e : g[from]) {
            if(ds[e.to] > ds[from] + e.yen) {
                ds[e.to] = ds[from] + e.yen;
                pqs.push(mp(ds[e.to], e.to));
            }
        }
    }

    priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > pqt;
    fill(dt, dt + n, LINF);
    dt[t] = 0;
    pqt.push(mp(0, t));

    while(!pqt.empty()) {
        pair<ll, int> p = pqt.top(); pqt.pop();
        int from = p.second;
        if(dt[from] < p.first) continue;
        for(edge e : g[from]) {
            if(dt[e.to] > dt[from] + e.snuke) {
                dt[e.to] = dt[from] + e.snuke;
                pqt.push(mp(dt[e.to], e.to));
            }
        }
    }

    ll ans[100000];
    ans[n - 1] = ds[n - 1] + dt[n - 1];
    for(int i = n - 2; i >= 0; i--) {
        ans[i] = min(ans[i + 1], ds[i] + dt[i]);
    }

    rep(i, n) {
        cout << (1000000000000000L - ans[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 11892
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int n = s.length();
    stack<char> st;
    st.push(s[n-1]);
    for (int i = n-2; i >= 0; --i) {
        if (st.empty() || st.top() == s[i]) st.push(s[i]);
        else st.pop();
    }
    cout << n-st.size() << endl;
    return 0;
}

Measured memory_bytes: 512
#Kが3種類なので、分岐を全て書く
#桁数をa、最上位の桁をbとし、その値で場合分け
#最上位が0場合、最上位が0以上b未満の場合(最上位が0は個数も0のため重複されない)、最上位がbで残りのa-1桁でK-1にして再帰
def ans(n,k):
  s=str(n)
  a=len(s)
  b=int(s[0])
  if(k==1):
    return 9*(a-1)+b
  elif(k==2):
    return int(81*(a-1)*(a-2)/2)+9*(b-1)*(a-1)+ans(n-b*10**(a-1),1)
  else:
    return int(729*(a-1)*(a-2)*(a-3)/6)+int(81*(b-1)*(a-1)*(a-2)/2)+ans(n-b*10**(a-1),2)

N=int(input())
K=int(input())
print(ans(N,K))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int k;
    cin >> k;
  	k--;
    int n[32] = {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};
    cout << n[k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
  ll X,Y;
  cin>>X>>Y;
  int ans=0;
  while(1){
     ans++;
     X=X*2;
     if(X>Y) break;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 1e5 + 5;
int arr[N];
int n, m;

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


int main() {
#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    ll lcm = arr[0];
    for (int i = 0; i < n; i++) {
        lcm = LCM(lcm, arr[i]);
        if (lcm > 2 * m) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 2 * m / lcm;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if ((lcm / arr[i]) % 2 == 0) {
            flag = false;
        }
    }

    if (flag)
        cout << (ans + 1) / 2 << endl;
    else
        cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 640
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int x;
    cin >> x;
    int count = x / 100;
    rep(o, count + 1){
        rep(s, count + 1){
            rep(c, count + 1){
                rep(k, count + 1){
                    rep(a, count + 1){
                        int temp = o * 100 + s * 101 + c * 102 + k * 103 + a * 104;
                        int diff = x - temp;
                        if(diff >= 0 && diff % 105 == 0)
                        {
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 384
a, b, x = gets.chomp.split(' ').map(&:to_f)

if x >= a ** 2 * b / 2.0
  puts Math.atan((a ** 2 * b -  x) * 2 / a ** 3) * 180 / Math::PI
else
  puts (Math::PI / 2 - Math.atan(2 * x / (a * b ** 2))) * 180 / Math::PI
end


Measured memory_bytes: 1788
# 全ての頂点について、フェネックからの距離とすぬけくんからの距離を求める
# フェネックからの距離 <= すぬけくんから距離　の頂点は黒　そうでなければ白

import sys
readline = sys.stdin.readline

N = int(readline())
G = [[] for i in range(N)]
for i in range(N - 1):
  a,b = map(int,readline().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)
  
dist_from_fen = [-1 for i in range(N)]
dist_from_snk = [-1 for i in range(N)]

stack = []
# 頂点、距離、親
stack.append([0,0,-1])
while stack:
  v,dist,parent = stack.pop()
  dist_from_fen[v] = dist
  for child in G[v]:
    if child == parent:
      continue
    stack.append([child,dist + 1,v])

stack = []
stack.append([N - 1,0,-1])
while stack:
  v,dist,parent = stack.pop()
  dist_from_snk[v] = dist
  for child in G[v]:
    if child == parent:
      continue
    stack.append([child,dist + 1,v])

black = 0
white = 0
for i in range(N):
  if dist_from_fen[i] <= dist_from_snk[i]:
    black += 1
  else:
    white += 1
print(("Snuke","Fennec")[black > white])

Measured memory_bytes: 29156
import math
n=int(input())
d=math.floor(math.log(1+(26-1)*n,26))
p=int(n-(26**d-1)/(26-1))
t=list('a'*d)
for i in range(d):
    t[d-i-1]=chr(ord(t[d-i-1])+(p%26))
    p=p//26
print(''.join(t))

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define tc() long long int t; cin>>t; while(t--)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<long long>
#define mi map<int, int>
#define mll map<long long, long long>
#define mc map<char, int>
#define si set<int>
#define pb push_back
#define eb emplace_back
#define sz size()
#define fi first
#define se second
#define mk make_pair
#define MOD 1000000007
#define INF 1e9+1
#define FI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define GCD(ll a,ll b) ll gcd(ll a,ll b){if(b==0){return a;} return gcd(b,b%a)}
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) 

void IO(){

	#ifndef OJ
	freopen("C:/Users/KIIT/GITHUB/input.txt","r",stdin);
	freopen("C:/Users/KIIT/GITHUB/output.txt","w",stdout);
	#endif
}

void solve(){

	ll n;cin>>n;
	ll x = 0;
	while(x<n){
		x = x+1000;
	}
	cout<<x-n;
}

int main(){

	FI;
  	//IO();

	solve();
	// tc(){
		
	// 	solve();

	// }

	return 0;
}

Measured memory_bytes: 3648
#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 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 llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-12;
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();}
//AGCばちゃ 1700~
int main(void){
	int n,i,j,ans=-9999;cin>>n;
	vector<bitset<200>>hen(n);
	for(i=0;i<n;i++){
		string s;cin>>s;
		for(j=0;j<n;j++){
			if(s[j]=='1'){hen[i][j]=1;}
		}
	}
	for(i=0;i<n;i++){
		//スタート地点
		bitset<200>mae;mae[i]=1;
		bitset<200>used;used[i]=1;
		int gen=1;
		while(-1){
			bitset<200>now={};
			for(j=0;j<n;j++){
				if(used[j]){continue;}
				if((mae&hen[j]).count()){now[j]=1;}
			}
			//for(j=0;j<n;j++){cerr<<now[j]<<" ";}cerr<<endl;
			for(j=0;j<n;j++){
				if(!now[j]){continue;}
				if((now&hen[j]).count()){cout<<-1<<endl;return 0;}
			}
			
			if(now.count()==0){break;}
			gen++;used|=now;
			mae=now;
		}
		maxeq(ans,gen);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    string t;
    cin >> t;
    for (int i = 0; i < (int)t.length(); i++) {
        if (t[i] == '?') t[i] = 'D';
    }

    cout << t << endl;
}


Measured memory_bytes: 3724
fn main() {
  let (_, a, b): (usize, i64, i64) = read_tuple();
  let vec: Vec<i64> = read_vec();
  
  let ans: i64 = vec.windows(2).fold(0, |acc,w| acc + std::cmp::min((w[1]-w[0])*a, b));
  println!("{}", ans);
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr>() -> (T1, T2, T3) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  let z = it.next().unwrap().parse::<T3>().ok().unwrap();
  (x, y, z)
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
#define pll pair<LL,LL>
using namespace std;
const int N=360;
const LL mod=1e9+7;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
	freopen("wash.in","r",stdin);
	freopen("wash.out","w",stdout);
}
int T,n;
LL K,A[N],B[N],C[N],D[N],ans;
struct node
{
	LL B,C;
	node(){}
	node(LL B,LL C):B(B),C(C){}
}a[N];
inline bool operator<(const node&x,const node&y){return x.C==y.C?x.B<y.B:x.C<y.C;}
map<vector<LL>,vector<pll>>mp;
map<vector<LL>,vector<pll>>::iterator it;
int main()
{
		ans=0;mp.clear();
		read(n),read(K);
		For(i,1,n)read(A[i]);
		for(LL x=0;x<=60;x++)
		{
			For(i,1,n)a[i]=node(A[i]/(1ll<<x),A[i]&((1ll<<x)-1));
			sort(a+1,a+n+1);
			For(i,1,n)
			{
				int cnt=x;
				LL L=i==1?0:a[i-1].C+1,R=a[i].C;
				if(L>R)continue;
				rFor(j,60,0)
				{
					LL x=L&(1ll<<j),y=R&(1ll<<j);
					if(x^y){if(L&((1ll<<j)-1))cnt++;break;}
					if(x)cnt++;
				}
				int flag=1;
				For(i,1,n)
				{
					if(!a[i].B&&a[i].C<L){flag=0;break;}
					D[i]=a[i].B-(a[i].C<L);
				}
				if(!flag||cnt>K)continue;
				sort(D+1,D+n+1);
				vector<LL>now;
				For(i,2,n)now.pb(D[i]-D[i-1]);
				mp[now].pb(pll(max(0ll,D[1]-(K-cnt)),D[1]));
			}
		}
		for(auto it:mp)
		{
			vector<pll>now=it.second;
			sort(now.begin(),now.end());
			pll ret=now[0];
			For(i,0,SZ(now)-1)
			{
				if(ret.second<now[i].first)
					ans=(ans+ret.second-ret.first+1)%mod,ret=now[i];
				chkmax(ret.second,now[i].second);
			}
			ans=(ans+ret.second-ret.first+1)%mod;
		}
		printf("%lld\n",ans);
	return 0;
}


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

def isPrime(n) : 
  
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    # This is checked so that we can skip  
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True

if N<=9:
  print("Yes")
elif ( N == 50 or N ==60 or N == 70 or N == 80 or isPrime(N) or N>81):
  print("No")
else:
  i = 2
  while(i<=9):
    if N%i == 0 and 1<=N/i <= 9:
      print("Yes")
      break
    else:
      if i == 9:
        print("No")
        break
      else:
        i = i + 1

  


Measured memory_bytes: 3064
from collections import Counter

c = Counter()  

N = int(input())
for x in input().split():
    c[int(x)] += 1

A_uniq = sorted(c.keys())

def gen_candiate(seq):
    s = set()
    for n in seq:
        s.add(n-1)
        s.add(n)
        s.add(n+1)
    return sorted(s)

#print(gen_candiate(A_uniq))

result = 0
for n in gen_candiate(A_uniq):
    tmp = c.get(n-1, 0) + c.get(n, 0) + c.get(n+1, 0)
    if tmp > result:
        result = tmp

print(result)


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int x;
    cin >> x;
    if (x == 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n, y;cin>>n>>y;
  y /= 1000;
  bool ans=false;
  int a, b, c; // 10, 5, 1
  for(a=0;a<=y/10;a++){
  	for(b=0;b<=(y-a*10)/5;b++){
      if(a+b+(y-a*10-b*5)==n){c=(y-a*10-b*5);ans=true;break;}
    }
    if(ans)break;
  }
  if(ans)cout<<a<<" "<<b<<" "<<c<<endl;
  else cout<<"-1 -1 -1"<<endl;
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,k,s;
    cin>>n>>k>>s;

    vector<ll> ans(n, s);

    ll x = 1000000000;
    if(x == s) x--;

    for(int i = k; i < n; i++) {
        ans[i] = x;
    }

    for(int i = 0; i < n ;i++) {
        cout<<ans[i]<<" ";
    }

    cout<<endl;


}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll a, b;
  cin >> a >> b;
  if(a>b){
    cout << 2 * a - 1 << endl;
  }
  else if(a==b){
    cout << 2 * a << endl;
  }
  else{
    cout << 2 * b - 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n;
	cin >> n;
	int ans = 0;
	rep0(i,n){
		int x;
		cin >> x;
		if(i%2==0 && x%2==1) ans++;
	}
	cout << ans;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3788
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  
  int k;
  cin >> k;
  
  if(k >= e-a)
    cout << "Yay!" << endl;
    else
    cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 30
int F[MAX+1];

main(){
    F[0] = 1;
    F[1] = 1;
    F[2] = 2;
    for ( int i = 3; i <= MAX; i++ ) F[i] = F[i-3] + F[i-2] + F[i-1];

    int n;
    while( cin >> n && n ){
	int p = F[n]/10;
	if ( F[n]%10 ) p++;
	int pp = p/365;
	if ( p%356) pp++;

	cout <<  pp << endl;
    }
}

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

const int N_MAX = 50;

long long n, k;
long long ans;
long long len[N_MAX + 2];

long long solve(int n, long long k) {
    if(n == 0)
        return 1;
    if(k == 1)
        return 0;

    long long med = (len[n] / 2 + 1);

    if(k == med)
        return (1LL << n);
    else if(k < med)
        return solve(n - 1, k - 1);
    else
        return (1LL << n) + solve(n - 1, k - 2 - len[n - 1]);
}

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

    len[0] = 1;
    for(int i = 1; i <= N_MAX; i++)
        len[i] = 3 + 2 * len[i - 1];

    cout << solve(n, k) << '\n';

    return 0;
}
// BBPPPBPBPPPBB 7776544332100
// BPPPB


Measured memory_bytes: 256
x, y = gets.split.map &:to_i

sum = 0

if x == 3 then
	sum += 100000
elsif x == 2 then
	sum += 200000
elsif x == 1 then
	sum += 300000
end

if y == 3 then
	sum += 100000
elsif y == 2 then
	sum += 200000
elsif y == 1 then
	sum += 300000
end

if x == 1 && y == 1 then
	sum += 400000
end

puts sum


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cassert>
using namespace std;

bool isLighting(int bit, int s, int p)
{
  int c = 0;
  for(int i = 0; i < 10; ++i){
    if((bit & s & (1 << i)))
      c++;
  }
  return (c % 2) == p;
}

bool test(int bit, const vector<int> &ss, const vector<int> &ps)
{
  assert(ss.size() == ps.size());
  for(int i = 0; i < ss.size(); ++i){
    if(!isLighting(bit, ss[i], ps[i]))
      {
        return false;
      }
  }
  return true;
}


int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> ss;
  for(int i = 0; i < m; ++i){
    int k;
    cin >> k;
    int v = 0;
    for(int j = 0; j < k; ++j){
      int s;
      cin >> s;
      v |= 1 << (s - 1);
    }
    ss.push_back(v);
  }
  vector<int> ps;
  for(int i = 0; i < m; ++i){
    int p;
    cin >> p;
    ps.push_back(p);
  }
  int count = 0;
  for(int i = 0; i < 1 << n; ++i)
    {
      if(test( i, ss, ps)){
        count ++;
      };
    }
  cout << count << endl;
}


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

#define N 100005

int n,m,Query,a[N];
struct SegementTree{
	int l,r,sum;
}Tree[N<<2];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	cin>>a[1]>>a[2]>>a[3];
}

int main(){
	init();
	sort(a+1,a+4);
	cout<<a[3]-a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
from collections import defaultdict
import math
import copy
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
n = int(input())
a = set()
for i in range(n):
        x,y = map(int,input().split())
        a.add((x,y))
b = list(a)
c = copy.deepcopy(b)
c.sort()
ans = 500
for i in range(n):
        for j in range(n):
                a = copy.deepcopy(c)
                x = b[i][0] - b[j][0]
                y = b[i][1] - b[j][1]
                tmp = 0
                while a:
                        f,g = a.pop()
                        while (f-x,g-y) in a:
                                a.remove((f-x,g-y))
                                f = f-x
                                g = g-y
                        tmp += 1
                ans = min(ans,tmp)
print(ans)
                        

Measured memory_bytes: 58200
N = int(input())
R = list(map(int, input().split()))
ans = []

for j in range (1, 100):
    diff = 0
    sum = 0
    
    for i in range (N):
        diff = pow(R[i] - j, 2)
        sum += diff
    
    ans.append(sum)

print(min(ans))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var Hs = new List<int>();
            var Ws = new List<int>();
            var temp = new int[2];
            while (true)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (temp[0] == 0 && temp[1] == 0)
                    break;
                Hs.Add(temp[0]);
                Ws.Add(temp[1]);
            }
            for (var i = 0; i < Hs.Count; i++)
            {
                for (var h = 0; h < Hs[i]; h++)
                {
                    if ((h%2)==0)
                    {
                        for (var w = 0; w < Ws[i]; w++)
                        {
                            if((w%2)==0)
                                Console.Write("#");
                            else
                                Console.Write(".");

                        }
                    }
                    else
                    {
                        for (var w = 0; w < Ws[i]; w++)
                        {
                            if((w%2)==0)
                                Console.Write(".");
                            else
                                Console.Write("#");

                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
            
        }


    }
}
    

Measured memory_bytes: 5656
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[500005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[500005];

int main(){
    cin >> n;
	map<ll,ll> kazu;
	for(i=0;i<n;i++){
		cin >> x[i];
		kazu[x[i]]++;
	}
	sort(x,x+n);
	reverse(x,x+n);
	for(i=0;i<n;i++){
		//pe(x[i]);p(kazu[x[i]]);
		if(kazu[x[i]] <= 0)continue;
		for(j=32;j>=0;j--){
			num = (1ll << j);
			//p(num);
			if(num < x[i])break;
			if(num == x[i] * 2){
				if(kazu[x[i]] >= 2){
					kazu[x[i]] -= 2;
					ans++;
					break;
				}
			}else{
				if(kazu[num - x[i]] >= 1){
					kazu[x[i]]--;
					kazu[num-x[i]]--;
					ans++;
					break;
				}
			}
		}
	}
	
	p(ans);
    return 0;
}

Measured memory_bytes: 92032