akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MOD = 1e9+7;

int main(){ _

	string s;
	int n; cin >> n >> s;
	s = ">" + s;

	vector<int> memo(n+1), pref(n+1);

	function<int(int,int)> sum = [&] (int l, int r) {
		if(r < l) return 0;
		return (((pref[r] - (l ? pref[l-1] : 0)) % MOD) + MOD) % MOD;	
	};

	memo[0] = 1;
	for(int i=n-1; i>=0; i--) {
		pref[0] = memo[0];

		for(int j=1; j<=n; j++) pref[j] = (pref[j-1] + memo[j]) % MOD;

		for(int j=0; j <= n-i; j++) {
			if(s[i] == '>') memo[j] = sum(0, j-1);
			else memo[j] = sum(j, n-i-1);
		}
	}	

	cout << memo[n] << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int x,a[4],i;
    while(scanf("%d",&x)!=EOF)
    {
        for(i=0; i<4; i++)
        {
            a[i]=x%10;
            x=x/10;
        }

        if((a[3]==a[2]&&a[2]==a[1])||(a[2]==a[1]&&a[1]==a[0]))
            printf("Yes\n");
        else
            printf("No\n");

    }
    return 0;
}


Measured memory_bytes: 128
let s = Array(readLine()!)
let n = s.count
let mod = 1000000007

var dp: [[Int]] = .init(repeating: .init(repeating: 0, count: 2), count: n + 1)

dp[0][0] = 1

for i in 0..<n {
  if s[i] == "0" {
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = dp[i][1]
  } else {
    dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod
  }
  if s[i] == "0" {
    dp[i+1][1] += dp[i][1] * 2 % mod
    dp[i+1][1] %= mod
  } else {
    dp[i+1][0] += dp[i][0] * 2 % mod
    dp[i+1][0] %= mod
    dp[i+1][1] += dp[i][1] * 2 % mod
    dp[i+1][1] %= mod
  }
}
print((dp[n][0] + dp[n][1]) % mod)

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

int main(void) {
  string str;
  string ans;
  cin>>str;

  for(int i=1; str[i-1]!='\0'; i++) {
    if(i%2==1) ans+=str[i-1];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
//Mandelbrot: z(n+1) = (z(n))^2 + c
//Rick: I programmed you to believe that
//#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 mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#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 3000005
//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);
ll fact[N];
ll powMod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
  
 
ll modInverse(ll n, ll p) 
{ 
    return powMod(n, p-2, p); 
} 

ll nCrModPFermat(ll n, ll r, ll p) 
{ 
    
    if (r==0) return 1;
    ll r1 = fact[n];
    ll r2 = fact[r];
    ll r3 = fact[n-r];
    return (r1* modInverse(r2, p) % p * modInverse(r3, p) % p) % p; 
} 

void solve(){

    ll k, l, ans=0;
    string s;
    cin>>k>>s;
    l = lt(s);
    f(i,0,k+1){
        ll a = nCrModPFermat(l+k-i-1,l-1,P);
        ll b = (powMod(26,i,P)*powMod(25,k-i,P))%P;
        (ans += (a*b)%P) %=P;
    }
    cout<<ans;
}

signed main() {
    teevra_gati
    
    fact[0]=1;
    f(i,1,N) fact[i] = (i*fact[i-1])%P;
    solve();
    return 0;
}

Measured memory_bytes: 27728
#include <cstdio>

using namespace std;

int main() {
    int n, d, x, i;
    double ans = 0, sum;
    
    scanf("%d %d %d", &n, &d, &x);
    
    sum = (double)n * (d * 2 + (n * 2 - 1) * x);
    
    for (i = n; i >= 1; i--) {
        ans += sum / (i * 2);
        sum *= ((double)i * i - 1) / ((double)i * i);
    }
    
    printf("%.12lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}

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

  ll A,B;
  char op;
  cin >> A >> op >> B;
  if(op=='+') cout << A+B << endl;
  else cout << A-B << endl;
    
  
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 1001001001;
    for (int i = 0; i < (max(X, Y) + 1) * 2; i++)
    {
        int cnt = A * max(0, X - i) + B * max(0, Y - i) + C * i * 2;
        ans = min(cnt, ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{


    int k;
    cin >> k;
    vector<int>a(k + 3);
    a[0] = 7 % k;
    for (int i = 0; i <= k; i++) {
        
        if (!a[i]) {
            cout << i+1 << endl;
            return 0;
        }
        a[i+1] = (a[i ] * 10 + 7) % k;
        
    }
    cout << -1 << endl;
    return 0;

}


Measured memory_bytes: 7140
package main

import "fmt"

func main() {

     for ; true ; {
     var n int
     fmt.Scan(&n)
     if n == 0 { break }
     a := make([]float64, n)
     var sum float64 = 0
     for i := 0; i < n; i++ {
     	 fmt.Scan(&a[i])
	 sum += float64(a[i])
     }
     sum /= float64(n)
     ans := 0
     for i := 0; i < n; i++ {
     	 if a[i] <= sum {
	    ans += 1
	 }
     }
     fmt.Println(ans)
     }
}


Measured memory_bytes: 3120
import java.lang.Math
fun main(args: Array<String>) {
    val a = IntArray(5) {readLine()!!.toInt()}
    var ans = 999999
    for (i in 0 until 5) {
        var now = 0
        for (j in 0 until 5) {
            if (j == i) {
                now += a[j]
            } else {
                now += ((a[j] + 9) / 10) * 10
            }
        }
        ans = Math.min(ans, now)
    }
    println(ans)
}

Measured memory_bytes: 31808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;

class Sobaya
{
  static void Main(){
    new Sobaya().calc();
    return;
  }
    
  Scanner cin;
  
  void calc(){
      cin = new Scanner();
      int n = cin.nextInt();
      int[] a = new int[n];
      int[] aa = new int[n];
      int i1;
      for(i1=0; i1<n; i1++){
          a[i1] = cin.nextInt();
          aa[i1] = a[i1];
      }
      
      //Console.WriteLine(a[0]);
      
      Array.Sort(a);
      bool x = false;
      int primero = a[n-1];
      int segundo = a[n-2];
      if(primero == segundo) x = true;
      
      if(x) for(i1=0; i1<n; i1++) Console.WriteLine(primero);
      else for(i1=0; i1<n; i1++) {
          if(aa[i1]!=primero) Console.WriteLine(primero);
          else Console.WriteLine(segundo);
      }

  }
}




class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

template<class T> T in() {T a; cin >> a; return a;}
#define sim template<class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e;};
sim > rge<c> range(c i, c j) {return rge<c>{i, j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() {cerr << '\n';}
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair<b, c> d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++) 
		*this << (it == d.b ? "" : ", ") << *it;
	ris << "]";
}
#else
sim dor(const c&) {ris;}
#endif
};
#define imie(...) " [" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0);
	int k;
	cin >> k;
	if (k % 7 == 0) k /= 7;
	if (gcd(10, k) != 1) {
		cout << "-1\n";
		return 0;
	}
	long long v = 1 % k;
	int len = 1;
	while (v != 0) {
		v = (10 * v + 1) % k;
		len++;
	}
	cout << len << '\n';
	return 0;
}


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

int main() {
	long long n, a = 0;
	cin >> n;
	long long m = n;
	while(n / 10 != 0){
		a += n % 10;
		n = n - (n % 10);
		n /= 10;
	}
	a += n;
	if(m % a == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc054/tasks/abc054_c

int edges[10][10];

int main() {
    int N, M; cin >> N >> M;
    int a, b;
    REP(i, M) {
        cin >> a >> b;
        edges[a][b] = 1;
        edges[b][a] = 1;
    }

    vector<int> perm(N-1);
    REP(i, N-1) {
        perm[i] = i + 2;
    }
    sort(perm.begin(), perm.end());

    int ans = 0;
    do {
        int now = 1;
        for (int i = 0; i < perm.size(); i++) {
            if (!edges[now][perm[i]]) break;
            now = perm[i];
            if (i == perm.size() - 1) ans ++;
        }
    } while(next_permutation(perm.begin(), perm.end()));

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        boolean j =true;
        int o;
        for(int i=0;;i++){
            String s = sc.nextLine();
        	o=0;
            	if(s.equals("0"))break;
            for(int a=0;a<s.length();a++){
            o+=(Character.getNumericValue(s.charAt(a)));
            }
            System.out.println(o);
        }
        sc.close();
    }
}


Measured memory_bytes: 26588
#include <bits/stdc++.h>
using namespace std;
const int maxn=300005;
int w,h,n;
struct point{
	int x,y;
}p[maxn],stack1[maxn],stack2[maxn];
int Hash[maxn*2],all;
int add[maxn*8],Max[maxn*8],ans;
bool cmp1(point a,point b){
	return a.y>b.y;
}
void LSH(){
	int tot=0;
	Hash[++tot]=0,Hash[++tot]=w,Hash[++tot]=h;
	for (int i=1;i<=n;i++)
		Hash[++tot]=p[i].x,Hash[++tot]=p[i].y;
	sort(Hash+1,Hash+tot+1);
	all=1;
	for (int i=2;i<=tot;i++)
		if (Hash[i]!=Hash[i-1]) Hash[++all]=Hash[i];
	for (int i=1;i<=n;i++){
		p[i].x=lower_bound(Hash+1,Hash+all+1,p[i].x)-Hash;
		p[i].y=lower_bound(Hash+1,Hash+all+1,p[i].y)-Hash;
	}
	w=lower_bound(Hash+1,Hash+all+1,w)-Hash;
	h=lower_bound(Hash+1,Hash+all+1,h)-Hash;
}
void build(int rt,int L,int R){
	add[rt]=0;
	if (L==R){
		Max[rt]=2*(Hash[w]-Hash[1]+Hash[L]);
		return;
	}
	int mid=(L+R)>>1;
	build(rt<<1,L,mid);
	build((rt<<1)|1,mid+1,R);
	Max[rt]=max(Max[rt<<1],Max[(rt<<1)|1]);
}
void pushdown(int rt){
	if (add[rt]){
		int lc=rt<<1,rc=(rt<<1)|1;
		add[lc]+=add[rt],add[rc]+=add[rt];
		Max[lc]+=add[rt],Max[rc]+=add[rt];
		add[rt]=0;
	}
}
void change(int rt,int L,int R,int CL,int CR,int val){
	if (CL>CR || CL>R || CR<L) return;
	if (CL<=L && CR>=R){
		Max[rt]+=val,add[rt]+=val;
		return;
	}
	pushdown(rt);
	int mid=(L+R)>>1;
	change(rt<<1,L,mid,CL,CR,val);
	change((rt<<1)|1,mid+1,R,CL,CR,val);
	Max[rt]=max(Max[rt<<1],Max[(rt<<1)|1]);
}
void solve(){
	sort(p+1,p+n+1,cmp1);
	build(1,1,h);
	int top1=0,top2=0;
	stack1[0].y=stack2[0].y=h;
	for (int i=1;i<=n;i++)
	if (Hash[p[i].x]*2<=Hash[w]){
		ans=max(ans,Max[1]-Hash[p[i].y]*2);
		change(1,1,h,p[i].y+1,stack1[top1].y,-2*(Hash[p[i].x]-Hash[0]));
		while (top1 && p[i].x>stack1[top1].x){
			change(1,1,h,stack1[top1].y+1,stack1[top1-1].y,-2*(Hash[p[i].x]-Hash[stack1[top1].x]));
			top1--;
		}
		stack1[++top1]=p[i];
	}
	else{
		ans=max(ans,Max[1]-Hash[p[i].y]*2);
		change(1,1,h,p[i].y+1,stack2[top2].y,-2*(Hash[w]-Hash[p[i].x]));
		while (top2 && p[i].x<stack2[top2].x){
			change(1,1,h,stack2[top2].y+1,stack2[top2-1].y,-2*(Hash[stack2[top2].x]-Hash[p[i].x]));
			top2--;
		}
		stack2[++top2]=p[i];
	}
	ans=max(ans,Max[1]);
}
int main(){
	scanf("%d%d%d",&w,&h,&n);
	for (int i=1;i<=n;i++)
		scanf("%d%d",&p[i].x,&p[i].y);
	LSH();
	ans=0;
	solve();
	swap(w,h); for (int i=1;i<=n;i++) swap(p[i].x,p[i].y);
	solve();
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  bool ok = true;
  rep(i, n - 1) {
    if (h[i] < h[i + 1]) {
      h[i + 1]--;
    }
    if (h[i] > h[i + 1]) {
      ok = false;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long
#define W V<L>
L E=70,M=2e17,i,a,b;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}for(L i;i<2;i++){L c=0;for(W x:T[!i]){c^=(2*x[0]+x[1])%3+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}int main(){cin>>i;V<W>p(i);while(i--){cin>>a>>b;p[i]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        boolean[][] A = new boolean[N][N];
                        for (int i = 0; i < N; i++) {
                                int now = sc.nextInt() - 1;
                                int M = sc.nextInt();
                                for (int j = 0; j < M; j++) {
                                        A[now][sc.nextInt() - 1] = true;
                                }
                        }
                        for (int i = 0; i < N; i++) {
                                for (int j = 0; j < N; j++) {
                                        if (A[i][j]) {
                                                System.out.print(1);
                                        } else {
                                                System.out.print(0);
                                        }
                                        if (j == N - 1) {
                                                System.out.print("\n");
                                        } else {
                                                System.out.print(" ");
                                        }
                                }
                        }
                }
        }
}

Measured memory_bytes: 34796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
vpii solve(int n)
{
    vpii res;
    for (int i = 2; i * i <= n; i++)
        if (!(n % i))
        {
            pii cur = {i, 0};
            while (!(n % i))
                n /= i, cur.se++;
            res.push_back(cur);
        }
    if (n > 2)
        res.push_back({n, 1});
    return res;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vpii v = solve(n);
    int res = 0;
    for (auto& it : v)
    {
        int cur = 1;
        while (it.se >= cur)
            it.se -= cur, cur++;
        res += cur - 1;
    }
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int main() {
	int K;
	string S;
	cin >> K >> S;
	if (S.size() > K) {
		S.erase(K);
		S = S + "...";
	}
	cout << S;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

void solve() {
	ll a, b, c; cin >> a >> b >> c;
	ll le = 4 * a*b;
	ll ri = c - (a + b);
	if (ri < 0) {
		cout << "No" << endl; return;
	}
	ri = ri * ri;
	if (le < ri) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define rep(i,a,b) for(register int i(a);i <= b;i++)
#define ll long long
using namespace std;
const int mod = 1000000007;
int main()
{
	int n,x,k(0);ll ans(1);
	scanf("%d",&n);
	rep(i,1,n)
	{
		scanf("%d",&x);++k;
		if(x < (k << 1) - 1) ans *= k,ans %= mod,--k;
	}
	while(k != 1) ans *= k,ans %= mod,--k;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string n;
	cin >> n;
	bool ans = (n[0] == n[1] && n[1] == n[2]);
	ans |= (n[1] == n[2] && n[2] == n[3]);
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int ans = 0;
        for (int i = 1; i <= N; i += 2)
        {
            if (CountDivisor(i) == 8) ans++;
        }
        Console.WriteLine(ans);
    }
    static int CountDivisor(int n)
    {
        int count = 1; 
        for(int i = 1; i < n; i++)
        {
            if (n % i == 0) count++;
        }
        return count;
    }
}


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

using namespace std;

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

    vector<int> C[3];
    const constexpr int R = 0, G = 1, B = 2;
    auto f = [&](auto c){
        if (c == 'R') return 0;
        if (c == 'G') return 1;
        return 2;
    };

    for (int i = 0; i < n; i++){
        C[f(S[i])].push_back(i);
    }

    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (S[i] == S[j])
                continue;
            auto &c = C[3 - f(S[i]) - f(S[j])];
            ans += c.end() - lower_bound(c.begin(), c.end(), j + 1);
            if (j + (j - i) < n and f(S[j + j - i]) == 3 - f(S[i]) - f(S[j]))
                ans--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	r := shellsort(a)
	fmt.Println(r)
	for i := 0; i < len(a); i++ {
		fmt.Println(a[i])
	}
}

func isort(a []int, g int) int {
	rcnt := 0
	for i := g; i < len(a); i++ {
		v := a[i]
		j := i - g
		for j >= 0 && a[j] > v {
			a[j+g] = a[j]
			j = j - g
			rcnt++
		}
		a[j+g] = v
	}
	return rcnt
}

func shellsort(a []int) int {
	rcnt := 0
	G := make([]int, 0)
	h := 1
	for {
		if h > len(a) {
			break
		}
		G = append(G, h)
		h = 3*h + 1
	}
	fmt.Println(len(G))
	for i := len(G) - 1; i >= 0; i-- {
		fmt.Printf("%d", G[i])
		if i > 0 {
			fmt.Printf(" ")
		}
	}
	fmt.Println()
	for i := len(G) - 1; i >= 0; i-- {
		rcnt += isort(a, G[i])
	}
	return rcnt
}



Measured memory_bytes: 17492
N = int(input())
A = (input().split())
i_count = 0
test = []
for i in A:
  num = int(i) % 2
  if num == 0 :
    test.append(i)

for i in test:
  num3 = int(i) % 3
  num5 = int(i) % 5
  if num3 == 0 or num5 ==0:
    i_count += 1

if i_count == len(test):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int up(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}

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

  int a[n][2] , b;
  for(int i = 0;i < n;i ++){
    scanf("%d",&b);
    a[i][0] = b;
    a[i][1] = i+1;
  }
  
 qsort(a,n,sizeof(int)*2,up);

 for(int i = 0;i < n;i ++){
   printf("%d ",a[i][1]);
 }

  return 0;
}

Measured memory_bytes: 1788
#coding: utf-8
import math
x=int(input())
r=math.floor(math.sqrt(x))
i=2
j=2
ans=1
while(i<=r):
    while(i**j<=x):
        j+=1
    if(i**(j-1)>ans):
        ans=i**(j-1)
    j=2
    i+=1
print(ans)

Measured memory_bytes: 3060
from collections import Counter

N = int(input())
s_list = []
for _ in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    s_list.append(s_sorted)

C = Counter(s_list)
ans = 0
for x in C.values():
    ans += (x * (x - 1)) // 2

print(ans)


Measured memory_bytes: 68312
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	forn(i, s.size()){
		if(s[i] + n > 'Z'){
			s[i] = 'A' + n - ('Z' - s[i]) - 1;
		}else s[i] += n;
	}
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 256
a = list(str(input()))
b = list(str(input()))
c = list(str(input()))

from collections import deque
a = deque(a)
b = deque(b)
c = deque(c)

t = a.popleft()
while True:
  if t == 'a':
    if len(a) == 0:
      print('A')
      exit()
    else:
      t = a.popleft()
  elif t == 'b':
    if len(b) == 0:
      print('B')
      exit()
    else:
      t = b.popleft()
  else:
    if len(c) == 0:
      print('C')
      exit()
    else:
      t = c.popleft()

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>

int main(void){
    int N,M,X,Y;
    std::cin>>N>>M>>X>>Y;
    std::vector<int> x;
    std::vector<int> y;
    int input;
    for(int i=0;i<N;i++){
        std::cin>>input;
        x.push_back(input);
    }
    for(int i=0;i<M;i++){
        std::cin>>input;
        y.push_back(input);
    }

    int xmax=*std::max_element(x.begin(),x.end());
    int ymin=*std::min_element(y.begin(),y.end());
    int X_MAX,Y_MIN;
    X_MAX=std::max(xmax,X);
    Y_MIN=std::min(ymin,Y);
    if(X_MAX<Y_MIN){
        std::cout<<"No War"<<std::endl;
    }else{
        std::cout<<"War"<<std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d,ans1,ans2;
  cin >> n >> a >> b >> c >> d;

  if(n%a==0) ans1 = b*(n/a);
  else{
  ans1 = n/a+1;
  ans1 = ans1*b;
  }
  if(n%c==0) ans2 = d*(n/c);
  else{
  ans2 = n/c+1;
  ans2 = ans2*d;
  }

  if(ans1<ans2) cout << ans1 << endl;
  if(ans1>ans2) cout << ans2 << endl;
  if(ans1==ans2) cout << ans1 << endl;

  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<string> key={".,!? ","abc","def","ghi","jkl","mno",
					"pqrs","tuv","wxyz"};
int main(){
	int n;	cin>>n;
	while(n--){
		string s;	cin>>s;
		s+='0';
		string ret="";
		for(int i=1;i<s.size();i++){
			while(i<s.size()&&s[i]==s[i-1]&&s[i]=='0'){
				s.erase(s.begin()+i);
			}
		}
		while(s[0]=='0')	s.erase(s.begin());
		int type=s[0]-'0'-1;
		int push=0;
		for(int i=1;i<s.size();i++){
			if(type==s[i]-'0'-1)	push=(push+1)%key[type].size();
			else if(s[i]=='0'){
				ret+=key[type][push];
				if(i+1<s.size()){
					type=s[i+1]-'0'-1;
					push=-1;
				}
				else 	type=-1;
			}
			else{
				ret+=key[type][push];
				type=s[i]-'0'-1;
				push=0;
			}
		}
		if(type!=-1){
			ret+=key[type][push];
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 3160
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long count = 0;
		Map<Long, Integer> map = new HashMap<>();
		map.put(0L, 1);
		long a = 0;
		for (int i=0;i<n;i++){
			a += sc.nextInt();
			Integer num = map.get(a%m);
			if (num!=null) {
				count+=num;
				map.put(a%m, num+1);
			} else
				map.put(a%m, 1);
		}
		System.out.println(count);
		
	}

}


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

using namespace std;

using ll = int64_t;
using ull = uint64_t;
using ld = long double;

const int MX = 100 * 1000 + 7;

ll x[MX];
ll v[MX];
ll ps[MX];



int main() {
#ifdef NIZNIY_MAGAZIN_MIR_V_CENTRE_VINNITSY
    freopen("in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    ll c;
    cin >> n >> c;
    set<pair<ll, int> > go1, go2;

    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
        ps[i] = ps[i - 1] + v[i];
    }
    go1.emplace(0, 0);
    go2.emplace(0, 0);
    for (int i = 1; i <= n; i++) {
        go1.emplace(ps[i] - x[i], i);
        go2.emplace(ps[i] - x[i] - x[i], i);
    }

    ll ans = go1.rbegin()->first;

    ll csum = 0;
    for (int i = n; i >= 1; i--) {
        go1.erase(make_pair(ps[i] - x[i], i));
        go2.erase(make_pair(ps[i] - x[i] - x[i], i));
        csum += v[i];
        ll cdist = c - x[i];
        ans = max(ans, csum - cdist - cdist + go1.rbegin()->first);
        ans = max(ans, csum - cdist  + go2.rbegin()->first);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 15104
import java.util.Scanner;

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

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

Measured memory_bytes: 26324
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCode
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            string result;
            if(a >= 1000)
            {
                result = "ABD";
            }
            else{
                result = "ABC";
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.next();
		if(in.equals("A")) {
			System.out.println("T");
		} else if(in.equals("T")) {
			System.out.println("A");
		} else if(in.equals("C")) {
			System.out.println("G");
		} else {
			System.out.println("C");
		}
	}

}


Measured memory_bytes: 23636
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c){
    LL ans=10101010;
    LL minA = 10101010;
    LL minB = 10101010;
    REP(i, A)minA = min(minA,a[i]);
    REP(i, B)minB = min(minB,b[i]);
    ans = min(ans, minA+minB);
    
    LL minM = 101001010;
    REP(i, M){
        minM = min(minM, a[x[i]]+b[y[i]]-c[i]);
    }
    ans = min(minM, ans);
    cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&c[i]);
        x[i]--;y[i]--;
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> h(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
    }
    vector<int> dp(n + 1);
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n];
}

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

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> tree(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<int> count(N, 0), ans(N, -1);
    
    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        p--;
        count[p] += x;
    }

    queue<int> q;
    q.push(0);
    ans[0] = count[0];

    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto nv : tree[v]) {
            if (ans[nv] >= 0) continue;
            ans[nv] = ans[v] + count[nv];
            q.push(nv);
        }
    }

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


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

int main() {
  string s, t;
  cin >> s >> t;
  int answer = 0;
  int a = s.size();

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == t.at(i)) {
      answer++;
    }
  }
  if (answer == a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}


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

constexpr long long int M = 1000000007;

template<int N>
struct Fact{
  long long int val[N];
  long long int v2[N];
  constexpr Fact() : val(), v2() {
    val[0] = 1;
    for(int i = 1; i < N; ++i)val[i] = val[i - 1] * i % M;
    for(int i = 1; i < N; ++i)v2[i] = val[i - 1] * val[i] % M;
  }
};

template<int N, long long F>
struct IFact{
  long long int val[N];
  constexpr IFact() : val() {
    val[N - 1] = F;
    for(int i = N - 1; i > 0; --i)val[i - 1] = val[i] * i % M;
  }
};

long long int N, ans;
constexpr auto fact = Fact<1000000>();
constexpr auto ifact = IFact<1000000, 498215386>();

int main(){
    scanf("%lld", &N);
    for(int i = N / 2; i < N - 1; ++i){
        ans += fact.v2[i] * ifact.val[i * 2 - N] % M;
    }
    ans = fact.val[N - 1] * (N - 1) - ans;
    ans %= M;
    cout << (ans > 0 ? ans : M + ans) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	m=10**9+7
	n,a,b=MI()
	f=[1]
	for i in range(b+5):
		t=f[-1]*(n-i)*pow(i+1,m-2,m)
		t%=m
		f.append(t)
	#print(f)

	ans=pow(2,n,m)-1-f[a]-f[b]
	ans%=m
	print(ans)




























if __name__ == "__main__":
	main()


Measured memory_bytes: 91528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

def bfs(c,sy=0, sx=0, gy=0, gx=0, blocks=['#'], dire=[(1,0), (0,1), (-1,0), (0,-1)], return_maximum_distance=False):
    H = len(c)
    W = len(c[0])
    distance_limit = H*W+1
    dist = [[distance_limit]*W for i in range(H)]

    q = deque()

    q_append = q.append
    q_popleft = q.popleft

    if (type(sy)==list) or (type(sx)==list):
        for syi, sxi in zip(sy, sx):
            dist[syi][sxi] = 0
            q.append((syi, sxi))
    else:
        dist[sy][sx] = 0
        q_append((sy, sx))

    while q:
        y, x = q_popleft()
        d = dist[y][x]
        for dy, dx in dire:
            if (y+dy<H) and (y+dy>=0) and (x+dx<W) and (x+dx>=0):
                if (c[y+dy][x+dx] in blocks):
                    continue
                else:
                    if (dist[y+dy][x+dx] > d+1):
                        dist[y+dy][x+dx] = d+1
                        q_append((y+dy, x+dx))
                    if (y+dy==gy) and (x+dx==gx):
                        return (d+1)
    if (return_maximum_distance):
        return d
    return -1

H, W = LI()
c = SR(H)

sy = []
sx = []

for i in range(H):
    for j in range(W):
        if (c[i][j]=="#"):
            sy.append(i)
            sx.append(j)

print(bfs(c, sy, sx, sy, sx, return_maximum_distance=True))


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

int main() {
	int L,R;
	cin >> L >> R;
	
	int ModMin = 2019;
	rep(i,L,R){
        rep(j,i+1,R){
            int64_t Val= (int64_t)i * j;
            int tmpMod = Val % 2019;
            ModMin = min(tmpMod, ModMin);
            if(ModMin == 0) break;
        }
        if(ModMin == 0) break;
	}

    cout << ModMin << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  string ans="No";
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n){
        ans="Yes";
      }
    }
  }
  cout<<ans<<endl;
}

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

signed main(void){
  int N; cin >> N;
  vector<int> Set1,Set2;
  for(int i = 1; i <= N; i++){
    int a; cin >> a;
    Set1.push_back(i-a);
    Set2.push_back(i+a);
  }
  
  sort(Set1.begin(),Set1.end());
  sort(Set2.begin(),Set2.end());
  
  int ans = 0;
  
  for(auto X : Set2){
    
    int itr1 = lower_bound(Set1.begin(),Set1.end(),X)-Set1.begin();
    int itr2 = upper_bound(Set1.begin(),Set1.end(),X)-Set1.begin();
    
    ans += itr2-itr1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6540
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;
    ll res = max(0LL, a - 2 * b);
    cout << res << endl;
    return 0;
}

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

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

  int maxVal = 0;
  int p;
  int sum = 0;

  for(int i = 0; i < n; i++){
    cin >> p;

    if(p > maxVal){
      sum += maxVal;
      maxVal = p;
    }

    else sum += p;

  }

  cout << sum + maxVal/2 << endl;

  return 0;

}



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

int main(){
	int N;
	int p[51];
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> p[i];
	}
	
	int cnt = 0;
	
	for (int i = 1; i < N; i++){
		if ( cnt <=1 && p[i] > p[i+1]) {
			for(int j = N; j >= 1; j--){
				if( j == i )continue;
				if( p[i] > p[j] ){
					swap(p[i],p[j]);
					cnt++;
					i = 1;
				}
			}
		}
		else if (cnt > 1 && p[i] > p[i+1]) break;
	}
	
	if(cnt <= 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
eval"H,W,*A="+`dd`.split*?,
t=1e4
A.pop(H*W).zip(A){|a,b|a=(a-b).abs
$.%W<1&&N=0
N|=$*[-W]||0**$.<<t
$*<<N=N<<a|N>>a
$.+=1}
p (0..t).find{|i|N[t+i]+N[t-i]>0}

Measured memory_bytes: 37000