akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 2e4 + 5;
int p[N], a[N], b[N];

void solve() {
	int n;
    sc(n);
    fr(i, 1, n) {
        sc(p[i]);
    }
    int B = n + 5;
    fr(i, 1, n) {
        a[i] = i * B;
        b[i] = (n - i + 1) * B;
    }
    fr(i, 2, n) {
        if(p[i] > p[i - 1]) {
            a[p[i]] += i - 1;
        }
        else {
            b[p[i]] += i - 1;
        }
    }
    fr(i, 1, n) {
        cout << a[i] << " ";
    }
    cout << endl;
    fr(i, 1, n) {
        cout << b[i] << " ";
    }
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n;
    cin >> n;
    int ans = 0;
    while (n--) {
        int l, r;
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = r[0];
            var B = r[1];
            var C = r[2];
            var X = r[3];
            var Y = r[4];
            int p1 = 0;
            int p2 = 0;
            int p3 = 0;

            p1 = Math.Max(X, Y) * 2 * C;
            p2 = A * X + B * Y;
            var tmp = X < Y ? B : A;
            p3 = 2 * C * Math.Min(X, Y) + Math.Abs(X - Y) * tmp;
            var ret = Math.Min(Math.Min(p1, p2), p3);
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
def solve():
    a, b, c, d = map(int, input().split())

    list = [0] * 4
    list[0] = a * c
    list[1] = a * d
    list[2] = b * c
    list[3] = b * d

    list = sorted(list)

   # print(list)

    print(list[3])


if __name__ == "__main__":
    solve()
        


Measured memory_bytes: 9196
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int ans = 0;
		
		for (int i=1; i<=n; i++) {
			if (i<=k) {
				ans += x;
			} else {
				ans += y;
			}
		}

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

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;


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

    long long ans = 0;
    for (int i = 1 ; i <= n ; ++ i) {
        if (!(i % 3 == 0 || i % 5 == 0))
            ans += i;
    }
    cout << ans << endl;
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3636
n=int(input())
multi3 = [int(x.strip()) for x in input().split()]
ans=1
flag=True
for i in multi3:
    if ans*i>10**18:
        flag=False
    elif i==0:
        flag=True
        ans=0
        break
    else:
        ans*=i
if(flag):
    print(ans)
else:
    print(-1)


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

#define ll long long
#define pb push_back

void solve()
{
    ll a,b;
    cin>>a>>b;
    
    if(a==1 || b==1){
        cout<<1<<endl;
        return;
    }
    
    if(a&1){
        ll x1 = (a+1)/2;
        ll x2 = x1-1;
        ll ans = 0;
        ll t = b/2;
        if(b&1){
            ans = (t+1)*x1;
        }
        else
            ans = t*x1;
        
        ans += t*x2;
        cout<<ans;
    }
    else{
        ll x1 = a/2;
        cout<<x1*b<<endl;
        
    }

}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    // ll t;cin>>t;while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,y,i,j,yukichi,higuchi,natsume,x=0;
    cin >>n>>y;
    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                yukichi=i; higuchi=j; natsume= n-i-j;
                x=1;
            }
            if(x==1) break;
        }
        if(x==1) break;
    }
    if(x==1) cout <<yukichi << " "<<higuchi<<" "<<natsume<<endl;
    else cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
int main()
{
	ll n; cin>>n; ll a[n];
	ff(0,n) cin>>a[i];
	ll d=*min_element(a,a+n);
	ll x=d;
	while(1)
	{
		ff(0,n) if(a[i]%d!=0) d=a[i]%d;
		if(d==x) break;
		if(d==1) break;
		x=d;	
	}
	cout<<d;
}

Measured memory_bytes: 4364
def main():
    import heapq
    left=[10**20]
    right=[10**20]
    heapq.heapify(left)
    heapq.heapify(right)
    q=int(input())
    ans=0
    cnt=0
    left_sum=0
    right_sum=0
    for _ in range(q):
        temp=input()
        if temp[0]=="1":
            cnt+=1
            x,a,b=map(int,temp.split())
            l=-heapq.heappop(left)
            r=heapq.heappop(right)
            left_sum-=l
            right_sum-=r
            ans+=b
            ll,aa,rr=sorted([l,a,r])
            heapq.heappush(right,rr)
            right_sum+=rr
            heapq.heappush(left,-ll)
            left_sum+=ll
            if len(left)==len(right):
                heapq.heappush(left,-aa)
                left_sum+=aa
            else:
                heapq.heappush(right,aa)
                right_sum+=aa
        else:
            i=-heapq.heappop(left)
            left_sum-=i
            print(i,ans+(right_sum-(len(right)-1)*i)+((len(left)-1)*i-left_sum))
            heapq.heappush(left,-i)
            left_sum+=i
main()


Measured memory_bytes: 11192
#include <algorithm>
#include <iostream>

// x * 0.08 = a
// x * 0.10 = b

int main() {
  int a, b;
  std::cin >> a >> b;
  for (int x = 0; x < std::max(a, b) * 100; ++x) {
    if ((int)(x * 0.08) == a && (int)(x * 0.1) == b) {
      std::cout << x << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	string s, t;
	cin >> s >> t;
	int s1 = s.length();
	int t1 = t.length();
	if (s1 > t1)puts("GREATER");
	else if (s1 < t1)puts("LESS");
	else {
		rep(i, s1) {
			if (s[i] > t[i]) {
				puts("GREATER");
				return 0;
			}
			else if (s[i] < t[i]) {
				puts("LESS");
				return 0;
			}
		}
		puts("EQUAL");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, k, x, i, m, ans = 0;
    cin >> n >> m;
    vector <ll> a[m + 1]; 
    for(i = 1; i <= m; i++)
    {
        cin >> k;
        for(ll j = 0; j < k; j++)
            cin >> x, a[i].pb(x);
    }
    ans = 0;
    vll p(m + 1);
    for(i = 1; i <= m; i++)
        cin >> p[i];
    for(i = 0; i <= (1 << n) - 1; i++)
    {
        bool p1 = true;
        for(ll j = 1; j <= m; j++)
        {
            ll t = 0;
            for(auto x : a[j])
                if((i & (1 << (x - 1))) > 0)
                    t++;
            p1 = p1 && (t % 2 == p[j]);
        }
        if(p1)
        {
            // cout << i << endl;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;   
}

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

int main()
{
    int a, b, c;
    int k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k; i++)
    {
        if (a >= b)
        {
            b *= 2;
            continue;
        }
        if (b >= c)
        {
            c *= 2;
            continue;
        }
    }

    if (a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int N;
    cin >> N;
    LL ans1=0,ans2=0;
    LL sum1[N],sum2[N];
    for(int i=0;i<N;i++){
        LL t;
        cin >> t;
        if(i==0){
            if(t>0){
                sum1[i]=t;
                sum2[i]=-1;
                ans2+=t+1;
            }
            else if(t<0){
                sum1[i]=t;
                sum2[i]=1;
                ans2+=-t+1;
            }
            else{
                sum1[i]=1;
                ans1+=1;
                sum2[i]=-1;
                ans2+=1;
            }
            continue;
        }
        sum1[i]=sum1[i-1]+t;
        if(sum1[i-1]>0){
            if(sum1[i]>=0){
                ans1+=sum1[i]+1;
                sum1[i]=-1;
            }
        }
        else if(sum1[i-1]<0){
            if(sum1[i]<=0){
                ans1+=-sum1[i]+1;
                sum1[i]=1;
            }
        }
        sum2[i]=sum2[i-1]+t;
        if(sum2[i-1]>0){
            if(sum2[i]>=0){
                ans2+=sum2[i]+1;
                sum2[i]=-1;
            }
        }
        else if(sum2[i-1]<0){
            if(sum2[i]<=0){
                ans2+=-sum2[i]+1;
                sum2[i]=1;
            }
        }
    }
    cout << min(ans1,ans2) << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(int.Parse(Console.ReadLine()) * 2 * Math.PI);
        }
    }
}

Measured memory_bytes: 27612
def main():
    N,C,K = map(int, input().split())
    times = [int(input()) for n in range(N)]
    times.sort()

    first = 0
    index = 1
    count = 1
    rider_num = 1

    while index <= N-1:
        if times[index] - times[first] <= K and rider_num < C:
            index += 1
            rider_num += 1
        else:
            count += 1
            first = index
            index += 1
            rider_num = 1

    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 7444
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int mod = 1000000007;
int dp[100010][13];

int main() {
  string s;
  cin >> s;
  int n = len(s);
  dp[0][0] = 1;
  rep(i,0,n) rep(j,0,13) {
    int ni = i+1, nj;
    if (s[i] == '?') {
      rep(nd,0,10) {
        nj = (j*10 + nd) % 13;
        dp[ni][nj] += dp[i][j];
        dp[ni][nj] %= mod;
      }
    } else {
      int d = s[i]-'0';
      nj = (j*10 + d) % 13;
      dp[ni][nj] += dp[i][j];
      dp[ni][nj] %= mod;
    }
  }
  int ans = dp[n][5];
  cout << ans << endl;
  return 0;
}


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


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"

template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
    
    ll a, b;
    cin >> a >> b;
    
    cout << a * b << endl;
}



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

    ll t=1;
   // cin >> t;

    while(t--){  
        
        solve();
    }


    return 0;
        
}


Measured memory_bytes: 3564
n = input()

if n[len(n) - 1] == '3':
  print('bon')
elif n[len(n) - 1] == '0' or n[len(n) - 1] == '1' or n[len(n) - 1] == '6' or n[len(n) - 1] == '8':
  print('pon')
else:
  print('hon')

Measured memory_bytes: 9052
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<pair<ld,ld> > v(n);
    for(auto &x:v)
    {
        cin>>x.fi>>x.se;
    }
    sort(v.begin(),v.end());
    ld tot = 0.0;
    do
    {
        ld dis = 0.0;
        for(ll i=1;i<n;i++)
        {
            ld tempx = ((v[i].fi - v[i-1].fi)*(v[i].fi - v[i-1].fi));
            ld tempy = ((v[i].se - v[i-1].se)*(v[i].se - v[i-1].se));
            ld ans = (tempx+tempy);
            dis += sqrt(ans);
        }
        tot += dis;
    }
    while(next_permutation(v.begin(),v.end()));
    for(ll i=1;i<=n;i++)
    {
        tot = (tot/(1.0*i));
    }
    cout<<fixed<<setprecision(10)<<tot;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int a;
  cin >> a;
  cout << a * a;
  hinata;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[100005];
int main() {
    int n, x, ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        if (x > 0) num[x - 1]++;
        num[x]++; num[x + 1]++;
    }
    for (int i = 0; i <= 100001; i++) {
        ans = max(ans, num[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
def lcm(a,b): 
    return (a*b) / gcd(a,b) 

a,b = input().split()
a = int(a)
b = int(b)
print(int(lcm(a,b)))

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

int main() {
  int N, cnt = 0;
  cin >> N;
  string cmp = "ABC";
  vector<char> S(N);
  for (int i = 0; i < N; i++) cin >> S[i];

  for (int i = 0; i < N - 2; i++) {
    if (S[i] == cmp[0]) {
      if (S[i + 1] == cmp[1]) {
        if (S[i + 2] == cmp[2]) {
          cnt++;
        } else
          continue;
      } else
        continue;
    } else
      continue;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

struct dice {
	int top;
	int bottom;
	int front;
	int back;
	int left;
	int right;
};

void rotate_front(dice* d) {
	int tmp = d->top;
	d->top = d->back;
	d->back = d->bottom;
	d->bottom = d->front;
	d->front = tmp;
}

void rotate_back(dice* d) {
	int tmp = d->top;
	d->top = d->front;
	d->front = d-> bottom;
	d->bottom = d-> back;
	d->back = tmp;
}

void rotate_right(dice* d) {
	int tmp = d->top;
	d->top = d->left;
	d->left = d->bottom;
	d->bottom = d->right;
	d->right = tmp;
}

void rotate_left(dice* d) {
	int tmp = d->top;
	d->top = d->right;
	d->right = d->bottom;
	d->bottom = d->left;
	d->left = tmp;
}

int n;
vector<PP> vec[15];

ll dp[1<<15];
set<P> data[1<<15];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			dice d;
			scanf("%d%d%d%d%d%d",&d.left,&d.right,&d.front,&d.back,&d.bottom,&d.top);
			string str;
			cin >> str;
			map<P,int> m;
			m[P(x,y)]=d.bottom;
			for(int j=0;j<str.size();j++){
				if(str[j]=='R'){
					rotate_right(&d);
					x++;
				}
				if(str[j]=='L'){
					rotate_left(&d);
					x--;
				}
				if(str[j]=='F'){
					rotate_front(&d);
					y--;
				}
				if(str[j]=='B'){
					rotate_back(&d);
					y++;
				}
				m[P(x,y)]=d.bottom;
			}
			vec[i].clear();
			for(map<P,int>::iterator it=m.begin();it!=m.end();it++){
				vec[i].push_back(PP(it->first,it->second));
			}
		}
		memset(dp,0,sizeof(dp));
		for(int i=0;i<(1<<n);i++){
			data[i].clear();
			for(int j=0;j<n;j++){
				if((i>>j) & 1){
					for(int k=0;k<vec[j].size();k++){
						data[i].insert(vec[j][k].first);
					}
				}
			}
		}
		ll res=0;
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				if(!((i>>j) & 1)){
					ll val=dp[i];
					for(int k=0;k<vec[j].size();k++){
						if(data[i].find(vec[j][k].first)==data[i].end()){
							val+=vec[j][k].second;
						}
					}
					dp[i|(1<<j)]=max(dp[i|(1<<j)],val);
					res=max(res,dp[i|(1<<j)]);
				}
			}
		}
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 235448
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a,b;     // +,-
    int cnt0=0;
    int i;
    for(i=0; i<n; i++) {
        int tmp = 0;
        scanf("%d", &tmp);
        if(tmp>0) a.push_back(tmp);
        else if(tmp<0) b.push_back(tmp);
        else cnt0++;
    }
    sort(a.rbegin(),a.rend());
    sort(b.begin(),b.end());

    if(a.empty()&&b.empty()) {
        a.push_back(0);
        for(i=0; i<n-1; i++) b.push_back(0);
    }
    else if(a.empty()) {
        if(cnt0) {
            for(i=0; i<cnt0; i++) a.push_back(0);
        }
        else {
            int tmp = b.back();
            b.pop_back();
            a.push_back(tmp);
        }
    }
    else {
        if(cnt0) {
            for(i=0; i<cnt0; i++) b.push_back(0);
        }
        else if(b.empty()) {
            int tmp = a.back();
            a.pop_back();
            b.push_back(tmp);
        }
    }
#if 0
    //#ifdef _DEBUG
    for(i=0; i<a.size(); i++) {
        printf("%d ", a[i]);
    }
    printf("\n");
    for(i=0; i<b.size(); i++) {
        printf("%d ", b[i]);
    }
    printf("\n");
#endif

    ll sum=0;
    for(i=0; i<(int)a.size(); i++) {
        sum += a[i];
    }
    for(i=0; i<(int)b.size(); i++) {
        sum -= b[i];
    }
    printf("%lld\n", sum);

    ll tmp=a[0];
    for(i=1; i<(int)b.size(); i++) {
        printf("%lld %d\n", tmp, b[i]);
        tmp = tmp - b[i];
    }

    ll tmp2=b[0];
    for(i=1; i<(int)a.size(); i++) {
        printf("%lld %d\n", tmp2, a[i]);
        tmp2 = tmp2 - a[i];
    }
    printf("%lld %lld\n", tmp, tmp2);

    return 0;
}


Measured memory_bytes: 2424
class BIT:
    """
    https://tjkendev.github.io/procon-library/python/range_query/bit.html
    Binary index treeの実装
    配列[a1, a2,...,an]に対して以下のクエリをO(logn)で行う:
        1. aiにxを加える
        2. 区間和 ai + a(i+1) + ... + aj の和を求める
    """
    def __init__(self, n):
        """
        添字は1スタート
        """
        self.n = n
        self.data = [0] * (n + 1)
        self.el = [0] * (n + 1)

    def add(self, i, x):
        """
        i>0に対してaiにxを加算(x < 0でもOK)
        """
        if i <= 0 or self.n < i:
            print("i should be within 1 to n")
        else:
            self.el[i] += x
            while i <= self.n:
                self.data[i] += x
                i += i & -i

    def sum(self, i):
        """
        添字1からiまでの累積和を求める
        """
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def get(self, i, j=None):
        """
        添字iからjまでの累積和を求める
        j=Noneの場合はaiの値を返す
        """
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i - 1)


"""
ここから本問の解答
各アルファベットごとにBITを作成する
"""

N = int(input())
S = list(input())
Q = int(input())

# ここを Alphabet = [BIT(N)] * 26とすると、
# どうもすべてのAlphabet[i]が連動するらしい
Alphabet = [None] * 26
for i in range(26):
    Alphabet[i] = BIT(N)

# Sの初期値からBITを初期化
for i, s in enumerate(S):
    num = ord(s) - 97
    Alphabet[num].add(i + 1, 1)

"""
各クエリごとに行う操作を関数にまとめておく
"""
def change(i, c):
    if S[i - 1] != c:
        pre = ord(S[i - 1]) - 97
        Alphabet[pre].add(i, -1)
        post = ord(c) - 97
        Alphabet[post].add(i, 1)
        S[i - 1] = c

def appear(l, r):
    char = 0
    for i in range(26):
        if Alphabet[i].get(l, r) >= 1:
            char += 1
    return char

"""
クエリ処理
"""

for _ in range(Q):
    flag, x, y = input().split()
    if flag == "1":
        i, c = int(x), y
        change(i, c)
    elif flag == "2":
        l, r = int(x), int(y)
        print(appear(l, r))


Measured memory_bytes: 271144
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j;
  int M[MAX][MAX];
  int  k, c, u, v;
  int minv;
  int d[MAX];
  int vis[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > d[u] + M[u][v] ){
	  d[v] = d[u] + M[u][v];
	}
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }

  return 0;
}



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

#define var auto
#define ll long long
//#define APPLY(a, f) f(a.begin(), a.end())
#define APPLY(a, f, ...) f(a.begin(), a.end(), __VA_ARGS__)
#define FUN1(x, f) [&](auto& x){return f;}
#define FUN2(x, y, f) [&](auto& x){return f;}
using namespace std;

int main() {
    double d;
    cin >> d;
    double res = d * sqrt(2);
    for (int i = 1; i <= 10; i++){
        var sqrtx = d * d - i * i;
        if (sqrtx < 0) break;
        if (sqrtx <= 1) res = max(res, (double)i + 1);
    }
    cout << fixed << setprecision(15);
    cout << res << endl;
}




Measured memory_bytes: 3284
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int dq1[400000+10],h1=1,t1=0,dq2[400000+10],h2=0,t2=0,p[200000+10];int n,k;
void Push1(int x){
	while(h1<=t1){
		if(p[dq1[t1]]>=p[x]) t1--;
		else break;
	}
	dq1[++t1]=x;
	
}
void Push2(int x){
	while(h2<=t2){
		if(p[dq2[t2]]<=p[x]) t2--;
		else break;
	}
	dq2[++t2]=x;
	
}
int getmini1(int line){
	while(dq1[h1]<line) h1++;
	return dq1[h1];
}
int getmini2(int line){
	while(dq2[h2]<line) h2++;
	return dq2[h2];
}
int jian[200000+10]; 
int main(){
	cin>>n>>k;
	rb(i,1,n) scanf("%d",&p[i]);
	int res=0;
	rl(i,n,1){
		jian[i]=1;
		if(p[i]<p[i+1]) jian[i]+=jian[i+1];
	}
//	rb(i,1,n) cout<<jian[i]<<" ";cout<<endl;
	rb(i,1,k) {
		Push1(i),Push2(i);
	}
	res=1;
//	cout<<res<<endl;
	int OK=0;
	if(jian[1]>=k) OK=1;
	rb(i,k+1,n){
		Push1(i),Push2(i);
//		cout<<i<<" "<<getmini1(i-k)<<" "<<getmini2(i-k+1)<<endl;
		if(getmini1(i-k)==i-k&&getmini2(i-k+1)==i){
			continue;
		}
		else {
			if(jian[i-k+1]>=k&&OK) continue;
			if(jian[i-k+1]>=k)  OK=1;
//			cout<<i<<endl;
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;


int main(){
  int N,K;
  cin >> N >> K;
  string s;
  cin >> s;
  if(s[K-1] == 'A'){
    s[K-1] = 'a';
    cout << s; return 0;
  }
  if(s[K-1] == 'B'){
    s[K-1] = 'b';
    cout << s; return 0;
  }
  if(s[K-1] == 'C'){
    s[K-1] = 'c';
    cout << s; return 0;
  }
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s,t; cin>>s>>t;
	int aans=0x7fffffff;
	for(size_t i=0; i+t.size()<=s.size(); i++) {
		int ans=0;
		for(size_t j=0; j<t.size(); j++) {
			if(s[i+j]!=t[j]) {
				ans++;
			}
		}
		aans=min(aans,ans);
	}
	cout << aans << '\n';
}

Measured memory_bytes: 3644
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

int main(int argc, char *argv[])
{
	long long a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2;
    system("PAUSE");
    return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%mod;
            inv[i]=mod-inv[mod%i]*(mod/i)%mod;
            finv[i]=finv[i-1]*inv[i]%mod;
        }
    }
    ll operator()(int n,int k){
        if(n<k)return 0;
        return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
    }
};

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    Combination comb(n*m-2);
    ll ans=n*m*(n*m-1)*(n+m)/6;
    ans%=mod;
    ans*=comb(m*n-2,k-2);
    ans%=mod;
    cout<<ans<<endl;
}


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

int main() {
    long q, h, s, d;
    cin >> q >> h >> s >> d;
    long n;
    cin >> n;
    long qhp = min(q*4, h*2);
    long hsp = min(qhp, s);
    long sdp = min(hsp*2, d);
    cout << n / 2 * sdp + n % 2 * hsp << endl;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$hash = array(
    "S" => array_fill(0, 13, null),
    "H" => array_fill(0, 13, null),
    "C" => array_fill(0, 13, null),
    "D" => array_fill(0, 13, null)
);
 
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    $arr = explode(" ", $line);
 
    $hash[$arr[0]][$arr[1]-1] = 1;
}

foreach ($hash as $key => $val) {
    for ($i = 0; $i < 13; $i++) {
        if (! isset($hash[$key][$i])) echo "$key " . ($i+1) . "\n";
    }
}

Measured memory_bytes: 15308
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
#include <cstdint>
typedef long long int llint;

int main(void){
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  int now = 0;
  for(int i=0; i<n; i++){
    std::cin >> a[i];
    if(a[i] == now+1) now++;
  }

  if(now == 0) std::cout << -1 << std::endl;
  else         std::cout << n - now << std::endl;

  return 0;
}


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

int main() { 
  int N;
  cin >> N;
 
  vector<int> d(N);
   for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }  
  sort(d.begin(), d.end()); 

  cout << d.at(N/2) - d.at(N/2-1) << endl;  
} 

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solution(String[] args) throws Exception{
		int H = nextInt();
		int W = nextInt();
		char[][] c = new char[H+2][W+2];
		Arrays.fill(c[0], '-');
		Arrays.fill(c[H+1], '-');
		for(int i=1;i<=H;i++){
			c[i]=("-"+nextString()+"-").toCharArray();
		}

		//4方向の場合はx[i+around[n]][k+around[n+1]]n<4,8方向はn<8でループ
		int[] around = { -1, 0, 1, 0, -1, 1, 1, -1, -1 };
		for(int h=1;h<=H;h++){
			for(int w = 1;w<=W;w++){
				if(c[h][w]=='#'){
					boolean flg = false;
					for(int i=0;i<4;i++){
						if(c[h+around[i]][w+around[i+1]]=='#'){
							flg=true;
							break;
						}
					}
					if(flg==false){
						pw.println("No");
						return ;
					}
				}
			}
		}
		pw.println("Yes");

	}

	public static void dfs(int n,int cnt,ArrayList<Integer>[] tree,int parent,int[] set){
		if(n!=parent&&tree[n].size()==1){
			set[n]=cnt;
			return;
		}
		for(int x:tree[n]){
			if(x==parent){
				continue;
			}
			dfs(x,cnt+1,tree,n,set);
		}
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<char> ans;
  bool ok = true;
  if(A+B+C>=3){
    for(int i=0; i<N; i++){
      string s;
      cin >> s;
      if(s == "AB"){
        if(A>B){
          ans.push_back('B');
          B++; A--;
        }else{
          ans.push_back('A');
          A++; B--;
        }
      }else if(s == "AC"){
        if(A>C){
          ans.push_back('C');
          C++; A--;
        }else{
          ans.push_back('A');
          A++; C--;
        }
      }else{
        if(B>C){
          ans.push_back('C');
          C++; B--;
        }else{
          ans.push_back('B');
          B++; C--;
        }
      }
      if(A<0 || B<0 || C<0){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
      for(int i=0; i<N; i++)
        cout << ans[i] << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    vector<string> s(N);
    for(int i=0;i<N;i++)
      cin >> s[i];
    for(int i=0; i<N; i++){
      if(s[i] == "AB"){
        if(A>B){
          ans.push_back('B');
          B++; A--;
        }else{
          if(A == B && A == 1 && i+1<s.size() && s[i+1]!="AB"){
            if(s[i+1] == "AC"){
              ans.push_back('A');
              A++; B--;
            }else{
              ans.push_back('B');
              B++; A--;
            }
          }else{
            ans.push_back('A');
            A++; B--;
          }
        }
      }else if(s[i] == "AC"){
        if(A>C){
          ans.push_back('C');
          C++; A--;
        }else{
          if(A == C && A == 1 && i+1<s.size() && s[i+1]!="AC"){
            if(s[i+1] == "AB"){
              ans.push_back('A');
              A++; C--;
            }else{
              ans.push_back('C');
              C++; A--;
            }
          }else{
            ans.push_back('A');
            A++; C--;
          }
        }
      }else{
        if(B>C){
          ans.push_back('C');
          C++; B--;
        }else{
          if(C == B && C == 1 && i+1<s.size() && s[i+1]!="BC"){
            if(s[i+1] == "AB"){
              ans.push_back('B');
              B++; C--;
            }else{
              ans.push_back('C');
              C++; B--;
            }
          }else{
            ans.push_back('B');
            B++; C--;
          }
        }
      }
      if(A<0 || B<0 || C<0){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << "Yes" << endl;
      for(int i=0; i<N; i++)
        cout << ans[i] << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 6652
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,K,M;
int A[100010],B[100010];
int C[100010];
vector<edge> G[100010];
int d[100010];

void Dijkstra(int s){
	std::priority_queue<P,vector<P>,std::greater<P>> que;
	std::fill(d,d+N,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p =que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(int i=0;i<(signed)G[v].size();i++){
			edge e =G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

signed main(){
	cin>>N;
	M=N-1;
	REP(i,M){
		cin>>A[i]>>B[i]>>C[i];
		edge e;
		e.to=B[i]-1,e.cost=C[i];
		G[A[i]-1].push_back(e);
		e.to=A[i]-1;
		G[B[i]-1].push_back(e);
	}
	Dijkstra(0);
	int cnt=0;
	cout<<0<<endl;
	for(int i=1;i<N;i++){
		if(d[i]%2==0){
			cout<<0<<endl;
		}
		else{
			cout<<1<<endl;
		}
	}
	return 0;
}


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

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

int main() {
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<ll> H(N);
	for(int i=0; i<N; i++) cin >> H[i];
	vector<vector<int>> graph(N);
	set<pair<int, int>> edge;
	for(int i=0; i<M; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(a>b) swap(a,b);
		if(edge.count({a, b})>0) continue;
		graph[a].push_back(b);
		graph[b].push_back(a);
		edge.insert({a,b});
	}

	int ans = 0;
	for(int i=0; i<N; i++){
		bool ok=true;
		for(int j: graph[i]){
			if(H[i]<=H[j]) ok = false;
		}
		if(ok) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13756
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int n,q;string s;pair<char,char> p[210000];
bool checkLeft(int x){
  rep(i,q){
    if(s[x] == p[i].first){
      if(p[i].second == 'L'){
        x--;
      }else{
        x++;
      }
      if(x == -1)return false;
      if(x == n)break;
    }
  }
  return true;
}
bool checkRight(int x){
  rep(i,q){
    if(s[x] == p[i].first){
      if(p[i].second == 'L'){
        x--;
      }else{
        x++;
      }
      if(x == n)return true;
      if(x == -1)break;
    }
  }
  return false;
}

signed main(){
  cin>>n>>q;cin>>s;
  rep(i,q)cin>>p[i].first>>p[i].second;
  int ng = -1; 
  int lok = n;
  while (abs(lok - ng) > 1) {
    int mid = (lok + ng) / 2;
    if (checkLeft(mid)) lok = mid;
    else ng = mid;
  }
  ng = -1; 
  int rok = n;
  while (abs(rok - ng) > 1) {
    int mid = (rok + ng) / 2;
    if (checkRight(mid)) rok = mid;
    else ng = mid;
  }
  cout << rok - lok << endl;
}


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

typedef unsigned long long ull; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(long long N, std::vector<long long> A){
    ull res = 1;
    for(auto iter: A){
 if(iter == 0){
            cout << 0 << endl;
            return;
        }
    }
    for(auto iter: A){
       
        if(res <= 1'000'000'000'000'000'000/iter){
            res *= iter;
        }else{
            cout << -1 << endl;
            return;
        }
    }
    cout << res << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    GET(A);
    GET(B);
    GET(C);
    if(A+B+C >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
}



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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define INF 1000000000
#define PI 3.14159265359

int main(){
	IO
	long double r, cir;
	cin >> r;
	cir = 2*PI*r;
	cout << setprecision(6) << fixed << cir << endl;
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

int main() {
  map<int, int> m;
  ll sum = 0;

  int t, n;
  cin >> n;
  rep(i, n) {
    cin >> t;
    m[t]++;
    sum += t;
  }

  int q, b, c;
  cin >> q;
  rep(i, q) {
    cin >> b >> c;
    sum -= ll(m[b]) * ll(b);
    sum += ll(m[b]) * ll(c);
    m[c] += m[b];
    m[b] = 0;
    printf("%lld\n", sum);
  };

  return 0;
}


Measured memory_bytes: 8148