akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>
 
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
 
int main(){
	int n, x;
	cin >> n >> x;
	if(n==2){
		if(x==2){
			cout << "Yes" << endl;
			for(int i=1; i<=3; i++) cout << i << endl;
			return 0;
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
 
	if(x==1 || x==2*n-1){
		cout << "No" << endl;
		return 0;
	}
 
	vector<int> v(2*n-1, 0);
	vector<bool> b(2*n, false);
	if(x!=2){
		v[n-2]=x-1; b[x-1]=true;
		v[n-1]=x; b[x]=true;
		v[n]=x+1; b[x+1]=true;
		v[n+1]=x-2; b[x-2]=true;
		int tmp=1;
		for(int i=0; i<2*n-1; i++){
			if(v[i]!=0) continue;
			while(b[tmp]) tmp++;
			v[i]=tmp;
			b[tmp]=true;
		}
	}else{
		v[n-2]=3;
		v[n-1]=2;
		v[n]=1;
		v[n+1]=4;
		for(int i=0; i<n-2; i++) v[i]=5+i;
		for(int i=n+2; i<2*n-1; i++) v[i]=i+1;
	}
 
	cout << "Yes" << endl;
	for(int i=0; i<2*n-1; i++) cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define LL long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define I insert
#define bull bool
#define Max(a,b) ((b<a)?a:b)
#define Min(a,b) ((a<b)?a:b)

const LL N = 200005, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans;
pair < LL, LL > p[N];

LL getint(){
	char c = getchar();
	LL t = 0;
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		t = (t << 3) + (t << 1);
		t += c - '0';
		c = getchar();
	}
	return t;
}


int main(){
	/*/
	freopen ( "detectivein.txt", "r", stdin);
	freopen ( "detectiveout.txt", "w", stdout);
	/**/
	cin >> n;
	for ( i = 0; i < n; ++i ){
		cin >> p[i].S >> p[i].F;
	}
	sort ( p, p + n );
	
	k = 0;
	for ( i = 0; i < n; ++i ){
		if ( k + p[i].S > p[i].F ) {
			cout << "No\n";
			return 0;
		}
		k += p[i].S;
	}
	cout << "Yes\n";
	
	return 0;
}
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;
const int oo = 0x3f3f3f3f;


int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    set<int> s;
    int x; cin >> x;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int y; cin >> y;
        s.insert(y);
    }

    int l = x, r = x;

    while (s.count(l)) --l;
    while (s.count(r)) ++r;

    if (abs(l - x) <= abs(r - x)) {
        cout << l << endl;
    } else {
        cout << r << endl;
    }



    return 0;
%>

Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {

	int N;
	cin >> N;

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



	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vd x(N);
  vs u(N);
  rep(i,N) cin >> x.at(i) >> u.at(i);
  
  double Y = 0;
  rep(i,N) {
    Y += u.at(i)=="JPY"?x.at(i):x.at(i)*380000.0;
  }
  
  cout << fixed << setprecision(11);
  cout << Y << endl;
}

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

int main(){
  int N, K;	cin >> N >> K;
  vector<int> v(N+1,0);
  for(int i=0; i<N; i++){
    int A;	cin >> A;
    v[A]++;
  }
  sort(v.begin(),v.end(),greater<int>());
  int tmp = 0;
  for(int i=0; i<N; i++){
    tmp += v[i];
    if(i+2 > K)	break;
  }
  cout << N - tmp << endl;
  return 0;
}

Measured memory_bytes: 4000
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if(A[A.size()-1]==B[0] and B[B.size()-1]== C[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
from decimal import *
getcontext().prec = 30000
a, b, c = map(int, input().split())
#print(a **.5, b**.5,c**.5)
#print(a **.5+ b**.5,c**.5)
#print(Decimal(a).sqrt() , Decimal(b).sqrt() , Decimal(c).sqrt())
#if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
if 2 * Decimal(a * b).sqrt() + Decimal(b) + Decimal(a) < Decimal(c):
#if a **.5 + b**.5 < c**.5:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 6228
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        int q = N;
        do {
            int r = Math.abs(q % (-2));
            list.add(r);
            q = (q - r) / (-2);
        } while (q != 0);
        String res = "";
        for (int i = list.size() - 1; i >= 0; i--) {
            res += list.get(i);
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 21844
class Dice
  def initialize(t, s, e, w, n, b)
    $north = n
    $south = s
    $east = e
    $west = w
    $top = t
    $bottom = b
  end

  def execute_orders(orders)
    length = orders.length
    for i in 0...length
      if orders[i] == "N"
        move_north
      elsif orders[i] == "S"
        move_south
      elsif orders[i] == "E"
        move_east
      elsif orders[i] == "W"
        move_west
      else
        puts "error!"
      end
    end
  end

  def check_dices_same(order_t, order_s, order_e, order_w, order_n, order_b)
      100.times do
        execute_orders(["N", "W"].sample)
        return true if $top == order_t && $south == order_s && $east == order_e && $west == order_w && $north == order_n && $bottom == order_b
      end
    return false
  end


  private
  def move_north
    north = $north
    south = $south
    top = $top
    bottom = $bottom
    $north = top
    $top = south
    $bottom = north
    $south = bottom
  end

  def move_south
    north = $north
    south = $south
    top = $top
    bottom = $bottom
    $south = top
    $bottom = south
    $north = bottom
    $top = north
  end

  def move_east
    top = $top
    bottom = $bottom
    east = $east
    west = $west
    $east = top
    $bottom = east
    $west = bottom
    $top = west
  end

  def move_west
    top = $top
    bottom = $bottom
    east = $east
    west = $west
    $west = top
    $bottom = west
    $east = bottom
    $top = east
  end
end

d1 = gets.chomp.split.map(&:to_i)
d2 = gets.chomp.split.map(&:to_i)
dice1 = Dice.new(d1[0], d1[1], d1[2], d1[3], d1[4], d1[5])
if dice1.check_dices_same(d2[0], d2[1], d2[2], d2[3], d2[4], d2[5])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 8744
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let mut iter = line.split_whitespace().map(|i| i.parse::<usize>().unwrap());
    let n = iter.next().unwrap();
    let m = iter.next().unwrap();
    let l = iter.next().unwrap();

    let mut mat_a = Vec::new();
    for _ in 0..n {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();
        mat_a.extend(line.split_whitespace().map(|i| i.parse::<i32>().unwrap()));
    }

    let mut mat_b = Vec::new();
    for _ in 0..m {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();
        mat_b.extend(line.split_whitespace().map(|i| i.parse::<i32>().unwrap()));
    }

    let mut mat_c = Vec::new();
    for r in 0..n {
        for c in 0..l {
            let v1 = mat_a.iter().skip(m * r).take(m);
            let v2 = mat_b.chunks(l).flat_map(|chunk| chunk.iter().skip(c).take(1));
            let val = v1.zip(v2).map(|(a, b)| (a * b) as i64).sum::<i64>();
            mat_c.push(val);
        }
    }

    for row in mat_c.chunks(l) {
        for (i, elem) in row.iter().enumerate() {
            if i != 0 { print!(" "); }
            print!("{}", elem);
        }
        println!("");
    }
}



Measured memory_bytes: 5040
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>

using namespace std;

template <class T> inline void chmax(T &x, const T &y) {if (x < y) x = y;}

typedef pair<int, int> P;

int n;
P p[2000];
long long dp[2020][2020];

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

  sort(p, p + n);

  for (int len = 0; len < n; len++) {
    for (int i = 0; i < n-len; i++) {
      chmax(dp[i][len + 1], dp[i][len] + (long long)p[len].first * abs(p[len].second - (i + len)));
      chmax(dp[i][len + 1], dp[i+1][len] + (long long)p[len].first * abs(p[len].second - i));
    }
  }

  cout << dp[0][n] << endl;
  return 0;
}


Measured memory_bytes: 26292
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from fractions import gcd


def lcm(a, b):
    # 最小公約数
    g = gcd(a, b)
    return a * b // g


S = read()[:-1]
if len(S) < 2 or len(S) & 1 == 1:
    print('No')
    exit()
hi = 'hi'
for s, ss in zip(S[::2], S[1::2]):
    if hi != s + ss:
        print('No')
        exit()

print('Yes')


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

int main(){
    int64_t N;
    cin>>N;
    string answer;
    int amari;
    while(N!=0){
        amari=N%26;
        N=N/26;
        if(amari!=0){
            answer+=(char)(96+amari);
        }else{
            answer+='z';
            N-=1;
        }
    }
    reverse(answer.begin(),answer.end());
    cout<<answer<<endl;
    
    
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define toupper(S) transform(S.begin(),S.end(),S.begin(),toupper)
#define tolower(S) transform(S.begin(),S.end(),S.begin(),tolower)

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

lint invmod(lint n, lint m) {
	//nの逆元を返す
	lint ret = 0;
	ret = power(n, m-2, m);
	return ret;
}

lint comb(lint n, lint k, lint m) {
	//nCk%MODを返す
	//O(k)
	lint ans = 1;
	rep(i, k) {
		ans *= n-i;
		ans %= m;
		ans *= invmod(k-i,m);
		ans %= m;
	}
	return ans;
}



int main() {
	lint MOD = pow(10, 9) + 7;
	lint n, a, b;
	cin >> n >> a >> b;
	cout << (power(2, n, MOD) - comb(n, a, MOD) - comb(n, b, MOD)-1+MOD*10)%MOD;
}


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

bool qwe(int x)
{
    int k=(int)sqrt( (double)x );
    for(int i = 3;i <= k;i += 2)
        if(x%i==0)
            return false;
    return true;
}
int main ()
{
    int n;
    cin >> n;
    if(n == 2)cout << n <<endl;
    else
    {
        int w;
        if(n % 2 == 0) n ++;
        for (int i = n ; ; i += 2)
        {

            if(qwe(i))
            {
                w = i;
                break;
            }
        }
        cout << w << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().ToCharArray();

            var output = new List<char>();

            foreach(var item in s)
            {
                output.Add(convert(item,n));
            }

            Console.WriteLine(new string(output.ToArray()));




        }

        public static char convert(char c, int n)
        {
            var num = Convert.ToInt16(c) + n;
            if(num >90)
            {
                num -=26;
            }

            return Convert.ToChar(num);
        }
    }
}


Measured memory_bytes: 13140
import numpy as np
h, w, m = map(int, input().split())

hcnt = [0] * w
wcnt = [0] * h
field = {}
for i in range(m):
    y, x = map(int, input().split())
    y -= 1; x -= 1
    wcnt[y] += 1
    hcnt[x] += 1
    row = field.get(y, {})
    row[x] = True
    field[y] = row
def f(y, x):
    return bool(field.get(y, {}).get(x))
# print(wcnt)
# print(hcnt)
hmax = max(hcnt)
wmax = max(wcnt)
ans = hmax + wmax - 1
harg = np.argsort(hcnt)[::-1]
warg = np.argsort(wcnt)[::-1]
for i in harg:
    if hcnt[i] != hmax:
        break
    for j in warg:
        if wcnt[j] != wmax:
            break
        if not f(j, i):
            print(ans + 1)
            __import__("sys").exit()
print(ans)


Measured memory_bytes: 138948
#include<stdio.h>

#define max 100
#define INF 1e9

int head,tail,que[max];

void push(int);
int pop(void);
int Empty(void);

int main(){
  int u,num,k,v,i,j,dist[max];
  int data[max][max];
  scanf("%d",&num);

  for(i = 0;i < num;i++){
    for(j = 0;j < num;j++){
      data[i][j] = 0;
    }
    que[i] = -1;
    dist[i] = INF;
  }


for(i = 0;i < num;i++){
  scanf("%d%d",&u,&k);
  u--;
  for(j = 0;j < k;j++){
    scanf("%d",&v);
    v--;
    data[u][v] = 1;
  }
}

head = tail = 0;
dist[0] = 0;
push(0);

while(!Empty()){
  int v = pop();
  for(i = 0;i < num;i++){
    if(data[v][i] == 0){
      continue;
    }
    if(dist[v] + 1 < dist[i]){
      dist[i] = dist[v] + 1;
      push(i);
    }
  }
}

 for(i = 0;i < num;i++){
   printf("%d %d\n",i + 1,(dist[i] == INF ? -1 : dist[i]));
 }
 return 0;
}

void push(int x){
  que[tail % max] = x;
  tail++;
}

int pop(){
  int res = que[head % max];
  que[head % max] = -1;
  head++;
  return res;
}

int Empty(){
  return (head == tail);
}



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

int ab(int n){
  if(n<0) return -n;
  return n;
}

int main() {
  int N;
  cin >> N;
  int ti=0, xi=0, yi=0;
  bool ans = true;
  rep(i, N){
    int t, x, y;
    cin >> t >> x >> y;
    if(ab(x-xi)+ab(y-yi) > (t-ti)){
      ans = false;
      break;
    }
    if((ab(x-xi)+ab(y-yi))%2 != (t-ti)%2){
      ans = false;
      break;
    }
    xi = x;
    yi = y;
    ti = t;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define N (int) 3e5
using namespace std;
int n;
struct Edge {
	int v, nxt;
} edge[N<<1];
int fst[N], ecnt;
void add_edge (int u, int v) {
	edge[ecnt].v = v, edge[ecnt].nxt = fst[u], fst[u] = ecnt ++;
}
void init_e () {
	memset (fst, -1, sizeof (fst));
}
 
int ksm (int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1) (ret *= x) %= MOD;
		(x *= x) %= MOD;
		y >>= 1;
	}
	return ret;
}
 
int inv (int x) {
	return ksm (x, MOD-2);
}
 
int sz[N], dp1[N], dp2[N];
void DP1 (int u, int f) {
	sz[u] = 1;
	dp1[u] = 1;
	for (int e = fst[u]; e != -1; e = edge[e].nxt) {
		int v = edge[e].v;
		if (v == f) continue;
		DP1 (v, u);
		sz[u] += sz[v];
		(dp1[u] *= dp1[v]) %= MOD;	
	}
	(dp1[u] *= sz[u]) %= MOD;
//	cout << u << " " << dp1[u] << endl;
}
void DP2 (int u, int f) {
	if (u != 1) dp2[u] = dp2[f] * (n - sz[u]) % MOD * inv (sz[u]) % MOD;
//	cout << u << " " << dp2[u] << endl;
	for (int e = fst[u]; e != -1; e = edge[e].nxt) {
		int v = edge[e].v;
		if (v == f) continue;
		DP2 (v, u);
	}
}
 
signed main () {
	init_e ();
	
	cin >> n;
	for (int i = 1; i < n; i ++) {
		int u, v; cin >> u >> v;
		add_edge (u, v); add_edge (v, u);
	}
	
	DP1 (1, 0);
	dp2[1] = dp1[1];
	DP2 (1, 0);
	
	int tmp = 1;
	for (int i = 1; i <= n; i ++) (tmp *= i) %= MOD;
	
	for (int i = 1; i <= n; i ++) cout << (1ll * tmp * inv (dp2[i]) % MOD) << endl;
	
	return 0;
}

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

#define MIN(a,b) ((a < b) ? a : b)

static int C[10000];
typedef struct {
  int id;
  int edge;
  int val;
  int chk;
} st_node;
static st_node node[10001];

typedef struct {
  int a;
  int b;
} st_edge;
static st_edge E[10000];
static int edge[10000][10000];

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

int main(void) {
  int N;
  scanf("%d", &N);

  int max_edge = 0;
  int max_node = 0;
  for(int i = 0; i < N-1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;

    node[a].id = a;
    edge[a][node[a].edge++] = b;
    if(max_edge < node[a].edge) {
      max_edge = node[a].edge;
      max_node = a;
    }
    
    node[b].id = b;
    edge[b][node[b].edge++] = a;
    if(max_edge < node[b].edge) {
      max_edge = node[b].edge;
      max_node = b;
    }
    E[i].a = a;
    E[i].b = b;
  }
  for(int i = 0; i < N; i++) {
    qsort(edge[i], node[i].edge, sizeof(int), int_sort);
  }
  int srcC = 0;
  for(int i = 0; i < N; i++) {
    scanf("%d", &C[i]);
  }
  qsort(C, N, sizeof(int), int_sort);

  // bfs
  int queue[10000];
  int src = 0;
  int dst = 0;
  queue[dst++] = node[max_node].id;
  node[max_node].val = C[srcC++];
  node[max_node].chk = 1;
  while(src != dst) {
    int n = queue[src++];
    for(int i = 0; i < node[n].edge; i++){
      //printf("n=%d edge[%d][%d]=%d\n", n, n, i, edge[n][i]);
      int m = edge[n][i];
      if(node[m].chk == 1)
	continue;
      node[m].val = C[srcC++];
      node[m].chk = 1;
      queue[dst++] = m;
    }
  }

  int ans = 0;
  for(int i = 0; i < N-1; i++) {
    int a = E[i].a;
    int b = E[i].b;
    ans += MIN(node[a].val, node[b].val);
  }
  printf("%d\n", ans);
  for(int i = 0; i < N; i++) {
    printf("%d ", node[i].val);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 388092
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

ll a[3];
int main(){fastio
    ll n;
    
    cin>>n;
    rep(i,0,2)cin>>a[i];
    ll b[n];
    rep(i,0,n-1){
        string s;cin>>s;
        if(s=="AB")b[i]=2;
        else if(s=="AC")b[i]=1;
        else b[i]=0;
    }
    ll ans[n];
    rep(i,0,n-1){
        ll cnt=0;
        rep(j,0,2){
            if(b[i]==j)continue;
            if(a[j]==0)cnt++;
        }
        if(cnt==2){
            cout<<"No"<<endl;return 0;
        }
        if(i==n-1){
            rep(j,0,2){
                if(b[i]==j)continue;
                ans[i]=j;
                if(a[j]==0)break;
            }
        }else if(cnt==1){
            rep(j,0,2){
                if(b[i]==j)continue;
                if(a[j]==0){
                    a[j]++;
                    ans[i]=j;
                }else{
                    a[j]--;
                }
            }
        }else{
            ll cnt[3];
            memset(cnt,0,sizeof(cnt));
            rep(j,0,2){
                if(b[i]==j)continue;
                cnt[j]++;
            }
            rep(j,0,2){
                if(b[1+i]==j)continue;
                cnt[j]++;
            }
            
            rep(j,0,2){
                if(cnt[j]==2){
                    ans[i]=j;
                }
            }
            rep(j,0,2){
                if(b[i]==j)continue;
                if(ans[i]==j)a[j]++;
                else a[j]--;
            }
        }
        //rep(j,0,2)cout<<a[j]<<" ";cout<<endl;
    }
    cout<<"Yes"<<endl;
    rep(i,0,n-1)cout<<(char)('A'+ans[i])<<endl;
    
    return 0;
}



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

#define   db(x)         printf("**%d\n",x)
#define   loop(i,x,n)   for(int i=x;i<n;i++)
#define   pb            push_back
#define   pii           pair<int,int>
#define   imax          2147483647
#define   pcase(x)      printf("Case %d: ",x)
#define   md            1000000007
#define   mm(x,y)       memset(x,y,sizeof(x))
#define   pf1(x)        printf("%d\n",x)
#define   pf2(x,y)      printf("%d %d\n",x,y)
#define   sf1(x)        scanf("%d",&x)
#define   sf2(x,y)      scanf("%d %d",&x,&y)

using namespace std;

int main()
{
    int n,op=0;
    scanf("%d",&n);
    int a[n+2];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n-1;i++)
    {
        for(int j=n-1;j>=i+1;j--)
        {
            if(a[j]<a[j-1])
            {
                int temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
                op++;
            }
        }
    }
    printf("%d",a[0]);
    for(int i=1;i<n;i++) printf(" %d",a[i]);
    printf("\n%d\n",op);
    return 0;
}
/*sample

*/

Measured memory_bytes: 3212
#include<stdio.h>

int kei(int year, int month, int day){
  int sum=0;
  
  for(int i=1;i<year;i++){
    if(i%3==0){
      sum+=20*10;
    }else{
      sum+=20*5+19*5;
    }
  }

  if(year%3==0){
    for(int i=1;i<month;i++){
      sum+=20;
    }
  }else{
      for(int i=1;i<month;i++){
	if(i%2==0){
	  sum+=19;
	}else{
	  sum+=20;
	}
      }
  }

  sum+=day;

  return sum;
}

int main(void)
{
  int sum;
  int year;
  int month;
  int day;
  int i=0;
  int num=0;
  int tan[1000][3];

  scanf("%d", &num);
  
  for(i=0;i<num;i++){
    scanf("%d %d %d", &tan[i][0], &tan[i][1], &tan[i][2]);
  }
 for(i=0;i<num;i++){
    printf("%d\n",kei(1000,1,1)-kei(tan[i][0],tan[i][1],tan[i][2]));
  }
  return 0;
}



Measured memory_bytes: 2048
/*
在？为什么出jb题
*/

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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

ll a[N];
int main() {
	int n; scanf("%d", &n);
	for(int i = 1 ; i <= n ; ++ i) {
		scanf("%lld", &a[i]);
	}
	sort(a + 1, a + 1 + n);
	vector<pair<ll, ll> > way;
	if(a[1] == 0 && a[n] == 0) {
		puts("0");
		for(int i = 1 ; i < n ; ++ i) {
			puts("0 0");
		}
	} else if(a[n] <= 0) {
		for(int i = 1 ; i < n ; ++ i) {
			way.emplace_back(a[n], a[i]);
			a[n] -= a[i];
		}
		printf("%lld\n", a[n]);
		for(auto t: way) {
			printf("%lld %lld\n", t.first, t.second);
		}
	} else if(a[1] > 0) {
		// 都 > 0
		for(int i = 2 ; i < n ; ++ i) {
			way.emplace_back(a[1], a[i]);
			a[1] -= a[i];
		}
		way.emplace_back(a[n], a[1]);
		a[n] -= a[1];
		printf("%lld\n", a[n]);
		for(auto t: way) {
			printf("%lld %lld\n", t.first, t.second);
		}
	} else {
		for(int i = 1 ; i <= n ; ++ i) {
			if(a[i] > 0) {
				// [i, n] 是 > 0
				// a[1] -= a[i + k]
				for(int j = i + 1 ; j <= n ; ++ j) {
					way.emplace_back(a[1], a[j]);
					a[1] -= a[j];
				}
				for(int j = 1 ; j < i ; ++ j) {
					way.emplace_back(a[i], a[j]);
					a[i] -= a[j];
				}
				printf("%lld\n", a[i]);
				for(auto t: way) {
					printf("%lld %lld\n", t.first, t.second);
				}
				break;
			}
		}
	}
}


Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {
	static int n;
	static int k;
	static int[] weight;
	public Main(int n,int k,int[] weight) {
		this.n= n;
		this.k = k;
		this.weight = weight;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();	
		int[] weight = new int[n];
		int total = 0;
		for(int i=0;i<n;i++) {
			weight[i] = sc.nextInt();
			total+=weight[i];
		}
		
		Main al = new Main(n,k,weight);
//		System.out.println(al.check(9));
		
		int p =al.binarySearch(1, total);
		System.out.println(p);
		
		
		
		

	}
	
	public  int binarySearch(int start,int end) {
		int mid;
		mid = (start + end)/2;
//		System.out.println(start + " " +end);
		if(check(mid) == true && check(mid-1) == false) {
			
			  return mid;
		}else if(check(mid) == false && check(mid+1) == true){
			 return mid + 1;
		}else if(check(mid) == false ) {
			return binarySearch(mid,end);
		}else {
			return binarySearch(start,mid);
		}
		
		
	}
	
	public static boolean check(int p) {
		int next = 0;
		
		for(int i=0;i<k;i++) {	
			int max = 0;
			for(int j=next;j<n;j++) {
				max = max+weight[j];
				if(max>p) {
					next = j;
					break;
				}else if(max<=p && j==n-1) {
					return true;
				}
			}
		}
		return false;
	}

}



Measured memory_bytes: 70380
w,h,c=input().split(" ")
w=int(w)
h=int(h)
print("+"+"-"*(w-2)+"+")
for i in range(h-2):
    if i*2==h-3:
        print("|"+"."*((w-3)//2)+c+"."*((w-3)//2)+"|")
    else:
        print("|"+"."*(w-2)+"|")
print("+"+"-"*(w-2)+"+")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    auto v = make_vec<bool>(n, n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a][b] = 1;
        v[b][a] = 1;
    }
    vector<int> p(n);
    rep(i, n) p[i] = i;
    int ans = 0;
    do {
        if (p[0] != 0) continue;
        int ok = 1;
        rep(i, n - 1) {
            ok &= v[p[i]][p[i + 1]];
        }
        ans += ok;
    } while (next_permutation(all(p)));
    cout << ans << endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
ts = list(map(int, input().split()))

total = 0

for t_pre, t_post in zip(ts[:-1], ts[1:]):
  if t_post - t_pre < T:
    total += t_post - t_pre
  else:
    total += T

total += T

print(total)
  

Measured memory_bytes: 26708
import java.util.Scanner;

/**
 * @author kep
 * @date 2019-10-17
 */
public class Main {

    private static  int[] parent  = new int[200005];
    private static  int[] count = new int[200005];
    private static int findRoot(int x){
        if(parent[x] == 0){
            return x;
        }
        parent[x] = findRoot(parent[x]);
        return parent[x];
    }

    private static void add(int a,int b){
        if(a < b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        if(a == b){
            return;
        }
        parent[a] = b;
    }

    public static void init(){
        for(int i = 0;i<200005;i++){
            parent[i] = count[i] = 0;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        init();
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        for(int i = 0;i<m;i++){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int root_a = findRoot(a);
            int root_b = findRoot(b);
            add(root_a,root_b);
        }
        int ans = 0;
        for(int i = 1;i<=n;i++){
            int root_i = findRoot(i);
            count[root_i]++;
            ans = Math.max(count[root_i],ans);
        }
        System.out.println(ans);

    }



}


Measured memory_bytes: 61888
#include<iostream>
#include<vector>
#include<queue>
#include<functional>

using namespace std;

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

int N, M;
vector<vector<P>> E;
ll d[100000];
const ll INF = 1145141919810893;

void djk() {
	for (int i = 0; i < N; i++)d[i] = INF;
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push(P(0, 0));
	while (pq.size()) {
		auto now = pq.top(); pq.pop();
		if (now.first > d[now.second])continue;
		for (int i = 0; i < E[now.second].size(); i++) {
			int nxt = E[now.second][i].first;
			ll cost = E[now.second][i].second;
			if (d[nxt] > d[now.second] + cost) {
				d[nxt] = d[now.second] + cost;
				pq.push(P(d[nxt], nxt));
			}
		}
	}
}

int main() {
	cin >> N >> M;
	E.resize(N);
	for (int i = 1; i < N; i++) {
		E[i].push_back(P(i - 1, 0));
	}
	for (int i = 0; i < M; i++) {
		int L, R;
		ll C;
		cin >> L >> R >> C;
		L--, R--;
		E[L].push_back(P(R, C));
	}

	djk();
	if (d[N - 1] == INF)cout << -1 << endl;
	else cout << d[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 10104
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const int N = 3005;
int n;
long double p[N], dp[N][N];
long double solve(int idx, int heads){
    if(idx >= n){
        if(heads > n - heads) return 1;
        else return 0;
    }
    if(dp[idx][heads] != -1) return dp[idx][heads];
    long double ans = solve(idx + 1, heads) * (1.0 - p[idx]) +
                      solve(idx + 1, heads + 1) * (p[idx]);
    dp[idx][heads] = ans;
    return dp[idx][heads];
}
int main()
{
    Hello
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            dp[i][j] = -1;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> p[i];
    cout << fixed << setprecision(10) << solve(0, 0);
    return 0;
}

Measured memory_bytes: 145040
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

ll dodp(ll k, vec& dp, vec& a) {
	if (dp[k] != -1) return dp[k];

	dp[k - 2] = dodp(k - 2, dp, a);
	dp[k - 1] = dodp(k - 1, dp, a);
	dp[k] = dp[k - 2] + dp[k - 1];
	dp[k] %= mod;

	return dp[k];
}

int main()
{
	// 入力
	ll N, M;
	cin >> N >> M;

	vec a(M);

	REP(i, M) {
		cin >> a[i];
	}

	vec dp(N + 1, -1);
	dp[0] = 1;
	dp[1] = 1;
	REP(i, M) {
		dp[a[i]] = 0;
	}

	ll ans = dodp(N, dp, a);


	cout << ans << endl;

	return 0;
}

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

int main() {
	static long long N, A[100], K, DP[110][256][110] = {}, MOD = 1000000007, ANS = 0, NOW = 1;
	DP[0][0][0] = 1;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 256; j++) {
			for (int k = 0; k < N; k++) {
				DP[i + 1][j][k] = (DP[i + 1][j][k] + DP[i][j][k]) % MOD;
				DP[i + 1][j ^ A[i]][k + 1] = (DP[i + 1][j ^ A[i]][k + 1] + DP[i][j][k]) % MOD;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		NOW = (NOW * i) % MOD;
		ANS += (DP[N][K][i] * NOW) % MOD;
		ANS = ANS % MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 22528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

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

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

  int parity = max({a, b, c})*3 - (a+b+c);
  int ans;

  if (parity & 1) {
    cout << ((max({a, b, c})+1)*3-(a+b+c)) / 2 << endl;
  } else {
    cout << (max({a, b, c})*3-(a+b+c)) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9;
using namespace std; // std::を省略して書くことができる

int c[10][10];
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for (int m = 0; m < 1000; m++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++)
        if (i != j) {
          for (int k = 0; k < 10; k++) {
            if (i != k && j != k) {
              c[i][k] = min(c[i][k], c[i][j] + c[j][k]);
            }
          }
        }
    }
  }
  int ans = 0;
  for (int i = 0; i < H * W; i++) {
    int num;
    cin >> num;
    if (num != -1) {
      ans += c[num][1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
class UnionFind{
public:
//親の番号を格納。親なら-(その集合のサイズ)
	vector<int> Parent;

	UnionFind(int N){
		Parent = vector<int>(N,-1);
	}
	//Aのグループを調べる
	int root(int A){
		if(Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
	//自分のいるグループの頂点数を調べる
	int size(int A){
		return -Parent[root(A)];
	}
	//AとBをくっつける
	bool connect(int A,int B){
		//AとBを直接くっつけず、親どうしをくっつける
		A = root(A);
		B = root(B);
		if(A == B){ // すでにくっついてる
			return false;
		}
		//おおきいほうを親にしたい
		if(size(A) < size(B)) swap(A,B);
		//Aのサイズを更新
		Parent[A] += Parent[B];
		//BをAにつるす
		Parent[B] = A;
		return true;
	}
};

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> A (M),B (M);
	for(int i=0;i<M;i++){
	cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	vector<long long> ans(M);
	ans[M-1] = (long long)N*(N-1)/2;
	
	UnionFind Uni (N);

	for(int i=M-1;i>0;i--){
		if(Uni.root(A[i]) != Uni.root(B[i])){
			ans[i-1] = ans[i] - (long long)Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i],B[i]);
		}else{
			ans[i-1] = ans[i];
		}
	}
	for(int i=0;i<M;i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    int L;
    double x;
    scanf("%d",&L);
    x = L/ 3.0;
    printf("%f",x*x*x);
    return 0;
}

int A(){
    int N,M;
    int ans;
    scanf("%d %d",&N,&M);

    ans = (N-1)*N/2 + (M-1)*M/2;
    printf("%d",ans);

    return 0;
}

int B(){
    char S[100];
    char mae[50]={};
    char ato[50]={};
    char mae_mae[25]={};
    char mae_ato[25]={};
    char ato_mae[25]={};
    char ato_ato[25]={};

    scanf("%s",&S);

    strncpy(mae,S,(strlen(S)-1)/2);
    for(int i = 0; i < (strlen(S)-1)/2; ++i){
        ato[i] = S[(strlen(S)- 1 - i)];
    }
    if(strcmp(mae,ato) != 0){
        printf("No");
        return 0;
    }

    if(strlen(mae)% 2 == 1) {
        strncpy(mae_mae, mae, (strlen(mae) - 1) / 2);
        strncpy(ato_mae, ato, (strlen(ato) - 1) / 2);
        for(int i = 0; i < (strlen(mae)-1)/2; ++i){
            mae_ato[i] = S[(strlen(mae)- 1 - i)];
            ato_ato[i] = S[(strlen(mae)- 1 - i)];
        }

    }
    else {
        strncpy(mae_mae, mae, strlen(mae) / 2);
        strncpy(ato_mae, ato, strlen(ato) / 2);
        for (int i = 0; i < (strlen(mae)) / 2; ++i) {
            mae_ato[i] = S[(strlen(mae)- 1 - i)];
            ato_ato[i] = S[(strlen(mae)- 1 - i)];
        }
    }

    if(strcmp(mae_mae,mae_ato) != 0 || strcmp(ato_mae,ato_ato) != 0){
        printf("No");
        return 0;
    }
    else{
        printf("Yes");
        return 0;
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main(){
    int n;
    cin >> n;
    ll all = 0;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        all += a[i];
    }

    vector<int> r(n);
    r[0] = a[0];
    for(int i = 1; i < n; i++) r[i] = r[i-1] + a[i];

    ll ans = 0;
    rep(i,n){
        ans += (a[i] % MOD) * ((all - a[i])%MOD);
        all -= a[i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    v_int p(n), q(n);
    cin >> p >> q;

    v_int idx(n), org(n);
    rep(i,n) { 
        idx[i] = i; 
        org[i] = i+1;
    }
    
    int ans[2] = {0,0}, cnt = 1;
    do {
        v_int r(n);
        rep(i,n) {
            r[i] = org[idx[i]];    
        }
        rep(i,2) {
            bool ok = true;
            rep(j,n) {
                if(i==0) {
                    if(r[j] != p[j]) { ok = false; }
                } else {
                    if(r[j] != q[j]) { ok = false; }
                }
            }
            if(ok) {
                ans[i] = cnt;
            }
        }
        cnt++;
    } while(next_permutation(idx.begin(), idx.end()));
    cout << abs(ans[0]-ans[1]) << endl;
    return 0;
} /*atcoder*/


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int m1,m2;
    m1=max(a[0],a[1]);
    m2=min(a[0],a[1]);
    int c1,c2;
    if(a[0]==m1){
        c1=0;
        c2=1;
    }
    else{
        c1=1;
        c2=0;
    }
    for(int i=2;i<n;i++){
        if(m1<=a[i]){
            m2=m1;
            m1=a[i];
            c2=c1;
            c1=i;
        }
        else if(m2<=a[i]){
            m2=a[i];
            c2=i;
        }
    }
    rep(i,n){
        if(i==c1){
            cout<<m2<<endl;
        }
        else{
            cout<<m1<<endl;
        }
    }




    return 0;
}



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

int main(void){
    int N;
    cin >> N;
    int W[N];
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    int min = 1000000;
    for(int j = 0; j < N - 1; j++){
        int suma = 0, sumb = 0;
        for (int a = 0; a <= j; a++){
            suma += W[a];
        }
        for (int b = j + 1; b < N; b++){
            sumb += W[b];
        }
        if(abs(suma - sumb) < min) min = abs(suma - sumb);
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int black[300000] = {};
void solve(long long N, std::string S){
    for(int i = 0;i < N;++i){
        black[i] += black[max(i-1,0)];
        if(S[i] == '#'){
            black[i]++;
        }
    }
    int ans = black[N-1];
    int now_black = 0;
    for(int i = 0;i < N;++i){
        int cnt_white = N - i;
        cnt_white -= black[N-1] - now_black;
        ans = min(ans,now_black + cnt_white);
        if(S[i] == '#'){
            now_black++;
        }
    }
    cout << ans << endl;
    return;
}

// Generated by 1.1.4 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 N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 2036