akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        h1: i64, m1: i64, h2: i64, m2: i64, k: i64
    }

    let duration = (m2 - m1) + (h2 - h1) * 60;
    let ans = max(0, duration - k);

    println!("{}", ans);
}


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

int main(){
    bitset<64> x(0uL);
    int q, c, i;
    cin >> q;
    for(int j = 0; j < q; j++){
        cin >> c;
        switch(c){
            case 0:
                cin >> i;
                if (x[i] == 0){
                    cout << "0" << endl;
                }else{
                    cout << "1" << endl;
                }
                break;
            case 1:
                cin >> i;
                x.set(i, true);
                break;
            case 2:
                cin >> i;
                x.reset(i);
                break;
            case 3:
                cin >> i;
                x.flip(i);
                break;
            case 4:
                if (x.all()){
                    cout << "1" << endl;
                }else{
                    cout << "0" << endl;
                }
                break;
            case 5:
                if (x.any()){
                    cout << "1" << endl;
                }else{
                    cout << "0" << endl;
                }
                break;
            case 6:
                if (x.none()){
                    cout << "1" << endl;
                }else{
                    cout << "0" << endl;
                }
                break;
            case 7:
                cout << x.count() << endl;
                break;
            case 8:
                cout << x.to_ullong() << endl;
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        v:[isize;2],
    }
    let result: isize = if v[0] >= 10 {v[1]} else {v[1] + 100*(10 - v[0])};
    println!("{}", result);
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = list(map(int,input().split()))

    if n & 1 == 0:
        res = -INF
        score = sum(A[::2])
        res = max(res, score)
        for i in range(n-1,-1,-1):
            if i & 1:
                score += A[i]
            else:
                score -= A[i]
                res = max(res, score)
        print(res)
        return

    front_dp = [None] * n
    choose = -INF
    not_choose = 0
    for i in range(1, n, 2):
        choose, not_choose = max(choose, not_choose) + A[i], not_choose + A[i-1]
        front_dp[i] = max(choose, not_choose)

    back_dp = [None] * n
    choose = -INF
    not_choose = 0
    for i in range(n-2, -1, -2):
        choose, not_choose = max(choose, not_choose) + A[i], not_choose + A[i+1]
        back_dp[i] = max(choose, not_choose)

    res = -INF
    for i in range(1, n, 2):
        if i + 2 < n:
            res = max(res, front_dp[i] + back_dp[i+2])

    res = max(res, front_dp[-2])
    res = max(res, back_dp[1])

    print(res)
resolve()

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

int main()
{
        int n;
        double m;
        cin >> n >> m;
        vector<int> a(n);
        rep(i,n) cin >> a[i];

        int sum = 0;
        rep(i,n) sum += a[i];

        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());

        double tmp = sum * 1.0 / (4.0*m);
        rep(i,m) {
                if ((double)a[i] < tmp) {
                        cout << "No" << endl;
                        return 0;
                }
        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

signed main() {
    int i;
    string S;
    int N;
    cin>>N;
    cin>>S;
    bool ok=true;
    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    rep(i,0,N/2){
        if(S.at(i)!=S.at(i+N/2)){
            ok=false;
        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
c = []
for i in range(10):
    ci = list(map(int,input().split()))
    c.append(ci)
A = []
for i in range(h):
    a = list(map(int,input().split()))
    A.append(a)
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
c = warshall_floyd(c)
ans = 0
for i in range(h):
    for j in range(w):
        if A[i][j] == -1:
            continue
        else:
            ans+=c[A[i][j]][1]
print(ans)

Measured memory_bytes: 40284
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, long long int>>>;
long long int INF = 1001001001001001LL;
int inf = 100100100;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  string s; cin >> s;
  int ans = 0;
  for(auto c : s) ans += (c == '2');
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
import re
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

s = S()
ACGT = {'A', 'C', 'G', 'T'}
T = [x for x in re.split(r'[^ACGT]', s) if x != '']
ans = 0
for t in T:
    ans = max(ans, len(t))
print(ans)

Measured memory_bytes: 64620
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#2335

def main():
	n = 10**5+10
	primes = set(range(2, n+1))
	for i in range(2, int(n**0.5+1)):
		primes.difference_update(range(i*2, n+1, i))

	li=set()
	for i in primes:
		li.add(i)
		if i*2<n:
			li.add(i*2)
	li=list(li)
	li.sort()
	#print(li)

	li2=[0]*(n)
	for i in range(len(li)-1):
		if li[i]%2==1 and li[i+1]==li[i]+1:
			li2[li[i]]=1
	#print(li2)

	for i in range(n-1):
		li2[i+1]+=li2[i]
	#print(li2)

	q=II()
	for _ in range(q):
		l,r=MI()
		print(li2[r]-li2[l-1])





if __name__ == "__main__":
	main()

Measured memory_bytes: 63716
#include <stdio.h>
#define N 251
#define NIL 0

int A[N];

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}
  

int main()
{
  int i,H;
  for(i = 0; i < N; i++) A[i] = NIL;
  scanf("%d",&H);
  for(i = 1; i <=H; i++){
    scanf("%d",&A[i]);
  }
  for(i = 1; i <= H ;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(A[parent(i)] == NIL) printf("left key = %d, right key = %d, \n",A[left(i)],A[right(i)]);
    else if(A[right(i)] != NIL && A[left(i)] != NIL) printf("parent key = %d, left key = %d, right key = %d, \n",A[parent(i)],A[left(i)],A[right(i)]);
    else if(A[right(i)] == NIL && A[left(i)] != NIL) printf("parent key = %d, left key = %d, \n",A[parent(i)],A[left(i)]);
    else printf("parent key = %d, \n",A[parent(i)]);
  }
    return 0;
}
  



Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define inf MOD 
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int main() {
	int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	vector<int>p(a);
	vector<int>q(b);
	vector<int>r(c);
	rip(i, a)cin >> p[i];
	rip(i, b)cin >> q[i];
	rip(i, c)cin >> r[i];
	sort(all(p));
	sort(all(q));
	sort(all(r));
	vector<int>d;
	rip(i, x) {
		d.push_back(p[a - i - 1]);
	}
	rip(i, y) {
		d.push_back(q[b - i - 1]);
	}
	rip(i, c) {
		d.push_back(r[i]);
	}
	sort(all(d));
	ll sum = 0;
	rip(i, x + y) {
		sum += d[x + y + c - i - 1];
	}
	cout << sum << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N + 1), B(M + 1);
  for (int i = 1; i <= N; ++i)
    cin >> A[i];
  for (int j = 1; j <= M; ++j)
    cin >> B[j];

  vector<int> v(N + 1);
  for (int j = 1; j <= M; ++j) {
    for (int i = 1; i <= N; ++i)
      if (A[i] <= B[j]) {
        ++v[i];
        break;
      }
  }

  int ans = 0, v_n = 0;
  for (int i = 1; i <= N; ++i)
    if (v[i] > v_n)
      ans = i, v_n = v[i];

  cout << ans << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c,d,temp;
int main(){
  cin>>a>>b>>c>>d;
  if(a>c)temp=a,a=c,c=temp,temp=b,b=d,d=temp;
  if(b>d)temp=b,b=d,d=temp;
  cout<<(b>c?b-c:0)<<endl;
}


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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
#define  mod  1000000007
#define  endl  "\n"
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

bool vis[100005];
vector<int>v[100005];
void dfs(int r){
    vis[r]=1;
    for( auto i: v[r])
        if(!vis[i]) dfs(i);
}

int32_t main()
{
    fast
    int n,m,x,y,ans=0;
    cin>>n>>m;
    f(i,1,m){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    f(i,1,n)
        if(!vis[i]){
            dfs(i);
            ans++;
        }
    cout<<ans-1;
}

Measured memory_bytes: 10424
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	auto l = vector<int>(n);
	for(auto& r : l) cin >> r;
	auto rec = [&n, &a, &b, &c, &l](auto rec, int cnt, int x, int y, int z) -> int {
		if(cnt == n){
			return x * y * z > 0 ? abs(a - x) + abs(b - y) + abs(c - z) : 1000000000;
		}
		int res1 = rec(rec, cnt + 1, x, y, z);
		int res2 = rec(rec, cnt + 1, x + l[cnt], y, z) + 10;
		int res3 = rec(rec, cnt + 1, x, y + l[cnt], z) + 10;
		int res4 = rec(rec, cnt + 1, x, y, z + l[cnt]) + 10;
		return min({res1, res2, res3, res4});
	};
	cout << rec(rec, 0, 0, 0, 0) - 30 << endl;
	return 0;
}

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

struct Sieve {
        int n;
        vector<int> f,primes;
        
        Sieve(int n=1):n(n),f(n+1){
                f[0] = f[1] = -1;
                for(long long i=2;i<=n;++i){
                        if(f[i]) continue;
                        primes.push_back(i);
                        f[i] = i;
                        for(long long j = i*i;j <= n;j += i) {
                                if(!f[j]) f[j] = i;
                        }
                }
        }
        
        bool isPrime(int x){return f[x] == x;}
        
        int ff(int x){
                return  f[x];
        }
        
};

int main() {
        Sieve sieve(8000000);
        
        while(1){
                int n,m;
                cin >> m >> n;
                if(m == 0 && n == 0) break;
                int i = m;
                int count = 0;
                while(count <= n){
                        if(sieve.isPrime(i)) {count ++;}
                        else if(i/sieve.ff(i) < m) {count ++;}
                        i ++;
                }
                cout << i-1 << endl;
        }   
                
        return 0;
}



Measured memory_bytes: 38052
#include <iostream>
#include <string>
#include <algorithm>

int main() 
{
    std::string s_initial;
    std::string extend_init;
    std::string extend_tail;

    std::cin >> s_initial;
    size_t n_q;
    std::cin >> n_q;
    bool flip = false;
    for (size_t i = 0; i < n_q; i++) {
        size_t type;
        std::cin >> type;
        if (type == 1) {
            flip = !flip;
        } else {
            size_t end;
            char c;
            std::cin >> end >> c ;
            if ((!flip && end == 1) || (flip && end == 2)) {
                extend_init.push_back(c);
            } else {
                extend_tail.push_back(c);
            }
        }
        
    }

    if (!flip) {
        std::reverse(extend_init.begin(), extend_init.end());
        std::cout << extend_init << s_initial << extend_tail << std::endl; 
    } else {
        std::reverse(s_initial.begin(), s_initial.end());
        std::reverse(extend_tail.begin(), extend_tail.end());
        std::cout << extend_tail << s_initial << extend_init << std::endl;
    }
    return 0;
}


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

#define ll long long
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    if( (H+2)%2 != 0 ) H--;
    
    ll key = 1;
    while( H >= 2 )
    {
        key *= 2;
        H /= 2;
    }
    cout << key * 2 - 1 << endl;

}


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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int n;
	cin >> n;
	ll a[n+1], b[n];
	for(int i = 0; i <= n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];

	ll sum = 0;
	for(int i = 0; i < n; i++) {
		if(b[i] < a[i]) sum += b[i];
		else {
			sum += a[i];
			b[i] -= a[i];
			if(b[i] < a[i+1]) {
				sum += b[i];
				a[i+1] -= b[i];
			} else {
				sum += a[i+1];
				a[i+1] = 0;
			}
		}
	}

	cout << sum;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

const int MAX_N = 1001001; //埋め
int par[MAX_N];
int rank_union_find[MAX_N];

void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    rank_union_find[i] = 0;
  }
}

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_union_find[x] < rank_union_find[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank_union_find[x] == rank_union_find[y]) rank_union_find[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int n, m;

int main(){
  cin >> n >> m;
  init(n);
  rep(i, m){
    int x, y, z;
    x--;y--;
    cin >> x >> y >>z;
    unite(x, y);
  }
  set<int> ans;
  rep(i, n){
    ans.insert(find(i));
  }
  cout << ans.size() <<endl;
}
    



Measured memory_bytes: 9472
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]
uf = UnionFind(N)

for _ in range(M):
  x, y, z = map(int, input().split())
  uf.Unite(x, y)

roots = set()
for i in range(1, N + 1): roots.add(uf.Find_Root(i))
print(len(roots))

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

const int INF = (int)(1e7 + 5);
const int MAX_N = (int)(100 + 5);
const int MAX_M = (int)(1000 + 5);

int n, m;
int d[MAX_N][MAX_N];
int ta[MAX_M];
int tb[MAX_M];
int tc[MAX_M];

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) d[i][j] = INF;

  for (int i = 1; i <= n; ++i) d[i][i] = 0;

  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    d[a][b] = c;
    d[b][a] = c;
    ta[i] = a;
    tb[i] = b;
    tc[i] = c;
  }

  for (int k = 1; k <= n; ++k) for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }

  for (int edge = 1; edge <= m; ++edge) {
    bool tmp = true;
    for (int s = 1; s <= n; ++s) {
      tmp &= (d[s][ta[edge]] + tc[edge] != d[s][tb[edge]] && d[s][tb[edge]] + tc[edge] != d[s][ta[edge]]);
    }
    if (tmp) ans += 1;
  }


  printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]
a=[]
for i in range(h):
    if i%2==0:
        for j in range(w-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j+2])
                l[i][j+1]+=1
        j=w-1
        if l[i][j]%2==1 and i!=h-1:
            a.append([i+1,j+1,i+2,j+1])
            l[i+1][j]+=1
    else:
        for j in range(w-1,0,-1):
            if l[i][j]%2==1:
                a.append([i+1,j+1,i+1,j])
                l[i][j-1]+=1
        j=0
        if l[i][j]%2==1 and i!=h-1:
            a.append([i+1,1,i+2,1])
            l[i+1][j]+=1

print(len(a))
for i in a:print(' '.join(map(str,i)))

Measured memory_bytes: 29856
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
ll N;
ll ans = 0;
void dfs(ll n, vector<ll>& A,bool f) {
	if (n == N) {
		if (f)ans++;
		return;
	}
	for (int i = -1; i <= 1;i++) {
		if ((A[n] + i) % 2 == 0) {
			dfs(n + 1, A, true);
		}
		else {
			dfs(n + 1, A, f);
		}
	}
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N;i++) cin >> A[i];
	dfs(0, A, false);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

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

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

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

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  ll n;
  cin >> n;
  ll a[n+5],s[n+5];
  s[0]=0;
  rep (i,n){
    cin >> a[i];
    s[i+1]=s[i]+a[i];
  }
  ll mini = abs(a[0]-(s[n]-a[0]));
  //cout << mini << endl;
  for (int i = 1;i < n;i++){
    mini = min(mini,abs(s[i]-(s[n]-s[i])));

  }

cout << mini << endl;
    
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, a, b, X);
  print(b / X - (a ? (a - 1) / X : -1));
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;

int main()
{
	migmig ;
	string s ; 
	cin>>s ; 
	cout<<s[0]<<s[1]<<s[2] << endl ; 

}
//////
////////
///////////




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

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

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> A(N);
    rep(i,N) A[i]=i;
    vector<string> S(N);
    vector<int> P(N);
    rep(i,N) cin >> S[i]>>P[i];
    
    //-----------------------------------
    sort(A.begin(), A.end(), [&](int a, int b) {
        if(S[a]==S[b]) return P[a]>P[b];
        return strcmp(S[a].c_str(),S[b].c_str())<0;
    });
    rep(i,N) cout << A[i]+1 <<endl;
    return (0);
}

Measured memory_bytes: 256
/**************************
  * Author : Leo101
  * Problem : Four Coloring
  * Tags : 贪心，找规律
**************************/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define _FILE(s) freopen(#s".in", "r", stdin); freopen(#s".out", "w", stdout)
#define gi get_int()
int get_int()
{
	int x = 0, y = 1; char ch = getchar();
	while (!isdigit(ch) && ch != '-') ch = getchar();
	if (ch == '-') y = -1, ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * y;
}

char ch[4] = {'R', 'G', 'B', 'Y'};

int main()
{
	int n = gi, m = gi, k = gi;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int x = (i + j + m) / k % 2, y = (i - j + m) / k % 2;
			printf("%c", ch[x * 2 + y]);
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 512
#create date: 2020-07-07 10:59

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    r = ni()
    print(3 * r ** 2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9172
N = int(input())
A = list(map(int, input().split()))

prev = A[0]
cnt = 1
ans = 0
for i in range(1, N):
    if A[i] == prev:
        cnt += 1
    else:
        ans += cnt // 2
        cnt = 1
        prev = A[i]
ans += cnt // 2
print(ans)

Measured memory_bytes: 9072
x = int(input())
'''
if x == 1:
    ans = 1
elif x == 2:
    ans = 2
elif x == 3:
    ans = 2
elif x == 4:
    ans = 3
elif x == 5:
    ans = 3
elif x == 6:
    ans = 3
elif x == 7:
    ans = 4
elif x == 8:
    ans = 4
elif x == 9:
    ans = 4
elif x == 10:
    ans = 4
11から15までは5
122333444455555...の群数列
'''
for i in range(1,x+1):
    if i*(i-1)/2 < x <= i*(i+1)/2:
        ans = i
        break
print(ans)

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

int main() {
  string strgrade[] = {"AC", "WA", "TLE", "RE"};
  map<string, int> score;
  int num;
  cin >> num;

  for (int i = 0; i < num; i++)
  {
    string grade;
    cin >> grade;
    score[grade]++;
  }

  for (int i = 0; i < sizeof(strgrade) / sizeof(*strgrade); i++)
  {
    cout << strgrade[i] << " x " << score[strgrade[i]] << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>

using namespace std;


int main()
{
    string s;
    cin >> s;
    
    cout << (s[0] == s[1] && s[1] == s[2] ? "No" : "Yes") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vector<int> a(n);
	int cnt=0;//負の整数の数.
	bool jud0=false;//0があるかどうか.
	int tmp=INF;
	llong sum=0;
	REP(i,n){
		scanf("%d",&a[i]);
		if(a[i]==0){
			jud0=true;
			continue;
		}
		if(a[i]<0){
			++cnt;
			a[i]*=-1;
		}
		tmp=min(tmp,a[i]);
		sum+=a[i];
	}
	
	bool jud=!(cnt%2);//負の整数の数が偶数個かどうか.
	if(jud0||jud) cout<<sum<<endl;
	else cout<<sum-tmp*2<<endl;;
}//解説参考.かっこいい解放.

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

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

int Gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

  int N;
  cin >> N;

  vector<int> A(N);
  int mx = numeric_limits<int>::min();
  for (int& a : A) {
    cin >> a;
    mx = max(mx, a);
  }

  int g = A[0];
  repi(i, 1, N) {
    g = Gcd(g, A[i]);
  }

  if (g > 1) {
    cout << "not coprime" << '\n';
    return 0;
  }

  vector<int> divisor(mx + 1, -1);
  for (int i = 2; i <= mx; ++i) {
    if (divisor[i] == -1) {
      if (1LL * i * i <= mx) {
        for (int j = i + i; j <= mx; j += i) {
          if (divisor[j] == -1) {
            divisor[j] = i;
          }
        }
      }
    }
  }

  auto Primes = [&divisor](int N) {
    vector<int> result;
    while (N > 1) {
      int d = divisor[N];
      if (d == -1) {
        break;
      }

      result.push_back(d);
      while (N % d == 0) {
        N /= d;
      }
    }

    if (N > 1) {
      result.push_back(N);
    }

    return result;
  };

  set<int> M;
  for (int i = N - 1; i >= 0; --i) {
    auto p = Primes(A[i]);
    for (int v : p) {
      if (M.count(v)) {
        cout << "setwise coprime" << '\n';
        return 0; 
      }

      M.insert(v);
    }
  }

  cout << "pairwise coprime" << '\n';

  return 0;
}


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

long double ans,cur;
int n,k;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int clo=i,cnt=1;
        while(clo<k){
            cnt*=2;
            clo*=2;
        }
        ans+=((long double)1)/cnt;
    }
    ans/=n;
    printf("%.15Lf",ans);

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let h:i32 = read();
    
    println!("{}", h * (a + b) / 2)
}


Measured memory_bytes: 4352
a = 0
b = 0
num = int(input())
for i in range(num):
    s1,s2 = input().split()
    s1 = s1.lower()
    s2 = s2.lower()
    if s1 < s2:
        b += 3
    elif s1 > s2:
        a += 3
    else:
        a += 1
        b += 1
print(a,b)



Measured memory_bytes: 5600
import java.util.Scanner;

//Puzzle
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		boolean f = true;
		while(t--!=0){
			if(!f)System.out.println();
			f = false;
			int[][] a = new int[9][9];
			for(int i=0;i<9;i++)for(int j=0;j<9;j++)a[i][j]=sc.nextInt();
			boolean[][] b = new boolean[9][9];
			for(int i=0;i<9;i++){
				int[] c = new int[10];
				for(int j=0;j<9;j++)c[a[i][j]]++;
				for(int j=0;j<9;j++)if(c[a[i][j]]>=2)b[i][j]=true;
			}
			for(int j=0;j<9;j++){
				int[] c = new int[10];
				for(int i=0;i<9;i++)c[a[i][j]]++;
				for(int i=0;i<9;i++)if(c[a[i][j]]>=2)b[i][j]=true;
			}
			for(int si=0;si<9;si+=3){
				for(int sj=0;sj<9;sj+=3){
					int[] c = new int[10];
					for(int i=0;i<3;i++){
						for(int j=0;j<3;j++){
							c[a[si+i][sj+j]]++;
						}
					}
					for(int i=0;i<3;i++){
						for(int j=0;j<3;j++){
							if(c[a[si+i][sj+j]]>=2)b[si+i][sj+j]=true;
						}
					}
				}
			}
			for(int i=0;i<9;i++){
				for(int j=0;j<9;j++){
					System.out.print((b[i][j]?"*":" ")+a[i][j]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
// AOJ 0525: Osenbei
// 2017.11.12 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#define TM 0
#if TM
#include <time.h>
#endif

char b[2][10][20010], *a[10];
char buf[20010];

int main()
{
	int r, c, i, j, k, s, lim, cnt, ans;
	char *p;
#if TM
	clock_t start, finish;
	start = clock();
#endif
	while (fgets(p=buf, 20, stdin) && *p != '0') {
		r = atoi(p); while (*p >= '0') p++;
		c = atoi(p);
		for (j = 0; j < r; j++) {
			fgets(p=buf, 20010, stdin);
			for (i = 0; i < c; i++, p+=2) {
				b[1][j][i] =    *p  & 1;
				b[0][j][i] = (1+*p) & 1;
			}
		}

		ans = 0;
		for (lim = 1 << r, k = 0; k < lim; k++) {
			for (j = 0; j < r; j++) a[j] = b[(k>>j)&1][j];
			cnt = 0; for (i = 0; i < c; i++) {
				s = 0; for (j = 0; j < r; j++) s += a[j][i];
				cnt += ((s<<1) < r) ? r-s : s;
			}
			if (cnt > ans) ans = cnt;
		}
		printf("%d\n", ans);
	}
#if TM
	finish = clock();
	printf("time %lf\n", (double)(finish-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
template<typename T>
map< T, int > prime_factor(T n) {
  map< T, int > res;
  for(T i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
ll mod_pow(ll x, ll n, ll mod){
    if(n == 0)return 1;
    ll res = mod_pow(x*x%mod,n/2,mod);
    if(n&1) res = res * x % mod;
    return res;
}
int main(){ 
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<ll> num(1000001,0);
  for (int i = 0; i < n; i++) {
    auto t = prime_factor<ll>(a[i]);
    for (auto e : t) num[e.first] = max(num[e.first], (ll)e.second);
  }

  ll LCM = 1LL;
  for (int i = 2; i <= 1000000; i++) {
    (LCM *= mod_pow(i,num[i], mod)) %= mod;
  }
  ll res = 0;
  for (int i = 0; i < n; i++) (res += LCM * mod_pow(a[i], mod-2, mod) ) %= mod;
  cout << res << endl;
  return 0;
} 

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

int main(){
  vector<vector<int>> A(10, vector<int>(10,0));

  int x, y, s; char c;
  while(cin >> x >> c >> y >> c >> s){
    vector<int> dx, dy;
    if(s == 1){
      dx = {0, 1, 0, -1, 0};
      dy = {0, 0, 1, 0, -1};
    } else if (s == 2){
      dx = {0, 0, 0, 1, 1, 1, -1, -1, -1};
      dy = {0, 1, -1, 0, 1, -1, 0, 1, -1};
    } else {
      dx = {0, 0, 0, 0, 0, 1, 1, 1, -1, -1, -1, 2, -2};
      dy = {0, 1, -1, 2, -2, 0, 1, -1, 0, 1, -1, 0, 0};
    }

    for(int i=0; i<dx.size(); i++){
      int cx = x+dx[i], cy = y+dy[i];
      if(0 <= cx && cx < 10 && 0 <= cy && cy < 10){
        A[cx][cy]++;
      }
    }
  }

  int white = 0, darkest = 0;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      darkest = max(darkest, A[i][j]);
      if(A[i][j] == 0) white++;
    }
  }

  cout << white << endl;
  cout << darkest << endl;
}
  
  


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
string S;
  cin >>S;
  int N = S.size();
  int ans = 753;
  vec k(N);
  for(int i=0;i<N;i++) k[i] = S[i]-48;
  for(int i=0;i<N-2;i++){
	int kai = k[i]*100 + k[i+1] * 10 + k[i+2];
    ans = min(ans,abs(kai-753));
  }
  cout << ans <<endl;
  
}

Measured memory_bytes: 256
n = int(input())
TP = [[0, 0, 0]]
for _ in range(n):
    TP.append(list(map(int, input().split())))
for i in range(1, n + 1):
    td = TP[i][0] - TP[i-1][0]
    pd = abs(TP[i][1] - TP[i-1][1]) + abs(TP[i][2] - TP[i-1][2])
    if td >= pd and td % 2 == pd % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 27312
import sys
import numpy as np
MOD = 1000000007


def main():
    bits = input()
    ans = 1
    pow3 = 1
    for i, b in enumerate(reversed(bits)):
        if b == '1':
            ans = ((ans * 2 % MOD) + pow3) % MOD
        pow3 = (pow3 * 3) % MOD
    print(ans)


main()


Measured memory_bytes: 21628
#include <iostream>
#include <string>

using namespace std;

int main(){
    string O, E;
    cin >> O >> E;

    int o = O.length(), e = E.length();

    if (o - e == 0){
        for (int i = 0; i < e; i++){
            cout << O[i] << E[i];
        }
        cout << endl;
    }else{
        for (int i = 0; i < e; i++){
            cout << O[i] << E[i];
        }
        cout << O[o - 1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N=int(input())
ABC=[]
for i in range(N):
	ABC+=[[int(i) for i in input().split()]]
DP=[[0,0,0] for i in range(N+1)]
for i in range(N):
	for j in range(3):
		DP[i][j]=ABC[i][j]+max(DP[i-1][(j+1)%3],DP[i-1][(j+2)%3])
print(max(DP[N-1]))



Measured memory_bytes: 76504
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const long long INF = 1LL<<60;
const int MAX = 16;
int N;
vector<long long> A;

vector<long long> calc(const vector<long long> &a, int offset = 0) {
    stack<pair<int,int>> st;
    vector<long long> res(N+1, 0);
    res[1] = offset;
    for (int i = 1; i < N; ++i) {
        long long s = a[N-i-1], t = a[N-i];
        long long need = 0;
        while (s > t) ++need, t *= 4;

        if (need) {
            long long add = 0;
            while (!st.empty() && need) {
                auto gake = st.top(); st.pop();
                if (gake.second >= need) {
                    add += need * (i - gake.first) * 2;
                    gake.second -= need;
                    need = 0;
                    if (gake.second) st.push({gake.first, gake.second});
                }
                else {
                    add += gake.second * (i - gake.first) * 2;
                    need -= gake.second;
                }
            }
            if (need) add += need * i * 2;
            res[i+1] = res[i] + add + offset;
        }
        else {
            long long new_gake = 0;
            while (s * 4 <= t) ++new_gake, s *= 4;
            st.push({i, new_gake});
            res[i+1] = res[i] + offset;
        }
    }
    return res;
}

long long solve() {
    const auto &right = calc(A);
    reverse(A.begin(), A.end());
    const auto &left = calc(A, 1);

    //COUT(right); COUT(left);
    
    long long res = INF;
    for (int i = 0; i <= N; ++i) chmin(res, left[i] + right[N-i]);
    return res;
}

int main() {
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << solve() << endl;
}


Measured memory_bytes: 6528
import java.util.*;

/**
 * B
 */
public class Main {
    
    void run() {

        int min = 1000010;
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();

        int[][] G = new int[n][n];
        int[] discover = new int[n];

        int u, k, v, c;

        for(int i=0; i<n; i++) {
            u = sc.nextInt();
            k = sc.nextInt();
            for(int j=0; j<k; j++) {
                v = sc.nextInt();
                c = sc.nextInt();
                G[u][v] = c;
            }
        }

        sc.close();

        for(int i=0; i<n; i++) {
            discover[i] = min;
        }

        discover[0] = 0;

        for(int m=0; m<n; m++) {

            boolean dis = false;

            for(int i=0; i<n; i++) {
                for(int j=0; j<n; j++) {

                    if(discover[i]<min && G[i][j] > 0) {
                        if(discover[j]>discover[i]+G[i][j]) {
                            discover[j] = discover[i]+G[i][j];
                            dis = true;
                        }
                    }

                }
            }

            if(!dis) {
                break;
            }

        }

        for(int i=0; i<n; i++) {
            System.out.println(i+" "+discover[i]);
        }

    /*
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                System.out.print(G[i][j]+" ");
            }
            System.out.println();
        }
        
        */
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 40492
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<U> aa = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			BigInteger a = in.nextBigInteger();
			BigInteger b = in.nextBigInteger();

			U u = new U();
			u.d = a.add(b);
			u.a = a;
			u.b = b;

			aa.add(u);
		}
		Collections.sort(aa, (u1, u2) -> -u1.d.compareTo(u2.d));
		BigInteger r = BigInteger.ZERO;
		for (int i = 0; i < aa.size(); i = i + 2) {
			r = r.add(aa.get(i).a);
		}
		for (int i = 1; i < aa.size(); i = i + 2) {
			r = r.subtract(aa.get(i).b);
		}

		in.close();
		System.out.println(r);
	}

}

class U {
	BigInteger d;
	BigInteger a;
	BigInteger b;
}

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

int main() {

    string o, e;
    cin >> o >> e;    

    string ans = "";
    int idx = 0;
    rep(i, o.size()*2){
        if(i % 2 == 0){
            ans += o[idx];
        }
        else{
            if(idx >= e.size()){
                break;
            }
            ans += e[idx++];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256