akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

const int MAX_V = 101010;
//const int64 INF64 = (1LL<<62) - 1;

struct edge {
  int64 to, cost;
};

int n;
std::vector<edge> G[MAX_V];
int64 dis[MAX_V];

void dijkstra(int s){
  std::priority_queue<std::pair<int64, int64>,
                      std::vector<std::pair<int64, int64>>,
                      std::greater<std::pair<int64, int64>>> pq;
  std::fill(dis, dis + n, INF64);
  dis[s] = 0;
  pq.push(std::pair<int64, int64>(0, s));

  while (!pq.empty()){
    std::pair<int64, int64> p = pq.top(); pq.pop();
    int v = p.second;
    if (dis[v] < p.first) continue;
    for (size_t i = 0; i < G[v].size(); ++i){
      edge e = G[v][i];
      if (dis[e.to] > dis[v] + e.cost){
        dis[e.to] = dis[v] + e.cost;
        pq.emplace(std::pair<int64, int64>(dis[e.to], e.to));
      }
    }
  }
}

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

  cin >> n;
  for (int i = 0; i < n; ++i) {
    int u, k; cin >> u >> k;
    for (int j = 0; j < k; ++j) {
      int64 v, c; cin >> v >> c;
      G[u].push_back({v, c});
    }
  }

  dijkstra(0);

  for (int i = 0; i < n; ++i) {
    cout << i << " " << dis[i] << '\n';
    //if (i != n - 1) cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 14312
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  bool a[26] = {};
  string s;
  cin >> s;
  rep(i,s.size()){
      if(a[(char)s[i]-'a']){
          cout << "no" << endl;
          return 0;
      }
      else a[(char)s[i]-'a'] = true;
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ary1 = gets.chomp.split(" ").map(&:to_i)


result = 0
(0..59).each{|elem|
  count = 0
  ary1.each{|elem1|
    count += 1 if elem1[elem] == 1 
  }
  result += count * (n-count) * (2**elem)
  result = result %  (10**9+7)
  }

puts result



Measured memory_bytes: 42396
#include <algorithm>
#include <cstring>
#include <cstdio>

typedef long long LL;

const int MAXN = 2000;
const int MOD = 924844033;

int N, K;
int Fac[MAXN + 5];

int Cnt;
bool Begin[MAXN * 2 + 5];

int Dp[MAXN * 2 + 5][MAXN * 2 + 5][2];

int main() {
	scanf("%d%d", &N, &K);
	Fac[0] = 1;
	for (int i = 1; i <= N; i++)
		Fac[i] = (LL)Fac[i - 1] * i % MOD;
	for (int i = 1; i <= K; i ++) {
		for (int j = i; j <= N; j += K)
			Begin[++Cnt] = (j == i);
		for (int j = i; j <= N; j += K)
			Begin[++Cnt] = (j == i);
	}
	Dp[0][0][0] = 1;
	for (int i = 1; i <= 2 * N; i++) {
		for (int j = 0; j <= i; j++) {
			Dp[i][j][0] = (Dp[i - 1][j][0] + Dp[i - 1][j][1]) % MOD;
			if (!Begin[i] && j)
				Dp[i][j][1] = Dp[i - 1][j - 1][0];
		}
	}
	int Ans = 0;
	for (int i = 0; i <= N; i++) {
		int tmp = (Dp[N * 2][i][0] + Dp[N * 2][i][1]) % MOD;
		if (i & 1)
			tmp = -tmp;
		Ans = ((Ans + (LL)tmp * Fac[N - i] % MOD) % MOD + MOD) % MOD;
	}
	printf("%d", Ans);
}

Measured memory_bytes: 123648
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int main() {
#ifdef LOCAL
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int a, b, c;
    cin >> a >> b >> c;
    int cur = 1;
    while (a * cur <= 1e8) {
        if ((a * cur) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
        cur++;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<i32>();
    let n = v[0] as usize;
    let m = v[1] as usize;
    let c = v[2];

    let b = read_vec::<i32>();
    let a = read_vec2::<i32>(n as u32);

    let mut ans = 0;
    for i in 0..n {
        let mut ans_i = 0;
        for j in 0..m {
            ans_i += a[i][j] * b[j]
        }
        if ans_i + c > 0 {
            ans += 1;
        }
    }

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


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var rDX = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var r = rDX[0];
            var D = rDX[1];
            var x0 = rDX[2];

            int[] x = new int[11];
            x[0] = x0;

            for (int i = 1; i < 11; i++)
            {
                x[i] = r * x[i - 1] - D;
                Console.WriteLine(x[i]);
            }

        }
    }
}


Measured memory_bytes: 11220
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1167
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

#define MAX 1000000
int const MOD = 1e9 + 7;
int main(void)
{
    int N, M;
    while (cin >> N >> M, N || M)
    {
        vector<int> h(N), w(M);
        for (int i = 0; i < N; ++i)
            cin >> h[i];
        for (int i = 0; i < M; ++i)
            cin >> w[i];

        int sh[1510] = {0}, sw[1510] = {0};
        for (int i = 0; i < N; ++i)
        {
            sh[i + 1] = sh[i] + h[i];
        }
        for (int i = 0; i < M; ++i)
        {
            sw[i + 1] = sw[i] + w[i];
        }
        map<ll, int> nh, nw;
        for (int i = 0; i < N + 1; ++i)
        {
            for (int j = 0; j < i; ++j)
            {
                nh[sh[i] - sh[j]]++;
            }
        }
        for (int i = 0; i < M + 1; ++i)
        {
            for (int j = 0; j < i; ++j)
            {
                nw[sw[i] - sw[j]]++;
            }
        }
        ll sum = 0;
        for (auto itr = nh.begin(); itr != nh.end(); ++itr)
        {
            sum += (*itr).second * nw[(*itr).first];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 44788
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    r, g, b, n = makeMultiInteger(input_string[0])
    c = 0
    nr = int(n/r)+1
    ng = int(n/g)+1
    nb = int(n/b)+1
    #print(r, g, b, n, nr, ng, nb)
    # 二分探索？
    """
    for i in range(nr):
        _sum = i*r
        if _sum == n:
            c += 1
            break
        for j in range(ng):
            _sum = j*g+i*r
            if _sum == n:
                c += 1
                break
            for k in range(nb):
                _sum = i*r + j*g + k*b
                #print(_sum)
                if _sum == n:
                    c += 1
                    break
    """
    for i in range(nr):
        _sum = i*r
        if _sum > n:
            break
        for j in range(ng):
            _sum = j*g+i*r
            if _sum > n:
                break
            rg_sum = j*g+i*r
            if (n - rg_sum) % b == 0:
                c += 1
            """
            for k in range(nb):
                _sum = i*r + j*g + k*b
                #print(_sum)
                if _sum == n:
                    c += 1
                    break
            """
    return c


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// in the name if Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
ll n , a[N] , ans = 0;
vector<char> v ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
for(int i = 1 ; i <= n ; i ++)cin >> a[i] ;
for(int i = 2 ; i <= n-1 ; i ++){
    ll x = a[i] ;
    vector<ll> v ;
    v.push_back(a[i-1]) ;
    v.push_back(a[i]) ;
    v.push_back(a[i+1]) ;
    sort(v.begin() , v.end()) ;
    if(v[1] == x)ans ++ ;
}
cout << ans  ;
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>
using namespace std;
typedef pair<int, int> P;

#define _CRT_SECURE_NO_WARNINGS
int N,a[100010];
int ans = 0;
int c[100010] = {};
int main() {
	scanf("%d",&N);
	for (int i = 0; i < N;i++) {
		scanf("%d", &a[i]);
		if (a[i]>N) {
			ans++;
		}
		else {
			c[a[i]]++;
		}
	}
	for (int i = 0; i <= N;i++) {
		if (c[i]<i) {
			ans += c[i];
		}
		else {
			ans += c[i] - i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
n,a,b = gets.split.map(&:to_i)
count_a = []

(1..n).each do |_n|
  x = _n.to_s.chars.map(&:to_i).inject(&:+)
  if  x >= a && x <= b
    count_a << _n
  end
end
print count_a.inject(&:+)


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdint>

using namespace std;

int num_leading_A(const string& s) {
    int n = 0;
    for (auto c : s) {
        if (c == 'A') {
            ++n;
        } else {
            return n;
        }
    }

    return n;
}

bool solve(const string& s) {
    string ss = "AKIHABARA";

    int num_a = 0;
    string subblock = "";
    string remains = s;
    for (auto c : ss) {
        if (c == 'A') {
            if (num_a == 0) {
                // transition from not A block to A block
                if (subblock != remains.substr(0, subblock.size())) {
                    return false;
                }
                remains = remains.substr(subblock.size());
                subblock.clear();
            }
            ++num_a;
        } else {
            if (num_a > 0) {
                // transition from A block to not A block
                auto num_a_at_target = num_leading_A(remains);
                if (num_a_at_target > num_a) {
                    return false;
                }
                remains = remains.substr(num_a_at_target);
                num_a = 0;
            }
            subblock += c;
        }
    }

    // last block
    assert(num_a > 0);
    {
        // all characters of remains should be 'A', and the number of those should be less than or equal to num_a
        if (num_a < remains.size()) {
            return false;
        }

        for (auto c : remains) {
            if (c != 'A') {
                return false;
            }
        }
    }

    return true;
}


int main() {
    string s;
    cin >> s;

    // cout << solve(s) << endl;
    cout << (solve(s) ? "YES" : "NO") << endl;

    return 0;
}

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

int main(){
	int N;
	int flag = 0;
	cin >> N;
	for(int i = 1; i <= 9; i++){
		if( N % i == 0 && N / i <=9 ){
			flag = 1;
			break;
		}
	}
	if( flag==1 )cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(Calc(a,b));
		
	}
	
	public static int Calc(int a,int b) {
		int c = a + b;
		if (c % 2 == 0) {
			return  c/2;
			
		} else {
			return (int)(c/2) + 1;
		}
	}

}


Measured memory_bytes: 22608
"""
Author: guiferviz
Time: 2020-03-27 15:55:42
"""


def check_palin(s):
    i = 0
    j = len(s) - 1
    while i<j:
        if s[i] != s[j]:
            return False
        i += 1
        j -= 1
    return True

def main():
    s = input()
    n = len(s)
    middle = (n - 1) // 2
    res = check_palin(s) and check_palin(s[:middle]) and check_palin(s[middle+1:])
    print("Yes" if res else "No")


if __name__ == "__main__":
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      string S;
      cin>>S;
      if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
          cout<<"Yes"<<endl;}
        else {cout<<"No"<<endl;}
      return 0;
    }

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let mut a = io.readn::<i64>(3);
    a.sort();
    io.writeln(a.iter().take(2).fold(0, |sum, x| sum + x));
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define INF 1000000000000000001LL
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

ll n,k;

bool C(ll v){
	for(int i=0;i<n;i++){
		if(v<=0)return true;
		v-=((v+k-1LL)/k);
	}
	return false;
}

int main(void){
	scanf("%d%d",&n,&k);
	ll l=0,r=INF;
	for(int i=0;i<100;i++){
		ll mid=(l+r)/2LL;
		if(C(mid))l=mid;
		else r=mid;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 3200
import sys
from collections import deque

N, Q = list(map(int, input().split()))
E = {}

# change limit for deep tree (recursion)
sys.setrecursionlimit(int(2e5+10))

for i in range(N-1):
  a,b = list(map(int, input().split()))
  a,b = a-1,b-1 # 1-indexed -> 0-indexed
  if a not in E:
    E[a] = [b]
  else:
    E[a].append(b)
  if b not in E:
    E[b] = [a]
  else:
    E[b].append(a)

P = [0] * N
for i in range(Q):
  a,b= list(map(int, input().split()))
  P[a-1] += b # 1-indexed -> 0-indexed
  
#print(E)
#print(P)

visited = [False for i in range(N)]
d = deque()

d.append(0)
while len(d) > 0:
  parent = d.pop()
  visited[parent] = True
  
  next_point = E[parent]
  
  for child in next_point:
    if visited[child]:
      continue
    P[child] += P[parent]
    d.append(child)
  
print(" ".join(list(map(str,P))))

Measured memory_bytes: 85824
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int p, x;
        cin >> p >> x;
        int r = 0;
        for (int j = 0; j < n; j++) {
            if (j == p-1) {
                r += x;
            }
            else {
                r += t[j];
            }
        }
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int mod = 998244353;
const int N = 3e5+5;
ll fac[N], ifac[N], inv[N];

int main(){
    //ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,a,b,k;
    cin >> n >> a >> b >> k;

    fac[0] = 1; ifac[0] = 1;
    fac[1] = 1; ifac[1] = 1;
    for(ll i = 2; i <= n; i++){
        fac[i] = fac[i-1]*i;
        fac[i] %= mod;
    }

    inv[1] = 1;
    for(ll i = 2; i <= n; i++){
        inv[i] = mod - (mod/i)*inv[mod%i]%mod;
        ifac[i] = ifac[i-1]*inv[i];
        ifac[i] %= mod;
        //cout << ifac[i] << endl;
    }

    ll answer = 0;
    for(ll x = 0; x <= n; x++){
        if(k-a*x < 0) break;
        if((k-a*x)%b) continue;
        ll y = (k-a*x)/b;
        if(y > n) continue;
        ll t = ((fac[n]*ifac[x])%mod*ifac[n-x])%mod;
        ll p = ((fac[n]*ifac[y])%mod*ifac[n-y])%mod;
        answer += t*p%mod;
        answer %= mod;
    }

    cout << answer << endl;
}


Measured memory_bytes: 10664
#include <bits/stdc++.h>  // ver2.3.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define VTiii vector<Tiii>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define PI 3.141592653589793238462
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;} // 最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;} // 最小公倍数lcm
int mypow(int x, int n, int m){ // 累乗x^n(mod m) O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r; // nCr(小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r; // nCr(%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
Vi stpowV(){Vi a(100001);
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
//Vi stpow = stpowV();  // 階乗配列(%MOD)
void press(auto &v){v.erase(unique(ALL(v)),v.end());} // 圧縮
Vi Vsum(Vi &v){Vi S(v.size()+1);rep(i,1,S.size())S[i]+=v[i-1]+S[i-1];return S;} // 累積和
int keta(int k,int i){string s = itos(k);return s[s.size()-i]-'0';} // i桁目の数字



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m,qw,er,ty;
  cin >> n;
  int ct = n/100;
  int amari = n%100;
  
  if(amari <= ct*5) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
mod = int(1e9+7)

sum = 0
row = 0
for ii in range(N-1):
    i = N-2-ii
    row += A[i+1]
    row %= mod
    sum += A[i] * row
    sum %= mod

print(sum)

Measured memory_bytes: 92040
from collections import deque

n = int(input())
g = [None] * n
visited = [0] * n
dist = [-1] * n
queue = deque()

while n:
    l = list(map(int, input().split()))
    connected = [i - 1 for i in l[2:]]
    g[l[0] - 1] = [i - 1 for i in l[2:]]
    n -= 1

queue.append((0, 0))
visited[0] = 1

while queue:
    i, d = queue.popleft()
    dist[i] = d
    for c in g[i]:
        if not visited[c]:
            visited[c] = 1
            queue.append((c, d + 1))

for i, d in enumerate(dist):
    print(i + 1, d)

Measured memory_bytes: 8068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, a[100005], v, u, k, l[2];
vector<int> G[100005];
int dfs(int u, int c){
	a[u] = c;
	int ret = 0;
	for(int nx: G[u]) if(a[nx] != -c){
		if(a[nx] == c) ret = 1;
		else ret |= dfs(nx,-c);
	}
	return ret;
}
int main(){
	scanf("%d%d", &n, &m);
	rep(i,m){
		scanf("%d%d", &v, &u);
		v--; u--;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	rep(i,n) if(a[i] == 0){
		if(G[i].size() == 0) k++;
		else l[dfs(i,1)]++;
	}
	printf("%lld\n", (ll)k*n*2 - (ll)k*k + (ll)(l[0] + l[1])*(l[0]+l[1]) + (ll)l[0]*l[0]);
}

Measured memory_bytes: 9984
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %d]\n", #x, x)

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, l, mn = 101, sm = 0;
	scanf("%d%d", &n, &l);
	for (int i = 1; i <= n; i++) {
		mn = abs(mn) > abs(l + i - 1) ? (l + i - 1) : mn;
		sm += l + i - 1;
	}
	printf("%d\n", sm - mn);
}

Measured memory_bytes: 128
import numpy as np
n=int(input())
A=np.array(list(map(int,input().split())))
B=np.array(list(map(int,input().split())))
C=A-B
C.sort()
husai=0
genkai=0
if sum(C)<0:
    print(-1)
else:
    for i in range(n):
        if C[i]<0:
            husai+=C[i]
        else:
            genkai=i
            break
    if husai==0:
        genkai2=0
    else:
        for j in range(1,n+1):
            husai+=C[-j]
            if husai>=0:
                genkai2=j
                break
    print(genkai+genkai2)


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

void solve(long long H, long long W, long long h, long long w)
{
    cout << (H - h) * (W - w) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long h;
    scanf("%lld", &h);
    long long w;
    scanf("%lld", &w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl;

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

const ll MX = 1e18;//10^18


int main (){
  int N;
  ll ans=1;
  cin>>N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
    if(A[i]==0){
      print("0");
      return 0;
    }
  }
  rep(i,N){
    if(A[i]>MX/ans){
      print("-1");
      return 0;
    }else{
      ans*=A[i];
    }
  }

  print(ans);
  return 0;

}


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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    int n;
    cin>>n;
    n=n%10;
    if(n==3)
      cout<<"bon";
    else if(n==0||n==1||n==6||n==8)
      cout<<"pon";
    else
      cout<<"hon";
    nl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vli vector<li>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pi pair<int,int>
#define FOR(i,s,n) for(auto i=s;i<n;++i)
#define FORN(i,s,n) for(auto i=s;i<=n;++i)
#define FORR(i,s,n) for(auto i=s;i>=n;--i)
#define FORE(i,a) for(auto i : a)
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    ll r;
    cin >> r;
    r = r* r;
    cout << r << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<algorithm>
#include<deque>
#define F first
#define S second
#define pb push_back

using namespace std;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<P> VP;
typedef vector<VP> VVP;

class Pox
{
public:
  int p;
  int ST;
  int cost;
  Pox(int p = 0,int ST = 0,int cost = 0):p(p),ST(ST),cost(cost){}
};

int main()
{
  int N,M,L,K,A,H;
  while(cin >> N >> M >> L >> K >> A >> H,(N || M || L || K || A || H))
    {
      VVP G;
      G.resize(N);
      int mincost[N][M+1];
      bool hospital[N];
      for(int i=0;i<N;i++)
	hospital[i] = false;
      for(int i=0;i<N;i++)
	for(int j=0;j<=M;j++)
	  mincost[i][j] = (1<<28);

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

      for(int i=0;i<K;i++)
	{
	  int X,Y,T;
	  cin >> X >> Y >> T;
	  G[X].push_back(P(Y,T));
	  G[Y].push_back(P(X,T));
	}

      deque<Pox> deq;
      deq.pb(Pox(A,M,0));
      mincost[A][M] = 0;
      int ans = (1<<28);

      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();
	  int p = pox.p;
	  int ST = pox.ST;
	  int cost = pox.cost;

	  if(cost >= ans)
	    continue;	 

	  if(p == H)
	    {
	      ans = min(ans,cost);
	      continue;
	    }

	  for(int i=0;i<G[p].size();i++)
	    {
	      P np = G[p][i];
	      int nST = ST - np.S;
	      
	      if(nST < 0)
		continue;	      
	      
	      if(!hospital[np.F])
		{	
		  if(mincost[np.F][nST] > cost + np.S)
		    {
		      mincost[np.F][nST] = cost + np.S;
		      if(deq.front().cost < cost+np.S)
			deq.push_back(Pox(np.F,nST,cost+np.S));
		      else 
			deq.push_front(Pox(np.F,nST,cost+np.S));
		    }

		}
	      else
		{

		  for(int j=0;j<=M-nST;j++)
		    {
		      assert(nST+j <= M);
		      if(mincost[np.F][nST+j] > cost + np.S + j)
			{
			  mincost[np.F][nST+j] = cost + np.S + j;
			  if(deq.front().cost < cost+np.S+j)
			    deq.pb(Pox(np.F,nST+j,cost+np.S+j));
			  else 
			    deq.push_front(Pox(np.F,nST+j,cost+np.S+j));
			}	  
		    }
		  
		}

	    }

	}
      ans == (1<<28)?cout << "Help!" << endl:cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 1508
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        a: [u64; n],
    }

    let mut sum = vec![0; n + 1];
    for i in (1..=n).rev() {
        let mut j = i + i;
        let mut count = 0;
        while j <= n {
            count ^= sum[j];
            j += i;
        }
        sum[i] = count ^ a[i - 1];
    }

    let mut ans = Vec::new();
    for i in 1..sum.len() {
        if sum[i] == 1 {
            ans.push(i);
        }
    }

    println!("{}", ans.len());
    for i in 0..ans.len() {
        print!("{}{}", ans[i], if i + 1 == ans.len() { "\n" } else { " " });
    }
}


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

import sys
from bisect import bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

W,H=MAP()
P=[INT() for i in range(W)]
Q=[INT() for i in range(H)]

P.sort()
Q.sort()

ans=0
for i in range(W):
    cnt=H+1-bisect_left(Q, P[i])
    ans+=cnt*P[i]
for i in range(H):
    cnt=W+1-bisect_right(P, Q[i])
    ans+=cnt*Q[i]
print(ans)


Measured memory_bytes: 11492
#include <stdio.h>

int gcd(int a, int b) {
	while (a) {
		int t = b%a;
		b = a;
		a = t;
	}
	return b;
}

int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	int g = gcd(a, b);
	long long int lcm = (long long int)a*b;
	lcm /= g;

	printf("%lld\n", lcm);
}


Measured memory_bytes: 128
fun main(args: Array<String>){
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    var xx = Array(n, { listOf(d) }).toList().toMutableList()
    for (i in 0 until n){
        xx[i] = readLine()!!.split(" ").map { it.toInt() }
    }
    for (i in 0 until n){
        for (j in i+1 until n){
            var distance = 0
            for (k in 0 until d){
                val a = xx[i][k] - xx[j][k]
                distance += a * a
            }
            for (k in 0 until 127){
                if (distance == k * k){
                    count++
                    break
                }
            }
        }
    }
    println(count)
}

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

typedef long long ll;

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

	ll n, k;
	cin >> n >> k;
	
	if(k < n) n = n % k;
	cout << min(abs(n - k), n) << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i, j, N, K, a[110], dp[100010];
    scanf("%d%d", &N, &K);
    for (i=1;i<=N;i++) scanf("%d", &a[i]);

    dp[0] = 0;
    for (i=1;i<=K;i++) {
        dp[i] = 0;
        for (j=1;j<=N;j++) if (i-a[j] >= 0) {
            dp[i] |= !dp[i-a[j]];
        }
    }
    if (dp[K] == 1) printf("First\n");
    else printf("Second\n");
    return 0;
}

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

int main(){
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  
  cin >> K;
  
  cout << a[K-1] << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sz = s.size();
    for(int i=0; i<min(n,sz); i++){
        cout<<s[i];
    }
    if(s.size()>n){
        cout<<"...";
    }
}


Measured memory_bytes: 3632
from itertools import product
from collections import deque
import numpy as np
inputs = open(0).readlines()
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:], function=lambda x: int(x == '#'))

from collections import deque
def bfs(root):
    count = 1
    x, y = root
    grid[y, x] = 0
    queue = deque([root])
    while queue:
        x, y = queue.popleft()
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid[y+dy, x+dx]:
                queue.append((x+dx, y+dy))
                grid[y+dy, x+dx] = 0
                count += 1
    return count
    
ans = 'Yes'
for i, j in product(range(h), range(w)):
    if grid[i, j]:
        if bfs((j, i)) == 1:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 18300
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

int main(){

  // read problem
  long long int N, tmp;
  scanf("%lld", &N);
  
  std::vector<std::vector<long long int> > a(N);
  for(long long int i = 0; i < N; i++){
    for(long long int j = 0; j < N; j++){
      scanf("%lld", &tmp);
      a[i].push_back(tmp);
    }
  }

  // calculate group score
  std::vector<long long int> group_tmp(N), group_score;
  long long int n_member, score_tmp;

  for(long long int S = 0; S < (1<<N); S++){
    // make group
    n_member = 0;
    for(long long int i = 0; i < N; i++){
      if((S>>i) & 1){
        group_tmp[n_member] = i;
        n_member++;
      }
    }
    // calculate score
    score_tmp = 0;
    for(long long int i = 0; i < n_member; i++){
      for(long long int j = i+1; j < n_member; j++){
        score_tmp += a[group_tmp[i]][group_tmp[j]];
      }
    }

    group_score.push_back(score_tmp);
  }

  long long int x, y, subS;
  // solve problem
  for(long long int n = 2; n <= N; n++){
    for(long long int S = (1<<n)-1; S < (1<<N); x = S&(-S), y = S+x, S = (((S & ~y) / x) >> 1) | y /*S = next_combination(S)*/){

      // make group
      n_member = 0;
      for(long long int i = 0; i < N; i++){
        if((S>>i) & 1){
          group_tmp[n_member] = i;
          n_member++;
        }
      }

      /*std::cerr << "n_member = " << n_member << std::endl;
      std::cerr << "S: ";
      for(long long int i = 0; i < N; i++){
        tmp = (S>>i)&1;
        std::cerr << tmp << " ";
      }std::cerr << std::endl;*/

      for(long long int i = 0; i < (1<<(n_member-1)); i++){
        // make subgroup
        subS = 0;
        for(long long int j = 0; j < n_member; j++){
          if((i>>j)& 1){
            subS += (1<< group_tmp[j]);
          }
        }

       /* std::cerr << "subS: " << std::endl;
        for(long long int i = 0; i < N; i++){
          tmp = (subS>>i)&1;
          std::cerr << tmp << " ";
        }std::cerr << std::endl;*/
        
        // update group_score[S]
        group_score[S] = std::max(group_score[S], group_score[S-subS] + group_score[subS]);
      }
    }
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << group_score[(1<<N)-1] << std::endl;

  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int N;
  string S;
  cin>>N>>S;

  int cont[300005];
  for(int i=1;i<N;i++){
    if(S[i]=='E')cont[0]++;
  }

  for(int t=1;t<N;t++){
    if(S[t-1]=='W'&&S[t]=='W'){
      cont[t]=cont[t-1]+1;
    }else if(S[t-1]=='E'&&S[t]=='E'){
      cont[t]=cont[t-1]-1;
    }else{
      cont[t]=cont[t-1];
    }
  }

  int min=INF;
  for(int t=0;t<N;t++){
    if(cont[t]<min)min=cont[t];
  }

  cout<<min<<"\n";
  return 0;
}


Measured memory_bytes: 1796
#include<stdio.h>
#include<string.h>

#define M 1000007
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M + 1)); }

int find(char str[]){

  int i;
  long long key;

  key = getKey(str);
  
  for(i = 0; i < M; i++){
    if(H[(h1(key) + i * h2(key)) % M][0] == '\0') return 0;
    if(strcmp(H[(h1(key) + i * h2(key)) % M], str) == 0) return 1;
  }
  return 0;
}

int insert(char str[]){
  
  int i =0;
  long long key;

  key = getKey(str);

  while(1){
    if(i == M) break;
    if(H[(h1(key) + i * h2(key)) % M][0] == '\0'){
      strcpy(H[(h1(key) + i * h2(key)) % M],str);
      return 0;
    }
    else i++;
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    
    scanf("%s %s", com, str);    
    
    if ( com[0] == 'i' ) insert(str);
    else {
      if(find(str)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 14280
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var bList = readLine()!!.split(' ').map(String::toInt).toMutableList()
    for (i in 0 until n) {
        if (bList[i] > i + 1) {
            println(-1)
            return
        }
    }
    val ans = mutableListOf<Int>()
    while (true) {
        val temp = mutableListOf<Int>()
        var max = 0
        var maxi = -1
        bList.forEachIndexed { index, b ->
            if (index + 1 == b) {
                if (max < b) {
                    max = b
                    maxi = index
                }
            }
        }
        ans.add(max)
        bList.forEachIndexed { index, b ->
            if (index != maxi) {
                temp.add(b)
            }
        }
        bList = temp
        if (bList.size == 0) break
    }
    ans.reversed().forEach { println(it) }
}

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

using namespace std;
#define int long long
#define mp make_pair
#define pb push_back


const int inf = 1e18;
const double EPS = 0.00000001;

signed main(){
    int a,b;
    cin >> a >> b;
    cout << (a == b ? "Yes" : "No");
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N;
    std::cin >> N;

    vector<int> V(N);
    REP(i, N) {
        std::cin >> V[i];
    }

    SORT(V);

    double ans = V[0];
    for(int i = 1; i < N; i++) {
        ans = (ans + V[i]) / 2;
    }

    std::cout << setprecision(20) << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  string s1,s2;
  cin>>s1>>s2;

  cout<< ( s1[0]==s2[2] and s1[1]==s2[1] and s1[2]==s2[0] ? "YES" : "NO" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 1e9 + 12;

vector<vector<int>> v,dp;
int n;
vector<char> choices{'a','b','c'};
int memo(int i=n, char last = 'z'){
    if(i==0)
        return 0;
    if(last-'a' < 3 && dp[i][last-'a']!=INF){
        return dp[i][last-'a'];
    }
    int ans = 0;
    for(char c: choices){
        if(last!=c){
            ans = max(ans, memo(i-1,c) + v[i][c-'a']);
        }
    }
    return dp[i][last-'a'] = ans;
}

void solve() {
    cin >> n;
    v.resize(n+1,vector<int>(3));
    dp.assign(n+1, vector<int>(3,INF));
    for(int i=1; i<=n; i++){
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    cout << memo();

}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


Measured memory_bytes: 21828
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long int n,d;
	scanf("%lld",&n);
	long long f=0;
	//long long five = n/5,three = n/3, fif = n/15;
	//long long f = (n*(n+1))/2 - (five*(five+1)/2) - (three*(three+1)/2) + (fif*(fif+1)/2);
	for(int i=1;i<=n;i++) {
		if(i%5!=0 && i%3!=0) {
			f+=i;
		}
	}
	printf("%lld",f);
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll n, d;
  cin >> n >> d;

  ll ans = n / (d * 2 + 1);
  if(n % (2*d+1) != 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdlib.h>
p(int*a,int*b){return*a-*b;}c,V,i,f[999];main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){for(f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;qsort(f,V,4,p);for(i=c=1;i<V;f[i]-f[i++-1]<d?:c++);}exit(0);}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// 処理
void Solve()
{
	string T;
	cin >> T;

	ll ans = 0;
	REP(i, T.size()) {
		if (T[i] == '?') {
			T[i] = 'D'; 
		}
	}

	cout << T << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3724