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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    ll n,k;
    cin>>n>>k;
    V x(n);
    rep(i,n){
        cin>>x[i];
    }
    ll ans=MAXX;
    for(ll i=0;i+k-1<n;i++){
        ll tmp=min(abs(x[i]),abs(x[i+k-1]))+x[i+k-1]-x[i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scn = new Scanner(System.in);

        int int1 = scn.nextInt();
        int int2 = scn.nextInt();

        String x = Integer.toString(int1) + Integer.toString(int2);

        int y = Integer.parseInt(x);

        if (Math.sqrt(y) == (double) ((int) Math.sqrt(y))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 21972
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] list1 = new int[3][10];
        int[][] list2 = new int[3][10];
        int[][] list3 = new int[3][10];
        int[][] list4 = new int[3][10];
        int sum = sc.nextInt();
        int a,b,c,d;
        for(int i = 0; i < sum; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            d = sc.nextInt();
            if(a == 1){
                list1[b-1][c-1] = list1[b-1][c-1] + d;
            }
            if(a == 2){
                list2[b-1][c-1] = list2[b-1][c-1] + d;
            }
            if(a == 3){
                list3[b-1][c-1] = list3[b-1][c-1] + d;
            }
            if(a == 4){
                list4[b-1][c-1] = list4[b-1][c-1] + d;
            }
        }
        for(int i = 0; i < 3; i++){
            for(int n = 0; n < 10; n++){
                if(n == 9){
                    System.out.println(" " + list1[i][9]);
                }else{
                    System.out.print(" " + list1[i][n]);
                }
            }
        }
        System.out.println("####################");
        for(int i = 0; i < 3; i++){
            for(int n = 0; n < 10; n++){
                if(n == 9){
                    System.out.println(" " + list2[i][9]);
                }else{
                    System.out.print(" " + list2[i][n]);
                }
            }
        }
        System.out.println("####################");
        for(int i = 0; i < 3; i++){
            for(int n = 0; n < 10; n++){
                if(n == 9){
                    System.out.println(" " + list3[i][9]);
                }else{
                    System.out.print(" " + list3[i][n]);
                }
            }
        }
        System.out.println("####################");
        for(int i = 0; i < 3; i++){
            for(int n = 0; n < 10; n++){
                if(n == 9){
                    System.out.println(" " + list4[i][9]);
                }else{
                    System.out.print(" " + list4[i][n]);
                }
            }
        }
    }
}


Measured memory_bytes: 29684
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    int[] array = new int[2];
    Scanner scanner = new Scanner(System.in);
    int i = 0;
    while(scanner.hasNext() && scanner.hasNextInt() && i < array.length) {
      array[i] = scanner.nextInt();
      i++;
    }
    
    if(array[0] * array[1] % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int s[11];
int N;
vvi p;

void partition(int next, int sets) {
	if (next == N + 1) {
		for (int i = 1; i <= N; ++i) {
			cout << char(s[i] + 'a');
		}ndl;
		return;
	}

	for (int setID = 0; setID < sets; ++setID) {
		s[next] = setID;
		partition(next + 1, sets);
	}

	s[next] = sets;
	partition(next + 1, sets + 1);


}


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N;

	partition(1, 0);



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 1536
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: i32 = read();
    for i in (1..10).rev(){
	if n%i==0 && n/i <10{
	    println!("Yes");
	    return;
	}
    }
    println!("No");
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // in
            int N = Integer.parseInt(sc.next());
            int ac = 0, wa = 0, tle = 0, re = 0;
            String in;
            for (int i = 0; i < N; i++) {
                in = sc.next();
                switch (in) {
                    case "AC":
                        ac++;
                        break;
                    case "WA":
                        wa++;
                        break;
                    case "TLE":
                        tle++;
                        break;
                    case "RE":
                        re++;
                        break;
                }
            }
            System.out.println("AC x " + ac);
            System.out.println("WA x " + wa);
            System.out.println("TLE x " + tle);
            System.out.println("RE x " + re);
        }
    }
}

Measured memory_bytes: 57824
#include<stdio.h>

int main(){
    int i,n,k,d=0,g=0;
    scanf("%d %d",&n,&k);
    char s[n+1];
    scanf("%s",s);
    for(i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            d++;
        }
        else{
            g++;
        }
    }
    if(g>k+k){
        g=k+k;
    }
    d=d+g;
    printf("%d",d);
}


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

int main(){
    int n;
    cin >> n;
    int v[n+5];
    int c[n+5];
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll dp[31];
signed main(void)
{
  dp[1] = 1; dp[2] = 2; dp[3] = 4;
  FOR(i, 4, 31) {
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }

  int n;
  while(1) {
    cin >> n;
    if(!n) break;
    //cout << dp[n] << endl;
    cout << dp[n]/3650 + !!(dp[n]%3650) << endl;
  }

  return 0;
}

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

int n;
char a[19];

void Print()
{
	for(int i = 0;i<n;i++)cout << a[i];
	cout << endl;
}

void dfs(int x,int v)
{
	if(x==n)return Print();
	for(int i = 0;i<v;i++)
	{
		a[x] = 'a'+i;
		dfs(x+1,v);
	}
	a[x] = 'a'+v;
	dfs(x+1,v+1);
}

int main()
{
	cin >> n;
	a[0] = 'a';
	dfs(1,1);
	return 0;
}

Measured memory_bytes: 1536
for _ in range(int(input())):
    s = input().replace("->", ">").replace("<-", "<")
    t, train, s = s[0], [s[0]], s[1:]
    for i in range(0, len(s), 2):
        if s[i] == '>' and not s[i+1] in train:
            idx = train.index(t)+1
            train.insert(idx, s[i+1])
        elif not s[i+1] in train:
             idx = train.index(t)
             train.insert(idx, s[i+1])
        t = s[i+1]
    print(''.join(train))

Measured memory_bytes: 7532
$primes = [2,3]

def is_prime?(n)
	i = 0
	while $primes[i] <= Math.sqrt(n).to_i
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime?(n)
		n += 2
	end
end

def make_prime(n)
	while $primes[-1] <= n
		$primes << next_prime($primes[-1]+1)
	end
end

def print_prime(n)
	if is_prime?(n)
		i = $primes.index(n)
		puts "#{$primes[i-1]} #{$primes[i+1]}"
	else
		i = 0
		i += 1 while $primes[i] < n
		puts "#{$primes[i-1]} #{$primes[i]}"
	end
end

while gets
	n = $_.to_i
	if n < 3 || 50000 < n
		puts "n must be in the range (3..50000)"
		next
	end
	make_prime(n) if $primes[-2] < n
	print_prime(n)
end

Measured memory_bytes: 6152
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
 
#define rad(x) (x*atan(1.0)*4.0/180.0)
int n;
 
void koch( double x1, double y1, double x4, double y4, int d ){
    if( d == n ){
        printf("%.5lf %.5lf\n", x4, y4);
        return;
    }
    double x2 = (x4-x1) / 3.0 + x1;
    double y2 = (y4-y1) / 3.0 + y1;
    double x3 = (x4-x1) * 2.0 / 3.0 + x1;
    double y3 = (y4-y1) * 2.0 / 3.0 + y1;
    double x = (x3-x2)/2 - (y3-y2)*sqrt(3)/2 + x2;
    double y = (x3-x2)*sqrt(3)/2 + (y3-y2)/2 + y2;
    koch( x1, y1, x2, y2, d+1 );
    koch( x2, y2, x,  y,  d+1 );
    koch( x,  y,  x3, y3, d+1 );
    koch( x3, y3, x4, y4, d+1 );
}
 
int main(){
    cin >> n;
    cout << "0.00000 0.00000" << endl;
    koch(0.0,0.0,100.0,0.0,0);
    return 0;
}

Measured memory_bytes: 3224
module Main where

main :: IO ()
main = readLn >>= (putStrLn . f "")

f :: String -> Int -> String
f "" 0 = "0"
f s  0 = s
f s n | n `mod` 2 == 0 = f ('0' : s) (n `div` (-2))
      | otherwise      = f ('1' : s) ((n - 1) `div` (-2))


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    int r;
    cin >> r;
    cout << 2 * r * 3.141592 << endl;

    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

int main() {
	ll N, M;
	cin >> N >> M;
	IfOut(N * 2 > M , M / 2);
	ll ans = N;
	M -= N * 2;
	ans += M / 4;
	out(ans);
	return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(vector<ll> A) {
  cout << *max_element(ALL(A)) - *min_element(ALL(A)) << endl;
}

int main() {
  vector<ll> A(3);
  for (int i = 0; i < 3; i++) {
    cin >> A[i];
  }
  solve(move(A));
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) FOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int X;
    cin >> X;
    if (X == 1) {
        cout << 1 << endl;
        return 0;
    }
    int e = sqrt(1000);
    int res = 0;
    FOR(i, 2, e + 1, 1) {
        int p = i * i;
        if (p > X) {
            break;
        }
        while (p * i <= X) {
            p *= i;
        }
        amax(res, p);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    i64 n;
    i64 ans=0;
    cin >> n;
    for(int i=1; i<=n; i++) {
        i64 m = n / i;
        ans += (m*(2*i+(m-1)*i))/2;
    }
    cout << ans;
    return 0;
} 

Measured memory_bytes: 3620
#!/usr/bin/env python3

import sys

def frog1(n, hs):
    if n < 2:
        return 0

    if n == 2:
        return abs(hs[1] - hs[0])

    dp = [sys.maxsize] * (n)
    dp[0] = 0
    dp[1] = abs(hs[1] - hs[0])

    for i in range(2, n):
        dp[i] = min(dp[i - 2] + abs(hs[i] - hs[i - 2]), dp[i - 1] + abs(hs[i] - hs[i - 1]))

    return dp[n - 1]


def main():
    n = int(input())
    hs = list(map(int, input().split()))
    print(frog1(n, hs))


if __name__ == '__main__':
    main()

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,M;
int T[50010];
int S[50010];
int lis[]={9,11,0,2,4,5,7};

char t[3];
inline int in(){
    scanf("%s",t);
    return lis[t[0]-'A']+(t[1]=='#');
}
inline int add(int a,int b){
    a+=b;
    if(a>=12)a-=12;
    return a;
}

void solve(){
    scanf("%lld%lld",&N,&M);
    rep(i,N)T[i]=in();
    rep(i,M)S[i]=in();
    for(int fin=N-2;fin<N;fin++){
        bool ok=true;
        int pos=fin;
        for(int i=M-1;i>=0;i--){
            if(pos<0||pos==N){
                ok=false;
                break;
            }
            if(T[pos]==S[i])pos--;
            else if(add(T[pos],1)==S[i])pos-=2;
            else if(add(T[pos],11)==S[i])pos++;
            else{
                ok=false;
                break;
            }
        }
        if(ok&&pos==-1){
            puts("Yes");
            return;
        }
    }
    puts("No");
}

signed main(){
    int T;scanf("%lld",&T);
    while(T--)solve();
    return 0;
}

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

const int MAX_N = 15;

int main(){
  int n;
  int a[MAX_N][MAX_N];

  while(cin >> n){
    if(n==0) break;

    for(int i=0; i<n; i++)
      for(int j=0; j<n; j++)
	a[i][j]=0;
    
    int x=n/2+1, y=n/2;
    a[x][y]=1;
    for(int i=2; i<=n*n; i++){
      x++; y++;
      while(1){
	if(y>n-1) y=0;
	if(y<0) y=n-1;
	if(x>n-1) x=0;
	if(a[x][y]==0) break;
	x++; y--;
      }
      a[x][y] = i;
      //      cout << a[x][y] << endl;
    }
    
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
	printf("%4d",a[i][j]);
      }
      cout << endl;
    }
  }

}

Measured memory_bytes: 0
#include <iostream>
#include<math.h>

using namespace std;

int main()
{
    int N,M;
    cin >> N >> M;
    int A[M];
    int somme=0,x;
    for ( int i=0;i<M;i++){
      cin >>x;
      A[i]=x;
      somme+=x;
    }
    if(somme>N){cout<< -1;}
    else{cout<< N-somme;}

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  vector<int> v;
  if (s[0] == '1')
    v.push_back(0);

  char bef = s[0];
  int count = 1;
  rep(i, 1, n) {
    if (bef == s[i]) {
      count++;
    } else {
      v.push_back(count);
      count = 1;
    }
    bef = s[i];
  }

  if (count > 0)
    v.push_back(count);

  int vn = v.size();
  vector<ll> acc(vn + 1, 0);
  rep(i, 1, vn + 1) acc[i] = acc[i - 1] + v[i - 1];

  ll ans = 1;

  int start = 1;
  if (acc[1] == 0)
    start = 2;

  for (int i = start; i < vn + 1; i++) {
    if (i & 1) {
      chmax(ans, acc[min(vn, i + (k * 2) - 1)] - acc[i - 1]);
    } else {
      chmax(ans, acc[min(vn, i + (k * 2))] - acc[i - 1]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL A, B; cin >> A >> B;
		UL Q; cin >> Q;
		set<LL> shrine; rep(i, A) { LL x; cin >> x; shrine.insert(x); }
		set<LL> temple; rep(i, B) { LL x; cin >> x; temple.insert(x); }
		shrine.insert(-1e11); shrine.insert(-1e11); shrine.insert(1e11); shrine.insert(1e11);
		temple.insert(-1e11); temple.insert(-1e11); temple.insert(1e11); temple.insert(1e11);
		rep(i, Q) {
			LL X; cin >> X;
			LL ans = 1e11;
			LL nSh[2], nTm[2];
			{
				auto itr = shrine.upper_bound(X);
				nSh[1] = *itr - X; itr--; nSh[0] = X - *itr;
			}
			{
				auto itr = temple.upper_bound(X);
				nTm[1] = *itr - X; itr--; nTm[0] = X - *itr;
			}
			ans = min(ans, max(nSh[0], nTm[0]));
			ans = min(ans, max(nSh[1], nTm[1]));
			ans = min(ans, min(nSh[0], nTm[1]) + nSh[0] + nTm[1]);
			ans = min(ans, min(nSh[1], nTm[0]) + nSh[1] + nTm[0]);
			cout << ans << endl;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<vector<int>> z(n, vector<int> (m));
    for (int i = 0; i < n; i++) {
        string h;
        cin >> h;
        int y = 0;
        for (int j = 0; j < m; j++) {
            if (h.at(j) == '.')y++;
            else {
                for (int k = 0; k < y; k++) {
                    z.at(i).at(j - k - 1) += y;
                }
                y = 0;
            }
        }
        for (int k = 0; k < y; k++) {
            z.at(i).at(m-k-1) += y;
        }
    }
    for (int i = 0; i < m; i++) {
        int y = 0;
        for (int j = 0; j < n; j++) {
            if (z.at(j).at(i) != 0)y++;
            else {
                for (int k = 0; k < y; k++) {
                    z.at(j-k-1).at(i) += y;
                }
                y = 0;
            }
        }
        for (int k = 0; k < y; k++) {
            z.at(n-k-1).at(i) += y;
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            ans = max(ans, z.at(j).at(i)-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	char ch; cin>>ch;
	cout<<char(ch+1)<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S; cin >> S;
	S[5] = ' ', S[13] = ' ';
	cout << S << endl;
}


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

int main(){

    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = a % b;
    f = double(a) / double(b);

    cout << d << " " << r << " " << fixed << setprecision(10) << f << endl;

    return 0;

}


Measured memory_bytes: 3232
function Main(input) {
	input = input.split("\n");
	var arr = input[1].split(" ").map(Number);
	var sum = 0;
	for(var i=1;i<arr.length-1;i++){
		if((arr[i-1]<arr[i]&&arr[i]<arr[i+1])||(arr[i-1]>arr[i]&&arr[i]>arr[i+1])){
			sum++;
		}
	}
	console.log(sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int, int, int> tiii; // node, cost, parent
typedef long long ll;

struct Comp
{
	bool operator() (tiii a, tiii b)
	{
		return get<1>(a) > get<1>(b);
	}
};

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

int find_index(vector<int> a, int x)
{
	if (a.size() == 0) return -1;

	int l = 0;
	int r = a.size();
	while (l + 1 != r)
	{
		int mid = (l + r) / 2;
		if (a[mid] <= x)
			l = mid;
		else
			r = mid;
	}
	if (a[l] == x)
		return l;
	else
		return -1;
}

int main()
{
	int R, C, M; cin >> R >> C >> M;

	vs grids(R);
	rep(y, 0, R) cin >> grids[y];

	vvi consume(R, vi(C, 0));
	rep(y, 0, R) rep(x, 0, C) cin >> consume[y][x];

	vvi turnon(R, vi(C, 0));
	rep(y, 0, R) rep(x, 0, C) cin >> turnon[y][x];

	vvi turnoff(R, vi(C, 0));
	rep(y, 0, R) rep(x, 0, C) cin >> turnoff[y][x];



	vi order;
	int _x, _y; cin >> _y >> _x;
	int bak = _y * C + _x;
	order.push_back(bak);
	rep(_m, 1, M)
	{
		int y, x; cin >> y >> x;
		int s = y * C + x;

		vi dist(R*C, INF);
		vi back(R*C, -INF);
		priority_queue<tiii, vector<tiii>, Comp> que;
		que.push(tiii(bak, 0, -1));
		dist[bak] = 0;
		while (!que.empty())
		{
			tiii t = que.top(); que.pop();

			int node = get<0>(t);
			int cost = get<1>(t);

			if (back[node] != -INF) continue;
			back[node] = get<2>(t);

			if (node == s) break;

			rep(i, 0, 4)
			{
				int xx = (node % C) + dx[i];
				int yy = (node / C) + dy[i];

				if (xx < 0 || C <= xx) continue;
				if (yy < 0 || R <= yy) continue;
				if (grids[yy][xx] == '#') continue;

				int ss = yy * C + xx;

				if (cost + 1 < dist[ss])
				{
					dist[ss] = cost + 1;
					que.push(tiii(ss, cost + 1, node));
				}
			}
		}

		vi tmp;
		int to = s;
		while (0 <= to)
		{
			tmp.push_back(to);
			to = back[to];
		}
		rep(i, 1, tmp.size()) order.push_back(tmp[tmp.size() - 1 - i]);

		bak = s;
	}



	vvi list(R*C);
	rep(i, 0, order.size()) list[order[i]].push_back(i);

	ll ans = 0;

	vi onoff(R*C, 0);
	ll pluscost = 0;
	rep(i, 0, order.size())
	{
		if (i != 0) ans += pluscost;

		int node = order[i];
		int y = node / C;
		int x = node % C;

		if (onoff[node] == 0) ans += (ll)turnon[y][x];

		int index = find_index(list[node], i);

		if (list[node].size() - 1 == index)
		{
			// last
			ans += (ll)turnoff[y][x];
			if (onoff[node] == 1) pluscost -= (ll)consume[y][x];
			onoff[node] = 0;
			continue;
		}

		if (consume[y][x] * (list[node][index + 1] - list[node][index]) < turnon[y][x] + turnoff[y][x])
		{
			// tukeppa
			if (onoff[node] == 0) pluscost += (ll)consume[y][x];
			onoff[node] = 1;
		}
		else
		{
			ans += (ll)turnoff[y][x];
			if (onoff[node] == 1) pluscost -= (ll)consume[y][x];
			onoff[node] = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 13120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    

    ll x;
    cin>>x;
    ll p = 100;
    ll count = 0;
    ll check = 1;

    while(true){

        if(p>=x){
            break;
        }
        if(check <= 10){
            p+= floor(0.01*p);
            count++;
        }else{
            p+= (0.01* p);
            count++;
        }

    }
    cout<<count<<endl;
}

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

int main(){
  int n;
  int count;
  cin >> n;
  if (n==100000){
    cout << 90000+900+9;
  } else if (n>= 10000){
    cout << n-9999+900+9;
  } else if (n>=1000){
    cout << 900+9;
  } else if (n>=100){
    cout << n-99+9;
  } else if (n>=10){
    cout << 9;
  } else if (n>=1){
    cout << n;
  }
}


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

#define int long long

using namespace std;



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

    int N;
    cin >> N;

    int temp = 0;

    int res = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	int n;
    	cin >> n;

    	if(temp <= n)
    	{
    		temp = n;
    	}
    	else
    	{
    		res += temp-n;
    	}
    }

    cout << res << '\n';

    return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<P> D(N);
    rep(i, N){
        int a, b; cin >> a >> b;
        D[i].first = a;
        D[i].second = b;
    }
    sort(D.begin(), D.end());
    int now = 0;
    ll ans = 0;
    rep(i, N){
        ll b = D[i].second;
        if(now+b > M){
            b = M - now;
        }
        now += b;
        ans += b * D[i].first;
        if(now == M)break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4000
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  ll ans = 0;
  rep(i,1,v.sz){
    ll a = min(0LL,v[i]-v[i-1]);
    v[i]-=a;
    ans -= a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5364
#include<stdio.h>
int main(){
int N,i;
long long int A[200],B[200],min=1000000000;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&A[i]);
for(B[i]=0;A[i]%2==0;B[i]++){
A[i]=A[i]/2;
}
if(min>B[i]){
min=B[i];}}
printf("%d",min);
return 0;

}

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

void solv() {
    vector<char> str;
    string buf;
    cin >> buf;
    // cout << "buf:" << buf[0] <<buf[1]<< endl;
    for (int i = 0; i < buf.size(); i++) {
        if (buf[i] != 'B') {
            str.push_back(buf[i]);
        } else {
            if (str.size() > 0)
                str.pop_back();
        }
    }
    rep(i, str.size()) {
        cout << str[i];
    }
    cout << endl;
}

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

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N];
int32_t main() {
	int n;
	cin >> n;
	for (int j = 0; j < n; ++j) {
		cin >> a[j];	
	}
	int mn = 2, mx = 2;
	if (a[n - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	for (int j = n - 2; j >= 0; --j) {
		int nmx = (mx + a[j + 1] - 1) / a[j] * a[j];
		int nmn = (mn - 1) / a[j] * a[j] + a[j];
		if (nmx < nmn) {
			cout << -1 << endl;
			return 0;
		}
		mx = nmx;
		mn = nmn;
	}
	cout << mn << ' ' << mx + a[0] - 1 << endl;
}









Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll n, k;
ll a[220000], f[220000];

ll binary_search(ll k)
{
  ll l = 0, r = 1e12, mid;  
  while (l < r) {
    mid = (l + r) / 2;
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
      cnt += (max(0LL, a[i] * f[i] - mid) + f[i] - 1) / f[i];
    }
    if (cnt <= k) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return l;
}

int main() {
  cin >> n >> k;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (ll i = 0; i < n; i++) {
    cin >> f[i];
  }
  sort(a, a+n);
  sort(f, f+n, greater<ll>());
  
  cout << binary_search(k) << endl;
  return 0;
}

Measured memory_bytes: 3328
N, K = map(int, input().split())
a = list(map(int, input().split()))
dic = {}

for elem in a:
    if elem not in dic:
        dic[elem] = 1
    else:
        dic[elem] += 1

kosuu_list = []
for key in dic:
    kosuu_list.append(dic[key])
kosuu_list_asc = sorted(kosuu_list)

ans = 0
for i in range(len(kosuu_list_asc) - K):
    ans += kosuu_list_asc[i]
print(ans)


Measured memory_bytes: 32288
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

double A[10];
string B;
ll N, K;
double ans;


int main(void) {
	cin >> N;
	FOR(i, 0, N) {
		cin >> A[i] >> B;
		if (B[0] == 'B') {
			ans += A[i] * 380000.0;
		}
		else {
			ans += A[i];
		}
	}

	ct(ans);

	return 0;
}


Measured memory_bytes: 256
N, K, S=map(int, input().split())
Ans=[]

for i in range(K):
    Ans.append(S)

if S!=10**9:
    for i in range(N-K):
        Ans.append(S+1)
else: 
    for i in range(N-K):
        Ans.append(1)
 
print(*Ans)

Measured memory_bytes: 9580
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define U (LL)0
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>o;
        if(i==0)
        {
            k=o;
        }
        else
        {
            k=__gcd(k,o);
        }
    }
    cout<<k<<endl;
    return 0;

}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll MODP = 998244353;

ll gen(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x%MODP;
  if(y%2 == 1){
    return ((x%MODP)*(gen(x,y-1))%MODP)%MODP;
  }else{
    ll t = gen(x,y/2);
    return ((t%MODP)*(t%MODP))%MODP;
  }
}

ll comb(ll x,ll y){
  if(y == 0)return 1;
  ll res = 1;
  rep(i,y){
    res = ((res%MODP)*((x-i)%MODP))%MODP;
  }
  for(ll i = 1;i <= y;i++){
    res = ((res%MODP)*gen(i,MODP-2))%MODP;
  }
  return res%MODP;
}

int main(){
  ll N;
  cin >> N;
  vector<double> p(N+1);
  rep(i,N)cin >> p[i];
  double dp[N+5][N+5];
  dp[0][0] = 1;
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      if(i + j < N){
        dp[i][j+1] += dp[i][j]*(1.0-p[i+j]);
        dp[i+1][j] += dp[i][j]*p[i+j];
      }
    }
  }
  double ans = 0.0;
  rep(i,N+1)rep(j,N+1){
    if(i == 0 & j == 0)continue;
    if(i > j & i + j == N){
      ans += dp[i][j];
    }
  }
  cout << fixed << setprecision(10) << ans << endl;



  return 0;
}


Measured memory_bytes: 49868
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 300005;

int a[MAX_N];
int n;

int main()
{
	scanf("%d",&n);
	rep(i,3*n){
		scanf("%d",&a[i]);
	}
	sort(a,a+3*n,greater<int>());
	ll ans=0;
	rep(i,n){
		ans += a[2*i+1];
	}
	printf("%lld\n",ans);		
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((abs(a-c)<=d) || (abs(a-b)<=d) & (abs(b-c)<=d)){
        printf("Yes");
    }
    else{
        printf("No");
    }
}


Measured memory_bytes: 128
#include<queue>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7ffffff
using namespace std;
int main()
{
    int n,m,v,x,y,maxa,maxb;
	maxa=-inf;maxb=inf;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for(int i=1;i<=n;i++){scanf("%d",&v);maxa=max(maxa,v);}; 
	for(int i=1;i<=m;i++){scanf("%d",&v);maxb=min(maxb,v);};
	if(maxa<maxb&&maxa<y&&maxb>x&&x<y)printf("No War");
	else printf("War"); 
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	VISITED = 1
)

var (
	n int
	m int
	a []int
	b []int

	graph map[int][]int

	ans int
)

func main() {
	n = readi()
	m = readi()
	a = make([]int, m)
	b = make([]int, m)
	for i := 0; i < m; i++ {
		a[i] = readi()
		b[i] = readi()
	}

	// init graph
	graph = make(map[int][]int)
	for i := 0; i < m; i++ {
		graph[a[i]] = append(graph[a[i]], b[i])
		graph[b[i]] = append(graph[b[i]], a[i])
	}

	// init visited
	visited := make([]int, n+1)
	for i := 0; i <= n; i++ {
		visited[i] = -1
	}

	dfs(1, 1, visited)
	fmt.Println(ans)
}

func dfs(p, depth int, visited []int) {
	tmpVisited := make([]int, len(visited))
	copy(tmpVisited, visited)
	if depth == n {
		ans++
		return
	}
	tmpVisited[p] = VISITED

	dests, ok := graph[p]
	if !ok {
		return
	}
	for _, d := range dests {
		if tmpVisited[d] == VISITED {
			continue
		}
		dfs(d, depth+1, tmpVisited)
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_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
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int H, W;
	while(cin >> H >> W && H)
	{
		vector<string>	field(H);
		vector<vint>	dp(H, vint(W, 0));

		rep(i, H) cin >> field[i];
        
        rep(y, H) rep(x, W)
            for(int dx = 0; x + dx < W && field[y][x + dx] == '.'; dx++)
                dp[y][x]++;
        
		int res = 0;
        rep(y, H) rep(x, W)
		{
			int mi = 1 << 30;
			rep(k, y + 1)
        	{
				chmin(mi, dp[y - k][x]);
				chmax(res, mi * (k + 1));
        	}
		}
		
		cout << res << endl;
    }
}

Measured memory_bytes: 2180
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab,key=lambda x: x[1])
now = 0
for i in ab:
    if i[1] >= now + i[0]:
        now += i[0]
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 55264
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++ -o C_Colon.exe C_Colon.cpp 
Execute: ./C_Colon
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include <cstring> 
#include<bits/stdc++.h> 
#include <string>  
using namespace std;

int main() { 	
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	
	double hour_angle, minute_angle, between_angle, 
		length_between; 
	
	hour_angle = (360.0 / 12.0 * (H + M / 60.0)) * M_PI / 180.0; 
	minute_angle = (360.0 / 60.0) * M * M_PI / 180.0; 
	between_angle = hour_angle - minute_angle; 
	
	length_between = sqrt(A*A + B*B - 2*A*B*cos(between_angle)); 
	
	// Output angles (test) 
	cout << setprecision(11) << length_between << endl; 
	
	return 0; 
} 


Measured memory_bytes: 4216
num = int(input())
count=0

for i in range(num):
  line = input().split()
  nums = [int(a) for a in line]
  if nums[0]==nums[1]:
    count+=1
  else:
    count=0
  if count==3:
    break

if count==3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9136