akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    int a[n+1];
    for(int i = 1; i <= n; i++)  cin >> a[i];
    vector<int> lfrom[n+1], r(n+1);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        lfrom[x].push_back(y);
    }
    priority_queue<int> pq;
    for(int i = 1; i <= n; i++){
        for(int j : lfrom[i])   pq.push(j);
        while(!pq.empty() && pq.top() < i)    pq.pop();
        r[i] = pq.empty() ? i : pq.top();
    }
    vector<ll> dp(n+1, 0);
    ll val = 0;
    for(int i = 1; i <= n; i++){
        dp[r[i]] = max(dp[r[i]], val+a[i]);
        val = max(val, dp[i]);
    }
    cout << val << endl;
    return 0;
}


Measured memory_bytes: 15168
/*

	ABC060
	C Sentou

*/
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long int N, T;
	cin >> N >> T;
	long long totalTime = 0;
	long int t,prevt;
	cin >> t;
	for (int i = 1; i < N; i++)
	{
		prevt = t;
		cin >> t;
		totalTime += min(T, (t - prevt));;
	}
	totalTime += T;

	cout << totalTime << endl;

	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 100;

int n, a[N], deg[N];
vi adj[N];

bool res;
ll dfs(int u, int p) {
    bool leaf = true;
    ll sum = 0, mx = 0;
    for (int v : adj[u]) if (v != p) {
        ll dv = dfs(v,u);
        sum += dv;
        mx = max(mx, dv);
        leaf = false;
    }
    if (leaf) return a[u];


    auto rest = sum - a[u];
    auto pairs = min(sum/2, sum-mx);
    res &= (0 <= rest && rest <= pairs);

    if (res) return sum - 2*rest;
    else return 0;
}

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

    cin >> n;
    forn(i,n) cin >> a[i];
    forn(_,n-1) {
        int u,v; cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
        deg[u]++; deg[v]++;
    }

    res = true;
    forn(u,n) if (deg[u] > 1) {
        res &= dfs(u,-1) == 0;
        break;
    }
    if (n == 2) res = a[0] == a[1];
    cout << (res ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 13184
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    double d1;
    double x;
    cin >> N >> d1 >> x;
    double ans = 0;
    double d = (d1 + d1 + x) / 2;
    double xx = x * 2;
    while (N >= 3) {
        double pl = (d + (d + xx * (N - 1))) / 2;
        ans += pl;
        ll N2 = N - 1;
        double fir = ((d + xx) + (d + xx + d) * 2 + d * (2 * (N - 2) + 1)) / (2 * N);
        double sec = ((d + 2 * xx) * 3 + (d + 2 * xx + d + xx) * 2 + (d + xx) * (2 * (N - 3) + 1))
            / (2 * N);
        N = N2;
        d = fir;
        xx = sec - fir;
        if (x == 0) {
            xx = 0;
        }
    }
    if (N == 2) {
        ans += (d + d + xx) / 2;
        d = (d + (d + d + xx) * 2 + (d + xx)) / 4;
    }
    ans += d;
    cout << setprecision(12);
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::cmp;

const INF: usize = 1e15 as usize;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let h: usize = sc.read();
    let w: usize = sc.read();
    let c: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();
    let mut map = vec![vec![0; h]; w];
    for i in 0..w {
        for j in 0..h {
            map[i][j] = c[j][i] as usize - 'a' as usize;
        }
    }

    let mut ans = 0;
    for i in 1..w {
        ans += calc(&map[i - 1], &map[i]);
    }
    println!("{}", ans);
}

fn calc(a: &Vec<usize>, b: &Vec<usize>) -> usize {
    let n = a.len();
    let mut cost_dp = vec![vec![0; n + 1]; n + 1];
    for i in 0..n {
        let mut cost = 0;
        for j in 0..(n - i) {
            if a[j + i] == b[j] {
                cost += 1;
            }
        }
        cost_dp[0][i] = cost;
    }
    for i in 0..n {
        let mut cost = 0;
        for j in 0..(n - i) {
            if b[j + i] == a[j] {
                cost += 1;
            }
        }
        cost_dp[i][0] = cost;
    }
    for d in 0..n {
        for i in 0..n {
            if i + 1 + d > n { break; }
            cost_dp[i + 1][i + 1 + d] = cost_dp[i][i + d] - if a[n - 1 - i] == b[n - 1 - d - i] { 1 } else { 0 };
            cost_dp[i + 1 + d][i + 1] = cost_dp[i + d][i] - if a[n - 1 - d - i] == b[n - 1 - i] { 1 } else { 0 };
        }
    }

    let mut dp = vec![vec![INF; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..n {
            dp[i + 1][j] = cmp::min(dp[i][j] + cost_dp[i][j], dp[i + 1][j]);
            dp[i][j + 1] = cmp::min(dp[i][j] + cost_dp[i][j], dp[i][j + 1]);
        }
    }
    let mut ans = INF;
    for i in 0..n {
        ans = cmp::min(ans, dp[n][i]);
        ans = cmp::min(ans, dp[i][n]);
    }
    ans
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long a,b,c;
    a=n/500;
    n=n%500;
    b=n/5;
    c=1000*a+b*5;
    cout<<c<<"\n";
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<double> v(n);
  rep(i, n) cin >> v[i];
  sort(all(v));
  double ans = (v[0] + v[1]) / 2;
  for (int i = 2; i < n; ++i) {
    ans = (ans + v[i]) / 2;
  }
  cout << setprecision(20);
  out(ans);
}


Measured memory_bytes: 3656
N, M, C = (int(i) for i in input().split())  
B = [int(i) for i in input().split()]
a_list  = [[int(i) for i in input().split()] for i in range(N)] 

count = 0
for A in a_list:
    sum_num = 0
    for i in range(M):
        sum_num += A[i] * B[i] 

    if sum_num + C > 0:
        count += 1

print( count )


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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll; 
 
int main(void){
	
	char b;
	
	cin >> b;
	
	if(b == 'A')
		cout << 'T';
	else if(b == 'C')
		cout << 'G';
	else if(b == 'T')
		cout << 'A';
	else
		cout << 'C';
	
	return 0;
}

Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int x, a, b;
    scan(x, a, b);

    if (b - a <= 0) {
        writeln("delicious");
    }
    else if (b - a <= x) {
        writeln("safe");
    }
    else {
        writeln("dangerous");
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

Measured memory_bytes: 256
// sandeep_007  
#include <bits/stdc++.h>
 
using namespace std; 
 
#define PI acos(-1)
#define mod 1000000007
#define ll long long
#define nitro std::ios_base::sync_with_stdio (false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define vi vector < int >
#define md 998244353
#define rep(i,a,b) for(int i=a;i<b;i++)
#define FF first
#define SS second
#define all(a) (a).begin(),(a).end()

int main () {
    nitro;
 
    #ifdef DBG
        freopen("in","r",stdin);
    #endif
   
   	int a,b; cin >> a >> b;
   	if(b%a == 0) cout << a + b << endl;
   	else cout << b-a << endl;
   	
   	
    return 0;
}   

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

int main(){
  int i,j,ans,c;
  int a[2][4001];
  string str,str2;
  while(cin >> str >> str2){
    
    for(i=0;i<=str.size();i++) a[0][i] = 0;
    for(j=0;j<=str2.size();j++) a[0][j] = 0;

    ans = 0;
    for(i=1;i<=str.size();i++){
      for(j=1;j<=str2.size();j++){
	if(str[i-1] == str2[j-1]){
	  a[1][j] = a[0][j-1] + 1;
	  ans = max(ans,a[1][j]);
	}
	else a[1][j] = 0;
      }
      for(j=0;j<str2.size();j++) a[0][j] = a[1][j];
    }

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

Measured memory_bytes: 964
import java.math.BigInteger;
import java.util.Scanner;

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

        String[] str;
        str = s.split(" ");
        BigInteger a = new BigInteger(str[0]);
        BigInteger b = new BigInteger(str[1]);

        BigInteger c = a.subtract(b);

        System.out.println(c);
    }
}



Measured memory_bytes: 77040
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

H,W = inpl()
MAP = [list(input()) for i in range(H)]
xx = []
yy = []

for x in range(W):
	for y in range(H):
		if MAP[y][x] == '.':
			continue
		else:
			break
	else:
		xx.append(x)

for y in range(H):
	for x in range(W):
		if MAP[y][x] == '.':
			continue
		else:
			break
	else:
		yy.append(y)

ans = []
for y in range(H):
	if y in yy:
		continue
	tmp = []
	for x in range(W):
		if x in xx:
			continue
		tmp.append(MAP[y][x])
	ans.append(tmp)

for azu in ans:
	print(''.join(azu))


Measured memory_bytes: 4328
x = int(input())
if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 1000 <= x < 1200:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)

Measured memory_bytes: 9184
# -*- coding: utf-8 -*-

import sys

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 ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

G = list2d(N, N, 0)
A = list(range(N))

def rec(li, lv):
    n = len(li)
    # 頂点が1つ以下になったら終了
    if n <= 1:
        return
    # 頂点集合を半分に分けて、2部グラブにする
    li1 = li[:n//2]
    li2 = li[n//2:]
    for u in li1:
        for v in li2:
            G[u][v] = lv
    # 半分にした集合を再帰的に処理する
    rec(li1, lv+1)
    rec(li2, lv+1)
    return

rec(A, 1)

ans = []
for i in range(N):
    row =[]
    for j in range(i+1, N):
        row.append(G[i][j])
    ans.append(row)

for row in ans:
    print(*row)


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

#define lp_i(k,n)  for(int i = (k); i < (n); i++)
#define lp_j(k,n)  for(int j = (k); j < (n); j++)
#define lp_ui(k,n) for(uint32_t i = (k); i < (n); i++)
#define lp_uj(k,n) for(uint32_t j = (k); j < (n); j++)

typedef uintmax_t    ull;
typedef uint32_t     ui;
typedef uint8_t      uc;

using namespace std;

int main()
{
	ui N, D;
	ui ans = 0;
	std::cin >> N >> D;

	vector<vector<int>> posArray(N);
	lp_ui(0, posArray.size())
	{
		vector<int> pos(D);
		lp_uj(0, pos.size())
			std::cin >> pos[j];
		posArray[i] = pos;
	}

	lp_ui(0, posArray.size())
	{
		if (i == 0) continue;
		auto pos_current = &posArray[i];

		lp_uj(0, i)
		{
			ui sum = 0;
			auto pos_old = &posArray[j];
			for (ui k = 0; k < pos_old->size(); k++)
			{
				sum += (ui)pow((*pos_current)[k] - (*pos_old)[k], 2);
			}
			auto dis = (ui)sqrt(sum);
			if (dis * dis == sum)
				ans++;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main() {
	
int n, k1;
cin >> n >> k1;
long a[n+1];
multiset <int> ss;   
multiset <int> :: iterator  it;   
for(int i = 1; i < n+1; i++)
	cin >> a[i];

long ans = 0;
for(int i = 1; i < min(n+1,k1+1); i++)
{
	for(int j = 0; j <= i; j++)
	{
		long sum = 0;
		for(int k = 1; k <= j; k++)
		{
			sum+=a[k];
			if(a[k] < 0)
				ss.insert(a[k]);
		}

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

		int c = k1- i;
		for(auto it = ss.begin(); it!= ss.end() && c>0 ; it++)
		{
			sum -= *it;
			c--;
		}
		ss.clear();
		ans = max(ans, sum);
	}
}
cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
/*
          Life before Death
          Strength before Weakness
          Journey before Destination
    */
    
    #include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(ll i=a;i<n;i++)
    #define per(i,n,a) for (ll i=n;i>a;i--)
    #define te ll t; std::cin >> t; while(t--)
    #define SZ 100010
    //#define M_PI  3.141592653589793238462643383279502884L
    /*------Just DO IT--------------------------------------*/
  
    ll solve(){
      ll n;
      cin>>n;
      ll a[n],cnt=0;
      rep(i,0,n) cin>>a[i] , (a[i]%2 ? cnt++:0) ;
      cout<<(cnt ? "first":"second");
    }
    
    int main() {
       fastio;
       solve();
    }

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

void call(int n)
{
	int i = 1;
	int x = 1;
	
	while( true )
	{
		x = i;
		if( x % 3 == 0 )
		{
			cout << " " << i;
			++i;
			if( i > n )
				break;
			else
				continue;
		}
		
		do
		{
			if( x % 10 == 3 )
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		}while( x );
		
		++i;
		if( i > n )
			break;
	}
	
	cout << endl;
}

int main()
{
int n;
cin >> n;
call(n);
return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;


signed main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for( int i = 0; i < N; i++ ) cin >> H[i];

  vector<int> dp(N+10, INF);
  dp[0] = 0;
  for( int i = 1; i < N; i++ ){
    dp[i] = min(dp[i], dp[i-1]+abs(H[i]-H[i-1]));
    if( i >= 2 ) dp[i] = min(dp[i], dp[i-2]+abs(H[i]-H[i-2]));
  }
  cout << dp[N-1] << endl;
  
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;

struct UnionFind{
    vector<int> par; 
    vector<int> rank; 
    int num;
    UnionFind(int N){
        num = N;
        rank.resize(N);
        par.resize(N);
        for(int i  = 0; i < N; i++) {
            rank[i] = 0;
            par[i] = i;
        }
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] > rank[y]){
            swap(x, y);
        }
        if(rank[x] == rank[y]) rank[y]++;
        par[x] = y;
        num--;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int count() const{
        return num;
    }
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  int ans = n - 1;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }
  cout << uf.count()-1 << endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t) && t != '-') t = getchar();
	if (t == '-')
	{
		_read(x);
		x *= -1;
		return ; 
	}
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}

const int MAXN = 2e5 + 50;
vector <pll> G[MAXN];
vector <pll> f[MAXN];
vector <pll> tl, tr;
ll lim;
inline void inc(int x, const pll &t)
{
	if(f[x].size() && f[x].back() <= t) return;
	while(f[x].size() && f[x].back().second >= t.second) f[x].pop_back();
	f[x].push_back(t);
}
inline bool dfs(int x, int fa)
{
	f[x].clear();
	if(G[x].size() == 1)
	{
		f[x].push_back(pll(0, 0));
		return true;
	}
	ll lc, rc, disl, disr;
	int fir = 0;
	for(int e = G[x].size() - 1; e >= 0; --e)
	{
		int v = G[x][e].first;
		if(v == fa) continue;
		if(!dfs(v, x)) return false;
		if(!fir) fir = 1, lc = v, disl = G[x][e].second;
		else rc = v, disr = G[x][e].second;
	}
	tl.clear(), tr.clear();
	ll lim2 = lim - disl - disr;
	if(lim2 < 0) return false;
	for(int p1 = 0, p2 = 0; p2 < f[rc].size(); ++p2)
	{
		while(p1 < f[lc].size() && f[lc][p1].first + f[rc][p2].second > lim2) ++p1;
		if(p1 == f[lc].size()) break;
		tl.push_back(pll(f[rc][p2].first + disr, f[lc][p1].second + disl));
	}
	for(int p1 = 0, p2 = 0; p1 < f[lc].size(); ++p1)
	{
		while(p2 < f[rc].size() && f[lc][p1].second + f[rc][p2].first > lim2) ++p2;
		if(p2 == f[rc].size()) break;
		tr.push_back(pll(f[lc][p1].first + disl, f[rc][p2].second + disr));
	}
	int pl = 0, pr = 0;
	while(pl < tl.size() && pr < tr.size())
	{
		if(tl[pl].first > tr[pr].first) inc(x, tl[pl++]);
		else inc(x, tr[pr++]);
	}
	while(pl < tl.size()) inc(x, tl[pl++]);
	while(pr < tr.size()) inc(x, tr[pr++]);
	return f[x].size() > 0;
}
inline bool check(ll v)
{
	lim = v;
	return dfs(1, 0);
}
int n;
int main()
{
	_read(n);
	for(int i = 2, x, w; i <= n; ++i)
	{
		_read(x), _read(w);
		G[x].push_back(pll(i, w));
		G[i].push_back(pll(x, w));
	}
	ll l = 0, r = 1e12, ans = 0;
	while(l <= r)
	{
		ll mid = (l + r) >> 1;
		if(check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

struct unionfind {
  vector<int> parent;
  vector<int> per_size;

  unionfind(int n): parent(n, -1), per_size(n, 1) {}

  int root(int x){
    return parent[x] != -1 ? parent[x] = root(parent[x]) : x; 
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    if(per_size[rx] < per_size[ry]) swap(rx, ry);
    per_size[rx] += per_size[ry];
    parent[ry] = rx; 
  }

  bool is_same(int x, int y){
    return root(x) == root(y);
  }

  int tree_size(int x){
    return per_size[root(x)];
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> edges(m);
  for(int i = 0, x, y; i < m; ++i){
    cin >> x >> y;
    x--; y--;
    edges[i] = make_pair(x, y);
  }
  int ans = 0;
  for(int i = 0; i < m; ++i){
    unionfind uf(n);
    for(int j = 0; j < m; ++j){
      if(i == j) continue;
      uf.unite(edges[j].first, edges[j].second);
    }
    if(uf.tree_size(0) != n) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_M = 100000;



int main(int argc, char *args[]) {
	int n, m;
	cin >> n >> m;
	priority_queue<ll> q;
	for (int i = 0; i < n; i++) {
		ll A;
		cin >> A;
		q.push(A);
	}
	for (int i = 0; i < m; i++) {
		ll t = q.top(); q.pop();
		q.push(t / 2);
	}
	ll res = 0;
	while (!q.empty()) {
		res += q.top();
		q.pop();
	}
	cout << res << endl;

}

Measured memory_bytes: 1528
defmodule Main do
  require Integer

  def main do
    n = IO.gets("") |> String.trim() |> String.to_integer()

    div_game(n) |> IO.puts()
  end

  @doc """
  div_game

  ## Examples

      iex> DivGame.div_game(24)
      3
      iex> DivGame.div_game(64)
      3
      iex> DivGame.div_game(1)
      0
      iex> DivGame.div_game(1000000007)
      1
      iex> DivGame.div_game(997764507000)
      7

  """
  def div_game(n) do
    M.factorization(n)
    |> Enum.map(fn [_, p] -> p end)
    |> Enum.map(&divide/1)
    |> Enum.sum()
  end

  defp divide(n) do
    Stream.iterate(1, &(&1 + 1))
    |> Enum.reduce_while({n, 0}, fn i, {acc_n, acc_cnt} ->
      rem = acc_n - i
      if rem < 0, do: {:halt, {rem, acc_cnt}}, else: {:cont, {rem, acc_cnt + 1}}
    end)
    |> elem(1)
  end
end

# https://qiita.com/sym_num/items/c7ad291644a55d6c0419
defmodule M do
  def normal(n) do
    W.factor([], n, 2, trunc(:math.sqrt(n)))
    |> compress
  end

  def factorization(n) when n < 10000 do
    W.factor([], n, 2, trunc(:math.sqrt(n)))
    |> compress
  end

  def factorization(n) do
    limit = trunc(:math.sqrt(n))
    factors1(10, n, 2, div(limit, 10) + 1, limit)
    factors2(10, []) |> Enum.sort() |> sieve |> adjust(n) |> compress |> Enum.reverse()
  end

  def compress(ls) do
    Enum.chunk_by(ls, fn n -> n end)
    |> Enum.map(fn x -> [hd(x), length(x)] end)
    |> Enum.reverse()
  end

  def factors1(1, n, start, _, limit) do
    pid = spawn(W, :part, [])
    send(pid, {self(), {n, start, limit}})
  end

  def factors1(c, n, start, add, limit) do
    stop = start + add
    pid = spawn(W, :part, [])
    send(pid, {self(), {n, start, stop}})
    factors1(c - 1, n, stop + 1, add, limit)
  end

  def factors2(0, ls) do
    ls
  end

  def factors2(n, ls) do
    receive do
      {:answer, msg} ->
        factors2(n - 1, msg ++ ls)
    end
  end

  def sieve([]) do
    []
  end

  def sieve([l | ls]) do
    [l] ++ sieve(sieve1(ls, l, []))
  end

  def sieve1([], _, res) do
    Enum.reverse(res)
  end

  def sieve1([l | ls], x, res) do
    if rem(l, x) == 0 && x != l do
      sieve1(ls, x, res)
    else
      sieve1(ls, x, [l] ++ res)
    end
  end

  def adjust(l, x) do
    if Enum.member?(l, x) do
      [x]
    else
      l
    end
  end
end

defmodule W do
  def part do
    receive do
      {sender, {n, start, stop}} -> send(sender, {:answer, W.factor([], n, start, stop)})
    end
  end

  def factor(p, n, x, limit) do
    cond do
      n == 1 -> p
      x > limit -> [n | p]
      rem(n, x) == 0 -> factor([x | p], div(n, x), x, limit)
      x == 2 -> factor(p, n, 3, limit)
      rem(x, 2) == 0 -> factor(p, n, x + 1, limit)
      true -> factor(p, n, x + 2, limit)
    end
  end
end

Measured memory_bytes: 30900
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n;
  cin >> n;
  vector<lld> a(n),b(n);
  for (lld i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  lld c1 = a[(n - 1) / 2], c2 = a[n / 2], d1 = b[(n - 1) / 2], d2 = b[n / 2];
  // cout << c1 << "," << c2 << "," << d1 << "," << d2 << "\n";
  if (n % 2 == 0) {
    cout << ((d1 + d2) - (c1 + c2) + 1) << "\n";
  } else {
    cout << (d1 - c1 + 1) << "\n";
  }
}

Measured memory_bytes: 6428
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

map <char,int> mp;

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
	    if(mp[s[i]]) {puts("no"); return 0;}
	    mp[s[i]]=1;
	}
	cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  int ans = 0;
  REP(i, s.length())
  {
    if (s[i] == t[i])
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


K, S = map(int, input().split())


# In[9]:


count = 0


# In[10]:


for x in range(K+1):
    for y in range(K+1):
        if x+y >= S-K and x+y <= S:
            #print(x, y)
            count += 1


# In[11]:


print(count)


# In[ ]:






Measured memory_bytes: 2940
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define N (100000+1000)
using namespace std;

int n,a[4][N],tar[N],R[2];

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=3; ++i)
		for (int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	for (int i=1; i<=n; ++i)
	{
		tar[i]=(a[2][i]+1)/3;
		if (abs(a[2][i]-a[1][i])!=1 || abs(a[2][i]-a[3][i])!=1 || abs(i-tar[i])%2)
		{
			puts("No");
			return 0;
		}
		R[i&1]^=(a[1][i]>a[3][i]);
	}
	for (int i=1; i<=n; ++i)
		while (tar[i]!=i)
			R[i&1^1]^=1,swap(tar[i],tar[tar[i]]);
	if (R[0] || R[1]) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;

#define MAX_N 1000
#define MAX_M 1000

int main(){
	int N, M;
	int X[MAX_N + 1], D[MAX_M];
	int P, T;
	
	while(true){
		scanf("%d%d", &N, &M);
		if(N == 0 && M == 0) break;
		for(int i = 1; i <= N; i++){
			scanf("%d", X + i);
		}
		for(int i = 0; i < M; i++){
			scanf("%d", D + i);
		}
		
		P = 1; T = 0;
		while(P < N){
			P += D[T];
			T++;
			if(P >= N) break;
			P += X[P];
			if(P >= N) break;
		}
		
		printf("%d\n", T);
	}
	
	return 0;
}

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

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	
	int wpf[n+2];
	memset(wpf, 0, sizeof wpf);
	for (int i=1; i<=n; i++) {
		wpf[i] = wpf[i-1] + (s[i-1] == 'W');
	}
	wpf[n+1] = wpf[n];
	
	int esf[n+2];
	memset(esf, 0, sizeof esf);
	for (int i=n; i>=1; i--) {
		esf[i] = esf[i+1] + (s[i-1] == 'E');
	}
	
	int mn = INT_MAX;
	
	for (int i=1; i<=n; i++) {
		mn = min(mn, wpf[i-1] + esf[i+1]);
	}
	
	cout << mn << endl;
	
}


Measured memory_bytes: 3076
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    x, y = IL(int)
    print('Yes' if y % 2 == 0 and 2 * x <= y <= 4 * x else 'No')


solve()


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

int main() {
  string s;
  cin>>s;
  
  for(int i=0;i<s.size()-1;i++){
      if(s.at(i)=='A'&&s.at(i+1)=='C'){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8
import Data.List (sort)

type Input  = (Int, Int, [(Int, Int)])
type Output = Int

input :: Parser Input
input = do
  (_N, _M) <- decimalPair
  _ABs <- count _N decimalPair
  return (_N, _M, _ABs)

decimalPair :: Parser (Int, Int)
decimalPair = (,)
  <$> decimal <* char ' '
  <*> decimal <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Output
solve (_N, _M, _ABs) = go 0 _M $ sort _ABs
  where
    go !n !m ((a, b) : abs)
      | m <= b    = n + a * m
      | otherwise = go (n + a * b) (m - b) abs

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

public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
	      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	      String input[] = br.readLine().split(" ");
	      long a = Long.parseLong(input[0]);
	      long b = Long.parseLong(input[1]);
	      long c = Long.parseLong(input[2]);
	      if(c < a || c < b) {
	    	  System.out.println("No");
	    	  return;
	      }
	      long d = c - a - b;
	      
	      System.out.println((d > 0 && (d * d) > (4 * a * b))?"Yes":"No");
	}

}


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

int main() {
  string s;
  cin>>s;
  for (int i=0; i<3; i++) {
    if (s[i] == s[i+1]) {
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;

}

Measured memory_bytes: 256
import copy
from collections import deque

n, m = map(int,input().split())

e = [[] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
visited = [False]*n
visited[0] = True
d = deque([[0, visited]])

cnt = 0
while d:
    f, visited = d.pop()
    for t in e[f]:
        v = copy.deepcopy(visited)
        if not v[t]:
            v[t] = True
            if False in v:
                d.append([t, v])
            else:
                cnt += 1
print(cnt)

Measured memory_bytes: 77104
S = int(input())
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

mod = 10**9+7
giveup = S//3
answer = 0
for i in range(1,giveup+1):
    left = S-i*3
    answer += (cmb(left+i-1,i-1))%mod
    
print(answer%mod)

Measured memory_bytes: 68136
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;


int main(){
	fast_io; cout_precision;
	int n;	cin >> n;	
	string str[n];
	unordered_map <string,ll> mp;
	for(int i=0; i<n; i++){
		cin >> str[i];
		sort(str[i].begin() , str[i].end());
		mp[str[i]]++;
	}
	ll ans=0;
	for(auto i=mp.begin() ; i!= mp.end() ;i++)	ans+=(((i->second)*(i->second-1))/2);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
int n,m,k,a,b,ans[mxN];// declarations ans[i] stores the ans for ith user

unordered_set<int>component ;// unordered set to store all the nodes of current component of analysis  

bool visited[mxN] ;// boolean array to keep track of all visited nodes 
vi friendship[mxN],blockship[mxN] ;//adjacency matrices storing all friendship nd blockship relations 

// the following dfs returns the size of connected component in which th source is also it stores all the nodes of that component in unordered set
int dfs(int v){
    int ans =1 ;// initialise for each node ans as 1 (node itself)
    visited[v]=true ;component.insert(v) ;
    for(int x :friendship[v])// for each adjacent node check if it is not visited yet then add its contribution
        if(!visited[x])
            ans+=dfs(x);
    return ans ;// return the size 
}
void solve(){
    cin >> n >> m >> k ;// input stuff 
    For(i,m){
        cin >>a >> b ;
        friendship[a].em(b);
        friendship[b].em(a) ;
    }
    For(i,k){
        cin >>a>> b ;
        blockship[a].em(b);
        blockship[b].em(a) ;
    }
    mems(visited,0) ;   // initialise all visited nodes as non visited
    //Now traverse all nodes and check if it is visited or not if it is then you can be sure that it is part of some component
    //that has already be processed  else compute tha ans for all nodes of that particular component 
    for(int i =1;i<=n;i++){
        if(visited[i])
            continue ;
        component.clear() ;// make sure to empty the set before moving ahead 
        int comp_size=dfs(i) ;// find size of the component which contains node i 
        for(int x :component){
            ans[x]=comp_size-1 ;// first condition says that a!=b
            for(int c:blockship[x])
                if(component.count(c))ans[x]-- ;// second says that no blockship between a and b 
            ans[x]-=sz(friendship[x]) ;// lastly no friendship too
        }
    }
    Rep(i,n)pff(ans[i]);// print the ans array 

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}

Measured memory_bytes: 17396
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

typedef vector<vector<int>> Graph;

void warhsall_floyd(Graph& G) {
    for (int k = 0; k < G.size(); k++) {
        for (int i = 0; i < G.size(); i++) {
            if (G[i][k] == INF) {
                continue;
            }
            for (int j = 0; j < G.size(); j++) {
                if (G[k][j] == INF) {
                    continue;
                }
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}

int main() {
    int H, W;
    cin >> H >> W;

    Graph g(10, vector<int>(10, 0));

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            int cij;
            cin >> cij;
            g[i][j] = cij;
        }
    }

    warhsall_floyd(g);

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int Aij;
            cin >> Aij;
            if (Aij != -1) {
                ans += g[Aij][1];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int k;
int val[105];
int cnt=0;
void DFS(int depth,int v){
    if(depth==v){
        cnt++;
        if(cnt==k){
            for(int i=0;i<depth;i++){
                cout<<val[i];
            }
        }
        return ;
    }
    if(depth==0){
        for(int i=1;i<=9;i++){
            val[depth]=i;
            DFS(depth+1,v);
        }
    }else if(val[depth-1]==0){
        val[depth]=val[depth-1];
        DFS(depth+1,v);
        val[depth]=val[depth-1]+1;
        DFS(depth+1,v);
    }else if(val[depth-1]==9){
        val[depth]=val[depth-1]-1;
        DFS(depth+1,v);
        val[depth]=val[depth-1];
        DFS(depth+1,v);
    }else{
        val[depth]=val[depth-1]-1;
        DFS(depth+1,v);
        val[depth]=val[depth-1];
        DFS(depth+1,v);
        val[depth]=val[depth-1]+1;
        DFS(depth+1,v);
    }
    return ;
}
int main(){
    cin>>k;
    for(int i=1;i<=10;i++){
        DFS(0,i);
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int l; cin >> l;
    double hen = (double)l / 3;
    cout << fixed << setprecision(9) << hen * hen * hen << "\n";
}   
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




using P = complex<double>;
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
const double eps = 1e-10;



int main() {
    P p1, p2;
    double p1x, p1y, p2x, p2y;
    cin >> p1x >> p1y >> p2x >> p2y;
    p1 = P(p1x, p1y);
    p2 = P(p2x, p2y);
    P a = p2 - p1;
    
    int query;
    cin >> query;
    while (query--) {
        double x, y;
        cin >> x >> y;
        P p = P(x, y);
        P b = p - p1;
        
        P v = dot(a, b) / real(conj(a) * a) * a;
        v += p1;
        cout << fixed << setprecision(10) << real(v) << " " << imag(v) << endl;
    }
}



Measured memory_bytes: 3264
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))

    count = 0
    for i in range(0, n, 2):
        if A[i] % 2 != 0:
            count += 1

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9176
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn main(){
    input!{
        x1: isize,
        y1: isize,
        x2: isize,
        y2: isize
    }
    let dx = x2 - x1;
    let dy = y2 - y1;
    println!("{} {} {} {}", x2-dy, y2+dx, x1-dy, y1+dx);
}



Measured memory_bytes: 4352
#include <stdio.h>
int main(){
    int a,b,c,x,cnt=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    int i,j,k;
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(i*500+j*100+k*50==x)cnt++;
            }
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;main(){int n,k;cin>>n>>k;k-=n*(n-1)/2;if(1<n+k)cout<<-1;else{cout<<-k<<"\n";for(int i=1;i<n&&k;++i)for(int j=i+1;j<=n&&k;++j)cout<<i<<" "<<j<<"\n",k++;}}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){return *(LL*)a-*(LL*)b;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  LL i,a=0,b=0,flag=0,ans=0;
  char S[500010];
  scanf("%s",S);
  LL l=strlen(S);
  if(S[0]=='<')a=1;
  else flag=1,b=1;
  FOR(i,0,l-1){
    if(S[i]==S[i+1]){
      if(flag==0)a++;
      else b++;
    }
    else{
      if(flag==0)flag=1;
      else{
        flag=0;
        ans+=a*(a+1)/2+b*(b+1)/2-MIN(a,b);
        a=0,b=0;
      }
      if(flag==0)a++;
      else b++;
    }
  }
  ans+=a*(a+1)/2+b*(b+1)/2-MIN(a,b);

  printf("%lld\n",ans);
	return 0;
}


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

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

    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
    }
    else if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) FOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
ll ans;

void search(char s[][400]){
  rep(i,n){
    rep(j,n){
      if(s[i][j]!=s[j][i]) return;
    }
  }

  ans+=n;
}


void f(char s[][400],int m){
  rep(i,n){
    rep(j,n-m){
      swap(s[i][j],s[i][(j+n+m)%n]);
    }
  }
}


signed main(){
  char s[400][400];
  cin>>n;
  rep(i,n){
    cin>>s[i];
  }


  rep(i,n){
    search(s);
    f(s,1);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 1e5 + 100;
double n;
int main() {
	
	cin >> n;
	int x = ceil(n / 1.08);
	int tmp = x * 1.08;
	if(tmp != n) {
		puts(":(");
	}else {
		cout << x << endl;
	}
	return 0;
} 

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
int main(void) {
  arr(a,3);
  sortall(a);

  prtok(a[0]+a[1]==a[2]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256