akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define  int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int dp[85][85][8001];pair<int,int> a[85][85];
int32_t main()
{
    IOS;
    int h,w;
    cin>>h>>w;
    int x,y;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>x;
            a[i][j].first=x;
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>x;
            a[i][j].second=x;
        }
    }
    dp[0][0][abs(a[0][0].first-a[0][0].second)]=1;
    for(int i=0;i<=h;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0&&j==0)
                continue;
            int a1=a[i][j].first,a2=a[i][j].second;
            for(int k=0;k<=8000;k++)
            {
                y=abs(k+a1-a2);
                if(y<=8000&&(((i>=1)&&dp[i-1][j][y])||((j>=1)&&dp[i][j-1][y])))
                {
                    dp[i][j][k]=1;
                }
                y=abs(k+a2-a1);
                if(y<=8000&&(((i>=1)&&dp[i-1][j][y])||((j>=1)&&dp[i][j-1][y])))
                {
                    dp[i][j][k]=1;
                }
            }
        }
    }
    for(int i=0;i<=8000;i++)
        if(dp[h-1][w-1][i])
        {
            cout<<i<<endl;
            return 0;
        }
    return 0;
}


Measured memory_bytes: 430848
#include<iostream>
#include<string>
using namespace std;
#define MAX 2000000
int n,A[MAX+1];

void maxHeap(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;
    
    if(l<= n&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=n&&A[r]>A[largest])largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeap(largest);
    }
}
int extract(){
    int maxv;
    if(n<1)return 0;
    maxv=A[1];
    A[1]=A[n--];
    maxHeap(1);
    return  maxv;
}

void increase(int i,int key){
    if(key<A[i])return;
    A[i]=key;
    while(i>1&&A[i/2]<A[i]){
        swap(A[i],A[i/2]);
        i=i/2;
    }
}

void insert(int key){
    n++;
    A[n]=0;
    increase(n,key);
}

int main(){
    int key;
    char com[10];
    
    while(1){
        cin>>com;
        if(com[0]=='e'&&com[1]=='n')break;
        if(com[0]=='i'){
            cin>>key;
            insert(key);
        }else{
            cout<<extract()<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 6900
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


d=list(map(int,input().split()))

d=sorted(d)
LEN=int(len(d)/2)
if is_even(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])

elif is_odd(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])



Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int lcm(int x, int y)
{
    int a;
    a = (x > y) ? x : y; 
    while (true)
    {
        if (a % x == 0 && a % y == 0)
            return a;
        ++a;
    }
}
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a,b;
	cin>>a>>b;
	ll z=lcm(a,b);
	cout<<z;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m;

int main(){
	cin >> n;
  	if((n-7)*(n-5)*(n-3)) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

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

int main() {
  int n = 0;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) {
      n++;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
/*
本宝的程序别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int s=0, w=1;

	char ch=getchar();

	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
		{
			w=-w;
		}

		ch=getchar();
	}

	while(ch>='0' && ch<='9')
	{
		s=(((s*10ll))+(ch-'0'));

		ch=getchar();
	}

	return s;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	set<string> m;
	
	long long int n, sum=0;
	
	cin>>n;
	
	for(int i=1; i<=n; i++)
	{
		string tmp;
		
		cin>>tmp;
		
		sum++;
		
		if(m.find(tmp)!=m.end())
		{
			sum--;
		}
		else
		{
			m.insert(tmp);
		}
	}
	
	printf("%lld", sum);
	
	return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        String s = in.ns();
        String t = in.ns();
        int min = 10000;
        for (int i = 0; i <= s.length()-t.length(); i++) {
            min = Math.min(min, not_same(s.substring(i, i+t.length()), t));
        }
        out.println(min);
    }
    public static int not_same(String s, String t){
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)!=t.charAt(i)) res++;
        }
        return res;
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 33344
n=int(input())
h = list(map(int,input().split()))
cost = [0] * n
cost[1] = abs(h[1] - h[0])
for i in range(2, n):
  cost[i] = min(abs(h[i]-h[i-1]) + cost[i-1], abs(h[i]-h[i-2]) + cost[i-2])
print(cost[n-1])

Measured memory_bytes: 13928
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2040
# solution

import io

array=[]
for i in range(3):
  array.append(list(map(int, input().split())))

if (array[0][0]+array[1][1]+array[2][2])*3==(sum(array[0])+sum(array[1])+sum(array[2])):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


template<class T> struct BIT {
  int n, h;
  V<T> t;

  BIT(int n) : n(n), h(__lg(n) + 1), t(n + 1, (T) 0) {}

  void add(int x, T a) {
    for (int i = x + 1; i < n + 1; i += i & -i) t[i] += a;
  }

  int lower_bound(T s) {
    if (s <= 0) return 0;
    int res = 0;
    for (int k = 1 << h - 1; k; k >>= 1) if (res + k < n + 1 and t[res + k] < s) s -= t[res += k];
    return res + 1;
  }

  T sum(int x) {
    T res = 0;
    for (int i = x; i; i -= i & -i) res += t[i];
    return res;
  }

  T sum(int l, int r) {
    return sum(r) - sum(l);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> chi(n);
  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    chi[i].resize(k);
    for (int j = 0; j < k; ++j) cin >> chi[i][j];
  }
  V<> a;
  auto dfs = [&](auto dfs, int v) -> void {
    a.push_back(v);
    for (int w : chi[v]) {
      dfs(dfs, w);
      a.push_back(v);
    }
  };
  dfs(dfs, 0);
  V<> l(n, -1), r(n, -1);
  for (int i = 0; i < 2 * n - 1; ++i) {
    if (l[a[i]] == -1) l[a[i]] = i;
    if (r[a[2 * n - 2 - i]] == -1) r[a[2 * n - 2 - i]] = 2 * n - 2 - i;
  }
  BIT<lint> bit(2 * n - 2);
  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int c; cin >> c;
    if (!c) {
      int v, w; cin >> v >> w;
      bit.add(l[v] - 1, w);
      bit.add(r[v], -w);
    } else {
      int v; cin >> v;
      cout << bit.sum(l[v]) << '\n';
    }
  }
}


Measured memory_bytes: 14060
N = int(input())
a= list(map(int , input().split()))


def gcd(a, b):
    if a < b: return gcd(b, a)
    elif b > 0: return gcd(b, a % b)
    else:
        return a

L = [0,a[0]]
R = [0,a[-1]]

for i in range(1,N):
	L.append(gcd(a[i] , L[-1]))
	R.append(gcd(a[-(i+1)] , R[-1]))
gcd_val_list = []
for i in range(N):
	gcd_val_list.append(gcd(L[i] , R[-(i+2)]))
print(max(gcd_val_list))

Measured memory_bytes: 14440
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

S = [n for n in range(1, N+1)]
a = 0
b = 0

for i, p in enumerate(list(permutations(S))):
    if p == P:
        a = i + 1
    if p == Q:
        b = i + 1

print(abs(a-b))


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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ans = 0;
    for i in 1..n - 1 {
        if v[i - 1] < v[i] && v[i] < v[i + 1] || v[i - 1] > v[i] && v[i] > v[i + 1] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

using namespace std;

int main(void){
  int N,i;
  cin >> N;
  pair<pair<string,int>,int> rest[N];
  for(i=0;i<N;i++){
    cin >> rest[i].first.first >> rest[i].first.second;
    rest[i].first.second=-rest[i].first.second;
    rest[i].second=i+1;
  }
  sort(rest,rest+N);
  for(i=0;i<N;i++){
    cout << rest[i].second << endl;
  }
}

Measured memory_bytes: 256
#ABC082C
N=int(input())
a_sorted=sorted(list(map(int,input().split())))
#必要な変数の作成
Allowable_original=0
Allowable_count=0
Delete_count=0
#aが要素1個のみの場合
if N==1:
    if a_sorted[0]==1:
        print(0)
    else:
        print(1)
    exit()
#順番にチェック
for i in range(N):
    #開始処理
    if i==0:
        #許容個数カウントとその元値を作成
        Allowable_original=a_sorted[0]
        Allowable_count=Allowable_original-1
        continue

    #前の数字と同じか否か
    # 同じなら、
    if a_sorted[i]==a_sorted[i-1]:
        #許容個数カウントを一つ減らす
        Allowable_count-=1
    # 違うなら、または末尾なら、
    if a_sorted[i]!=a_sorted[i-1]:
        # 許容個数カウントの現在値が正か0か負かチェック
        # 正なら、
        if Allowable_count>0:
            #カウントしてきた許容個数（許容個数カウントの元値-現在値）を削除対象カウントに追加
            Delete_count+=Allowable_original-Allowable_count
        #0以下なら、
        else:
            # -1をかけた値を削除対象カウントに追加
            Delete_count-=Allowable_count
        # 許容個数カウントとその元値を新規作成
        Allowable_original = a_sorted[i]
        Allowable_count = Allowable_original - 1
    #末尾なら、
    if i==N-1:
        # 許容個数カウントの現在値が正か0か負かチェック
        # 正なら、
        if Allowable_count>0:
            #カウントしてきた許容個数（許容個数カウントの元値-現在値）を削除対象カウントに追加
            Delete_count+=Allowable_original-Allowable_count
        #0以下なら、
        else:
            # -1をかけた値を削除対象カウントに追加
            Delete_count-=Allowable_count
#結果出力
print(Delete_count)

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

template <class T>
inline bool read(T &ret)
{
    char c;
    int sgn;
    if (c = getchar(), c == EOF)
    {
        return 0;
    }
    while (c != '-' && (c < '0' || c > '9'))
    {
        c = getchar();
    }
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0');
    }
    ret *= sgn;
    return 1;
}

template <class T>
inline void write(T x)
{
    if (x > 9)
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}

const int MAXN=21;
int n;
int a[110],b[110];

int main()
{
    cin>>n;
    for(int i=2;i<=n;i++)
        cin>>b[i];
    a[n]=b[n];
    for(int i=n;i>=2;i--)
    {
        a[i-1]=min(b[i],b[i-1]);
    }
    a[1]=b[2];
    int ans=0;
    for(int i=1;i<=n;i++)
    {
//        cout<<a[i]<<" ";
        ans+=a[i];
    }
//    cout<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


H, W = MI()

pieces = H * W


memo = dict()
def divide(h, w):
    if memo.get((h, w)) is not None:
        return memo[(h, w)]
    elif memo.get((w, h)) is not None:
        return memo[(w, h)]
    p = h * w
    if w > 1:
        a1 = w // 2 * h
        a2 = p - a1
        memo[(h, w)] = (a1, a2)
    if h > 1:
        b1 = h // 2 * w
        b2 = p - b1
        if memo.get((h, w)) is not None:
            a1, a2 = memo[(h, w)]
            if abs(a1 - a2) > abs(b1 - b2):
                memo[(h, w)] = (b1, b2)
    return memo[(h, w)]


ans = float('inf')
for i in range(1, W):
    p1 = i * H
    p2, p3 = divide(W - i, H)
    ans = min(ans, max(p1, p2, p3) - min(p1, p2, p3))
for i in range(1, H):
    p1 = i * W
    p2, p3 = divide(H - i, W)
    ans = min(ans, max(p1, p2, p3) - min(p1, p2, p3))
print(ans)


Measured memory_bytes: 62680
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int aa,bb,cc;
    aa=abs(a-b);
    bb=abs(b-c);
    cc=abs(c-a);
    if(aa<=bb&&cc<=bb){
        cout << aa+cc;
    }else if(bb <= aa&&cc<=aa){
        cout << bb+cc;
    }else if(aa<=cc&&bb<=cc){
        cout << aa+bb;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
const ll mod = 998244353;
int n,a[N];
map<int,int>mp;
int ma;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
		ma=max(ma,a[i]);
	}
	if(a[1]||mp[0]>1)
	{
		cout<<0<<endl;
		return 0;
	}
	ll ans=1;
	mp[0]=1;
	for(int i=1;i<=ma;i++)
		for(int j=1;j<=mp[i];j++)
		ans=ans*mp[i-1]%mod;
	cout<<ans<<endl;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int factorial(int n)
{
    if(n == 1)
        return 1;
    return n * factorial(n - 1);
}

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++)
        cin >> x[i] >> y[i];

    vector<int> a(n);
    for(int i = 0; i < n; i++)
        a[i] = i;
    double ans = 0;
    for(int i = 0; i < factorial(n); i++)
    {
        double path = 0;
        for(int i = 0; i < n - 1; i++)
                path += (sqrt(pow(x[a[i]] - x[a[i + 1]], 2) + pow(y[a[i]] - y[a[i + 1]], 2)));
        ans += path;
        next_permutation(a.begin(), a.end());
    }

    cout << fixed << setprecision(10) << ans / factorial(n);

    return 0;
}


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

int main() {
	int s;
	cin >> s;
	int s1 = s % 10;
	int s2 = ((s - s1) / 10) % 10;
	int s3 = ((s - s2 * 10 - s1) / 100) % 10;
	cout << s1 + s2 + s3 << endl;

	return 0;
}

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

int main(){

	string s;
	cin >> s;

	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] == 'C') {
			for (int j = i+1; j < n; j++) {
					if (s[j] == 'F'){
						cout << "Yes\n";
						return 0;
					}
			}
		}
	}
	cout << "No\n";

	return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeMap;



public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int s = sc.nextInt()-1;
		int t = sc.nextInt()-1;

		ArrayList<ArrayList<Edge>> graph = new ArrayList<ArrayList<Edge>>();

		for (int i=0;i<n;i++) {
			graph.add(new ArrayList<Edge>());
		}

		for (int i=0;i<m;i++) {
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			int a = sc.nextInt();
			int b = sc.nextInt();
			Edge e = new Edge();
			e.from=u;
			e.to=v;
			e.yen=a;
			e.snuke=b;
			Edge f = new Edge();
			f.from=v;
			f.to=u;
			f.yen=a;
			f.snuke=b;

			graph.get(u).add(e);
			graph.get(v).add(f);
		}
		long [] yen = new long[n];
		long [] snuke = new long[n];
		TreeMap<Long,Integer> map = new TreeMap<Long, Integer>();
		for(int i=0;i<n;i++) {
			if (i != s) {
				yen[i]=(long)Math.pow(10, 14);

			} else {
				yen[i]=0;
			}
			map.put(yen[i]*n-Long.MAX_VALUE+i, i);
		}


		while (!map.isEmpty()) {
			int node = map.firstEntry().getValue();
			map.remove(map.firstEntry().getKey(), node);
			for (Edge e:graph.get(node)) {
				int toNode = e.to;
				if (yen[toNode] > yen[node]+e.yen && map.containsKey(yen[toNode]*n-Long.MAX_VALUE+toNode)) {
					map.remove(yen[toNode]*n-Long.MAX_VALUE+toNode, toNode);
					yen[toNode] = yen[node]+e.yen;
					map.put(yen[toNode]*n-Long.MAX_VALUE+toNode, toNode);
				}
			}
		}


		map = new TreeMap<Long, Integer>();
		for(int i=0;i<n;i++) {
			if (i != t) {
				snuke[i]=(long)Math.pow(10, 14);

			} else {
				snuke[i]=0;
			}
			map.put(snuke[i]*n-Long.MAX_VALUE+i, i);
		}

		while (!map.isEmpty()) {
			int node = map.firstEntry().getValue();
			map.remove(map.firstEntry().getKey(), node);
			for (Edge e:graph.get(node)) {
				int toNode = e.to;
				if (snuke[toNode] > snuke[node]+e.snuke && map.containsKey(snuke[toNode]*n-Long.MAX_VALUE+toNode)) {
					map.remove(snuke[toNode]*n-Long.MAX_VALUE+toNode, toNode);
					snuke[toNode] = snuke[node]+e.snuke;
					map.put(snuke[toNode]*n-Long.MAX_VALUE+toNode, toNode);
				}
			}
		}

		long min = Long.MAX_VALUE;
		long[] ans = new long[n];
		for (int i=n-1;i>=0;i--) {
			min = Math.min(yen[i]+snuke[i], min);
			ans[i] = min;
		}
		for (int i=0;i<n;i++) {
			System.out.println((long)Math.pow(10, 15)-ans[i]);
		}

	}



}


class Edge {
	int from;
	int to;
	long yen;
	long snuke;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;

    vector<int> pos_r, pos_s, pos_p;
    rep(i, N) {
        if (T[i] == 'r') pos_r.push_back(i);
        if (T[i] == 's') pos_s.push_back(i);
        if (T[i] == 'p') pos_p.push_back(i);
    }

    llong ans = 0;
    int n;

    n = (int)pos_r.size();
    vector<bool> check1(n, true);
    if (n == 1) {
        ans += P;
    } else {
        rep(i, n) {
            if (!check1[i]) continue;
            ans += P;
            int pos = lower_bound(pos_r.begin(), pos_r.end(), pos_r[i] + K) - pos_r.begin();
            if (pos_r[pos] == pos_r[i] + K) {
                check1[pos] = false;
            }
        }
    }

    n = (int)pos_s.size();
    vector<bool> check2(n, true);
    if (n == 1) {
        ans += R;
    } else {
        rep(i, n) {
            if (!check2[i]) continue;
            ans += R;
            int pos = lower_bound(pos_s.begin(), pos_s.end(), pos_s[i] + K) - pos_s.begin();
            if (pos_s[pos] == pos_s[i] + K) {
                check2[pos] = false;
            }
        }
    }

    n = (int)pos_p.size();
    vector<bool> check(n, true);
    if (n == 1) {
        ans += S;
    } else {
        rep(i, n) {
            if (!check[i]) continue;
            ans += S;
            int pos = lower_bound(pos_p.begin(), pos_p.end(), pos_p[i] + K) - pos_p.begin();
            if (pos_p[pos] == pos_p[i] + K) {
                check[pos] = false;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B = map(int, input().split())
    print(A * B)


if __name__ == "__main__":
    main()


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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    int cnt = 0;
    std::sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(a[i] + a[j] > a[k])cnt++;
            }
        }
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop for(;;)
typedef std::vector<long> LI;
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename W>
struct N008 {
   typedef std::vector<long> LI;
   typedef std::vector<W>    LW;
   long n, e;
   const LI &ss, &ds;
   const LW &ws;
   std::vector<LI> fi;
   std::vector<LI> ri;
   N008(long n_, const LI& ss_, const LI& ds_, const LW& ws_)
      : n(n_), e(ss_.size()), ss(ss_), ds(ds_), ws(ws_) {
      ri.resize(n+1);
      fi.resize(n+1);
      for(long i = 0; i < e; ++i) {
         fi[ss[i]].push_back(i);
         ri[ds[i]].push_back(i);
      }
   }
};

template<typename W>
struct N013 {
   std::vector<W> xs;
   N013(const N008<W>& g, long s, W inf) : xs(g.n+1, inf) {
      std::priority_queue<std::pair<W, long>> q;
      q.push(std::make_pair(0, s));
      while( not q.empty() ) {
         W d2; long i;
         std::tie(d2, i) = q.top(); q.pop();
         W d = -d2;
         if( not ( d < xs[i] ) ) continue;
         xs[i] = d;
         for(long k : g.fi[i]) {
            W nd = d + g.ws[k];
            if( not ( nd < xs[g.ds[k]] ) ) continue;
            q.push(std::make_pair(-nd, g.ds[k]));
         }
      }
   }
};


struct Solver {
   void solve() {
      double inf = (1LL << 50);
      long n, m, p, a, b; scan(n, m, p, a, b);
      if( not ( n | m | p | a | b ) ) exit(0);
      a -= 1; b -= 1;
      LI ts(n); for(long &t : ts) scan(t);
      LI xs(p), ys(p), zs(p);
      for(long i = 0; i < p; ++i) {
         long x, y, z; scan(x, y, z);
         x -= 1; y -= 1;
         xs[i] = x; ys[i] = y; zs[i] = z;
      }
      LI ss, ds;
      std::vector<double> ws;
      for(long i = 0; i < (1LL << n); ++i) {
         for(long k = 0; k < n; ++k) {
            if( (i & (1LL << k)) != 0 ) continue;
            for(long u = 0; u < p; ++u) {
               {
                  long from = i * 32 + xs[u];
                  long to = (i | (1LL << k)) * 32 + ys[u];
                  ss.push_back(from);
                  ds.push_back(to);
                  ws.push_back((double)zs[u] / ts[k]);
               }
               {
                  long from = i * 32 + ys[u];
                  long to = (i | (1LL << k)) * 32 + xs[u];
                  ss.push_back(from);
                  ds.push_back(to);
                  ws.push_back((double)zs[u] / ts[k]);
               }
            }
         }
      }
      N008<double> graph(256*32, ss, ds, ws);
      N013<double> dijkstra(graph, a, inf);
      double res = inf;
      for(long i = 0; i < (1LL << n); ++i) {
         res = std::min(res, dijkstra.xs[i*32+b]);
      }
      if( res > inf / 2 ) puts("Impossible");
      else printf("%.20lf\n", res);
   }
};

int main() {
   loop std::shared_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 58496
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   string s;
   cin>>s;

   if(s.back() == 's')
   		s.append("es");
   else
   	s.push_back('s');

   cout<<s;
   return 0;
}

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

int main(){
	int N;
    cin>>N;
	vector<int> a(N),b(N);
	for(int i=0;i<N;i++){
		//www
		cin>>a.at(i)>>b.at(i);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	cout<<a.at(N-1)+b.at(N-1)<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	string str,p;
	cin >> str >> p;
	int size1 = str.size();
	int size2 = p.size();
	
	for (int i=0; i<size1; i++) {
		int j;
		for (j=i; j<i+size2; j++) {
			if (str[j] != p[j-i]) {
				break;
			}
		}
		if (j == i+size2) {
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define ll long long
//#define int long long
using namespace std;
void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void free()
{
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
}
main()
{
	//free();
	boost();
	int x1 = 0, y1 = 0;
	int x = 0, y = 0;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'N') x = 1;
		if(s[i] == 'S') y = 1;
		if(s[i] == 'E') x1 = 1;
		if(s[i] == 'W') y1 = 1;
	}
	//cout << x << " " << y << " " << x1 << " " << y1 << endl;
	if(x == 1 && y == 0 || y == 1 && x == 0 || x1 == 1 && y1 == 0 || x1 == 0 && y1 == 1) cout << "No";
	else cout << "Yes", exit(0);
}


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

int main() {
	int n,cR=0,cB=0;
	cin>>n;
	while(n--)
	{
	    char s;
	    cin>>s;
	    if(s=='R')
	    cR++;
	    else
	    cB++;
	}
	if(cR>cB)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define Max(x,y) ((x>y)?x:y)
int comp(const void *p,const void *q){
	return *(int *)q-*(int *)p;
}
int i,j,n,a,b,c,p[105],ans,x,y;
int main(){
	ans=0;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	for(i=0;i<n;i++)scanf("%d",&p[i]);
	qsort(p,n,sizeof(int),comp);
	x=a;y=c;
	ans=y/x;
	for(i=0;i<n;i++){
		x+=b;
		y+=p[i];
		ans=Max(ans,y/x);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll func(ll a,ll b,ll c)
{
	return max(max(a,b),max(b,c));
}
int main()
{
	ll a,b;
  cin>>a>>b;
  cout<<func(a-b,a+b,a*b)<<endl;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}
signed main()
{
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    vector<int> c;
    int count = 1;
    rep(i, S.length())
    {
        if (i == 0)
        {
            continue;
        }
        if (S[i - 1] != S[i])
        {
            c.push_back(count);
            count = 1;
        }
        else
        {
            count++;
        }
    }
    c.push_back(count);
    sort(c.begin(), c.end(), greater<int>());
    if ((c[2] == c[1] && ((c[0] - c[1]) < 2)) || (c[1] == c[0] && c[1] == c[2] + 1))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int t[100000];
int main(){
	int n,q,ans=0;;

	cin>>n;
	for(int i=0;i<n;i++)cin>>t[i];
	cin>>q;
	int tmp;
	bool x;
	for(int i=0;i<q;i++){
		cin>>tmp;
		x=0;
		for(int j=0;j<n;j++)if(t[j]==tmp)x=1;
		ans+=x;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1204
#!/usr/bin/ruby
def vec_product(a,b)
	a.zip(b).reduce(0){|s,(x,y)|s+x*y}
end
def matrix_mul(a,_b)
	b=_b.transpose
	a.size.times.map{|i|
		b.size.times.map{|j|
			vec_product(a[i],b[j])
		}
	}
end
n,m=gets.split.map(&:to_i)
matrix_mul(*[n,m].map{|e|e.times.map{gets.split.map(&:to_i)}}).each{|e|puts e*' '}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

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

  int N,K;
  cin >> N >> K;

  int ans = 1;
  REP(N){
    if((ans * 2) < (ans + K)) {
      ans *= 2;
    }
    else {
      ans += K;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int N = 1e5;

int n, k, h[N + 1], dp[N + 1];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	for (int i = 2; i <= N; ++i)
		dp[i] = INT_MAX;

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		scanf("%d", h + i);

	dp[2] = abs(h[2] - h[1]);
	for (int i = 1; i < n; ++i)
		for (int j = 1; j <= k && i + j <= n; ++j)
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));

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


Measured memory_bytes: 4440
S = input()[:-1]

while True:
    s_len = len(S)
    if s_len % 2 == 0:
        if S[:s_len//2] == S[s_len//2:]:
            print(s_len)
            break
        else:
            S = S[:-2]
    else:
        S = S[:-1]


        


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

typedef long long ll;

int last_ans[2019];
int last_ans_aux[2019];
string s;
ll ans = 0;

void calculate(int pos) {
  int d = s[pos] - '0';
  if (pos == 0){
    last_ans[d] = 1;
    return;
  }
  calculate(pos - 1);
  for (int i = 0; i < 2019; i++) {
    if (last_ans[i] > 0) {
      int res = (10 * i + d) % 2019;
      if (res == 0) {
        ans += last_ans[i];
      }
      last_ans_aux[res] += last_ans[i];
    }
  }
  last_ans_aux[d] += 1;
  for (int i = 0; i < 2019; i++) {
    last_ans[i] = last_ans_aux[i];
    last_ans_aux[i] = 0;
  }
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  int len = s.size();
  calculate(len - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9944
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a,b,fa[100000][18],depth[100000],x,y,m;
vector<ll> v[100000];
void dfs(ll a,ll cnt){
    depth[a]=cnt;
    for(ll z:v[a]){
        fa[z][0]=a;
        dfs(z,cnt+1);
    }
    return ;
}
P d(ll a,ll b){
    if(depth[a]==depth[b])return {a,b};
    if(depth[a]<depth[b])swap(a,b);
    //cout<<a<<" "<<b<<endl;
    for(int i=17;i>=0;i--){
        if(fa[a][i]!=-1&&depth[fa[a][i]]>depth[b])return d(fa[a][i],b);
        //cout<<depth[fa[a][i]]<<" "<<depth[b]<<endl;
    }
    //cout<<"W"<<a<<b<<endl;
    return {fa[a][0],b};
}
ll d2(ll a,ll b){
    if(a==b)return a;
    for(int i=17;i>=0;i--){
        if(fa[a][i]!=-1&&fa[a][i]!=fa[b][i])return d2(fa[a][i],fa[b][i]);
    }
    return fa[a][0];
}
int main(void){
    cin>>n;
    for(int i=0;i<18;i++)fa[0][i]=-1;
    for(int i=0;i<n;i++){
        cin>>a;
        while(a--){
            cin>>b;
            v[i].push_back(b);
        }
    }
    dfs(0,0);
    
    for(int i=1;i<18;i++){
        for(int j=0;j<n;j++){
            int L=i;
            int LL=j;
            while(L){
                if(fa[LL][L-1]==-1){
                    fa[j][i]=-1;
                    break;
                }
                LL=fa[LL][L-1];
                L--;
            }
            if(fa[j][i]==0)fa[j][i]=fa[LL][0];
        }
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        P q=d(a,b);
        //cout<<q.first<<" "<<q.second<<endl;
        cout<<d2(q.first,q.second)<<endl;
    }
}



Measured memory_bytes: 28000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;

vector<int> to[200005];
int ans[200005];
bool used[200005];


void bfs (int x) {
    queue<int> q;
    q.push(x);
    used[x] = true;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int e: to[now]) {
            if (used[e]) continue;
            used[e] = true;
            q.push(e);
            ans[e] = now;
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    bfs(0);

    
    rep(i, n) {
        if (!used[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i, n) {
        if (i==0) continue;
        cout << ans[i]+1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 12860
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,a,b,t,ans=0;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&t);
		if(t<a||t>=b)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, K;
	cin >> N >> K;
	vector<int> D(K);
	rep(i, K)cin >> D[i];
	for (int i = N;; i++) {
		auto s = to_string(i);
		bool f = 1;
		for (auto x : s) {
			rep(j, K) {
				if (x - '0' == D[j]) {
					f = 0;
				}
			}
		}
		if (f) {
			cout << s << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static final int INF = Integer.MAX_VALUE / 2;

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int A = sc.nextInt();

        _out.println((N * N - A));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f,sato=0,satomizu=0;
  double ans=0;
  cin >>a >>b >>c >>d >>e >>f;
  for (int i=0;i<=f/(100*a);i++)
    for (int j=0;j<=f/(100*b);j++)
      for (int k=0;k<=f/c;k++)
        for (int l=0;l<=f/d;l++){
          if(i*a+j*b>0){
            int x=i*a*100+j*b*100;
            if(k*c+l*d>=0){
              int y=k*c+l*d;
              if(x+y<=f && x*e>=y*100){
                double ansa=double(y)/double(x);
                if (ans<=ansa){
                  ans=ansa;
                  satomizu=x+y;
                  sato=y;
                }
              }
            }
          }
        }
  cout << satomizu <<" "<< sato <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string a, b;
    cin >> a >> b;
    
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    
    if (a < b) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
static const int a = 20000;
static const int b = 20000;

int main(){
	int a,b,c;
	char op;
	
	while(1){
		cin >> a;
		cin >> op;
		cin >> b;
		if(op == '+'){
			c=a+b;
			cout<<c<<endl;
		}
		if(op == '-'){
			c=a-b;
			cout<<c<<endl;
		}
		if(op == '*'){
			c=a*b;
			cout<<c<<endl;
		}
		if(op == '/'){
			c=a/b;
			cout<<c<<endl;
		}
		if(op == '?') break;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int r, g, b; cin >> r >> g >> b;
  string result;
  if ((g*10+b)%4==0) result = "YES"; 
  else result = "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#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 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 sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
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<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
int n,l;
cin>>n>>l;
vstr s(n);
vint a(n);
rep(i,n){
cin>>s[i];
}
sort(a);
sort(s);
rep(i,n){
cout<<s[i];
}
cout<<rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 256