akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<ll,ll>;
using piii = pair<pii,ll>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<pii>v,u;
    priority_queue<pii,vector<pii>,greater<pii>>vque;
    rep(i,n){
        pii temp; cin >> temp.first >> temp.second;
        u.push_back(temp);
        v.push_back(pii(temp.first + temp.second,i));
    }
    int cnt = 0,vsum = 0,usum = 0;
//    while(!vque.empty()){
//        pii top = vque.top();
//        vque.pop();
//        if(cnt % 2 == 0){
//            vsum += v[top.second].first.first;
//        } else {
//            usum += v[top.second].first.second;
//        }
//        cnt++;
//    }
    sort(all(v),greater<>());
    rep(i,n){
        if(i % 2 == 0)vsum += u[v[i].second].first;
        else usum += u[v[i].second].second;
    }
    cout << vsum - usum << endl;
}





Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int count=0,i;
  for(i=1;i<n+1;i++){
    string s=to_string(i);
    if(s.size()%2==1){
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

n=int(input())

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

m = 1000000000

for i in range(n - 1):
    a = sum(w[:i + 1])
    b = sum(w[i+ 1:])
    m = min(abs(a-b), m)

print(m)

Measured memory_bytes: 21908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------


const int MAX_N = 1e+2;
const int MAX_W = 1e+5;
VVL dp(MAX_N + 1, VL(MAX_W + 1, 0));

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

    int N, W; cin >> N >> W;
    VL w(N), v(N); REP(i,N) cin >> w[i] >> v[i];

    REP(i, N) {
        REP(j, W + 1) {
            if (j - w[i] >= 0) {
                dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    ll ans = *max_element(dp[N].begin(), dp[N].end());
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 83068
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if((c>=a && c<=b) || (c>=b && c<=a))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
   var s = Number(lines[0]);
   var list = [s]
   for (var i = 1;i < 1000000;i++){
     list = c_list(list, s, i)
     var f_list = list.filter(l => l === list[list.length - 1])
     if (f_list.length > 1){
       console.log(i)
       return;
     }
   }
});

const c_list = (list, s, m) => {
    for(var i = list.length;i < m;i++) {
        if(!(list[i - 1] % 2)) {
            list.push(list[i - 1]/2)
        } else {
            list.push(3 * list[i -1] + 1)
        }
     }
    return list
}
 


Measured memory_bytes: 7884
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    while(K--) {
        if(count(A.begin(), A.end(), N) == N) break;
        vector<int> tmp(N+1);
        for(int i=0; i<N; i++) {
            tmp[max(0, i-A[i])]++;
            tmp[min(N, i+A[i]+1)]--;
        }
        tmp.pop_back();
        partial_sum(tmp.begin(), tmp.end(), A.begin());
    }

    for(auto e: A) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 4840
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var l1 = ReadIntArray();

        int n = l1[0];
        int r = l1[1];

        var result = n >= 10 ? r : r + 100 * (10 - n);
        Console.WriteLine(result);
    }

    static string[] ReadStringArray()
    {
        return Console.ReadLine().Trim().Split(' ');
    }

    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(_ => int.Parse(_)).ToArray();
    }

    static long[] ReadLongArray()
    {
        return ReadStringArray().Select(_ => long.Parse(_)).ToArray();
    }
}
 


Measured memory_bytes: 13396
#include <iostream>
#include <map>
#include <cmath>
using namespace std;

int main (void) {
  int n; cin >> n;
  map<pair<int, int>, int> cnt;
  int64_t ans = 0;
  for (int rep = 0;rep < n; rep++) {
    double x; cin >> x;
    int64_t i = llround(x * 1e9);
    int two = 0, five = 0;
    while (i % 2 == 0) {
      i /= 2;
      two++;
    }
    while (i % 5 == 0) {
      i /= 5;
      five++;
    }
    cnt[{two, five}]++;
  }
  for (auto p1: cnt) {
    for (auto p2: cnt) {
      if (p1.first.first + p2.first.first >= 18 && p1.first.second + p2.first.second >= 18) {
        if (p1 < p2) ans += 1ll * p1.second * p2.second;
        else if (p1 == p2) ans += 1ll * p1.second * (p1.second - 1) / 2;
      }
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3760
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let s = input::<String>();

    let mm = s.chars().skip(5).take(2).collect::<String>();
    let m = mm.parse::<i64>().ok().unwrap();
    let ans = if m <= 4 { "Heisei" } else { "TBD" };
    println!("{}", ans);
}


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

typedef long long ll;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

int n, m ;
ll a[100001][2];
vector<pair<ll,ll> > p;

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

    cin>>n;
    for(int i = 0; i < n; i++){
        cin >> a[i][0] >> a[i][1];
        p.pb(mp(a[i][0]+a[i][1],i));
    }
    sort(p.begin(),p.end());

    ll ans = 0;
    for(int i = n-1; i >= 0; i--){
        if((n-1-i)%2==0){
            ans+=a[p[i].se][0];
        }
        else{
            ans-=a[p[i].se][1];
        }
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;

    int A[N];
    bool flag = false;
    REP(i, N){
        cin >> A[i];
        if(A[i] == 1) flag = true;
    }

    if(flag) {
        int x = 1, ans = 0;
        REP(i, N){
            if(A[i] == x) x++;
            else ans++;
        }
        cout << ans << endl;
    }
    else cout << -1 << endl;
}

Measured memory_bytes: 4352
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    n = int(input())
    s = set()
    for i in range(n):
        t = input()
        s.add(t)
    print(len(s))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 30888
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val domino = readLine()!!
    readLine()

    val p = domino.mapIndexed { i, c ->
        if(i==0) false
        else domino[i-1]==c
    }
    val dg = domino.groupBy { it } .mapValues { it.value.size }
    val d = mutableListOf<Int>()
    for (i in 0..domino.lastIndex) {
        if(p[i]) continue
        d.add(dg[domino[i]]!!)
    }

    var dp = if(d[0] == 1) 3L else 6L
    for(i in 1..d.lastIndex) {
        val comb = when {
            d[i-1] == 1 && d[i] == 1 -> 2
            d[i-1] == 1 && d[i] == 2 -> 2
            d[i-1] == 2 && d[i] == 1 -> 1
            d[i-1] == 2 && d[i] == 2 -> 3
            else -> 0
        }
        dp = (dp * comb) % 1000000007L
    }
    println(dp)
}


Measured memory_bytes: 33788
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""
    int mask[50];
    vector<pair<int,int> > v[N];
bool dfs(int x,int y,int z,int pr=-1)
{
    if (x==y) re 1;
    for(auto a:v[x])
    {
        if (a.fi==pr) continue;
        if (dfs(a.fi,y,z,x))
        {
            mask[a.se]|=(1<<z);
            re 1;
        }
    }
    re 0;
}
    int n,m;
    bool was[50][(1<<20)];
    ll table[50][(1<<20)];
ll f(int x,int mask)
{
    if (x==n-1)
    {
        re (mask==(1<<m)-1);
    }
    if (was[x][mask]) re table[x][mask];
    was[x][mask]=1;
    ll o=f(x+1,mask);
    o+=f(x+1,mask|::mask[x]);
    re table[x][mask]=o;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int i,a,b;
    cin>>n;
    fo(i,n-1)
    {
        cin>>a>>b;
        a--;
        b--;
        v[a].pb({b,i});
        v[b].pb({a,i});
    }
    cin>>m;
    fo(i,m)
    {
        cin>>a>>b;
        a--;
        b--;
        dfs(a,b,i);
    }
    cout<<f(0,0);
}


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

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int n,p,odd=0,even=0;
  cin>>n>>p;
  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
    if(v[i]%2==0){
      even++;
    }else{
      odd++;
    }
  }
  if(p==1){
    if(odd!=0){
      cout<<(long long int)pow(2,odd+even-1)<<endl;
    }else{
      cout<<0<<endl;
    }
  }else if(p==0){
    if(odd!=0){
      cout<<(long long int)pow(2,odd+even-1)<<endl;
    }else{
      cout<<(long long int)pow(2,odd+even)<<endl;
    
    }
    
    
    
    
    
  }
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll sum=0;
    int t=n-1;
    rep(i,n){
        int lim=2;
        if(i==0) lim=1;
        rep(j,lim) {
            if(t>0) {
                sum+=a[i];
                t--;
            }
        }
    } 
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4496
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007LL;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1LL;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}
  

int main(void) {

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

  ll z[200100];
  z[0] = 1LL;
  for (ll i = 1; i <= n; i++) {
    z[i] = z[i - 1] * i % MOD;
  }

  ll ans = 0, s, t;
  for (int i = 0; i <= min(n - 1, k); i++) {
    s = z[n] * powMod(z[i] * z[n - i] % MOD, MOD - 2, MOD) % MOD;
    t = z[n - 1] * powMod(z[i] * z[n - 1 - i] % MOD, MOD - 2, MOD) % MOD;
    ans += s * t % MOD;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;

}

  


Measured memory_bytes: 1792
def eratosthenesAray(N):
    prime=[True]*(N+1)
    prime[0]=False
    prime[1]=False
    for i in range(2,N+1):
        if prime[i]:
            for j in range(i+i,N+1,i):
                prime[j]=False
    return prime

N=int(input().strip())
primes=eratosthenesAray(100000)
ruiseki=[0]*100001
for i in range(1,100001):
    ruiseki[i]=ruiseki[i-1]
    if primes[i] and primes[(i+1)//2]:
        ruiseki[i]+=1
for i in range(N):#N
    l,r=map(int,input().split())
    print(ruiseki[r]-ruiseki[l-1])

Measured memory_bytes: 5108
# 貰うDP
INF = float('inf')
n = int(input())
a = [1]
i = 6
while i <= n:
  a.append(i)
  i *= 6
i = 9
while i <= n:
  a.append(i)
  i *= 9
t = [0] * (n + 1)
for i in range(1, n + 1):
  k = INF
  for j in a:
    if i - j >= 0 and k > t[i - j] + 1:
      k = t[i - j] + 1
  t[i] = k
print(t[n])


Measured memory_bytes: 3828
int main(void){
	int a,b;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?')break;
		switch(op){
			case '+':
				printf("%d\n",a+b);
				break;
				
			case '-':
				printf("%d\n",a-b);
				break;
				
			case '/':
				printf("%d\n",a/b);
				break;
				
			case '*':
				printf("%d\n",a*b);
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
N = gets.to_i
a = gets.split.map(&:to_i)
 
ans = 0
 
29.times do |i|
  
  f = true
  
  a.each do |j|
    
    if j % 2 == 1
      f = false
      break
    end
  end
  
  if f
    ans += 1
    a = a.map{ |j| j / 2 }
  end
  
  break if !f
 
end
 
puts ans

Measured memory_bytes: 1788
def petrozavodsk001_b():
    _ = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    act = sum(B) - sum(A)
    if act < 0:
        print('No')
        return

    addA, addB = 0, 0
    for a, b in zip(A, B):
        if a > b: addB += a - b
        else: addA += (b - a + 1) // 2

    if addA <= act and addB <= act:
        print('Yes')
    else:
        print('No')

petrozavodsk001_b()

Measured memory_bytes: 4596
n,y=map(int,input().split())

n1=y//1000
n5=y//5000
n10=y//10000
for x1 in range(n1+1):
    if x1>n:continue
    for x5 in range(n5+1):
        x10=n-x1-x5
        if n10<x10:continue
        if x10<0:break
        if x1*1000+x5*5000+x10*10000==y and x1+x5+x10==n:
                print(x10,x5,x1)
                exit()
print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L,R,d; cin >> L >> R >> d;
    cout << R/d-(L-1)/d << '\n';
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
char a[40]={0};
int len,b;
cin.getline(a,40);
len = strlen(a);
for(int i=len-1;i>=0;i--){
cout<<a[i];
}
cout<<endl;
return 0;
}

Measured memory_bytes: 1116
h,w=map(int,input().split())
a=[]
s=0
for i in range(h):
    p=[int(j) for j in input().split()]
    a.append(p)
    s+=sum(p)
ans=[]
if s%2==0:
    if a[0][0]%2==1:
        if w!=1:
            ans.append([1,1,1,2])
            a[0][1]+=1
        elif h!=1:
            ans.append([1,1,2,1])
            a[1][0]+=1
else:
    if a[0][0]%2==0:
        if w!=1:
            ans.append([1,1,1,2])
            a[0][1]+=1
        elif h!=1:
            ans.append([1,1,2,1])
            a[1][0]+=1

for i in range(h):
    for j in range(w):
        if i==0 and j==0:
            continue
        if j==w-1:
            if i!=h-1:
                if a[i][j]%2==1:
                    ans.append([i+1,j+1,i+2,j+1])
                    a[i+1][j]+=1
        else:
            if a[i][j]%2==1:
                ans.append([i+1,j+1,i+1,j+2])
                a[i][j+1]+=1

print(len(ans))
for a,b,c,d in ans:
    print(a,b,c,d)






Measured memory_bytes: 30112
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#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 pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 9223372036854775807
#define LONG_LONG_MIN -9223372036854775808
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const int maxn = 1e5 + 10;
string s;
int ans[maxn], r[maxn], l[maxn];

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ms(r, 0); ms(l, 0); ms(ans, 0);
    cin >> s;
    int len = s.size();
    if (s[0] == 'L') ++l[0];
    else if (s[0] == 'R') ++r[0];
    for (int i = 1; i < len; ++i) {
        if (s[i] == 'R') {
            r[i] = r[i-1] + 1;
        }
    }
    if (s[len-1] == 'L') ++l[len-1];
    else if (s[len-1] == 'R') ++r[len-1];
    for (int i = len - 2; i >= 0; --i) {
        if (s[i] == 'L') {
            l[i] = l[i+1] + 1;
        }
    }
    for (int i = 1; i < len; ++i) {
        if (s[i] == 'L' && s[i-1] == 'R') {
            ans[i] += r[i-1] / 2;
            ans[i-1] += (r[i-1] + 1) / 2;
        }
    }
    for (int i = 0; i < len - 1; ++i) {
        if (s[i] == 'R' && s[i+1] == 'L') {
            ans[i] += l[i+1] / 2;
            ans[i+1] += (l[i+1] + 1) / 2;
        }
    }
    for (int i = 0; i < len; ++i) {
        if (i != len - 1) {
            cout << ans[i] << " ";
        } else {
            cout << ans[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1872
def actual(N, D, X, A):
    # 2 * [食べる日数] + 1 <= D かつ [食べる日数] は整数を解けばよい 
    count_eating_days = lambda a_i: (D - 1) // a_i + 1

    eating_day_counts = sum([count_eating_days(a_i) for a_i in A])

    return X + eating_day_counts

N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]

print(actual(N, D, X, A))


Measured memory_bytes: 8960
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    private static int[][] adj;
    private static int[] d;
    private static int[] f;
    private static int time = 1;
    private static HashSet<Integer> visited = new HashSet<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        adj = new int[n +1][];
        for (int i = 0; i < n; i++) {
            int u = in.nextInt();
            int k = in.nextInt();
            adj[u] = new int[k];
            for (int j = 0; j < k; j++) {
                adj[u][j] = in.nextInt();
            }
        }
        in.close();
        d = new int[n+1];
        f = new int[n+1];
        for (int i = 1; i <= n; i++) {
            dfs(i);
        }
        for (int i = 1; i <= n; i++) {
            System.out.println(i + " " + d[i] + " " + f[i]);
        }
    }

    private static void dfs(int node) {
        if (!visited.contains(node)) {
            visited.add(node);
            d[node] = time++;
            int[] neighbors = adj[node];
            for (int neighbor : neighbors) {
                dfs(neighbor);
            }
            f[node] = time++;
        }
    }
}



Measured memory_bytes: 28396
N,M = map(int,input().split())

node = [[] for i in range(N+1)]

for i in range(M):
    a,b = map(int,input().split())
    node[a].append(b)
    node[b].append(a)

from collections import deque

que = deque([1])

ans = [-1 for i in range(N+1)]
dist = [0 for i in range(N+1)]
ans[1] = 0
dist[1] = 0

while que:
    now = que.popleft()
    for v in node[now]:
        if ans[v] == -1:
            ans[v] = now
            dist[v] = dist[now] + 1
            que.append(v)
print('Yes')
print('\n'.join(map(str,ans[2:])))



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

int main() {
  
  int a,b,c,d,x,y;
  cin >> a >> b >> c >> d;
  
  x = a * b;
  y = c * d;
  
  if ( x >= y ){
    cout << x << endl;
  }else{
    cout << y << endl;
  } 
  
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define ll long long
const long long INF = 1LL << 60;
typedef vector<ll> Array;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
  
	Array prime;
	Array isPrime(101010, 1);
    isPrime[0]=isPrime[1]=0;
	map<ll, int> pSqrt;

	REP(i, 101010) {
		if (isPrime[i] == 1){
			prime.push_back(i);
			for (int j = i * 2; j < 101010; j += i)isPrime[j] = 0;
			pSqrt[(ll)i * (ll)i] = i;
		}
	}

    ll n;
    cin>>n;
	map<ll, int> mp;
	Array b(n, 1);
	Array p(n, 1);
  
	REP(i, n) {
		ll s;
		cin >> s;
		REP(j, prime.size()) {
			if (s < prime[j] * prime[j] * prime[j])break;
			ll cnt = 0;
            if(s%prime[j])continue;
			while (true) {
				if (s % prime[j] == 0) {
					cnt++;
					s /= prime[j];
				}
				else {
					break;
				}
			}
			cnt %= 3;
			REP(k, cnt)b[i] *= prime[j];
			if (cnt != 0)REP(k, 3 - cnt)p[i] *= prime[j];
		}
		if (pSqrt[s]) {
			b[i] *= s;
			p[i] *= pSqrt[s];
		}
		else {
			b[i] *= s;
			p[i] *= s * s;
		}
		mp[b[i]]++;
	}
    int ans=0;
	ans += !!mp[1];
	REP(i, n) {
		if (b[i]==1)continue;
        if (mp[b[i]]>mp[p[i]])ans++;
		else if (mp[b[i]] == mp[p[i]] && b[i] > p[i])ans++;
	
    }
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 21888
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int M = NextInt();
        List<Tuple<long, long, long>> xyz = Enumerable.Range(0, N).Select(v => new Tuple<long, long, long>(NextLong(), NextLong(), NextLong())).ToList();
        long ans = 0;
        for (int pt = 0; pt < 8; pt++)
        {
            List<long> data = new List<long>();
            for (int i = 0; i < N; i++)
            {
                long score = 0;
                if ((1 & pt >> 0) == 1) score += xyz[i].Item1;
                else score -= xyz[i].Item1;
                if ((1 & pt >> 1) == 1) score += xyz[i].Item2;
                else score -= xyz[i].Item2;
                if ((1 & pt >> 2) == 1) score += xyz[i].Item3;
                else score -= xyz[i].Item3;
                data.Add(score);
            }
            ans = Math.Max(ans, data.OrderByDescending(v => v).Take(M).Sum());
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13792
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Monad.Primitive
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt

for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  graph <- buildWeightedUndirectedGraph (1,n) . map (listToTuple2 . map readIntBS . BS.words) . BS.lines <$> BS.getContents :: IO (Array Int [Int])
  
  check <- newArray (1,n) False :: IO (IOUArray Int Bool)

  let
    search cur = do
      writeArray check cur True
      
      let neighb = graph!cur
      next <- (filterM (\i -> not <$> readArray check i) neighb)
      

      if null next then
        return [cur]
        else
        (cur:) <$> search (head next)

  path <- (++) <$> (reverse <$> search 1) <*> (tail <$> search 1)
  print $ length path
  putStrLn $ unwords . map show $ path

type Node = Int

{-- 重みなし無向グラフ --}
buildWeightedUndirectedGraph :: (Node,Node) -> [(Node,Node)] -> Array Node [Node]
buildWeightedUndirectedGraph bound dat = runST $ do
  graph <- newArray bound [] :: ST s (STArray s Node [Node])
  forM_ dat $ \(s,e) -> do
    modifyArray graph s (e:)
    modifyArray graph e (s:)
  freeze graph


Measured memory_bytes: 27772
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int MAX = 2000010;
const int MOD = 1000000007;
long long int fac[MAX], finv[MAX], inv[MAX];
long long int rui25[2000010],rui26[2000010];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    COMinit();
    rui25[0]=1;rui26[0]=1;
    for(int i=1;i<2000010;i++){
        rui25[i]=(rui25[i-1]*25)%MOD;
        rui26[i]=(rui26[i-1]*26)%MOD;
    }
    long long int K;
    long long int ans=0;
    string S;
    cin>>K>>S;
    for(int i=S.size(),j=0;i<=K+S.size();i++,j++){
        if(i==S.size()){
            ans=(ans+rui26[K])%MOD;
        }
        else{
            ans=(ans+((((COM(i,S.size())%MOD-COM(i-1,S.size())%MOD)%MOD)*rui25[j])%MOD*rui26[K-j])%MOD)%MOD;
            ans=(ans+MOD)%MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 83448
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef long long LL;

const int maxn=1e5+5;
const LL mo=1e9+7;

int n;
LL a[maxn],inv[maxn];

LL Pow(LL x,LL y)
{
	LL re=1;
	for(; y; y>>=1, x=x*x%mo) if (y&1) re=re*x%mo;
	return re;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%lld",&a[i]);
	
	LL fac=1;
	fo(i,1,n) (fac*=i)%=mo, inv[i]=(inv[i-1]+Pow(i,mo-2))%mo;
	
	LL ans=0;
	fo(i,1,n) (ans+=fac*(inv[i]+inv[n-i+1]-1)%mo*a[i])%=mo;
	
	printf("%lld\n",(ans%mo+mo)%mo);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class StonesOnATree
{
    public:
int minStones(vector <int> p, vector <int> w)
{

}
};
int main()
{
  LL a,b;
  while(cin>>a>>b){
        if(b==0){
            cout<<a*a<<endl;
            con;
        }
    LL ans=0;
    LL o=0;
    for(LL i=b+1;i<=a;i++){
        ans+=a/i*(max(o,i-b) );
        ans+=max(o,a%i-b+1);
    }
    cout<<ans<<endl;




  }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1193&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int H;

ll check(vector<int>& vec){
    ll ret = 0;
    
    for(int i = 0; i < 3;i++){
        ll t = vec[i];
        ll cnt = 1;
        for(int j = i+1; j < 5;j++){
            if(vec[j] != t) break;
            cnt++;
        }
        if(cnt >= 3){
            for(int j = i; j < i+cnt;j++){
                vec[j] = 0;
            }
            ret += t*cnt;
            return ret;
        }
    }
    return ret;
}
ll solve(){
    ll res = 0;
    vector<vector<int>> Stone(H,vector<int>(5,0));
    for(int i = H-1; i >= 0; i--){
        for(int j = 0; j < 5;j++){
            cin >> Stone[i][j];
        }
    }
    while(true){
        ll t = res;
        for(int i = H-1; i >= 0; i--){
            res += check(Stone[i]);
        }
        if(t == res) break;
        while(true){
            bool update = false;
            for(int i = 0; i < H-1;i++){
                for(int j = 0; j < 5;j++){
                    if(Stone[i][j] == 0 && Stone[i+1][j] != 0){
                        update = true;
                        swap(Stone[i][j],Stone[i+1][j]);
                    }
                }
            }
            if(!update) break;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> H,H){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
using namespace std;
int a,n;
int main()
{
	cin>>n>>a;
	n=n%500;
	if(n<=a)
	{
		cout<<"Yes";
	}
	else cout<<"No";
}

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


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

		if (a[i] == 'o') {
			b++;
		}
	}
	cout << 700 + (b * 100) << endl;
}



Measured memory_bytes: 3472
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int total =0;
    for (int i =0; i<3; i++) {
      if (S.charAt(i) == T.charAt(i)) total++;
    }
    System.out.print(total);
  }
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int x; cin >> x;
  cout << (x < 1200 ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{

    int N;
    cin>>N;
    int A;
    int count = 0;

    int dec_count;
    for (int i = 1; i <= N; i++)
    {
        dec_count = 0;
        A = i;
        while(1)
        {
            if (A < 10)
            {
                break;
            }
            else
            {
                A = A/10;
                dec_count++;
            }
        }

        dec_count ++;
        if(dec_count%2 == 1)
        count++;
    }

    cout<<count;
    
    return 0;
}

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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  int ans=0;
  ans += a[2] -a[1];
  ans += (a[1] -a[0])/2 + ((a[1] -a[0])%2)*2;


  cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>

int main() {
  size_t x;
  scanf("%zu", &x);

  int const inf = 1e9;
  std::vector<int> dp(x+1, inf);
  std::vector<size_t> a{100, 101, 102, 103, 104, 105};
  dp[0] = 0;
  for (size_t i = 0; i < a.size(); ++i) {
    for (size_t j = 0; j < dp.size(); ++j) {
      if (j >= a[i])
        dp[j] = std::min(dp[j], dp[j-a[i]]);
    }
  }
  printf("%d\n", !dp[x]);
}


Measured memory_bytes: 640
// IN THE NAME OF RIGHT
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
queue <ll> q;
ll k,ans;
int main(){
	cin>>k;
	for(int i=1;i<10;i++){
		q.push(i);
	}
	for(int i=0;i<k;i++){
		if(q.front()%10!=0){
			q.push(10*q.front()+(q.front()%10)-1);
		}
		q.push(10*q.front()+(q.front()%10));
		if(q.front()%10!=9){
			q.push(10*q.front()+(q.front()%10)+1);
		}
		ans=q.front();
		q.pop();
	}
	cout<<ans<<endl;
}


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

int main(){
    int n;
    cin >> n;
    if(n<=999) cout <<"ABC" << endl;
    else cout <<"ABD" <<endl; 
    return 0; 

}

Measured memory_bytes: 256
class RMQ:
    def __init__(self, n):
        self.n = n 
        self.size = 2**(self.n - 1).bit_length()
        self.data = [0] * (2*self.size-1)

    # Update ak as x
    def update(self, k, x):
        k += self.size - 1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])

    # Min value in [l, r)
    def query(self, l, r):
        L = l + self.size; R = r + self.size
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])
            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

n = int(input())
h = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

rmq = RMQ(2*10**5 + 10)
for i in range(n):
    beaut = rmq.query(0, h[i])
    rmq.update(h[i] - 1, beaut - a[i])
print(-rmq.data[0])

Measured memory_bytes: 122960
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)

using namespace std;
const int Nmax = 1e5 + 1;

int n, cur, a[Nmax], ans;

int main() {
    scanf("%d", &n);
    FOR(i, 1, n) {
        scanf("%d", a + i);
    }
    FOR(i, 1, n + 1) {
        if (a[i] != a[i - 1]) {
            ans += cur / 2;
            cur = 1;
        } else {
            ++cur;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
n = int(input())
t = []
x = []
y = []
for i in range(n):
    T,X,Y=[int(i) for i in input().split()]
    t.append(T)
    x.append(X)
    y.append(Y)

flagCount = 0

for i in range(n):
    if t[i] < x[i] + y[i]:
        flagCount += 1
    if t[i]%2 != (x[i]+y[i])%2:
        flagCount += 1

if flagCount == 0:
    print('Yes')
else :
    print('No')


Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	vector<int> v{0};
	for (auto& c : s) {
		if (c == '/') v.push_back(v.back() + 1);
		else if (c == '_') v.push_back(v.back());
		else v.push_back(v.back() - 1);
	}
	vector<int> m(v);
	int ma = 0;
	for (int i = 1; i < v.size(); i++) {
		if (ma < v[i]) {
			ma = v[i];
		} else {
			m[i] = ma;
		}
	}
	ma = v.back();
	for (int i = v.size() - 1; i >= 0; i--) {
		if (ma < v[i]) {
			ma = v[i];
			m[i] = v[i];
		} else {
			m[i] = min(m[i], ma);
		}
	}
	int res = 0;
	vector<int> r;
	int cnt = 0;
	for (int i = 1; i < v.size(); i++) {
		int t = m[i-1] - v[i-1] + m[i] - v[i];
		res += t;
		if (m[i] > v[i]) {
			cnt += t;
		} else {
			cnt += m[i-1] - v[i-1];
			if (cnt) r.push_back(cnt / 2);
			cnt = 0;
		}
	}
	cout << res / 2 << endl;
	cout << r.size();
	for (auto& x : r) cout << " " << x;
	cout << endl;
}


Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

struct Node{
	int key;
	Node *parent;
	Node *left;
	Node *right; 
};
Node *root;
void insert(int k){
	Node *x = root;
	Node *y = NULL;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NULL;
	z->right = NULL;
	while(x){
		y = x;
		if(k<x->key)
			x = x->left;
		else if(k>x->key)
			x = x->right;
	}
	z->parent = y;
	if(y==NULL)
		root = z;
	else{
		if(k<y->key)
			y->left = z;
		else
			y->right = z;
	}
}
Node* find(int k,Node *u){
	while(u&&u->key!=k){
		if(u->key>k)
			u = u->left;
		else
			u = u->right;
	}
	return u;
}

Node* getMin(Node *n){
	while(n->left) n = n->left;
	return n;
}
void set(Node *a,Node *b){
	if(a->parent->left==a)
		a->parent->left = b;
	else if(a->parent->right==a)
		a->parent->right = b;
	if(b) b->parent = a->parent;
}
void deleteT(Node *t){
	Node *y;
	if(t==NULL) return;
    if(t->left==NULL){
		set(t,t->right);
	}else if(t->right==NULL){
        set(t,t->left);
	}else{
		y = getMin(t->right);
		t->key = y->key;
        deleteT(find(y->key,t->right));
	}
}
void pre(Node *n){
	if(n==NULL) return;
	printf(" %d",n->key);
	pre(n->left);
	pre(n->right);
}
void in(Node *n){
	if(n==NULL) return;
	in(n->left);
	printf(" %d",n->key);
	in(n->right);
}
int main() {
	int n,x;
	char s[10];
	scanf("%d",&n);
	while(n--){
		scanf("%s",&s);
		if(s[0]=='i'){
			scanf("%d",&x);
			insert(x);
		}else if(s[0]=='p'){
			in(root);
			printf("\n");
			pre(root);
			printf("\n");
		}else if(s[0]=='f'){
			scanf("%d",&x);
			if(find(x,root)!=NULL)
				printf("yes\n");
			else
				printf("no\n");
		}else{
			scanf("%d",&x);
			deleteT(find(x,root));
		}
	}
	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll r, d, x; cin >> r >> d >> x;
  REP(i, 10){
    x = r * x - d;
    cout << x << endl;
  }
}


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

void _140() {
    int n;
    cin >> n;

    int a[20];
    int b[20];
    int c[20];
    for (int i = 0; i < n; ++i) 
        cin >> a[i];
    for (int i = 0; i < n; ++i) 
        cin >> b[i];
    for (int i = 0; i < n - 1; ++i) 
        cin >> c[i];

    int score = 0;
    for (int i = 0; i < n - 1; ++i) {
        score += b[a[i] - 1];
        if (a[i + 1] == a[i] + 1) {
            score += c[a[i] - 1];
        }
        // cout << score << endl;
    }
    score += b[a[n - 1] - 1];

    cout << score << endl;
}

void _141() {

}

int main()
{
    _140();
    return 0;
}



Measured memory_bytes: 256
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll M = 26 + 10;
const ll N = 30 * 100 + 10;

ll dp[2][N][N] , a[N];

ll solve(int t, int l, int r)
{
	if(l == r)
	{
		if(t == 0)
		{
			return a[l];
		}
		else
		{
			return -a[l];
		}
	}
	if(dp[t][l][r] != -1)
		return dp[t][l][r];
	if(t == 0)
	{
		return dp[t][l][r] = max(solve(1 - t, l + 1, r) + a[l], solve(1 - t, l, r - 1) + a[r]);
	}
	else
	{
		return dp[t][l][r] = min(solve(1 - t, l + 1, r) - a[l], solve(1 - t, l, r - 1) - a[r]);
	}
}

int main()	
{
	faster();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int k = 0; k < 2; k++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				dp[k][i][j] = -1;
			}
		}
	}
	cout << solve(0, 0, n - 1) << endl;
}

Measured memory_bytes: 141824