akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
vector<int> parent, leftn, rightn, depth;
void calc(int node, int dep)
{
    depth[node] = dep;
    if (leftn[node] != -1)
    {
        calc(leftn[node], dep);
    }
    if (rightn[node] != -1)
    {
        calc(rightn[node], dep + 1);
    }
}
int main()
{
    int n, node, degree, root;
    scanf("%d", &n);
    parent.resize(n, -1);
    leftn.resize(n, -1);
    rightn.resize(n, -1);
    depth.resize(n, -1);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &node, &degree);
        if (degree != 0)
        {
            int child[degree];
            scanf("%d", &child[0]);
            rightn[node] = child[0];
            parent[child[0]] = node;
            for (int j = 1; j < degree; j++)
            {
                scanf("%d", &child[j]);
                leftn[child[j - 1]] = child[j];
                parent[child[j]] = node;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (parent[i] == -1)
        {
            root = i;
            break;
        }
    }
    calc(root, 0);
    for (int i = 0; i < n; i++)
    {
        printf("node %d: parent = %d, depth = %d, ", i, parent[i], depth[i]);
        if (depth[i] == 0)
        {
            printf("root, [");
            if (rightn[i] != -1)
            {
                printf("%d", rightn[i]);
                for (int j = leftn[rightn[i]]; j != -1; j = leftn[j])
                {
                    printf(", %d", j);
                }
            }
            printf("]\n");
        }
        else if(rightn[i] == -1)
        {
            printf("leaf, []\n");
        }
        else
        {
            printf("internal node, [");
            if (rightn[i] != -1)
            {
                printf("%d", rightn[i]);
                for (int j = leftn[rightn[i]]; j != -1; j = leftn[j])
                {
                    printf(", %d", j);
                }
            }
            printf("]\n");
        }
    }
}


Measured memory_bytes: 7588
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

// #define int long は変なところでハマる可能性がるのでやらない。

struct Meal {
	long a, b, c;
};

int main()
{
	long N;
	std::vector<Meal> X;

	std::cin >> N;
	X.resize(N);
	for (long i = 0; i < N; ++i) {
		std::cin >> X[i].a >> X[i].b;
		X[i].c = X[i].a + X[i].b;
	}
	std::sort(X.begin(), X.end(), [](auto& x, auto& y)->bool{return x.c > y.c;});
	
	long result = 0;
	int i = 0;
	for (; i < X.size()-1; i += 2) {
		result += X[i].a - X[i+1].b;
	}
	if (i != X.size()) {
		result += X[i].a;
	}
	std::cout << result << "\n";
}


Measured memory_bytes: 2560
#include <iostream>
#include <map>

using namespace std;

int main(){
    int n,m;
    map<int,int>ma;
    cin >> n >> m;

    for(int i = 0;i < n;i++)
        ma[i+1] = 0;

    for(int i = 0;i < m;i++){
        int a,b;
        cin >> a >> b;
        ma[a]++;
        ma[b]++;
    }

    for(auto &i:ma)
        cout << i.second << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios::sync_with_stdio(false)
#define N 100000
#define INF 0x3f3f3f3f
#define LL long long int
using namespace std;
int main(){
	int n;
	int T,A;
	cin>>n>>T>>A;
	int pos=0;
	float delta=10000;
	float temp;
	for(int i=1;i<=n;i++){
		cin>>temp;
		temp=T-0.006f*temp;
		temp=abs(temp-A);
		if(temp<delta){
			pos=i;
			delta=temp;
		}
	}
	cout<<pos<<endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.container;
import std.typecons;

int size(in string s) {
    return cast(int)s.length;
}

void main() {
    string s = readln.chomp;

    immutable X = "ABC";
    bool check(in string s) {
        foreach (i, c; s) {
            if (s[i] != X[i]) return false;
        }
        return true;
    }

    bool f(in string s) {
        if (s.size < 3) return false;
        if (s.size == 3) {
            return check(s);
        }
        if (s.find("ABC").empty) return false;
        bool r = false;
        foreach (c; "ABC") {
            string t = "" ~ c;
            if (!s.replace("ABC", "").find(t).empty) continue;
            r |= f(s.replace("ABC", t));
        }
        return r;
    }

    writeln(f(s) ? "Yes" : "No");
}

Measured memory_bytes: 31396
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        ITP1_2_D(args);
    }
    public static void ITP1_2_D(String[] args) {

        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();

        if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26392
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    sh, sw = map(int, input().split())
    sh -= 1
    sw -= 1
    fh, fw = map(int, input().split())
    fh -= 1
    fw -= 1

    S = [input().strip("\n") for _ in range(H)]

    q = deque()
    P = [[-1 for _ in range(W)] for h in range(H)]
    q.append((0, sh, sw))
    while q:
        d, h, w = q.popleft()
        if P[h][w] == -1:
            P[h][w] = d
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    if 0<=h+dh<H and 0<=w+dw<W and S[h+dh][w+dw] == "." and P[h+dh][w+dw] == -1:
                        if abs(dh) + abs(dw) == 1:
                            q.appendleft((d, h+dh, w+dw))
                        else:
                            q.append((d+1, h+dh, w+dw))
    print(P[fh][fw])
    

    return 0

if __name__ == "__main__":
    solve()

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

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  T res = e;
  while (n) {
    if (n & 1) res = op(res, a);
    if (n >>= 1) a = op(a, a);
  }
  return res;
}

template <unsigned Mod> struct Modular {
  using M = Modular;
  unsigned v;
  Modular(long long a = 0) : v((a %= Mod) < 0 ? a + Mod : a) {}
  M operator-() const { return M() -= *this; }
  M& operator+=(M r) { if ((v += r.v) >= Mod) v -= Mod; return *this; }
  M& operator-=(M r) { if ((v += Mod - r.v) >= Mod) v -= Mod; return *this; }
  M& operator*=(M r) { v = (uint64_t)v * r.v % Mod; return *this; }
  M& operator/=(M r) { return *this *= power(r, Mod - 2); }
  friend M operator+(M l, M r) { return l += r; }
  friend M operator-(M l, M r) { return l -= r; }
  friend M operator*(M l, M r) { return l *= r; }
  friend M operator/(M l, M r) { return l /= r; }
  friend bool operator==(M l, M r) { return l.v == r.v; }
};

constexpr long long mod = 1e9 + 7;
using Mint = Modular<mod>;

vector<Mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = 1 / fact[n];
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
Mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template<> Mint& Mint::operator/=(Mint r) {
  return *this *= r.v < minv.size() ? minv[r.v] : power(r, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  sort(begin(a), end(a));
  prepare(n);
  Mint res;
  for (int i = 1; i < n; ++i) {
    Mint d = a[i] - a[i - 1];
    res += d * (binom(n, k) - binom(i, k) - binom(n - i, k));
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int c[3][3]={0};
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    int a[3],b[3];
    a[0]=0;
    b[0]=c[0][0];
    b[1]=c[0][1];
    b[2]=c[0][2];
    a[1]=c[1][0]-b[0];
    a[2]=c[2][0]-b[0];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(a[i]+b[j]!=c[i][j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main(void) {
	int N, D;
	scanf("%d %d", &N, &D);
	printf("%d", (int) ceil((double) N / (2 * D + 1)));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MOD 1000000007
typedef long long ll;
ll a[300000];
int main() {
	int n;
	ll sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < 60; i++) {
		int c0 = 0, c1 = 0;
		for (int j = n - 1; j >= 0; j--) {
			if ((a[j] >> i) & 1) {
				c1++;
			} else {
				c0++;
			}
		}
		sum += (1LL << i) % MOD * c0 % MOD * c1 % MOD;
		sum %= MOD;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 3988
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

ll p10[19];

ll check(ll d, int k, int i) {
  if (2 * i >= k) {
    return d == 0 ? 1 : 0;
  }

  ll prod = 0;
  ll tmp = (p10[k - i] - p10[i]) / 9;
  int rem = (d / p10[i]) % 10;
  if (rem < 0) {
    rem += 10;
    rem %= 10;
  }
  REP(u, 0, 2) {
    ll uv = i == 0 ? 9 - abs(rem) : 10 - abs(rem);
    uv *= check(d - rem * tmp, k, i + 1);
    prod += uv;
    rem -= 10;
  }
  return prod;
}


ll calc(ll d, int k) {
  ll prod = 1;
  bool odd = k % 2 == 1;
  prod = check(d, k, 0);
  if (not odd) {
    prod *= 10;
  }
  return prod;
}

int main(void){
  ll d;
  cin >> d;
  if (d % 9 != 0) {
    cout << 0 << endl;
    return 0;
  }
  p10[0] = 1;
  REP(i, 0, 18) {
    p10[i + 1] = p10[i] * 10;
  }
  d /= 9;
  ll tot = 0;
  REP(k, 1, 19) {
    tot += calc(d, k);
  }
  cout << tot << endl;
}


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

int main() {
    int n,k,a = 1;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        if(a * 2 < a + k){
            a *= 2;
        }else{
            a += k;
        }
    }
    cout << a << endl;
}


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


int main() {
	int n, m, x;
	int a[100];
	int cnt1 = 0;
	int cnt2 = 0;


	cin >> n >> m >> x;
	for (int i = 0;i < m;i += 1) {
		cin >> a[i];
		if (a[i] < x) {
			cnt1 += 1;
		}
		else {
			cnt2 += 1;
		}
	}
	if (cnt1 >= cnt2) {
		cout << cnt2 << endl;
	}
	else {
		cout << cnt1 << endl;
	}

	system("pause");
}


	


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;
const ll INF = 1e13;

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    REP(i,N){
        cin >> H[i];
    }

    vector<ll> DP(N+K, INF);
    DP[0] = 0;
    REP(i,N){
        REPi(s, 1, K+1){
            chmin(DP[i+s], DP[i] + abs(H[i] - H[i+s]));
        }
    }

    ll ans = DP[N-1];

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


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
i64 X[101010];
int A[101010], B[101010]; i64 Y[101010];

int uf[101010];
vector<i64> assoc_edges[202020];
pair<int, int> child[202020]; i64 conw[202020]; i64 totalw[202020];

int entity[101010];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
void join(int p, int q)
{
	p = root(p); q = root(q);
	if (p == q) return;
	uf[p] += uf[q];
	uf[q] = p;
}

int ans = 0;

void visit(int p)
{
	if (p < N) return;
	while (assoc_edges[p].size() > 0) {
		if (assoc_edges[p].back() > totalw[p]) {
			//printf("hoge %lld\n", assoc_edges[p].back());
			assoc_edges[p].pop_back();
			++ans;
		} else break;
	}
	//printf("%d: %lld %lld\n", p, conw[p], totalw[p]);
	if (conw[p] > totalw[p]) {
		++ans;
		visit(child[p].first);
		visit(child[p].second);
	}
}

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; ++i) scanf("%lld", X + i);
	for (int i = 0; i < M; ++i) {
		scanf("%d%d%lld", A + i, B + i, Y + i);
		--A[i]; --B[i];
	}

	for (int i = 0; i < N; ++i) uf[i] = -1;

	vector<pair<i64, pair<int, int>>> edges;
	for (int i = 0; i < M; ++i) edges.push_back({Y[i], {A[i], B[i]}});
	sort(edges.begin(), edges.end());

	for (int i = 0; i < N; ++i) {
		entity[i] = i;
		totalw[i] = X[i];
	}
	int idl = N;

	for (auto e : edges) {
		i64 w = e.first; int x = e.second.first, y = e.second.second;
		int rx = root(x), ry = root(y);
		//printf("%d %d, %d %d\n", x, y, rx, ry);
		if (rx == ry) {
			//printf("e %d %lld\n", entity[rx], w);
			assoc_edges[entity[rx]].push_back(w);
		} else {
			int e2 = idl++;
			child[e2] = make_pair(entity[rx], entity[ry]);
			totalw[e2] = totalw[entity[rx]] + totalw[entity[ry]];
			conw[e2] = w;
			entity[rx] = entity[ry] = e2;
			join(rx, ry);
		}
	}

	visit(idl - 1);
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 15216
def d_teleporter():
    N, K = [int(i) for i in input().split()]
    A = [int(i) - 1 for i in input().split()]  # 0-origin

    current_city = 0
    visit_list, visit_dict = [current_city], {current_city: 1}
    for i in range(min(K, N)):  # N 回移動すればループはわかる
        current_city = A[current_city]
        if current_city in visit_dict:  # ループを検出した
            j = visit_list.index(current_city)  # ここからループ
            current_city = visit_list[j + (K - j) % (i - j + 1)]
            break
        else:
            visit_list.append(current_city)
            visit_dict[current_city] = current_city
    return current_city + 1

print(d_teleporter())

Measured memory_bytes: 32356
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  ll x;
  cin >> x;
  REP(i,6100){
    REP(j,6100){
      ll s1 = pow(i,5);
      ll s2 = pow(j,5);
      ll m1 = pow(-i,5);
      ll m2 = pow(-j,5);
      if(s1-s2 ==x){
        cout << i << " " << j << endl;
        return 0;
      }else if(s1-m2 ==x){
        cout << i << " " << -j << endl;
        return 0;
      }else if(m1-s2 ==x){
        cout << -i << " " << j << endl;
        return 0;
      }else if(m1-m2 ==x){
        cout << -i << " " << -j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[m];
    int b[m];
    for(int i=0;i<m;i++)cin >> a[i] >> b[i];
    vector<set<int> >rooms(n+1);
    for(int i=0;i<m;i++){
        rooms[a[i]].insert(b[i]);
        rooms[b[i]].insert(a[i]);
    }
    vector<int>distance(n+1,1<<30);
    distance[1] = 0;
    vector<int>answer(n+1,-1);
    queue<int>que;
    que.push(1);
    
    while(!que.empty()){
        int now = que.front();
        que.pop();
        
        for(int j: rooms[now]){
            if(distance[j] > distance[now] + 1){
                que.push(j);
                answer[j] = now;
                distance[j] = distance[now] + 1;
            }
        }
        
    }
    bool chk = true;
    for(int i=2;i<=n;i++){
        if(answer[i]==-1)chk=false;
    }
    if(chk){
        cout << "Yes"<<endl;
        for(int i=2;i<=n;i++)cout << answer[i]<<endl;

    }else cout<<"No"<<endl;

}

Measured memory_bytes: 29352
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d;
    long long max;
    cin>>a>>b>>c>>d;
    
    max = a*c;
    if (a*d > max) max=a*d;
    if (b*c > max) max=b*c;
    if (b*d > max) max=b*d;
    if (((a<0&&b>0)||(c<0&&d>0))&&(max<0)) max=0;
    
    cout<<max;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

long long int nums[10000];

bool flags[10000];
int index[10000];

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < 10000; i++){
			nums[i] = 0;
			flags[i] = true;
		}
		
		for(int i = 0; i < n; i++){
			long long int e, p, q;
			cin >> e >> p >> q;
			nums[e] += p * q;
			index[i] = e;
		}
		
		bool check = false;
		
		for(int i = 0; i < n; i++){
			if(nums[index[i]] >= 1000000 && flags[index[i]]){
				cout << index[i] << endl;
				check = true;
				flags[index[i]] = false;
			}
		}
		
		if(!check){
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
const int MAXN = 1e5+7;
vector<int> sz;
int cur_sz=1, cur_pai=2, prev_pai=1;
bool mrk[MAXN];
vector<pii> E;
string s;
int main(){
    cin >> s;
    int n = (int)s.size();
    if(s[n-1]=='1' || s[0]=='0'){cout<<"-1"<<endl; return 0;}
    for(int i=1; i<=n/2; i++){
        if(s[i-1] != s[n-i-1]){cout<<"-1"<<endl; return 0;}
        if(s[i-1]=='1')sz.push_back(i);
    }
    for(int i=1; i<(int)sz.size(); i++){
        int si = sz[i];
        int prev = sz[i-1];
        E.push_back({prev_pai, cur_pai});
        mrk[prev_pai]=true;
        int atual = prev+1;
        int prox = cur_pai+1;
        while(atual<si){
            E.push_back({cur_pai, prox});
            mrk[prox]=true;
            atual++;
            prox++;
        }
        prev_pai = cur_pai;
        cur_pai = prox;
    }
    for(int i=1; i<n; i++){
        if(mrk[i])continue;
        E.push_back({i, n});
    }
    for(int i=0; i<(int)E.size(); i++)cout<<E[i].first<<" "<<E[i].second<<endl;
}

Measured memory_bytes: 2740
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 h,n,sum=0;
    cin>>h>>n;
    vector<int64> a(n);
    for (int64 i = 0; i < n; i++)
    {
        cin>>a[i];
        h-=a[i];
    }

    cout<<((h>0)?"No":"Yes")<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

//階乗
ll factorial(int x) {
    if (x == 1) return 1;
    return x * factorial(x-1) % mod;
}

int main() {
    int n, m; cin >> n >> m;
    ll ans = 0;
    int diff = abs(n-m);
    if (diff >= 2) ans = 0;
    if (diff < 2) ans += (factorial(n) * factorial(m)) % mod;
    if (diff == 0) ans *= 2;
    cout << ans%mod << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  string s;cin>>s;
  string ans="Yes";
  for(int i=0;i<s.size();i=i+2)
  {
    if(s.at(i)=='L')
      ans="No";
  }
   for(int i=1;i<s.size();i=i+2)
  {
    if(s.at(i)=='R')
      ans="No";
  }
  cout<<ans;
}
    
  

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int n;
    string s;
    set<string>st;
    cin >> n;
    while(n--)
    {
        cin >> s;
        st.insert(s);
    }
    cout << st.SZ;
    return 0;
}


Measured memory_bytes: 19232
S = input()
T  = input()

def check(S,T):
	for i in range(len(S)):
		if S[i] != T[i] and S[i] != "?":
			return False
	return True

def pad(S,T,idx):
	tmp = ""
	for i in range(len(S)):
		if i < idx:
			tmp += "a" if S[i] == "?" else S[i]
		elif i < idx + len(T):
			tmp += T[i-idx]
		else:
			tmp += "a" if S[i] == "?" else S[i]
	return tmp

if len(T) > len(S):
	print('UNRESTORABLE')
	exit()


a = []
for i in range(len(S)-len(T)+1):
	if check(S[i:i+len(T)],T) == True:
		a.append(pad(S,T,i))
if len(a) == 0:
	print('UNRESTORABLE')
	exit()

print(sorted(a)[0])



Measured memory_bytes: 3064
n,x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
if x<min(a):
    ans = 0
elif x>sum(a):
    ans = n-1
else:
    for i in range(1,n+1):
        if x>=sum(a[:i]):
            ans+=1
        else:
            break        
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S,T;
    cin >> S >> T;
    bool ok = false;
    ll N = stoi(S + T);
    rep(i,400){
        if(N == i * i){
            ok = true;
        }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

	int a[10010];
	int b[10010];

	int c[10010];

	rep(i,N-1) cin >> a[i] >> b[i];

	vector<int> c_data;
	rep(i,N){
		cin >> c[i];
		c_data.push_back(c[i]);
	}

	sort(c_data.begin(),c_data.end(), std::greater<int>());

	vector<int> data[10010];
	vector<int> check;
	rep(i,N){
		data[a[i]].push_back(b[i]);
		data[b[i]].push_back(a[i]);
		check.push_back(1);
	}

	int max=0;
	int M=0;
	rep(i,N){
		M+=c[i];
		if(c[i]>max) max=c[i];
	}
	M -= max;

	cout << M << endl;


	queue<int> que;
	que.push(a[0]);
	check[a[0]-1]=0;

	int ans[10000];
	int count = 0;

	while (!que.empty()){
		int p = que.front();

		ans[p-1]=c_data[count];
		count += 1;

		que.pop();
		rep(i,data[p].size()){
			int tmp=data[p][i];
			if(check[tmp-1]==1){
				que.push(tmp);
				check[tmp-1]=0;
			}
		}
	}

	rep(i,N){
		cout << ans[i] << " ";
	}


}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<double> x(N);
    vector<string> u(N);
    
    for(int i=0;i<N;i++){
        cin>>x[i]>>u[i];
    }

    double ans=0.0;

    for(int i=0;i<N;i++){
        if(u[i]=="BTC"){
            x[i]*=380000.0;
        }
        ans+=x[i];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    c = na()

    dp = [INF for _ in range(n + 1)]
    dp[0] = 0

    for ci in c:
        for i in range(n + 1 - ci):
            dp[i + ci] = min(dp[i + ci], dp[i] + 1)

    print(dp[n])


if __name__ == '__main__':
    main()



Measured memory_bytes: 9328
n=int(input())
d=[]
for i in range(n):
    x,y=map(int,input().split())
    d.append([x,y])
f=1
for i in range(n-2):
    if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]:
        f=0
print("Yes" if f==0 else "No")



Measured memory_bytes: 62336
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int X;cin>>X;
	int n=lcm(360,X);
	cout<<n/X<<endl;
}


Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        a: u64, b: u64, c: u64
    }

    let mut ns = vec![a, b, c];
    ns.sort();
    let mut cnt = 0;
    if ns[0] < ns[1] && ns[1] < ns[2] {
        let delta = ns[2] - ns[1];
        ns[0] += delta;
        ns[1] += delta;
        cnt += delta;
    }

    if ns[0] < ns[1] {
        let delta = ns[1] - ns[0];
        let cnt_delta = (delta + 2 - 1) / 2;
        ns[0] += cnt_delta * 2;
        cnt += cnt_delta;
        if ns[0] > ns[1] {
            cnt += 1;
        }
    }

    if ns[0] == ns[1] && ns[1] < ns[2] {
        cnt += ns[2] - ns[1];
    }
    println!("{}", cnt);
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;



int main(){
  int N; cin>>N;
  vector<queue<int>> G(1010);
  rep(i,N){
    rep(j,N-1){
      int a;
      scanf("%d",&a);
      G.at(i+1).emplace(a);
    }
  }
  int MAXday = N*(N-1)/2;
  int game = N*(N-1)/2;
  set<int> player;
  set<int> today;//前日試合をした人
  
  for(int d = 1; d <= MAXday; d++){
    vector<bool> seen(1010,false);
    set<int> tommorow;
    int flag = 0;
    //初日
    if(d==1){
      rep1(i,N){
        if(seen.at(i))continue;
        else{
          int opponent = G.at(i).front();
          if(!seen.at(opponent)&&G.at(opponent).front()==i){
            seen.at(i)=true;
            G.at(i).pop();
            G.at(opponent).pop();
            if(!G.at(i).empty())tommorow.insert(i);
            if(!G.at(opponent).empty())tommorow.insert(opponent);
            seen.at(opponent)=true;
            game--;
            flag = 1;
            //cout<<"day "<<d<<" "<<i<<" vs "<<opponent<<endl;
          }
        }
      }
    }else{
      for(auto i:today){
        if(seen.at(i))continue;
        else{
          int opponent = G.at(i).front();
          if(!seen.at(opponent)&&G.at(opponent).front()==i){
            seen.at(i)=true;
            G.at(i).pop();
            G.at(opponent).pop();
            if(!G.at(i).empty())tommorow.insert(i);
            if(!G.at(opponent).empty())tommorow.insert(opponent);
            seen.at(opponent)=true;
            game--;
            flag = 1;
            //cout<<"day "<<d<<" "<<i<<" vs "<<opponent<<endl;
          }
        }
      }  
    }
    today = tommorow;//更新
    if(flag==0)break;
    if(game==0){
      cout<<d<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}


Measured memory_bytes: 6656
n, m = map(int, input().split())
ans = [""] * m
li = []
for i in range(m):
    p, y = map(int, input().split())
    li.append((p, y, i))
li.sort()
cnt = 1
ans[li[0][2]] = "{:06}{:06}".format(li[0][0], cnt)
for i in range(1, m):
    cnt = cnt + 1 if li[i - 1][0] == li[i][0] else 1
    ans[li[i][2]] = "{:06}{:06}".format(li[i][0], cnt)
print(*ans, sep="\n")


Measured memory_bytes: 30592
#include <bits/stdc++.h>
using namespace std;
const int N=1000100;
int f[N],g[N],h[N],a[N],n,x,b[N];
char s[N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=1000000;i++)
		if (i%2==0) f[i]=f[i/2]+1;
	for (int i=1;i<n;i++)
	{
		g[i]=g[i-1]+f[n-i]-f[i];
		if (g[i]) h[i]=0; else h[i]=1;
	}
	h[0]=1;
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
	{
		a[i]=s[i]-'1';
		b[a[i]]++;
	}
	//for (int i=0;i<n;i++) printf("%d ",h[i]);
	if (b[1]==0)
	{
		for (int i=1;i<=n;i++)
			if (a[i]==2) x+=h[i-1];
		if (x%2==0) printf("%d",0); else printf("%d",2);
	}
	else
	{
		for (int i=1;i<=n;i++)
			if (a[i]==1) x+=h[i-1];
		if (x%2==0) printf("%d",0); else printf("%d",1);
	}
} 

Measured memory_bytes: 17664
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let S = scan.word::<String>();
    let T = scan.word::<String>();

    let ok = T.starts_with(&S);

    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 2120
def main():
	n = int(input())
	x = list(map(int, input().split()))
	max_x = 0
	total = 0
	for xi in x:
		total += xi
		if xi > max_x:
			max_x = xi
	if max_x < total - max_x:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def is_prime(n)
  return 0 if n < 2
  return 1 if n == 2
  return 0 if n % 2 == 0
  i = 3;
  while i <= Math.sqrt(n)
    return 0 if n % i == 0
    i += 2
  end
  return 1
end

n = gets.to_i

count = 0
n.times{
  count += is_prime(gets.to_i)
}
printf "%d\n", count

Measured memory_bytes: 8804
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int N, A, sum[200001] = { 0 }, Min = 1000000000000000000;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A;
		sum[i] = sum[i - 1] + A;
	}
	for (int i = 1; i < N; i++) {
		Min = min(Min, abs(sum[N] - 2 * sum[i]));
	}
	cout << Min;
}

Measured memory_bytes: 1792
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 
 
int n;
ll a[N], b[N];
 
set <pair<ll,int> > st;
 
int main () {
	scanf("%d", &n);
 
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
	}
 
	for(int i = 1; i <= n; i++){
		scanf("%lld", &b[i]);
		st.insert(mp(-b[i], i));
	}
	ll ans = 0;
	while(!st.empty()){
		ll val = -(*st.begin()).f;
		int id = (*st.begin()).s;
		st.erase(st.begin());
		if(a[id] == val){
			continue;
		}
		ll res = 0;
		if(id - 1 > 0) res += b[id - 1];
		else res += b[n];
		if(id + 1 <= n) res += b[id + 1];
		else res += b[1];
		ll nxt = a[id] + res;
		ll k = max((b[id] - nxt + res) / res, 1ll);
		ans += k;
		b[id] -= k * res;
		st.insert(mp(-b[id], id));
		if(b[id] < a[id]) break;
	}
 
	for(int i = 1; i <= n; i++){
		if(a[i] != b[i]){
			cout << -1;
			return 0;
		}
	}
	cout << ans;
	
 
return 0;
}

Measured memory_bytes: 16384
n,m = map(int,input().split())
d = [0 for _ in range(n)]
d[0] = 1
sarr = []
if m == 0 and n == 1:
    d[0] = 0
for i in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and not n == 1:
        print(-1)
        exit()
    if s in sarr and c != d[s-1]:
        print(-1)
        exit()
    d[s-1] = c
    sarr.append(s)
    #print(sarr)
    #print(d)
ans = ''
for i in range(n):
    ans += str(d[i])
print(ans)


Measured memory_bytes: 38384
a, b, c = sorted(map(int, input().split()))
ans = 0
if a == b == c and a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    print(-1)
    exit(0)
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    ans += 1
    a, b, c = (a + b) // 2, (a + c) // 2, (b + c) // 2
print(ans)

Measured memory_bytes: 3060
takahashi, aoki, count = map(int,input().split())
k = count
if takahashi - count >= 0:
  takahashi -= count
else:
  count -= takahashi
  takahashi = 0
  if aoki - count > 0:
    aoki -= count
  else:
    aoki = 0
print(takahashi, aoki)


Measured memory_bytes: 2940
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 H = sc.nextInt();
        int M = sc.nextInt();
        double hAngle = 30 * H;
        double mAngle = 6 * M;

        hAngle += 30 * (mAngle / 360);
        
        double angle = Math.abs(hAngle - mAngle);
        double rad = Math.toRadians(angle);
        double cos = Math.cos(rad);
        double x = Math.pow(A,2) + Math.pow(B,2) - 2*A*B *cos;

        System.out.println(Math.sqrt(x));
    }
}

Measured memory_bytes: 27192
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<double> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end());
    double sum = vs[0];
    for (int i = 1; i < n; i++)
    {
        sum = (sum + vs[i]) / 2.0;
    }
    cout << setprecision(15) << sum << endl;
}


Measured memory_bytes: 256
n = int(input())
l = [int(i) for i in input().split()]
l = sorted(l)
total = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                if l[i]+l[j] > l[k]:
                    total += 1
print(total)

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  int ans=1, flag=0;
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      	if(a[j]<=a[i]){
          flag=1;
        }
      else{
      flag=0;
      break;
      }
    }
    if(flag)
      	ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    int c = GCD(a,b);
    map<int,int> d = prime_factor(c);
    out(d.size()+1);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    int A, B;
    cin >> A >> B;
    int ans;
    if(A >= 13) ans = B;
    else if(A >= 6 && A < 13) ans = B/2;
    else ans = 0;
    cout << ans << endl; 
}

Measured memory_bytes: 256
n,m = map(int,input().split())
from collections import Counter

s = []
for _ in range(m):
    a,b = map(int,input().split())
    s.append(a)
    s.append(b)
    
c = Counter(s)
d = list(c.values())

ans = "YES"
for i in d:
    if i % 2 == 1:
        ans = "NO"
        break
        
print(ans)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(M * 2);
  for(int i = 0; i < M * 2; i++)
  {
    cin >> vec.at(i);
  }
  for(int i = 0; i < N; i++)
  {
    cout << count(vec.begin(), vec.end(), i + 1) << endl;
  }  
}


Measured memory_bytes: 256
h1, m1, h2, m2, k = map(int, input().split())
t = 0

if h1 == h2:
    t = m2 - m1
else:
    if m2 >= m1:
        t = (h2 - h1) * 60 + m2 - m1
    else:
        t = (h2 - h1 -1) * 60 + m2 +60 - m1
print(t - k)

Measured memory_bytes: 9036
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    # n以下の素数のリストprimes
    n = 10**5
    primes = set(range(2, n + 1))

    # 合成数 x は p<=x**0.5を満たす素因子 p をもつという性質を利用
    for i in range(2, int(n ** 0.5 + 1)):
        primes.difference_update(range(i * 2, n + 1, i))
    primes = list(primes)

    L=[0]*10**5
    for i in primes:
        if (i+1)//2 in primes:
            L[i]=1

    from itertools import accumulate


    B = [0] + L
    B = list(accumulate(B))  # 累積和を格納したリスト作成

    # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り

    Q=int(input())
    for i in range(Q):
        l,r=map(int,input().split())
        print(B[r+1]-B[l])


resolve()

Measured memory_bytes: 64100
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
/*int gcd(int n,int m)
{
	if(m==0)
		return n;

	return gcd(m, n % m);
}*/
string s;
int c;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(s[i]=='o')c++;

	cout<<700+(c*100)<<"\n";

	return 0;
}

Measured memory_bytes: 3608
def main():
    A, B = input().split()

    A = int(A)

    B_spl = B.split('.')
    L = len(B_spl[1])  # 小数部分の桁数, int化前に桁を調べる必要がある(000xxxのケースでint後に桁数変わる)
    B_int, B_frac = map(int, B_spl)  # 整数部分, 小数部分

    ans = (A * B_int) + (A * B_frac) // pow(10, L)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#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 << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
N, K= map(int, input().split())
g =[[] for i in range(N)]
h=0
for i in range(N):
    a, b = map(int, input().split())
    g[i].append(a)
    g[i].append(b)
def S(L):
    return L[0]
def T(L):
    return L[1]
g.sort(key=S)
for j in range(N):
    h+=T(g[j])
    if h>=K:
        y=S(g[j])
        break
print(y)

Measured memory_bytes: 22884
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    string answer = "ABC";
    cin >> N;
    answer += to_string(N);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif

bool c2(string a, string b){
    int n = min(a.length(),b.length()) ;
    rep(i,n)
        if(a[i] != b[i])
            return a[i] < b[i] ;
    return a.length() < b.length() ;
}
bool cmp( pair<pair<string,int>,int> A , pair<pair<string,int>,int> B){
    if(A.ff.ff != B.ff.ff)
        return c2(A.ff.ff,B.ff.ff) ;
    else
        return A.ff.ss > B.ff.ss ;
}
void solve()
{
    int n ;
    cin >> n ;
    vector<pair<pair<string,int>,int>> p(n) ;
    std::vector<int> a(n) ;
    rep(i,n) cin >> p[i].ff.ff >> p[i].ff.ss , p[i].ss = i + 1 ;
    sort(all(p),cmp) ;
    rep(i,n)
        cout << p[i].ss << endl ;
    // cout << c2("ka","kazan") ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int ceiling(int a, int b) {
    return (a % b > 0) ? a / b + 1 : a / b;
}

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int x = c / (7 * a + b) * 7,
        y = c % (7 * a + b);
    printf("%d\n", x + ((y > 7 * a) ? 7 : ceiling(y, a)));
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    ll a,b,x;
    cin >> a >> b >> x;
    cout << ((b / x) * x - ((x + a - 1) / x) * x + x) / x << endl;
}

Measured memory_bytes: 256
counts = [0, 0, 0, 0]
3.times{
	a, b = gets.strip.split(/ /).collect{|n| n.to_i - 1}
	counts[a] += 1
	counts[b] += 1
}

if counts.max == 3
	puts "NO"
else
	puts "YES"
end


Measured memory_bytes: 1788