akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+(pll a, pll b) { return {a.x + b.x, a.y + b.y}; }

ll rand0m() {
    return (ull(rand()) << 15ull | ull(rand()));
}                   //[0 ... n)
ll rand0m(ll x) {
    return rand0m() % x;
}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {
    return rand0m(maxx - minn + 1) + minn;
}   //[minn ... maxx]

const ll MAXN = 2e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

ll n, m;

struct SegTree{
    vector<ll> t;
    
    explicit SegTree(ll siz){
        t.resize(siz * 4, 0);
    }
    
    void set(ull v, ull l0, ull r0, ull ind, ll val){
        if(l0 + 1 == r0){
            t[v] = val;
            return;
        }
        ull mid = (l0 + r0) >> 1ull;
        if(ind < mid){
            set(v << 1ull, l0, mid, ind, val);
            if(t[v] < t[v << 1ull]) t[v] = t[v << 1ull];
        }else {
            set(v << 1ull | 1ull, mid, r0, ind, val);
            if(t[v] < t[v << 1ull | 1ull]) t[v] = t[v << 1ull | 1ull];
        }
    }

    ll get(ull v, ull l0, ull r0, ull l, ull r){
        if(r <= l) return 0;
        if(l0 == l && r0 == r){
            return t[v];
        }
        ull mid = (l0 + r0) >> 1ull;
        return max(get(v << 1ull, l0, mid, l, min(mid, r)),
                get(v << 1ull | 1ull, mid, r0, max(l, mid), r));
    }
};

ll h[MAXN];

void solve() {
    cin >> n;
    ll N = n + 1;
    SegTree st(N);
    fori(i, n) cin >> h[i];
    fori(i, n){
        cin >> m;
        st.set(1, 0, N, h[i], st.get(1, 0, N, 1, h[i]) + m);
    }
    cout << st.get(1, 0, N, 0, N);
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}


Measured memory_bytes: 8064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import Control.Monad.Trans.State.Strict
import Data.List
import Data.Ord
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B
--
type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parse :: Parser ([(Int,Int)], [(Int,Int)])
parse = do
    n <- parseInt
    liftM2 (,) (replicateM n parseInt2) (replicateM n parseInt2)

main=do
    (rs,bs) <- (\(xs,ys)->(sort xs, sort ys)).fromJust.evalStateT parse <$> B.getContents
--    print rs
--    print bs
    print.sum $ unfoldr f (rs,bs)

--f :: ([(Int,Int)], [(Int,Int)]) -> Maybe(Int, ([(Int,Int)], [(Int,Int)]))
f ([], _ ) = Nothing
f (_ , []) = Nothing
f (rs, ba@((bx,by):bs)) = g (partition (\(x,y)->x<bx&&y<by) rs) ba

--g :: ([(Int,Int)],[(Int,Int)]) -> [(Int,Int)] -> Maybe(Int, ([(Int,Int)],[(Int,Int)]))
g ([],rs) (b:bs) = Just(0, (rs,bs))
g (rs1,rs2) (b:bs) = Just(1, ((filter(/=mr)rs1)++rs2, bs))
    where
        (mr:_) = sortBy (flip $ comparing snd) rs1


Measured memory_bytes: 1020
import java.io.*;
import java.util.*;

public class Main {
	static public void main(String[] argv) {
		try{
//			FileWriter fw = new FileWriter("output.txt");
//			BufferedWriter bw = new BufferedWriter(fw);
//			PrintWriter pw = new PrintWriter(bw, true);
			
//			FileReader fr = new FileReader("input.txt");
//			BufferedReader br = new BufferedReader( fr );
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));	
//			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
//			PrintWriter pw = new PrintWriter(bw, true);
			
			while(true) {
				String buf = br.readLine();
				int n;
				n = Integer.valueOf(buf);
				if(n == 0) break;
				
				solve(n, n, "");
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	static void solve(int max, int total, String str) {
		for(int i = max; i >= 1; i--) {
			int rest = total - i;
			if(rest < 0) {
				continue;
			} else if(rest == 0) {
				String buf = str + i;
				System.out.println(buf);
			} else if(rest > 0) {
				String buf = str + (i + " ");
				solve(i, rest, buf);
			}
		}
	}
}

Measured memory_bytes: 38056
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

t = ns()
a = ''
for i in t:
    if i == '?':
        a+='D'
    else:
        a+=i

print(a)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    int x,y;
    cin>>N;
    cin>>x>>y;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;

        int s=(x+a-1)/a;
        int t=(y+b-1)/b;
        chmax(s,t);
        x=s*a;
        y=s*b;
    }

    cout<<x+y<<endl;
    return 0;
}


Measured memory_bytes: 256
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)*}
    };
}

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)*}
    };
}

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")
    };
}

use std::cmp::max;

fn main() {
    input!{
        s: chars,
        t: chars
    }
    let ls = s.len();
    let lt = t.len();
    let mut tab: Vec<Vec<usize>> = vec![vec![0; lt + 1]; ls + 1];
    for i in 0..ls {
        for j in 0..lt {
            tab[i + 1][j + 1] = max(tab[i][j + 1], tab[i + 1][j]);
            if s[i] == t[j] {
                tab[i + 1][j + 1] = max(tab[i + 1][j + 1], tab[i][j] + 1);
            }
        }
    }
    let mut ans = Vec::new();
    let mut is = ls;
    let mut it = lt;
    while is > 0 && it > 0 {
        if tab[is][it] == tab[is - 1][it] {
            is -= 1;
        } else if tab[is][it] == tab[is][it - 1] {
            it -= 1;
        } else {
            ans.push(s[is - 1]);
            is -= 1;
            it -= 1;
        }
    }
    println!("{}", ans.iter().rev().map(|c| *c).collect::<String>());
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n, k;
  cin >> n >> k;
  vi d(k);
  rep(i,k) cin >> d[i];

  for (int i = n; i <= 10*n; ++i) {
    int tmp = i;
    bool ok = true;
    while (tmp > 0) {
      if (binary_search(rng(d),tmp%10)) {
        ok = false;
        break;
      }
      tmp /= 10;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int i, l, r;
  int ans = 0;
  rep(i, n) {
    cin >> l >> r;
    ans+=r-l+1;
  }
  cout << ans << endl;
}

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

int main(void)
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

#define N_MAX 100000

string name[N_MAX];
int t[N_MAX];
int queue[N_MAX+1];
int head = 0;
int tail = 0;

void enqueue(int i) {
  queue[tail++] = i;
  if(tail == N_MAX+1) tail = 0;
}

int dequeue() {
  int v = queue[head++];
 
  if(head == N_MAX+1) head = 0;

  return v;
}

bool empty() {
  return head == tail;
}

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

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

  int sum = 0;
  int count = 0;
  
  while(!empty()) {
    int v = dequeue();

    if (t[v] <= q) {
      sum += t[v];
      t[v] = 0;
      cout << name[v] << " " << sum << endl;
    } else {
      sum += q;
      t[v] -= q;
      enqueue(v);
    }
  }
}



Measured memory_bytes: 6920
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

int main(){
  int m1=0,m2=0,m3=0,a;
  rep(i,10){
    cin>>a;
    if(a>m1){
      m3=m2;
      m2=m1;
      m1=a;
    }
    else if(a>m2){
      m3=m2;
      m2=a;
    }
    else if(a>m3){
      m3=a;
    }
  }
  
  cout<<m1<<endl;
  cout<<m2<<endl;
  cout<<m3<<endl;
  
  return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a) for(int i=0; i<a; i++)
using namespace std;
typedef pair<int, int> P;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
bool cmp(int a, int b)
{
	return a > b;
}
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge one, two;
	one.from = a; one.to = b; one.weight = c;
	two.from = b; two.to = a; two.weight = c;
	V[a].push_back(one);
	V[b].push_back(two);
}


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


void solve()
{
	cin >> a >> b;
	cout << max(a - b, max(a + b, a * b));
}
int main()
{
	int times = 1;
//	cin << times;
	loop(times)
	{
		solve();
		printf("\n");
	}
	return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0; i<h; i++){
        cin >> s[i];
    }

    //同じ行に#があるかつ同じ列に#がある部分を出力する
    vector<bool> x(h,false);
    vector<bool> y(w,false);
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                x[i]=true;
                y[j]=true;
            }
        }
    }     
    rep(i,h){
        if(x[i]==true){
            rep(j,w){
                if(y[j]==true) cout << s[i][j];
            }
            cout << endl;
        }
    }   
    



}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;

signed main() {
int n;
cin>>n;
vector<int>p(n);
vector<int>q(n);
rep(i,n)cin>>p[i];
rep(i,n)cin>>q[i];
vector<int>a(0);
rep(i,n)a.push_back(i+1);
int count=0;
int aj=0,bj=0;
do{
count++;
if(a==p) aj=count;
if(a==q) bj=count;
}while(next_permutation(a.begin(),a.end()));

cout<<abs(aj-bj)<<endl;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

int main() { FAST
    int x; cin >> x;
    cout << (x>=30 ? "Yes" : "No") << "\n";
}



Measured memory_bytes: 3636
import math

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

A,B,C,D = map(int,input().split())

C_ = len(range(A//C*C if A//C*C==A else (A//C+1)*C,B+1,C))
D_ = len(range(A//D*D if A//D*D==A else (A//D+1)*D,B+1,D))
CD = lcm(C,D)
CD_ = len(range(A//CD*CD if A//CD*CD==A else (A//CD+1)*CD,B+1,CD))

print(B-A+1-C_-D_+CD_)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll A, B, C; cin >> A >> B >> C;
	ll ans = LINF;

	if ((A % 2 == 0) || (B % 2 == 0) || (C % 2 == 0)) {
		ans = 0;
	}
	else {
		ans = min({ A*B,B*C,C*A });
	}
	cout << ans << endl;
	return		0;
}

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

namespace _20200426_ABC164B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(1);

            string[] sp = input[0].Split(' ');
            int A = int.Parse(sp[0]);
            int B = int.Parse(sp[1]);
            int C = int.Parse(sp[2]);
            int D = int.Parse(sp[3]);

            string output = "Yes";

            int AAtackCount = C / B + (C % B != 0 ? 1 : 0);
            int CAtackCount = A / D + (A % D != 0 ? 1 : 0);

            if (AAtackCount > CAtackCount)
            {
                output = "No";
            }

            Console.WriteLine(output);
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }
    }
}


Measured memory_bytes: 27812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 2e6+10;

string N;

void solve()
{
	ll ans = 0;
	for(char c : N) ans += c-'0';
	if(ans % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 3744
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c = ism()

if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define rg register
#define f(i,a,b) for(rg int i=a;i<=b;++i)
#define df(i,a,b) for(rg int i=a;i>=b;++i)
#define F(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
template <typename T> inline void cmax(T &a,T b) {a=a>b?a:b;}
template <typename T> inline void cmin(T &a,T b) {a=a<b?a:b;}
template <typename T> inline void read(T &n) {
	n=0;rg char ch;while(!isdigit(ch=getchar()));
	for(n=ch^48;isdigit(ch=getchar());n=n*10+(ch^48));
}
int n;
char a[233];
signed main() {
	scanf("%d\n",&n);
	f(i,1,n) a[i*2-1]=getchar();
	getchar();
	f(i,1,n) a[i*2]=getchar();
	printf("%s",a+1);
}


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


int main()
{
    int a,b;
    int other;
    cin >> a >> b;
    if(a == 1)
    {
        if(b==2)
            cout << 3;
        if(b==3)
            cout << 2;
    }
    else if(a==2)
    {
        if(b==1)
            cout <<3;
        if(b==3)
            cout << 1;
    }
    else
    {
        if(b==1)
            cout << 2;
        if(b==2)
            cout << 1;
    }
    return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Long e = Long.parseLong(sc.next());

    Map<Long, Long> map = new HashMap<>();
    map.put(0L, 0L);
    map.put(1L, 1L);
    map.put(2L, 2L);
    map.put(3L, 3L);
    map.put(4L, 5L);
    map.put(5L, 7L);
    map.put(6L, 8L);
    map.put(7L, 9L);
    while (!e.equals(0L)) {
      List<Long> lists = new ArrayList<>();
      while (e / 8 != 0) {
        lists.add(map.get(e % 8L));
        e = e / 8L;
      }
      lists.add(map.get(e % 8L));
      Collections.reverse(lists);
      System.out.println(lists.stream().map(Object::toString).collect(Collectors.joining("")));
      e = Long.parseLong(sc.next());
    }
  }
}


Measured memory_bytes: 67696
# ダイクストラ法で部屋1から各部屋への最短経路を出す
import queue

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]

# 隣接行列の作成
edges_dict = {}
for edge in edges:
    a, b = edge

    if a not in edges_dict:
        edges_dict[a] = [b]
    else:
        edges_dict[a].append(b)

    if b not in edges_dict:
        edges_dict[b] = [a]
    else:
        edges_dict[b].append(a)

# i=0は未使用, i>0は部屋iの最短経路がたどる次の部屋 = 道しるべ
prev_list = [None] * (n + 1)
q = queue.Queue()

# 初期化
q.put(1)
prev_list[1] = 1

while not q.empty():
    v = q.get()
    for w in edges_dict[v]:
        if prev_list[w] is None:
            prev_list[w] = v
            q.put(w)

print("Yes")
for v in prev_list[2:]:
    print(v)


Measured memory_bytes: 65152
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


using namespace std;

#define N 1000000
int arr[N];
int a[N];
 
void eratosthenes(){
    REP(i,N){
        arr[i]=1;
    }
 
    for(int i=2;i<sqrt(N);i++){
        if(arr[i]){
            for(int j=0;i*(j+2)<N;j++){
                arr[i*(j+2)]=0;
            }
        }
    }
    arr[0]=0;
    arr[1]=0;
}

signed main(){
 
    int n,y;
    cin>>n>>y;

    for(int i=0;i<=n;i++){
    	for(int j=0;j<=n;j++){
    		int k=n-(i+j);

    		if(k>=0){
    			// cout<<i<<" "<<j<<" "<<k<<endl;

    			if(i*10000+j*5000+k*1000==y){
    				cout<<i<<" "<<j<<" "<<k<<endl;
    				return 0;
    			}
    		}
    		
    	}
    }

    cout<<-1<<" "<<-1<<" "<<-1<<endl;






}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n;cin>>n;
    ll mxx=-INF,mx=-INF,s=0;
    ll a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>mx)mx=a;
        if(mx>mxx){swap(mxx,mx);s=i;}
    }
    for(int i=0;i<n;i++){
        if(i==s)cout<<mx<<"\n";
        else cout<<mxx<<"\n";
    }
}


Measured memory_bytes: 1664
#include <cstdio>

int pr[10000] = { 0 };
int n[10000] = { 0 };

int main() {
    int co = 0;
    int sum = 0;
    int allco = 0;
    for (int i = 0; scanf("%d,%d", &pr[i], &n[i]) != EOF; ++i) {co++;}

    for (int i = 0; i < co; ++i) {
        sum += pr[i] * n[i];
        allco += n[i];
    }

    int ave = 0;
    {
        double t = allco / (double) co;
        ave = (int) (t + 0.5d);
    }

    printf("%d\n%d\n", sum, ave);

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans = 0, n = 0, m, count, sum = 0, ch = 0;
	llint s, a, aa, aaa, rr = 0, gg = 0, bb = 0,b;
	bool check = false;

	vector<llint> r, g;
	char c;
	cin >> aa>>aaa;
	if (aa >= 10)cout << aaa << endl;
	else cout << aaa + 100 * (10 - aa) << endl;
	
	please AC;
}


Measured memory_bytes: 256
STDIN.each{|s|
    a,b,c,d,e,f = s.split(" ").map!{|d| d.to_f}
    z1 = b*d-e*a
    z2 = c*d-f*a
    y = z2 / z1
    x = (-(b*y)+c)/a
    printf("%.3f %.3f\n", x, y)
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

double e(double p){
  double tot = 0;
  for(double i = 1; i <=p; i++){
    tot += i/p;
  }
  return tot;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<double> E(n);
  rep(i,n){
    int p;
    cin >> p;
    E.at(i) = e(p);
  }
  
  double ans;
  rep(i,k) ans += E.at(i);
  double update = ans;
  rep(i,n-k) {
    update = update-E.at(i)+E.at(i+k);
    ans = max(ans, update);
  }
  printf("%5.7f\n",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N=1000005;
int n,a[N];
char s[N];
int main(){
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++)
		a[i]=(s[i]-'0')*9;
	reverse(a,a+n);
	for (int i=0;i<n;i++)
		a[i+1]+=a[i]/10,a[i]%=10;
	while (a[n])
		n++,a[n+1]+=a[n]/10,a[n]%=10;
	int now=0;
	for (int i=0;i<n;i++)
		now+=a[i];
	for (int i=1;;i++){
		int p=0;
		while (a[p]==9)
			p++;
		a[p]++,now+=1-p*9;
		while (p--)
			a[p]=0;
		if (now<=i)
			return printf("%d",(i+8)/9),0;
	}
	return 0;
}

Measured memory_bytes: 3840
n = int(input())
a = [[[0]*10 for _ in range(3)] for _ in range(4)]
for i in range(n):
  b, f, r, v = list(map(int, input().split()))
  a[b-1][f-1][r-1] += v
for i in range(4):
  for j in range(3):
    print(" "+" ".join(map(str, a[i][j])))
  if i!=3:
    print("#"*20)


Measured memory_bytes: 5608
import sys 
sys.setrecursionlimit(1000)
n=int(input())
H=list(map(int,input().split()))
def bunkai(H):
    B=[]
    b=0
    f=0
    for i in range(len(H)):
        if H[i]==0:
            if i!=0:
                B.append(H[b:i-1+1])
                b=i+1
            else:
                b=i+1
        elif i==len(H)-1:
            B.append(H[b:])
    return B
def min(lis):
    min=101
    if len(lis)==0:
        return 0
    for i in range(len(lis)):
        if lis[i]<min:
            min=lis[i]
    return min
def mizu(lis,n):
    for i in range(len(lis)):
        lis[i]+=-n
    return lis
def sso(lis,sum):
    #print(sum)
    B=bunkai(lis)
    #print(B)
    if len(B)==0:
        #print("return: "+str(sum))
        return sum
    for l in B:
        #print(l)
        x=min(l)
        #print("+"+str(x))
        sum+=x
        li=mizu(l,x)
        #print("li"+str(li))
        sum=sso(li,sum)
    #print("return end:"+str(sum))
    return sum

#print(min([]))
sum=0
x=sso(H,sum)

    
print(x)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

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

Measured memory_bytes: 3624
N, M = map(int, input().split())
lst = list()
for i in range(M):
    P, Y = map(int, input().split())
    lst.append((Y, i, P))
lst.sort()

cnt = [1] * (N + 1)
ans = list()
for Y, i, P in lst:
    id = str(P).zfill(6) + str(cnt[P]).zfill(6)
    cnt[P] += 1
    ans.append((i, id))
ans.sort()
for i, id in ans:
    print(id)


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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll solve(int N) {
    return -1LL;
}

int main() {
    int N; cin >> N;
    vector<vector<int>> ne(N); // 隣、x
    rep(i, N-1) {
        int xi, yi; cin >> xi >> yi;
        ne[xi].pb(yi);
        ne[yi].pb(xi);
    }
    vector<int> br(N, 0);
    rep(i, N) br[i] += ne[i].size();
    int max_at = -1, max_br = -1;
    rep(i, N) {
        if (br[i] > max_br) { max_at = i; max_br = br[i]; }
    }

    queue<int> q;
    vector<int> ord;
    q.push(max_at);
    vector<int> parent(N, -1), children(N, 0);
    vector<bool> visited(N, false);
    while(!q.empty()) {
        int u = q.front(); q.pop();
        visited[u] = true;
        ord.pb(u);
        for (int v : ne[u]) {
            if (visited[v]) continue;
            q.push(v);
            parent[v] = u;
            ++children[u];
        }
    }
#ifdef DEBUG
    cout << "ord:" << ord << endl;
    cout << "parent:" << parent << endl;
    cout << "children:" << children << endl;
#endif

    vector<int> val(N, 0);
    vector<vector<ii>> escal(N);
    rep(u, N) if (children[u] == 0) { val[u] = 1; escal[u].pb(ii(1, 0)); }
    // unerasable

    for (int i=N-1; i>=0; --i) {
        int v = ord[i];
        val[v] = 0;
        int l = 0;
        for (auto p : escal[v]) {
            val[v] += p.first;
            if (p.second == 1) l = 1;
        }
        if (children[v] >= 2) {
            for (ii p : escal[v]) {
                if (p.first == 1 && p.second == 0) {
                    val[v]--; break;
                }
            }
        }

        int u = parent[v];
        if (u != -1) {
            escal[u].pb(ii(val[v], (children[v]>=2)?1:l));
        }
    }
#ifdef DEBUG
    cout << endl;
    cout << "escal:" << escal << endl;
    cout << "val:" << val << endl;
#endif
    cout << val[max_at] << endl;

    return 0;
}


Measured memory_bytes: 14916
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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


int main(){
    string S;
    cin >> S;
    if(S[2] == S[3] and S[4] == S[5]){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using LL = int64_t;
using VL = vector<LL>;

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}

int main(int argc, char *argv[])
{
	int n,m,q;
	cin >> n >> m >> q;
	VL a(q), b(q), c(q), d(q);
	for (int i = 0; i < q; i++) {
		cin >> a[i]>> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	VL A(n,1);
	LL ans = 0;
	auto dfs = [&](auto&& dfs, int v) -> void{
		while (A[v] <= m) {
			if (v == n-1) {
				int tmp = 0;
				for (int i = 0; i < q; i++) {
					tmp += A[b[i]] - A[a[i]] == c[i] ? d[i] : 0;
				}
				chmax(ans,tmp);
			}
			else {
				if (A[v+1] < A[v]) {
					A[v+1] = A[v];
				}
				dfs(dfs, v+1);
			}
			A[v]++;
		}
		A[v] = 1;
		return;
	};
	dfs(dfs, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {
    cin >> a >> b;
    
    if(a==0 && b==0)
       break;
       
       if(a > b)
       {
        temp = a ;
        a = b ;
        b = temp ;
        
       }
       cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3052
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
   bool flg=false;
      int tmp=N;
   int i=0;
     while(!IsPrime(tmp)){
       tmp++;
        
      }
        
    
      Console.WriteLine(tmp);
      }
    public static bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = Math.Sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
  }

}


Measured memory_bytes: 27468
#include<stdio.h>
#define zyougen 150
#define Big 1000000
int i, j, num, A[zyougen][zyougen]={0};
int back[zyougen], min[zyougen], used[zyougen];
int prim(){
 int dir, next,  Sum = 0;
 min[1] = 1;
 while(1){
   dir  = Big;
   next = -1;
   for(i=1; i<=num; i++){
     if (dir > min[i] && used[i] != -1) {
       next = i;
       dir  = min[i];
     }
   }
   if (next == -1) {
     break;
   }
   used[next] = -1;
   for(j=1; j<=num; j++){
     if(used[j] != -1 && A[next][j] != Big){
       if(min[j] > A[next][j]){
         min[j] = A[next][j];
         back[j] = next;
         used[j] = 1; 
       }
     }
   }
 }

 for(i=1; i<=num; i++){
   if(back[i] != -1){
     Sum += A[i][back[i]];
   }
 }
 
 return Sum;
}
int main(){
 int omomi;
 scanf("%d", &num);
 for(i=1; i<=num; i++){
   for(j=1; j<=num; j++){
     scanf("%d", &omomi);
     if(omomi != -1){
       A[i][j] = omomi;
     } else {
       A[i][j] = Big;
     }
   }
   min[i]  = Big;
   back[i]    = -1;
   used[i] = 0;
 }

 printf("%d\n", prim());
 return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

string s;
cin >> s;
int size = s.length();

    rep(i,size/2){
        if(s[i] != s[size-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,(size/2)/2){
        if(s[i] != s[(size/2)-1-i]){
             cout << "No" << endl;
            return 0;
        }
    }
    for(int  i = size/2+1;i < size/2+1+(size/2)/2;i++){
        if(s[i] != s[size+(size/2)-i]){
             cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define xx return
using namespace std;
int main(){
    int k,ans=0;
    cin>>k;
    for (int i=1; i<=k; i++){
        ans*=10;
        ans+=7;
        ans%=k;
        if (!ans){
            cout<<i;
            return 0;
        }
    }
    cout<<"-1\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<char, char> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n, m;
char a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> n){
		if(n == 0) break;
		Vp v(n);
		rep(i,n) cin >> v[i].fi >> v[i].sec;
		cin >> m;
		rep(i,m){
			cin >> a;
			rep(j,n){
				if(v[j].fi == a){
					a = v[j].sec;
					break;
				}
			}
			cout << a;
		}
		cout << endl;
	}
}

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

using namespace std;

int main()
{
    map <string,int> m;
    int q;
    cin>>q;
    while(q--)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            string key;
            long long x;
            cin>>key>>x;
            m[key]=x;
        }
        else
        {
            string key;
            cin>>key;
            cout<<m[key]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 27700
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    V<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    int sm = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sm += d[i] * d[j];
        }
    }
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

G = []
for _ in range(H):
    g = []
    line = input()
    for i in range(W):
        g.append(line[i])
    G.append(g)

# 左に何マス行けるか
G_left = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W):
        if G[h][w] == "#":
            cnt = 0
            G_left[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_left[h][w] = cnt
# print(G_left)

# 右に何マス行けるか
G_right = [[0] * W for _ in range(H)]
for h in range(H):
    cnt = 0
    for w in range(W - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_right[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_right[h][w] = cnt
# print(G_right)

# 上に何マス行けるか
G_up = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H):
        if G[h][w] == "#":
            cnt = 0
            G_up[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_up[h][w] = cnt
# print(G_up)

# 下に何マス行けるか
G_down = [[0] * W for _ in range(H)]
for w in range(W):
    cnt = 0
    for h in range(H - 1, -1, -1):
        if G[h][w] == "#":
            cnt = 0
            G_down[h][w] = 0
        elif G[h][w] == ".":
            cnt += 1
            G_down[h][w] = cnt
# print(G_down)
ans = 0
for h in range(H):
    for w in range(W):
        tmp = G_left[h][w] + G_right[h][w] + G_up[h][w] + G_down[h][w] - 3
        ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 360792
//====== begin of bisma c++ template===========

        #include <iostream>
        #include <string>
        #include <vector>
        #include <algorithm>
        #include <sstream>
        #include <queue>
        #include <deque>
        #include <bitset>
        #include <iterator>
        #include <list>
        #include <stack>
        #include <map>
        #include <set>
        #include <functional>
        #include <numeric>
        #include <utility>
        #include <limits>
        #include <time.h>
        #include <math.h>
        #include <stdio.h>
        #include <string.h>
        #include <stdlib.h>
        #include <assert.h>
        using namespace std;
        #define rep(a,b,c) for(int a=b;a<=c;a++)
        #define ll long long
        #define sum(a,b) a=a+b
        #define mem(a, b) memset(a, (b), sizeof(a))


int main(){
            
    int a,b;
    cin>>a>>b;
    
    if(a>8 || b>8){
        cout<<":(";
    }else{
        cout<<"Yay!";
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int sum = 0;
    int n, l;
    vector<int> sticks;
    scanf("%d", &n);
    for (int i = 0 ; i < 2 * n; i++) {
        scanf("%d", &l);
        sticks.push_back(l);
    }
    sort(sticks.begin(), sticks.end());
    for (int i = 0 ; i < n; i++) {
        sum += sticks[2 * i];
    }
    printf("%d\n", sum);

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    ll ans=1;
    for (int i = 0; i <n; ++i) {
        ans*=(i+1);
        ans%=mod;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n;
int f[110][10];
int c[110][10];
 
int cnt[110] = {};
 
int dfs(int i){
    if(i == 10){
        int ans = 0;
        int zero = 0;
        for(int j = 0;j < n;j++){
            if(cnt[j] > 0){
                zero++;
            }
        }
        if(zero == 0) return INT_MIN;
 
 
        for(int j = 0;j < n;j++){
            ans += c[j][cnt[j]];
        }
        return ans;
    }
 
    int a1 = dfs(i+1);
 
    for(int j = 0;j < n;j++){
        cnt[j] += f[j][i];
    }
 
    a1 = max(a1, dfs(i+1));
 
    for(int j = 0;j < n;j++){
        cnt[j] -= f[j][i];
    }
 
    return a1;
}
 
 
 
int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 10;j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 11;j++){
            cin >> c[i][j];
        }
    }
 
    cout << dfs(0) << endl;
 
    return 0;
}

Measured memory_bytes: 256
def main():
    s = input()

    ans = 0
    st = []
    for x in s:
        st.append(x)
        if len(st) >= 2:
            if st[-1] != st[-2]:
                st.pop()
                st.pop()
                ans += 2

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <bits/stdc++.h>
const int N = 2e5 + 7;
using namespace std;
int a[N], b[N];
auto main() -> int {
    int n; cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> b[i];
    sort(b + 1, b + 1 + n, greater<int>());
    int l = 1 << 30, r = -1, c = -1;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) {
            l = min(l, i);
            r = max(r, i);
            c = a[i];
        }
    }
    if (c == -1) {
        cout << "Yes\n";
        for (int i = 1; i <= n; ++i) cout << b[i] << " \n"[i==n];
        return 0;
    }
    vector<int> opts;
    for (int i = 1; i <= n; ++i) {
        if (a[i] != c && b[i] != c) {
            opts.emplace_back(i);
        }
    }
    for (int i = l; i <= r; ++i) {
        if (opts.empty()) {
            cout << "No\n";
            return 0;
        }
        auto nxt = opts.back(); opts.pop_back();
        swap(b[i], b[nxt]);
    }
    cout << "Yes\n";
    for (int i = 1; i <= n; ++i) cout << b[i] << " \n"[i==n];


    return 0;
}

Measured memory_bytes: 5872