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

const int MOD = static_cast<int>(1e9 + 7);

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

    string S;
    cin >> S;
    unsigned long n = S.size();
    long long dp[100001][4] = {};  // { all, A, AB, ABC }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 4; ++j) {
            dp[i + 1][j] += dp[i][j] * (S[i] ==  '?' ? 3 : 1);
            dp[i + 1][j] %= MOD;
            if (j < 3 && (S[i] ==  '?' || S[i] == "ABC"[j] )) {
                dp[i + 1][j + 1] += dp[i][j];
            }
        }
    }

    cout << dp[n][3] << '\n';

    return 0;
}


Measured memory_bytes: 3664
def main():
    H, W = map(int, input().split())
    s = [input() for _ in range(H)]
    ctr = [[0] * W for _ in range(H)]
    for r, row in enumerate(s):
        for c, cell in enumerate(row):
            if cell == '#':
                for dr in (-1, 0, 1):
                    for dc in (-1, 0, 1):
                        if 0 <= r + dr < H and 0 <= c + dc < W and s[r + dr][c + dc] == '.':
                            ctr[r + dr][c + dc] += 1
    for r in range(H):
        for c in range(W):
            print('#' if s[r][c] == '#' else ctr[r][c], end='')
        print()


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3444
h,w = map(int,input().split())
ch,cw = map(int,input().split())
ch -= 1
cw -= 1
dh,dw = map(int,input().split())
dh -= 1
dw -= 1
s = [input() for i in range(h)]

cost = [[-1]*w for i in range(h)]

from collections import deque
q = [[0,ch,cw]]
q = deque(q)

ans = -1
while q:
    cnt,cx,cy = q.popleft()
    if cost[cx][cy]<0:
        cost[cx][cy]=cnt
        for dx in range(-2,3):
            for dy in range(-2,3):
                if 0<=cx+dx<h and 0<=cy+dy<w and s[cx+dx][cy+dy]=='.':
                    if cost[cx+dx][cy+dy]<0:
                        if [dx,dy] in [[1,0],[-1,0],[0,1],[0,-1]]:
                            q.appendleft([cnt,cx+dx,cy+dy])
                        else:
                            q.append([cnt+1,cx+dx,cy+dy])

print(cost[dh][dw])


Measured memory_bytes: 172296
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 





int main()
{
     int n;
     cin>>n;
     int a[]={1, 6, 9, 36, 81, 216, 729, 1296, 6561,  7776, 46656, 59049};
     int dp[100005];
     for(int i=0;i<=100000;i++)dp[i]=i;
     for(int i=1;i<=n;i++){
          for(int j=0;j<12;j++){
               if(i>=a[j]){
                    dp[i]=min(dp[i],dp[i-a[j]]+1);
               }
          }
     }
     cout<<dp[n];
}




































Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int maxn = 1e5 + 50;
const ll mod = 1e9+7;
int n;
ll dp[maxn][2];// b:0 w:1
bool vis[maxn];
vector<int> G[maxn];
vector<int> g[maxn];
int dfs(int root, int color){
    if(dp[root][color]) return dp[root][color];
    if(G[root].empty()){
        dp[root][color] = dp[root][1-color] = 1;
        return dp[root][color];
    }
    if(color == 1)//white
    {
        dp[root][1] = 1;
        for(int i = 0; i < G[root].size(); i++){
            dp[root][1] = dp[root][1] * (dfs(G[root][i], 0) + dfs(G[root][i], 1)) % mod;
    /*        dp[root][1] = (dp[root][1] + 
                dfs(G[root][i],0) + dfs(G[root][i],1)) % mod;*/
        }
    }
    else{//black
        dp[root][0] = 1;
        for(int i = 0; i < G[root].size(); i++)
            dp[root][0] = dp[root][0] * dfs(G[root][i], 1) % mod;
//              if(dfs(G[root][i], 1))
//            dp[root][0] = (dp[root][0] + dfs(G[root][i],1)) % mod;
    }
    return dp[root][color];
}
void dfs2(int u){
    vis[u] = true;
    for(int i = 0; i < g[u].size(); i++){
        if(!vis[g[u][i]]){
            G[u].pb(g[u][i]);
            dfs2(g[u][i]);
        }
    }
}
int main(){
    scanf("%d", &n);
    int x, y;
    for(int i = 1; i < n; i++) {
        scanf("%d%d", &x, &y);
        g[x].pb(y);
        g[y].pb(x);
    }
    memset(vis, false, sizeof(vis));
    dfs2(1);
    printf("%lld\n", (dfs(1, 0) + dfs(1, 1))%mod);
    return 0;
}

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

const ll mod = 1000000007;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
}
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll divide(ll a, ll b, ll m) {
    a %= m;
    return a * modinv(b, m) % m;
}

ll comb(ll n, ll r, ll m) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        n %= m;
        ans *= i;
        ans %= m;
    }
    for (int j = 1; j <= r; ++j) {
        ans = divide(ans, j, m);
    }
    return ans;
}

ll modpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}


int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod);
    ans--;
    ans -= comb(n, a, mod);
    ans += mod;
    ans %= mod;
    ans -= comb(n, b, mod);
    ans += mod;
    ans %= mod;
    cout << ans << endl;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> l(2*n);
    for(int i = 0; i < 2 * n; ++i){
        cin >> l[i];
    }
    sort(begin(l), end(l));
    int ans = 0;
    for(int i = 0; i < 2 * n; i += 2){
        ans += l[i];
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll k; cin >> k;
	queue<ll>q;
	for(int i=1; i<=9; i++)q.push(i);
	while(k>1){
		ll x = q.front(); q.pop();
		if(x%10!=0)q.push(10*x+x%10-1);
		q.push(10*x+x%10);
		if(x%10!=9)q.push(10*x+x%10+1);
		k--;
	}
	cout << q.front() << endl;
}	
/*  Benq's (modified)
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

const int SZ = 1e5;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        fill_n(b, N + 1, true);
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int_fast64_t j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

// BIT(Binary-Indexed-Tree) 別名：Fenwick Tree
template <typename T> struct BIT {
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    // 要素iにxを加算
    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    // 区間[0, i]の合計を求める（閉区間）
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    BIT<int> bit(SZ);
    for (int i = 1; i < SZ; i += 2) {
        if (prime.b[i] && prime.b[(i + 1) / 2]) {
            bit.add(i, 1);
        }
    }
    int Q;
    cin >> Q;
    while (Q--) {
        int l, r;
        cin >> l >> r;
        cout << bit.sum(r) - bit.sum(l - 1) << "\n";
    }

    return 0;
}


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

map<char, string> table = {
    {'A', "00000"},
    {'B', "00001"},
    {'C', "00010"},
    {'D', "00011"},
    {'E', "00100"},
    {'F', "00101"},
    {'G', "00110"},
    {'H', "00111"},
    {'I', "01000"},
    {'J', "01001"},
    {'K', "01010"},
    {'L', "01011"},
    {'M', "01100"},
    {'N', "01101"},
    {'O', "01110"},
    {'P', "01111"},
    {'Q', "10000"},
    {'R', "10001"},
    {'S', "10010"},
    {'T', "10011"},
    {'U', "10100"},
    {'V', "10101"},
    {'W', "10110"},
    {'X', "10111"},
    {'Y', "11000"},
    {'Z', "11001"},
    {' ', "11010"},
    {'.', "11011"},
    {',', "11100"},
    {'-', "11101"},
    {'\'', "11110"},
    {'?', "11111"}
};
map<string, char> table2 = {
    {"100101", 'A'},
    {"10011010", 'B'},
    {"0101", 'C'},
    {"0001", 'D'},
    {"110", 'E'},
    {"01001", 'F'},
    {"10011011", 'G'},
    {"010000", 'H'},
    {"0111", 'I'},
    {"10011000", 'J'},
    {"0110", 'K'},
    {"00100", 'L'},
    {"10011001", 'M'},
    {"10011110", 'N'},
    {"00101", 'O'},
    {"111", 'P'},
    {"10011111", 'Q'},
    {"1000", 'R'},
    {"00110", 'S'},
    {"00111", 'T'},
    {"10011100", 'U'},
    {"10011101", 'V'},
    {"000010", 'W'},
    {"10010010", 'X'},
    {"10010011", 'Y'},
    {"10010000", 'Z'},
    {"101", ' '},
    {"010001", '.'},
    {"000011", ','},
    {"10010001", '-'},
    {"000000", '\''},
    {"000001", '?'}
};

int main() {
    string s;
    while (getline(cin, s)) {
        string s2 = "";
        for (char c : s) {
            s2 += table[c];
        }
        string s3 = "", tmp = "";
        for (char c : s2) {
            tmp += c;
            if (table2.find(tmp) != table2.end()) {
                s3 += table2[tmp];
                tmp = "";
            }
        }
        cout << s3 << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  int palindromeCount = 0;	//Palindrome：回文数
  
  //AからB回繰り返す
  for(int i = A; i <= B; i++){
    //5桁    
    //割って数字を取得
    int digitCount = 0;
    int remainder = i;
    int compare = 0;
    for(int j = 10000; j > 0; j /= 10){
      int digits = 1;
      digitCount++;
      for(int k = 1; k < digitCount; k++){
        digits *= 10;
      }
      
      if(!(digitCount == 5 && remainder == 0)){
        compare += remainder / j * digits;
      	remainder = i % j;
      }else{
        compare = 0;
      }
    }
    if(i == compare) palindromeCount++;
  }
  //出力
  cout << palindromeCount << endl;
}

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

int main(){
	int n;
	int t=0,x=0,y=0;
	
	cin >> n;
	
	for(int i=1;i<=n;i++){
		int tt,xx,yy;
		cin >> tt >> xx >> yy;
		
		int tmp=abs(xx-x)+abs(yy-y);
		if(tmp>tt-t){
			cout << "No" << endl;
			return 0;
		}
		if(tmp%2!=(tt-t)%2){
			cout << "No" << endl;
			return 0;
		}
		t=tt;x=xx;y=yy;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int N=11111;
    vector<int> ps(N);
    rep(i,N)ps[i]=i;
    ps[0]=ps[1]=0;
    for(int i=2;i<N;i++){
        if(!ps[i])continue;
        for(int j=i+i;j<N;j+=i){
            ps[j]=0;
        }
    }
    ps.erase(remove(ps.begin(),ps.end(),0),ps.end());
    int sum[11111]={};
    rep(i,ps.size()){
        sum[i+1]=sum[i]+ps[i];
    }

    int cnt[11111]={};
    rep(i,ps.size())rep(j,i){
        if(sum[i]-sum[j]>11111)continue;
        cnt[sum[i]-sum[j]]++;
    }
    int n;
    while(cin>>n && n) cout << cnt[n] << endl;
}

Measured memory_bytes: 1328
h, w, k = gets.chomp.split.map(&:to_i)

f = []
h.times do
  f.push(gets.chomp.chars)
end

total = 0
hcnt = []
f.each do |fi|
  temp = fi.tally
  temp.default = 0
  hcnt.push(temp["#"])
end
total = hcnt.sum

wcnt = []
(w).times do |wi|
  wtemp = 0
  (h).times do |hi|
    wtemp += 1 if f[hi][wi] == '#'
  end
  wcnt.push(wtemp)
end

cnt = 0
# 2^(h+w) loop
# status = (hhhhhwwwww)_2
(2**(h+w)).times do |s|
  # sからbitが立っている桁を取る
  black = total
  h_i = []
  w_i = []
  (h+w).times do |i|
    if s & 2**i == 2**i
      if i < w
        black -= wcnt[i]
        w_i.push(i)
      else
        black -= hcnt[i-w-1]
        h_i.push(i-w-1)
      end
    end
  end

  prod = h_i.product(w_i)
  prod.each do |hi, wi|
    black += 1 if f[hi][wi] == '#'
  end
  cnt += 1 if black == k
end

p cnt

Measured memory_bytes: 14348
#include<cstdio>
using namespace std;
#define N 1050000
#define mod 1000000007
int dp[N][2],n,s[N],las[N],k=20,sn;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&s[i]);
	for(int i=0;i<1<<k;i++)dp[i][0]=1;
	for(int i=1;i<n;i++)
	{
		s[i]^=s[i-1];
		dp[s[i]][0]=(dp[s[i]][0]+1ll*dp[s[i]][1]*(sn-las[s[i]]))%mod;
		dp[s[i]][1]=(dp[s[i]][1]+dp[s[i]][0])%mod;
		las[s[i]]=sn;
		if(s[i]==0)sn++;
	}
	s[n]^=s[n-1];
	if(s[n])
	{
		int ans=0;
		dp[s[n]][0]=(dp[s[n]][0]+1ll*dp[s[n]][1]*(sn-las[s[n]]))%mod;
		printf("%d\n",dp[s[n]][0]);
	}
	else
	{
		int ans=0;
		for(int i=1;i<1<<k;i++)
		ans=(ans+dp[i][1])%mod;
		int tp=1;
		for(int i=1;i<=sn;i++)tp=tp*2%mod;
		printf("%d\n",(ans+tp)%mod);
	}
}

Measured memory_bytes: 14464
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                           
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
const ll N=1000008;

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

  ll n;
  cin>>n;
  if(n==1)
  {
    cout<<"Hello World";
  }  
  else{
    ll a,b;
    cin>>a>>b;
    cout<<a+b;
  }
  return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int ans = 2e9;
	for(int i=0;i<=max(x,y)*2;i+=2){
		int tmp = c*i;
		if(x-i/2>0) tmp += a*(x-i/2);
		if(y-i/2>0) tmp += b*(y-i/2);
		chmin(ans,tmp);
	}
	cout<<ans<<endl;
}


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

ll n, a[100005], b[100005], ans;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[n - 1 - i] >> b[n - 1 - i];
    }
    for(int i = 0; i < n; i++){
        ll mult;
        mult = (ans + a[i] + b[i] - 1) / b[i];
        ll sa = b[i] * mult - a[i] - ans;
        ans += sa;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
#define printmatrix(a,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
//#define int long long

/*/-----------------------------Code begins----------------------------------/*/
int main(){
int n;
cin>>n;
int a[n],b[n],c[n];
For(i,0,n){
cin>>a[i]>>b[i]>>c[i];}
int dp[n][3];
dp[0][0]=a[0];
dp[0][1]=b[0];
dp[0][2]=c[0];
for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
            if(j==0)
        dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+a[i];
    else if(j==1)
        dp[i][j]=max(dp[i-1][j-1],dp[i-1][j+1])+b[i];
    else dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+c[i];
    }
}
cout<<max3(dp[n-1][0],dp[n-1][1],dp[n-1][2]);
}




















Measured memory_bytes: 2560
'use strict'

const main = (input) => {
    input = input.split('\n')
    const N = parseInt(input[0])
    const A = input[1].split(' ').map(v => parseInt(v))
    let obj = {}
    A.forEach(v => {
        if(typeof obj[v] === 'undefined'){
            obj[v] = 0
        }
        obj[v]++
    })
    let count = 0
    for(let key in obj){
        let k = parseInt(key)
        let c = obj[key]
        if(k < c){
            count += c - k
        }
        if(k > c){
            count += c
        }
    }
    console.log(count)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 39804
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int ans=1,n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	  ans+=min(ans,k);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

bool isSame(vector<int> a, vector<int> b) {
    for(int i = 0; i < a.size(); i++) {
        if(a[i] != b[i])
            return false;
    }
    return true;
}

int main(){
    int n; cin >> n;
    vector<int> v(n);
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) {
        v[i] = i+1;
    }
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }
    int nump, numq;
    int count = 1;
    do {
        if(isSame(v,p))
            nump = count;
        if(isSame(v,q))
            numq = count;
        count++;
    } while(next_permutation(v.begin(), v.end()));
    cout << abs(nump-numq) << endl;
}


Measured memory_bytes: 256
N, K = [int(element) for element in input().split(" ")]

if N < K:
    if abs(N - K) < N:
        print(abs(N - K))
        
    else:
        print(N)

else:
    if (N % K) == 0:
        print(abs(N % K))

    else:
        if abs((N % K) - K) < (N % K):
            print(abs((N % K) - K))

        else:
            print(abs(N % K))

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

int main(){
	// sengen
	int h,w;
	// nyuryoku
	cin >> h >> w;
	char s[h][w];
	int count = 0;
	int dist[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s[i][j];
			dist[i][j] = -1;
			if(s[i][j] == '.'){
				count++;
			}
		}
	}
	int dx[4] = {-1,1,0,0};
	int dy[4] = {0,0,-1,1};
	// keisan
	queue<pair<int,int>> que;
	que.push(pair<int,int> (0,0));
	dist[0][0] = 1;
	while(!que.empty()){
		pair<int,int> now = que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx = now.first + dx[i];
			int ny = now.second + dy[i];
			if(nx<0 || ny<0 || nx>h-1 || ny>w-1) continue;
			if(s[nx][ny] == '#') continue;
			if(dist[nx][ny] == -1){
				dist[nx][ny] = dist[now.first][now.second] +1;
				que.push(pair<int,int>(nx,ny));
			}
		}
	}
	// syutsuryoku
	if(dist[h-1][w-1] == -1){
		cout << "-1";
	}else{
		cout << count - dist[h-1][w-1];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool b[105];
int main()
{
	int x,n,a;
	cin>>x>>n;
	for(int t=0;t<n;t++)
	{
		cin>>a;
		b[a]=1;
	}
	for(int t=0;;t++)
	{
		if(b[x-t]==0)
		{
			cout<<x-t;
			return 0;
		}
		if(b[x+t]==0)
		{
			cout<<x+t;
			return 0;
		}
	}
} 

Measured memory_bytes: 3636
$Q = <STDIN>-0;
@P=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317);
$S[5]=1;$s=1;
for($i=5;$i<=100000;$i+=4){
	$f=1;
	$ii=($i+1)/2;
	for($j=0;$P[$j]*$P[$j]<=$ii;$j++){
		if($ii%$P[$j]==0) { $f=0; last; }
		if($i%$P[$j]==0) { $f=0; last;}
	}
	if ($f) {
		for(;$P[$j]*$P[$j]<=$i;$j++){
			if($i%$P[$j]==0) { $f=0; last;}
		}
		$s=$s+1 if ($f);
	}
	$S[$i+2]=$s;
	$S[$i+4]=$s;
}

for($i=$Q;$i>0;$i--){
	my ($l,$r)=map { $_ - 0 } split / /,<STDIN>;
	print $S[$r+2]-$S[$l],"\n";
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
  int a[3];
  for(int i=0; i<3; i++) cin >> a[i];

  int ans=0;
  sort(a, a+3);
  for(int i=a[2]; ; i++){
    int sum=0;
    for(int j=0; j<3; j++) {
      sum += i-a[j];
    }

    if(sum % 2 == 0){
      ans = sum/2;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char ** argv){
    int A, B;
    cin >> A >> B;
    int aa = A + ((A == 0) ? 0 : A-1);
    int ab = A + B;
    int bb = B + ((B == 0) ? 0 : B-1);
    cout << max(aa, max(ab, bb));
    return 0;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = [0 for i in range(N)]
xy = [[] for i in range(N)]
value = [[] for i in range(N)]
for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        x,y = LI()
        x -= 1
        xy[i].append([x,y])

def make2digits(n):
    digits = [0 for i in range(N)]
    i = 0
    while n > 0:
        digits[i] = n % 2
        n = n // 2
        i += 1
    return digits

def check(digits, xy):
    for i in range(N):
        if digits[i] == 1:
            for signal in xy[i]:
                if digits[signal[0]] == signal[1]:
                    pass
                else:
                    return False
    return True
ans = -1
for i in range(2**N):
    digits = make2digits(i)
    if check(digits, xy):
        ans = max(ans, sum(digits))

print(ans)


Measured memory_bytes: 70360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, a, b;
  cin >> n >> a >> b;
  int count = 0;
  auto f = [&](int c) {
    int digit = 0;
    while(c > 0) {
      digit += c % 10;
      c = c / 10;
    }
    return digit;
  };
  for(int i = 1; i <= n; i++) {
    if(f(i) >= a && f(i) <= b) {
      count += i;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}



int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll>f(n + 1);
	//vector<ll>f_inv(n + 2);
	f[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		f[i] = f[i - 1] + i;
		f[i] %= mod;
	}
	ll ans = 1;
	for (int i = k; i <= n; i++) {
		ll add = (f[n] - f[n - i]) % mod;
		if (add < 0)add += mod;
		add -= f[i - 1] -1;
		if (add < 0)add += mod;
		add %= mod;
		ans += add;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4840
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

int isprime(lint x) {
	//xが素数:1,xが素数でない:0
	if (x == 2) {
		return 1;
	}
	else if (x == 1 || x % 2 == 0) {
		return 0;
	}
	else {
		lint i = 3;
		while (i * i <= x) {
			if (x % i == 0) {
				return 0;
			}
			i += 2;
		}
		return 1;
	}
}

/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N, K, R, S, P, cntr=0, cnts=0, cntp=0;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	vector<char>V(N);
	rep(i, N) {
		if (T[i]=='r'&&(i - K < 0||V[i-K]!='R')) {
			V[i] = 'R';
			cntr++;
		}
	}
	rep(i, N) {
		if (T[i] == 's' && (i - K < 0 || V[i - K] != 'S')) {
			V[i] = 'S';
			cnts++;
		}
	}
	rep(i, N) {
		if (T[i] == 'p' && (i - K < 0 || V[i - K] != 'P')) {
			V[i] = 'P';
			cntp++;
		}
	}
	cout << cntr * P + cnts * R + cntp * S << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,m,pos[100010],p[100010],to[100010],w[100010],ans[100010];
long long u[100010],k;
bool v[100010];
int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int o[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&pos[i]);
	for(int i=1;i<n;++i) p[i]=i;
	scanf("%d",&m); scanf("%lld",&k);
	for(int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		swap(p[x-1],p[x]);
	}
	for(int i=1;i<n;i++) to[p[i]]=i;
	for(int i=1;i<n;i++)
	{
		if(v[i]) continue;
		v[i]=1;
		int cnt=1; o[cnt]=i;
		for(int j=to[i];j!=i;j=to[j])
		{
				v[j]=1;
				o[++cnt]=j;
		}
		int yy=k%cnt;
		for(int j=1;j<=cnt;j++) {
			ans[o[j]]=o[(j+yy)>cnt?j+yy-cnt:j+yy];
		}
	}
	for(int i=1;i<n;++i) w[ans[i]]=i;
	u[n]=pos[n];
	
	for(int i=n-1;i>=1;i--) u[i]=u[i+1]-pos[w[i]+1]+pos[w[i]];
	for(int i=1;i<=n;i++) printf("%lld\n",u[i]);
	return 0;
}

Measured memory_bytes: 4480
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            int x = int.Parse(a[0]);
            int y = int.Parse(a[1]);
            Console.WriteLine((x * y) + " " + (2 * (x + y)));
        }
    }
}

Measured memory_bytes: 9124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;
const int maxn=100+10;
int n;
vector<int> g[maxn];
int s[maxn],e[maxn];
int vis[maxn];
int t=1;
void dfs(int u)
{
    vis[u]=1;
    s[u]=t++;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(!vis[v])
        {
            dfs(v);
        }
    }
    e[u]=t++;
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int no,cnt,dd;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&no,&cnt);
        for(int j=0;j<cnt;j++)
        {
            scanf("%d",&dd);
            g[no-1].push_back(dd-1);
        }
    }
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++)
    {
        if(!vis[i])   dfs(i);
    }
    for(int i=0;i<n;i++)
    {
        printf("%d %d %d\n",i+1,s[i],e[i]);
    }
    return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll A,B,C,D;

ll gcd(ll a,ll b){
  return b==0?a:gcd(b,a%b);
}

ll f(ll x){
  ll tmp=x/C;
  tmp+=x/D;
  ll z=gcd(C,D);
  z=C*D/z;

  tmp-=x/z;
  return tmp;
}

int main(){
  cin>>A>>B>>C>>D;

  cout<<B-A+1-(f(B)-f(A-1))<<endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  string s;
  cin>>s;
  if (n%2 == 1) dame;
  if (s.substr(n/2) != s.substr(0,n/2)) dame;
  cout<<"Yes"<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)
 
#define LL long long
#define Ldouble long double
 
using namespace std;
 
char s[19];
 
int len;
 
int main(){
  cin.getline(s, 19);
  len = strlen(s);
  if (len >= 4){
    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m=0,tmp=1,ax=0,k=0,t[500000],x,y,res=0,a,b,c,GCD,two=1,kisuu=0,p,q,r,type=0;
	string str, str2[5000];
	cin>>n;
	

	for (int i =0; i <3*n; i++) {
		cin >> t[i];
		
	}
	sort(t, t + 3 * n);
	for (int i = 0; i < n; i++) {
		res += t[3 * n - 2 * i - 2];
		

	}
	cout << res;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};



#define pb push_back
#define F first
#define S second
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define gap ' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///

 int main()
 { ll n,i,coun=0;
 cin>>n;
 int a[n+5];
 for(i=0;i<n;i++)
 {
     cin>>a[i];
     if(a[i]%2!=0&&(i+1)%2!=0)coun++;
 }
 cout<<coun<<endl;





 return 0;


}


///Thanking you by Roxy






Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>

using namespace std;

int absmax(int p, int q) {
	int a, b;
	a = p;
	b = q;
	if( a < 0 ) a *= -1;
	if( b < 0 ) b *= -1;
	if( a < b ) return b;
	return a;
}

struct pairs {
	int p, q;
};

int main(void){
	int N;
	cin >> N;
	string ans[] = { "C", "P" };

	for(int i = 0; i < N; i++) {
		pairs p, q;
		vector< pairs > sp;
		cin >> p.p >> p.q;
		for( q.p = - absmax(p.p, p.q) ; q.p <= absmax(p.p, p.q); q.p ++) {
			for( q.q = - absmax(p.p, p.q); q.q <= absmax(p.p, p.q); q.q ++) {
				int tmp = q.p * q.p + q.q * q.q;
				if( tmp > 0 && ( ( q.p * p.p + q.q * p.q ) % tmp == 0 ) && 
					( q.p * p.q - q.q * p.p ) % tmp == 0 ) {
						sp.push_back( q );
				}
			}
		}
		cout << ans[sp.size() == 8] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N;cin >> N;
    vector<LL> x(N);
    vector<LL> y(N);
    rep(i,N){
        LL t,s;cin >> t >> s;
        x[i] = t - s;
        y[i] = t + s;
        // Chebyshev
    }

    sort(all(x));
    sort(all(y));

    LL ans = x[N-1] - x[0];
    ans = max(ans,y[N-1] - y[0]);

    cout << ans << endl;
  
}

Measured memory_bytes: 6420
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second

using namespace std;

typedef long long LL;
typedef double db;
typedef pair<int,int> pir;
typedef unsigned int ui;

ui seed;
ui getrand(){seed^=seed<<13;seed^=seed>>17;seed^=seed<<5;return seed;}

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 500005;

int n;
int a[N];
int w[N];
int fa[N];
struct edge{
	int x,nxt;
}e[N];
int h[N],tot;

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

bool vis[N];

bool dfs(int x){
	vis[x]=1;
	for(int p=h[x];p;p=e[p].nxt)
	if (vis[e[p].x])return 0;
	else{
		fa[e[p].x]=x;
		if(!dfs(e[p].x))return 0;
	}
	return 1;
}

int co[N];
struct seg{
	LL sum;
	int tot;
	seg(const LL sum_=0,const int tot_=0){sum=sum_;tot=tot_;}
	friend bool operator <(seg a,seg b){
		//a.sum/a.tot<b.sum/b.tot
		return a.sum*b.tot<b.sum*a.tot;
	}
};
int ans[N];
int Fa[N];
int m;
int num[N];

bool cmp(int x,int y){return w[x]<w[y];}

int getFa(int x){return Fa[x]==x?x:Fa[x]=getFa(Fa[x]);}

int D[N];
seg val[N];

int Lef[N],Rig[N],Lst[N];
bool bz[N];
int wei[N],siz;

int pop(){
	int ret=D[1];
	wei[ret]=0;
	wei[D[1]=D[siz--]]=1;
	int now=1;
	while(now*2<=siz){
		int t=now*2;
		if (t<siz&&val[D[t+1]]<val[D[t]])t++;
		if (val[D[now]]<val[D[t]])break;
		swap(D[now],D[t]);
		wei[D[now]]=now;
		wei[D[t]]=t;
		now=t;
	}
	return ret;
}

void updt(int now){
	while(now>1&&val[D[now]]<val[D[now>>1]]){
		swap(D[now],D[now>>1]);
		wei[D[now]]=now;
		wei[D[now>>1]]=now>>1;
		now=now>>1;
	}
}

void solve(){
	fo(i,1,n)val[i]=seg(w[i],1),num[i]=Fa[i]=i;
	sort(num+1,num+1+n,cmp);
	fo(i,1,n)wei[D[i]=num[i]]=i;
	siz=n;
	m=0;
	fo(tim,1,n){
		int x=pop();
		seg v=val[x];
		bz[x]=1;
		if (fa[x]){
			int y=getFa(fa[x]);
			if (!bz[y]&&(val[x]<val[y]||(val[x]<val[y])==(val[y]<val[x]))){
				Fa[x]=y;
				seg tmp=val[y];
				val[y]=seg(v.sum+tmp.sum,v.tot+tmp.tot);
				updt(wei[y]);
				//y=fa[x];
				if(!Lef[y])Lef[y]=Lst[y]=x;
				else{
					Rig[Lst[y]]=x;
					Lst[y]=x;
				}
			}
			else ans[++m]=x;
		}
		else ans[++m]=x;
	}
}

int u;
int fans[N];

void getans(int x){
	fans[++u]=w[x];
	for(int y=Lef[x];y;y=Rig[y])getans(y);
}

LL calc(){
	fo(i,1,m)getans(ans[i]);
	LL ret=0;
	int cnt=0;
	fo(i,1,n)if (!w[i])cnt++;
	fo(i,1,n)
	if (fans[i])ret=ret+cnt;
	else cnt--;
	return ret;
}

int main(){
	seed=20010419;
	n=get();
	a[1]=0;
	fo(i,2,n)a[i]=get();
	fo(i,1,n)w[i]=get();
	fo(i,1,n)
	if (a[i]&&a[i]<=n)inse(a[i],i);else inse(0,i);
	fo(i,0,n)
	if (!vis[i])if (!dfs(i))return printf("-1\n"),0;
	solve();
	printf("%lld\n",calc());
	return 0;
}

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

vector<int> rec(int x) {
	vector <int> sol;
	int pet = 1, bit = 0;
	for (; bit < 10; bit++) {
		pet = 1<<bit;
		if ((pet&x) != 0) break;
	}
	if (pet == x) {
		sol.push_back(bit+1);
		return sol;
	}
	vector<int> aux = sol  = rec(x^pet);
	sol.push_back(bit+1);
	for (auto it = aux.rbegin(); it != aux.rend(); it++)
		sol.push_back(-*it);
	sol.push_back(-bit-1);
	return sol;
}

string tira(const vector<int> & par) {
	string sol;
	for (int x: par) {
		sol += string(abs(x)-1,'R');
		if (x > 0) sol += "URDL";
		else sol += "RULD";
		sol += string(abs(x)-1,'L');
	}
	return sol;
}


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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int m = 1<<n;
	bool ok = true;
	vector<int> obs;
	for (int i = 1; i < m; i++) {
		if (s[i] == '0') obs.push_back(i);
		for (int j = i+1; j < m; j++) {
			int p = i, g = j;
			if (p > g) swap(p, g);
			if ((p&g) == p and s[p] == '0' and s[g] == '1') ok = false;
		}
	}
	if (!ok) cout << "Impossible" << endl;
	else {
		cout << "Possible" << endl;
		string sol;
		for (auto x: obs)  {
			sol += tira(rec(x));
		}
		int k = sol.size();
		cout << k   << endl;
		assert(k <= 250000);
		int px = 0, py = 0; 
		cout << px << " " << py << "\n";
		for (int i = 0; i < k; i++) {
			if (sol[i] == 'U') py++;
			else if (sol[i] == 'D') py--;
			else if (sol[i] == 'L') px--;
			else if (sol[i] == 'R') px++;
			cout << px << " " << py << "\n";
		}
	}


}



Measured memory_bytes: 1024
import sys

c = []
for i in range(3):
    c.append(list(map(int, input().split())))

#print(c)

coldif = [c[0][1] - c[0][0], c[0][2] - c[0][1]]

#print(coldif)

for i in range(1, 3):
    dif = [c[i][1] - c[i][0], c[i][2] - c[i][1]]
    if dif != coldif:
        print('No')
        sys.exit()

rowdif = [c[1][0] - c[0][0], c[2][0] - c[1][0]]

#print(rowdif)

for i in range(1, 3):
    dif = [c[1][i] - c[0][i], c[2][i] - c[1][i]]
    if dif != rowdif:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 38512
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int cnt = 0;

        for(int i = a; i <= b; i++){
            String s = String.valueOf(i);
            char[] c = s.toCharArray();
            if(c[0] == c[4] && c[1] == c[3]){
                cnt ++;
            }
        }

        System.out.println(cnt);
        
    }
}

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

int main() {
  int N;
  cin >> N;
  
  int a[N] = {0};
  int i;
  for (i = 0; i < N; i++){
	cin >> a[i];
  }
  
  int counter = 0;
  bool is_continue = true;
  while(is_continue){
  	for (i = 0; i < N; i++){
      if (a[i] % 2 != 0)
        is_continue = false;
      a[i] /= 2;
    }
    counter++;
  }
  counter--;
  cout << counter << endl;
}


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

int main() {
  int x,y;
  cin>>x>>y;
  if((y-x*2)%2==0&&(y-x*2)/2<=x&&(y-x*2)>=0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
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; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll r; cin >> r;


  //main
  double ans = 0;
  ans = 2*r*acos(-1);
  
  // output
  cout << setprecision(10) <<ans << endl;

  return 0;
}

Measured memory_bytes: 3780
S = input()
T = input()
ans = "Yes"
start = [-1]*26
goal = [-1]*26
for i in range(len(S)):
    s,t = ord(S[i])-97,ord(T[i])-97
    if start[s]!=-1 or goal[t]!=-1:
        if start[s]!=t or goal[t]!=s:
            ans = "No"
    else:
        start[s] = t
        goal[t] = s
print(ans)

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(System.Console.ReadLine());
            int m = int.Parse(System.Console.ReadLine());
            System.Console.WriteLine(n+(m - n) * 2);
        }
    }
}

Measured memory_bytes: 11092