akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    r = I()
    print(3 * r * r)

main()



Measured memory_bytes: 64364
(function(input) {
    var a = parse(input);
    var w = a[0][0];
    a.shift();
    var ws = {};
    for (var i = 0; i < a.length; i++) {
        var l = a[i];
        for (var j = 0; j < l.length; j++) {
            var s = l[j];
            if (s == 'END_OF_TEXT') {
                break;
            }
            s = s.toLowerCase();
            if (s in ws) {
                ws[s]++;
                continue;
            }
            ws[s] = 1;
        }
    }
    console.log(ws[w]);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function parse(str, sep, ter) {
    sep = typeof(sep) !== 'undefined' ? sep : ' ';
    ter = typeof(ter) !== 'undefined' ? ter : '\n';
    str = str.replace(/\n$/, '');
    var a = str.split(ter);
    for (var i = 0; i < a.length; i++) {
        a[i] = a[i].split(sep);
    }
    return a;
}

Measured memory_bytes: 8436
#include <iostream>
using namespace std;
int main () {
	int n;
	cin >> n;
	int a[n];
	int zeronum = 0;
	for (int i = 0;i < n;i++) {
		char c;
		cin >> c;
		if (c == 'R') {
			a[i] = 0;
			zeronum += 1;
		} else {
			a[i] = 1;
		}
	}
	int zeros = 0, ones = 0;
	int ans = 10000000;
	for (int i = 0;i <= n;i++) {
		int m = 0;
		if (zeronum - zeros > ones) {
			m = zeronum - zeros;
		} else {
			m = ones;
		}
		//cout << i << " " << m << endl;
		if (m < ans) {
			ans = m;
		}
		if (i < n) {
			if (a[i] == 0) {
				zeros += 1;
			} else {
				ones += 1;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin >> b;
  if(b == 'A'){
    cout << 'T' << endl;
  }else if(b == 'C'){
    cout << 'G' << endl;
  }else if(b == 'G'){
    cout << 'C' << endl;
  }else if(b == 'T'){
    cout << 'A' << endl;
  }
}


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


int main(){
  int n,k;string s;
  cin>>n>>k>>s;
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1])ans++;
  }
  ans+=2*k;
  if(ans>=n-1){
    cout<<n-1<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    char s[19];
    rep(i,19)cin>>s[i];
    s[5]=s[13]=' ';
    rep(i,19)cout<<s[i];
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	io_init;
	int N;
	cin >> N;
	vector<int> A(N),ans(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		ans[0] += A[i] * pow(-1, i);
	}
	ans[0] /= 2;
	for (int i = 0; i < N-1; i++) {
		ans[i + 1] = A[i] - ans[i];
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] * 2 << " ";
	}
	cout << endl;
}


Measured memory_bytes: 2176
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.math.*;
import java.io.*;


public class Main {
    static boolean properTriangle(long... e){
        if(e.length != 3) return false;
        Arrays.sort(e);
        if(e[0] == e[1]) return false;
        if(e[1] == e[2]) return false;
        return e[0]+e[1] > e[2];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] L = new long[N];

        for(int n=0; n<N; n++) L[n] = sc.nextLong();
        Arrays.sort(L);

        long ans = 0;

        for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) for(int k=j+1; k<N; k++){
            if(properTriangle(L[i], L[j], L[k])) ans++;
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 42920
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int A[4005]={0};

int main(){
  int n;
  ll rn=0;
  ll gn=0;
  ll bn=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    char c;
    cin>>c;
    if(c=='R'){rn++;A[i]=1;}
    else if(c=='G'){gn++;A[i]=2;}
    else{bn++;A[i]=3;}
  }
  ll ans=rn*gn*bn;
  for(int i=1;1+2*i<=n;i++){
    for(int j=1;j+2*i<=n;j++){
      if(A[j]!=A[j+i]&&A[j+i]!=A[j+2*i]&&A[j]!=A[j+2*i])ans--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int h, n;
    cin >> h >> n;
    vector<pair<int, int> > ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    
    vi dp(h+1);
    rep(i, h) {
        int mi = 1000000000;
        rep(j, i){ 
            mi = min(mi, dp[j+1] + dp[i-j]);
        } 
        rep(j, n) {
            if(ab[j].first > i) {
                mi = min(mi, ab[j].second);
            }
        }
        dp[i+1] = mi;
    }

    cout << dp[h] << endl;
}

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

int main(){
	
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if ( A + B > C + D ){
		cout << " Left " << endl;
	} else if ( A + B == C + D ){
		cout << " Balanced " << endl;
	} else {
		cout << " Right " << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  map<string,int> data;
  int MAX=-1;
  for(int i=0;i<N;i++){
    string tmp;
    cin>>tmp;
    data[tmp]++;
    MAX=max(MAX,data[tmp]);
  }
  for(auto moji:data){
    if(moji.second==MAX){
      cout<<moji.first<<endl;
    }
  }
  

}

Measured memory_bytes: 25216
import math
a,b = map(int, input().split())
x = math.ceil(a/0.08)
y = math.ceil(b/0.10)
ans1 = 10**8
ans2 = 10**8
while math.floor(x*0.08) == a and math.floor(x*0.1) == b:
    ans1 = x
    x -= 1
while math.floor(y*0.08) == a and math.floor(y*0.1) == b:
    ans2 = y
    y -= 1
print(min(ans1,ans2) if min(ans1,ans2)!=10**8 else -1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <iomanip>
typedef long long LL;
using namespace std;
typedef pair<int, int> Pii;
typedef pair<LL, LL> PLL;
const int maxn = 2E5 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string S, T;
	cin >> S >> T;
	int len = S.length();
//	int mp[maxn];
	map<char, int> mp;
	for(int i = 0; i <= 25; i++){
		char b = 'a' + i;
		mp[b] = 0;     
	}
	bool ok = true;
//	memset(mp, 0, sizeof(mp));
	for(int i = 0; i <= len - 1; i++){
		if(mp[S[i]] == 0){
			mp[S[i]] = T[i];
		}else{
			if(T[i] != mp[S[i]]){ puts("No"); return 0;}
		}
	}
//	memset(mp, 0, sizeof(mp));
	for(int i = 0; i <= 25; i++){
		char b = 'a' + i;
		mp[b] = 0;     
	}
	for(int i = 0; i <= len - 1; i++){
		if(mp[T[i]] == 0){
			mp[T[i]] = S[i];
		}else{
			if(S[i] != mp[T[i]]){ puts("No"); return 0;}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll H,N;
    cin >>H>>N;
    vector<ll> A(N);

    rep(i,N){
        ll a;
        cin >>a;
        H -= a;
    }
    if(H<=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    


    return 0;
    

}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; LL ans=1;
    cin >> N;
    for (int i = 2; i <= N; i *= 2)
    {
        ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

type Queue struct {
	v []int
}

func NewQueue() Queue {
	return Queue{make([]int, 0)}
}

func (s *Queue) Enqueue(x int) {
	s.v = append(s.v, x)
}

func (s *Queue) Front(w *bufio.Writer) {
	lenS := len(s.v)
	if lenS > 0 {
		w.WriteString(fmt.Sprintf("%d\n", s.v[0]))
	}
}

func (s *Queue) Dequeue() {
	lenS := len(s.v)
	if lenS > 0 {
		s.v = s.v[1:]
	}
}

func (s Queue) String() string {
	return strings.Trim(fmt.Sprint(s.v), "[]")
}

func NextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)

	n, _ := NextInt(sc)
	s := make([]Queue, n)
	for i := 0; i < n; i++ {
		s[i] = NewQueue()
	}

	q, _ := NextInt(sc)
	for i := 0; i < q; i++ {
		cmd, _ := NextInt(sc)
		t, _ := NextInt(sc)
		switch cmd {
		case 0:
			x, _ := NextInt(sc)
			s[t].Enqueue(x)
		case 1:
			s[t].Front(w)
		case 2:
			s[t].Dequeue()
		}
	}

	w.Flush()
}



Measured memory_bytes: 8840
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[1<<21] = {};

int main() {
    nfs
    int i, j, mask, n, bit;
    cin >> n;
    dp[0] = 1;
    for (i = 0; i < n; i++) {
        
        // cout << i << endl;
        int coolMask = 0;
        for (j = 0; j < n; j++) {
            cin >> bit;
            coolMask ^= bit ? 1<<j : 0;
        }
        
        for (mask = 0; mask < (1<<n); mask++) {
            // cout << mask << ',' << endl;
            if (__builtin_popcount(mask) == i + 1) {
                int checkMask = mask & coolMask;
                while (checkMask) {
                    int lastPos = checkMask & (-checkMask);
                    dp[mask] = (dp[mask] + dp[mask^lastPos]) % mod;
                    checkMask ^= lastPos;
                }
            }
        }
    }
    cout << dp[(1<<n) - 1];
}

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


int main() {
  int N;
	cin >> N;
  vector<int> X(N);
  vector<int> Y(N);
  vector<int> ind(N);
  iota(ind.begin(),ind.end(),0);
  for(int i = 0; i < N; i++){
  	cin >> X.at(i) >> Y.at(i);
  }
  
  long long fact = 1;
  double sum = 0;
  
  for(int i = 1; i <= N; i++) fact *= i;
  
  for(int i = 0; i < fact; i++){
    for(int j = 0; j < N - 1; j++){
    	double distX = X.at(ind.at(j)) - X.at(ind.at(j+1));
        double distY = Y.at(ind.at(j)) - Y.at(ind.at(j+1));
      	sum += sqrt(distX*distX + distY*distY);
    }
  next_permutation(ind.begin(),ind.end());
  }
  
  cout << fixed << setprecision(10);
  cout << sum/fact <<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[101];
	int flag1=0,flag2=0;
	cin.getline(a,101);
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='C')	flag1=1;
		else if(a[i]=='F')	flag2=1;
		if(flag2&&flag1==0)
			flag2=0;
		else if(flag1&&flag2){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main( void ){
    int n, m, k, x;
    cin >> n >> m;
    vector<int> a(m, 0);
    for(int i=0; i<n; i++){
        cin >> k;
        for(int j=0; j<k; j++){
            cin >> x;
            a[x-1] += 1;
        }
    }
    int cnt = 0;
    for(int i=0; i<m; i++){
        if(a[i] == n) cnt+=1;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
B = []

for v, c in zip(V, C):
    B.append(v - c)

total_b = 0
for b in B:
    if b > 0:
        total_b += b

print(total_b)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int ans = 0;
    char cur = '@';
    rep(i, s.size())
    {
        if (cur != s[i])
        {
            ans++;
            cur = s[i];
        }
    }
    cout << ans - 1 << endl;
    return 0;
}

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

     
int main() {
	string s;
	cin >> s;
	int ans = s.size();
	for (int i = 0; i < s.size(); i++) {
		string a = s.substr(i, 1);
		string b = s.substr(i + 1, 1);
		
		if (a == b) {
			ans--;
			i += 2;
		}
		else {
		}
	}
 
	cout << ans << endl;
 
 
	return 0;
}

Measured memory_bytes: 640
#include <algorithm> // std::sort(begin,end)
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<ll> v(2 * n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i + n] = v[i];
  }
  ll my_max = 0, tmpsum;
  for (int start = n - min(k,n); start <= n; start++) {
    for (int end = start + min(k,n) - 1; end >= n - 1; end--) {
      tmpsum = 0;
      priority_queue<int> q;
      for (int i = start; i <= end; i++) {
        //cerr<< v[i] << " ";
        tmpsum += v[i];
        if (v[i] < 0) {
          q.push(-v[i]);
        }
      }
      //cerr<< ";" << endl ;
      for (int i = 0; i < k - (end - start + 1) && (!q.empty()); i++) {
        tmpsum += q.top();
        //cerr<< "pop" << -q.top();
        q.pop();
      }
      //cerr<< "tmpsum" << tmpsum << endl;
      my_max = max(my_max,tmpsum);
    }
  }
  cout << my_max << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    int N; cin >> N;
    vector<pair<ll,ll> > x(N);
    ll out = 0;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        x[i].first = a+b;
        x[i].second = a-b;
    }
    sort(x.begin(),x.end());
    ll now = -1*10e9;
    for(int i=0;i<N;i++){
        int r = x[i].first;
        int l = x[i].second;
        //cerr << now << " " << out << "\n";
        if(l<now && now<=r){
            continue;
        }
            out++;
            now = r;
        
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
def num(n):
    return n*(n+1)//2

from sys import exit
N, K = [int(n) for n in input().split()]
if num(N-2) < K:
    print(-1)
    exit()
# 1をハブにしてつぶす
cnt = num(N-2) - K
print(N-1 + cnt)
for i in range(2, N+1):
    print(1, i)



while(cnt != 0):
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            print(i, j)
            cnt -= 1
            if cnt == 0:
                exit()


Measured memory_bytes: 42736
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
struct edge{int x,y,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int root,du[MAXN],n,num[MAXN],up[MAXN];
int tot[MAXN],ln;
void gg(){puts("NO");exit(0);}
void solve(int x,int fa)
{
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y!=fa)solve(y,x);
	}if(du[x]==1){up[x]=num[x];return ;}
	ln=0;LL sum=0;int mx=0;
	for(int k=last[x];k;k=a[k].next)if(a[k].y!=fa)tot[++ln]=up[a[k].y];
	for(int i=1;i<=ln;i++)sum+=tot[i],mx=max(mx,tot[i]);
	if(sum<num[x])gg();
	if(x!=root)
	{
		LL lim=0;
		if(mx>sum-mx)lim=sum-mx;else lim=sum/2;
		if(sum-lim>num[x])gg();
		up[x]=sum-2*(sum-num[x]);
	}
	else
	{
		LL lim=0;
		if(mx>sum-mx)lim=sum-mx;else lim=sum/2;
		if(lim*2!=sum)gg();if(lim!=num[x])gg();
	}
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)num[i]=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);++du[x];++du[y];
	}
	if(n==2)return puts(num[1]==num[2]?"YES":"NO"),0;
	for(int i=1;i<=n;i++)if(du[i]>=2){root=i;break;}
	solve(root,0);
	puts("YES");
	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,k;
  cin >> n >> k;

  vll x(n);
  REP(i, n)
    cin >> x[i];

  ll ans = 0;
  REP(i, n)
    ans += min(x[i], k-x[i])*2;

  cout << ans << endl;
}


Measured memory_bytes: 256
S = input()

if S == 'SUN':
    print('7')
elif S == 'MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
elif S == 'SAT':
    print('1')
else:
    print('No data')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
#define pi (acos(-1))
///#define for(i,a,b) for(i=(a);i<(b);++i)
///freopen("input.txt","r",stdin);
///   freopen("output.txt","w",stdout);
double l;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   cin>>l;
   cout<<setprecision(10)<<fixed<<(l/3)*(l/3)*(l/3)<<"\n";
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

Tone = M * 1900 + (N - M) * 100
Pone = 1.0 / 2**M
prob = 1 - 1.0 / 2**M

ans = 1
for time in range(2, 100000):
    ans += prob * time
    prob *= (1.0 - Pone)

print(int(ans * Tone * Pone + 0.5))

Measured memory_bytes: 39024
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    X, Y = Scanner.map_int()
    if (X + Y) % 3 != 0:
        print(0)
        return
    n = (X + Y) // 3
    X -= n
    Y -= n
    MAX = 670000
    fac = [0 for _ in range(MAX)]
    finv = [0 for _ in range(MAX)]
    inv = [0 for _ in range(MAX)]
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

    N = X + Y
    if N < X:
        print(0)
        return
    if N < 0 or X < 0:
        print(0)
        return
    ans = fac[N] * (finv[X] * finv[Y] % MOD) % MOD
    print(ans)
    return


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto &e : p) cin >> e;
  auto m = max_element(begin(p), end(p));
  int r = 0;
  for (auto i = begin(p); i != end(p); i++) r += i == m ? *i / 2 : *i;
  cout << r << endl;
}


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

int main (){
string s;
int n,k;
cin>>n>>s>>k;
char x = s[k-1];
for(int i = 0;i <n;i++){
if (s[i]!=x) s[i]='*';
cout<<s[i];
}
cout << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    int count = 0;
    rep(i, n) {
        if (a[i] == b[i])
            count++;
        else
            count = 0;
        if (count == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int k, x;
    cin >> k >> x;
    int min = -1000000;
    int max = 1000000;
    chmax(min, x - k + 1);
    chmin(max, x + k - 1);
    FOR(i, min, max + 1) { cout << i << " "; }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(input())

cnt=0
for i in range(1,n+1):
    wk=n//i
    if n%i==0:
        wk-=1
    cnt+=wk

print(cnt)

Measured memory_bytes: 67864
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F(i,n) for(long long int i=0;i<n;i++)
#define REF(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ln "\n"
#define m 1000000007
#define fastio ios::sync_with_stdio(0);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")


int main() {
    fastio;
    fast;
    string s;
    cin>>s;
    ll cnt=0;
    if(s[0]=='R' && s[1]=='R' && s[2]=='S')
        cnt=2;
    else if(s[0]=='S' && s[1]=='R' && s[2]=='R')
        cnt=2;
    else if(s[0]=='R' && s[1]=='S' && s[2]=='R')
        cnt=1;
    else if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        cnt=3;
    else if(s[0]=='R' && s[1]=='S' && s[2]=='S')
        cnt=1;
    else if(s[0]=='S' && s[1]=='R' && s[2]=='S')
        cnt=1;
    else if(s[0]=='S' && s[1]=='S' && s[2]=='R')
        cnt=1;
    else if(s[0]=='S' && s[1]=='S' && s[2]=='S')
        cnt=0;
    cout<<cnt<<ln;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std ;
int main(){
	long long a, b, x;
    long long ans=0;
    scanf("%lld %lld %lld",&a,&b,&x);
    if(a==0){
    	ans=(b/x)+1;
    	printf("%lld",ans);
	}
	else
	{
		ans=(b/x)-((a-1)/x);
		printf("%lld",ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def extended_euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1

    while c1 != 0:
        m = c0 % c1
        q = c0 // c1

        c0, c1 = c1, m
        a0, a1 = a1, (a0 - q * a1)
        b0, b1 = b1, (b0 - q * b1)

    # return c0, a0, b0
    return a0

def quotient(p, q): #p: 分子, q: 分母
	return (extended_euclid(q, MOD) * p) % MOD

def factorial(i):
	if i == 1:
		return 1
	else:
		return (factorial(i-1) * i) % MOD

inv_list = [1]
for i in range(2, n+1):
	inv_list.append((inv_list[-1] + quotient(1, i)) % MOD)

#print(inv_list[-1])
#print(factorial(n))

ans = 0
for i in range(n):
	ans += ((inv_list[i] + inv_list[n-1-i] - 1) * a[i]) % MOD
	ans %= MOD
ans *= factorial(n)
ans %= MOD
print(ans)

Measured memory_bytes: 91636
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	vector<int> a(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		cnt+=a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		if(a[i]*4*m>=cnt)sum++;
	}
	if(sum>=m){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

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

void sub(vector<int> &h, vector<int> &dp, int n) {
    for(int i = 2; i < n; i++) {
        int a = abs(h[i] - h[i-1]) + dp[i-1];        
        int b = abs(h[i] - h[i-2]) + dp[i-2];        
        if(a <= b) {
            dp[i] = a;
        }else {
            dp[i] = b;
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    sub(h,dp,n);
    int ans = dp[n-1];
    cout << ans << endl;
}

Measured memory_bytes: 1024
A, B, H ,M = map(int,input().split())

import math

if H == 12:
    H = 0

a_rad = 2 * math.pi * (H / 12 + M / 720)
b_rad = 2 * math.pi * (M /60)

ab_rad = a_rad - b_rad
ba_rad = b_rad - a_rad

if ab_rad == math.pi:
    d = A + B
if ab_rad == 0:
    d = B - A
if 0 < ab_rad < math.pi:
    d = math.sqrt(A**2 + B **2 - 2*A*B*math.cos(ab_rad))
else:
    d = math.sqrt(A**2 + B **2 - 2*A*B*math.cos(ba_rad))
print(d)
    

Measured memory_bytes: 9520
n, m = [int(i) for i in input().split()]
x = []
y = []
for i in range(m):
  x1,y1=[int(i) for i in input().split()]
  x.append(x1)
  y.append(y1)

z = min(y) - max(x)

if z >= 0:
  print (z+1)
else:
  print (0)


Measured memory_bytes: 10996
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Measured memory_bytes: 8908
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


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

    vector<ll> a(n), s(n+1);
    long i;
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }
    sort(a.begin(), a.end());

    s[0]=0;
    for(i=0; i<n; i++) {
        s[i+1]=s[i]+a[i];
    }
    if(s[n]==x) {
        printf("%ld\n", n); return 0;
    }

    for(i=1; i<=n; i++) {
        if(s[i]==x) {
            printf("%ld\n", i); return 0;
        }
        else if(s[i]>x) {
            printf("%ld\n", MAX(0, i-1)); return 0;
        }
    }
    printf("%ld\n", n-1);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int ma = 0;
    int mi = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << endl;
}

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

signed main(){
  int n;cin>>n;ll ans = 0;
  int c[5];rep(i,5)c[i] = 0;char cc[5] = {'M', 'A', 'R', 'C', 'H'};
  rep(i,n){
    string s;cin>>s;
    rep(j,5)if(s[0] == cc[j])c[j]++;
  }
  rep(i,1<<5){
    int count = 0;
    ll k = 1;
    rep(j,5){
      if(i & (1<<j)){
        k *= c[j];
        count++;
      }
    }
    if(count == 3){
      ans += k;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#if 0
IDが1から始まることをどのように扱うかを最初にしっかり定義していなかったせいで時間がかかってしまった。
#endif

#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

map<int, vector<int>> init(int N)
{
    map<int, vector<int>> P;
    for (int i = 0; i < N; i++)
    {
        int id, dataNum;
        cin >> id >> dataNum;
        vector<int> temp;
        for (int j = 0; j < dataNum; j++)
        {
            int tempNode;
            cin >> tempNode;
            temp.push_back(tempNode);
        }
        P[id - 1] = temp; // P[i] = 隣接ノード
    }
    return P;
}

int main()
{
    int N;
    cin >> N;
    map<int, vector<int>> P = init(N);
    int distance[N];
    for (int i = 0; i < N; i++)
    {
        distance[i] = -1;
    }
    distance[0] = 0;
    queue<int> Q = queue<int>({0});
    while (!Q.empty())
    {
        int cur = Q.front(); // 現在地
        Q.pop();
        for (int itr = 0; itr < P[cur].size(); itr++)
        {
            int dst = P[cur][itr] - 1;
            if (distance[dst] == -1)
            {
                distance[dst] = distance[cur] + 1;
                Q.push(dst);
            }
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << i + 1 << " " << distance[i] << endl;
    }
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool used[100010];
vector<ll> p(100010);
set<ll> st1, st2;
vector<ll> g[100010];
void dfs(int s) {
  if(used[s]) return;
  used[s] = true;
  st1.insert(p[s]);
  st2.insert(s);
  ll ret = 0;
  for(int i=0;i<g[s].size();i++) {
    dfs(g[s][i]);
  }

}
int main() {
  ll N, M;
  cin >> N >> M;
  for(int i=0;i<N;i++) {
    cin >> p[i];
    p[i]--;
  }


  for(int i=0;i<M;i++) {
    ll xi, yi;
    cin >> xi >> yi;
    xi--; yi--;
    g[xi].push_back(yi);
    g[yi].push_back(xi);
  }


  ll ans = 0;
  for(int i=0;i<N;i++) {
    dfs(i);
    for(auto itr=st1.begin();itr != st1.end();++itr) {
      ans += st2.count(*itr);
    }
    st1.clear();
    st2.clear();
  }
  cout << ans << endl;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    string S;
    cin >> S;
    int N = S.length();
    vector<vector<int>> dp(N + 1, vector<int>(2));
    for (int i = 0; i < N; ++i) {
        dp[i + 1][0] = dp[i][1] + 1;
        if (i == 0 || S[i] != S[i - 1])
            dp[i + 1][0] = max(dp[i][0] + 1, dp[i + 1][0]);
        if (i > 0)
            dp[i + 1][1] = max(dp[i - 1][0] + 1, dp[i + 1][1]);
    }

    cout << max(dp[N][0], dp[N][1]) << endl;

    return 0;
}


Measured memory_bytes: 14412
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Calc c = new Calc();
		c.abc118A();
	}
}

class Calc{
	void abc118A() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b%a == 0) {
			System.out.println(a+b);
		}else {
			System.out.println(b-a);
		}
	}
}

Measured memory_bytes: 21972
import sys
input = sys.stdin.readline
import collections
import fractions
from collections import defaultdict
import math

n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
b=defaultdict(int)
c=defaultdict(int)
b0=0
c0=0
mod=1000000007
ans=1
cnt=0
for i,j in a:
    if i!=0 and j!=0:
        x=i
        y=j
        i //= math.gcd(x, y)
        j //= math.gcd(x, y)
        i=abs(i)
        j=abs(j)
        if x*y>0:
            b[(i,j,0)]+=1
            c[(j,i,1)]+=1
        else:
            b[(i,j,1)]+=1
            c[(j,i,0)]+=1

    elif i==0 and j!=0:
        b0+=1
    elif i!=0 and j==0:
        c0+=1
    else:
        cnt+=1
w=[]
if c0!=0 or b0!=0:
    ans*=pow(2,c0+b0)-((pow(2,c0,mod)-1)*(pow(2,b0,mod)-1))

for k,v in b.items():
    if c[k]!=0:
        ans*=(pow(2,c[k]+v,mod)-(pow(2,c[k],mod)-1)*(pow(2,v,mod)-1))
        w.append((pow(2,c[k]+v,mod)-(pow(2,c[k],mod)-1)*(pow(2,v,mod)-1)))
        ans%=mod
    else:
        ans*=pow(2,v,mod)
        ans%=mod

w=collections.Counter(w)
w=list(w.most_common())
for i,j in w:
    for k in range(j//2):
        ans*=pow(i,mod-2,mod)
ans+=cnt-1
print(int(ans%mod))

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int cnt[100] = {0};
void prime_factor(int n){
  for (ll i(2);i*i<=n;i++){
    while(n%i==0){
      ++cnt[i];
      n/=i;
    }
  }
  if (n!=1) cnt[n]++;
}
int main(){
  int N;
  cin>>N;
  for(int i(2);i<=N;i++){
    prime_factor(i); 
  }
  int cnt5(0),cnt25(0),cnt15(0),cnt3(0),cnt75(0);
  for(int i(1);i<10;i++){
    //cout << cnt[i] << " ";
  }
  //cout << endl;
  for(int i(0);i<100;i++){
    if(cnt[i] >= 2) cnt3++; 
    if(cnt[i] >= 4) cnt5++; 
    if(cnt[i] >= 14) cnt15++; 
    if(cnt[i] >= 24) cnt25++; 
    if(cnt[i] >= 74) cnt75++; 
  }
  ll ans(0);
  //cout << cnt5 << " " << cnt25 << " " << cnt75 << endl;
  ans += cnt75;
  ans += (cnt3-1)*(cnt25);
  ans += (cnt5)*(cnt5-1)/2*(cnt3-2);
  ans += cnt15 * (cnt5-1);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import re

ans = ['A', 'B', 'NA']
for _ in range(int(input())):
    s = input()
    l = max([1, (len(s) - 4) // 2])
    p = [r">'"+("="*l)+"#"+("="*l)+"~", r'>\^(Q=)+~~', r'\S']
    for i in range(3):
        if re.match(p[i], s):
            print(ans[i])
            break



Measured memory_bytes: 6808
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

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

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n;

int dist[505][505];
int out[505][505];
int grid[505][505];

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

queue < pii > Q;

bool isValid(int r, int c){
  if(r < 1 || c < 1) return 0;
  if(r > n || c > n) return 0;
  return 1;
}

void SPFA(){
  while(!Q.empty()){
    pii u = Q.front();
    grid[u.fs][u.se] = 0;
    Q.pop();
    for(int i = 0; i < 4; i++){
      int x = u.fs + dx[i];
      int y = u.se + dy[i];
      if(isValid(x, y) && dist[x][y] > dist[u.fs][u.se] + !out[x][y]){
        dist[x][y] = dist[u.fs][u.se] + !out[x][y];
        if(grid[x][y] == 0) Q.push(mp(x, y));
      }
    }
  }
}

int main(){
  int ans = 0;
  fastScan(n);
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      dist[i][j] = n * n;
    }
  }
  for(int i = 1; i <= n; i++){
    dist[1][i] = dist[i][1] = dist[n][i] = dist[i][n] = 0;
    grid[1][i] = grid[i][1] = grid[n][i] = grid[i][n] = 1;
    Q.push(mp(1, i)); Q.push(mp(i, 1));
    Q.push(mp(n, i)); Q.push(mp(i, n));
  }
  SPFA();
  for(int i = 1; i <= n * n; i++){
    int who, x, y;
    fastScan(who);
    x = (who - 1) / n + 1;
    y = (who - 1) % n + 1;
    ans += dist[x][y];
    dist[x][y]--;
    out[x][y] = 1;
    Q.push(mp(x, y));
    SPFA();
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6676
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int C=min(A,B);
  cout<<C<<endl;
  int D=A+B;
  if(D>=N){
    cout<<D-N<<endl;
  }else{
    cout<<0<<endl;
  }
  




  


}



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

int main(){
int n;
cin >>n;
vector<int> w(n);
for(int i = 0; i< n; i++)cin >> w[i];
vector<int> a(n);
int t;
a[0] = w[0];
for(int i = 1; i<n;i++) a[i] += a[i-1]+w[i];
int ans =100100 ;
for(int t=0; t< n-1;t++){
   ans = min(ans, abs(a[t] -(a[n-1]-a[t])));
}

cout << ans << endl;
return 0;
}


Measured memory_bytes: 3536
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (l, r, d) = (v[0], v[1], v[2]);
    let mut ans = 0;
    for i in l..r + 1 {
        if i % d == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2124
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_number(X),
    get_number(A),
    (X < A) -> writeln("0") ; writeln("10").


Measured memory_bytes: 8004
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<map>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){

    int n,m;
    cin>>n>>m;
   vector<pair<int,int>> s[n];
    int si=1;
    int ansm[m+1];
   rep(i,m){
        int p,m;
        cin>>p>>m;
        ansm[i+1]=p;
        s[p-1].push_back(make_pair(m,si));
        si++;
    }

     rep(i,n)   sort(s[i].begin(),s[i].end());
    
    int ans[m+1];
    rep(i,n) rep(j,s[i].size()){
            int h=s[i][j].second;
            ans[h]=j+1;
        }
    
    /*for(int i=1;i<m+1;i++){
        cout<<ansm[i]<<ans[i]<<endl;
    }*/
    for(int i=1;i<m+1;i++){
        printf("%06d",ansm[i]);
        printf("%06d",ans[i]);
        cout<<endl;
    }
   
return 0;
}


Measured memory_bytes: 7808
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B, C;
	
	cin >> A >> B >> C;

	if ((C >= A ) && (C <= B))
	{
		cout << "Yes" <<endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256