akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

bool Visitable[105][105];

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

    int V, E;
    cin >> V >> E;
    constexpr ll inf = 1e+15;
    vector<vector<ll>> dp(V, vector<ll>(V, inf));
    vector<tuple<int, int, int>> es;
    for(int i = 0; i < E; ++i){
        int s, t, d;
        cin >> s >> t >> d;
        dp[s][t] = d;
        Visitable[s][t] = true;
        es.emplace_back(s, t, d);
    }

    vector<ll> dist(V, 0);
    for(int i = 0; i < V; ++i){
        bool update = false;
        for(auto tup : es){
            int s, t, d;
            tie(s, t, d) = tup;
            if(chmin(dist[t], dist[s] + d)) update = true;
        }
        if(i == V - 1 && update){
            cout << "NEGATIVE CYCLE\n";
            return 0;
        }
    }

    for(int i = 0; i < V; ++i){
        dp[i][i] = 0;
        Visitable[i][i] = true;
    }
    for(int k = 0; k < V; ++k){
        for(int i = 0; i < V; ++i){
            for(int j = 0; j < V; ++j){
                chmin(dp[i][j], dp[i][k] + dp[k][j]);
                Visitable[i][j] |= Visitable[i][k] & Visitable[k][j];
            }
        }
    }
    
    for(int i = 0; i < V; ++i){
        for(int j = 0; j < V; ++j){
            if(Visitable[i][j]) cout << dp[i][j];
            else    cout << "INF";
            cout << ((j == V - 1) ? '\n' : ' ');
        }
    }
}


Measured memory_bytes: 3440
N = int(input())
H = [i for i in map(int,input().split())]
for i in range(N-1):
    if H[i+1] == H[i]:
        continue
    if H[i+1] > H[i]:
        H[i+1] -= 1 
        continue
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 14396
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

struct UnionFind {
	UnionFind(size_t size){
        for(int i = 0;i < (int)size;i++){
            par.emplace_back(i);
            rnk.emplace_back(0);
        }
    }
	vector<int> par, rnk;

    int find(int x){
        if(par[x] == x)return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        if(rnk[x] < rnk[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rnk[x] == rnk[y])rnk[x]++;
        }
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

int n, m;
int x, y, z;

int main(){
    cin >> n >> m;
    UnionFind uf(n);

    REP(i, m){
        cin >> x >> y >> z;
        x--, y--;
        uf.unite(x, y);
    }
    set<int> st;
    REP(i, n){
        st.insert(uf.find(i));
    }
    cout << (int)st.size() << endl;
}

Measured memory_bytes: 5748
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int N=sc.nextInt();
            if(N==0) break;
            int A[]=new int[N];
            for(int i=0;i<N;i++) A[i]=sc.nextInt();
            Arrays.sort(A);
            int sum=0;
            for(int i=1;i<N-1;i++) sum+=A[i];
            int rem=sum%(N-2);
            sum-=rem;
            System.out.println(sum/(N-2));
        }
    }
}


Measured memory_bytes: 28860
N, K = map(int, input().split())
A = list(map(int, input().split()))
len_arr = len(A)
i = 0
ans = 0
while True:
    if i == 0:
        len_arr -= K
    else:
        len_arr -= (K - 1)
    i += 1
    ans += 1
    if len_arr <= 0:
        break
print(ans)


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

int n;

int check(long long n)
{
    bool f1, f2, f3;
    f1 = f2 = f3 = false;

    for (; n; n /= 10) {
        int t = n % 10;
        f1 |= t == 3;
        f2 |= t == 5;
        f3 |= t == 7;
    }

    return f1 && f2 && f3;
}
int dfs(long long x) {
    if (x > n) return 0;

    int ret = check(x);
    ret += dfs(10 * x + 3);
    ret += dfs(10 * x + 5);
    ret += dfs(10 * x + 7);

    return ret;
}
int main()
{
    cin >> n;

    cout << dfs(0) << endl;

    return 0;
}


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

int main() {
    ll x;
    cin>>x;
    ll a=100;
    ll n=0;
    while(x>a){
        ll add=a*0.01;
        a+=add;
        n++;
    }
    cout<<n<<endl;
}



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

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

#define  ff           first
#define  ss           second
#define  pb           push_back
#define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D(x)         cout << #x << " - " << x << endl;
#define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
#define  all(x)       (x).begin(), (x).end()
#define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)
#define  sz(x)		  x.size();

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll MAXN = 1e6 + 4;


void solve(){
 	int x;
 	cin >> x;
    if(x>=400 && x<=599){
    	cout << 8;
    }
    else if(x>=600 && x<=799){
    	cout << 7;
    }
    else if(x>=800 && x<=999){
    	cout << 6;
    }
    else if(x>=1000 && x<=1199){
    	cout << 5;
    }
    else if(x>=1200 && x<=1399){
    	cout << 4;
    }
    else if(x>=1400 && x<=1599){
    	cout << 3;
    }
    else if(x>=1600 && x<=1799){
    	cout << 2;
    }
    else if(x>=1800 && x<=1999){
    	cout << 1;
    }
}

int main(){
  IOS
     solve();
     cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    int N,A,B; cin>>N>>A>>B;
    int ans = 0;
    rep(i,N+1){
        int sum = 0;
        string s = to_string(i);
        rep(j,s.length()) sum += s[j] - '0';
        if(A <= sum and sum <= B) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;


/**
 * ABC155
 */
public class Main {

	public static void main(String[] args) throws Exception {
		Main main = new Main();

		try (Scanner scan = new Scanner(System.in)) {
			main.paperPlease(scan);
		}
	}

	private void paperPlease(Scanner scan) {
		int n = scan.nextInt();
		System.out.println(IntStream.range(0, n)
			.map(i -> scan.nextInt())
			.allMatch(i -> i % 2 != 0 || i % 3 == 0 || i % 5 == 0) ? "APPROVED" : "DENIED");
	}

	@SuppressWarnings("unused")
	private void poor(Scanner scan) {
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if (a == b) {
			if (b == c){
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		} else if (a == c) {
			System.out.println("Yes");
		} else if (b == c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	@SuppressWarnings("unused")
	private static class Pair<T1, T2> {

		private T1 left;
		private T2 right;

		public Pair(T1 left, T2 right) {
			this.left = left;
			this.right = right;
		}

		public T1 left() {
			return left;
		}

		public T2 right() {
			return right;
		}
	}


	@SuppressWarnings("unused")
	private static class UnionFindTree {
		private List<Integer> parents;

		public static UnionFindTree initialize(int n) {
			return new UnionFindTree(n);
		}

		public UnionFindTree(int n) {
			parents = IntStream.range(0, n).boxed().collect(Collectors.toCollection(() -> new ArrayList<>()));
		}

		public int find(int index) {
			if (index == parents.get(index)) {
				return index;
			}
			// 自分の親の親は自分の親とできるため経路圧縮
			parents.set(index, find(parents.get(index)));
			return parents.get(index);
		}

		public void union(int x, int y) {
			int xParent = find(x);
			int yParent = find(y);
			parents.set(yParent, xParent);
		}

		public long size() {
			return parents.stream().map(i -> find(i)).distinct().count();
		}
	}

}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];

        var min = n;
        n %= k;
        min = Math.Min(min, n);
        min = Math.Min(min, -n + k);

        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 ll ans = 0; int n; cin >> n;
 for(int j = 1;j <= n;j++) {
   int k = n/j;
   ans += j*1LL*(k+1)*k/2;
 }
 cout << ans << endl;

 return 0;
}


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

int main(){
    long n,k;cin>> n>> k;
    
    if(n > k) n = n%k;
    
    long ans = n;

    while(1){
        n = abs(n - k);

        if(n < ans){
            ans = n;
        }else{
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int k, s;

int main() {
    cin >> k >> s;
    int res = 0;
    for (int a = 0; a <= k; a++) {
        for (int b = 0; b <= k; b++) {
            int c = s - a - b;
            if (c >= 0 && c <= k) res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
s=gets.chomp.chars.map(&:to_i).select{|x|x>0}
k=gets.to_i

t1 = t0 = s[0]

while (s[0] == 1) && (k > 1)
  t1 = t0
  t0 = s.shift
  k-=1
end
p s[0]? s[0] : t1

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll d = gcd(a, b);
    if (d == 1){
        cout << 1 << endl;
        return 0;
    }
    ll ans = 1, now = d, i = 2;
    while (now > 1)
    {
        if (now % i == 0)
        {
            ++ans;
            while (now % i == 0)
            {
                now /= i;
            }
        }
        ++i;
        if (i*i >= d)
            break;
    }
    if (now > 1) ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product
n,k = map(int, input().split())
d = list(map(int, input().split()))

nums = []
for i in range(10):
  if i not in d: nums.append(i)

m = str(n)
for i in range(len(m), len(m)+2):
  for j in product(nums, repeat=i):
    ans = ""
    for k in j: ans += str(k)
    if int(ans) >= n:
      print(ans)
      exit()

Measured memory_bytes: 8964
N, M = map(int, input().split())
result = [0] * N

for i in range(M):
    s,c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    if result[s-1] != 0 and result[s-1] != c:
        print(-1)
        exit()
    else:
        result[s-1] = c

if len(result) >= 2 and result[0] == 0:
    result[0] = 1

print("".join(map(str, result)))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
const int MOD = 1000000007;
const int BUF = 200005;


int add(int a, int b) {
    return (a + b) % MOD;
}

int sub(int a, int b) {
    return (a + MOD - b) % MOD;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}


int modpow(int p, int n) {
    if (n == 0) return 1;
    int t = modpow(p, n / 2);
    return n % 2 == 0 ? mul(t, t) : mul(p, mul(t, t));
}


int nNum, cost[BUF];

void read() {
    cin >> nNum;
    for (int i = 0; i < nNum; ++i) {
        cin >> cost[i];
    }
    sort(cost, cost + nNum);
}


void work() {
    int sum = 0;
    for (int i = 0; i < nNum; ++i) {
        sum = add(sum, mul(cost[i], add(modpow(2, nNum - 1), mul(modpow(2, nNum - 2), nNum - i - 1))));
    }
    cout << mul(sum, modpow(2, nNum)) << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
M = 10 ** 9 + 7
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    ans = []
    for i, a in enumerate(arr):
        for j in range(a[1]):
            ans.append(a[0])
    return ans
val = 1
if n == 1:
    print(1)
    exit()
ans = 1
ary = []
for i in range(2,n+1):
    ary.extend(factorization(i))
import collections
cnt = collections.Counter(ary).most_common()
for j, tmp in enumerate(cnt):
    ans *= tmp[1] + 1
    ans %= M

print(ans)


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

namespace Diverta2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split();
            int n = int.Parse(strs[0]);
            int k = int.Parse(strs[1]);

            Console.WriteLine("{0}", n - k + 1);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
using namespace std;
typedef pair<int,int> P;
struct edge{
	int to,cost,money;
};
vector<edge> G[10005];
int d[10005];
int ans;
void dij(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	memset(d,0x3f,sizeof(d));
	d[s]=0;
	que.push(P(0,s));
	while(que.size()){
		P p = que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first)
			continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
int main()
{
	int N,M;
	cin>>N>>M;
	while(N||M){
		for(int i=0;i<M;i++){
			int v;
			edge e;
			cin>>v>>e.to>>e.cost>>e.money;
			G[v].push_back(e);
			swap(e.to,v);
			G[v].push_back(e);
		}
		ans=0;
		dij(1);
		for(int i=2;i<=N;i++){
            int temp=0x3f3f3f3f;
            for(int j=0;j<G[i].size();j++)
            {
                if(d[G[i][j].to]+G[i][j].cost==d[i])
					temp=min(temp,G[i][j].money);
            }
            ans+=temp;
        }
		cout<<ans<<endl;
		for(int i=1;i<=N;i++){
			G[i].clear();
		}
		cin>>N>>M;
	}
	return 0;
}


Measured memory_bytes: 5080
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int N,K,Q,num;
	int points[100000] = {0};
	cin >> N >> K >> Q;
	rep(i, Q){
		cin >> num;
		points[num-1]++;
	}
	rep(i, N){
		if(0 >= K - Q + points[i] ) cout << "No";
		else cout << "Yes";
		cout << endl;
	}
}

Measured memory_bytes: 1024
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong()

  def solve(n: Long): String = {
    if (n == 0) {
      ""
    } else {
      s"${solve((n - 1) / 26)}${('a' + ((n - 1) % 26)).toChar}"
    }
  }

  println(solve(n))
}


Measured memory_bytes: 55252
#include <cstdio>
#include <unordered_map>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
 
typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))
 
 ll po(char u){
  string alp = "abcdefghijklmnopqrstuvwxyz";
  REP(i,26){
    if(u==alp[i])return 2<<i;
  }
  return 0;
}
 
 
int main(){
  ll N; 
  cin >> N;
  string s[100000]; 
 
  ll p = 0;

  unordered_map<string,ll> b;

  REP(i,N){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    p+=b[s[i]];
    b[s[i]]++;
  }
  cout << p << endl;
}


Measured memory_bytes: 17700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double, int>;

int main() {
    int a, b;
    while(cin >> a >> b) {
        int g = __gcd(a, b);
        cout << g << ' ' << a / g * b << endl;
    }
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	string s; cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='?') s[i] = 'D';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3784
n, a, b = map(int, input().split())
S = input()
cnt = 0
no = 0
for i in range(n):
    if S[i] == 'a':
        if cnt < a+b:
            print('Yes')
            cnt += 1
        else:
            print('No')
    if S[i] == 'b':
        no += 1
        if cnt < a+b and no <= b:
            print('Yes')
            cnt += 1
        else:
            print('No')
    if S[i] == 'c':
        print('No')


Measured memory_bytes: 4244
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  long long x;
  cin >> x;
  long long a = 100;
  for (int i = 1; ; i++) {
    a = (long long) (1. * a * 1.01);
    if (a >= x) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin>>x;
    if(x%7==1)
    cout<<"fri"<<endl;
    if(x%7==2)
    cout<<"sat"<<endl;
    if(x%7==3)
    cout<<"sun"<<endl;
    if(x%7==4)
    cout<<"mon"<<endl;
    if(x%7==5)
    cout<<"tue"<<endl;
    if(x%7==6)
    cout<<"wed"<<endl;
    if(x%7==7)
    cout<<"thu"<<endl;
    if(x%7==0)
    cout<<"thu"<<endl;
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int H,W;
    cin>>H>>W;

    if(H==1||W==1){
        cout<<1<<endl;
    }
    else{
        cout<<(H * W + 1) / 2<<endl;
    }
}

Measured memory_bytes: 3596
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
n = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

ans = [0 for i in range(n)]
for i in range(len(a)):
    ans[a[i]-1] += 1

for i in range(len(ans)):
    print(ans[i])



    


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

const long long int MAX = 1<<30;

int main(void){
    bitset<MAX> flag;
    int n, a;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a;
        flag[a]=!flag[a];
    }
    cout << flag.count() << endl;
    return 0;
}


Measured memory_bytes: 131328
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<char,int>P;
int main(){
	int n;
	cin>>n;
	while(n--){
		vector<P>v;
		char c[9];
		int a[9],b[3][9]={},f=0;
		r(i,9)cin>>a[i];
		r(i,9)cin>>c[i];
		r(i,9)v.push_back(P(c[i],a[i]));
		sort(v.begin(),v.end());
		if(v[0].first!=v[2].first||v[3].first!=v[5].first||v[6].first!=v[8].first){
			cout<<0<<endl;
			f++;
		}
		if(!f){
		vector<int>vv[3];
		r(i,9){
			if(c[i]=='R')vv[0].push_back(a[i]);
			if(c[i]=='G')vv[1].push_back(a[i]);
			if(c[i]=='B')vv[2].push_back(a[i]);
		}
		r(j,3)r(i,(int)vv[j].size()-3){
			if(vv[j][i]==vv[j][i+1]&&vv[j][i]==vv[j][i+2]){
				r(k,3)vv[j].erase(vv[j].begin()+i);
			}
		}
		r(j,3)r(i,vv[j].size()){
			if(j==0)b[0][vv[j][i]]++;
			if(j==1)b[1][vv[j][i]]++;
			if(j==2)b[2][vv[j][i]]++;
		}
		r(i,3)r(j,9)b[i][j]=b[i][j]%3;
		r(i,3)r(j,9)if(b[i][j]){
			if(!b[i][j+1]||!b[i][j+2])goto L2;
			b[i][j]--;
			b[i][j+1]--;
			b[i][j+2]--;
			j--;
		}
		cout<<1<<endl;
		if(0){L2:;cout<<0<<endl;}}
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n),b(n),c(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    for(ll i=0;i<n;i++) cin >> b[i];
    for(ll i=0;i<n;i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    vector<ll>bc(n+1,0);
    for(ll i=0;i<n;i++){
        auto ite=upper_bound(c.begin(),c.end(),b[i]);
        bc[i+1]=c.end()-ite;
    }
    for(ll i=1;i<n+1;i++){
        bc[i]+=bc[i-1];
    }
    for(ll i=0;i<n;i++){
        auto ite1=upper_bound(b.begin(),b.end(),a[i]);
        ll x=ite1-b.begin();
        ans+=bc[n]-bc[x];
    }
    cout << ans << endl;
}

Measured memory_bytes: 6408
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int prime_list[55555+1];
  prime_list[0] = 0;
  prime_list[1] = 0;
  for (int i = 2; i <= 55555; i++) {
    prime_list[i] = 1;
  }
  for (int i = 2; i <= 55555; i++) {
    if (prime_list[i] == 1) {
      for (int j = 2; i*j <= 55555; j++) {
        prime_list[i*j] = 0;
      }
    }
  }
  for (int i = 2; i <= 55555; i++) {
    if (i%5 != 1) {
      prime_list[i] = 0;
    }
  }
  int count = 0;
  for (int i = 2; i <= 55555; i++) {
    if (prime_list[i] == 1) {
      printf("%d", i);
      count++;
      if (count == n) {
        printf("\n");
        break;
      } else {
        printf(" ");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 384
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int ans = 0;
		int min = 10;
		int trg = 0;

		for (int i = 0; i < 5; i++) {
			int X = sc.nextInt();
			if ((X - 1) % 10 < min) {
				trg = X;
				min = (X - 1) % 10;
			}
			if (X % 10 == 0) {
				ans += X;
			} else {
				ans += (X / 10) * 10 + 10;
			}
		}

		if (trg % 10 == 0) {
			ans -= trg;
		} else {
			ans -= (trg / 10) * 10 + 10;
		}
		ans += trg;
		sc.close();

		System.out.println(ans);
	}
};


Measured memory_bytes: 35664
W = list(input())
N = int(input())

for i in range(N):
    command,a,b,*c = input().split()
    a= int(a) ; b= int(b)
    if command == 'print':
        print(*W[a:b+1],sep='')
    elif command == 'reverse':
        W[a:b+1] = reversed(W[a:b+1])
    else:
        W[a:b+1] = c[0]


Measured memory_bytes: 5732
#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(i,x,y) for(int i=(x);i<=(y);++i)
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 1000000007
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less_equal<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;


int p(int d[],int n)
{
    int c[n+5];
    int pos=0;
    for(int i=1;i<=n;++i)
    {
        c[i]=i;
    }
    do
    {
        ++pos;
        int flag=1;
        for(int i=1;i<=n;++i)
        {
            if(d[i]!=c[i])
            {
                flag=0;
                break;
            }
        }
        if(flag)
        {
            return pos;
        }
    }
    while(next_permutation(c+1,c+n+1));
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[n+5],b[n+5];
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&b[i]);
    }
    int x=p(a,n);
    int y=p(b,n);
    printf("%d",abs(x-y));
    return 0;
}



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

using namespace std;

int main(){
  	int N;
  	cin >> N;
  	vector<int> H(N);
  	vector<int> cnt(N);
  	for(int i = 0; i < N; i++){
    	cin >> H[i];
    }
  	
  	for(int i = 0; i < N; i++){
    	for(int j = i; j < N-1; j++){
        	if(H[j] >= H[j+1]){
              cnt[i]++;
            }else{
            	break;
            }
        }
     	if(cnt[i]*2 >= N){
        	break;
        }
    }
  	sort(cnt.begin(), cnt.end());

  	cout << cnt[N-1] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
            public static void main(String[] args) {
				Scanner sc = new Scanner(System.in);
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				if (a < b && b < c) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
}



Measured memory_bytes: 26216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950


bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////


void solve(){

    ll a;
    cin>>a;

    cout<< a+a*a+a*a*a;

    return;           
} 
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> a(A + 1);
    vector<ll> b(B + 1);
    vector<ll> c(C + 1);
    for (int i = 0; i < A; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < B; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < C; i++)
    {
        cin >> c[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    vector<int> d;
    for (int i = 0; i < X; i++)
    {
        d.push_back(a[i]);
    }
    for (int i = 0; i < Y; i++)
    {
        d.push_back(b[i]);
    }
    for (int i = 0; i < C; i++)
    {
        d.push_back(c[i]);
    }
    ll sum = 0;
    sort(d.rbegin(), d.rend());
    for (int i = 0; i < X + Y; i++)
    {
        sum += d[i];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 4852
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int C = sc.nextInt();

			// S = 1/2 * a * (b * sinC)
			double rad = Math.PI*C/180.0;
			double h = b * Math.sin(rad);
			double S = 0.5 * a * h;
			double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(rad));

			System.out.println(S);
			System.out.println(a + b + c);
			System.out.println(h);
		}
	}

}


Measured memory_bytes: 26396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {ans++;}
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  ll ans;
  if (b - a <= 2) {
    ans = k + 1;
  } else {
    if (a - 1 > k) ans = k + 1;
    else {
      ans = a;
      k -= a - 1;
      ans += (ll)(b - a) * (k / 2) + k % 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

bool is_valid(ll num)
{
    // cout << num << " ";
    vector<bool> cnt_753(3, false);
    while (num>0)
    {
        int now = num%10;
        num/= 10;
        if (now == 3)
            cnt_753[0] = true;
        else if (now == 5)
            cnt_753[1] = true;
        else
            cnt_753[2] = true;
    }
    // cout << (cnt_753[0] and cnt_753[1] and cnt_753[2]) << endl;
    return cnt_753[0] and cnt_753[1] and cnt_753[2];
}

int main()
{
    int N;
    cin >> N;
    vector<ll> cands={0};
    int cnt = 0;
    for(;;)
    {
        vector<ll> new_cands;
        for (auto &cand: cands)
        {
            for (auto n: {3,5,7})
            {
                long long now = cand*10+n;
                if (now <= N)
                    new_cands.push_back(now);
            }
        }
        swap(cands, new_cands);
        for (auto cand: cands)
            if (is_valid(cand))
                ++cnt;
        if (cands.size() == 0) break;
    }
    cout << cnt << endl;
    return 0;
}

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

signed main()
{
	int K, S, res = 0;
	cin >> K >> S;
	for (int i = 0; i <= K && i <= S; i++) {
		int s = S - i;
		for (int j = 0; j <= s && j <= K; j++) {
			if (s - j >= 0 && s - j <= K) {
				res++;
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for(int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;

template<typename T> void maxself(T &a, T &b){a = max(a, b);};
template<typename T> void minself(T &a, T &b){a = min(a, b);};

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

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

map<int, bool> foi;
int m[5][5];

bool checkRows(){
	for(int i = 1; i <= 3; i++){
		bool bingo = true;
		for(int j = 1; j <= 3; j++){
			if(foi.find(m[i][j]) == foi.end()){
				bingo = false;
			}
		}
		if(bingo) return bingo;
	}
	return false;
}

bool checkColumns(){
	for(int j = 1; j <= 3; j++){
		bool bingo = true;
		for(int i = 1; i <= 3; i++){
			if(foi.find(m[i][j]) == foi.end()){
				bingo = false;
			}
		}
		if(bingo) return bingo;
	}
	return false;
}

bool checkDiag(){
	if(foi.find(m[1][1]) != foi.end() and foi.find(m[2][2]) != foi.end() and foi.find(m[3][3]) != foi.end()){
		return true;
	}else if(foi.find(m[1][3]) != foi.end() and foi.find(m[2][2]) != foi.end() and foi.find(m[3][1]) != foi.end()){
		return true;
	}
	return false;
}

int main(){

	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= 3; j++){
			scanf("%d", &m[i][j]);
		}
	}
	int n, x;
	scanf("%d", &n);
	while(n--){
		scanf("%d", &x);
		foi[x] = true;
	}
	if(checkRows() or checkColumns() or checkDiag()){
		printf("Yes\n");
	}else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
def day(y, m, d):
    days = 0
    days += (y-1)*195
    days += (y-1)//3*5
    days += (m-1)*19
    if y%3 == 0:
        days += (m-1)
    else:
        days += m//2
    days += (d-1)
    return days

def main():
    n = int(input())
    for _ in range(n):
        (y, m, d) = [int(x) for x in input().split()]
        print(day(1000,1,1) - day(y,m,d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 6720
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  int N;
  scanf("%d", &N);
  vector<vector<int>> G(N, vector<int>());
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> V(N, -1);
  priority_queue<pii, vector<pii>, greater<pii>> P;

  int K;
  cin >> K;
  for (int i = 0; i < K; i++) {
    int a, v;
    scanf("%d%d", &a, &v);
    a--;
    V[a] = v;
    P.push(mp(v, a));
  }

  while(!P.empty()) {
    pii p = P.top(); P.pop();
    for(int i = 0; i < G[p.second].size(); i++) {
      if (V[G[p.second][i]] != -1 && abs(p.first - V[G[p.second][i]]) != 1) {
        printf("No\n");
        return 0;
      }
      if (V[G[p.second][i]] == -1) {
        V[G[p.second][i]] = p.first + 1;
        P.push(mp(p.first + 1, G[p.second][i]));
      }
    }
  }

  printf("Yes\n");
  for (int i = 0; i < N; i++) {
    printf("%d\n", V[i]);
  }

  return 0;
}

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

int main()
{
    int N, Y; cin>>N>>Y;
    for(int x=0, a; a=10000*x, x<=N && a<=Y; ++x)
    for(int y=0, b; b=a+5000*y, x+y<=N && b<=Y; ++y) {
        int z=N-(x+y);
        int c=b+1000*z;
        if (c==Y) { return !printf("%d %d %d\n", x, y, z); }
    }
    puts("-1 -1 -1");
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <limits>

int main() {
  int a, b;
  std::cin >> a >> b;
  const double ans1 = (b - a) / 2.0 + a;
  const int ans2 = (b - a) / 2 + a;
  if (std::abs(ans1 - ans2) < std::numeric_limits<double>::epsilon())
    std::cout << ans2;
  else
    std::cout << "IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-09-13 19:58:04
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    a,b,c,d = map(int,input().split())

    print(max(a*c,a*d,b*c,b*d))
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 62600
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	int n;
	int tri[3];
	cin >> n;
	REP(i, n){
		cin >> tri[0] >> tri[1] >> tri[2];
		sort(tri, tri + 3);
		if (pow(tri[2], 2) == pow(tri[0], 2) + pow(tri[1], 2)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,m;cin >> n>>m;
    vector<vector<lint>> v(n,vector<lint>(2));
    REP(i, n) {
        int a, b;
        cin >> a>>b;
        v[i][0] = a;
        v[i][1] = b;
    }
    lint ans=0;
    sort(ALL(v));
    int c = 0;
    REP(i,n){
        lint p = v[i][0],num = v[i][1];
        ans += p*num;
        c += num;
        if(c>=m){

            ans -= (c-m)*p;
            break;
        }
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 5760
from itertools import permutations
Q, H, S, D = map(int, input().split())
N = int(input())*4

ans = 0
s = [(Q, 1), (H, 2), (S, 4), (D, 8)]

ans = float("inf")
for x in permutations(s):
    tmp = 0
    n = N
    for a, b in x:
        tmp += (n // b)*a
        n %= b
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 3064
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let [|n; k|] = read int64
    let n = int n

    let ps =
      [|
        for i in 0..(n - 1) do
          let [|a; b|] = read int64
          yield (a, b)
      |]

    let calc () =
      let ps = ps |> Seq.sortBy fst |> Seq.toArray
      let rec loop k i =
        if i < ps.Length then
          let (a, b) = ps.[i]
          if 1L <= k && k <= b then
            a
          else
            loop (k - b) (i + 1)
        else
          failwith "N/A"
      loop k 0

    printfn "%d" (calc ())

    0


Measured memory_bytes: 32312
s = input()
ans=[]
for i in range(len(s)):
    if(s[i] == '0' or s[i] == '1'):
        ans.append(s[i])

    else:
        if(len(ans) != 0):
            del ans[-1]

for i in range(len(ans)):
    print(ans[i], end ="")

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

int main() {
   long long A,B,C,X,Y;
   cin >> A >> B >> C >> X >> Y;
   if (A>=2*C && B>=2*C) cout << 2*C*max(X,Y) << endl;
   else if (A+B<=2*C) cout << A*X+B*Y << endl;
   else if (X>Y) {
       if (A<2*C) cout << 2*C*Y+A*(X-Y) << endl;
       else cout << 2*C*X << endl;
   }
   else {
       if (B<2*C) cout << 2*C*X+B*(Y-X) << endl;
       else cout << 2*C*Y << endl;
   }
}

Measured memory_bytes: 256