akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  int N;
  int res = 0;
  int d[110];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> d[i];
  for(int j = 0; j < N; j = j + 2){
    if(d[j]%2 != 0) res++;
    }
  cout << res << endl;
  }

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        label:
        var array = new int[Parse(ReadLine())];
        var sp = ReadLine().Split();
        for(int i = 0; i < sp.Length; ++i)
        {
            array[i] = Parse(sp[i]) - i;
        }
        Array.Sort(array);
        int mid = array[array.Length / 2];
        long result = 0;
        foreach(var num in array)
        {
            result += Math.Abs(mid - num);
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 32732
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	long long int n, sum, a;
	
	cin >> n;
	
	sum = 0;
	
	for(int i = 0; i < n; i++){
		cin >> a;
		sum += a;
	}
	
	printf("%lld\n", sum / n);
	
	return 0;
}

Measured memory_bytes: 1148
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int X, A, B; cin >> X >> A >> B;
    int N; cin >> N;
    vector<string> vs(N);
    for(int i=0; i<N; i++) cin >> vs[i];

    int len = X;
    for(int i=0; i<N; i++) {
        if(vs[i] == "nobiro") len += A;
        if(vs[i] == "tidime") len += B;
        if(vs[i] == "karero") len = 0;

        len = max(0, len);
    }
    cout << len << endl;
    return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
#include <cmath>
#include<string>
#include<cmath>
using namespace std;

int main()
{
	int n, a[2][100], ans = 0;

	cin >> n;

	for (int i = 0; i < 2; i++)
		for (int j = 0; j < n; j++)
			cin>>a[i][j];

	for (int i = 0; i < n; i++){
		int sum = 0;
		for (int j = 0; j <= i; j++){
			sum += a[0][j];
		}
		for (int k = i; k < n; k++){
			sum += a[1][k];
		}
		if (ans < sum)
			ans = sum;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    n = int(input())
    if n == 1:
        print("Hello World")
    else:
        A = int(input())
        B = int(input())
        print(A+B)


if __name__ == '__main__':
    main()

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    k--;
    if (s[k] == 'A')
        s[k] = 'a';
    else if (s[k] == 'B')
        s[k] = 'b';
    else if (s[k] == 'C')
        s[k] = 'c';
    cout << s << ln;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
    string::iterator ite=s.begin();
    vector<int> a(4);

    for (ite = s.begin(); ite < s.end(); ite++) 
    {
        if (*ite == 'K') {a[0]++;}
        if (*ite == 'U') {a[1]++;}
        if (*ite == 'P') {a[2]++;}
        if (*ite == 'C') {a[3]++;}
    }
    int min;
    sort( a.begin(), a.end());
    min = a[0];
    cout << min << endl;
    return 0;
}

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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;
using ii = pair<int,ll>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}




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

const double EPS = 1e-9;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int N = 1e6 + 5;
const ll CONSTANT = 9e18 + 7;


int add(int a, int b){
    return (a + b) % mod;
}
int dp[N][2][2];
int n;
int solve(int i, bool a, bool b){
        if(i == n)
            return (a & b);
        int &ret = dp[i][a][b];
        if(~ret)
                return ret;
        ret = 0;
        for(int j = 0; j <= 9; ++j){
            ret = add(ret, solve(i + 1, a | (j == 0), b | (j == 9)));
        }
        return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    memset(dp,-1,sizeof dp);
    cout << solve(0,0,0) << '\n';

    return 0;
}


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

int main() {
    int n,k;
    string str;
    cin >> n >> k;
    cin >> str;
    if(n==1) {
        cout << 1 << endl;
        return 0;
    }

    vector<int> v;
    vector<int> mv;
    v.push_back(0);
    char c = str.at(0);
    int count = c == '0' ? -1 : 1;
    for(int i = 1; i < n; i++) {
        if(c == str.at(i)) {
            if(c == '0') count--;
            else count++;
        }
        else {
            if(c == '0') mv.push_back(v.size());
            v.push_back(count);
            c = str.at(i);
            count = c == '0' ? -1 : 1;
        }
    }
    if(c == '0') mv.push_back(v.size());
    v.push_back(count);
    v.push_back(0);
    int mvs = mv.size();

    int sum[mvs+1];
    if(mvs != 0) {
        sum[0] = mv.at(0) != 1 ? v.at(1) : 0;
    }else sum[0] = v.at(1);
    for(int i = 0; i < mvs; i++) {
        sum[i+1] = sum[i] + -1*v.at(mv.at(i)) + v.at(mv.at(i)+1);
        if(i - k >= 0) sum[i+1] -= -1*v.at(mv.at(i-k)) + v.at(mv.at(i-k)-1);
    }

    int ans = 0;
    for(int i = 0; i <= mvs; i++) {
        if(ans < sum[i]) ans = sum[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXN = 5 + 100;
const int MAXK = 5 + 100000;
const int MOD = 7 + 1000000000;
int N, K;
int arr[MAXN], dp[MAXN][MAXK];

void add(int& p, const int& q) { /// p = (p + q) % MOD
    assert(p >= 0 && p < MOD);
    assert(q >= 0 && q < MOD);
    p += q;
    if(p >= MOD) p -= MOD;
}

void sub(int& p, const int& q) { /// p = (p - q + MOD) % MOD
    assert(p >= 0 && p < MOD);
    assert(q >= 0 && q < MOD);
    p -= q;
    if(p < 0) p += MOD;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N >> K;
    foi(i,0,N) {
        cin >> arr[i];
    }
    dp[N][0] = 1;
    for(int i = 1; i <= K; ++i) {
        dp[N][i] = 0;
    }
    for(int i = N - 1; i >= 0; --i) {
        for(int j = 0; j <= K; ++j) {
            dp[i][j] = dp[1 + i][j];
            if(j > min(j,arr[i])) {
                sub(dp[i][j], dp[1 + i][j - min(j, arr[i]) - 1]);
            }
            if(j) {
                add(dp[i][j], dp[i][j - 1]);
            }
        }
    }
    cout << dp[0][K] << '\n';
    return 0;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
#define INF 100000000000

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> h;
    rep(i, K) h.push_back(0);
    for (ll i = K; i < N + K; i++) {
        ll temp; cin >> temp;
        h.push_back(temp);
    }
    vector<ll> dp(N + K);
    for(ll k = 0; k < N + K; k++) {
        if (k < K) dp[k] = 0;
        else dp[k] = INF;
    }
    for(ll i = K; i < N + K; i++) {
        ll temp_min = INF;
        ll cand;
        if (i == K) {
            dp[i] = 0;
            continue;
        }
        for (ll j = 1; j < K + 1; j++) {
            // cout << j << endl;
            if (h[i - j] == 0) continue;
            cand = dp[i - j] + abs(h[i] - h[i - j]);
            if (cand < temp_min) {
                temp_min = cand;
            }
        }
        dp[i] = temp_min;
    }
    // view(dp);
    cout << dp[N + K - 1] << endl;
    return 0;
}

Measured memory_bytes: 1908
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long X = scanner.nextLong();
    System.out.println(count(N, X));
  }

  private static long count(int n, long x) {
    if ((1L << (n + 2)) - 3 < x) throw new IllegalArgumentException();
    if (n == 0) {
      return 1;
    }
    if (x == 1) return 0;
    x--;
    if (x <= (1L << (n + 1)) - 3) return count(n - 1, x);
    x -= (1L << (n + 1)) - 3;
    long p = 1L << n;
    if (x == 1) return p;
    x--;
    if (x <= (1L << (n + 1)) - 3) return count(n - 1, x) + p;
    return (1L << (n + 1)) - 1;
  }
}


Measured memory_bytes: 21844
N = int(input())
H = list(int(i) for i in (input().split()))
H_max = []
tmp = 0
cnt = 0
for i in range (N):
  if (tmp < H[i]):
    H_max.append(H[i])
    tmp = H[i]
  else:
    H_max.append(tmp)
  if(H[i] >= H_max[i]):
    cnt += 1
print(cnt)

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

int main(){
    int n; 
    string s;
    cin >> n >> s;
    int x=0;int max=0;
    for(int i=0;i<n;++i){
        if(s[i]=='I') ++x;
        else if(s[i]=='D') --x;
        if(max<=x) max=x;
    }
    cout << max << endl;
}

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

int main(int argc, char const *argv[]) {
  int n,ans=0,max=0;
  std::cin >> n;
  string s;
  std::cin >> s;

  for(int i=0; i<n; i++){
    if(s[i]=='I'){
      ans++;
      if(ans>max) max=ans;
    }
    else ans--;
  }

  std::cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int A;cin>>A;
    int B;cin>>B;
    int C;cin>>C;
    int X;cin>>X;
    int output=0;

    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            
            if(((X-i*500-j*100)/50)<=C&&(X-i*500-j*100)>=0){
                output++;
            } 
        }
    }

    cout<<output<<endl;
    return 0;
    
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        Long sum1 = 0L;
        Long sum2 = 0L;
        Long sum3 = 0L;
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                for(int k=j;k<=n;k++){
                    Integer tmp = gcd(i, gcd(j, k));
                    if(i==j && i==k)sum1 += tmp;
                    else if(i==j || j==k || k==i)sum2 += tmp;
                    else sum3 += tmp;
                }
            }
        }

        System.out.println(sum1 + sum2*3 + sum3*6);

    }
    
    private static int gcd(int x, int y) {
        if(y > x)return gcd(y, x);
        if(y==0)return x;
        return gcd(y, x%y);
    }
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) { 
    int A, B, C;
    cin >> A >> B >> C;
    int a, b, c;
    a = max({A, B, C});
    c = min({A, B, C});
    b = A + B + C - a - c;
    int ans = 0;
    ans += a - b;
    c += a - b;
    if ((a - c) % 2 == 0) ans += (a - c) / 2;
    else ans += (a - c) / 2 + 2;

    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
A=[];B=[]
for i  in range(n):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
A=A[::-1];B=B[::-1]
now=0
for i in range(n):
    qq=(A[i]+now) % B[i]
    if qq==0:continue
    now+=B[i]-qq
print(now)
    

Measured memory_bytes: 87360
H,W = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(H)]
ans = []
for i in range(H):
    for j in range(W):
        if j == W-1:
            if i == H-1:
                continue
            if a[i][j]%2 == 1:
                a[i+1][j] += 1
                ans.append([i+1,j+1,i+2,j+1])
        else:
            if a[i][j]%2 == 1:
                a[i][j+1] += 1
                ans.append([i+1,j+1,i+1,j+2])
print(len(ans))
for a in ans:
    print(*a)

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

using ll = long long;

constexpr ll inf = 1e18;

class convex_hull_trick {
    using T = long long;

    bool check(int f1, int f2, T aa, T bb) {
        return (a[f2] - a[f1]) * (bb - b[f2]) >= (b[f2] - b[f1]) * (aa - a[f2]);
    }
    bool check(int f1, int f2, int f3) {
        return (a[f2] - a[f1]) * (b[f3] - b[f2]) >= (b[f2] - b[f1]) * (a[f3] - a[f2]);
    }

    T f(int idx, T x) {
        return a[idx] * x + b[idx];
    }

public:
    convex_hull_trick() = default;
    // a : sorted sequence, a[i] >= a[i + 1] >= a[i + 2] ...
    convex_hull_trick(std::vector<T> const& a_, std::vector<T> const& b_) {
        assert(a_.size() == b_.size());
        for(int i = 0; i < (int)a_.size(); ++i) {
            add_f(a_[i], b_[i]);
        }
    }

    void add_f(T aa, T bb) {
        while(a.size() >= 2 && check(a.size() - 2, a.size() - 1, aa, bb)) {
            a.pop_back();
            b.pop_back();
        }
        a.push_back(aa);
        b.push_back(bb);
    }
    T min(T x) {
        assert(a.size() > 0);
        while(a.size() >= 2 && f(0, x) >= f(1, x)) {
            a.pop_front();
            b.pop_front();
        }
        return a[0] * x + b[0];
    }

private:
    std::deque<T> a, b; // functions
};


int main() {
    ll n, c; cin >> n >> c;
    vector<ll> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    convex_hull_trick cht;
    vector<ll> dp(n, inf);
    dp[0] = 0;
    cht.add_f(-2 * h[0], h[0] * h[0]);
    for(int i = 1; i < n; ++i) {
        dp[i] = cht.min(h[i]) + c + h[i] * h[i];
        cht.add_f(-2 * h[i], dp[i] + h[i] * h[i]);
    }

    cout << dp.back() << endl;
}


Measured memory_bytes: 5632
<?php
// クラス
class UnionFind {
	// ルートならサイズ
	// 子なら親のID
	public $d = [];
	
	// コンストラクタ
	public function __construct(int $n) {
		$this->d = array_fill(0, $n, -1);
	}
	
	// $xがどこのルートに所属しているか
	public function find(int $x):int {
		if($this->d[$x] < 0) {
			return($x);
		}
		// 親のIDを入れておく
		$this->d[$x] = $this->find($this->d[$x]);
		
		// 親のIDを返す
		return($this->d[$x]);
	}
	
	// くっつける(木の小さい方を大きい方に引っ付ける)
	public function unite(int $x, int $y):bool {
		// ルート検索
		$x = $this->find($x);
		$y = $this->find($y);
		
		// 同じルートなので何もしない
		if($x == $y) {
			return(false);
		}
		
		// サイズの小さい方を$xにする(サイズは負の数でやってる)
		if($this->d[$x] > $this->d[$y]) {
			$wk = $x;
			$x = $y;
			$y = $wk;
		}
		
		// ひっついてる数を加算
		$this->d[$x] += $this->d[$y];
		
		// 引っ付ける
		$this->d[$y] = $x;
		
		return(true);
	}
	
	// 同じルートか
	public function same(int $x, int $y):bool {
		return($this->find($x) == $this->find($y));
	}
	
	public function size(int $x):int {
		return(-$this->d[$this->find($x)]);
	}
}

fscanf(STDIN, "%d %d %d", $N, $M, $K);

// クラス生成
$tree = new UnionFind($N);

// 変数
$deg = array_fill(0, $N + 5, 0);
$to = array_fill(0, $N + 5, []);

// M
for($i = 0; $i < $M; $i++) {
	fscanf(STDIN, "%d %d", $A, $B);
	// 0オリジン
	$A--;
	$B--;
	
	// フレンド数カウント
	$deg[$A]++;
	$deg[$B]++;
	
	// 引っ付ける
	$tree->unite($A, $B);
}

// K
for($i = 0; $i < $K; $i++) {
	fscanf(STDIN, "%d %d", $C, $D);
	// 0オリジン
	$C--;
	$D--;
	
	$to[$C][] = $D;
	$to[$D][] = $C;
}

for($i = 0; $i < $N; $i++) {
	// サイズ - 1(自分自身) - フレンド数
	$ans = $tree->size($i) - 1 - $deg[$i];
	foreach($to[$i] as $v) {
		if($tree->same($i, $v) != false) {
			$ans--;
		}
	}
	echo "{$ans}" . ($i == $N - 1 ? "\n" : " ");
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll H, N;
  cin >> H >> N;
  vector<int> A(N);
  REP(i, N) { cin >> A[i]; }
  sort(A.begin(), A.end());
  ll total = 0;
  REP(i, N) {
    total += A[i];
    if (total >= H) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iterator>
#include<deque>
#include<cstdio>

#define lp(i,a,n) for(ll i=a;i<n;++i)
#define rep(i,a,n) for(ll i=a;i<=n;++i)
#define all(v) v.begin(),v.end()
#define clr(n,a) memset(n,a,sizeof(n))
#define vi vector <int>
#define sc set <char>
#define si set<int>
#define pb push_back
#define vb vector <bool>
#define pi(n) printf("%d\n",n)
#define ln "\n"
#define mahmoud_abdelsamie ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;


int main()
{
    mahmoud_abdelsamie
    int n,cnt=0; cin>>n;
    rep(i,1,n) {
        int x; cin>>x;
        if(i%2 && x%2) ++cnt;
    }
    cout<<cnt<<ln;
    return 0;
}


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


int main() {
  int n ;
  cin >> n ;
  
  string s ;
  cin >> s ;
  
  int c =0;
  for(int i=0; i<s.size() ; i++ ){
    if( s.at(i)=='R'){
      c++;
    }
  }
  
  if(c>n/2){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int main(){
	n=read();
  if(n>=30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include <numeric>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << #s << " " << s << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

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

    string ans;
    if(D==25){
        ans = "Christmas";
    }else if(D==24){
        ans = "Christmas Eve";
    }else if(D==23){
        ans = "Christmas Eve Eve";
    }else{
        ans = "Christmas Eve Eve Eve";
    }

    p(ans);
    
    return 0;
}

Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){
          ll d,s,t;
          cin>>d>>s>>t;
          if(d <= (s*t))cout<<"Yes\n";
          else cout<<"No\n";
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3644
def strong(s,n):
    k=s[0:(n-1)//2 ]
    p=s[(n+3)//2 - 1:n]
    return s==s[::-1] and k==k[::-1] and p==p[::-1]
s=input()
n=len(s)
print("Yes" if strong(s,n) else "No")


Measured memory_bytes: 38384
from collections import deque
N,M=list(map(int,input().split()))
N_l=set()
one_l=set()
for i in range(M):
   A,B=list(map(int,input().split()))
   if A == 1:
      one_l.add(B)
   elif B==N:
      N_l.add(A)
if len(N_l & one_l) > 0:
   print("POSSIBLE")
else:
   print("IMPOSSIBLE")


Measured memory_bytes: 19256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	
	string s;
	cin >> s;
	++s[0];
	cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

namespace aoj_ALDS1_3_B
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string[] inputArray = Console.ReadLine().Split(' ');
			int processCount = int.Parse(inputArray[0]);
			int quantum = int.Parse(inputArray[1]);

			Queue<Process> processQueue = new Queue<Process>();
			for (int i = 0; i < processCount; i++)
			{
				string[] tempArray = Console.ReadLine().Split(' ');
				processQueue.Enqueue(new Process { Name = tempArray[0], Time = int.Parse(tempArray[1]) });
			}

			int totalTime = 0;
			while (processQueue.Count > 0)
			{
				int tempResult = processQueue.Peek().Time - quantum;
                if (tempResult > 0)
				{
					totalTime += quantum;

					processQueue.Peek().Time -= quantum;
					processQueue.Enqueue(processQueue.Dequeue());
				}
				else
				{
					totalTime += processQueue.Peek().Time;

					Console.WriteLine(processQueue.Peek().Name + " " + totalTime);
					processQueue.Dequeue();
				}
			}
		}
	}

	public class Process
	{
		public string Name { get; set; }
		public int Time { get; set; }
	}
}



Measured memory_bytes: 24384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,M;
  cin>>N>>M;
  cout<<(N-1)*(M-1);
  }


Measured memory_bytes: 256
#include <stdio.h>

#define OVER -1000

char op[3] = { '+', '-', '*' };

int cal(int a, int b, int o){
	int r = 0;
	switch(o){
	case 0:
		r = a + b;
		break;
	case 1:
		r = a - b;
		break;
	case 2:
		r = a * b;
		break;
	default:
		break;
	}
	return r;
}

void c31(const int a[], char *dest){
	dest[0] = '0';
	int sum = 0;
	int tmp = 0;
	for(int i=0; i<3; ++i){
		sum = cal(a[0], a[1], i);
		for(int j=0; j<3; ++j){
			tmp = sum;
			sum = cal(sum, a[2], j);
			for(int k=0; k<3; ++k){
				if(cal(sum, a[3], k) == 10){
					sprintf(dest, "((%d%c%d)%c%d)%c%d",
						a[0], op[i], a[1], op[j], a[2], op[k], a[3]);
					return;
				}
			}
			sum = tmp;
		}
	}
}

void c22(const int a[], char *dest){
	char find = '\0';
	dest[0] = '0';
	int map1[3] = {
		cal(a[0], a[1], 0),
		cal(a[0], a[1], 1),
		cal(a[0], a[1], 2),
	};
	int map2[3] = {
		cal(a[2], a[3], 0),
		cal(a[2], a[3], 1),
		cal(a[2], a[3], 2),
	};
	for(int i=0; i<3; ++i){
		if(map1[i] == OVER){ continue; }
		for(int j=0; j<3; ++j){
			if(map2[j] == OVER){ continue; }
			for(int k=0; k<3; ++k){
				if(cal(map1[i], map2[j], k) == 10){
					find = op[k];
					break;
				}
			}
			if(find != '\0'){
				sprintf(dest, "(%d%c%d)%c(%d%c%d)",
					a[0], op[i], a[1], find, a[2], op[j], a[3]);
				return;
			}
		}
	}
}

int main(void){
	int a[4];
	char dest[30] = "";
	while(true){
		dest[0] = '0';
		dest[1] = '\0';
		scanf("%d %d %d %d", a, a+1, a+2, a+3);
		if(a[0] + a[1] + a[2] + a[3] == 0){ break; }
		int p[24][4] = {
			{ a[0], a[1], a[2], a[3] },
			{ a[0], a[1], a[3], a[2] },
			{ a[0], a[2], a[1], a[3] },
			{ a[0], a[2], a[3], a[1] },
			{ a[0], a[3], a[1], a[2] },
			{ a[0], a[3], a[2], a[1] },
			{ a[1], a[0], a[2], a[3] },
			{ a[1], a[0], a[3], a[2] },
			{ a[1], a[2], a[0], a[3] },
			{ a[1], a[2], a[3], a[0] },
			{ a[1], a[3], a[0], a[2] },
			{ a[1], a[3], a[2], a[0] },
			{ a[2], a[0], a[1], a[3] },
			{ a[2], a[0], a[3], a[1] },
			{ a[2], a[1], a[0], a[3] },
			{ a[2], a[1], a[3], a[0] },
			{ a[2], a[3], a[1], a[0] },
			{ a[2], a[3], a[0], a[1] },
			{ a[3], a[1], a[2], a[3] },
			{ a[3], a[1], a[0], a[2] },
			{ a[3], a[2], a[1], a[0] },
			{ a[3], a[2], a[0], a[1] },
			{ a[3], a[0], a[1], a[2] },
			{ a[3], a[0], a[2], a[1] },
		};
		for(int i=0; i<24; i++){
			c22(p[i], dest);
			if(dest[0] != '0'){ break; }
			c31(p[i], dest);
			if(dest[0] != '0'){ break; }
		}
		puts(dest);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>

//void Aoj_learning1();
//void Aoj_learning2();
//void Aoj_learning3();
//void Aoj_learning4();
//void Aoj_learning5();
void Aoj_learning6();

int main()
{
	Aoj_learning6();
}

void Aoj_learning6()
{
	std::string sInput;
	int intInputNum = 0;
	std::istringstream ss;	// 汎用文字列ストリーム

	// 入力個数の取得
	std::cin >> sInput;
	ss = std::istringstream(sInput);
	ss >> intInputNum;
	if (intInputNum > 100 || 1 > intInputNum)
	{
		exit(0);
	}

	// 数列を取得
	std::string sInputNum[100];
	for (int count = 0; count < intInputNum; count++)
	{
		std::cin >> sInputNum[count];
	}

	// 選択ソート
	int imin;				// 最小値格納先
	int changeNum;			// 交換元の配列番号
	int changeCount = 0;	// 交換回数
	int flag;				// 交換発生フラグ
	int temp;
	std::string sTemp;
	for (int count = 0; count < intInputNum; count++)
	{
		// フラグ初期化
		flag = 0;

		// 未整理領域から最小値を探す
		ss = std::istringstream(sInputNum[count]);
		ss >> imin;
		for (int i = count; i < intInputNum; i++)
		{
			ss = std::istringstream(sInputNum[i]);
			ss >> temp;
			if (imin > temp)
			{
				imin = temp;
				changeNum = i;
				// 交換が発生する場合フラグを立てる
				flag = 1;
			}
		}

		// 交換する必要がある場合交換と同時に回数をカウント
		if (flag == 1)
		{
			sTemp = sInputNum[count];
			sInputNum[count] = sInputNum[changeNum];
			sInputNum[changeNum] = sTemp;
			changeCount++;
		}
	}

	// 整列した数列を表示
	for (int k = 0; k < intInputNum; k++)
	{
		std::cout << sInputNum[k];
		if (k == intInputNum - 1)
		{
			std::cout << std::endl;
		}
		else
		{
			std::cout << " ";
		}
	}
	// 交換回数を表示
	std::cout << changeCount << std::endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

vector<ll> BFS(Graph G, ll V) {
  vector<ll> dist(G.size(), -1);  //全頂点を-1（未訪問）に初期化
  queue<ll> que;

  dist[V] = 0;  //初期ノードをdistとqueueにセット
  que.push(V);

  // BFS開始

  while (!que.empty()) {
    int v = que.front();  //頂点vを訪問（最初は頂点0）
    que.pop();

    for (int nv : G[v]) {    //頂点vから辿れる全頂点を訪問
      if (dist[nv] != -1) {  //訪問済頂点は上書きしない
        continue;
      } else {
        dist[nv] = v;  //頂点nvの原点からの距離を更新
        que.push(nv);
      }
    }
  }
  // BFS完了
  return dist;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, M;
  cin >> N >> M;
  Graph G(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    G.at(a - 1).push_back(b - 1);
    G.at(b - 1).push_back(a - 1);
  }
  Vl Ans = BFS(G, 0);
  for (auto a : Ans) {
    if (a == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int j = 1; j < N; j++) {
    cout << Ans.at(j) + 1 << endl;
  }
}

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

int main(){
	int n,m,x,y,t;
	cin >> n >> m >> x >> y;
	int a=x, b=y;
	while(n--){
		cin>>t;
		if(x<t){
			x=t;
		}
 	}
	while(m--){
		cin>>t;
		if(y>t){
			y=t;
		}
 	}
	 cout << (x<y?"No War":"War");
}

Measured memory_bytes: 256
def gcd(a,b):
  while b>0:
    a,b=b,a%b
  return a

x,y=map(int,input().split())
S=input()
T=input()
GCD=gcd(x,y)
LCM=(x * y) // GCD

x_new=x//GCD
y_new=y//GCD
for i in range(0,GCD):
  if S[(x_new)*i]==T[(y_new)*i]:
    result=LCM
  else:
    result=-1
    break
print(result)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define mii map<int,int>
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define log2(x) (31 - __builtin_clz(x))
#define lcm(x,y) (x*y) / __gcd(x,y)
int inf = (1e9) + 7;
int mod = 998244353;




int main(){


	int x;
	sf1(x);


	int sum = 0;
	int y = x;
	while(y > 0)
	{
		sum += y%10;
		y/=10;
	}

	if(!(x%sum)) printf("Yes\n");
	else printf("No\n");

} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

constexpr ll mod = 998244353;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

stack<int> st;
stack<int> stans;
bool flag = false;

bool dfs(vector<int>& a) {
  if (a.empty()) {
    flag = true;
    stans = st;
    return true;
  }
  auto it = a.end();
  for(int i=a.size()-1; i>=0; i--) {
    --it;
    if (a[i] == i+1) {
      st.push(a[i]);
      a.erase(it);
      return dfs(a);
    }
  }
  return false;
}

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  dfs(a);
  if (flag) {
    while(stans.size()) {
      int a = stans.top(); stans.pop();
      cout << a << '\n';
    }
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
import math

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        return False
    else:
        return x % m

def divisors(X):
    Sets = set([])
    for i in range(1, N+1):
        if i**2 > X:
            break
        else:
            if X % i == 0:
                Sets.add(i)
                Sets.add(X//i)
    return Sets


def chinese_reminder(pair1, pair2):

    x1, y1 = pair1
    x2, y2 = pair2
    g = math.gcd(y1, y2)
    if (x2-x1) % g != 0:
        return (float("inf"), float("inf"))
    else:
        K = (x2-x1)//g
        y1, y2 = y1//g, y2//g
        t = -K*modinv(y2, y1)
        m = x2+t*g*y2
        return (m % (g*y1*y2), g*y1*y2)



N = int(input())
divs = divisors(2*N)
ans = 10**20
for n in divs:
    u, v = n, (2*N)//n
    if math.gcd(u, v) != 1:
        continue
    else:
        V,mod = chinese_reminder((0, u), (v-1, v))
        if V == 0:
            V = mod
        ans = min(V, ans)
print(ans)



Measured memory_bytes: 71288
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
    int n;

	cin >> n;
	cout << n*(n+1)/2;

	return 0;
}

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

int main(void){
    int N;
    double ans = 0;
    std::cin >> N;
    std::vector<int> v(N);
    for (int i=0; i<N; ++i){
        std::cin >> v.at(i);
    }

    std::sort(v.begin(), v.end());

    ans += v.at(0) / pow(2, N - 1);
    for (int i=1; i<N; ++i) {
        ans += v.at(i) / pow(2, N - i);
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4120
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Dec 16 19:40:35 2018
//
package main

import "fmt"

func find(arr []int, val int) int {
	for i, a := range arr {
		if val == a {
			return i
		}
	}
	return -1
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	fmt.Println((N - 1 + K - 2) / (K - 1))
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;

int n ,k;
int a[maxn] , h[maxn];
vector<int> adj[maxn];
void DFS(int u , int par){
    for(int c : adj[u]){
        if(c == par)continue;
        h[c] = h[u] + 1;
        DFS(c , u);
    }
}
int res = 0;

int DFS1(int u , int par){
    int cur = 1;
    for(int c : adj[u]){
        if(c == par)continue;
        cur = max(cur , DFS1(c , u) + 1);
    }
    if(cur == k && u != 1)cur = 0 , res += par != 1;
    return cur;
}

int main(){
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    cin >> n >> k;
    res = 0;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
        res += (a[i] != 1);
    }
    for(int i = 2 ; i <= n ; ++i){
        adj[a[i]].pb(i);
    }
    if(k == 1)return cout << res , 0;
    res = 0;
    DFS1(1 , 0);
    res += (a[1] != 1);
    cout << res;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

int main()
{
  int k;
  cin >> k;
  vector<ll> list;
  for (int i = 1; i < 10; i++) {
    list.push_back(i);
  }
  while (1) {
    if (k <= list.size()) {
      cout << list[k - 1] << endl;
      return 0;
    }
    k -= list.size();
    vector<ll> old;
    swap(old, list);
    for (ll x : old) {
      for (int i = -1; i < 2; i++) {
        int d = x % 10 + i;
        if (d < 0 || d > 9) continue;
        list.push_back(x * 10 + d);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1712
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
l = sorted(list(li()))
print(sum(l[::2]))

Measured memory_bytes: 3064
import sys
X = int(input())
#for a in range(-120,120):
#  b = a**5-X
#  if b < 0: b = -(-b)**0.2
#  else: b = b**0.2
#  if b.is_integer():
#    print(a,int(b))
#    break
    
for a in range(-120,120):
  for b in range(-120,120):
    if a**5-b**5 == X:
      print(a,b)
      sys.exit()

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

int n, q;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n >> q;
		if(n == 0 && q == 0) return 0;
		int a[110] = {};
		for(int i=0; i<n; ++i){
			int m;
			cin >> m;
			for(int j=0; j<m; ++j){
				int t;
				cin >> t;
				++a[t];
			}
		}
		int ans = 0;
		int ma = 0;
		for(int j=1; j<100; ++j)
			if(a[j] >= q && a[j] > ma){
				ans = j;
				ma = a[j];
			}
		cout << ans << "\n";
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define sz(x) (int)x.size()
#define db(x) cerr << #x << ": " << x << "\n";

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

    ll X, N = 100;
    cin >> X;
    for(int i=1; ;i++) {
        N += (N/100);
        if(N >= X)
            return cout << i << "\n", 0;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{

    
    int n,k;
    cin>>n>>k;
    int tab[n];
    for(int i=0;i<n;i++)
    {
    	cin>>tab[i];
	}
	int dp[k+1];
	dp[0]=0;
	for(int j=1;j<k+1;j++)
	{
		dp[j]=0;
	}
	for(int j=1;j<k+1;j++)
	{
		for(int i=0;i<n;i++)
		{
			if((j-tab[i]>=0)and(dp[j]==0))
			{
				dp[j]=1-dp[j-tab[i]];
			}
		}
	}
	if(dp[k]==1)
	{
		cout<<"First";
	}
	else
	{
		cout<<"Second";
	}
}



Measured memory_bytes: 640
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int main(){

    ios :: sync_with_stdio(false);
    int N, K;
    ll psum[100005], pmax[100005];
    memset(psum, 0, sizeof(psum));
    memset(pmax, 0, sizeof(pmax));

    cin >> N >> K;
    FOR(i,N){
        ll x;
        cin >> x;
        psum[i] = psum[i-1] + x;
        pmax[i] = pmax[i-1] + max(x, 0ll);
    }

    ll ans = 0;
    FOR(i,N-K+1){
        int j = i+K-1;
        ans = max(
            ans,
            pmax[i-1] + (pmax[N] - pmax[j]) +
            max(psum[j] - psum[i-1], 0ll)
        );
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)

all_dist = arr[0].abs
(0..n-2).each do |i|
  all_dist += (arr[i+1] - arr[i]).abs
end
all_dist += arr[n-1].abs

p all_dist - (arr[0].abs + (arr[1] - arr[0]).abs) + arr[1].abs

(1..n-2).each do |i|
  minus = (arr[i+1] - arr[i]).abs + (arr[i] - arr[i-1]).abs
  plus = (arr[i+1] - arr[i-1]).abs
  p all_dist - minus + plus
end

p all_dist - (arr[n-1].abs + (arr[n-1] - arr[n-2]).abs) + arr[n-2].abs


Measured memory_bytes: 16780
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

template <class _T> void tp_getPrimes(_T targ, std::map<_T, _T>& primes)
{
	_T target = targ;
	_T i = 2;
	while ((i * i) <= target) {
		if ((target % i) == 0) {
			target /= i;

			if (primes.find(i) == primes.end()) {
				primes[i] = 1;
			}
			else {
				primes[i] = primes[i] + 1;
			}
		}
		else {
			i++;
		}
	}
	if (target == 1) {
		//	なにもしない
	}
	else if (primes.find(target) == primes.end()) {
		primes[target] = 1;
	}
	else {
		primes[target] = primes[target] + 1;
	}
}

static void D_task()
{
	LLONG A, B;
	get2int<LLONG>(A, B);

	std::map<LLONG, LLONG> pa, pb;
	tp_getPrimes<LLONG>(A, pa);
	tp_getPrimes<LLONG>(B, pb);

	LLONG ans = 0;
	for (auto ait = pa.begin(); ait != pa.end(); ait++) {
		if (pb.find(ait->first) != pb.end()) {
			ans++;
		}
	}
	printf("%lld\n", ans + 1);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int ns,nt,i,sum=0,key,j,flag;
  int s[10000],t[10000];
  scanf("%d",&ns);
  for(i=0;i<ns;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&nt);
  for(i=0;i<nt;i++){
    scanf("%d",&t[i]);
  }
  
  for(i=0;i<nt;i++){
    j=0;
    flag=0;
    key=t[i];
    while(s[j]!=key){
      j++;
      if(j==ns){flag=1; break;}
    }
    if(flag==0) {sum++;}
  }
  printf("%d\n",sum);
  return 0;
}



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

int main() {
    int n,a[105],max=0,min=0,b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    for(int i=0;i<n;i++){
        if(i%2==0){
            max+=a[i];
        }
        else{
            min+=a[i];
        }
    }
    cout<<max-min<<'\n';
	return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出,オーバーフローする入力を投げるとよい
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    ll w,x;
    cin>>str;
    rep(i,str.length()){
        if(i==4) cout<<" ";
        cout<<str[i];
    }
    ln;

    return 0;
}


Measured memory_bytes: 3572
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int donutType = int.Parse(s[0]);
            int mix = int.Parse(s[1]);
            int recipe = 0;
            int minimumRecipe = 1000;
            // お菓子の素からすべての種類のドーナツの素グラム引く
            for (int i = 0; i < donutType; ++i)
            {
                recipe = int.Parse(Console.ReadLine());
                mix -= recipe;
                if (minimumRecipe >= recipe)
                {
                    minimumRecipe = recipe;
                }
            }
            // 残ったお菓子の素で一番使用量の少ないドーナツがいくつ作れるかと
            // ドーナツの種類の数を足すと答えが出る
            Console.WriteLine(donutType + (mix / minimumRecipe));
        }
    }
}

Measured memory_bytes: 13140