akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
int H = 1;
using namespace std;
int left(int i) { return i*2; }
int right(int i){ return i*2+1;}
int parent(int i){return i/2;}

int heap[2000001];
/**
 * O(logH)
 */
void maxHeapify(int i) {
    int l = left(i);
    int r = right(i);
    int maxind = i;
    if(l <= H && heap[l] > heap[maxind]) {
        maxind = l;
    }
    if(r <= H && heap[r] > heap[maxind]) {
        maxind = r;
    }

    if(maxind != i) {
        swap(heap[i], heap[maxind]);
        maxHeapify(maxind);
    }
}

void insert(int v) {
    heap[H] = v;
    int i = H;
    while(parent(i) >= 1 && heap[i] > heap[parent(i)]) {
        swap(heap[i], heap[parent(i)]);
        i = parent(i);
    }
    H++;
}

void extract() {
    cout << heap[1] << "\n";
    heap[1] = heap[--H];
    maxHeapify(1);
}

int main() {
    char command[20];
    while(true) {
        scanf("%s", &command);
        if (!strcmp(command, "insert"))
        {
            int val;
            scanf("%d", &val);
            insert(val);
        }
        else if (!strcmp(command, "extract"))
        {
            extract();
        }
        else if (!strcmp(command, "end"))
        {
            break;
        }
    }
}



Measured memory_bytes: 7044
#include<iostream>

using namespace std;

int main()
{
  int n;
  long long int dp[31]={1,1,2};
  for(int i=3;i<31;i++)
      dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  for(;cin>>n,n;)
    cout<<(long long int)((dp[n]/3650.0)+0.999999)<<endl;
}

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

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

    if (a > 9)
    {
        cout << "-1" << endl;
        return 0;
    }

    if (b > 9)
    {
        cout << "-1" << endl;
        return 0;
    }

    cout << a * b << endl;

    return 0;
}

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

int main(){
  int R;
  cin >> R;
  
  if(R < 1200){
    cout << "ABC" << endl;
  }else if(R < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }

  return 0;
}

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

//素因数分解
vector<pair<ll,ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  for (long long a = 2; a * a <= n; a++){
    if(n % a != 0) continue;
    ll ex = 0; //指数
    while(n % a == 0){
      ex++;
      n /= a;
    }
    res.push_back(make_pair(a, ex));
  }
  if(n != 1){
    res.push_back(make_pair(n, 1));
  }
  return res;
}


int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> num(1100000, 0);
  rep(i,n){
    cin >> a[i];
    auto pf = prime_factorize(a[i]);
    for(auto p :pf) num[p.first] = max(num[p.first], p.second);
  }
  mint lc_num = 1;
  for (int i = 2; i < 1100000; i++){
    lc_num *= modpow(mint(i), num[i]);
  }
  mint ans = 0;
  rep(i,n){
    ans += lc_num / a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 8960
#include <iostream>
#include <string.h>

#define MAX_LINE 8
#define MAXA_DATA 50

using namespace std;

// プロトタイプ宣言
void searchString(string box);

// main関数
int main() {
    int count = 0;
    int max = MAX_LINE * MAXA_DATA;
    char str[8];
    string box;
    for (int i = 0; i < max; i++) {
        while(cin >> str){
            //cin >> str;
            box.append(str);
            count++;
            // 8行ごとにチェック
            if(count%MAX_LINE == 0){
                searchString(box);
                box = "";
                //cout << "flag" << endl;
            }
        }
    }
}

// 文字列チェック
void searchString(string box){
    string A("1100000011");
    string B("1000000010000000100000001");
    string C("1111");
    string D("1000000110000001");
    string E("11000000011");
    string F("100000001100000001");
    string G("110000011");
    
    // find関数は文字列がみつからなかったときにnposを返す
    if (box.find(A) != std::string::npos) {
        cout << "A" << endl;
    }
    else if(box.find(B) != std::string::npos) {
        cout << "B" << endl;
    }
    else if(box.find(C) != std::string::npos) {
        cout << "C" << endl;
    }
    else if(box.find(D) != std::string::npos) {
        cout << "D" << endl;
    }
    else if(box.find(E) != std::string::npos) {
        cout << "E" << endl;
    }
    else if(box.find(F) != std::string::npos) {
        cout << "F" << endl;
    }
    else if(box.find(G) != std::string::npos) {
        cout << "G" << endl;
    }
}


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

int main() {
  int n, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0 && (a % 5 && a % 3)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

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

int main(){
    int n;
    while(cin >> n, n != 0){
        int cnt = 0;
        while(1){
            if(n == 1) break;
            if(n % 2 == 0){
                n /= 2;
            }else{
                n = 3*n + 1;
            }
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main(){
    long long N,K;
    cin>>N>>K;
    N = N%K;
    
    if(N==0){
        cout<<N<<endl;
    }else if(K-N<N){
        cout<<K-N<<endl;
    }else if(K-N>N){
        cout<<N<<endl;
    }
}


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

int main()
{
    int n, x;
    cin >> n >> x;

    int boundCount = 1;
    int prevD = 0;

    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;
        int boundD = prevD + input;

        if (boundD <= x)
        {
            ++boundCount;
        }

        prevD = boundD;
    }

    cout << boundCount << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    const int MaxNum = 1000000;
    static bool[] isPrime = Enumerable.Repeat(true, MaxNum).ToArray();

    static void Main()
    {
        InitializePrimeArray();
        int n = 0;
        while (int.TryParse(Console.ReadLine(), out n))
        {
            var cnt = isPrime.Where((flg, idx) => flg && idx <= n).Count();
            Console.WriteLine(cnt);
        }
    }

    static void InitializePrimeArray()
    {
        for (int i = 0; i <= Math.Sqrt(MaxNum); i++)
        {
            if(i == 0 || i == 1) isPrime[i] = false;
            else if(isPrime[i])
            {
                for (int j = i * 2; j < MaxNum; j += i)
                {
                    isPrime[j] = false;
                }
            }
        }
    }
}

Measured memory_bytes: 12124
S = input()
T = input()
ans = ""
for i in range(len(S)-len(T)+1):
  u = S[i:i+len(T)]
  flag = True
  for j in range(len(T)):
    if u[j] == T[j] or u[j] == "?":
      continue
    else:
      flag = False
      break
  if flag:
    ans = S[0:i] + T + S[i+len(T):]
if ans != "":
  print(ans.replace("?","a"))
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		int[] Hb = new int[H];
		int[] Wb = new int[W];
		String[] graph = new String[H];
		int total = 0;
		for (int i = 0; i < H; i++) {		
			String s = sc.next();
			graph[i] = s;
			char[] c = s.toCharArray();
			for (int j = 0; j < W; j++) {
				if (c[j] == '#') {
					Hb[i]++;
					total++;
				}
			}
		}
		for (int i = 0; i < W; i++) {
			for (String s : graph) {
				if (s.toCharArray()[i] == '#') {
					Wb[i]++;
				}
			}
		}
		List<List<Integer>> Hnum = new ArrayList<>();
    	for (int i = 1; i < Math.pow(2, H); i++) {
    		List<Integer> num = new ArrayList<>();
    		for (int j = 0; j < H; j++) {
    			if (((i>>j)&1) == 1) {
    				num.add(j);
    			}
    		}
    		Hnum.add(num);
    	}
		List<List<Integer>> Wnum = new ArrayList<>();
    	for (int i = 1; i < Math.pow(2, W); i++) {
    		List<Integer> num = new ArrayList<>();
    		for (int j = 0; j < W; j++) {
    			if (((i>>j)&1) == 1) {
    				num.add(j);
    			}
    		}
    		Wnum.add(num);
    	}
    	int ans = 0;
    	for (int i = -1; i < Hnum.size(); i++) {
    		int score = total;
    		List<Integer> Hp = null;
    		if (-1 < i) {
    			Hp = Hnum.get(i);
        		for (Integer n : Hp) {
        			score -= Hb[n];
        		}
    		}
    		if (score < K) {
    			continue;
    		} else {
    			for (int j = -1; j < Wnum.size(); j++) {
    				int score2 = score;
    				if (-1 < j) {
            			List<Integer> Wp = Wnum.get(j);
                		for (Integer n : Wp) {
                			int db = 0;
                			if (Hp != null) {
                    			for (Integer Hn : Hp) {
                    				String s = graph[Hn];
                    				if (s.charAt(n) == '#') {
                    					db++;
                    				}
                    			}
                			}
                			score2 -= (Wb[n]-db);
                		}
    				}
            		if (score2 == K) {
            			ans++;
            		}
        		}
    		}
    	}
    	System.out.println(ans);
	}
}

Measured memory_bytes: 36280
#include <iostream>
#include <map>
#include <vector>
using namespace std;

long long int hex2int(string s, map<char,int> &M){
  long long int ret = 0;
  for(int i = 0; i < s.length(); ++i){
    ret *= 16;
    ret += M[s[i]];
  }
  return ret;
}

string int2hex(long long int x){
  if(x == 0) return "0";
  string ret = "";
  while(x > 0){
    int t = x%16;
    x /= 16;
    if(t > 9) ret = (char)('a'+t-10) + ret;
    else ret = (char)('0'+t) + ret;
  }
  return ret;
}

int main() {
  int s;
  cin >> s;
  map<char, int> M;
  for(int i = 0; i < 10; ++i) M['0' + i] = i;
  for(int i = 0; i < 6; ++i) M['a' + i] = i + 10;

  for(int i = 0; i < s; ++i){
    vector<long long int> N;
    string s;
    for(int j = 0; j < 9; ++j){
      cin >> s;
      N.push_back(hex2int(s,M));
    }
    long long int ans = 0, MOD = (1LL<<32);
    int t = 0, u = 0;

    while(t < 32){
      int v = 0;
      for(int j = 0; j < 8; ++j){
        if((N[j]>>t) & 1) ++v;
      }
      if((v+u)%2 != ((N[8]>>t) & 1)){
        ans += 1LL<<t;
        v = 8 - v;
      }
      ++t;
      u = (u+v)/2;
    }
    
    cout << int2hex(ans) << endl;
  }
  return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,sum=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  for(int i=0;i<n;i++)   
  {
     for(int j=i+1;j<n;j++)
       sum+=a[j]*a[i];
  }
  cout<<sum;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,i,line[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&line[i]);
    for(i=n-1;i>=0;i--)
        printf("%d%s",line[i],i==0?"\n":" ");
    return 0;
}

Measured memory_bytes: 596
import * as fs from 'fs';

function main(input: string) {
  let lines = input.split('\n');
  let tmp = lines[0].split(' ');

  let N = Number(tmp[0]);
  let A = Number(tmp[1]);

  let x = [0];
  x = x.concat(lines[1].split(' ').map(Number));

  let dp = new Array(N + 1);
  for (let i = 0; i <= N; ++i) {
    dp[i] = new Array(N + 1);
    for (let j = 0; j <= N; ++j) {
      dp[i][j] = new Array(A * N + 1).fill(0);
    }
  }

  for (let i = 0; i < N; ++i) dp[i][0][0] = 1;

  for (let i = 1; i <= N; ++i) {
    for (let j = 1; j <= i; ++j) {
      for (let k = 1; k <= A * N; ++k) {
        if (k < x[i]) {
          dp[i][j][k] = dp[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }

  let ans = 0;
  for (let j = 1; j <= N; ++j) {
    ans += dp[N][j][j * A];
  }

  console.log(ans);
}

main(fs.readFileSync('/dev/stdin', 'utf8').toString());

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

class BIT {
   public:
    explicit BIT(int64_t nn) : n(pow(2, ceil(log2(nn)))), b(n + 1) {}

    void init() { b.assign(n + 1, 0); }

    // [0, i)の和
    int64_t sum(int64_t i) const {
        int64_t s = 0;

        while (i > 0) {
            s += b[i];
            i -= (i & -i);
        }

        return s;
    }

    void add(int64_t i, int64_t a) {
        // 1-indexedに直す
        ++i;

        while (i <= n) {
            b[i] += a;
            i += (i & -i);
        }
    }

   private:
    int64_t n;
    vector<int64_t> b;
};

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> r = a;
    sort(r.begin(), r.end());

    BIT bit(n + 1);
    auto ans = *partition_point(r.begin(), r.end(), [&](int64_t m) {
        vector<int64_t> b(n + 1);
        map<int64_t, int64_t> idxs;
        idxs[b[0]] = 0;
        for (auto i : irange(1L, n + 1)) {
            b[i] = b[i - 1] - 1;
            if (a[i - 1] <= m) {
                b[i] += 2;
            }
            idxs[b[i]] = 0;
        }

        int64_t idx = 0;
        for (auto&& kv : idxs) {
            kv.second = idx++;
        }

        bit.init();
        bit.add(idxs[b[0]], 1);
        int64_t k = 0;
        for (auto i : irange(1L, n + 1)) {
            k += bit.sum(idxs[b[i]]);
            bit.add(idxs[b[i]], 1);
        }

        return k <= n * (n + 1) / 2 / 2;
    });

    cout << ans << endl;
}

Measured memory_bytes: 9920
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
ll a[100001];
ll b[100001];
ll c[100001];
bool comp(ll x, ll y) {
	return x > y;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < C; i++) {
		cin >> c[i];
	}

	sort(a, a + A);
	sort(b, b + B);
	sort(c, c + C, comp);
	ll sum = 0;
	int l = A - X;
	int r = B - Y;
	int z = 0;
	
	while (l < A && r < B) {
		if (a[l] <= b[r]) {
			if (z < C && c[z] > a[l]) {
				sum += c[z];
				l += 1; z += 1;
			}
			else {
				sum += a[l];
				l += 1;
			}
		}
		else {
			if (z < C && c[z] > b[r]) {
				sum += c[z]; r += 1; z += 1;
			}
			else {
				sum += b[r];
				r += 1;
			}
		}
	}

	while (l < A) {
		if (z < C && c[z] > a[l]) {
			sum += c[z];
			z += 1;  l += 1;
		}
		else {
			sum += a[l];
			l += 1;
		}
	}
	while (r < B) {
		if (z < C && c[z] > b[r]) {
			sum += c[z];
			z += 1;  r += 1;
		}
		else {
			sum += b[r];
			r += 1;
		}
	}
	cout << sum << '\n';
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x=n/i;
		ans+=i*x*(x+1)/2;
	}
	cout<<ans;
}

Measured memory_bytes: 3648
class Array
  def tally
    self.inject(Hash.new(0)) { |res, e| res[e] += 1; res }
  end
end

n = gets.to_i
nums = gets.split.map(&:to_i)
cumulative_sums = [0]
nums.each { |num| cumulative_sums << cumulative_sums.last + num }
puts cumulative_sums.tally.values.inject(0) { |res, num| res + (num * (num - 1) / 2) }


Measured memory_bytes: 32132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  int64_t sum = 0;
  for(int i=2; i<N; i++){
    sum ^= vec[i];
  }
  
  int64_t two = vec[0] + vec[1];
  
  bool flag = true;
  if(two < sum){
    flag = false;
  }
  
  int64_t A = 0;
  int64_t a = vec[0];
  int64_t B = 0;
  two -= sum;
  
  bitset<60> S(sum);
  bitset<60> T(two);
  
  for(int64_t i=0; i<59; i++){
    if(T.test(i)){
      if(i == 0){
        flag = false;
      }
      else if(S.test(i-1)){
        flag = false;
      }
      else{
        int64_t X = pow(2,i-1);
        A += X;
      }
    }
  }
  
  a = vec[0] - A;
  
  for(int64_t i=59; i>=0; i--){
    if(S.test(i)){
      int64_t X = pow(2,i);
      if(a >= X){
        A += X;
        a -= X;
      }
    }
  }
  
  
  if(!flag || A > vec[0] || A == 0){
    cout << -1 << endl;
  }
  else{
    cout << vec[0] - A << endl;
  }
}

Measured memory_bytes: 4100
# coding: utf-8
import sys
import math


def func_dis(x_y_list):
    dis = (x_y_list[0]*x_y_list[0]) + (x_y_list[1]*x_y_list[1])
    dis = math.sqrt(dis)
    return dis


if __name__ == "__main__":
    lines = []
    data = []
    count = 0
    for line in sys.stdin:
        lines.append(line.rstrip('\r\n'))

    setting = lines[0].split(' ')
    n = int(setting[0])
    d = int(setting[1])

    for num in range(len(lines)):
        if num == 0:
            continue
        tmp_list = []
        tmp = lines[num].split(' ')
        for one in tmp:
            tmp_one = int(one)
            tmp_list.append(tmp_one)
        data.append(tmp_list)

    # 計算
    for one in data:
        dis = 0
        dis = func_dis(one)
        if dis <= d:
            count = count + 1
    print(count)


Measured memory_bytes: 56588
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    long long int n,a,b;
    cin>>n;
    b=sqrt(n);
    for(long long int i=b;i>0;i--){
        if(n%i==0){
            a=i+n/i-2;
            break;
        }
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,a[55],i,ans;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0;i<k;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 100010


int main(){
    IOS;
     
 	ll n;cin>>n;
 	ll a[n],ans=0;
 	rep(i,1,n+1){
 		cin>>a[i];
 		if(i&1 and a[i]&1)ans++;
 	}
 	cout<<ans;
     
     
     
    return 0;
}


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

int main() {
  
  int64_t X; cin >> X;
  
  int64_t savings = 100; int count = 0;
  
  while (true) {
    
    count++;
    
    savings += savings / 100;
    
    if (X <= savings) {
      cout << count << endl;
      return 0;
    }
    
  }
  
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
struct Edge{
	int v,nxt;
}e[210];int tot;
int first[110],deg[110];
void build(int u,int v)
{
	e[++tot]=(Edge){v,first[u]};
	first[u]=tot;deg[u]++;
	return ;
}
int n;
int dep[110];
int mxdeg[110];
int bfs(int x,int y)
{
	int ans=0;
	queue<int>q;
	memset(dep,0,sizeof(dep));
	memset(mxdeg,0,sizeof(mxdeg));
	dep[x]=1;q.push(x);
	if(y){dep[y]=1;q.push(y);}
	while(!q.empty())
	{
		int u=q.front();q.pop();
		mxdeg[dep[u]]=max(mxdeg[dep[u]],deg[u]);
		ans=max(ans,dep[u]);
		for(int i=first[u];i;i=e[i].nxt)
			if(!dep[e[i].v])
			{
				dep[e[i].v]=dep[u]+1;
				q.push(e[i].v);
			}
	}
	return ans;
}
pair<int,long long>work(int x,int y)
{
	pair<int,long long>ans;
	ans.first=bfs(x,y);ans.second=1;
	if(!y)mxdeg[1]++;
	for(int i=1;i<=n;i++)
		if(mxdeg[i]>1)
			ans.second*=(mxdeg[i]-1);
	if(y)ans.second*=2;
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		build(u,v);build(v,u);
	}
	pair<int,long long>ans;ans.first=1e9;
	for(int u=1;u<=n;u++)
	{
		ans=min(ans,work(u,0));
		for(int i=first[u];i;i=e[i].nxt)
			ans=min(ans,work(u,e[i].v));
	}
	printf("%d %lld\n",ans.first,ans.second);
	return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
w = [input() for _ in range(n)]

if (len(w) != len(set(w))):
    print("No")
    exit()

for i in range(1,n):
    if w[i][0] != w[i-1][-1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 9180
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

signed main(){

	lli n;
	cin>>n;

	cout<<(n/2) - (n%2==0)<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

n = ri()
# n = str(reversed(n))
n = [n[len(n)-i-1] for i in range(len(n))]
# print(n)
if n[0] == '2' or n[0] == '4' or n[0] == '5' or n[0] == '7' or n[0] == '9':
    print('hon')
elif  n[0] == '0' or n[0] == '1' or n[0] == '6' or n[0] == '8':
    print('pon')
else:
    print('bon')  



Measured memory_bytes: 62308
import java.util.Scanner;

public class Main {

    static String[] OPR = { "+", "-" };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String ABCD = sc.nextLine();

        String ans = solve(ABCD);
        System.out.println(ans);
    }

    private static String solve(String aBCD) {
        char[] abcd = aBCD.toCharArray();
        int a = Integer.parseInt(String.valueOf(aBCD.charAt(0)));
        int b = Integer.parseInt(String.valueOf(aBCD.charAt(1)));
        int c = Integer.parseInt(String.valueOf(aBCD.charAt(2)));
        int d = Integer.parseInt(String.valueOf(aBCD.charAt(3)));

        for (int i = 0; i < OPR.length; i++) {
            for (int j = 0; j < OPR.length; j++) {
                for (int k = 0; k < OPR.length; k++) {
                    int tmp = sum(OPR[i], a, b);
                    tmp = sum(OPR[j], tmp, c);
                    tmp = sum(OPR[k], tmp, d);
                    if (tmp == 7) {
                        return makeFormula(i, j, k, a, b, c, d);
                    }
                }
            }
        }
        return null;
    }

    private static String makeFormula(int i, int j, int k, int a, int b, int c, int d) {
        StringBuilder sb = new StringBuilder();
        sb.append(a);
        sb.append(OPR[i]);
        sb.append(b);
        sb.append(OPR[j]);
        sb.append(c);
        sb.append(OPR[k]);
        sb.append(d);
        sb.append("=7");
        return sb.toString();
    }

    private static int sum(String term, int v1, int v2) {
        if (term.equals("+")) {
            return v1 + v2;
        } else {
            return v1 - v2;
        }
    }
}


Measured memory_bytes: 21844
from collections import deque

N,M = [int(i) for i in input().split()]
graph = {i:set() for i in range(1,N+1)}
for _ in range(M):
    a,b = [int(i) for i in input().split()]
    graph[a].add(b)
    graph[b].add(a)

path = {1:0}
seen = set([1])
que = deque([1])
while que:
    node = que.popleft()
    for n in graph[node]:
        if n not in seen:
            seen.add(n)
            que.append(n)
            path[n] = node

if len(seen) != N:
    print("No")
else:
    print("Yes")
    for i in range(2,N+1):
        print(path[i])

Measured memory_bytes: 86096
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
	char A, B;
	cin >> A >> B;

	if (A < B) {
		cout << "<" << endl;
	}
	else if(A > B){
		cout << ">" << endl;
	}
	else {
		cout << "=" << endl;
	}

	return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        /// <summary>
        /// B - Easy Linear Programming
        /// https://atcoder.jp/contests/abc167/tasks/abc167_b
        /// </summary>
        /// <param name="args"></param>

        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            int[] str_ABCK = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
                        
            int result = 0;

            if (str_ABCK[3] <= str_ABCK[0])   //引く枚数がＡより少ないときは引く枚数が答え
            {
                result = str_ABCK[3];
            }
            else if (str_ABCK[3] <= str_ABCK[0] + str_ABCK[1])
            {
                result = str_ABCK[0];
            }
            else
            {
                //マイナスカードの枚数
                int num_Minus = str_ABCK[3] - (str_ABCK[0] + str_ABCK[1]);
                result = str_ABCK[0] - num_Minus;
            }
            


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28296
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	A, B, C := nextInt(), nextInt(), nextInt()
	fmt.Println(MaxOf(0, C-(A-B)))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std; 
int main() { 
	int num; 
	scanf("%d" , &num); 
	for ( int i = 1;; i++) { 
		if ( i*i > num) { 
			printf("%d\n" , ( i - 1)*( i - 1)); 
			break ; 
		} 
	}
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);



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

    vector<P> xs(n);

    rep(i, n) {
        int x;
        cin >> x;
        P p(x, i);
        xs[i] = p;
    }
    sort(xs.begin(), xs.end());

    ll cli = (n - 1) / 2;
    ll cl = xs[cli].first;
    ll rli = n - 1 - ((n - 1) / 2);
    ll cr = xs[rli].first;


    vector<P> ans(n);

    for (ll i = 0; i < (n / 2); i++) {
        P p = xs[i];
        P a(p.second, cr);
        ans[i] = a;
    }
    for (ll i = (n / 2); i < n; i++) {
        P p = xs[i];
        P a(p.second, cl);
        ans[i] = a;
    }

    sort(ans.begin(), ans.end());

    for (P p : ans) {
        cout << p.second << endl;
    }

}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int cpos=s.find('C',0);
	int fpos=s.rfind('F',s.size()-1);
	if(cpos==-1 || fpos==-1 || cpos>fpos){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

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

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const int MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ll d = pow(10, 9) + 7;
  COMinit();
  int a = N - K;
  for (int i = 1; i <= K; i++) {
    if (a + 1 < i) {
      cout << 0 << "\n";
    } else {
      if (i == 1) {
        cout << a + 1 << "\n";
      } else {
        ll t = COM(K - 1, i - 1);
        ll k = a - (i - 1);
        ll b = COM(k + i, k) * t;
        b %= d;
        cout << b << "\n";
      }
    }
  }
  return 0;
}

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

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String[] in1 = br.readLine().split(" ");
        int N = Integer.parseInt(br.readLine());
        String s = br.readLine();
        String t = br.readLine();
        br.close();

        int cmn_len = N;
        String sub_s = s;
        String sub_t = t;
        
        while(!sub_s.equals(sub_t) && cmn_len > 0){
            cmn_len--;
            sub_s = s.substring(N - cmn_len, N);
            sub_t = t.substring(0, cmn_len);
        }
        System.out.println(2 * N - cmn_len);
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define MAXN (int)(1e5+1)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
int main()
{
	fastio;
	int n,k,used;
	cin>>n>>k;
	vll dp(k+1,0),pref(k+1,1);
	dp[0]=1;
	for(int child=1;child<=n;child++)
	{
		ll candies;
		cin>>candies;
		vll newdp(k+1,0);
		for(int j=0;j<=k;j++){
			newdp[j] = pref[j];
			ll l=max(0ll,j-candies);
			if(l>0)newdp[j]=submod(newdp[j],pref[l-1]);
		}
		ll sm=0;
		for(int j=0;j<=k;j++){
			pref[j]=addmod(sm,newdp[j]);
			sm=pref[j];
		}
		dp=newdp;
	}
	cout<<dp[k]<<endl;
}


Measured memory_bytes: 5736
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

map<pair<LL,int>,int> memo;
int p = 1000000007;

pair<int,LL> topDig(LL n) {
  if(n<10) return make_pair(n,1);
  auto pa = topDig(n/10);
  return make_pair(pa.first, pa.second*10);
}

int solve(LL n, int need) {
  if(n == 0) {
    if(need) return 0;
    else return 1;
  }
  auto key = make_pair(n,need);
  if(memo.count(key)) return memo[key];
  int answer = 0;
  auto pa = topDig(n);
  int td = pa.first;
  REP(i,td) {
    if(i==0 && (need == ((1<<3)|(1<<5)|(1<<7))) ||
       (i==3 || i==5 || i==7))
    answer += solve(pa.second-1, need & ~(1<<i));
    answer %= p;
  }
  if(td==3 || td==5 || td==7) {
    answer += solve(n - td * pa.second, need & ~(1<<td));
    answer %= p;
  }
  return memo[key] = answer;
}

int main(void)
{
  LL n;
  cin >> n;
  cout << solve(n,((1<<3)|(1<<5)|(1<<7))) << endl;
  return 0;
}


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

int main(){
    long long n;
    cin >> n;
    char s[n];
    for(int i=0;i<n;i++) cin >> s[i];
    long long a=1e9+7;
    long long cnt[26];
    for(int i=0;i<26;i++) cnt[i]=0;
    for(int i=0;i<n;i++){
        cnt[s[i]-'a']++;
    }
    long long ret=1;
    for(int i=0;i<26;i++){
        ret=ret*(1+cnt[i])%a;
    }
    cout << (ret+a-1)%a << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void trace(int n, int a[])
{
	for (int i = 0; i < n; ++i)
	{
		cout << a[i];
		if (i < n - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
}

int selectionSort(int n, int a[])
{
	int min = 0;
	int count = 0;
	for (int i = 0; i < n; ++i)
	{
		min = i;
		for (int j = i; j < n; ++j)
		{
			if (a[j] < a[min])
			{
				min = j;
			}
		}
		if (i != min)
		{
			swap(a[i], a[min]);
			count++;
		}
	}
	return count;
}

int main(int argc, char const *argv[])
{
	int n = 0;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int count = selectionSort(n, a);
	trace(n, a);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  vll a(n);re(i, n) std::cin >> a[i];
  sort(all(a));reverse(all(a));
  ll s = 0;
  re(i, k) s += a[i];
  std::cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  set<int> a;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    a.insert(tmp);
  }
  if(n==a.size()) cout<<"YES";
  else cout<<"NO";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < n; ++i)
#define FORR(i, s, n) for (int i = n-1; i >= s; --i)
#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v, 0, sizeof(v))
#define F first
#define S second

ll n, a[100000];

int main() {
    cin >> n;
    REP(i, n) cin >> a[i];
    bool s = false;
    ll mi = INF, res = 0;
    REP(i, n) {
        if (a[i] < 0) s = !s;
        if (abs(a[i]) < mi) {
            mi = abs(a[i]);
        }
        res += abs(a[i]);
    }
    if (s) {
        res -= mi * 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
map<int ,int>mp;
const int N=10E5+5;
vector<int>vc;
long long int arr[N];
int main() {


long long n;
cin>>n;
long long sum2=0;
int neg=0;
long long mini=1e18;
for(int i=0;i<n;i++){cin>>arr[i]; if(arr[i]<0)neg++; sum2+=abs(arr[i]);}
for(int i=0;i<n;i++)
{
    //sum2+=abs(arr[i]);
    if(arr[i]<0 )
    {
        arr[i]=-1*arr[i];

    }

}
for(int i=0;i<n;i++)mini=min(mini,arr[i]);

if(neg%2==0){cout<<sum2; return 0;}
bool reham=true;
long long sum=0;
for(int i=0;i<n;i++)
{
    if(arr[i]==mini && reham==true)
    {
        reham=false;
        continue;

    }
    else sum+=arr[i];
}

cout<<sum-mini;

}

Measured memory_bytes: 1024
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
	

int main(){
	FIO
	
	string s;cin >> s;
	int q;cin >> q;
	while(q--){
		string op;
		int a, b;
		cin >> op >> a >> b;
		if(op == "replace"){
			string rep;cin >> rep;
			string fin = s.substr(0, a) + rep + s.substr(b + 1);
			s = fin;
		}else{
			if(op == "print"){
				cout << s.substr(a, b - a + 1) << '\n';
			}else{
				reverse(s.begin() + a, s.begin() + b + 1);
			}
		}
		//deb(s);
	}
	return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, W;
constexpr int V = 100000;
int main()
{
    cin >> N >> W;
    vector<lint> dp(V + 1, W + 1);
    dp[0] = 0;
    REP(_, N)
    {
        lint w, v;
        cin >> w >> v;
        IREP(vprv, V - v + 1) Min(dp[vprv + v], dp[vprv] + w);
    }

    IREP(v, V + 1) if (dp[v] <= W)
    {
        cout << v << endl;
        return 0;
    }
}


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

int		main(void)
{
	string s;

	cin >> s;
	for (int i = 0; s[i]; i++)
	{
		cout << s[i];
		if (i == 3)
			cout << " ";
	}
	cout << endl;
}



Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,m,x,dp[100010];
bool b[100010];

int main()
{
	cin>>n>>m;
	repn(i,m) scanf("%I64d",&x),b[x]=true;
	dp[0]=1;
	repn(i,n)
	{
		if(b[i]) continue;
		if(i-2>=0) dp[i]=(dp[i]+dp[i-2])%MOD;
		dp[i]=(dp[i]+dp[i-1])%MOD;
	}
	cout<<dp[n]<<endl;
	rt0;
}

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

int main()
{
    int N;
	long long K, a[100001] = { 0 };

	scanf("%d %lld", &N, &K);

	for (int i = 0; i < N; i++) {
		int A, B;
		scanf("%d %d", &A, &B);

		a[A] += B;
	}

	for (int i = 1; i <= 100000; i++) {
		if (K - a[i] <= 0) {
			cout << i << endl;
			break;
		}
		K -= a[i];
	}

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define LL long long
#define N 500
#define lowb(x) x&-x
 
int c[N][N];
map<pair<int,int>,int>mp;
void add(int x,int y)
{
    for(int i=x;i<=N;i+=lowb(i))
    {
        for(int j=y;j<=N;j+=lowb(j))
        {
            c[i][j]+=1;
        }
    }
}
 
int sum(int x,int y)
{
    int ans=0;
    for(int i=x;i;i-=lowb(i))
    {
        for(int j=y;j;j-=lowb(j))
        {
            ans+=c[i][j];
        }
    }
    return ans;
}
int main()
{
    int n,m,q;
    int l,r;
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&l,&r);
        add(l,r);
    }
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d",&l,&r);
        printf("%d\n",sum(r,r)-sum(r,l-1)-sum(l-1,r)+sum(l-1,l-1));
    }
}

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

typedef long long ll;
 
 
int a, b, c;
 
inline int read() {
	int out = 0;
	bool flag = false;
	register char cc = getchar();
	while (cc < '0' || cc > '9') {
		if (cc == '-') flag = true;
		cc = getchar();
	}
	while (cc >= '0' && cc <= '9') {
		out = (out << 3) + (out << 1) + (cc ^ 48);
		cc = getchar();
	}
	return flag ? -out : out;
} 
 
inline void write(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x == 0) putchar('0');
	else {
		int num = 0;
		char cc[20];
		while (x) cc[++num] = x % 10 + 48, x /= 10;
		while (num) putchar(cc[num--]);
	}
	putchar(' ');
}


int main() {
	a = read(), b = read(), c = read();
	write(c); write(a); write(b);
	return 0;
}

Measured memory_bytes: 256