akhauriyash/Code-Regression huggingface dataset:
//
// Created by sark2 on 14-01-2020.
//

#include "bits/stdc++.h"

using namespace std;
#define pb push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

int main() {
    IOS

    int n; cin>>n;
    string s, t;

    cin>>s>>t;

    string b;

    for(int i = 0; i < n; i++){
        b += string(1, s[i]) + string(1, t[i]);
    }
    cout<<b<<"\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

using lint = long long;
constexpr lint INF = 1LL << 45;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> xs(n);
    for (auto& x : xs) std::cin >> x;

    Graph<> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(u, v);
        graph[v].emplace_back(v, u);
    }

    auto dp = vec(2, vec(n, vec(n, 0LL)));
    auto ndp = std::vector<lint>(n);
    auto esz = vec(n, 0);

    std::function<void(int, int)> dfs =
        [&](int v, int p) {
            std::fill(dp[0][v].begin(), dp[0][v].end(), INF);
            dp[0][v][0] = xs[v];

            if (xs[v] > 0) dp[1][v][0] = 1;

            for (auto e : graph[v]) {
                int u = e.dst;
                if (u == p) continue;

                dfs(u, v);

                std::fill(ndp.begin(), ndp.end(), INF);
                for (int i = 0; i <= esz[v]; ++i) {
                    for (int j = 0; j <= esz[u]; ++j) {
                        // negative merge
                        ndp[i + j] = std::min(ndp[i + j], dp[0][v][i] + dp[0][u][j]);

                        if (dp[1][u][j]) {
                            // cut
                            ndp[i + j + 1] = std::min(ndp[i + j + 1], dp[0][v][i]);
                        }
                    }
                }
                std::swap(dp[0][v], ndp);

                std::fill(ndp.begin(), ndp.end(), 0);
                for (int i = 0; i <= esz[v]; ++i) {
                    if (!dp[1][v][i]) continue;

                    for (int j = 0; j <= esz[u]; ++j) {
                        if (dp[0][u][j] < 0) {
                            // cut
                            while ((int)ndp.size() < i + j + 1) ndp.push_back(0);
                            ndp[i + j + 1] = 1;
                        }

                        if (dp[1][u][j]) {
                            // positive merge
                            while ((int)ndp.size() < i + j) ndp.push_back(0);
                            ndp[i + j] = 1;
                        }
                    }
                }
                std::swap(dp[1][v], ndp);

                esz[v] += esz[u] + 1;
            }
        };

    dfs(0, -1);
    int ans = n;
    for (int i = 0; i < n; ++i) {
        if (dp[0][0][i] < 0 || dp[1][0][i]) {
            ans = std::min(ans, i);
            break;
        }
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 589568
from collections import defaultdict as dc
n, m = [int(i) for i in input().split()]
cq_dic = {}
wa_dic = dc(int)
for _ in range(m):
  p, w = input().split()
  if w == 'AC':
    cq_dic[p] = 1
  elif (not p in cq_dic) and  w == 'WA':
    wa_dic[p] += 1
ans = sum([wa_dic[k] for k in cq_dic])
print(len(cq_dic), ans)

Measured memory_bytes: 30516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll X, t;
    cin >> X >> t;
    ll ans = X-t;
    if (ans<0) ans = 0;
    cout << ans << "\n";
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := scanInt()
	max := 0
	maxvalue := 0
	for i := 0; i < n; i++ {
		a := scanInt()
		b := scanInt()
		if a > max {
			max = a
			maxvalue = b
		}
	}
	fmt.Println(max + maxvalue)
	return
}

var sc = bufio.NewScanner(os.Stdin)

func scanString() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}
func Permute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(nums, &ret)
	return ret
}
func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	var i, j int
	for {
		for i = n - 2; i >= 0; i-- {
			if nums[i] < nums[i+1] {
				break
			}
		}
		if i < 0 {
			return
		}
		for j = n - 1; ; j-- {
			if nums[j] > nums[i] {
				break
			}
		}
		nums[i], nums[j] = nums[j], nums[i]
		for k, l := i+1, n-1; k < l; {
			nums[k], nums[l] = nums[l], nums[k]
			k++
			l--
		}
		*ret = append(*ret, makeCopy(nums))
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}

func pow(n, m int) int {
	ret := 1
	for i := 0; i < m; i++ {
		ret *= n
	}
	return ret
}

func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}
func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func eratosthenes(n int) []int {
	search := make([]bool, n+1)
	ans := []int{}
	for i := 2; i < n+1; i++ {
		search[i] = true
	}
	for i := 2; i*i < n+1; i++ {
		for j := 2; i*j < n+1; j++ {
			search[i*j] = false
		}
	}
	for i := 2; i < n; i++ {
		if search[i] {
			ans = append(ans, i)
		}
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) { return m / gcd(n, m) * n; }

int main(void) {
	int a, b,c;
	cin >> a >> b>>c;
	if (a < b && b < c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  
  cout << (n+1)/2 << endl;
 
  return 0;
}




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

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  b += a;
  if (b >= k) {
    cout << min(a, k) << '\n';
  }
  else {
    k -= b;    
    cout << a - k << '\n';
  }

  return 0;
}

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

#[allow(dead_code)]
pub const M: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [usize; n+1]
    }

    let mut indices = vec![None;n+1];
    let mut l = 0;
    let mut r = 0;
    for i in 0..a.len() {
        if let Some(src) = indices[a[i]] {
            l = src;
            r = i;
            break;
        }
        indices[a[i]] = Some(i);
    }

    let mut comb_n1 = 1i64;
    let mut comb_rest = 1i64;
    for k in 1..n+2 {
        comb_n1 = (comb_n1 * (n+1-(k-1)) as i64) % M * modinv(k as i64, M);
        comb_n1 %= M;
        let mut ret = comb_n1;
        if k >= 2 && l+n-r >= k-1 {
            comb_rest = (comb_rest * (l+n-r-(k-2)) as i64) % M * modinv(k as i64 - 1,M);
            comb_rest %= M;
            ret = (ret - comb_rest) % M;
        } else if k == 1 {
            ret = (ret - 1) % M;
        }
        if ret < 0 {
            ret += M;
        }
        println!("{}", ret);
    }
}

#[doc = " a / b modulo m == a * modinv(b, m) % m"]
#[allow(dead_code)]
fn modinv(mut a: i64, m: i64) -> i64 {
    let mut b = m;
    let mut u = 1;
    let mut v = 0;
    while b != 0 {
        let t = a / b;
        a -= t * b;
        std::mem::swap(&mut a, &mut b);
        u -= t * v;
        std::mem::swap(&mut u, &mut v);
    }
    u %= m;
    if u < 0 {
        u += m
    };
    u
}


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

using namespace std;

typedef long long ll;

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

  int cur_i = 0, cnt_a = 0;
  ll ans = 0;

  while ( cur_i < s.length() ) {
    string t = s.substr(cur_i, 2);
    if (t == "BC") {
      ans += cnt_a;
      cur_i += 2;
    } else if (s[cur_i] == 'A') {
      cnt_a++;
      cur_i++;
    } else {
      cnt_a = 0;
      cur_i++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

const dx = [-1, 0, 1, -1, 1, -1, 0, 1];
const dy = [-1, -1, -1, 0, 0, 1, 1, 1];

void main() {
	auto ip = readln.split.to!(int[]), H = ip[0], W = ip[1];
	char[][] S;
	foreach(_; 0..H) S ~= readln.chomp.dup;
	
	foreach(i; 0..H) {
		foreach(j; 0..W) {
			if(S[i][j] != '#') {
				int count;
				foreach(m; -1..2) {
					if(i+m < 0 || i+m >= H) continue;
					foreach(n; -1..2) {
						if(j+n < 0 || j+n >= W) continue;
						if(S[i+m][j+n] == '#') count++;
					}
				}
				S[i][j] = ('0' + count).to!char;
			}
		}
	}
	foreach(i; 0..H) {
		writeln(S[i]);
	}
}


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

int main() {
	double a, b, c, d, e, f, x, y;
	while(cin >> a >> b >> c >> d >> e >> f) {
		y = (c*d-f*a)/(b*d-e*a);
		x = (c-b*y)/a;

		cout << fixed << setprecision(3) << x << " " << y << endl;
	}

	return 0;
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a - c) <= d || (Math.abs(a - b) <= d && Math.abs(b - c) <= d))
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 21460
import sys

INPUT = lambda: sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)


def main():
    N = INPUT()
    low = str(int(N) // 100)
    high = str(int(N) // 100 + 1)

    for i in range(1, 3):
        if int(N[i]) < int(low): 
            print(low * 3)
            sys.exit()
        if int(N[i]) > int(low): 
            print(high * 3)
            sys.exit()
        if int(N[i]) == int(low) and i == 2: 
            print(low * 3)


if __name__ == '__main__':
    main()

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

#define MAX 100

struct Card
{
    char suit;
    int value;
};

void selection(struct Card A[], int N)
{
    for(int i = 0;i < N;i++) {
        int minj = i;
        for(int j = i;j < N;j++) {
            if(A[j].value < A[minj].value)
                minj = j;
        }
        swap(A[i],A[minj]);
    }
}

void bubble(struct Card C[],int N)
{
    for(int i = 0;i < N;i++)
        for(int j = N-1;j >= i+1;j--)
            if(C[j].value < C[j-1].value)
                swap(C[j],C[j-1]);
}

void print(struct Card A[], int N)
{
    for(int i = 0;i < N;i++) {
        if(i > 0)
            cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[], int N)
{
    for(int i = 0;i < N;i++)
        if(C1[i].suit != C2[i].suit)
            return false;
    return true;
}

int main()
{
    int N;
    Card C1[MAX], C2[MAX];

    cin >> N;
    for(int i = 0;i < N;i++)
        cin >> C1[i].suit >> C1[i].value;

    for(int i = 0;i < N;i++) C2[i] = C1[i];

    bubble(C1,N);
    selection(C2,N);

    print(C1,N);
    cout << "Stable" << endl;
    print(C2,N);
    if(isStable(C1,C2,N))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;

    return 0;
}



Measured memory_bytes: 3104
#include<cstdio>
#define abs(x) ((x>0)?x:(-(x)))
int H, W, D, A;
int Q, L[100000], R[100000];
int px[90000], py[90000];
int d[90000];
int main(){
        scanf("%d %d %d", &H, &W, &D);
        for (int i=0; i<H; i++)
                for (int j=0; j<W; j++){
                        scanf ("%d", &A);
                        px[A]=i, py[A]=j;
                }
        for (int i=D+1; i<=H*W; i++)
                d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
        scanf("%d", &Q);
        for(int i=0; i<Q; i++)
                scanf("%d %d", &L[i], &R[i]);
        for(int i=0; i<Q; i++)
                printf("%d\n", d[R[i]]-d[L[i]]);
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    int n, l;
    bool b, c;
    b = false;
    c = true;
    string tmp1, tmp2;
    vector<string> w;
    cin >> n;
    w.resize(n);
    for (int i=0; i<n; ++i){
        cin >> w[i];
    }
    // 重複チェック
    for (int i=0; i<n-1; ++i){
        tmp1 = w[i];
        for(int j=i+1; j<n; ++j){
            tmp2 = w[j];
            if(w[i] == w[j]){
                cout << "No" << endl;
                b = true;
            }
        }
    }
    if(!b){
        for(int i=0; i<n-1; ++i){
            l = w[i].length();
            tmp1 = w[i];
            tmp2 = w[i+1];
            if(tmp1[l-1] != tmp2[0]){
                c = false;
            }
        }
        if(c){cout << "Yes" << endl;}
        else {cout << "No" << endl;}
    }
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    if (k <= a) {
      System.out.printf("%d %d", a - k, b);
    } else {
      System.out.printf("%d %d", 0, Math.max(0L, b - (k - a)));
    }
  }
}

Measured memory_bytes: 21076
//*Here I go out to sea again
//*The sunshine fills my hair
//*And dreams hang in the air

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    cout<<(n*(n+1)/2)<<"\n";

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf=1e9+7;
int main()
{
	ll n,val,i,j,k,c,s=0,x,y,a,b;
	string ss;
	cin>>x>>y>>a>>b>>c;
	//vector<ll> v;
	vector<pair<ll,ll> >v;
	for(i=0;i<a;i++)
	{
		ll xx;cin>>xx;
		v.push_back(make_pair(xx,1));
	}
	for(i=0;i<b;i++)
	{
		ll xx;cin>>xx;
		v.push_back(make_pair(xx,2));
	}
	for(i=0;i<c;i++)
	{
		ll xx;cin>>xx;
		v.push_back(make_pair(xx,0));
	}
	sort(v.rbegin(),v.rend());
	ll r=0;ll g=0;ll nc=0,zz=0;
	for(i=0;i<v.size();i++)
	{
		if(zz==x+y) break;
		if(v[i].second==1 && r<x)
		{
			s=s+v[i].first;r++;zz++;
		}
		if(v[i].second==2 && g<y)
		{
			s=s+v[i].first;g++;zz++;
		}
		if(v[i].second==0)
		{
			s=s+v[i].first;zz++;
		}
	}
	cout<<s;
}

Measured memory_bytes: 10476
N=int(input())
B=list(map(int,input().split()))
def DP(L):
	if L==[]:
		return 1,[]
	ret=[]
	for i in range(len(L))[::-1]:
		if L[i]==i+1:
			tL=L[:]
			del tL[i]
			f,dp=DP(tL)
			if f==1:
				return 1,[i+1]+dp
			else:
				break
	return -1,[]
f,dp=DP(B)
if f==1:
	for d in dp[::-1]:
		print(d)
else:
	print(-1)

Measured memory_bytes: 3064
N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(N)]

ab.sort(reverse = True)
cd.sort(reverse = True)

cd += [[1000, 1000]]

L = [0] * N
Ans = 0
for i in range(N):
  t = ab[i]
  mi = N
  for j in range(N):
    k = cd[j]
    if t[0] > k[0]:
      break
    if L[j] == 1: continue
    if t[1] > k[1]: continue
    if cd[mi][1] > k[1]:
      mi = j
  if mi != N:
    L[mi] = 1
    Ans += 1
      
print(Ans)    

Measured memory_bytes: 3064
import java.util.Scanner;

// B - YYMM or MMYY
// https://atcoder.jp/contests/abc126/tasks/abc126_b
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        scanner.close();

        boolean isYYMM = isYYMM(S);
        boolean isMMYY = isMMYY(S);
        if (isYYMM && isMMYY) {
            System.out.println("AMBIGUOUS");
        } else if (isYYMM) {
            System.out.println("YYMM");
        } else if (isMMYY) {
            System.out.println("MMYY");
        } else {
            System.out.println("NA");
        }
    }

    private static boolean isYYMM(String s) {
        int month = Integer.parseInt(s.substring(2, 4));
        return month >= 1 && month <= 12;
    }

    private static boolean isMMYY(String s) {
        int month = Integer.parseInt(s.substring(0, 2));
        return month >= 1 && month <= 12;
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
 
typedef vector< vector< int > > Graph;
 
inline void dfs(int idx, const Graph& graph, vector< bool >& used, vector< int >& order){
  if(used[idx]) return;
  used[idx] = true;
  for(int i = 0; i < graph[idx].size(); i++) {
    dfs( graph[idx][i], graph, used, order);
  }
  order.push_back(idx);
}
inline void rdfs(int idx, const Graph& rgraph, vector< int >& cmp, const int& cnt){
  cmp[idx] = cnt;
  for(int i = 0; i < rgraph[idx].size(); i++) {
    if(cmp[rgraph[idx][i]] == -1) rdfs( rgraph[idx][i], rgraph, cmp, cnt);
  }
}
  
size_t StronglyConnectedComponents(const Graph& graph, const Graph& rgraph, vector< int >& cmp){
  size_t cnt = 0;
  cmp.assign( graph.size(), -1);
  static vector< bool > used(graph.size(), false);
  vector< int > order;
  for(int i = 0; i < graph.size(); i++) {
    dfs(i, graph, used, order);
  }
  reverse( order.begin(), order.end());
  for(int i = 0; i < order.size(); i++) {
    if(cmp[order[i]] == -1) rdfs( order[i], rgraph, cmp, cnt), cnt++;
  }
  return cnt;
}
 
typedef pair< int , int > Pi;
 
int main(){
  int n, m;
  cin >> n;
  cin >> m;
  Graph graph(n), rgraph(n);
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    --a, --b;
    graph[a].push_back(b);
    rgraph[b].push_back(a);
  }
  vector< int > cmp;
  int sz = StronglyConnectedComponents( graph, rgraph, cmp);
 
  vector< Pi > ret(n);
  for(int i = 0; i < n; i++){
    ret[i] = make_pair( cmp[i], i);
  }
  sort( ret.begin(), ret.end());
  bool flag = false;
  for(int i = 0; i < n; i++){
    cout << ret[i].second + 1 << endl;
  }
}

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


long bsearch(vector<long> A, vector<long> F, long K){
  long min=0;
  long max=1e12;
  while(min<max){
    long mid = (min+max)/2;
    long count=0;
    for(int i=0; i<A.size(); i++){
      if(A[i]-mid/F[i]>0){
        count+= A[i]-mid/F[i];
      }
    }
    if(count<=K) max=mid;
    else min=mid+1;
  }
  return min;
}

int main(){
  int N;
  long K;
  vector<long> A;
  vector<long> F;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    long a; cin >> a;
    A.push_back(a);
  }
  for(int i=0; i<N; i++){
    long f; cin >> f;
    F.push_back(f);
  }
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<long>());
  long ans = bsearch(A, F, K);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6640
using System;

namespace aizu
{
    public class No0000
    {
        public static void Main()
        {
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    Console.WriteLine("{0}x{1}={2}", i, j, i * j);
                }
            }
        }
    }
}

Measured memory_bytes: 5592
import Data.List
import Control.Monad
import Control.Applicative

data Card = S Int | H Int | C Int | D Int deriving (Show, Eq, Ord)

readCards :: IO [Card]
readCards =
    map rd . lines <$> getContents
    where
    rd :: String -> Card
    rd l =
        case (words l) of
          ["S", n] -> S (read n)
          ["H", n] -> H (read n)
          ["C", n] -> C (read n)
          ["D", n] -> D (read n)
          _ -> undefined

main = do
    _ <- getLine
    cards <- readCards
    let suit = concat [map f [1..13] | f<-[S,H,C,D]]
    mapM_ print (suit \\ cards) 


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	io;
	ll i;
	string s;
	cin>>s;
	ll n=(int)s.length();
	ll c=0;
	ll ans=0;
	for(i=0;i<n;i++)
	{
			ll j=i;
			while(s[j]=='A'&&j!=n)
			{
				j++;
			}
			ll cnt1=j-i+c;
			if(cnt1==0)
			continue;
			ll cnt2=0;
			ll k;
			for(k=j;k+1<n;k+=2)
			{
				if(s[k]=='B'&&s[k+1]=='C')
				{
					cnt2++;
				}
				else break;
			}
			ans+=(cnt1*cnt2);
			if(s[k]=='A')
			{
			i=k-1;
			c=cnt1;
		}
			else
			{
				c=0;
			i=k;
		}
		}
		cout<<ans;
		}	


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	printf("%.6lf\n",(double)(n-n/2)/n);
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

using namespace std;

const int MAX = 3005;

int dp[MAX][MAX];

int main(){

  string s,t;

  cin >> s;
  cin >> t;

  for(int i=1;i<=s.size();i++){
    for(int j=1;j<=t.size();j++){
      if(s[i-1] == t[j-1]){
        dp[i][j] = 1 + dp[i-1][j-1];
      }
      else{
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }


  int x = s.size(), y = t.size();
  string ans;

  while(x > 0 && y > 0){
    if(dp[x-1][y] == dp[x][y]){
      x--;
    }else if(dp[x][y-1] == dp[x][y]){
      y--;
    }else if(dp[x-1][y-1] + 1 == dp[x][y]){
      ans+=s[x-1];
      x--;
      y--;
    }else{
      break;
    }
  }

  reverse(ans.begin(),ans.end());

  cout << ans << endl;
  
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int A, B;
    cin >> A >> B;
    
    int res = 0;
    repr(n,A,B+1) {
        string num = to_string(n);
        if (num[0] == num[4] && num[1] == num[3]) res += 1;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int main ( void ) {
	int a , b;
	scanf  ( "%d%d" , &a , & b);
	for ( int i = 1 ; i <= 3 ; i++ ) {
		if ( a * b * i % 2 == 1 ) {
			puts ( "Yes" );
			return 0;
		}
	}
	puts ( "No" );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 102, INF = 1000000009;

int n;
char a[N];
int k;

int main()
{
    #ifdef SOMETHING
    //freopen("input.txt", "r", stdin);
    #endif // SOMETHIN
    scanf(" %s", a);
    n = strlen(a);
    scanf("%d", &k);
    bool z = true;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] != a[0])
        {
            z = false;
            break;
        }
    }
    if (z)
    {
        printf("%lld\n", (n * 1LL * k) / 2);
        return 0;
    }
    int yans = 0;
    int q = 1;
    for (int i = 1; i < n; ++i)
    {
        if (a[i] != a[i - 1])
        {
            yans += (q / 2);
            q = 1;
        }
        else
            ++q;
    }
    yans += (q / 2);
    if (a[0] != a[n - 1])
    {
        printf("%lld\n", (yans * 1LL * k));
    }
    else
    {
        int q1 = 0;
        for (int i = 0; i < n; ++i)
        {
            if (a[i] != a[0])
            {
                q1 += i;
                break;
            }
        }
        int q2 = 0;
        for (int i = n - 1; i >= 0; --i)
        {
            if (a[i] != a[0])
            {
                q2 += (n - i - 1);
                break;
            }
        }
        if (q1 % 2 == 1 && q2 % 2 == 1)
            printf("%lld\n", (yans * 1LL * k) + (k - 1));
        else
            printf("%lld\n", (yans * 1LL * k));
    }
    return 0;
}


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

#define   ll   unsigned long long int
#define   sz   2000010


ll num[sz];

int main()
{

    ll n,i,j,k,x,p;

    cin>>n;
    p=0;
    ll c=0;


    for(i=1; i<=n; i++)
    {
        cin>>num[i];
        if(num[i]==0)
        {
            p=1;
        }
    }
    if(p==1)
    {
        cout<<0<<endl;
        return 0;
    }
    x=1000000000000000000;
    p=1;

    for(i=n; i>0; i--)
    {
        x=x/num[i];
        p=p*num[i];
        if(x<=0)
        {
            if(i!=0)
            {
                cout<<-1<<endl;
                return 0;
            }
        }

    }

    cout<<p<<endl;

    return 0;
}


Measured memory_bytes: 4404
/*
                        --------------- Shuvo 's code-_______
                        /''''''''''(______O] ----------____  \______/]_
     __...---'"""\_ --''        Metropolitan university     ___________@ -> ->  -> - --  - -- - ---- ->>
 |'''                   ._   _______________=---------"""""""
 |                ..--''|   l L |_l   |
 |          ..--''      .  /-___j '   '
 |    ..--''           /  ,       '   '
 |--''                /           `    \
                      L__'         \    -
                                    -    '-.
                                     '.    /
                                       '-./
*/

///   ------------ Bismillah hirrahman nirrahim ----------   ///

#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define sc(n) scanf("%I64d", &n);
#define pr(n) printf("%I64d\n", n);
#define prr(n, m) printf("%I64d %I64d\n", n, m);
#define prrr(n, m, p) printf("%I64d %I64d %I64d\n", n, m, p);
#define lp(i,s,n) for(long long  i = s; i<n; i++)
#define pl(n) for(long long i=n-1; i>=0; i--)
#define  ars(arr,s,e) sort(arr+s,arr+n);
#define pb push_back
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)

long long int mx = 1e18;
long long int mn = -1e18;
using namespace std;
ll a[1000010];
ll lft[1000010];
ll rgt[1000010];

vector < ll > v;
set < ll > st[100010];

ll gcd(ll a,ll b){
    ll tmp;
    while(b){
        tmp=b;
        b=a%tmp;
        a=tmp;
    }
    return a;
}


int main()
{
    FastRead;
    ll p,q,r,s,t,i, j,ii, x, jj, n, ans, sum, cnt = 0, st,tc = 0, len ;
    string str1, str2, str;

    cin >> str1 >> str2;

    len = str1.size();

    for(i=0; i<len; i++)
    {
        str.clear();
        for(j=i; j<len; j++)
        {
            str += str1[j];
        }

        for(j=0; j<i; j++)
        {
            str += str1[j];
        }

        if(str == str2)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


}




Measured memory_bytes: 6400
object Main extends App {
  val c = Array(1,2,3).map{i => readLine.split(" ").map{_.toInt}}
  
  var check = true
  
  check &&= (0 until 3).map{j => c(0)(j) - c(1)(j)}.forall{_ == c(0)(0) - c(1)(0)}
  check &&= (0 until 3).map{j => c(1)(j) - c(2)(j)}.forall{_ == c(1)(0) - c(2)(0)}
  check &&= (0 until 3).map{i => c(i)(0) - c(i)(1)}.forall{_ == c(0)(0) - c(0)(1)}
  check &&= (0 until 3).map{i => c(i)(1) - c(i)(2)}.forall{_ == c(0)(1) - c(0)(2)}
  
  println(if (check) "Yes" else "No")
}

Measured memory_bytes: 27200
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	string s;
	cin >> s;
	
	cout << string(s.size(), 'x') << endl;


	
	return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	for (auto i = 0; i < N; ++i) {
		cin >> A[i];
	}
	long long max_num = *max_element(A.begin(), A.end());
	long long min_num = *min_element(A.begin(), A.end());
	cout << max_num - min_num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int ans(){
int l,a,b,c,d;
cin>>l>>a>>b>>c>>d;
int i=0;
while(a>c*i or b>d*i){i++;}
return l-i;
}
int main() {
cout<<ans()<<endl;
	return 0;
}

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

using namespace std;

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

	int n, m, k = 0;
	long b, c, ans = 0;
	bool flag = true;

	cin >> n >> m;

	vector <long> as(n);
	vector <pair<long, long> > ps;

	for (int i = 0; i < n; i++) cin >> as[i];
	sort(as.begin(), as.end());

	for (int i = 0; i < m; i++) {
		cin >> b >> c;
		ps.push_back(make_pair(c, b));
	}

	sort(ps.begin(), ps.end());

	for (int i = m - 1; i >= 0 && flag; i--) {
		for (int j = 0; j < ps[i].second; j++) {
			if (k < n) {
				if (ps[i].first > as[k]) as[k] = ps[i].first;
			} else {
				flag = false;
			}	k++;
		}
	}

	//for (int i = 0; i < n; i++) cout << as[i] << ' ';
	//cout << endl;

	for (int i = 0; i < n; i++) ans += as[i];
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdint>
#include <string>
#include <vector>
#include <algorithm>

const size_t match[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

struct compare {
  bool operator ()(const std::string& s, const std::string& t) const {
    if (s.length() != t.length()) return s.length() < t.length();
    return s < t;
  }
} cmp;

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<int> A(M);
  for (auto& ai: A) scanf("%d", &ai);

  std::vector<std::string> dp(N+1);
  for (auto ai: A)
    if (match[ai] <= N)
      dp[match[ai]] = std::string(1, '0'+ai);

  for (size_t i = 1; i <= N; ++i) {
    for (auto ai: A) {
      size_t j = match[ai];
      if (i-j > N) continue;
      const std::string& prev = dp[i-j];
      if (prev.empty()) continue;
      char cur0 = '0'+ai;
      std::string cur = std::max(cur0+prev, prev+cur0, cmp);
      dp[i] = std::max(dp[i], cur, cmp);
    }
  }

  printf("%s\n", dp[N].c_str());
}


Measured memory_bytes: 28544
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi d(N);rep(i,N)cin>>d[i];
  set<int > se;
  rep(i,N)se.insert(d[i]);
  cout <<se.size()<<endl;
  
}







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

using namespace std;

typedef long long ll;

const int INF = 1e9;

void print_rect(int h, int w)
{
  string s(w, '#');
  for (int i = 0; i < h; ++i) {
    fprintf(stdout, "%s\n", s.c_str());
  }
  return;
}

int main()
{
  int h, w;
  while (true) {
    fscanf(stdin, "%d %d", &h, &w);
    if (h == 0 && w == 0) { break; }
    print_rect(h, w);
    fprintf(stdout, "\n");
  }
  return 0;
}

Measured memory_bytes: 1204
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
p = l()
x = list(itertools.accumulate(p))

if n==1:
    print((p[0]+1)/2)
    sys.exit()

if n==k:
    print((x[-1]+k)/2)
    sys.exit()

for i in range(1,n-k+1):
    ans = max(ans,x[i+k-1]-x[i-1])

print((ans+k)/2)


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

struct Node {
	list<int> vs;
	bool cn;
	Node() {
		cn = false;
	}
};

void _Connect(vector<Node> &ns, int n, pair<int, int> v, int i = 0) {
	if (ns[i].cn) return;
	ns[i].cn = true;
	for (int node : ns[i].vs) {
		if (v.first == node && v.second == i) continue;
		if (v.first == i && v.second == node) continue;
		_Connect(ns, n, v, node);
	}
}

bool CheckConnect(vector<Node> &ns, int n, pair<int, int> v) {
	for (int i = 0; i < n; i++) ns[i].cn = false;
	_Connect(ns, n, v);
	for (int i = 0; i < n; i++) {
		if (!ns[i].cn) return false;
	}
	return true;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vertices(m);
	vector<Node> ns(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		vertices[i] = make_pair(a, b);
		ns[a].vs.push_back(b);
		ns[b].vs.push_back(a);
	}
	int ans = 0;
	for (auto v : vertices) {
		if (!CheckConnect(ns, n, v)) ans++;
	}
	cout << ans << endl;
}

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

int main() {
    int n,r=0;cin>>n;
    int a[n];rep(i,n) cin>>a[i];
    
    while(true){
        rep(i,n) {
            if(a[i]%2!=0) {
                cout<<r<<endl;
                return 0;
            }
          	else a[i]/=2;
        }
        r++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int MAX_N = 100050;
int n;
vi adj[MAX_N];
bool vis[MAX_N];

int dfs(int here) {
	vis[here] = true;
	vi v;
	for(auto there : adj[here]) {
		v.pb(dfs(there));
	}
	if(!sz(v)) return 0;

	sort(all(v));
	rep(i,1,sz(v)) {
		if(v[i] <= v[i-1]) {
			v[i] = v[i-1]+1;
		}
	}
	return v.back()+1;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	rep(b,1,n) {
		int a; 
		cin >> a;
		a--;
		adj[a].pb(b);
	}
	cout << dfs(0) << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

int gcd(int x,int y){
    if(y == 0)return x;
    else return gcd(y, x % y);
}

int a[1000001];
bool c[1000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

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

    bool f = false;
    for(int i = 0; i < n; i++){
        int tmp = a[i];
        for(int j = 2; j * j <= tmp; j++){
            if(tmp % j == 0){
                if(c[j]){
                    f = true; break;
                }
                c[j] = true;
                while(tmp % j == 0)tmp /= j;
            }
        }
        if(f)break;
        if(tmp > 1){
            if(c[tmp]){
                f = true; break;
            }
            c[tmp] = true;
        }
    }
    if(!f){
        cout << "pairwise coprime" <<'\n'; return 0;
    }

    int x = a[0];
    for(int i = 1; i < n; i++){
        x = gcd(x, a[i]);
    }
    if(x == 1){
        cout << "setwise coprime" <<'\n';
    }else{
        cout << "not coprime" << '\n';
    }





}


Measured memory_bytes: 7560
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[80];

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

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

	vector<pair<ll, ll>> trade;
	ll buy = INF;
	ll sell = 0;
	bool buying = true;
	for (int i=0; i<N; i++) {
		//cout << buy << " " << sell << endl; // **** debug ****

		if (A[i] > buy) buying = false;

		if (buying) {
			buy = min(buy, A[i]);
		} else {
			sell = max(sell, A[i]);
			if (A[i] < sell) {
				trade.push_back(make_pair(buy, sell));
				buying = true;
				buy = A[i];
				sell = 0;
			}
		}
	}

	if (buying == false) {
		trade.push_back(make_pair(buy, sell));
	}

	// **** debug ****
	/*
	cout << "****" << endl;
	for (pair<ll, ll> t : trade) {
		cout << t.first << " " << t.second << endl;
	}
	*/


	ll money = 1000;

	for (pair<ll, ll> t : trade) {
		ll buy = t.first;
		ll sell = t.second;
		ll stock = money / buy;
		//if (stock == 0) continue;
		money = money - stock * buy + stock * sell;
	}

	ll ans = money;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<vector<int>> X(N),Y(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    X[i].resize(a);
    Y[i].resize(a);
    rep(j,a){
      cin>>X[i][j]>>Y[i][j];
      X[i][j]--;
    }
  }

  int ans=0;
  for(int bit=0;bit<(1<<N);bit++){
    bool ok=true;
    for(int i=0;i<N;i++){
      for(int j=0;j<X[i].size();j++){
        if(bit&(1<<i)){
          if(Y[i][j]&&(bit&(1<<X[i][j])));
          else if(Y[i][j]==0&&(bit&(1<<X[i][j]))==0);
          else{
            ok=false;
            break;
          }
        }
      }
    }
    if(ok==false) continue;

    int res=0;
    for(int j=0;j<N;j++) if(bit&(1<<j)) res++;
    ans=max(ans,res);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(){
	int a,b,c,k;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	if(k<=a) printf("%d",k);
	else {
		if(a+b>=k) printf("%d",a);
		else if(a+b+c>=k)printf("%d",a-k+a+b);
	    else printf("%d",a-c);
	}
	return 0;
}

Measured memory_bytes: 1732
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	while(true)
	    {
		str=input.readLine();
		int a[]=new int[2];
		String ary[]=str.split(" ");
		if(ary[0].equals("0") && ary[1].equals("0"))break;
		for(int i=0;i<2;i++)
		    {
			a[i]=Integer.parseInt(ary[i]);
		    }
		int day=0,j=31,f=29+j,mr=31+f,ap=30+mr,my=31+ap,jn=30+my,jl=31+jn,au=31+jl,s=30+au,o=31+s,n=30+o;
		if(a[0]==1)day=a[1];
		else if(a[0]==2)day=j+a[1];
		else if(a[0]==3)day=f+a[1];
		else if(a[0]==4)day=mr+a[1];
		else if(a[0]==5)day=ap+a[1];
		else if(a[0]==6)day=my+a[1];
		else if(a[0]==7)day=jn+a[1];
		else if(a[0]==8)day=jl+a[1];
		else if(a[0]==9)day=au+a[1];
		else if(a[0]==10)day=s+a[1];
		else if(a[0]==11)day=o+a[1];
		else if(a[0]==12)day=n+a[1];
		if(day%7==1)System.out.println("Thursday");
		else if(day%7==2)System.out.println("Friday");
		else if(day%7==3)System.out.println("Saturday");
		else if(day%7==4)System.out.println("Sunday");
		else if(day%7==5)System.out.println("Monday");
		else if(day%7==6)System.out.println("Tuesday");
		else if(day%7==0)System.out.println("Wednesday");
		
	    }
    }
}

Measured memory_bytes: 16904
#include<iostream>
using namespace std;
int main()
{
	int r;
	cin>>r;
	if(r>=0&&r<1200)
		cout<<"ABC\n";
	else if(r>=1200&&r<2800)
		cout<<"ARC\n";
	else if(r>=2800&&r<=4208)
		cout<<"AGC\n";
	return 0;
}

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

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    double d,t,s;
    cin >> d >> t >> s;
    double d1=d/s;
    if(d1<=t)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Measured memory_bytes: 3728