akhauriyash/Code-Regression huggingface dataset:
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

const INF: i32 = 1001001001;
const LNF: i64 = 1001001001001001001;
const MOD: u32 = 1000000007;

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
  }
  let mc = ModCalc::new(500000);
  let all = (mc.facc[m] * mc.finv[m - n]).pow(2);
  let mut acc = ModInt(0);
  for i in 1..=n {
    let a = mc.facc[m] * mc.finv[m - i];
    let b = (mc.facc[m - i] * mc.finv[m - n]).pow(2);
    if i % 2 == 1 {
      acc = acc + mc.com(n, i) * a * b;
    } else {
      acc = acc - mc.com(n, i) * a * b;
    }
  }
  let ans = all - acc;
  println!("{}", ans);
}

trait Monoid {
  fn one() -> Self;
}

trait Powerable: std::ops::Mul<Output = Self> + Monoid + Copy {
  fn pow(self, mut n: u64) -> Self {
    let mut r = Self::one();
    let mut x = self;
    while n > 0 { if n & 1 == 1 { r = r * x; } x = x * x; n >>= 1; }
    r
  }
}

#[derive(Clone, Copy)]
struct ModInt(u32);

impl Monoid for ModInt {
  fn one() -> Self { Self(1) }
}

impl Powerable for ModInt {}

impl std::fmt::Display for ModInt {
  fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
    write!(f, "{}", self.0)
  }
}

impl std::ops::Add for ModInt {
  type Output = Self;
  fn add(self, rhs: Self) -> Self {
    let x = self.0 + rhs.0;
    Self(if x >= MOD { x - MOD } else { x })
  }
}

impl std::ops::Sub for ModInt {
  type Output = Self;
  fn sub(self, rhs: Self) -> Self {
    let x = self.0 + MOD - rhs.0;
    Self(if x >= MOD { x - MOD } else { x })
  }
}

impl std::ops::Mul for ModInt {
  type Output = Self;
  fn mul(self, rhs: Self) -> Self {
    let x = self.0 as u64 * rhs.0 as u64;
    Self(if x >= MOD as u64 { x % MOD as u64 } else { x } as u32)
  }
}

impl std::ops::Div for ModInt {
  type Output = Self;
  fn div(self, rhs: Self) -> Self {
    self * rhs.inv()
  }
}

impl ModInt {
  fn new(x: u32) -> Self {
    Self(x % MOD)
  }
  fn inv(self) -> Self {
    self.pow((MOD - 2) as u64)
  }
}

struct ModCalc {
  facc: Vec<ModInt>,
  finv: Vec<ModInt>,
}

impl ModCalc {
  fn new(n: usize) -> Self {
    let mut facc = vec![ModInt(0); n + 1];
    let mut finv = vec![ModInt(0); n + 1];
    facc[0] = ModInt::one();
    for i in 0..n {
      facc[i + 1] = facc[i] * ModInt((i + 1) as u32);
    }
    finv[n] = ModInt::one() / facc[n];
    for i in (0..n).rev() {
      finv[i] = finv[i + 1] * ModInt((i + 1) as u32);
    }
    ModCalc { facc, finv }
  }
  fn com(&self, a: usize, b: usize) -> ModInt {
    if b > a {
      return ModInt(0);
    }
    self.facc[a] * self.finv[a - b] * self.finv[b]
  }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int n,q; cin >> n >> q;
  vector<int> line(n); cin >> line;
  vector<int> from_list(n);
  {
    map<int,int> mp;
    for(int i = 0; i < n; ++i){
      if(mp.count(line[i]) == 0){
	from_list[i] = -1;
      } else {
	from_list[i] = mp[line[i]];
      }
      mp[line[i]] = i;
    }
  }
  vector<P<int,int>> queries(q); cin >> queries;
  for(auto&e:queries){e.first--;e.second--;}
  static vector<P<int,int>> r_base[500000];
  for(int i = 0; i < q; ++i)
    r_base[queries[i].second].emplace_back(queries[i].first,i);
  vector<int> vec;
  vector<int> ans(q);
  for(int i = 0; i < n; ++i){
    // debug(i);
    auto it = lower_bound(vec.begin(),vec.end(),from_list[i]);
    if(it == vec.end() || *it != from_list[i])vec.insert(it,from_list[i]);
    for(auto e:r_base[i]){
      ans[e.second] = i-e.first+1-(vec.end()-lower_bound(vec.begin(),vec.end(),e.first));
      // debug(e.first);
      // debug(e.second);
      // debug(distance(st.lower_bound(e.first),st.end()));
    }
  }
  for(auto e:ans)cout << e << endl;
}




Measured memory_bytes: 42844
#include<stdio.h>

int binarySearch(int);

int A[100000],a;

int main(){
    int i,j,x,b;
    int result = 0;
    
    scanf("%d",&a);
    for(i = 0;i < a;i++){
        scanf("%d",&A[i]);
    }
    
    scanf("%d",&b);
    
    for(i = 0;i < b;i++){
        scanf("%d",&x);
        if(binarySearch(x))result++;
    }
    
    printf("%d\n",result);
    
    return 0;
    
}


int binarySearch(int key){
    int right = a;
    int left = 0;
    int mid;
    
    while(left < right){
        
        mid = (left + right)/2;
        
        if(A[mid] == key) return 1;
        
        else if(key > A[mid])left = mid + 1;
        
        else if(key < A[mid])right = mid;
    }
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define Cint boost::multiprecision::cpp_int
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    Cint ans = 1;
    Cint A[101010];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < N; i++) {
        ans *= A[i];
        if (ans > 1000000000000000000ll) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

    solve();
    return 0;
}


Measured memory_bytes: 6872
//  __      __       .__           .____________                   __________        __ ________   __                 
// /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
// \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//  \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//   \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//        \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define PI 3.14159265358979323846
#define endl '\n'

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll sum = (n * n + n) / 2;
    ll t3 = n / 3, t5 = n / 5, t15 = n / 15;
    sum -= 3 * (t3 * t3 + t3) / 2;
    sum -= 5 * (t5 * t5 + t5) / 2;
    sum += 15 * (t15 * t15 + t15) / 2;
    cout << sum << endl;
}

int main()
{
	int q = 1;
	//scanf("%d", &q);
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;
#define MX 1000000000

long long GCD(long long a, long long b)
{
    if (b > a)
        swap(a, b);
    if (a % b == 0)
        return b;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a * b << "\n";
}


Measured memory_bytes: 3640
import itertools
 
n = int(input())
l =[]
 
for _ in range(n):
  a = int(input())
  m = []
  for _ in range(a):
    xn, yn = map(int, input().split())
    m.append([xn-1, yn])
  l.append(m)
 
for i in itertools.product([1, 0], repeat=n):
  i = list(i)
  flg = 0
  for j in range(n):
    for x, y in l[j]:
      if i[j] == 1 and i[x] != y:
        flg += 1
        break
  if flg == 0:
    break
    
print(sum(i))

Measured memory_bytes: 3064
import numpy as np
from functools import reduce
n,m,c=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.empty((n,m),dtype=int)
for i in range(n):
  b[i,:]=np.array(list(map(int,input().split())))
d=np.dot(b,a)
ans=[1 if i>-c else 0 for i in d]
answer=reduce(lambda a,b:a+b,ans)
print(answer)

Measured memory_bytes: 12444
#include <stdio.h>
#include <limits.h>
 int main() { int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    
    (a!=c && a!=b && b!=c)?
    printf("3"):
    (a==b && a==c)?
    printf("1"):
    printf("2");
    
 return 0; }

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

int main() {
  int n, k;

#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif

  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 505



int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if((b>a&&a+t*v>=b+w*t)||(a>b&&a-t*v<=b-w*t)) cout<<"YES\n";
    else cout<<"NO\n";


    return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> x(m);
    for (int i = 0; i < m; i++) {
        std::cin >> x[i];
    }

    std::sort(x.begin(), x.end());
    std::vector<i64> diff;
    for (int i = 0; i < m - 1; i++) diff.push_back(x[i + 1] - x[i]);
    std::sort(diff.begin(), diff.end());
    i64 ret = 0;
    for (int i = 0; i < m - n; i++) {
        ret += diff[i];
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1784
sort [] = []
sort (x:xs) = sort small ++ [x] ++ sort large
  where
    small = [a | a <- xs, a <= x]
    large = [a | a <- xs, a > x]
main = getLine >>= putStrLn . unwords . (map show) . sort . (map (\n -> read n :: Int)) . words

Measured memory_bytes: 3624
l, r = gets.split.map &:to_i
ans = Float::INFINITY
(l...r).each do |_i|
  i = _i%2019
  (_i+1..r).each do |j|
    m = i*j%2019
    ans = m if m < ans
    if ans==0
      p 0
      exit
    end
  end
end
p ans


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

int main() {
  int N;
  cin >> N;
  
  if ( (N-7) % 10 == 0 )
    cout << "Yes" << endl;
  
  else if ( (N/10 - 7) % 10 == 0 )
    cout << "Yes" << endl;
  
  else if ( (N/100 - 7) % 10 == 0 )
    cout << "Yes" << endl;
  
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

vector<int> linear_sieve(ll n) {
    vector<int> lpd(n + 1, 0);
    vector<int> primes;

    for (ll i = 2; i <= n; ++i) {
        if (lpd[i] == 0) {
            primes.emplace_back(i);
            lpd[i] = i;
        }

        for (ll j = 0; j < primes.size() && primes[j] <= lpd[i] && i * primes[j] <= n; ++j) {
            lpd[i * primes[j]] = primes[j];
        }
    }

    return primes;
}

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll answer = 0;
    ll current = n * 2 * 10;
    while (true) {
        vector<int> primes = linear_sieve(current);

        auto found = lower_bound(primes.begin(), primes.end(), n);
        if (found != primes.end()) {
            answer = *found;
            break;
        }

        current *= 2;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (min(b,d) -max(a,c) <= 0) cout << 0 << endl;
    else cout << min(b,d)-max(a,c) << endl;
    
    
    return 0;    
}

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

int main()
{
  int n,m,k;
  cin >> n >> m >> k;
  int p;
  vector<int> t(n);
  cin >> p;
  for(int i=0;i<n;i++)
    cin >> t[i];
  sort(t.begin(),t.end(),greater<int>());
  int ma;
  ma=p/m;
  for(int i=0;i<n;i++){
    p+=t[i];
    m+=k;
    ma=max(ma,p/m);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int>up(n), mid(n), low(n);
	for (int& i : up) cin >> i;
	for (int& i : mid) cin >> i;
	for (int& i : low) cin >> i;
	sort(up.begin(), up.end());
	sort(low.begin(), low.end());
	long long ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int x = lower_bound(up.begin(), up.end(), mid[i]) - up.begin();
		int y = upper_bound(low.begin(), low.end(), mid[i]) - low.begin();
		y = (n - 1) - y + 1;
		ans += (1LL * x * y);
		//int x = lower_bound(up.begin(), up.end(), up[i]);
	}
	cout << ans;
		return 0;
}



Measured memory_bytes: 4560
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int A = 0;
	int B = 0;
	scanf("%d %d", &A,&B);

	for (int i = 0; i < 1000000000; i++) {
		if ((A - i) == (B - i) ||
			(A - i) == ((B - i)*-1) ||
			((A - i)*-1) == (B - i)) {
			printf("%d", i);
			break;
		}
		if (i == 999999999) {
			printf("IMPOSSIBLE");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int x , a , b ;
    cin >> x >> a >> b;
    if(b <= a){
        cout << "delicious" << endl;
    }else if(b <= x+a){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//IN THE NAME OF ALLAH//

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

    if(s == "SAT")
    {
        cout<<1<<endl;
    }
    else if( s == "SUN" )
    {
        cout<<7<<endl;
    }
    else if( s == "MON" )
    {
        cout<<6<<endl;
    }
    else if( s == "TUE" )
    {
        cout<<5<<endl;
    }
    else if( s == "WED" )
    {
        cout<<4<<endl;
    }
    else if( s == "THU" )
    {
        cout<<3<<endl;
    }
    else
    {
        cout<<2<<endl;
    }
    return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

    map<string,int> m;

    m["SAT"] =1;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["THU"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;

    cout<< m[s] <<endl;

}
*/


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> task;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    task.emplace_back(b,a);
  }
  sort(task.begin(),task.end());
  int sum=0;
  bool can=true;
  for(int i=0;i<n;i++){
    sum+=task[i].second;
    if(sum>task[i].first){
      can=false;
      break;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 2420
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i, n+1)cin >> a[i];
    rep(i, n)cin >> b[i];

    long long ans = 0;
    rep(i, n) {
        if (b[i] <= a[i])ans += b[i];
        else {
            if (b[i] - a[i] <= a[i + 1]) {                
                ans += b[i];
                a[i + 1] -= b[i] - a[i];
            }
            else {
                ans += a[i] + a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


D = z()
C = zz()
S = defaultdict(list)
for i in range(D):
    S[i + 1] = zz()
# やらなくていいコンテストはやらないC=0
never_held = []

arr = list(range(26))
resent_contests = []
C, arr = zip(*sorted(zip(C, arr), reverse=False))
i = 0
for d in range(1, D+1):
    if (len(resent_contests) == 26):
        resent_contests = []
    tmp_arr = list(range(26))
    s, tmp_arr = zip(*sorted(zip(S[d], tmp_arr), reverse=True))
    j = 0
    while (tmp_arr[j]+1 in resent_contests):
        j += 1
    resent_contests.append(tmp_arr[j]+1)
    print(tmp_arr[j]+1)


Measured memory_bytes: 27644
inputStr = input()
numList = inputStr.split(' ')
numList = [int(x) for x in numList]
numList.sort()

outputStr = ''
count = len(numList)
for z in numList:
    outputStr = outputStr + str(z)
    count-=1
    if count>0 :
        outputStr+=' '

print(outputStr)

Measured memory_bytes: 7668
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<String> s = nextCharArray();
      ArrayList<String> list = myconv("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0);
      for(int i = 0; i < s.size(); i++){
        int newV = list.indexOf(s.get(i)) + N;
        newV %= 26;
        s.set(i, list.get(newV));
      }
      myout(myconv(s, 0));
	}
	//Method addition frame start

  
  
	//Method addition frame end
}


Measured memory_bytes: 34896
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<utility>

// union find with count
struct union_find {
  std::vector<int> data, rank;

  explicit union_find(int n): data(n, -1), rank(n,0) {}

  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }

  void unite(int x, int y) {
    x = find(x); y = find(y);
    if(x == y) return;
    if(rank[x] > rank[y]) std::swap(x, y);
    data[y] += data[x];
    data[x] = y;
    if(rank[x] == rank[y]) ++rank[y];
  }

  int count(int x){ return -data[find(x)]; }
};

int main() {
  int N, M; std::cin >> N >> M;
  std::vector<std::vector<int>> G(N);
  union_find uf(N+N);
  for(int i = 0; i < M; ++i) {
    int a, b; std::cin >> a >> b; --a; --b;
    uf.unite(a, b+N);
    uf.unite(a+N, b);
  }
  std::map<int,int> m;
  for(int i = 0; i < N; ++i) ++m[uf.find(i)];
  int64_t p = m[uf.find(0)];
  int64_t ans = (p==N? (int64_t)N*(N-1)/2: p*(N-p)) - M;
  std::cout << ans << std::endl;
  return 0;
}


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

int main() {
	long r, d, x2000;
	cin >> r >> d >> x2000;
	for (int i = 0; i < 10; i++)
	{
		x2000 = r * x2000 - d;
		cout << x2000 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,a,b;cin >> n >> a >> b;
	if(a%2 == b%2){
		cout << abs(a-b)/2 << endl;
		return 0;
	}
	int toa = a-1;
	int tmp1 = toa + (abs(a-b)-1)/2 + 1;
	
	int ton = n-b;
	int tmp2 = ton +(abs(a-b)-1)/2 + 1;
	cout << min(tmp1,tmp2) << endl;


	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  for(j=2; j<=n; j++){
    key=A[j];
    i=j-1;
    while(i>=0 && A[i]>key){
      A[i+1]=A[i];
      i=i-1;
      A[i+1]=key;
    }
     trace(A,n);
  }
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
void solve(){
    ll a,b;
    cin>>a>>b;
    if(a>b){
        swap(a,b);
    }
    if(a==b){
        cout<<a*2-2<<endl;
        return;
    }
    if(a+1==b){
        cout<<a*2-2<<endl;
        return;
    }
    ll c=sqrt(a*b);
    if(c*c==a*b){
        c--;
    }
    if(c*(c+1)>=a*b){
        cout<<c*2-2<<endl;
    }else{
        cout<<c*2-1<<endl;
    }
}
int main(){
    int n;
    cin>>n;
    REP(i,n){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define sum(a) accumulate(begin(a), end(a), 0)


template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i, 1, N + 1) {
        if (1 % 15 == 0) {

        }
        else if (i % 3 == 0) {

        }
        else if (i % 5 == 0) {

        }
        else {
            ans += i;
        }
    }

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

Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc071/tasks/arc081_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;

int N;
int A[N_MAX];

vector<ll> ls;

void solve() {
  sort(A, A + N, greater<int>());
  int i = 0;
  while (i <= N - 2) {
    if (A[i] == A[i + 1]) {
      ls.push_back(A[i]);
      if (ls.size() >= 2) {
        printf("%lld\n", ls[0] * ls[1]);
        return;
      }
      i += 2;
    } else {
      i++;
    }
  }
  puts("0");
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int Main(){
    string S;
    cin >> S;
    if(S <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

int main(){ios::sync_with_stdio(false);Main();return 0;}

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

using namespace std;
int func(int n);
int main() {
	int n, a, b;
	int num, sum=0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		num=func(i);
		if (a <= num && num <= b) {
			sum += i;
		}
	}
	cout << sum << endl;
}

int func(int n) {
	int sum = 0;
	if (n < 10) {
		return n;
	}
	else {
		while (1) {
			sum += n % 10;
			if (n < 10)break;
			n /= 10;
		};
		return sum;
	}

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
MAX = a[-1]
l = [0]*(MAX+1)
for i in range(n):
    l[a[i]] += 1

ans = 0
for i in range(n):
    if l[a[i]] == 1:
        ans += 1
    for g in range(a[i], MAX+1, a[i]):
        l[g] = 10

print(ans)


Measured memory_bytes: 32260
#include <iostream>

 

using namespace std;

 

int main()
{
   int a, b, temp, i;
   for(i=1; i<=3000; i++)
   {
       cin >> a >> b;
 
       if(a==0 && b==0)
           break;
   if(a > b)
   {
       temp=a;
       a = b;
       b = temp;


   }
   
    
 

   cout << a << " " << b << endl;
   }
}


Measured memory_bytes: 3044
import java.util.Scanner;

public class Main {
	static long mod = 1000000007;
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();		
		long ans = 0;

		if (Math.abs(n-m) >= 2) {
			System.out.println(0);
			return;
		}
		
		if (n == m) {
			ans = equal(n, m);
		} else {
			ans = notequal(n, m);
		}
		System.out.println(ans);
	}
	
	public static long equal(int n, int m) {
		long N = kai(n);
		long M = kai(m);
		long ans = (2*N*M)%mod;
		return ans;
	}
	
	public static long notequal(int n, int m) {
		long N = kai(n);
		long M = kai(m);
		long ans = (N*M)%mod;
		return ans;
	}
	
	public static long kai(int x) {
		long a = 1;
		for (int i = 1; i <= x; i++) {
			a = (a*i)%mod;
		}
		return a;
	}
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 998244353

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=3003;
int a[mxn];

void add(ll &a, ll b){
	a%=MOD; b%=MOD; a+=b; a%=MOD;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,s;
	cin >> n >> s;
	for(int i=1; i<=n; i++)cin >> a[i];
	vector<ll>dp(s+1);
	ll ans = 0LL;
	for(int i=1; i<=n; i++){
		vector<ll>now(s+1);
		for(int j=0; j<=s; j++){
			add(now[j],dp[j]);
			if(j>=a[i])add(now[j],dp[j-a[i]]);
		}
		if(a[i]<=s)add(now[a[i]],i);
		add(ans, now[s]);
		dp = now;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<memory.h>
using namespace std;
class xy{
public:
	int x, y;
	void op(){};

};
int main()
{
	xy p;
	p.op();
	int dp[1001][8];
	memset(dp, 0, sizeof(dp));
	int n, i, i2, i3,k;
	char sc[1001];
	cin >> n >> sc;
	for (i = 0; i < n; i++){
		if (sc[i] == 'J')k = 1;
		else if (sc[i] == 'O')k = 2;
		else if (sc[i] == 'I')k = 4;
		for (i2 = 1; i2 < 8; i2++){
			for (i3 = 1; i3 < 8; i3++){
				if ((i2&i3) > 0 && (i2&k) == k&&i != 0){
					dp[i][i2] = (dp[i][i2] + dp[i - 1][i3]) % 10007;

				}
				else if (i==0&&(i2&1)==1&&(i2&k)==k){
					dp[0][i2] = 1;
				}
			}
		}
	}
	int sum = 0;
	for (i = 0; i < 8; i++){
		sum = (sum+dp[n - 1][i])%10007;
	}
	cout << sum <<endl;
}

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

typedef long long ll;

int main(){
    ll a,b,k; cin >> a >> b >> k;
    if(k<=a){
        cout << (a-k) << " " << b << endl; 
    }else if(k<=a+b){
        cout << 0 << " " << (b-(k-a)) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

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

using namespace std;

int main() {

    int n;

    while(cin >> n, n) {

        int num[n], sum, maxSum = -100000;

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

        for(int i = 0; i < n; ++i) {
            sum = 0;
            for(int j = i; j < n; ++j) {
                sum += num[j];
                maxSum = max(maxSum, sum);
            }
        }

        cout << maxSum << endl;

    }

}

Measured memory_bytes: 1172
#include<stdio.h>
int main(){
    int k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    int c;
    c=a/k;
    if(a%k==0){
        printf("OK");
        return 0;
    }

    if(k*(c+1)<=b){
        printf("OK");
        return 0;
    }
    else
    {
        printf("NG");
    }
    
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    char b;
    cin >> b;

    map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['C'] = 'G';
    mp['G'] = 'C';

    cout << mp[b] << '\n';
    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
#include <set>

using namespace std;

int parent[100001];

int find(int u)
{
	if (parent[u] == u) return u;
	return parent[u] = find(parent[u]);
}

void merge(int u, int v)
{
	u = find(u), v = find(v);
	if (u == v) return;

	if (u < v) parent[v] = u;
	else parent[u] = v;
}

int main()
{
	int N, M;

	scanf("%d %d", &N, &M);

	for (int i = 1; i <= N; ++i) parent[i] = i;

	for (int i = 0; i < M; ++i)
	{
		int X, Y, Z;

		scanf("%d %d %d", &X, &Y, &Z);

		merge(X, Y);
	}

	set<int> uniq;

	for (int i = 1; i <= N; ++i) uniq.insert(find(i));

	printf("%d\n", uniq.size());

	return 0;
}

Measured memory_bytes: 5376
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;

namespace 水色コーダーに俺はなった{
    class Inonoa{
        
        static long[] fac = new long[200001];
        static long[] ifac = new long[200001];

        /* ここに書け */
        static void Main(){
            fac[0] = 1;
            ifac[0] = 1;
            for(long i=0;i<200000;i++){
                fac[i+1] = fac[i] * (i+1) % MOD; // n!(mod M)
                ifac[i+1] = ifac[i] * Mpow(i+1, MOD-2) % MOD;
            }


            long[] nmk = ILongs();

            long n = nmk[0];
            long m = nmk[1];
            long k = nmk[2];

            long ans = 0;

            if(m==1){
                WriteLine(k==n-1 ? 1 : 0);
                return;
            }

            for(long i=0;i<=k;i++){
                long combi = Comb(n-1, i);
                long pow = Mpow(m-1, n - 1 - i);
                ans += ((combi * m) % MOD) * pow;
                ans %= MOD;
            }

            WriteLine(ans);
        }

        static long Comb(long a,long b){
            if(a==0 && b==0) return 1;
            if(a<b || a<0) return 0;
            long tmp = ifac[a-b] * ifac[b] % MOD;
            return tmp * fac[a] % MOD;
        }

        static long Mpow(long x,long n){
            long ans = 1;
            while(n != 0){
                if(n%2 == 1) ans = ans * x % MOD;
                x = x*x % MOD; 
                n = n / 2;
            }
            return ans;
        }

        static readonly long MOD = 998244353;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }

        static void print(object txt){
            WriteLine(txt);
        }
    }
}

Measured memory_bytes: 30880
#include <cstdio>
int main() {
	int l, s, r;
	scanf("%d%d", &s, &l);
	r = l+s-1;
	if (l <= 0 && 0 <= r) printf("%d\n", (l+r)*s/2);
	else if (r < 0) printf("%d\n", (l+r-1)*(s-1)/2);
	else if (l > 0) printf("%d\n", (l+r+1)*(s-1)/2);
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int card_count, gate_count;
  scanf("%d %d", &card_count, &gate_count);

  int minimum_number = 0, max_number = 0;
  int final_count = 0;

  for (int i = 0; i < gate_count; i += 1) {
    int count_start_number, count_end_number;
    scanf("%d %d", &count_start_number, &count_end_number);

    if (i == 0) {
      max_number = count_end_number;
    }
    if (count_end_number < max_number) {
      max_number = count_end_number;
    }
    if (count_start_number > minimum_number) {
      minimum_number = count_start_number;
    }
  }

  if (max_number >= minimum_number) {
    final_count = max_number - minimum_number + 1;
  }
  printf("%d\n", final_count);

  return 0;
}


Measured memory_bytes: 128
s = input()
# 0, 2, 4, ..., 2n 番目がeven_position
even_position_nums = s[::2]
len_even = len(even_position_nums)
odd_position_nums = s[1::2]
len_odd = len(odd_position_nums)

# 辞書のほうが計算量的に良い（毎度O(n)かかっている）
# evenを0、oddを1にする
tmp = len_even - even_position_nums.count('1')
tmp1 = len_odd - odd_position_nums.count('0')
first = tmp + tmp1
# evenを1、oddを0にする
tmp = len_even - even_position_nums.count('0')
tmp1 = len_odd - odd_position_nums.count('1')
second = tmp + tmp1
print(min(first, second))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        const double PI = acos(-1);
        int r;
        cin >> r;

        cout << fixed << setprecision(10) << 2.0 * r * PI << endl;

        return 0;
}


Measured memory_bytes: 3764
import fractions
def func(a,m):
    x,n=1,1
    x=(a*x)%m
    while x!=1:
        x=(a*x)%m
        n+=1
    return n

def lcm(a,b):
    return a*b/fractions.gcd(a,b)

while True:
    a1,m1,a2,m2,a3,m3=map(int,raw_input().split())
    if a1==m1==a2==m2==a3==m3==0:break
    x,y,z=func(a1,m1),func(a2,m2),func(a3,m3)
    print reduce(lcm,[x,y,z])

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

int main(){
  int n;
  int dp[1111][1111];
  cin >> n;
  while(n--){
    string str1, str2;
    cin >> str1 >> str2;
    memset(dp,0,sizeof(dp));
    for(int i = 1; i <= str1.size(); i++){
      for(int j = 1; j <= str2.size(); j++){
        if(str1[i-1] == str2[j-1]){
          dp[i][j] = dp[i-1][j-1] + 1;
        }else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
    cout<<dp[str1.size()][str2.size()]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int v[1000090];int re[1000090];
int main() {
  int ans=0;
  int s;cin>>s;v[0]=s;re[s]=1;
  rep(i,1000070){
    v[i]=(v[i-1]%2)?v[i-1]*3+1:v[i-1]/2;
    if(re[v[i]]==1){ ans=i+1;break;}
    re[v[i]]=1;
    cerr<<v[i]<<" ";
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 2304
//Be Name Khoda
//no comment...
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e3 + 2;
const int infint = (int)1e9;
const ll inf = (ll)1e18;
string s;
map<pair<string, string>, ll> M, P;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cin >> s;
	for (int i = 0; i < (1 << n); i++)
	{
		string tmp1, tmp2;
		for (int j = 0; j < n; j++)
			if((i >> j) & 1)
				tmp1 += s[j];
			else
				tmp2 += s[j];
		reverse(tmp2.begin(), tmp2.end());
		M[{tmp1, tmp2}]++;
	}
	for (int i = 0; i < (1 << n); i++)
	{
		string tmp1, tmp2;
		for (int j = 0; j < n; j++)
			if((i >> j) & 1)
				tmp1 += s[j + n];
			else
				tmp2 += s[j + n];
		reverse(tmp2.begin(), tmp2.end());
		P[{tmp2, tmp1}]++;
	}	
	ll ans = 0;
	for (auto u : M)
		ans += u.second * P[u.first];
	cout << ans;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    int n = s.length();
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 0; i < (n / 2) / 2; i++) {
        if (s[i] != s[n / 2 - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = (n + 3) / 2 - 1; i < n; i++) {
        if (s[i] != s[n - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> ca(N+1);
    ll a;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        ca[i+1] = ca[i] + a;
    }
    ll ans = 1e18;
    for ( int i = 1; i < N; i++ ) {
        ll x = abs(ca[i] - (ca[N] - ca[i]));
        if ( ans > x ) ans = x;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

ll v[100003];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  rep(i,n){
    cin >> v[i];
  }
  ll ans = 0;
  rep(i,n){
    ans += v[i] / 2;
    if(v[i] % 2 && v[i+1] > 0){
      v[i+1]--;
      ++ans;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1152
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(N):
	if a[i]>b[i]:
		ans+=b[i]
	elif a[i]<=b[i]<a[i]+a[i+1]:
		ans+=b[i]
		a[i+1]=a[i+1]+a[i]-b[i]
	else:
		ans+=(a[i]+a[i+1])
		a[i+1]=0
print(ans)

Measured memory_bytes: 18476