akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1);

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	if(x1>x2){
		swap(x1,x2);
		swap(y1,y2);
	}
	bool flag = false;
	if(y1>y2){
		flag = true;
		swap(y1,y2);
	}
	int n;
	cin>>n;
	vector<pair<int,int> > vp;
	for(int i=1,x,y;i<=n;i++){
		cin>>x>>y;
		if(x<x1||x>x2||y<y1||y>y2)	continue;
		if(flag)	y = y1+y2-y;
		vp.emplace_back(x,y);
	}
	sort(vp.begin(),vp.end());
	vector<int> v;
	for(auto it:vp){
		auto z = upper_bound(v.begin(),v.end(),it.second);
		if(z!=v.end())
			*z = it.second;
		else
			v.emplace_back(it.second);
	}
	int k = v.size();
	double ans = 100.0 * (x2-x1+y2-y1) - (20-5*pi)*k;
	if(k==min(x2-x1,y2-y1)+1){
		ans += (10*pi-20)+(20-5*pi);
	}
	cout<<fixed<<setprecision(20)<<ans<<endl;
}


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


int main(){
    string s;
    cin >> s;
    vector<int> ans(26,0);

    for(int i=0;i<s.size();i++){
        ans.at(s.at(i) - 'a')++;   
    }
        for (int i = 0; i < 26; i++)
        {
            if (ans.at(i) % 2 == 1)
            {
                cout << "No" << endl;
                return 0;
            }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("d",&a,&b)
#define sfff(a,b,c)     scanf("d%d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define PRINT_CASE printf("Case %d: ",z)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;
vector<int>g[maxn];
int n,m;

int DP[maxn];
bool visited[maxn];

void dfs(int u)
{
    visited[u]=1;
    DP[u]=0;

    for(int i=0 ; i<g[u].size() ; i++){
        int v=g[u][i];
        if(!visited[v])
            dfs(v);
        DP[u]=max(DP[v]+1, DP[u]); // jodi akadik way thake jawar.

    }

}

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


    cin>>n>>m;
    int x,y;
    f0(i,m){
        cin>>x>>y;

        g[x].pb(y);
    }

    int ans=0;
    for(int i=1 ; i<=n ; i++){
        if(!visited[i]){
            dfs(i);
        }

        ans=max(ans,DP[i]);
        //cout<<i<<" "<<" "<<DP[i]<<" "<<" "<<ans<<endl;
    }

    cout<<ans<<endl;


    return 0;
}


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

int main() {
  int n,k,ans=0;
  cin>>n>>k;
  int snuke[101];
  rep(i,1,101){snuke[i]=0;}

  rep(i,0,k){
    int d;
    cin>>d;
    rep(j,0,d){
      int tmp;
      cin>>tmp;
      snuke[tmp]++;
    }
  }

  //rep(i,1,101){cout<<snuke[i];}

  rep(i,1,n+1){
    if(snuke[i]==0){ans++;}
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        sc.close();

        if(k % 2 == 0){
            System.out.println(a-b);
        }else{
            System.out.println(b-a);
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9

#define PI 3.14159265359

int main(){
    int N;
    cin >> N;
    int ue[N];
    for(int i = 0; i < N;i++){
        ue[i] = 0;
    }
    for(int i = 1 ; i < N ;i++){
        int a;
        cin >> a;
        a--;
        ue[a]++;
    }
    for(int i =0 ; i < N;i++){
        cout << ue[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4376
import sys
import math


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def factorize(x):
        ret = set()
        for n in range(2, int(math.sqrt(x))+1):
            if x % n == 0:
                while x % n == 0:
                    x //= n
                ret.add(n)
        if x != 1:
            ret.add(x)
        return ret

    a_primes = factorize(a)
    b_primes = factorize(b)
    shared = a_primes.intersection(b_primes)
    print(len(shared) + 1)


main()


Measured memory_bytes: 38512
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = 998244353 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}
vector<ll> mFacts, mInvFacts;
ll modFact(int n){ return mFacts[n]; }
ll modInvFact(int n){ return mInvFacts[n]; }
ll modInv(int n, ll m){ return modPow(n, m - 2, m); }
ll modC(int n, int k, ll m){ return modFact(n) * modInvFact(k) % m * modInvFact(n - k) % m; }
void init(int n, ll m){
    mFacts.resize(n + 1);
    mInvFacts.resize(n + 1);
    mFacts[0] = 1;
    for(int i = 1; i <= n; i++){
        mFacts[i] = mFacts[i - 1] * i % m;
    }
    mInvFacts[n] = modInv(mFacts[n], m);
    for(int i = n - 1; i >= 0; i--){
        mInvFacts[i] = mInvFacts[i + 1] * (i + 1) % m;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    init(4096, M);
    int k, n;
    cin >> k >> n;
    ll total = modC(n + k - 1, k - 1, M);
    vector<int> anss;
    for(int i = 2; i <= k + 1; i += 2){
        int pairs = i / 2;
        ll ans = total;
        for(int j = 1; j <= pairs; j++){
            if(n < j * 2){ break; }
            ans = ans + (j & 1 ? -1 : 1) * modC(n + k - 1 - j * 2, k - 1, M) * modC(pairs, j, M) % M;
            ans = (ans + M) % M;
        }
        anss.push_back(ans);
        anss.push_back(ans);
    }
    for(int i = 0; i < k; i++){
        cout << anss[i] << '\n';
    }
    for(int i = k - 2; i >= 0; i--){
        cout << anss[i] << '\n';
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll h,a;
    cin>>h>>a;
    ll ans=h;
    ll sum=0;
    for(ll i=0;i<h;++i){
        ans-=a;
        sum+=1;
        if(ans<=0){
            break;
        }
    }
    cout<<sum<<endl;
}

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

int i,j,n;
int A[36],B[36];
char a[36],b[36];

string check() { //安定・不安定評価部
    for(i=0;i<n;i++){
        if(a[i]==b[i] && A[i]==B[i]) continue; //バブルと選択が一致か？
        return "Not stable";
    }
return "Stable";
}

int main(void)
{
    int min;
    cin>>n; //カード枚数入力
    
    for(i=0;i<n;i++) { //カード入力部
        cin>>a[i]>>A[i]; //数字はA,アルファベットはaに格納
        b[i]=a[i]; //アルファベット部
        B[i]=A[i]; //数字部
    }
    for(i=0;i<n-1;i++) { //バブルソート
        for(j=n-1;j>i;j--) {
            if(A[j]<A[j-1]) {
                swap(a[j],a[j-1]); //アルファベット部の入れ替え
                swap(A[j],A[j-1]); //数字部の入れ替え
            }
        }
    }
    for(i=0;i<n-1;i++) { //選択ソート
        min=i;
        for(j=i+1;j<n;j++) {
            if(B[j]<B[min]) {
                min=j;
            }
        }
        swap(b[i],b[min]); //アルファベット部の入れ替え
        swap(B[i],B[min]); //数字部の入れ替え
    }
    for(i=0;i<n;i++) { //バブルソート結果表示部
        if(i)cout<<' ';
        cout<<a[i]<<A[i];
    }
    cout<<endl<<"Stable"<<endl; //バブルソートは常に安定
    for(i=0;i<n;i++) { //選択ソート結果表示部
        if(i)cout<<' ';
        cout<<b[i]<<B[i];
    }
    cout<<endl<<check()<<endl; //安定・不安定評価の後結果表示
    return 0;
}    


Measured memory_bytes: 3204
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b - 1)) % MOD;
    }
}

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

    int n, k; cin>>n>>k;

    cout << modpow(k, n) << endl;

    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
const int mod = 1e9 + 7;

ll fac[N];

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init() {
    fac[0] = 1;
    for (int i = 1; i < N; i++)
        fac[i] = fac[i - 1] * i % mod;
}

ll inv(ll a) {
	return binpow(a, mod - 2);
}

ll A(ll n, ll m) {
	return fac[n] * inv(fac[n - m]) % mod;
}

ll C(ll n, ll m) {
    return fac[n] * inv(fac[m]) % mod * inv(fac[n - m]) % mod;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
init();
ll n,m;
cin >> n >> m;
ll sum = 0;
for(int i = 0;i<=n;i++){
    ll now = C(n,i) * A(m-i,n-i) %mod;
    if(i%2==0) sum = sum%mod + now%mod;
    else sum = (sum-now+mod)%mod;
}
cout << sum * A(m,n)%mod <<endl;
return 0;
}

Measured memory_bytes: 7500
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m = map(int,input().split())
ab = []
for i in range(m):
     ab.append(list(map(int,input().split())))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
land = UnionFind(n)
all = int(n*(n-1)/2)
lis = [all]
for i in range(m-1):
    [a,b] = ab[-1-i]
    if land.Find_Root(a) != land.Find_Root(b):
        all -= land.Count(a)*land.Count(b)
    land.Unite(a,b)
    lis.append(all)
#print(lis)
for i in range(m):
    print(lis[-1-i])


Measured memory_bytes: 34192
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    int a, b;
    cin >> a >> b;

    int ans = 1, ctr = 0;
    while(1){
        if(ans >= b) break;
        ctr++;
        ans = ans - 1 + a;
    }
    cout << ctr << endl;
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    char c;
    vector<uint> res(26, 0);
    do {
        c = getchar();
        c = tolower(c);
        res[c - 'a']++;
    } while (c != EOF);

    for (size_t i = 0; i < 26; i++) {
        cout << (char)('a' + i) << " : " << res[i] << endl;
    }
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 1034567
#define offset 1000000000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
int val[tam];
int n;
int go(int num)
{
    int tot=0;
    forr(i,0,n)
    {
        tot+=(val[i]-num)*(val[i]-num);
    }
    return tot;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    cin>>n;
    forr(i,0,n)
    {
        cin>>val[i];
    }
    int minn=1e9;
    forr(i,-100,101)
    {
        minn=min(minn,go(i));
    }
    cout<<minn<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	std::vector<int>a(2);
	for (int i = 0;; i++) {
		std::cin >> a[0] >> a[1];
		if (a[0] == 0 && a[1] == 0)
			break;
		std::sort(a.begin(), a.end());
		std::cout << a[0] << ' ' << a[1] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3100
import sys
import math
import bisect

def main():
    a, b, c = map(int, input().split())
    if c - a - b >= 0:
        if 4 * a * b < (c - a - b) ** 2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    return gcd(b, a%b);
}

const ll L = 1e5+5;
const ll mod = 1e9+7;

ll fact[L];

ll modexp(ll a, ll b, ll c)
{
    ll ans = 1;
    a%=c;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b>>=1;
    }

    return ans;
}

ll K;
ll ans = 1;

vector <ll> adj[L];
vector <bool> visited(L, false);

void dfs(ll s, ll par)
{
    visited[s] = true;

    ll cur = K-2;

    if(par == -1)
    {
        cur++;
    }

    for(auto i: adj[s])
    {
        if(!visited[i])
        {
            if(cur <= 0)
            {
                ans = 0;
            }

            // cout << i << " " << cur << " " << ans << endl;

            ans = (ans*cur)%mod;
            cur--;

            dfs(i, s);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N;
    cin >> N >> K;

    for(ll i=0; i<N-1; i++)
    {
        ll u, v;
        cin >> u >> v;

        adj[u].pb(v);
        adj[v].pb(u);
    }

    ans = K;

    dfs(1, -1);

    cout << ans << endl;

    return 0;
}

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

int n, a[101010], ans=0, b[101010];


int main(){
cin>> n;
rep(i, 0, n-1){
cin >> a[i];
b[i]=a[i];
}
sort(b, b+n);

rep(i, 0, n-1){

int k = lower_bound(b, b+n, a[i]) - b;

if(i%2!=k%2)ans++;

}

cout << ans/2;

return 0;}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

string solve(int n, int k, vector<string> const & s) {
    auto required = vectors(n + 1, k + 1, false);
    required[n][k] = true;
    REP_R (i, n) {
        int len = s[i].length();
        REP (j, k + 1) if (required[i + 1][j]) {
            required[i][j] = true;
            if (j - len >= 0) {
                required[i][j - len] = true;
            }
        }
    }

    string t;
    vector<int> cur(k + 1, -1), prv;
    cur[0] = 0;
    REP (i, n) {
        int len = s[i].length();
        cur.swap(prv);
        cur.assign(k + 1, -1);

        int modified = INT_MAX;
        int clear = INT_MAX;
        REP_R (j, k + 1) if (required[i + 1][j]) {
            if (j - len >= 0 and prv[j - len] != -1) {
                int l = j - len, r = t.length();

                if (len <= r - l and t.compare(l, len, s[i]) == 0) {  // if s[i] is a prefix of t[l, r)
                    cur[j] = j;

                } else if (r - l < len and t.compare(l, r - l, s[i], 0, r - l) == 0) {  // if t[l, r) is a prefix of s[i]
                    t += s[i].substr(r - l);
                    cur[j] = j;

                } else if (s[i].compare(0, len, t, l, r - l) < 0) {  // if you should truly replace t[l, r) with s[i]
                    for (int j1 = j - len, j2 = 0; j1 < t.length() and j2 < len; ++ j1, ++ j2) {
                        if (t[j1] != s[i][j2]) {
                            modified = j1;
                            break;
                        }
                    }
                    clear = j;
                    cur[j] = j;
                    t.erase(t.begin() + j - len, t.end());
                    t += s[i];
                }

            }
            if (prv[j] != -1 and j <= modified) {
                cur[j] = j;
            }
        }
        REP (j, k + 1) {
            if (cur[j] > clear) {
                cur[j] = -1;
            }
        }
    }
    assert (t.length() == k);
    return t;
}

int main() {
    int n, k; cin >> n >> k;
    vector<string> s(n);
    REP (i, n) cin >> s[i];
    cout << solve(n, k, s) << endl;
    return 0;
}


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

vector<vector<int>> graph;
vector<int> degree;
vector<int> depth;
vector<pair<int, int>> ans;

void DFS(int v, int previous_v){
    for(int adjacent : graph[v]){
        if(adjacent == previous_v) continue;

        if(depth[adjacent] == -1){// just dive down
            depth[adjacent] = depth[v] + 1;
            DFS(adjacent, v);
        }
        else{
            if(depth[adjacent] > depth[v]){
                ans.push_back({v, adjacent});
                degree[v] += 1;
            }
        }
    }

    if(previous_v == -1) return;
    if(previous_v != -1){
        if(degree[v] % 2 == 1){// then use (v --> previous_v) to make degree[v] even
            ans.push_back({v, previous_v});
            degree[v] += 1;
        }
        else{// degree[v] % 2 == 0
            ans.push_back({previous_v, v});
            degree[previous_v] += 1;
        }
    }
}

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

    graph.resize(n);
    degree.resize(n);
    depth.assign(n, -1);

    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;

        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    if(m % 2 == 1){
        cout << -1 << endl;
        return 0;
    }
   
    depth[0] = 0;
    DFS(0,-1);

    for(auto x : ans){
        cout << x.first + 1 << " " << x.second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 19756
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
typedef pair<int,int> P;
char maze[50][50];
int dist[50][50];
int dy[4] = {-1,0,1,0};
int dx[4] = {0,-1,0,1};


int main()
{
	for(int i = 0; i < 50; i++){
		for(int j = 0; j < 50 ; j++){
			dist[i][j] = -1;
			maze[i][j] = '#';
		}
	}
	int H,W;
	int si,sj;
	int gi,gj;
	cin>>H>>W;
	si = 0,sj=0;
	gi = H -1,gj = W - 1;
	int numW = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0 ; j<W; j++){
			cin>>maze[i][j];
			if(maze[i][j] == '.') numW++;
		}
	}

	queue<P> searchList;
	searchList.push(P(si,sj));
	dist[si][sj] = 1;
	int score = -1;
	while(searchList.empty() != true){
		P temp = searchList.front();
		searchList.pop();
		int currentDist = dist[temp.first][temp.second];
		if(temp.first == gi && temp.second == gj){
			score = currentDist;
			break;
		}
		int ny,nx;
		for(int i = 0; i < 4;i++){
			ny = temp.first + dy[i];
			nx = temp.second + dx[i];
			if( 0 <= ny && ny < H && 0 <= nx && nx < W && maze[ny][nx] != '#' && dist[ny][nx] == -1){
				dist[ny][nx] = currentDist + 1;
				searchList.push(P(ny,nx));
			}
		}
	}
	if(score == -1){
		cout<<-1<<endl;
	}else{
		cout<<numW-score<<endl;
	}

	/*for(int i = 0; i < R; i++){
		for(int j = 0; j < C; j++){
			cout<<dist[i][j]<<" ";
		}
		cout<<endl;
	}*/
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/
ll fact[400005];
ll inv(ll val)
{
  return power(val,hell-2,hell);
}
ll ncr(ll n,ll r)
{
  return ((fact[n]*inv(fact[r]))%hell*inv(fact[n-r])%hell)%hell;
}

void solve()
{
  ll n;
  cin>>n;
  ll i,num,flag=1;
  for(i=0;i<n;i++)
  {
    cin>>num;
    if(num%2==0)
    {
      if(num%3!=0 && num%5!=0)
        flag=0;
    }
  }
  if(flag)
    cout<<"APPROVED";
  else
    cout<<"DENIED";
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 256
while 1:
    t, h, s = map(int, input().split())
    if t == -1:
        break

    n = 7200 - (3600 * t + 60 * h + s)
    m = n * 3
    print('{:02d}:{:02d}:{:02d}'.format(n // 3600, (n % 3600) // 60, n % 60))
    print('{:02d}:{:02d}:{:02d}'.format(m // 3600, (m % 3600) // 60, m % 60))



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
vector<int> G[100005];
int d[100005];
int dfs(int x)
{
    if(d[x])return d[x];
    if(G[x].size()==0)return d[x]=1;
    else{
        for(int i=0;i<G[x].size();i++){
            d[x]=max(dfs(G[x][i])+1,d[x]);
        }
        return d[x];
    }
}
signed main()
{
     int n,m,x,y;sc(n)sc(m)
    for(int i=0;i<m;i++){
        sc(x)sc(y)
        G[x].pb(y);
    }
    for(int i=1;i<=n;i++){
        if(d[i]==0){
            dfs(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,d[i]);
    }
    cout<<ans-1<<'\n';
}


Measured memory_bytes: 8576
n,m = map(int,input().split())
l = [0]*m
r = [0]*m
lmax = 1
rmin = n

for i in range(m):
    l[i],r[i] = map(int,input().split())
    lmax = max(l[i],lmax)
    rmin = min(r[i],rmin)

if lmax>rmin:
    print(0)
else:
    print(rmin-lmax+1)

Measured memory_bytes: 10868
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define add(x,y)(x=((long long)y+x)%mo)
using namespace std;
const int N=305,mo=1e9+7;
int n,a,b,two,o,f[2][N][N],v,s,one[N*2],sw[N*2];
bool bz[N*2],can[N*2];
int main(){
	cin>>n;
	fo(i,1,n){
		cin>>a>>b;
		if(a==-1&&b==-1)++two;else
		if(a==-1)can[b]=1;else
		if(b==-1)can[a]=1;else
		bz[a]=bz[b]=1;
	}
	fo(i,1,n*2)one[i]=one[i-1]+can[i],sw[i]=sw[i-1]+(!can[i]&&!bz[i]);
	f[0][two][0]=1;
	fd(i,1,n*2)if(!bz[i]){
		o^=1;memset(f[o],0,sizeof f[o]);
		fo(j,0,two)fo(k,0,n)if(v=f[!o][j][k]){
			int l=k+sw[i]-2*j-one[i];
			if(can[i]){
				if(k)add(f[o][j][k-1],v);
				add(f[o][j][k],v);
			}else{
				if(k&&j)add(f[o][j-1][k-1],v*j);
				if(l)add(f[o][j][k],v*l);
				add(f[o][j][k+1],v);
			}
		}
	}
	cout<<f[o][0][0];
}

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

using namespace std;
using llong = long long int;

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

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

/* --------------- template start --------------- */
template <typename T> 
struct BinaryIndexTree { // [1, n]
    vector<T> array;
    int n;

    BinaryIndexTree(int _n) {
        array.resize(_n + 1, 0);
        n = _n;
    }

    T cumsum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;
        }

        return s;
    }

    T sum(int i, int j) {
        T ret_i = cumsum(i - 1);
        T ret_j = cumsum(j);

        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;
        }
    }
};

template<typename T>
struct UnionFind {
    vector<int> par;
    vector<T> sz;

    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};
/* --------------- template end --------------- */

/* --------------- function start --------------- */
llong my_gcd(llong a, llong b) {
    return (a ? my_gcd(b % a, a) : b);
}
llong my_lcm(llong a, llong b) {
    return a * b / my_gcd(a, b);    
}

llong facmod(llong n) {
    if (n == 0) return 1;

    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

    return res;
}
llong powmod(llong a, llong n) {
    llong res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }

    return res;
}
llong modinv(llong n) {
    return powmod(n, MOD - 2);
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    }
    res = (res * modinv(facmod(k))) % MOD;

    return res;
}
/* --------------- function start --------------- */

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

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

    for (int i = 1; i < 100000; ++i) {
        // cout << i << " " << i * 0.08 << " " << i * 0.1 << endl;
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;

string code[200];








int main(){
    code['A'] = "00000";
    code['B'] = "00001";
    code['C'] = "00010";
    code['D'] = "00011";
    code['E'] = "00100";
    code['F'] = "00101";
    code['G'] = "00110";
    code['H'] = "00111";
    code['I'] = "01000";
    code['J'] = "01001";
    code['K'] = "01010";
    code['L'] = "01011";
    code['M'] = "01100";
    code['N'] = "01101";
    code['O'] = "01110";
    code['P'] = "01111";
    code['Q'] = "10000";
    code['R'] = "10001";
    code['S'] = "10010";
    code['T'] = "10011";
    code['U'] = "10100";
    code['V'] = "10101";
    code['W'] = "10110";
    code['X'] = "10111";
    code['Y'] = "11000";
    code['Z'] = "11001";
    code[' '] = "11010";
    code['.'] = "11011";
    code[','] = "11100";
    code['-'] = "11101";
    code['\'']= "11110";
    code['?'] = "11111";
    
    map<string,string> code2;
    code2["101"] = " ";
    code2["000000"] = "\'";
    code2["000011"] = ",";
    code2["10010001"] = "-";
    code2["010001"] = ".";
    code2["000001"] = "?";
    code2["100101"] = "A";
    code2["10011010"] = "B";
    code2["0101"] = "C";
    code2["0001"] = "D";
    code2["110"] = "E";
    code2["01001"] = "F";
    code2["10011011"] = "G";
    code2["010000"] = "H";
    code2["0111"] = "I";
    code2["10011000"] = "J";
    code2["0110"] = "K";
    code2["00100"] = "L";
    code2["10011001"] = "M";
    code2["10011110"] = "N";
    code2["00101"] = "O";
    code2["111"] = "P";
    code2["10011111"] = "Q";
    code2["1000"] = "R";
    code2["00110"] = "S";
    code2["00111"] = "T";
    code2["10011100"] = "U";
    code2["10011101"] = "V";
    code2["000010"] = "W";
    code2["10010010"] = "X";
    code2["10010011"] = "Y";
    code2["10010000"] = "Z";
    
    
    string s;
    while(getline(cin,s)){
        string n,ret;
        for(int i=0; i<s.length(); i++){
            n+=code[s[i]];
        }
        //cout<<n<<endl;
        
        s.erase();
        while(n.length()!=0){
            s+=n[0];
            n.erase(0,1);
            if(code2.count(s)){
                ret+=code2[s];
                s.erase();
            }
        }
        cout<<ret<<endl;
        s.erase();
    }
}

Measured memory_bytes: 1220
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  const array<int, 32> arr = { 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 };
  int K;
  cin >> K, --K;
  cout << arr[K] << endl;
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
import sys
import re
import math

S = input()
Sd = re.sub('x', '', S)
Sd_rev = Sd[::-1]

if Sd != Sd_rev:
    print(-1)
    sys.exit()

x_n = re.split('[abcdefghijklmnopqrstuvwyz]', S)
res = 0
for i in range(0, len(x_n)):
    i_rev = len(x_n) - i - 1
    res += int(math.fabs(len(x_n[i]) - len(x_n[i_rev])))
print(res // 2)

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll N = 1000002;
const ll INF = 1000000007ll*1000000007ll;
//vector<ll> ans(100005, 1e9);
ll n, m;
ll l, r, d;
ll ans[N];
inline void No() {
    cout << "No\n";
}
inline void Yes() {
    cout << "Yes\n";
}
bool mark[N];
vector< PLL > g[N];
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < g[v].size(); ++i) {
    ll to = g[v][i].first, len = g[v][i].second;
    if (ans[to] == INF) {
      ans[to] = ans[v] + len;
    }
    if (ans[to] != ans[v] + len) {
      cout << "No" << endl;
      exit(0);
    }
    if (!mark[to]) {
      dfs(to);
    }
  }
}
void solve() {
    fill(ans, ans+N, INF);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r >> d;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    for (int i = 1; i <= n; ++i) {
        if (!mark[i]) {
            ans[i] = 0;
            dfs(i);
        }
    }
    cout << "Yes" << endl;
}
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 45568
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
void solve(int);
int main(){
  int n;
  while(cin >> n && n){
    solve(n);
    cout << endl;
  }
}
void solve(int n){
  if(n == 0) return;
  solve(n/8);
  int a=n%8;
  cout << (a==4?5:(a>4?a+2:a));
}

Measured memory_bytes: 1160
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int W , H;

int main(){
  cin >> W >> H;
  vector<pii> lines;
  int p , q;
  rep(i,0,W) {
    cin >> p;
    lines.pb(mp(p , 0));
  }
  rep(i,0,H) {
    cin >> q;
    lines.pb(mp(q , 1));
  }
  sort(all(lines));
  int w = W + 1 , h = H + 1;
  ll ans = 0;
  for(auto l : lines) {
    if(l.se == 0) ans += ll(l.fi) * h , --w;
    else ans += ll(l.fi) * w , --h;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll, ll>> v;
    for (int i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        v.emplace_back(b, a);
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    for (auto &p : v)
    {
        sum += p.second;
        if (sum > p.first)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

int main() {
  int N, K; cin >> N >> K;
  int mx = (N-1)*(N-2)/2;
  if(mx < K) {
    puts("-1");
    return 0;
  }
  vector<P> ans;
  for(int i = 0; i < N-1; ++i) {
    ans.push_back(P(i+1, N));
  }
  int add = mx - K;
  vector<P> edge;
  for(int i = 0; i < N-1; ++i) {
    for(int j = 0; j < i; ++j) {
      edge.push_back(P(i+1, j+1));
    }
  }
  for(int i = 0; i < add; ++i) {
    ans.push_back(edge[i]);
  }
  std::cout << ans.size() << std::endl;
  for(int i = 0; i < ans.size(); ++i) {
    std::cout << ans[i].first << " " << ans[i].second << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S[100010];
    rep(i,0,N) cin >> S[i];
    rep(i,0,N) sort(S[i].begin(), S[i].end());
    ll ans = 0;
    map<string,ll> mp;
    rep(i,0,N){
        ans += mp[S[i]];
        mp[S[i]]++;
    }
    print(ans);

    
    
}

Measured memory_bytes: 16640
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)


int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    vector<vector<ll>> g(N);
    vector<vector<ll>> weight(N);
    vector<ll> vcolor(N, -1);
    REP(i, N-1) {
        ll u,v,w;
        in >> u >> v >> w;
        --u;
        --v;
        g[u].emplace_back(v);
        weight[u].emplace_back(w);
        g[v].emplace_back(u);
        weight[v].emplace_back(w);
    }
    std::function<void(ll,ll,bool)> dfs = [&](ll cur, ll prev, bool color) -> void {
        vcolor[cur] = color ? 1 : 0;
        REP(i, g[cur].size()) {
            auto next = g[cur][i];
            if (vcolor[next] == -1) {
                bool next_color = weight[cur][i] % 2 == 1 ? !color : color;
                dfs(next, cur, next_color);
            }
        }
    };

    dfs(0, -1, true);
    REP(i, N) {
        out << vcolor[i] << endl;
    }
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 16000
#include <cstdio>

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int ans;
    if(a >= 13){
        ans = b;
    }else if(6 <= a && a <= 12){
        ans = b / 2;
    }else{
        ans = 0;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  long n,m,count;
  cin >> n >> m;
  if(n==1&&m==1){
    count =1;
  }else if(n==1){
    count = m-2;
  }else if(m==1){
    count = n-2;
  }else{
    count = (m-2)*(n-2);
  }
  cout << count <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
using namespace std;
int main(){
    int a;
    int b;
    while(1)
    {
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        for(int i = 0 ; i < a ; i++)
        {
            for(int j = 0; j < b ; j++ )
            {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;  // INFの値は1152921504606846976

int main()
{
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = k+1; i <= n; i++){
        ans += (((n/i) * (i-k)) + max((n%i+1-k),(ll)0));
    }
    if(k == 0) ans -= n;
    cout <<ans;
}


Measured memory_bytes: 256
import math
N, K = map(int, input().split())
lightPow = list(map(int, input().split()))

for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    low = pos - lightPow[pos-1]
    high = pos + lightPow[pos-1]
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] -= 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
    
  check = True
  for i in range(0, N):
    if (i > 0):
      newLightPow[i] += newLightPow[i-1]
    if (newLightPow[i] < N):
      check = False
  lightPow = newLightPow
  if (check):
    break

print(*lightPow[:-1])

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vll p(a), q(b), r(c);
  for(int i=0;i<a;++i) {
    cin >> p[i];
  }
  for(int i=0;i<b;++i) {
    cin >> q[i];
  }
  for(int i=0;i<c;++i) {
    cin >> r[i];
  }
/* 
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend()); */

  int nowa = 0, nowb = 0, nowc = 0;
  priority_queue<P> pq;
  for(int i=0;i<a;++i) {
    pq.push({p[i], 0});
  }
  for(int i=0;i<b;++i) {
    pq.push({q[i], 1});
  }
  for(int i=0;i<c;++i) {
    pq.push({r[i], 2});
  }

  ll ans = 0;
  while(!pq.empty() && nowa + nowb + nowc < x+y) {
    P now = pq.top(); pq.pop();
    //cout << now << ":" << ans << endl;
    if(now.second == 0) {
      if(nowa >= x) continue;
      ans += now.first;
      nowa++;
    } else if(now.second == 1) {
      if(nowb >= y) continue;
      ans += now.first;
      nowb++;
    } else {
      ans += now.first;
      nowc++;
    }
  }
  cout << ans << endl;



  

}


Measured memory_bytes: 8688
#include <stdio.h>

int main() {
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);

	if(a <= b && b <= c) {
		printf("%d %d %d",a,b,c);
	}else if(a <= c && c <= b) {
		printf("%d %d %d",a,c,b);
	}else if(b <= a && a <= c) {
		printf("%d %d %d",b,a,c);
	}else if(b <= c && c <= a) {
		printf("%d %d %d",b,c,a);
	}else if(c <= a && a <= b) {
		printf("%d %d %d",c,a,b);
	}else {
		printf("%d %d %d",c,b,a);
	}
	printf("\n");
}



Measured memory_bytes: 2728
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int dp[3][3][2010][2010];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  vector<string> s(3);
  cin >> s;
  int ans = numeric_limits<int>::max();
  for (int i = 0; i < 3; ++i)
    for (int j = i + 1; j < 3; ++j) {
      for (int a = (int)s[i].size() - 1; a >= 0; --a)
        for (int b = (int)s[j].size() - 1; b >= 0; --b) {
          if (!(s[i][a] != '?' && s[j][b] != '?' && s[i][a] != s[j][b]))
            dp[i][j][a][b] = dp[i][j][a + 1][b + 1] + 1;
        }
    }
  auto match = [&](int i, int j, int x, int y) {
    if (x < y) {
      swap(x, y);
      swap(i, j);
    }
    x -= y;
    if (i < j) return dp[i][j][0][x] >= min((int)s[i].size(), (int)s[j].size() - x);
    return dp[j][i][x][0] >= min((int)s[i].size(), (int)s[j].size() - x);
  };
  vector<int> r(3);
  iota(r.begin(), r.end() ,0);
  do {
    for (int x = 0; x <= s[r[0]].size(); ++x)
      for (int y = 0; y <= s[r[0]].size() + s[r[1]].size(); ++y) {
        if (match(r[0], r[1], 0, x) && match(r[0], r[2], 0, y)
            && match(r[1], r[2], x, y))
          ans = min(ans, (int) max({s[r[0]].size(), s[r[1]].size() + x, s[r[2]].size() + y}));
      }
  } while (next_permutation(r.begin(), r.end()));
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    float ans = (float)0;

    ll N;
    cin >> N;

    for(ll i=0; i<N; i++)
    {
        string u;
        float x;

        cin >> x >> u;

        if(u=="JPY")
        {
            ans+=x;
        }

        else
        {
            ans+=x*380000;
        }
    }

    cout << fixed << setprecision(8) << ans << endl;

    return 0;
}

Measured memory_bytes: 256