akhauriyash/Code-Regression huggingface dataset:
//e4-e5-f4
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define sl set<ll>
#define usl unordered_set<ll>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vpl vector<pll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 1000000007
#define Q 1000000006
#define inf 1e18
#define N 50
#define M 105
//using namespace boost::multiprecision; 
//using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);

struct Matrix { ll mat[N][N]; }; // we will return a 2D array

Matrix matMul(Matrix a, Matrix b) {
    Matrix ans;
    ll i, j, k;
    for (i = 0; i < N; i++){
        for (j = 0; j < N; j++){
            for (ans.mat[i][j] = k = 0; k < N; k++){
                ans.mat[i][j] += a.mat[i][k] * b.mat[k][j];
                ans.mat[i][j]%=P;
            }
        }
    }
    return ans; 
}
 
// if necessary, use modulo arithmetic
 
Matrix matPow(Matrix base, ll n) {
    // O(n^3 log p)
    Matrix ans;
    ll i, j;
    for (i = 0; i < N; i++) for (j = 0; j < N; j++) 
    ans.mat[i][j] = (i == j); // prepare identity matrix
    while (n) {
        // iterative version of Divide & Conquer exponentiation
        if (n & 1) ans = matMul(ans, base); // if n is odd (last bit is on)
        base = matMul(base, base);  // square the base
        n >>= 1;
        // divide n by 2
    }
    return ans; 
}
void solve(){
    
    Matrix adj;
    ll n,k;
    cin>>n>>k;
    f(i,0,n) f(j,0,n) cin>>adj.mat[i][j];
    Matrix p = matPow(adj,k);
    ll ans=0;
    f(i,0,n) f(j,0,n) (ans += p.mat[i][j]) %=P;
    cout<<ans;
}

signed main() {
    teevra_gati
        
    solve();

    return 0;
}

Measured memory_bytes: 3764
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<dbl,dbl> P;

#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define pb push_back

// from codeforces
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

ll mod = 1e9+7;

ll n, ming; string s;
ll w[300005], e[300005];

int main(){
  // fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> s;

  FOR(i,0,n) {
    if(i==0 && s[i]=='W') w[i] = 1;
    else if(s[i]=='W') w[i] = w[i-1]+1;
    else w[i] = w[i-1];
  }

  FOR(i,0,n) {
    if(i==0 && s[i]=='E') e[i] = 1;
    else if(s[i]=='E') e[i] = e[i-1]+1;
    else e[i] = e[i-1];
  }

  ming = mod;

  FOR(i,0,n){
    if(i==0) ming = min(ming,e[n-1]-e[0]);
    else if (i==n-1) ming = min(ming,w[n-2]);
    else ming = min(ming,w[i-1]+e[n-1]-e[i]);
  }

  cout << ming << endl;

  return 0;
}
// notes
//


Measured memory_bytes: 5396
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
   int n;
   cin>>n;
   long long i;
   long long ans=1;
   for(i=2; i<=n; i++)ans=(ans*i)%mod;
   printf("%lld\n", ans);
}


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

int main()
{
    string s;
    cin >> s;

    for (int bit = 0; bit < (1 << 3); bit++) {
        int cur = s[0] - '0';
        string v;
        v += s[0];

        for (int i = 1; i < 4; i++) {
            if (bit & (1 << (i - 1))) {
                cur += s[i] - '0';
                v += "+";
                v += s[i];
            }
            else {
                cur -= s[i] - '0';
                v += "-";
                v += s[i];
            }
        }

        if (cur == 7) {
            cout << v << "=7" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;

int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  int dp[k+1];
  memset(dp,0,sizeof dp);
  for(int i=0; i<=k; i++){
    for(int j=0; j<n; j++){
        if(i-a[j]>=0){
            if(dp[i-a[j]]==0){
                dp[i]=1;
            }
        }
    }
  }
  if(dp[k]==1){cout<<"First";}
  else{cout<<"Second";}
  return 0;
}

Measured memory_bytes: 4024
package main

import "fmt"

func fibonacci() func() int {
	x, y := 0, 1
	return func() int {
		x, y = y, x+y
		return x
	}
}
func main() {
	var n int

	fmt.Scan(&n)
	f := fibonacci()
	for i := 0; i < n; i++ {
		f()
	}
	fmt.Println(f())
}



Measured memory_bytes: 1156
N = int(input())
s = input()
stack = []
a = 0
b = 0
for i in range(N):
  if stack and stack[-1] == "(" and s[i] == ")":
    stack.pop()
    a -= 1
  else:
    stack.append(s[i])
    if s[i] == "(":
      a += 1
    else:
      b += 1

print("("*b + s + ")"*a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string S; 
	cin >> S; 
	if(S.size() >= 4 && S.substr(0, 4) == "YAKI"){cout << "Yes" << endl;}
	else{cout << "No" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
    
    if(A<B&&B>C&&C>=A){
      cout << "Yes" << endl;
    }
  else if(A>=B&&A>C&&C>=B){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


n, m, c = map(int, input().split())
b = [int(x) for x in input().split()]
a = [input().split() for x in range(n)]
ans = 0
for i in range(n):
    sum = 0
    for j in range(m):
        sum += int(a[i][j])*b[j]
    if sum+c > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int r,d,x,i;
    
    scanf("%d %d %d", &r, &d, &x);
    
    for(i = 0; i < 10; i++){
        x = r*x - d;
        printf("%d\n", x);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
const int maxn=2e3+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
vector<int> g[maxn];
int n,m;
queue<pair<int,int> > q;
bool vis[maxn];
int bfs(int k)
{
	memset(vis,false,sizeof(vis));
	while(!q.empty()) q.pop();
	for(auto x: g[k])
	{
		vis[x]=true;
		q.push(make_pair(x,1));
	}
	while(!q.empty())
	{
		pair<int,int> now=q.front();
		q.pop();
		if(now.fi==k) return now.se;
		for(auto x:g[now.fi])
		{
			if(vis[x]) continue;
			vis[x]=true;
			q.push(make_pair(x,now.se+1));
		}
	}
	return -1;
}
int pre[maxn];
void solve(int k)
{
	memset(vis,false,sizeof(vis));
	while(!q.empty()) q.pop();
	for(auto x: g[k])
	{
		vis[x]=true;
		pre[x]=k;
		q.push(make_pair(x,1));
	}
	while(!q.empty())
	{
		pair<int,int> now=q.front();
		q.pop();
		if(now.fi==k) 
		{
			cout<<now.se<<'\n';
			int pos=pre[k];
			while(pos!=k) cout<<pos<<'\n',pos=pre[pos];
			cout<<k<<'\n';
			return ;
		}
		for(auto x:g[now.fi])
		{
			if(vis[x]) continue;
			pre[x]=now.fi;
			vis[x]=true;
			q.push(make_pair(x,now.se+1));
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
	}
	int ans=-1,id;
	for(int i=1;i<=n;i++)
	{
		int now=bfs(i);
		if(now==-1) continue;
		if(ans==-1) ans=now,id=i;
		else if(ans>now) ans=now,id=i;
	}
	if(ans==-1) cout<<-1<<'\n';
	else
	{
		solve(id);
	}
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int d[10][10];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    rep(i,N){
        string S=to_string(i+1);
        if(S[SZ(S)-1]=='0' || S[0]=='0') continue;
        d[(int)(S[SZ(S)-1]-'0')][(int)(S[0]-'0')]++;
    }
    int ans=0;
    rng(i,1,10){
        rng(j,1,10){
            if(i<j) continue;
            if(i==j) ans+=d[i][j]*d[i][j];
            else ans+=d[i][j]*d[j][i]*2;
        }
    }
    cout << ans << endl;
}

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

int main()
{	
	double q;

	cin >> q;

	while (q > 0) {
		double d = q, x = q / 2;

		while (d >= 0.00001 * q) {
			x = x - (pow(x, 3) - q) / (3 * x * x);
			d = abs(pow(x, 3) - q);
		}

		cout << fixed << setprecision(7) << x << endl;

		cin >> q;
	}

	return 0;
}



Measured memory_bytes: 3280
N, A = map(int, input().split())
x = list(map(int, input().split()))
X = max(A, max(x))

DP = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]
DP[0][0][0] = 1

for j in range(1, N+1):
    for k in range(j+1):
        for s in range(k*X+1):
            if(s < x[j-1]):
                DP[j][k][s] = DP[j-1][k][s]
            else:
                DP[j][k][s] = DP[j-1][k][s]+DP[j-1][k-1][s-x[j-1]]
ans = 0                
for i in range(1, N+1):
    ans += DP[-1][i][i*A]
print(ans)

Measured memory_bytes: 65504
#include <bits/stdc++.h>
using namespace std;
#define MOD pow(10,9)+7

int main()
{
  int A,B;cin>>A>>B;
  if((1<= A && A <=9) && (1<=B && B<=9))
  {
    cout<< A*B<<endl;
    return (0);
  }
  else cout<<-1<<endl;
  return (0);
  
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var xyz = inta();
        Write(xyz[2] + " " + xyz[0] + " " + xyz[1]);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


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

using namespace std;

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

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

    cout << (a - 1) * (b - 1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
const int dx[8] = { 1,1,1,0,0,-1,-1,-1 };
const int dy[8] = { -1,0,1,-1,1,-1,0,1 };//方向向量

int a[N + 10][N + 10],h,w;
string s;
int main()
{
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
    {
        cin >> s;
        for (int j = 1; j <= w; j++)
        {
            if (s[j - 1] == '#')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
    }
    for (int i = 1;i <= h;i++)
        for (int j = 1; j <= w; j++)
        {
            if (a[i][j] == 1)
                cout<<"#";
            else
            {
                int num = 0;
                for (int k = 0; k < 8; k++)
                {
                    int tx = i + dx[k];
                    int ty = j + dy[k];
                    num += a[tx][ty];
                }
                cout<<num;
            }
            if (j == w)
                cout<<endl;
        }
    return 0;
}


Measured memory_bytes: 256
def isPrime(n):
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1

ans = 0
n = int(input())
for i in range(n):
    x = int(input())
    ans = ans + isPrime(x)

print(ans)




Measured memory_bytes: 5608
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int a = 0;
        for (int i = 0; i < n.length(); i++) {
            a += n.charAt(i) - '0';
        }
        if(Integer.valueOf(n) % a == 0) System.out.println("Yes");
        else System.out.println("No");
        sc.close();
    }

}

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

// Description: ????????????
// Verifyed: various problem 
using namespace placeholders;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

auto& operator >> (istream& is,P& p){ R x,y; is >> x >> y,p=P(x,y); return is;}
auto& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline P vec(L l){return l.t-l.s;}
auto sdot = bind(sgn,bind(dot,_1,_2,_3));
auto sdet = bind(sgn,bind(det,_1,_2,_3));

// convex_hull Verify AOJ CGL_4_A
VP convex_hull(VP pol){
	int n=pol.size(),k=0,t=1;
	
	auto cmp_x=[](P a,P b)->bool{
		int sr = sgn(real(a-b)), si=sgn(imag(a-b));
		return sr ? sr < 0:si < 0;
	};

	sort(begin(pol),end(pol),cmp_x);
	VP res(2*n);

	auto push = [&](P p)->void{
		while(k>t and sdet(res[k-1],res[k-2],p)<=-1) k--;
		res[k++]=p;
	};

	for_each(begin(pol),end(pol),push);
	t = k;
	for_each(rbegin(pol)+1,rend(pol),push);
	res.resize(k-1);
	return res;
}


int main(void){
	int n;
	cin >> n;
	VP pol;
	rep(i,n){
		P p;
		cin >> p;
		pol.push_back(p); 
	}
	VP res=convex_hull(pol);
	int m=res.size(),idx=0;
	rep(i,m){
		if(imag(res[i])<imag(res[idx])) idx=i;
		if(imag(res[i])==imag(res[idx])&&real(res[i])<real(res[idx])) idx=i;
	}
	cout << m << endl;
	rep(i,m) cout << res[(idx-i+m)%m] << endl;
	return 0;
}

Measured memory_bytes: 15352
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG aoj/grl_1_b.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int n, m, s;
vector<vector<pair<int, int> > > g;
vector<ll> dist;

void bellman_ford(){
    rep(i, n - 1){
        rep(j, n){
            if(dist[j] == INF) continue;

            rep(k, g[j].size()){
                int next = g[j][k].first;
                if(dist[next] > dist[j] + g[j][k].second){
                    dist[next] = dist[j] + g[j][k].second;
                }
            }
        }
    }

    int flag = 1;
    rep(j, n){
        if(dist[j] == INF) continue;

        rep(k, g[j].size()){
            int next = g[j][k].first;
            if(dist[next] > dist[j] + g[j][k].second){
                cout << "NEGATIVE CYCLE" << "\n";
                j = n;
                flag = 0;
                break;
            }
        }
    }
    if(flag){
        rep(i, n){
            if(dist[i] == INF) cout << "INF" << "\n";
            else cout << dist[i] << "\n";
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    cin >> n >> m >> s;
    g.resize(n);
    dist.resize(n);
    rep(i, m){
        int a, b, d;
        cin >> a >> b >> d;
        g[a].push_back(make_pair(b, d));
    }
    rep(i, n){
        dist[i] = INF;
    }
    dist[s] = 0;

    bellman_ford();
    return 0;
}


Measured memory_bytes: 3304
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(0, min(B, D) - max(A, C)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		int x = 0;
		int y = 0;
		int tmp = 0;
		for(int i = 1; true ;i++){
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0)break;
			if(x > y){
				tmp = x;
				x = y;
				y = tmp;
			}
			System.out.println(x + " " + y);
		}
	}
}


Measured memory_bytes: 35836
#include <iostream>
#include <climits>

using namespace std;

int main(int argc, char const* argv[])
{
    int maxprof = INT_MIN, min, x, n;

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    cin >> min;

    for (int i = 0; i < n - 1; i++) {
        cin >> x;
        int p = x - min;
        if(p > maxprof) maxprof = p;
        if(x < min) min = x;
    }

    cout << maxprof << endl;

    return 0;
}

Measured memory_bytes: 3204
use proconio::input;
use proconio::marker::Usize1;

fn main() {

    input!{
        N:usize,
        M:usize,
        XY:[(Usize1,Usize1);M]
    }

    let mut R = vec![false;N];
    R[0] = true;
    let mut B = vec![1;N];

    for &(x,y) in &XY{
        R[y] |= R[x];
        if B[x]==1{R[x] = false;}
        B[x] -= 1;
        B[y] += 1;
    }
    let ans = R.iter().filter(|&&b| b).count();
    println!("{}",ans);
}

Measured memory_bytes: 5112
N,P=map(int,input().split())
A=[int(i) for i in input().split()]
dp=[[0]*2 for i in range(N+1)]
dp[0][0]=1
for i in range(N):
  if A[i]%2:
    dp[i+1][1]=dp[i][0]+dp[i][1]
    dp[i+1][0]=dp[i][1]+dp[i][0]
  else:
    dp[i+1][1]=2*dp[i][1]
    dp[i+1][0]=2*dp[i][0]
print(dp[N][P])
  

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main() {
    int n, k;
    double ans = 0.0;
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        int pnt = i;
        double tmp = 1.0 / n;
        while(pnt < k){
            pnt *= 2;
            tmp /= 2.0;
        }
        ans += tmp;
    }
    cout << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())


split_num_list = []

for i in range(1,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        split_num_list.append(i)
split_num_list.sort(reverse=True)
print(split_num_list[K-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

vector<pair<int,int>>ans;

signed main(){
	IOS();
	int N;
	cin>>N;
	vector<int>a(N);
	int pls = 0;
	rep(i,0,N){
		cin>>a[i];
		if(a[i]>=0)pls++;
	}
	if(N==2){
		sort(all(a));
		if(a[0]>=0&&a[1]>=0){
			cout<<a[1]-a[0]<<endl;
			cout<<a[1]<<" "<<a[0]<<endl;
		}else if(a[0]>0&&a[1]>0){
			cout<<a[0]-a[1]<<endl;
			cout<<a[0]<<" "<<a[1]<<endl;
		}else{
			cout<<a[1]-a[0]<<endl;
			cout<<a[1]<<" "<<a[0]<<endl;
		}
		return 0;
	}
	int x;
	if(pls==N){
		x = -INF;
		sort(all(a));
		rep(i,1,N-1){
			if(x==-INF){
				x = a[0] - a[i];
				ans.push_back({a[0],a[i]});
			}else{
				ans.push_back({x,a[i]});
				x = x - a[i];
			}
		}
		ans.push_back({a[N-1],x});
		x = a[N-1] - x;
	}
	else if(pls>1){
		int iti=-1,ni=-1;
		rep(i,0,N){
			if(a[i]>=0&&iti==-1){
				iti=i;
			}else if(a[i]<0&&iti!=-1){
				ni=i;
				break;
			}
		}
		x = -INF;
		rep(i,0,N){
			if(i==iti||i==ni)continue;
			if(a[i]<0)continue;
			if(x == -INF){
				ans.push_back({a[ni],a[i]});
				x = a[ni] - a[i];
			}else{
				ans.push_back({x,a[i]});
				x = x - a[i];
			}
		}
		ans.push_back({a[iti],x});
		x = a[iti] - x;
		rep(i,0,N){
			if(i==iti||i==ni)continue;
			if(a[i]>=0)continue;
			ans.push_back({x,a[i]});
			x = x - a[i];
		}
	}else if(pls==1){
		int iti = -1;
		rep(i,0,N){
			if(a[i]>=0){
				iti = i;
				break;
			}
		}
		x=-INF;
		rep(i,0,N){
			if(i==iti)continue;
			if(x==-INF){
				x = a[iti] - a[i];
				ans.push_back({a[iti],a[i]});
			}else{
				ans.push_back({x,a[i]});
				x = x - a[i];
			}
		}
	}else{
		sort(all(a));
		x = a[N-1] - a[0];
		ans.push_back({a[N-1],a[0]});
		rep(i,1,N-1){
			ans.push_back({x,a[i]});
			x = x - a[i];
		}
	}
	cout<<x<<endl;
	for(auto e:ans){
		cout<<e.fi<<" "<<e.se<<endl;
	}
}

Measured memory_bytes: 4336
while 1:
    data=input().split()
    a=int(data[0])
    b=int(data[2])
    
    if data[1]=='?':break
    
    if data[1]=='+':
        print(a+b)
    elif data[1]=='-':
        print(a-b)
    elif data[1]=='*':
        print(a*b)
    elif data[1]=='/':
        print(int(a/b))
        


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N, K;
    cin >> N >> K;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];

    lint ng = 0, ok = 1e9 + 1;
    while (abs(ok - ng) > 1) {
        lint mid = (ok + ng) / 2;

        lint cnt = 0;
        for (int i = 0; i < N; i++) {
            lint k = (A[i] + mid - 1) / mid;
            cnt += k - 1;
        }

        if (cnt <= K) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t r;
  cin >> r;
  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
arr = []
MOD = 1000000007
for i in range(M):
    arr.append(int(input())) 

arr.append(10**10)

dp = [0 for i in range(N+1)]
dp[0] = 1

tmp = 0

if arr[0] == 1:
    dp[1] = 0
    tmp += 1
else:
    dp[1] = 1

for i in range(N-1):
    if arr[tmp] == i+2:
        dp[i+2] = 0
        tmp += 1
        continue
    dp[i+2] = (dp[i+1] + dp[i]) % MOD

print(dp[N])

Measured memory_bytes: 7852
#include<stdio.h>
int main(void){
    long long n,h[100001],num[100001],max=0;
    scanf("%lld",&n);
    for(long long i=0;i<n;i++){
        scanf("%lld",h+i);
        num[i]=0;
    }
    for(long long i=n-1;i>0;i--){
        if(h[i-1]>=h[i])num[i-1]=num[i]+1;
        if(max<num[i-1])max=num[i-1];
    }
    printf("%lld\n",max);
    return 0;
}

Measured memory_bytes: 1664
oni, oni_spd = list(map(int, input().split()))
child, child_spd = list(map(int, input().split()))
T = int(input())

dist = abs(child - oni)
ofs_spd = oni_spd - child_spd

if ofs_spd * T >= dist:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9172
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;




long long int N,M;
long double L;
string a,b,c;

int main()
{
    cout << fixed << setprecision(18);
    cin>>L;
    
    cout<<pow(L/3,3)<<endl;
}


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

constexpr int mod = 1000000007;
constexpr int N = 3010;
long long dp[N][N];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    for (int i = 1; i <= n; i++) dp[0][i] = 1;
    for (int i = 0; i < n-1; i++) {
        if (s[i] == '<') {
            for (int j = 1; j <= n-i-1; j++) {
                dp[i][j] %= mod;
                dp[i+1][j] = dp[i][j] + dp[i+1][j-1];
            }
        } else {
            for (int j = n-i-1; j > 0; j--) {
                dp[i][j+1] %= mod;
                dp[i+1][j] = dp[i][j+1] + dp[i+1][j+1];
            }
        }
    }
    cout << dp[n-1][1] % mod << "\n";
    return 0;
}

Measured memory_bytes: 70016
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;

ll INF = 114514191919119;

int main(){

    ll N, K; cin >> N >> K;

    vector<ll > vec;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }

    sort(vec.rbegin(), vec.rend());

    ll ans = 0;

    for(ll i = 0; i < K; i++){
        ans+=vec[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
	    
	    
		Scanner sc = new Scanner(System.in);
        
      	String s = sc.next();
      	String word[] =s.split("");
      	int i = word.length;
      	int j =0;
      	int A=0;
      	int B=0;
      	int count =0;
      	int resultA =0;
      	int resultB =0;
      	
      	while(B==0 && resultB==0){
      	    i--;
      	    if(word[i].equals("Z")){
      	        B=i;
      	        resultB =1;
      	    }
      	   
      	}
      	
      	while(A==0 && resultA ==0){
      	    if(word[j].equals("A")){
      	        A=j;
      	        resultA =1;
      	    }
      	    j++;
      	}
      	
      	
      	System.out.println(B-A+1);
 
    }
}

Measured memory_bytes: 53996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
typedef pair<ll,ll> pii;
const int maxn=100005;
const int mod=1e9+7;
int cnt[maxn];
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    IOS;
    int a,b,c;
    cin>>a>>b>>c;
    cnt[a]++,cnt[b]++,cnt[c]++;
    if(cnt[5]==2 && cnt[7]==1) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem159d(n, a))
}

fun problem159d(n: Int, a: List<Long>): String {
    /**
     * N個の中から2個を選ぶ公式
     */
    fun take2ByN(n: Long): Long {
        return n * (n - 1) / 2
    }
    val countMap = a.groupBy { it }
    val all = countMap.map { take2ByN(it.value.count().toLong()) }.sum()
    val ans = LongArray(n)
    for (i in 0 until n) {
        val num = countMap[a[i]]!!.count().toLong()
        val before = take2ByN(num)
        val after = (num - 1) * (num - 2) / 2
        ans[i] = all - before + after
    }

    return ans.joinToString("\n")
}

Measured memory_bytes: 112948
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int R, C;
    cin >> R >> C;
    vector<string>grid(R);
    for(string & s : grid)
        cin >> s;
    vector<vi> dist(R , vi(C, -1));
    vector<pair<int , int>> que;
    for(int i = 0; i < R; i++)
        for(int j = 0; j < C; j++)
    if(grid[i][j] == '#'){
        dist[i][j] = 0;
        que.emplace_back(i , j);
    }
    for(int tt = 0; tt < (int)que.size(); tt++) {
        for(int dx : {-1, 0 , 1}){
            for(int dy : {-1 , 0 , 1}){
                if(dx * dx + dy * dy == 1){
                  int   xk = dx + que[tt].first , yk = dy + que[tt].second;
                    if(0 <= xk && xk < R && 0 <= yk && yk < C && dist[xk][yk] ==-1){
                        dist[xk][yk] = dist[que[tt].first][que[tt].second] + 1;
                        que.emplace_back(xk , yk);
                    }
                }
            }
        }
    }
    cout << dist[que.back().first][que.back().second]  << '\n';

    return 0;
}














Measured memory_bytes: 14956
// abc115_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n;
  ll ans=0;
  cin>>n;
  vi p(n);
  rep(i,n){
    cin>>p.at(i);
  }
  sort(all(p));
  p.at(n-1)/=2;
  for(int x : p) {
    ans+=x;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int Q;

int main(){
    scanf("%d",&Q);

    for(int i=0;i<Q;i++){
        int c,a,n;
        int ans = 0;
        scanf("%d %d %d",&c,&a,&n);

        if(n > 0){
            if(c > a && a != 0){
                if(a > n){
                    ans += n;
                    a -= n;
                    c -= n;
                }
                else {
                    ans += a;
                    c -= a;
                    n -= a;
                    a = 0;
                }
            }
            else if(a >= c && c != 0){
                if(c > n){
                    ans += n;
                    a -= n;
                    c -= n;
                }
                else {
                    ans += c;
                    n -= c;
                    a -= c;
                    c = 0;
                }
            }
        }

        if(a > 0){
            if(c > 1){
                int hoge = c/2;
                if(a > hoge){
                    ans += hoge;
                    c = 1;
                    a -= hoge;
                }
                else if(hoge >= a){
                    ans += a;
                    hoge -= a;
                    c -= a*2;
                }
            }
        }

        if(c > 2){
            ans += c/3;
        }

        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1028
n,m = map(int,input().split())
q = [list(map(int,input().split())) for i in range(m)]

for i in range(0,1000):
  ans = list(str(i))
  alf = 0
  if len(ans) != n:
    continue
  for j in range(m):
    if int(ans[q[j][0]-1]) == q[j][1]:
      alf += 1
  if alf == m:
    print(i)
    exit()
print(-1)
  

Measured memory_bytes: 9092
def bingo():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    N=int(input())
    b=[int(input()) for i in range(N)]
    list_open=[[0]*3 for i in range(3)]
    flag=False

    #ビンゴのどこがあいたのか
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if bingo[i][j]==b[k]:
                    list_open[i][j]=1
            
            
    #ビンゴになっているかどうか
    for i in range(3):
        judge=0
        for j in range(3):
            judge+=list_open[i][j]
        if judge==3:
            flag=True
            break

    for i in range(3):
        judge=0
        for j in range(3):
            judge+=list_open[j][i]
        if judge==3:
            flag=True
            break

    judge=0
    for i in range(3):
        judge+=list_open[i][i]
    if judge==3:
        flag=True

    judge=0
    for i in range(3):
        judge+=list_open[i][2-i]
    if judge==3:
        flag=True

    #出力
    if flag:
        print("Yes")
    else:
        print("No")
    

bingo()

Measured memory_bytes: 3064
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, P = getNM()

def prime_factorize(n):
    divisors = []
    # 27(2 * 2 * 7)の7を出すためにtemp使う
    temp = n
    for i in range(2, int(sqrt(n)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                # 素因数を見つけるたびにtempを割っていく
                temp //= i
            divisors.append([i, cnt])
    if temp != 1:
        divisors.append([temp, 1])
    if divisors == []:
        divisors.append([n, 1])

    return divisors

ans = 1
for i in prime_factorize(P):
    if i[1] >= N:
        ans *= i[0] ** (i[1] // N)
print(ans)


Measured memory_bytes: 83424
N = int(input())

d = {}
S = set()

for i in range(N):
    s,p = input().split()
    p = int(p)
    S.add(s)
    if s in d:
        d[s].append([p, i+1])
        continue
    d[s] = []
    d[s].append([p, i+1])
S = list(S)
S.sort()

for key in S:
    L = d[key]

    L = sorted(L, reverse=True)
    for l in L:
        print(l[1]) 

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

int main() {
   int x, y;
   cin >> x >> y;

   double a = y / 2.0 - x;
   double b = 2 * x - y / 2.0;

   if (a == floor(a) && b == floor(b) && a >= 0 && b >= 0) cout << "Yes" << endl;
   else cout << "No" << endl;
}

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

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++)
    cin >> d[i];
  
  ll ans = 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      ans += d[i]*d[j];
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq

n,m = map(int,input().split())
s = list(map(lambda x: int(x) * -1, input().split()))
#print(type(s))
heapq.heapify(s)
for _ in range(m):
    heapq.heappush(s,int(heapq.heappop(s)/2))
sum = sum(s)*-1
print(sum)


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

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

  int n, m, d[100001] = {0};
  cin >> n >> m;

  int a, b;
  rep(i, 0, m) {
    cin >> a >> b;
    d[a]++, d[b]++;
  }

  rep(i, 0, n + 1) {
    if(d[i] & 1) {
      out("NO")
      return 0;
    }
  }

  out("YES")
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
string s;
int dp[100100][15];
int add(int a,int b){
	a+=b;
	a%=13;
	return a;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	int n=s.size();
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<13;j++){
			if(s[i]=='?'){
				for(int k=0;k<=9;k++){
					dp[i+1][add(j*10,k)]+=dp[i][j];
					dp[i+1][add(j*10,k)]%=1000000007;
				}
			}
			else{
				int k=s[i]-'0';
				dp[i+1][add(j*10,k)]+=dp[i][j];
				dp[i+1][add(j*10,k)]%=1000000007;
			}
		}
	}
	cout<<dp[n][5]<<endl;
	return 0;
}


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

int main()
{
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    for (int i = 0; i < N; i++)
    {
        if (H.at(i) >= K)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main() {
  char s;
  cin >> s;
  char ans;
  if (s == 'A') ans = 'T';
  if (s == 'T') ans = 'A';
  if (s == 'G') ans = 'C';
  if (s == 'C') ans = 'G';
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
lcm = 1
hash = Hash.new(0)
a.each do |x|
  lcm = (x/2).lcm(lcm)
  v = x
  cnt = 0
  while v % 2 == 0
    v = v / 2
    cnt += 1
  end
  hash[cnt] += 1
end
if hash.length >= 2 
  puts 0
else
  cnt = m/lcm - m/(lcm*2)
  puts cnt
end

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

using namespace std;

int main(){
	int n;
	
	scanf("%d", &n);
	
	int gcd = 0;
	
	for(int i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		
		gcd = __gcd(x, gcd);
	}
	
	vector <int> res;
	
	for(int i = 1; i <= sqrt(gcd); i++){
		if(gcd % i == 0){
			res.push_back(gcd / i);
		
			if(gcd / i != i)
			res.push_back(i);
		}
	}
	
	sort(res.begin(), res.end());
	
	for(int i = 0; i < res.size(); i++)
	printf("%d\n", res[i]);
}



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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	vector<int>rooms(n+1,-1);
	unordered_map<int,vector<int>>conn;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		conn[x].push_back(y);
		conn[y].push_back(x);
	}
	queue<int>q;
	unordered_set<int>s;
	q.push(1);
	s.insert(1);
	int count=n-1;
	while(!q.empty()){
		int sizes=q.size();
		for(int i=0;i<sizes;i++){
			int val=q.front();
			q.pop();
			for(int j=0;j<(int)conn[val].size();j++){
				int curr=conn[val][j];
				if(s.find(curr)==s.end()){
					count--;
					q.push(curr);
					rooms[curr]=val;
					s.insert(curr);
				}
			}
		}
	}
	if(count!=0){
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++){
		cout<<rooms[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 17608