akhauriyash/Code-Regression huggingface dataset:
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
	var N = nextInt();
	myout(list[N - 1]);
}


Measured memory_bytes: 30036
#include <bits/stdc++.h>
//<(") 
#define ll long long 
using namespace std;
 
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
 
const ll mod = 1e9 + 7;
const ll siz = 2e5 + 10;
const ll base = 32;
const ll MAXX = 1e18;

ll n;
vector<ll> nxt;
vector<ll> graph[siz];
vector<ll> last;
ll val[siz];

ll tree[4 * siz];

void change() {
	sort(nxt.begin(), nxt.end());
	ll l = unique(nxt.begin(), nxt.end()) - nxt.begin();
	nxt.resize(l);
	for (ll i = 1; i <= n; i++) {
		val[i] = lower_bound(nxt.begin(), nxt.end(), val[i]) - nxt.begin() + 1;
		//cerr << val[i] << ' ';
	}
}

void update(ll node, ll left, ll right, ll pos, ll val) {
	if (pos < left || pos > right) {
		return;
	}
	if (left == right) {
		if (left == pos) {
			tree[node] = val;
		}
		return;
	}
	ll mid = (left + right) / 2;
	update(node * 2, left, mid, pos, val);
	update(node * 2 + 1, mid + 1, right, pos, val);
	tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
}

ll get(ll node, ll left, ll right, ll gLeft, ll gRight) {
	if (gLeft > right || gRight < left) {
		return 0;
	}
	if (gLeft <= left && gRight >= right) {
		return tree[node];
	}
	ll mid = (left + right) / 2;
	return max(get(node * 2, left, mid, gLeft, gRight), get(node * 2 + 1, mid + 1, right, gLeft, gRight));
}

ll ans[siz];

void dfs(ll node, ll par) {
	ll stuff = get(1, 1, n, 1, val[node] - 1) + 1;
	last.push_back(get(1, 1, n, val[node], val[node]));
	if (stuff > last.back()) {
		update(1, 1, n, val[node], stuff);
	}
	ans[node] = get(1, 1, n, 1, n);
	for (ll i = 0; i < (int)graph[node].size(); i++) {
		ll v = graph[node][i];
		if (v != par) {
			dfs(v, node);
		}
	}
	update(1, 1, n, val[node], last.back());
	last.pop_back();
} 

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		cin >> val[i];
		nxt.push_back(val[i]);
	}
	change();
	for (ll i = 1; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	dfs(1, 1);
	for (ll i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}
	return 0;
}

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

typedef long long ll;
const int maxn = 2e5;

int main(int argc, const char * argv[])
{
    ll n, a[maxn], ans = 0;
    map<ll, ll> mp;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        mp[a[i]]++;
    }

    for (int i = 0; i < maxn; i++) {
        ans += mp[i] * (mp[i] - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        printf("%lld\n", ans - mp[a[i]] + 1);
    }
    return 0;
}

Measured memory_bytes: 17016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

bool used[200005];

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

    int n, q;
    cin >> n >> q;
    vector<tuple<int, int, int>> tup(n);
    set<P> s;
    for(int i = 0; i < n; ++i){
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        tup[i] = tie(x, s, t);
    }
    for(int i = 0; i < q; ++i){
        int d;
        cin >> d;
        s.insert(P(d, i));
    }
    
    sort(tup.begin(), tup.end());
    vector<int> res(q, -1);
    for(int i = 0; i < n; ++i){
        int x, st, term;
        tie(x, st, term) = tup[i];
        auto it = s.lower_bound(P(st, -1));
        while(it != s.end()){
            if(it->first >= term)   break;
            res[it->second] = x;
            auto tmp = it++;
            s.erase(tmp);
        }
    }

    for(int i = 0; i < q; ++i){
        cout << res[i] << "\n";
    }
}

Measured memory_bytes: 14464
#define deb 123321
#define fi first
#define se second
#define mp make_pair
#define pb push_back

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

typedef long long ll;
typedef unsigned long long ull;
//constexpr int R=5e7+69, INF=2e9+6969;

ull a,b;
float x;

int main()
{
	cin>>a>>x;
	b=(ull)(x*100);
	a=a*b;
	a=a/100;
	printf("%llu\n", a);
	return 0;
}


Measured memory_bytes: 3776
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[500010];
int a[500010];
int len;
int check(int k){
	int sum=0,i;
	FOR(i,0,len) a[i]=(str[len-i-1]-'0')*9;
	a[0]+=k;
	FOR(i,0,len+5){
		a[i+1]+=a[i]/10;
		sum+=a[i]%10;
		a[i]=0;
	}
	return sum<=k;
}
int main(void)
{
	int left,right,mid;
	scanf("%s",str);
	len=strlen(str);
	left=0,right=len*9+1;
	while(right-left>1){
		mid=(left+right)/2;
		if(check(mid)) right=mid;
		else left=mid;
	}
	printf("%d\n",(right+8)/9);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    string s;
    cin>>s;
    if(s[1] == 'R') s[1] = 'B';
    else s[1] = 'R';
    cout<<s;
} 


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}


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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int h1=Integer.parseInt(s[0]),m1=Integer.parseInt(s[1]),h2=Integer.parseInt(s[2]),m2=Integer.parseInt(s[3]),k=Integer.parseInt(s[4]);
        int min1=h1*60+m1,min2=h2*60+m2;
        int diff=min2-k;
        System.out.print(Math.max(0,diff-min1));
    }
}


Measured memory_bytes: 32700
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int mm[100005];
int cnt[100005];

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

// #ifndef ONLINE_JUDGE
//     if(fopen("INPUT.txt","r"))
//     {
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//     }
// #endif  

    int n,m;
    cin>>n>>m;
    int x,y;
    for(int i=1;i<=n;i++)
        cnt[i]=1;
    mm[1]=1;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        cnt[x]--;
        cnt[y]++;
        if(mm[x])
        {
            mm[y]=1;
        }
        if(cnt[x]==0)
            mm[x]=0;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=mm[i];

    cout<<ans;
} 
    
 

Measured memory_bytes: 5128
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    string s,t;
    while(cin>>s>>t){
        int dp[2][4100] = {};
        int ans = 0;
        for(int i = 0;i < s.length();i++){
            for(int j = 0;j < t.length();j++){
                if(s[i] == t[j]){
                    if(i == 0 || j == 0){
                        dp[i%2][j] = 1;
                    }
                    else{
                        dp[i%2][j] = dp[(i+1)%2][j-1] + 1;
                    }
                    ans = max(ans,dp[i%2][j]);
                }
            }
            for(int j = 0;j < t.length();j++){
                dp[(i+1)%2][j] = 0;
            }
        }
        cout<<ans<<endl;
    }


    return 0;
}

Measured memory_bytes: 1248
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(a * b, c * d) << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

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

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

    if (a == b && b == c) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 5003

long long n, m, a[mx], jaw, pre[mx], b[mx][202], kiri[mx], kanan[mx], pref[mx][mx];


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	cout.tie(0);
	cin >> n >> m;
	for(int i = 2; i <= n; i++)
		cin >> a[i];
	for(int i = 2; i <= n; i++)
		pre[i] = pre[i - 1] + a[i];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> b[i][j];

	for(int j = 1; j <= m; j++){
		vector<pair<int, int>> val;
		vector<bool> sudah(n + 2, false);
		for(int i = 1; i <= n; i++){
			val.pb({b[i][j], i});
			kiri[i] = kanan[i] = i;
		}
		sort(ALL(val));
		for(auto i : val){
			sudah[i.s] = true;
			int ki = i.s, ka = i.s;
			if(sudah[i.s + 1])
				ka = kanan[i.s + 1];
			if(sudah[i.s - 1])
				ki = kiri[i.s - 1];
			kiri[ka] = ki;
			kanan[ki] = ka;
			pref[ki][i.s] += i.f;
			pref[i.s + 1][ka + 1] += i.f;
			pref[i.s + 1][i.s] -= i.f;
			pref[ki][ka + 1] -= i.f;
			// cout << i.s << " -> " << ki << " - " << ka << endl;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			pref[i][j] += pref[i - 1][j];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			pref[i][j] += pref[i][j - 1];
	// debug(pref[1][2]);
	for(int l = 1; l <= n; l++){
		for(int r = l; r <= n; r++){
			jaw = max(jaw, pref[l][r] - pre[r] + pre[l]);
			// debug(jaw);
		}
	}
	cout << jaw << endl;
}

Measured memory_bytes: 203904
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll p=1e9+7;
int main()
{
  ll m,n;
  cin>>m>>n;
  char a[m][n];
  for(ll i=0;i<m;i++)
    for(ll j=0;j<n;j++)
      cin>>a[i][j];
 ll dp[m][n];
 int f=0;
 for(ll i=0;i<m;i++)
 {
   if(a[i][0]=='.'&&f==0)
     dp[i][0]=1;
   else{
     	dp[i][0]=0;
     	f=1;
   }
 }
   f=0;
   for(ll i=0;i<n;i++)
 {
   if(a[0][i]=='.'&&f==0)
     dp[0][i]=1;
   else{
     	dp[0][i]=0;
     	f=1;
   }
 }
   for(ll i=1;i<m;i++)
   {
     for(ll j=1;j<n;j++)
     {
       if(a[i][j]=='.')
       {
           dp[i][j]=(dp[i-1][j]+dp[i][j-1]);
           dp[i][j]%=p;
       }
       else
         dp[i][j]=0;
     }
   }
  ll ans=dp[m-1][n-1]%p;
    cout<<ans<<endl;
    return 0;
   }

Measured memory_bytes: 12380
N,M=map(int,input().split())
A=[]
for i in range(N):
    A.append(list(map(int,input().split())))
A.sort(key=lambda x:(x[0],x[1]))
C=[A[0][0]*A[0][1]]
D=[A[0][1]]
for i in range(N-1):
    C.append(C[i]+A[i+1][0]*A[i+1][1])
    D.append(D[i]+A[i+1][1])
for i in range(N):
    if M<D[i]:
        print(C[i]-(D[i]-M)*A[i][0])
        break
if M==D[N-1]:
    print(C[N-1])

Measured memory_bytes: 41672
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k, ans = 0, max_ele = 0;
	cin >> n;
	int a[100001] = {0};
	for (int i = 0; i < n;++i) {
		cin >> k;
		a[k]++;
		max_ele=max(max_ele, k);
	}
	
	for (int i = 0; i <= max_ele; ++i) {
		if (i == 0) {
			ans = a[0] + a[1];
		}
		else if (i == max_ele) {
			ans=max(ans, a[i] + a[i - 1]);
		}
		else {
			ans=max(ans, a[i - 1] + a[i + 1] + a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define fi first
#define se second

const int N = 100100;
const int mod = 998244353;

using namespace std;

int n;
int a[N];

int main()
{
    ios_base::sync_with_stdio(0);

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

    int m;
    cin >> n >> m;
    int res = -1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i > 1 && a[i] + a[i - 1] >= m){
            res = i - 1;
        }
    }
    if(res == -1){
        cout << "Impossible" << "\n";
        return 0;
    }
    cout << "Possible" << "\n";
    for(int i = 1; i < res; i++) cout << i << "\n";
    for(int i = n - 1; i >= res; i--) cout << i << "\n";
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    double t;
    cin>>a>>b>>t;
    t+=0.5;
    int i=1,ans=0;
    while(a*i<t){
        ans+=b;
        i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

type Pair struct {
	First  int64
	Second int
}

func prime_factor(n int64) []Pair {
	ret := make([]Pair, 0, 0)
	var num int

	for i := int64(2); i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		num = 0
		for n%i == 0 {
			num++
			n /= i
		}
		ret = append(ret, Pair{First: i, Second: num})
	}
	if n != 1 {
		ret = append(ret, Pair{First: n, Second: 1})
	}
	return ret
}

func main() {
	var n int64
	fmt.Scan(&n)

	ps := prime_factor(n)
	fmt.Print(n)
	fmt.Print(":")

	for i := 0; i < len(ps); i++ {
		for j := 0; j < ps[i].Second; j++ {
			fmt.Print(" ")
			fmt.Print(ps[i].First)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

void dfs(Graph &G, vector<int> &res, int v, int color, int p = -1)
{
    res[v] = color;
    for (auto u : G[v])
    {
        if (u.to == p)
            continue;
        if (u.weight % 2 == 0)
        {
            dfs(G, res, u.to, res[v], v);
        }
        else
        {
            if (color == 0)
            {
                dfs(G, res, u.to, 1, v);
            }
            else
            {
                dfs(G, res, u.to, 0, v);
            }
        }
    }
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    Graph G(N);
    for (int i = 0; i < N - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    vector<int> res(N, -1);
    dfs(G, res, 0, 0);
    for (auto it : res)
    {
        cout << it << endl;
    }

    return 0;
}


Measured memory_bytes: 12272
import bisect
a, b, c, d, e, f = [int(item) for item in input().split()]

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b 
        if w <= f // 100:
            water.add(w)
water = sorted(water)
sugar = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        sugar.add(i*c + j*d)
        j += 1
sugar = sorted(sugar)
ans = []
for w in water:
    sid = bisect.bisect_right(sugar, w*e) - 1
    while sugar[sid] + w*100 > f and sid > 0:
        sid -= 1
    if w != 0:
        total = w*100 + sugar[sid]
        ans.append([sugar[sid]/total, total, sugar[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])

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

int a,b,c,d[100000],ans;
int main(){
    cin>>a;
    for(int i = 1; i <= a; i++){
        cin>>d[i];
    }
    sort(d+1,d+a+1);
    for(int i = 1; i <= a; i++){
        for(int j = i + 1; j <= a; j++){
            int l=j,r=a;
            while(l<r){
                int m = (l + r + 1) >> 1;
                if(d[m]<=d[i]+d[j]-1){
                   l = m;
                } else r = m - 1;
            }
            ans+=l-j;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    k = i+1
    for j in range(i+1, n):
        while k < n and l[k] < l[i] + l[j]:
            k += 1
            ans += k - (j+1)
print(ans)


Measured memory_bytes: 9256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{ class Program
	{
		static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(" ");
			int x = int.Parse(s[0]);
			int y = int.Parse(s[1]);
			int z = int.Parse(s[2]);

			Console.WriteLine("{0} {1} {2}",z,x,y);
			
		}
	}

}



Measured memory_bytes: 27488
#include<stdio.h>
int main(void)
{
    int a,b,c;
    
    scanf("%d %d",&a,&b);

    c=a*b;

    if(c%2==0){
        
        printf("Even\n");
    }else{
        printf("Odd\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.Closeable;
import java.util.*;
public class Main {
	//0935 start
	
	class State {
		int step;
		String str;
		public State(int step, String s) {
			this.step = step;
			this.str = s;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0 )break;
			String [] a = new String[n];
			String [] b = new String[n];
			for(int i = 0 ; i < n; i++){
				a[i] = sc.next();
				b[i] = sc.next();
			}
			String start = sc.next();
			String end = sc.next();
			LinkedList<State> open = new LinkedList<Main.State>();
			open.add(new State(0, start));
			HashSet<String> close = new HashSet<String>();
			close.add(start);
			int ans = -1;
			while(! open.isEmpty()){
				State now = open.poll();
				if(now.str.equals(end)){
					ans = now.step;
					break;
				}
				
				for(int i = 0 ; i < n; i++){
					String nstr = now.str.replaceAll(a[i], b[i]);
					if(nstr.length() > end.length()) {
						continue;
					}
					if(close.contains(nstr)) continue;
					close.add(nstr);
					open.add(new State(now.step + 1, nstr));
				}
			}
			System.out.println(ans);
		}
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i(0);i<n;++i)
#define all(v) (v.begin(),v.end())
const int p=31;
const int MOD=1e9+9;

ll hash(string s){
	ll cnt=0;
	ll p_pow=1;
	for(char c : s){
		cnt=(cnt+(c-'a'+1)*p_pow)%MOD;
		p_pow=(p_pow*p)%MOD;
	}
	return cnt;
}

signed main(){
	int n,x,y;
	bool chk=0;
	cin >> n;
	vector<int> v;
	rep(i,n){
		cin >> x >> y;
		v.push_back((x-y));
	}		
	for(int i(0);i<(n-2);++i){
		if(v[i]==0 && v[i+1]==0 && v[i+2]==0){
			chk=1;
			break;
		}
	}
	cout << (chk ? "Yes" : "No");
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll k;
  cin >> k;
  deque<ll> que;
  vl cost(k,2*k);
  que.push_back(1ll);
  cost[1] = 1ll;
  ll ans;
  while(!que.empty()){
    ll node = que[0];
    que.pop_front();
    if(node==0ll){
      ans=cost[node];
      break;
    }

    ll nx = (node * 10ll)%k;
    if(cost[node]<cost[nx]){
      cost[nx] = cost[node];
      que.push_front(nx);
    }
    nx = (node + 1ll)%k;
    if(cost[node]+1ll<cost[nx]){
      cost[nx] = cost[node]+1ll;
      que.push_back(nx);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    int ans = 0;
    for(int i=0;i<n;i+=2){
        if(a[i]%2==1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L; cin >> N >> L;
	vector<string>v(N);
	rep(i, 0, N) {
		cin >> v[i];
	}
	vector<string>ans;
	vector<int>used(N, 0);
	rep(i, 0, N)rep(j, i + 1, N) {
		if (used[i] || used[j])continue;
		auto x = v[i];
		auto y = v[j];
		reverse(all(x));
		if (x == y) {
			if (v[i] < v[j])ans.push_back(v[i]);
			else ans.push_back(v[j]);
			used[i] = used[j] = 1;
		}

	}
	sort(all(ans));
	vector<string>center;
	rep(i, 0, N) {
		if (used[i])continue;
		auto x = v[i];
		reverse(all(x));
		if (v[i] == x) {
			center.push_back(v[i]);
		}
	}
	sort(all(center));
	string re;
	rep(i, 0, ans.size()) {
		re += ans[i];
	}
	if (center.size())re += center[0];
	rrep(i, 0, ans.size()) {
		auto x = ans[i];
		reverse(all(x));
		re += x;
	}
	cout << re << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)
string  cmap[60], cmap2[60];
#define WALL "............................................"
int main(void)
{
    int h,w;
    string s;
    cin >> h >> w;
    REP1(i, h) {
        cin >> s;
        cmap[i] = "." + s + ".";
    }
    cmap[0] = WALL;
    cmap[h+1] = WALL;
    REP1(y1, h) {
        REP1(x1, w) {
            char c[2] = ".";
            if(cmap[y1][x1] != '#') {
                int cnt = 0;
                for(int y2 = -1; y2 <= 1; y2++) {
                    for(int x2 = -1; x2 <= 1; x2++) {
                        cnt += cmap[y1+y2][x1+x2]=='#'? 1 : 0;
                    }
                }
                c[0] = '0' + cnt;
            } else {
                c[0] = '#';
            }
            cmap2[y1-1] = cmap2[y1-1] + c;
        }
    }

    REP(i,h) cout << cmap2[i] << endl;

}


Measured memory_bytes: 256
import numpy as np


N, K = map(int, input().split())
inputs = np.array([int(i) for i in input().split()])

dp = np.zeros(N, dtype=int)
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = (dp[start:i] + abs(inputs[i] - inputs[start:i])).min()

print(dp[-1])


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

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int main() {
	int n=gi();
	vector<pair<int,int>> ans;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(i+j!=n+(n%2==0)) ans.push_back(make_pair(i,j));
	printf("%d\n",ans.size());
	for(auto e:ans) printf("%d %d\n",e.first,e.second);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	double n;
	cin>>n;
	double t=0.0;
	for(int i=1;i<=n;i++){
		if(i%2!=0){
			t++;
		}
	}
	cout<<setprecision(10)<<fixed<<t/n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

#define dTolerance 1.0e-10

    //(x,y)が(x0,y0),(x1,y1)を通る直線のどちら側にあるか  1:左 -1:右 0:直線上
int LF_COUNTER_CLOCKWIZE(const double &x, const double &y, const double &x0, const double &y0, const double &x1, const double &y1){
    if((x1 - x0) * (y - y0) - (x - x0) * (y1 - y0) > dTolerance){
        return 1;
    } else if((x1 - x0) * (y - y0) - (x - x0) * (y1 - y0) < -dTolerance){
        return -1;
    } else {
        return 0;
    }
}

double max(const double &a, const double &b){
    if(a >= b){
        return a;
    } else {
        return b;
    }
}

double min(const double &a, const double &b){
    if(a <= b){
        return a;
    } else {
        return b;
    }
}

int main(){
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++){
        double x0,x1,x2,x3,y0,y1,y2,y3;
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        if(LF_COUNTER_CLOCKWIZE(x0, y0, x2, y2, x3, y3) == 0 && LF_COUNTER_CLOCKWIZE(x1, y1, x2, y2, x3, y3) == 0 ){    //2線分が延長して一致する場合だけ面倒
            if(fabs(x0 - x1) < dTolerance){    //y軸平行  y座標比較
                if(max(y0, y1) < min(y2, y3) || max(y2, y3) < min(y0, y1)){    //交わらない
                    printf("0\n");
                } else {    //交わる
                    printf("1\n");
                }
            } else {    //x座標比較
                if(max(x0, x1) < min(x2, x3) || max(x2, x3) < min(x0, x1)){    //交わらない
                    printf("0\n");
                } else {    //交わる
                    printf("1\n");
                }
            }
        } else {
            bool bIntersect = true;
            if(LF_COUNTER_CLOCKWIZE(x0, y0, x2, y2, x3, y3) * LF_COUNTER_CLOCKWIZE(x1, y1, x2, y2, x3, y3) == 1 ) {    //同じ側にあったら交わらない
                bIntersect = false;
            }
            if(LF_COUNTER_CLOCKWIZE(x2, y2, x0, y0, x1, y1) * LF_COUNTER_CLOCKWIZE(x3, y3, x0, y0, x1, y1) == 1 ) {    //同じ側にあったら交わらない
                bIntersect = false;
            }
            if(bIntersect == true){
                printf("1\n");                
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

string ss,tt; 

ll dp[3001][3001];
ll n1,n2;
ll rec(ll i1,ll i2){
    if(i1 >= n1 || i2 >= n2) return 0;

    ll &ans = dp[i1][i2];
    if(ans != -1) return ans;

    ans = 0;
    if(ss[i1] == tt[i2]) {
        ans = max(ans,rec(i1+1,i2+1) + 1);
    }
    ans = max(ans,rec(i1+1,i2));
    ans = max(ans,rec(i1,i2+1));

    return ans;
}

string anss = "";
void recc(ll i1,ll i2,ll val){
    if(i1 >= n1 || i2 >= n2) return;

    if(ss[i1] == tt[i2]){
        if(rec(i1+1,i2+1) + 1 == val){
            anss += ss[i1];
            recc(i1+1,i2+1,val-1);
            return;
        }
    }

    if(rec(i1+1,i2) == val){
        recc(i1+1,i2,val);
        return;
    }

    recc(i1,i2+1,val);
}

void solve(){
    cin>>ss>>tt;
    ss = '#' + ss,tt = '*' + tt;
    
    n1 = ss.length(),n2 = tt.length();
    memset(dp,-1,sizeof(dp));

    ll ans = rec(1,1);

    recc(1,1,ans);
    cout<<anss<<endl;
}

signed main(){

    FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    while(t--) solve();
    
}

Measured memory_bytes: 70912
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
        if sum_w + w[i] > W:
            continue
        dp[i+1][sum_w+w[i]] = max(dp[i+1][sum_w+w[i]], dp[i][sum_w] + v[i])

print(max(dp[N]))


Measured memory_bytes: 120300
import math
a,b,x = map(int,input().split())

s = x / a
height = s / a

if height * 2 > b:
  print(math.degrees(math.atan((b-height)/(a*0.5))))

else:
  tall = s*2/b
  print(math.degrees(math.atan(b/tall)))

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[][] a = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = Integer.parseInt(in.next());
			}
		}
		int n = Integer.parseInt(in.next());
		int[] b = new int[n];
		for (int k = 0; k < n; k++) {
			b[k] = Integer.parseInt(in.next());
		}
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < n; k++) {
					if (a[i][j] == b[k]) {
						a[i][j] = 0;
					}
				}
			}
		}
		
		int count = 0;
		
		for (int i = 0; i < 3; i++) {
			if (a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
				count++;
				break;
			}
		}
		for (int j = 0; j < 3; j++) {
			if (a[0][j] == a[1][j] && a[1][j] == a[2][j]) {
				count++;
				break;
			}
		}
		if (a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
			count++;
		} else if (a[0][2] == a[1][1] && a[1][1] == a[2][0]) {
			count++;
		}
		
		System.out.println(count > 0 ? "Yes" : "No");
	}
}	

Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

//先行順巡回
void preParse(int u){
    if( u == NIL ) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

//中間順巡回
void inParse(int u){
    if( u == NIL ) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

//後行順巡回
void postParse(int u){
    if( u == NIL ) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

using namespace std;
int main(){
    int v, l, r, root;

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        T[i].p = NIL;
    }

    for(int i = 0; i < n; ++i){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if( l != NIL ) T[l].p = v;
        if( r != NIL ) T[r].p = v;
    }

    for(int i = 0; i < n; ++i) if(T[i].p == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    putchar('\n');
    printf("Inorder\n");
    inParse(root);
    putchar('\n');
    printf("Postorder\n");
    postParse(root);
    putchar('\n');

    return 0;
}

Measured memory_bytes: 3220
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	h := make([]int, N)
	dp := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&h[i])
	}

	for i := 1; i < N; i++ {
		dp[i] = math.MaxInt64
		for j := 1; j <= K; j++ {
			if i >= j {
				dp[i] = Min(dp[i], dp[i-j]+Abs(h[i]-h[i-j]))
			}

		}
	}
	fmt.Println(dp[N-1])
}
func Abs(a int) int {
	return int(math.Abs(float64(a)))
}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll a, b, x;
    cin >> a >> b >> x;

    if ( a == 0 ) {
        cout << b / x + 1 << endl;
    }
    else {
        cout << b / x - ( a - 1 ) / x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,dist[305][305];
ll ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%d",&dist[i][j]);
	for(int i=1;i<+n;i++)
	{
		for(int j=i+1;j<=n;j++) ans+=dist[i][j];
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			if(i==k) continue;
			for(int j=i+1;j<=n;j++)
			{
				if(j==k) continue;
				if(dist[i][j]>dist[i][k]+dist[k][j])
				{
					printf("-1\n");
					return 0;
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				if(k==i||k==j) continue;
				if(dist[i][j]==dist[i][k]+dist[k][j]) 
				{
					ans-=dist[i][j];
					break;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
import math

N, K = list(map(int,input().split()))
A = list(map(int,input().split()))

def is_ok(mid):
    cnt = 0
    for i in range(N):  cnt += (math.ceil(A[i] / mid) - 1)
    return cnt <= K

def binary_search(left, right):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid):  right = mid
        else:  left = mid
    return right

if K == 0:  print(max(A))
else:
    left = max(A)
    right = 0
    ret = binary_search(right, left)
    print(ret)

Measured memory_bytes: 104352
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int x;cin >> x;
	for(int i = 1;i <= 1000;i++){
		if(100*i <= x && x <= i*105){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

struct processes{
public:
	string name;
	int time;
};

int main(){
	queue<processes> myQueue;
	int num, quantum;
	cin >> num >> quantum;
	processes procs[num];
	int tm = 0;
	for(int i = 0; i < num; i++){
		cin >> procs[i].name >> procs[i].time;
		myQueue.push(procs[i]);
	}
	while(!myQueue.empty()){
		processes n = myQueue.front();
		myQueue.pop();
		if (n.time > quantum){
			n.time -= quantum;	
			myQueue.push(n);
			tm += quantum;
		}
		else {
			tm += n.time;
			cout << n.name << " " << tm << endl;
		}
	}

return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	ll N, K;
	cin >> N >> K;

	ll n = (N - 2) * (N - 1) / 2;
	if (K > n) {
		cout << -1 << endl;
		return 0;
	}

	vector<P> g;
	for (int i = 1; i <= N; ++i) {
		if (i == 2) { continue; }
		g.push_back(P(2, i));
	}

	int u = N;
	while (n != K && n >= 0) {
		for (int i = 1; i < u; ++i) {
			if (i == 2) { continue; }
			g.push_back(P(u, i));
			n -= 1;
			if (n == K || n < 0) { break; }
		}
		u -= 1;
		if (u == 2) { u -= 1; }
	}

	cout << g.size() << endl;
	for (int i = 0; i < g.size(); ++i) {
		cout << g[i].first << " " << g[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 384
/*
lakshaygpt28
Lakshay Gupta
*/

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

string to_string(char ch) {
    return "'" + string(1, ch) + "'";
}

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <size_t N>
string to_string(bitset<N> v) {
    return v.to_string();
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < v.size(); ++i) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const double PI = acos(-1);
const long long LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 2e5 + 10;

int main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector<int> a(n), b(n), cnta(n + 1), cntb(n + 1);
    vector<bool> vis(n);
    set<pair<int, int>> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnta[a[i]]++;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        cntb[b[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        if (n - cntb[i] < cnta[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    reverse(b.begin(), b.end());
    int val = 0;
    vector<int> c;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i]) {
            val = a[i];
            c.emplace_back(i);
        }
    }
    vector<int> d;
    for (int i = 0; i < n; i++) {
        if (a[i] != val and b[i] != val) {
            d.emplace_back(i);
        }
    }
    for (int i = 0; i < c.size(); i++) {
        swap(b[c[i]], b[d[i]]);
    }
    for (auto x : b) {
        cout << x << " ";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 7752
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

if N == M:
    if A == B:
        print('Yes')
    else:
        print('No')
    exit()

def isEmbeded(left, top):
    subA = [a[left: left + M] for a in A[top: top + M]]
    if subA == B:
        return True
    else:
        return False

for left in range(N - M):
    for top in range(N - M):
        if isEmbeded(left, top):
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
using ll = long long;
constexpr ll INF = 1LL << 60;

struct Edge {
    int src, dst, cost;
    Edge(int s, int d, int c = 1) : src(s), dst(d), cost(c) {}
    bool operator<(const Edge &e){ return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void dijkstra(int s, Graph &g, vector<long long> &dist){
    using Info = pair<long long, int>;
    // init
    dist.assign(g.size(),INF);
    dist[s] = 0;
    priority_queue<Info, vector<Info>, greater<Info> > pq;
    pq.emplace(0, s);
    //
    // main
    while(!pq.empty()){
        long long d = pq.top().first;
        int v = pq.top().second;
        pq.pop();
        if(dist[v] < d) continue;
        for(Edge e : g[v]){
            if(dist[e.dst] > dist[v] + e.cost){
                dist[e.dst] = dist[v] + e.cost;
                pq.emplace(dist[e.dst], e.dst);
            }
        }
    }
    //
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;cin>>N;
    int a,b,c;
    Graph g(N);
    REP(i,N-1){
        cin>>a>>b>>c;
        --a;--b;
        g[a].emplace_back(a,b,c);
        g[b].emplace_back(b,a,c);
    }
    int Q,K;cin>>Q>>K;
    --K;
    vector<ll> dist;
    dijkstra(K, g, dist);
    int x,y;
    REP(i,Q){
        cin>>x>>y;
        --x;--y;
        cout << dist[x] + dist[y] << '\n';
    }
    return 0;
}

Measured memory_bytes: 10804