akhauriyash/Code-Regression huggingface dataset:
package main
 
import "fmt"
 
func main() {
    var n int
    fmt.Scan(&n)
 
  if (n % 1000) == 0 {
        fmt.Println("0")
        return
    } else {
    m := n / 1000
    o := (m+1) * 1000 - n
	    fmt.Println(o)
	    return
    }
}

Measured memory_bytes: 1768
n = int(input())
cnt = 0
mx = -1
ps = []
for _ in range(n):
    d1,d2 = map(int, input().split())
    ps.append((d1,d2))
ps.append((1,2))
for d1,d2 in ps:
    if d1 != d2:
        mx = max(mx,cnt)
        cnt = 0
    else:
        cnt += 1

print("Yes" if mx>=3 else "No")


Measured memory_bytes: 9096
#include<iostream>
using namespace std;
#include<string>
int main()
{

  int sx, sy, ex, ey;
  cin>>sx>>sy>>ex>>ey;
  int dx = ex-sx;
  int dy = ey - sy;


  cout<<string(dy, 'U')<<string(dx, 'R');
  cout<<string(dy,'D')<<string(dx, 'L');


  cout<<'L'<<string(dy+1, 'U')<<string(dx+1, 'R')<<'D';
  cout<<'R'<<string(dy+1, 'D')<<string(dx+1, 'L')<<'U';

  return 0;
}


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

struct UnionFind{
    static const int MAX_N = 200010;
    //par[i] : iの親
    vector <int> par;
    //rank[i] : iのグラフの高さ
    int rank[MAX_N]={0};
    
    UnionFind(int N) : par(N){
        for(int i=0;i<N;i++)par[i]=i;
    }
    //xの根を見つける
    int root(int x){
        if(par[x]==x)return x;
        return par[x] = root(par[x]);
    }
    //x,yが同じ集合に属するか
    bool same(int x,int y){
        return root(x)==root(y);
    }
    //x,yが別の集合なら連結
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x==y)return;
        
        //高さの低いグラフの根に高さの高いグラフを連結
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
        if(rank[x] == rank[y])rank[x]++;
        }
        
    }
};

template<class T> inline bool chmin(T& a,T b){
    if (a > b) {
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a,T b){
    if(a < b) {
        a=b;
        return true;
    }
    return false;
}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/

int main(){
    int n,k,l;
    cin >> n >> k >> l;
    UnionFind road(n);
    UnionFind rail(n);
    map<pair <int,int>,int> a;
    pair <int,int> b[200010];
    int p,q;
    rep(i,k){
        cin >> p >> q;
        road.unite(p-1,q-1);
    }
    int s,t;
    rep(i,l){
        cin >> s >> t;
        rail.unite(s-1,t-1);
    }
    int cnt=0;
    rep(i,n){
        cnt = 0;
        b[i].first=road.root(i);
        b[i].second=rail.root(i);
        a[b[i]] ++;
    }
    rep(i,n)cout << a[b[i]] << " ";
}

Measured memory_bytes: 16768
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

inline int POW(int x) {
	return x * x;
}

int main() {
	for(int h, w, d; cin >> h >> w >> d, h || w || d;) {
		int a[] = {h, w, d};
		sort(a, a + 3);
		double len = sqrt(POW(a[0]) + POW(a[1]));
		
		int N; cin >> N;
		for(int i = 0; i < N; i++) {
			int L = 0; cin >> L;

			if (len < 2 * L - EPS) {
				cout << "OK" << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
int const MOD = 1e9 + 7;
i64 const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);

  int n; cin >> n;
  vector<int> a(n);
  for (int i = 1; i < n; ++i) {
    int x; cin >> x, --x;
    a[x]++;
  }
  for (int x : a) cout << x << '\n';
}


Measured memory_bytes: 3992
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

zeroPad :: Int -> String -> String
zeroPad num s = reverse . take num . reverse $ (take num $ repeat '0') ++ s

solve :: Int -> Int -> [(Int, Int)] -> [String]
solve n m pys = makeId <$> pys where
  prefYearMap :: M.Map Int [Int]
  !prefYearMap = M.fromListWith (++) $ (\(pref, year) -> (pref, [year])) <$> pys
  yearOrderMap :: Int -> M.Map Int Int
  yearOrderMap pref = M.fromList $ zip (sort $ M.findWithDefault [] pref prefYearMap) [1..]
  !prefYearOrderMap = M.fromList $ zip [1..] $ yearOrderMap <$> [1..n]
  makeId (pref, year) = (zeroPad 6 (show pref)) ++ (zeroPad 6 . show $ prefYearOrderMap M.! pref M.! year)

main :: IO ()
main = do
  (n, m) <- readTuple2
  pys <- replicateM m readTuple2
  forM_ (solve n m pys) putStrLn




Measured memory_bytes: 84604
d = int(input())
c = list(map(int,input().split()))
s = []
t = [0]*d
for i in range(d):
    s.append(list(map(int,input().split())))
for i in range(d):
    t[i] = int(input())-1
v = 0
x = [1]*26
for i in range(d):
    x[t[i]] *= 0
    v += s[i][t[i]]
    for j in range(26):
        v -= c[j]*x[j]
        x[j] += 1
    print(v)

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

int n, m, chk[200200], ans;
vector<int> v[200200];

int dfs(int u){
	chk[u] = 1;
	int re = 1;
	for(int x : v[u]) if(!chk[x]) re += dfs(x);
	return re;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int a, b; cin >> a >> b;
		v[a].push_back(b), v[b].push_back(a);
	}
	for(int i=1;i<=n;i++) if(!chk[i]) ans = max(ans, dfs(i));
	cout << ans;
}

Measured memory_bytes: 24636
#include<bits/stdc++.h>
using namespace std;
int n,m,a,ans;
vector<int> v;

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    v.push_back(0);
    for(int i=0;i<n;i++)
      cin>>a,v.push_back(a);
    for(int i=0;i<m;i++)
      cin>>a,v.push_back(a);
    sort(v.begin(),v.end());
    ans=0;
    for(int i=0;i<v.size()-1;i++)
      ans=max(ans,v[i+1]-v[i]);
    cout<<ans<<endl;
    v.clear();
  }
  return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int total = 0 ;
    int money = 0 ;
    while(1)
    {
        cin >> total ;
        if (!total) break ;
        for ( int i = 0 ; i < 9 ; i++ )
        {
            cin >> money ;
            total -= money ;
        }
        cout << total << endl ;
    }
    return 0 ;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
std::priority_queue<P, std::vector<P>, std::greater<P>> pq;

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

    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        int A, B;
        std::cin >> A >> B;

        pq.emplace(A, B);
    }
    
    ll sum = 0;

    while(M > 0){
        int A, B;
        std::tie(A, B) = pq.top();
        pq.pop();

        int n = std::min(M, B);
        sum += 1ll * n * A;
        B -= n;
        M -= n;

        if(B > 0){
            pq.emplace(A, B);
        }
    }

    std::cout << sum << std::endl;
}


Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int A = Integer.parseInt(str[0]);
        int B = Integer.parseInt(str[1]);
        int T = Integer.parseInt(str[2]);
        System.out.println(T / A * B);
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int ans[222222];
signed main(){
    cin>>N;
    vpint latte;
    rep(i,N){
        int a;cin>>a;
        latte.pb({a,i});
    }
    sort(all(latte));
    rep(i,latte.size()){
        if(i<N/2){
            ans[latte[i].se]=latte[N/2].fi;
        }
        else{
            ans[latte[i].se]=latte[N/2-1].fi;
        }
    }
    rep(i,N)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 7976
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi c(n - 1), s(n - 1), f(n - 1);
  rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
  rep(i, n - 1){
    int t = 0;
    for(int j = i; j < n - 1; j++){
      if(t < s[j]) t = s[j];
      else if(t % f[j] == 0);
      else t += f[j] - (t % f[j]);
      t += c[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
signed main() {
    cin >> N >> M;
    reps(i, bit(N) - 1) {
        reps(j, bit(M) - 1) {
            cout << ((__builtin_popcountll(i & j) ^ __builtin_popcountll(i - 1 & j)
                     ^ __builtin_popcountll(i & j - 1) ^ __builtin_popcountll(i - 1 & j - 1)) & 1);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3632
n=int(input())
a=0;w=0;r=0;tl=0
for _ in range(n):
  t=input()
  if(t=='AC'):
    a +=1
  elif(t=='WA'):
    w +=1
  elif(t=='RE'):
    r +=1
  elif(t=='TLE'):
    tl +=1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(tl))
print('RE x '+str(r))

Measured memory_bytes: 9148
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}



Measured memory_bytes: 1968
n = int(input())

prex = 0
prey = 0
pret = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    dt = t-pret
    mindis = abs(x-prex)+abs(y-prey)
    if dt >=mindis and (dt-mindis)%2==0:
        o = 1
    else:
        flag = False
    pret = t
    prex = x
    prey = y
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int N,M,i;
  int wa=0;
  int line;
  int select=0;
  int a[100];
  scanf("%d",&N);
  scanf("%d",&M);
  for(i=0;i<N;i++)
   scanf("%d",&a[i]);
  for(i=0;i<N;i++)
    wa=wa+a[i];
  line=(wa*100)/(4*M);
  for(i=0;i<N;i++){
    if(a[i]*100>=line)
      select=select+1;
  }
  if(M<=select)
    printf("Yes");
  else
    printf("No");
return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#define llint long long

using namespace std;

llint n, m;
llint a[105];

int main(void)
{
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
	
		for(int i = 1; i <= m; i++) a[i] = 0;
		
		llint d, v;
		for(int i = 1; i <= n; i++){
			cin >> d >> v;
			a[d] = max(a[d], v);
		}
		llint ans = 0;
		for(int i = 1; i <= m; i++) ans += a[i];
		cout << ans << endl;
	}
	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> d, v;
    v.push_back(0);
    rep(i, n) {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    sort(d.begin(), d.end());
    rep(i, n) {
        v.push_back(d[i] * (i%2 ? -1 : 1));
    }
    sort(v.begin(), v.end());
    int ans = 1e8;
    rep(i, n) {
        ans = min(ans, v[i+1] - v[i]);
    }
    ans = min(ans, abs(v[0] + 24 - v[n]));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, m, x;
  cin >> n >> m >> x;

  vector<bool> check(n+1, false);
  rep(i, m) {
    int a;
    cin >> a;
    check[a] = true;
  }

  int right = 0;
  for (int i = x; i <= n; ++i) {
    if (check[i]) ++right;
  }

  int left = 0;
  for (int i = x; i >= 0; --i) {
    if (check[i]) ++left;
  }

  cout << min(left, right) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n,a[1002],ans,ind,j;
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++)
{
	cin>>a[i];
}
int i=1;
while(i<=n)
{
	j=a[i];
	ind=i;
	while(j==a[i]&&i<=n)
		i++;
//		cout<<ind<<" "<<i<<" ";
	ans+=(i-ind)/2;
//	cout<<ans<<endl;
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()
    east = [0] * (N + 1)
    west = [0] * (N + 1)
    for i in range(1, N + 1):
        if S[i - 1] == "W":
            west[i] = west[i - 1] + 1
        else:
            west[i] = west[i - 1]
    for i in range(N - 1, -1, -1):
        if S[i] == "E":
            east[i] = east[i + 1] + 1
        else:
            east[i] = east[i + 1]

    ans = 10**18
    for n in range(N):
        ans = min(ans, west[n] + east[n + 1])
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 78564
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

D = []
for i in range(1, N):
    D.append(A[i] - A[i - 1])

if A[-1] % 2 == 1:
    print('first')
else:
    cnt_e, cnt_o = 0, 0
    for i in range(N - 1):
        if A[i] % 2 == 0:
            cnt_e += 1
        else:
            cnt_o += 1

    if cnt_o > 0:
        print('first')
    else:
        print('second')


Measured memory_bytes: 11572
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N,K = MI()
    i = 0
    ans = 0

    while True:
        i += 1
        if N <= (K**i)-1:
            ans = i
            break
    print(ans)





if __name__ == "__main__":
	main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#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 rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
ll y;
ll N;
void dfs(ll x, int a, int b,  int c)
{
    if(x>N) return;
    if(a&b&c) y++;
    dfs(10*x+7, 1, b, c);
    dfs(10*x+5, a, 1, c);
    dfs(10*x+3, a, b, 1);
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    cin >> N;
    y=0;
    dfs(0,0,0,0);
    cout << y << endl;
}

Measured memory_bytes: 256
/*input
100 100 100
*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/

int main()
{
    ifalse;
    int n, a, b;
    cin >> n >> a >> b;
    int ma = 0, mi = 0;
    mi = max(mi, a + b - n);
    ma = min(a, b);
    cout << ma << " " << mi, nl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<functional>

using namespace std;

int n, k;
int dis[100];
bool f = false;
int nowdis[100];
vector<vector<pair<int,int>>> edge;//to cost

int djk(int start, int end) {
	priority_queue < pair<int, int>, vector < pair<int, int>>, greater<pair<int, int>>> pq;// cost pos
	for (int i = 0; i < n; i++) {
		dis[i] = 100000000;
	}
	pq.push(make_pair(0, start));
	while (pq.size()) {
		pair<int, int> tmp = pq.top();
		pq.pop();
		if (tmp.first < dis[tmp.second]) {
			dis[tmp.second] = tmp.first;
			for (int i = 0; i < edge[tmp.second].size(); i++) {
				pq.push(make_pair(tmp.first + edge[tmp.second][i].second, edge[tmp.second][i].first));
			}
		}
	}
	if (dis[end] == 100000000)return -1;
	return dis[end];
}

int main() {
	while (cin >> n >> k, n * k) {
		edge.resize(n);
		for (int i = 0; i < k; i++) {
			int a;
			cin >> a;
			if (a == 0) {
				int b, c;
				cin >> b >> c;
				cout << djk(b - 1, c - 1) << endl;
			}
			else {
				int b, c, d;
				cin >> b >> c >> d;
				edge[b - 1].push_back(make_pair(c - 1, d));
				edge[c - 1].push_back(make_pair(b - 1, d));
			}
		}
		edge.clear();
	}
	return 0;
}

Measured memory_bytes: 3136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			List<String> vals = br.lines().limit(2).collect(Collectors.toList());
			int n = Integer.valueOf(vals.get(0));
			List<Integer> a = splitBySpace(vals.get(1)).stream().map(v -> Integer.valueOf(v)).collect(Collectors.toList());
			
			int alice = 0;
			int bob = 0;
			while(a.size() != 0){
				int value = a.stream().mapToInt(v -> v).max().getAsInt();
				alice += value;
				a.remove((Integer)value);
				if(a.size() == 0){
					break;
				}
				value = a.stream().mapToInt(v -> v).max().getAsInt();
				bob += value;
				a.remove((Integer)value);
			}
			
			System.out.println(alice - bob);
		}
	}


	private static List<String> splitBySpace(String target) {
		return Arrays.asList(target.split("\\s"));
	}

}


Measured memory_bytes: 26708
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll S, C;
    cin >> S >> C;
    
    ll ans = 0;
    if(2 * S <= C){
        C -= 2 * S;
        ans += S;
        S = 0;
        
    }
    else{
        ans += C / 2;
        S -= C / 2;
        C -= (C / 2) * 2;
        
    }
    ans += C / 4;
    output(ans);
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		string s = GetString();
		string t = GetString();
		for(int i = 0; i <= N; i++)
		{
			string u = s + t.Substring(N - i, i);
			if((u.IndexOf(s) == 0) && (u.IndexOf(t) == u.Length - N))
			{
				Console.WriteLine(u.Length);
				return;
			}
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define _GLIBCXX_DEBUG

int main(){
  
  int r, g, b;
  cin >> r >> g >> b;
  int c = 100*r + 10*g + b;
  if (!(c % 4))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}

Measured memory_bytes: 256
-- vim: set fdm=marker : -- {{{
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Monad.Fix (fix)
import Data.Maybe
import Data.Array.Unboxed
import qualified Data.IntMap as IM
import qualified Data.ByteString.Char8 as BS
-- }}}

-- Input functions with ByteString
-- {{{
tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

readInt :: Num a => BS.ByteString -> a
readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntTuple :: Num a => BS.ByteString -> (a, a)
readIntTuple = tuplify2 . map readInt . BS.words
readIntList :: Num a => BS.ByteString -> [a]
readIntList = map readInt . BS.words

getInt :: Num a => IO a
getInt = readInt <$> BS.getLine
getIntList :: Num a => IO [a]
getIntList = readIntList <$> BS.getLine
getIntN n = map readInt <$> replicateM (fromIntegral n) BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents
-- }}}

main = do
    [n,a,b] <- getIntList :: IO [Int]
    print $ min (n * a) b


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int k, x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
ans = ''
while True:
    a, op, b = map(str, input().split(' '))
    if op == '?':
        break
    else:
        a = int(a)
        b = int(b)
        if op == '+':
            ans += str(int(a + b)) + '\n'
        elif op == '-':
            ans += str(int(a - b)) + '\n'
        elif op == '*':
            ans += str(int(a * b)) + '\n'
        else:
            ans += str(int(a // b)) + '\n'
if ans != '':
    print(ans[:-1])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }
  rep(i,n-1){
    cin>>c[i];
  }
  int score=0;
  rep(i,n){
    score+=b[a[i]-1];
    if(a[i]+1==a[i+1]){
      score+=c[a[i]-1];
    }
  }
  cout<<score<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	int n; cin >> n;
	int d[n][2];
	bool possible = false;
	int cnt = 0;
	for(int i = 0 ; i < n ; i++){
		cin >> d[i][0] >> d[i][1];
		if(d[i][0] == d[i][1]){
			cnt++;
		}
		else cnt = 0;
		if(cnt >= 3){
			possible |= true;
		}
	}
	cout << (possible ? "Yes" : "No") << endl;


	

}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    }
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt), * )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(a:i32, b:i32);
    if (a % 2) != (b % 2) {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (a + b) / 2);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX 100
const llong mod = 1000000000 + 7;

int main()
{
  int S, W;
  scanf("%d%d", &S, &W);

  if (W >= S)
  {
    printf("unsafe\n");
  }
  else
  {
    printf("safe\n");
  }

  return 0;
}

Measured memory_bytes: 1632
N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
R = [abs(x-y)&1 for x, y in XY]
if not all(R[0] == r for r in R[1:]):
    print(-1)
    exit()
RM = max(abs(x)+abs(y) for x, y in XY)
D = [1 << i for i in range(32, -1, -1)]
if RM & 1 == 0:
    D.append(1)
W = ["" for _ in range(N)]
for d in D:
    for i in range(N):
        x, y = XY[i]
        if abs(x) > abs(y):
            if x > 0:
                x -= d
                W[i] += "R"
            else:
                x += d
                W[i] += "L"
        else:
            if y > 0:
                y -= d
                W[i] += "U"
            else:
                y += d
                W[i] += "D"
        XY[i] = (x, y)
print(len(D))
print(*D)
print(*W, sep="\n")

Measured memory_bytes: 3316
class SegmentTree():
    '''
    非再帰
    segment tree
    '''

    def __init__(self, n, func, init=float('inf')):
        '''
        n->配列の長さ
        func:func(a,b)->val,　func=minだとRMQになる
        木の高さhとすると,
        n:h-1までのノード数。h段目のノードにアクセスするために使う。
        data:ノード。data[0]:root<-leaf:data[-1]
        parent:k->child k*2+1とk*2+2
        '''
        self.n = 2**(n-1).bit_length()
        self.init = init
        self.data = [init]*(2*self.n)
        self.func = func

    def set(self, i, v):
        '''
        leafの初期化
        i: 0-origin idx
        v: value
        '''
        self.data[i+self.n-1] = v

    def build(self):
        '''
        setの後に一斉更新
        '''
        #leaf->rootに向かって、apply func していく
        for k in reversed(range(self.n-1)):
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def update(self, k, a):
        '''
        data[k]=aに更新する。
        更新をrootまで更新
        '''
        k += self.n-1 #k=segTree上での k-th leafのidx
        self.data[k] = a

        while k > 0: #while not reach to root
            k = (k-1)//2 #goto its parent
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2]) #update

    def query(self, l, r):
        '''
        [l,r)のfuncを求める
        '''
        L = l+self.n
        R = r+self.n
        ret = self.init
        while L < R:
            if R & 1: #R%2==1 
                R -= 1
                ret = self.func(ret, self.data[R-1]) #親が丸々区間に含まれない->はみ出したところを更新
            if L & 1:
                ret = self.func(ret, self.data[L-1])
                L += 1
            L >>= 1 #to parent
            R >>= 1
        return ret


    def lower_bound_index(self,x,v):
        """
        x:0-origin
        [x,N)の範囲で、v<=data[j]を満たす最小のjを探す(二分探索)

        存在しないなら、float("inf")をreturn している。
        """
        #区間の左端
        x+=self.n-1

        #data[x]が、v以上なるまで登る
        while self.data[x]<v:
            if x%2==0: #xが右のnodeなら、候補外になる
                if len(bin(x+1))==len(bin(x+2)):#一つ右に移動できるなら
                    x+=1
                else:#右に行けない->とりま大きい値をreturnしとく。(多分、全ての値が条件を満たさない時に、無限whileするのを防ぐ
                    return float("inf")

            else:#登る
                x>>=1

        # v<=data[x]を満たすように、できるだけ左(idxが小さい)に降る
        while x<self.n-1:#どこかの葉にたどり着くまで
            if self.data[2*x+1]>=v:#左の子が v<=data[x]を満たすなら、優先して左に。
                x=2*x+1
            else:#シャーなしの右
                x=2*x+2
        return x-self.n+1 #seg木のidxから、元のlistのidxに変換


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

Seg=SegmentTree(300005, lambda a,b:max(a,b),0)

ans=0
for a in A:
    tmp = Seg.query(max(a-K,0),min(300005,a+K)+1)

    tmp+=1
    Seg.update(a,tmp)
    ans = max(tmp,ans)
print(ans)


Measured memory_bytes: 103020
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
      cin>>p.at(i);
    }
  
  int count=0;
  
  for(int i=1;i<n-1;i++){
    if(p.at(i)>p.at(i-1) && p.at(i)<p.at(i+1) || p.at(i)<p.at(i-1) && p.at(i)>p.at(i+1)){
      count++;
    }
  }
  
  cout<<count<<endl;
  
  return 0;
  
}

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


int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    rep(i, S.size()){
        if(S.at(i) != T.at(i)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3920
n = int(input())
a = [0]+list(map(int,input().split()))
dp = [[0]*2 for _ in range(n+1)]
dp[1][1] = a[1]
dp[2][1] = max(a[1],a[2])

for i in range(3,n+1):
    if i % 2 == 1:
        dp[i][0] = max(dp[i-1][1],dp[i-2][0]+a[i])
        dp[i][1] = dp[i-2][1]+a[i]
    else:
        dp[i][0] = max(dp[i-1][0],dp[i-2][0]+a[i])
        dp[i][1] = max(dp[i-1][1],dp[i-2][1]+a[i])
if n % 2 == 1:
    print(dp[-1][0])
else:
    print(dp[-1][1])
#print(dp)

Measured memory_bytes: 114236
a = list(map(int, input().split())) 
b = list(map(int, input().split())) 

cnt = 0
n = a[1]

for i in range(a[0]):
    num = []
    num = list(map(int, input().split())) 
    sum = 0
    for j in range(a[1]):
        sum += b[j]*num[j]
   
    
    if sum + a[-1] > 0:
        cnt +=1

print(cnt)



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

int main() {
	int N, a;
	cin >> N;
	vector<int> human(N, 0);
	for (int i = 0; i < N-1; i++) {
		cin >> a;
		human[a - 1]++;
	}
	for (int n : human) cout << n << endl;
}


Measured memory_bytes: 4052
#include <iostream>

using namespace std;

int main() {
    int N, M;
    int x, y, t;
    char d[2];
    bool table[21][21], flag;

    while (cin >> N) {
        if (!N) { break; }

        for (int i = 0; i < 21; i++) {
            for (int j = 0; j < 21; j++) { table[i][j] = false; }
        }

        for (int i = 0; i < N; i++) {
            cin >> x >> y;
            table[x][y] = true;
        }

        x = 10; y = 10;
        cin >> M;

        while (M--) {
            cin >> d >> t;
            if (d[0] == 'N') {
                for (int i = 0; i < t; i++) {
                    table[x][++y] = false;
                }
            }
            if (d[0] == 'E') {
                for (int i = 0; i < t; i++) {
                    table[++x][y] = false;
                }
            }
            if (d[0] == 'S') {
                for (int i = 0; i < t; i++) {
                    table[x][--y] = false;
                }
            }
            if (d[0] == 'W') {
                for (int i = 0; i < t; i++) {
                    table[--x][y] = false;
                }
            }
        }

        flag = true;

        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 20; j++) {
                if (table[i][j]) {
                    flag = false;
                    break;
                }
            }
        }
        cout << (flag ? "Yes" : "No") << endl;
    }
    return 0;
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 s;
    cin >> s;

    constexpr i64 e = 1e9;
    if (s == e * e) {
        cout << 0 << " " << 0 << " ";
        cout << e << " " << 0 << " ";
        cout << 0 << " " << e << endl;
    } else {
        i64 x = e - s % e;
        i64 y = (s + x) / e;
        cout << 0 << " " << 0 << " ";
        cout << e << " " << 1 << " ";
        cout << x << " " << y << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("No War\n"); else printf("War\n");}
#define printans(ans) {printf("%d\n",(ans));}
typedef int* intarray;
typedef char* string;

int main(){
    int N, M, X, Y;
    scanf("%d%d%d%d", &N, &M, &X, &Y);
    int x, y, x_max, y_min;
    x_max = -100;
    for(int i=0; i<N; i++){
        scanf("%d", &x);
        x_max = (x>x_max) ? x : x_max;
    }
    y_min = 100;
    for(int i=0; i<M; i++){
        scanf("%d", &y);
        y_min = (y<y_min) ? y : y_min;
    }
    printjudge(X<y_min && y_min<=Y && x_max<y_min)
    return 0;
}

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

int main(){
  int n,m; cin>>n >>m;
  int A[50],B[50],C[50],D[50];
  for(int i=0;i<n;i++){
    cin>>A[i] >>B[i];
  }
  for(int i=0;i<m;i++){
    cin>>C[i] >>D[i];
  }
  for(int i=0;i<n;i++){
    int min_dist=abs(A[i]-C[0])+abs(B[i]-D[0]),checkpoints=1;
    
    for(int j=1;j<m;j++){
      const int cur_dist=abs(A[i]-C[j])+abs(B[i]-D[j]);
      if(min_dist>cur_dist){
        min_dist=cur_dist;
        checkpoints=j+1;
      }
    }
    cout<<checkpoints<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
def gcd(l, s)
  return l if s == 0

  gcd(s, l % s)
end

def trial_division(n)
  result = n
  (2..(n**0.5).to_i).each do |i|
    if n % i == 0
      result = i
      break
    end
  end
  if result == n
    [n]
  else
    [result] + trial_division(n / result)
  end
end

a, b = gets.split.map(&:to_i)
a, b = [a, b].minmax

num = gcd(b, a)
cands = trial_division(num)
cands |= [1]
puts cands.size


Measured memory_bytes: 1788
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >>k;
    long long sum=0;
    if(a>=k){
        sum = k;
    }else{
        k=k-a;
        sum = a;
        if(b>=k){

        }else{
            k=k-b;
            sum = sum-k;
        }
    }
    cout << sum << endl;
}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int max_ = numeric_limits<int>::min();
  max_ = max(max_, A + B);
  max_ = max(max_, A - B);
  max_ = max(max_, A * B);
  cout << max_ << endl;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

ans = 0

(n - 1).times do |i|
  l = s.chars[0, i + 1].uniq
  r = s.chars[i + 1, n - i].uniq

  ans = (l & r).count if (l & r).count >= ans
end

puts ans


Measured memory_bytes: 2172
#if 0

#endif
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF (1 << 30)
using namespace std;
using ll = long long;
int N, M, bit;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M;

    bit = pow(2, M) - 1;
    for (int n = 0; n < N; ++n) {
        int k; cin >> k;
        int like;
        int _like = 0;
        for (int kk = 0; kk < k; ++kk) {
            cin >> like;
            _like += pow(2, like - 1);
        }
        bit &= _like;
    }
    cout << __builtin_popcount(bit) << endl;

    return 0;
}

Measured memory_bytes: 512