akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<unordered_map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll d[N];
unordered_map<ll,vector<int> > p;
ll cnt[N],sum[N],n,r[N];
vector<pair<int,int> > w;
bool comp(int a,int b){
	return d[a]>d[b];
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)scanf("%lld",&d[i]),r[i]=i,p[d[i]].push_back(i),cnt[i]=1;
	sort(r+1,r+n+1,comp);
	for (int i=1;i<n;i++){
		ll x=r[i],s=d[x]-(n-2*cnt[x]),y;
		if (p[s].empty()||s>=d[x]){
			cout<<-1<<endl;
			return 0;
		}
		y=p[s].back();
		w.push_back(make_pair(x,y));
		cnt[y]+=cnt[x];
		sum[y]+=sum[x]+cnt[x];
	}
	if (sum[r[n]]!=d[r[n]]){
		cout<<-1<<endl;
		return 0;
	}
	for (int i=0;i<n-1;i++)printf("%d %d\n",w[i].first,w[i].second);
}

Measured memory_bytes: 14624
#include <stdio.h>
int main() {
	int n,i,x;
	
	scanf("%d",&n);

	for(i=1;i<=n;i++)
	{
		x=i;
		if(x%3==0) {printf(" %d",i);}
		else if(x%10==3) {printf(" %d",i);}
		else { 
			while(x!=0)
		 	 {
		  	x/=10;
		  	if(x%10==3) {printf(" %d",i);break;}
		 	 }
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2700
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	float N;
	cin >> N;

	if ((int)N%2 == 0) {
		cout << 0.5 << endl;
	} else {
		cout << ((N+1)/2)/N << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n,k; cin >> n >> k;
  vector<int> pow2(n+1);
  pow2[0] = 1;
  rep(i,n) pow2[i+1] = pow2[i] * 2;

  if(pow2[n] <= k) {
    cout << -1 << "\n";
  }
  else if(k == 0) {
    rep(i,pow2[n]) {
      cout << i << " ";
      cout << i << " ";      
    }
    cout << "\n";
  }
  else if(n == 1) {
    cout << -1 << "\n";
  }
  else {
    rep(i,pow2[n]) {
      if(i == k) continue;
      cout << i << " ";
    }
    cout << 0 << " ";
    cout << k << " ";    
    rep(i,pow2[n] - 1) {
      if(pow2[n] - i - 1== k) continue;
      cout << pow2[n] - i - 1 << " ";
    }
    cout << k << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if ((i + 1) % 2 == 1) {
      cout << (char)S[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;
}

int main(int argv, char *argc[]){
  unsigned char a;
  long long int N, M, K;
  long long int X[100000];
  long long int i, j;
  long long int location_coma[10000] = {0};
  long long int cnt = 0;
  scanf("%lld", &N);
  scanf("%lld", &K);
  for (i = 1; i <= N; i += 2) {
    cnt++;
    /* for (j = i; j <= N; j++) { */
    /*   if (abs(i-j) != 1 && i != j) { */
    /*     cnt++; */
    /*   } */
    /* } */

  }
  if (cnt >= K) {
    puts("YES");
  }else {
    puts("NO");
  }
  /* for (i = 0; i < M; i++) { */
  /*   scanf("%lld", &X[i]); */
  /* } */
 /*  qsort(X, M, sizeof(long long int), compare_int); */
 /*  long long int sum = 0; */
 /*  for (i = 0; i < M; i++) { */
 /*    printf("%lld, ", X[i]); */
 /*    //sum += L[i]; */
 /*  } */

 /*  location_coma[0] = X[0]; */
 /*  location_coma[N-1] = X[M-1]; */
 /*  printf("%lld, lld\n", location_coma[0], location_coma[N-1]); */
 /* for (i = 0; i < N; i++) { */
 /*    float pos = X[M-1] - X[0] / N; */
 /*      for (i = 0; i < M; i++) { */
        

 /*      } */
 /*  } */


  
  /* //qsort(L, N, sizeof(long long int), compare_int); */
  /* long long int sum = 0; */
  /* for (i = 0; i < N-1; i++) { */
  /*   //printf("%lld, ", L[i]); */
  /*   sum += L[i]; */
  /* } */
  /* if (sum > L[N-1]) { */
  /*   puts("Yes"); */
  /* } else { */
  /*   puts("No"); */
  /* } */
  return 0;
  /* scanf("%d", &X); */
  /* printf("%f\n", (float)T/X); */
  //a = 122;
  //printf("%lx\n",a);
  
}


Measured memory_bytes: 128
#include <stdio.h>
#define ALPHA 26

int main(void){
        char s[1200];
        int cou[ALPHA]={0},i=0;
        scanf("%[^\r]",s);
        while(s[i]){
                if(s[i]>='a' && s[i]<='z')
                        cou[s[i]-'a']++;
                else if(s[i]>='A'&&s[i]<='Z')
                        cou[s[i]-'A']++;
                i++;
        }
        for(i=0;i<ALPHA;i++)
                printf("%c : %d\n",'a'+i,cou[i]);
        return 0;
}

Measured memory_bytes: 532
#include <bits/stdc++.h>
#define int long long int
#define len length
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define pii pair <int, int>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
//Constants
const int MOD = 998244353; // 1e9 + 7
const int N = 1000001; // 1e6 +1

/* -------------------------------Solution Sarted--------------------------------------*/

int memo[100005][2], n;
vi a;

bool solve(int k, bool turn){
	int i = 0;

	if(memo[k][turn] != -1)
		return memo[k][turn];

	if(!turn){
		bool res = 0;
		for(; i < n; ++i){
			res = 0;
			if(k - a[i] >= 0){
				res = res or (solve(k - a[i], !turn));
			}else{
				break;
			}
			if(res == 0)
				
		return (memo[k][turn] = 0);
		}
		
		return (memo[k][turn] = 1);
	}else{
		bool res = 1;
		for(; i < n; ++i){
			res = 1;
			if(k - a[i] >= 0){
				res = res and (solve(k - a[i], !turn));
			}else{
				break;
			}
			if(res == 1)
				return (memo[k][turn] = 1);
		}
		return (memo[k][turn] = 0);

	}

}

int32_t main()
{
	faster;
// #ifndef ONLINE_JUDGE
// 	freopen("ip.txt", "r", stdin);
// 	freopen("op.txt", "w", stdout);
// #endif
	// int t; cin >> t; while(t--)
	{
		int k;
		cin >> n >> k;
		a.resize(n);
		scnarr(a, n);
		memset(memo, -1, sizeof(memo));
		sort(all(a));
		(solve(k, 0) ? puts("Second") : puts("First"));
	}
	return 0;
}


//Author : Ankit Raj
//InSearchForMeanings
//Problem Link :


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const long double PI=3.141592653589793238462643383279;
const int N=500005,M=998244353;
int n,k,i,p;
int main()
{
	scanf("%d %d",&n,&k);
	if(n<2*k-1)
	{
		puts("-1");
		return 0;
	}
	for(i=k,p=k+2*n;i<k+(n+1)/2;++i,p+=2)
		printf("%d %d %d\n",i,i+n+n/2,p);
	for(i=k+(n+1)/2,p=k+2*n+1;i<k+n;++i,p+=2)
		printf("%d %d %d\n",i,i+n-n/2-(n&1),p);	
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	map<char, int> m;
	for(int i = 1; i <= n; i++)
	{
		char ch;
		cin  >> ch;
		m[ch]++;
	}
	if(m.size() == 3)
		cout << "Three";
	else
		cout << "Four";;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll n;
vll a = {7, 5, 3};
ll dfs(ll s){
	if(s > n) return 0;
	ll tmp = s;
	vll check(3);
	while(tmp){
		ll c = tmp % 10;
		REP(i, 3){
			if(c == a[i]) check[i] = 1;
		}
		tmp /= 10;
	}
	ll res = check[0] * check[1] * check[2];
	REP(i, 3) res += dfs(10 * s + a[i]);
	return res;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
}

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

	ll ans = dfs(7) + dfs(5) + dfs(3);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
  ll X;
  cin >> X;
  ll a,b;
  
  for(ll i=0; i<1000; i++){
    for(ll j=0; j<1000; j++){
      if(i*i*i*i*i - j*j*j*j*j == X){
        a = i;
        b = j;
        break;
      }
      if(i*i*i*i*i + j*j*j*j*j == X){
        a = i;
        b = 0 - j;
        break;
      }
    }
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 3640
ss, t = input(), input()
lt = len(t)
lss = len(ss)
lst = []
for i in range(lss - 1, lt - 2, -1):
    tss = ss[i - lt + 1:i + 1]
    tb = True
    for a, b in zip(tss, t):
        if a == '?':
            continue
        elif a != b:
            tb = False
            break
    if tb:
        lst.append(ss[:i - lt + 1] + t + ss[i + 1:])
if len(lst):
    lst.sort()
    print(lst[0].replace('?', 'a'))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		c = new long[51][51];
		long[] v = new long[n];
		Map<Long, Integer> map = new HashMap<Long, Integer>();
		for (int i = 0; i < n; i++) v[i] = -sc.nextLong();
		Arrays.sort(v);
		for (int i = 0; i < n; i++) {
			long val = -v[i];
			if(!map.containsKey(val)) {
				map.put(val,1);
			}else {
				map.replace(val, map.get(val)+1);
			}
			v[i] = val;
		}
		long count = 0;
		int k = 1;
		long sum = 0;
		while(k <= a) {
			sum += v[k-1];
			k++;
		}
		while((k-1)*v[k]>sum&&k<=b) {
			sum += v[k];
			k++;
		}
		Fraction frac = new Fraction(sum, k-1);
		for (int i = a; i <= b; i++) {
			k = 1;
			sum = 0;
			Map<Long, Integer> map2 = new HashMap<Long, Integer>();
			while(k <= a) {
				sum += v[k-1];
				if(!map2.containsKey(v[k-1])) {
					map2.put(v[k-1],1);
				}else {
					map2.replace(v[k-1], map2.get(v[k-1])+1);
				}
				k++;
			}
			while(k<=i&&(k-1)*v[k-1]>=sum) {
				sum += v[k-1];
				if(!map2.containsKey(v[k-1])) {
					map2.put(v[k-1],1);
				}else {
					map2.replace(v[k-1], map2.get(v[k-1])+1);
				}
				k++;
			}
			if(k-1!=i) {
				continue;
			}
			Fraction frac2 = new Fraction(sum, k-1);
			if(frac2.equals(frac)) {
				count += comb(map.get(v[i-1]),map2.get(v[i-1]));
			}
		}
		System.out.println(frac.get_value());
		System.out.println(count);
		sc.close();
	}
	public static long[][] c;

	public static long comb(long a, long b) {
		if(c[(int)a][(int)b] == 0) {
			long res;
			if(b == 0) res = 1;
			else if(a == b) res = 1;
			else res = comb(a-1,b)+comb(a-1,b-1);
			c[(int)a][(int)b] = res;
			return res;
		}else {
			return c[(int)a][(int)b];
		}
	}
	public static class Fraction{
		long bunbo, bunshi;
		public Fraction(long u, long d){
			this.bunbo = d/gcd(u,d);
			this.bunshi = u/gcd(u,d);
		}
		public boolean equals(Fraction f) {
			return f.bunbo==bunbo&&f.bunshi==bunshi;
		}
		public double get_value() {
			return (double)this.bunshi/(double)this.bunbo;
		}
		public long gcd(long a, long b) {
			if(a < b) {
				long c = a;
				a = b;
				b = c;
			}
			while(b != 0) {
				long c = a;
				a = b;
				b = c%b;
			}
			return a;
		}
	}
}

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

int main(){
    int n,l,i,s;
    cin >> n;
    int date[n];
    for ( i = 0; i < n; i++ ){
        cin >> l;
        date[i] = l;
    }
    for ( i = 0; i < n/2; i++ ){
        s = date[i];
        date[i] = date[n-1-i];
        date[n-1-i] = s;
    }
    for ( i = 0; i < n-1; i++ ){
        cout << date[i] << " ";    
    }
    cout << date[n-1] << '\n';
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

typedef  long long ll;

ll p[55], nlen[55];

ll solve(ll n, ll x)
{
    if(x <= n) return 0;
    if(x >= nlen[n] - 1) return p[n];
    if(x == nlen[n] / 2 + 1) return (p[n] / 2 + 1);
    else if(x < nlen[n] / 2 + 1)
        return solve(n - 1, x - 1);
    else
        return p[n] / 2 + 1 + solve(n - 1, x - nlen[n] / 2 - 1);
}

int main()
{
    for(int i = 0; i <= 50; ++i)
    {
        p[i] = pow(2, i + 1) - 1;
        nlen[i] = pow(2, i - 1) * 8 - 3;
    }
    ll n, x;
    cin>>n>>x;
    cout<<solve(n, x)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

int main(){
	int n, k;
	cin >> n >> k;
	vector <pair <int, int>> d(k);
	for(int i = 0; i < k; i++)
		cin >> d[i].x >> d[i].y;
	sort(all(d));
	
	int mod = 998244353;
	
	vector <ll> sum(k);
	vector <ll> ans(n);
	ans[0] = 1;
	for(int i = 1; i < n; i++){
		for(int j = 0; j < k; j++){
			if(i - d[j].x >= 0)
				sum[j] += ans[i - d[j].x];
			if(i - d[j].y - 1 >= 0)
				sum[j] -= ans[i - d[j].y - 1];
		}
		
		for(int j = 0; j < k; j++)
			ans[i] = (ans[i] + sum[j]) % mod;
	}
	
	//for(int i = 0; i < n; i++)
		//cout << ans[i] << ' ';
	//cout << endl;
	cout << ans[n-1] << endl;
	return 0;
}


Measured memory_bytes: 4820
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_KEY2020
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int D = 1000000000;
            if (s[2] == D)
            {
                for (int i = 0; i < s[1]; i++)
                {
                    Write(s[2]);
                    Write(" ");
                }
                for (int i = 0; i < s[0] - s[1]; i++)
                {
                    if (i != s[0] - s[1]-1)
                    {
                        Write(1);
                        Write(" ");
                    }
                    else
                    {
                        WriteLine(1);
                    }
                }
            }else{
                for (int i = 0; i < s[1]; i++)
                {
                    Write(s[2]);
                    Write(" ");
                }
                for (int i = 0; i < s[0] - s[1]; i++)
                {
                    if (i != s[0] - s[1]-1)
                    {
                        Write(s[2] + 1);
                        Write(" ");
                    }
                    else
                    {
                        WriteLine(s[2] + 1);
                    }
                }                
            }
        }
    }
}



Measured memory_bytes: 16464
use std::cmp;

const INF: i64 = 1e17 as i64;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let a: Vec<i64> = sc.read_vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 0..(n - 1) {
        let v = sc.read::<usize>() - 1;
        let u = sc.read::<usize>() - 1;
        graph[v].push(u);
        graph[u].push(v);
    }

    let mut dp1 = vec![vec![]; n];
    let mut dp2 = vec![vec![]; n];
    dfs(0, 0, &graph, &a, &mut dp1, &mut dp2);

    for i in 1..(n + 1) {
        if dp1[0][i] < INF {
            println!("{}", i - 1);
            return;
        }
        if dp2[0][i] < 0 {
            println!("{}", i - 1);
            return;
        }
    }
}

fn dfs(
    v: usize,
    p: usize,
    graph: &Vec<Vec<usize>>,
    a: &Vec<i64>,
    dp1: &mut Vec<Vec<i64>>,
    dp2: &mut Vec<Vec<i64>>,
) {
    dp1[v].push(INF);
    dp1[v].push(if a[v] > 0 { a[v] } else { INF });
    dp2[v].push(INF);
    dp2[v].push(a[v]);
    for &next in graph[v].iter() {
        if next == p { continue; }
        dfs(next, v, graph, a, dp1, dp2);

        dp1[v] = connect(&dp1[v], &dp1[next], &dp2[next], true);
        dp2[v] = connect(&dp2[v], &dp1[next], &dp2[next], false);
    }
}

fn connect(dp: &Vec<i64>, child1: &Vec<i64>, child2: &Vec<i64>, power_only: bool) -> Vec<i64> {
    let mut ans = vec![INF; dp.len() + child1.len() - 1];
    assert_eq!(dp[0], INF);
    assert_eq!(child1[0], INF);
    assert_eq!(child2[0], INF);
    for groups in 1..dp.len() {
        if dp[groups] == INF { continue; }
        for child_groups in 1..child1.len() {
            let total_groups = groups + child_groups;

            if child1[child_groups] != INF {
                ch_min(&mut ans[total_groups - 1], dp[groups] + child1[child_groups]);
            }
            if child2[child_groups] != INF && !power_only {
                ch_min(&mut ans[total_groups - 1], dp[groups] + child2[child_groups]);
            }
            if child1[child_groups] != INF || child2[child_groups] < 0 {
                ch_min(&mut ans[total_groups], dp[groups]);
            }
        }
    }
    ans
}

fn ch_min<T: PartialOrd>(a: &mut T, b: T) {
    if *a > b {
        *a = b;
    }
}

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

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


Measured memory_bytes: 211836
N=int(input())
A=[int(input()) for i in range(N)]

A.sort()

B=A[:N//2]
C=A[N//2:]


#print(B)
#print(C)

if len(B)>=2:
    B=[B[-1]]+B[:-2]+[B[-2]]

if len(C)>=2:
    C=[C[1]]+C[2:]+[C[0]]

if N%2==0:
    B,C=C,B



X=[]
b=0
c=0
while b<len(B) or c<len(C):
    if c<len(C):
        X.append(C[c])
    if b<len(B):
        X.append(B[b])
    b+=1
    c+=1

#print(X)
ANS=0
for i in range(1,N):
    ANS+=abs(X[i]-X[i-1])

#print(ANS)




B=A[:N//2+1]
C=A[N//2+1:]

#print(B)
#print(C)

if len(B)>=2:
    B=[B[-1]]+B[:-2]+[B[-2]]

if len(C)>=2:
    C=[C[1]]+C[2:]+[C[0]]

X=[]
b=0
c=0
#print(B)
#print(C)
while b<len(B) or c<len(C):
    if b<len(B):
        X.append(B[b])

    if c<len(C):
        X.append(C[c])

    b+=1
    c+=1

#print(X)
ANS2=0
for i in range(1,N):
    ANS2+=abs(X[i]-X[i-1])

#print(ANS2)

print(max(ANS,ANS2))





Measured memory_bytes: 62552
#include<bits/stdc++.h>
using namespace std;
int n,m,c;
vector<vector<int>> a;
void dfs(int i,int j){
  c+=a[i][j];
  if(i==1&&j==n-1){
    m=max(m,c);
  }else{
    if(a[i+1][j]!=0){
      dfs(i+1,j);
    }
    if(a[i][j+1]!=0){
      dfs(i,j+1);
    }
  }
  c-=a[i][j];
}
int main(){
  cin>>n;
  a.resize(3);
  for(int i=0;i<3;i++){
    a[i].resize(n+1);
    for(int j=0;j<=n;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  m=0;
  c=0;
  dfs(0,0);
  cout<<m;
}
  

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

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

   if (A > C)
   {
      if (B > C)
         cout << "No" << endl;
      else
         cout << "Yes" << endl;
   }
   else
   {
      if (B < C)
         cout << "No" << endl;
      else
         cout << "Yes" << endl;
   }
}


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

int S[500000];
int L[250001];
int R[250001];
int c=0;

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, k;
    for(i=0; i<n1; i++) L[i] = A[left + i];
    for(i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = numeric_limits<int>::max();
    i=j=0;
    for(k=left; k<right; k++) {
        c++;
        if(L[i]<=R[j]) A[k] = L[i++];
        else A[k] = R[j++];
    }
}

void mergeSort(int A[], int left, int right)
{
    if(left+1<right) {
        int mid = (left+right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cin>>S[i];
    mergeSort(S, 0, n);
    cout<<S[0];
    for(int i=1; i<n; i++) cout<<' '<<S[i];
    cout<<'\n'<<c<<'\n';
    return 0;
}

Measured memory_bytes: 5108
#include <cstdio>
#include <vector>
#define N 50

using namespace std;
typedef long long ll;

int main() {
	ll K; scanf("%lld", &K);
	ll eqStartCt = K/N;
	ll delayMoveCt = (K%N); // also the number at the end of the delay moves
	// after the delay moves, we want it to be eqStartCt+(n-1).
	vector<ll> ans(N, eqStartCt+(N-1)-delayMoveCt);
	for (int i = 0; i < delayMoveCt; ++i) {
		ans[i] += N+1;
	}
	// after the delay moves, we have all numbers as delayMoveCt.
	printf("%d\n", N);
	for (int i = 0; i < N; ++i) {
		printf("%s%lld", (i == 0 ? "" : " "), ans[i]);
	}
	printf("\n");
	return 0;
}

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

const int INF = 100000; 

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

    cout << "ABC" << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n, q = map(int, input().split())
d = deque()
e,a = 0,[]
for _ in range(n):
    m, t = input().split()
    d.append((m, int(t)))
while d:
    m, t = d.popleft()
    if t - q > 0:
        e += q
        d.append((m, t - q))
    else:
        e += t
        a += [f'{m} {e}']
print('\n'.join(a))


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

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



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'

/*
	For Debugging we have define TRACE.
*/

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif  

const int N = 1e7 + 5;
int a[N];
int reach [10000001];


void solve(){

	int a,b,c;
	int k;
	cin>>a>>b>>c>>k;

	while(a >= b){
		b = b*2;
		k--;
	}
	while(b >= c){
		c = c*2;
		k--;
	}
	if(k < 0) cout<<"No";
	else cout<<"Yes";
	
}
 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    IOS;
    solve();


}








Measured memory_bytes: 3628
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! {
        ns: chars
    }
    let ans = if (ns[0] == ns[1] && ns[1] == ns[2]) || (ns[1] == ns[2] && ns[2] == ns[3]) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
int a[5];
cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
sort(a,a+5);
for(int i=4;i>0;i--) cout << a[i] << ' ';
cout << a[0] << endl;
return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 1e18;
    ll cnt = 0;
    rep(i,n-1){
        cnt += a[i];
        chmin(ans, abs(sum - cnt*2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
	long long int m;
	long long int s=0;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		if(i%5==0||i%3==0)
		continue;
		else
		s+=i;
	}
	cout<<s;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	int N,Y;
	cin>>N>>Y;
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			int k = N-i-j;
			if(k<0)continue;
			if(i*10000+j*5000+k*1000==Y){
				cout<<i<<' '<<j<<' '<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int D,T,S;
    cin>>D>>T>>S;
    if(D<=T*S){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n; cin >> n;
    vector<ll> b(n+1);
    b[0] = INF;
    b[n] = INF;
    for (int i=1;i<n;++i) cin >> b[i];

    ll ans = 0;
    for (int i=0;i<n;++i) {
        ans += min(b[i], b[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(ll int i=0;i<n;++i)
#define foru(i,n) for(int  i=1;i<=n;++i)
#define forz(i,a,b) for(int i=a;i<=b;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builtin_popcount(n)
#define remin(a,b) (a) = min((a),(b))
#define mod 1000000007
#define sp setprecision(7) 
#define cgog cout<<"Case #"<<T-t<<": "
#define ft first
#define st second
 
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
ll powN(ll a,ll p,ll md)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,md);
	z=(z*z)%md;
	if(p%2) z=(z*a)%md;
	return z;
}
 
ll modinverse(ll n, ll p)
{
	return(powN(n,p-2));
}
 
ll ncr(ll n, ll r)
{
	ll p=mod;
	if (r==0) 
      return 1; 
  
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%p; 
  
    return ((fac[n]* (modinverse(fac[r], p) % p))%p * modinverse(fac[n-r], p) % p) % p;
}
/*//////////////////////////////////////////////DSU///////////////////////////////////////////
*/
ll int parent[200005];
 
void make_set(int v) {
    parent[v] = v;
}
 
ll int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
 
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) 
    {
    	parent[b]=a;
    }
}
///////////////////////////////////////////////DSU///////////////////////////////////////////////
 
///////////////////////////////////////////////// sieve //////////////////////////////////

int r[3000005];
bool prime[3000005];
 
void sieve(ll int n)
{
	foru(i,n)
		prime[i]=true;
	prime[1]=prime[0]=false;
	r[1]=1;
	for(ll int i=2;i<=n;++i)
	{
		if(prime[i])
		{
			r[i]=i;
			for(ll int j=i;i*j<=n;++j)
			{
				if(prime[j*i])
					r[j*i]=i;
				prime[j*i]=false;
			}
		}
	}
}
////////////////////////////////////////////////sieve///////////////////////////////////////////////
 
 
///////////////////////////////////////////////////////BFS/////////////////////////////////////////
 
void bfs(int s, vector<int> adj[],int n, int p[],int d[])
{
	p[s]=s;
	queue<int> q;
	q.push(s);
	d[s]=0;
	vector<bool> visited(n+1,false);
	visited[s]=true;
	while(!q.empty())
	{
		int u = q.front();
		q.pop();
		for(int i=0;i<sz(adj[u]);++i)
		{
			int v = adj[u][i];
			if(!visited[v])
			{
				q.push(v);
				visited[v]=true;
				p[v]=u;
				d[v]=d[u]+1;
			}
		}
	}
 
}
////////////////////////////////////////////////////BFS///////////////////////////////////////////



int main()
{
	int x;
	cin>>x;
	foru(i,12000)
	{
		int p = (360*i)%x;
		if(p==0)
		{
			cout<<(360*i)/x<<endl;
			return(0);
		}
	}
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long


using namespace std;
using ARRAY = vector<pair<int,int>>;
using field = vector<ARRAY>;

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

void dfs(field &m, size_t h, size_t w, bool isBlack){
	for(size_t i = 0; i < 4; i++){
		int nexth = h+dx[i];
		int nextw = w+dy[i];
		auto &tmp = m[nexth][nextw];
		if(tmp == make_pair(-1,-1))continue;
		if(isBlack){
			if(tmp.first == 0 && tmp.second != 2){
				tmp = {1, tmp.second};
				dfs(m, nexth, nextw, true);
			}
		}
		else{
			if(tmp.second== 0 && tmp.first != 2){
				tmp = {tmp.first, 1};
				dfs(m, nexth, nextw, false);
			}
		}
	}
}

signed main(){
	while(true){
		int h,w; cin >> w >> h;
		if(h == 0)break;
		field m(h+2, ARRAY(w+2));
		for(int i = 0; i < h+2; i++){
			m[i][0] = {-1,-1};
			m[i][w+1] = {-1,-1};
		}
		for(int i = 0; i < w+2; i++){
			m[0][i] = {-1,-1};
			m[h+1][i] = {-1,-1};
		}
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				char t; cin >> t;
				switch(t){
					case 'B':
						m[i][j] = {2,0};
						break;
					case 'W':
						m[i][j] = {0,2};
						break;
				}
			}
		}
		for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++){
			if(m[i][j] == make_pair(2,0)){
				dfs(m,i,j,true);
			}
			else if(m[i][j] == make_pair(0,2)){
				dfs(m,i,j,false);
			}
		}
		pair<int, int> ans{0,0};
		for(auto a : m)for(auto e : a){
			if(e.second == 0 && e.first == 1)ans.first++;
			else if(e.first == 0 && e.second == 1)ans.second++;
		}
		cout << ans.first << " " << ans.second << endl;
	}


	return 0;
}




Measured memory_bytes: 3172
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var a = Read();
            var b = Read();
            if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) Println("YES");
            else Println("NO");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
from itertools import product
N=int(input())
S=input()
S=[int(s) for s in S]
ans=0

for q in product(range(10),repeat=3):
  i=0
  for s in S:
    if s == q[i]:
      if i==2:
        ans+=1
        break
      else:
        i+=1
print(ans)

Measured memory_bytes: 41708
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;
 
    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 5628
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    ll A; cin >> A;
    double B; cin >> B;

    int iB = 100 * B + 0.5;

    ll ans = A * iB;
    ans /= 100;

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


Measured memory_bytes: 3716
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vector<ll> h(N+10);
  for(int  i = 1;i <= N; i++){
    cin >> h[i];
  }
  vector<ll> sum(N+10, INFL);
  sum[0] = INFL;
  sum[1] = 0;
  for(int i = 2; i <= N; i++){
    sum[i] = min( abs(h[i]-h[i-1])+sum[i-1] , abs(h[i]-h[i-2])+sum[i-2]);
  }
  //rep(i,N+1){
    cout << sum[N] << endl;
  //}


}


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

int main(){
    int num[4][3][10]{};
    int n, b, f, r, v;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        num[b - 1][f - 1][r - 1] += v;
    }

    for(int i = 0; i < 4; ++i){
        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 10; ++k){
                printf(" %d", num[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3) printf("####################\n");
    }
    return 0;
}

Measured memory_bytes: 1040
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: usize = sc.read();
    let b: usize = sc.read();
    let c: usize = sc.read();
    let k: usize = sc.read();

    let mut ans = false;
    for i in 0..=k {
        for j in 0..=(k - i) {
            if b * 2_usize.pow(j as u32) > a * 2_usize.pow(i as u32)
                && c * 2_usize.pow(k as u32 - i as u32 - j as u32) > b * 2_usize.pow(j as u32)
            {
                ans = true;
            }
        }
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

int main()
{
   long long int x,y,z;
   long long int count=0;
   int arr[1000];
   cin>>x;
   for(int i=0;i<x;i++){
    cin>>arr[i];
   }
   for(int i=0;i<x;i++){
        int ck=i;
        for(int j=i;j<x;j++){
            if(arr[j]<arr[ck]){
                ck=j;//count++;

            }

        }
         swap(arr[i],arr[ck]);
         if(i!=ck){
           count++;
         }
   }
   for(int i=0,ck=1;i<x;i++,ck++){
    cout<<arr[i];
    if(ck!=x){
        cout<<" ";
    }
   }
   cout<<endl;
    cout<<count<<endl;;
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(){

int a,b,c,d,e,k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
   
 if(e-a>k){
  cout << ":(" << endl;
 }
 else{
  cout << "Yay!" << endl;
 }

}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s
main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, m] <- map strToInteger . words <$> getLine
    -- スペース区切り整数の入力
    xaxis <- map strToInteger . words <$> getLine
    yaxis <- map strToInteger . words <$> getLine
    let x = sum $ zipWith (\x k ->flip mod moD $ (2*k - n - 1) * x) xaxis [1..]
        y = sum $ zipWith (\y k ->flip mod moD $ (2*k - m - 1) * y) yaxis [1..]
        moD = 10^9 + 7
    -- 出力
    putStrLn . show $ (x * y) `mod` moD


Measured memory_bytes: 145660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
const int N=300000,p2=1<<19;
int A[N],B[N];
int bit[N+1];
bool seg[p2*2];
set<int> bs,twos;
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i=(i&(i-1));
	}
	return s;
}
void add(int i,int x){
	while(i<=N){
		bit[i]+=x;
		i+=(i&-i);
	}
}
void update(int x){
	seg[x+p2]=(A[x]+B[x]>=1);
	x+=p2;
	while(true){
		x/=2;
		if(x==0) break;
		seg[x]=seg[x*2]&&seg[x*2+1];
	}
}
bool q(int a,int b,int l,int r,int k){
	if(b<=l||r<=a) return 1;
	if(a<=l&&r<=b) return seg[k];
	return q(a,b,l,(l+r)/2,k*2)&&q(a,b,(l+r)/2,r,k*2+1);
}
int main(){
	int Q;
	string As,Bs;
	cin>>Q>>As>>Bs;
	rep(i,As.size()) A[N-1-i]=As[As.size()-1-i]-'0';
	rep(i,Bs.size()) B[N-1-i]=Bs[Bs.size()-1-i]-'0';
	rep(i,N){
		if(B[i]) bs.insert(i);
		if(A[i]+B[i]==2) twos.insert(i);
		add(i+1,A[i]);
		update(i);
	}
	rep(tt,Q){
		char c;
		cin>>c;
		if(c=='Q'){
			int b=*bs.begin();
			int ans=sum(b)+N-1-b;
			if(!twos.empty()){
				int t=*twos.begin();
				if(q(b,t+1,0,p2,1)) ans++;
			}
			cout<<ans<<endl;
		}else if(c=='A'){
			int x;
			cin>>x;
			x=N-1-x;
			int d=1;
			if(A[x]==1) d=-1;
			A[x]+=d;
			add(x+1,d);
			twos.erase(x);
			if(A[x]+B[x]==2) twos.insert(x);
			update(x);
		}else{
			int x;
			cin>>x;
			x=N-1-x;
			int d=1;
			if(B[x]==1) d=-1;
			B[x]+=d;
			bs.erase(x);
			if(B[x]) bs.insert(x);
			twos.erase(x);
			if(A[x]+B[x]==2) twos.insert(x);
			update(x);
		}
	}
}

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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }

    int choco = X;
    for(int i=0; i<N; i++){
        int d = 1;
        while(d<=D){
            choco++;
            d += vec[i];
        }
    }

    cout << choco << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
start = 1 if N % 2 == 0 else 0
if N % 2 == 0:
    if counter[start] != 2:
        print(0)
        exit()
else:
    if counter[start] != 1:
        print(0)
        exit()

for i in range(start+2, N, 2):
    if counter[i] != 2:
        print(0)
        exit()
print(2 ** (N // 2) % (10**9 + 7))


Measured memory_bytes: 14820
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
    int N, T;
    cin >> N >> T;
    
    vector<int> c;
    int a, b;
    
    for(int i = 0; i < N ; ++i){
        cin >> a >> b;
        if(b <=T){
            c.push_back(a);
        }
    }
    
    
    if(c.size() == 0){
        cout << "TLE" << endl;
    } else {
        sort(c.begin(), c.end());
        cout << c[0] << endl;
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
G = [[]for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)
    G[b].append(a)

from collections import deque
def bfs():
    heap = deque()
    road = [0]*n

    heap.append((0, -1))
    used = set()
    while heap:
        cur, prev = heap.popleft()
        if cur in used:
            continue
        used.add(cur)
        road[cur] = prev+1
        for to in G[cur]:
            if to not in used and to != prev:
                heap.append((to, cur))
    return road

ans = bfs()
print("Yes")
for i in range(1, n):
    print(ans[i])



Measured memory_bytes: 105076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		long[] a = new long[N + 1];
		long[] b = new long[M + 1];
		for (int i = 1; i <= N; i++) {
			a[i] = a[i - 1] + sc.nextInt();
		}
		for (int i = 1; i <= M; i++) {
			b[i] = b[i - 1] + sc.nextInt();
		}
      
		int max = 0;
		for (int i = 0, j = M; i <= N; i++) {
			while (j >= 0 && K < a[i] + b[j]) j--;
			if (j < 0) break;
			max = Math.max(max, i + j);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 63200
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
x_t = []
for i in range(m - 1):
    x_t.append(x[i + 1] - x[i])
x_t = sorted(x_t)
ans = 0
for i in range(m - n):
    ans += x_t[i]
print(ans)

Measured memory_bytes: 13968