akhauriyash/Code-Regression huggingface dataset:
use input::*;
use std::cmp::*;
use std::collections::HashSet;
use std::io::*;
use std::num::*;
use std::str::*;

//#[rustfmt::skip]
mod input {
    use super::*;
    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn string() -> String {
        read()
    }
    pub fn int() -> i64 {
        read()
    }
    pub fn char() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn vecchar() -> Vec<char> {
        string().chars().collect()
    }
    pub fn vecint(n: i64) -> Vec<i64> {
        let mut vec = Vec::new();
        for i in 0..n {
            vec.push(int())
        }
        vec
    }
}
fn main() {
    let (a, b) = (int(), int());
    let (adiv, bdiv) = (divisor(a), divisor(b));
    let mut ans = 0;
    for ai in &adiv {
        for bi in &bdiv {
            if ai == bi {
                ans += 1
            }
        }
    }
    //println!("{:?}", adiv);
    //println!("{:?}", bdiv);
    println!("{}", ans)
}

fn divisor(mut n: i64) -> HashSet<i64> {
    let mut r = HashSet::new();
    let mut l = 2;
    while l * l <= n {
        if n % l == 0 {
            n /= l;
            r.insert(l);
            continue;
        }
        l += 1;
    }
    r.insert(1);
    r.insert(n);
    r
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;

  cout << (S.substr(0,4) == "YAKI"? "Yes":"No") << endl;

  return 0;
}


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


int main(){
    string S,T;
    cin >> S >> T;
    int64_t N = S.size();
    int64_t cnt = 0;
    for(int64_t i = 0; i < N; i++){
        if(S.at(i) != T.at(i)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3848
#デフォルト
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

n = int(input())
a = list(map(int,input().split()))

ans = 1
sub = 10 ** 18
for i in range(n):
    if a[i] == 0:
        print("0")
        exit()
for i in a:
    ans *= i
    if ans > sub:
        ans = -1
        break

print(ans)

Measured memory_bytes: 22364
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  sort(a);
  auto d = a.uniq.array.length;
  if (a.length == d) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 11128
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
  float t,sel;int c=0;
  scanf("%f%f",&t,&sel);
  set <int> v; vector <int> final;int s=0,co=0,j=0;
    for(int i=0;i<t;i++)
    {
        int n;
        scanf("%d",&n);
      v.insert(n);
      s=s+n;
     // printf("%d\n",sel);
    } float x=((1/(sel*4))*s);
   // printf("%f",x);
  for(auto ii=v.rbegin();ii!=v.rend();ii++)
    {
        //printf("%d",*ii);
    if(co<sel)
    { 
        final.push_back(*ii);//printf("%d",*ii);
        ++co;}
  }
  int l=final.size();
  for(int i=0;i<l;i++)
  {
      //printf("%d\n",(1/(4*(i+1)))*s);
    if(final[i]<x)
       {
         printf("No");
         ++j;
         break;}++c;
       }
       if(c==final.size())
       printf("Yes");
       
       }
    

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    vector<string> A(N);
    vector<vector<int>> res(N, vector<int>(M, -1));
    int t = 1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < M; j++) {
            if (A[i][j] == '#') {
                res[i][j] = t;
                t++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < M; j++) {
            if (res[i][j] == -1) {
                res[i][j] = res[i][j - 1];
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = M - 2; j >= 0; j--) {
            if (res[i][j] == -1) {
                res[i][j] = res[i][j + 1];
            }
        }
    }
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (res[i][j] == -1) {
                res[i][j] = res[i - 1][j];
            }
        }
    }
    for (int i = N - 2; i >= 0; i--) {
        for (int j = 0; j < M; j++) {
            if (res[i][j] == -1) {
                res[i][j] = res[i + 1][j];
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (j > 0)
                cout << " ";
            cout << res[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1664
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		for(int i=0; i<n; i++)
		{
			String a = scanner.next();
			String b = scanner.next();
			String c = "";
			
			int s = 0;
			for(int j=0; j<a.length() || j<b.length(); j++)
			{
				int a0 = 0, b0 = 0;
				if(j < a.length())
					a0 = Integer.parseInt(a.substring(a.length()-j-1, a.length()-j));
				if(j < b.length())
					b0 = Integer.parseInt(b.substring(b.length()-j-1, b.length()-j));
				
				int m = a0 + b0 + s;
				c = (m%10) + c;
				if(m >= 10)
				{
					s = 1;
				}
				else {
					s = 0;
				}
			}
			c = (s>0?"1":"") + c;
			System.out.println((c.length()>80) ? "overflow" : c);
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a % 2 != 0 && (i+1) % 2 != 0) ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int H[100000];
int n, a, b;

int check(long long int t){
  int i;
  long long int tt = 0;
  for(i=0;i<n;i++){
    if(H[i] > (long long) t * b) tt += (H[i] - (long long) t * b + a - b - 1) / (a-b);
  }
  return t >= tt;
}

int main(){
  int i;
  long long sum = 0;
  long long l, r;
  scanf("%d%d%d", &n, &a, &b);
  for(i=0;i<n;i++){
    scanf("%d", H+i);
    sum += H[i];
  }
  l = 0; r = 1+sum/b;
  while(l<r){
    long long m = (l+r)/2;
    if(check(m)) r = m;
    else l = m+1;
  }
  printf("%lld\n", l);

  return 0;
}


Measured memory_bytes: 512
S = list(map(int, list(input())))
s0 = S[::2]
s1 = S[1::2]

count_0 = 0
count_1 = 0

for i in s0:
    if i == 0:
        count_0 += 1
    else:
        count_1 += 1

for i in s1:
    if i == 1:
        count_0 += 1
    else:
        count_1 += 1

if count_0 > count_1:
    print(count_1)
else:
    print(count_0)


Measured memory_bytes: 4652
#include <iostream>
#include <string>
#include <queue>
#include <map>

using namespace std;

#define N 3
#define N2 9

struct Puzzle {
	int f[N2], space;
	string path;
	bool operator<(const Puzzle& a) const {
		for (int i = 0; i < N2; ++i) {
			if (f[i] == a.f[i]) continue;
			return f[i] > a.f[i];
		}
		return false;
	}
};

int dx[] = { -1,0,0,1 }, dy[] = { 0,-1,1,0 };
char dir[] = { 'u','l','r','d' };

bool ok(Puzzle& p) {
	for (int i = 0; i < N2; ++i)
		if (p.f[i] != i + 1) return false;
	return true;
}

string bfs(Puzzle s) {
	queue<Puzzle> q;
	map<Puzzle, bool> V;
	Puzzle u, v;
	s.path = "";
	q.push(s);
	V[s] = true;
	while (!q.empty()) {
		u = q.front(); q.pop();
		if (ok(u)) return u.path;
		int sx = u.space / N, sy = u.space % N;
		for (int r = 0; r < 4; ++r) {
			int tx = sx + dx[r], ty = sy + dy[r];
			if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
			v = u;
			swap(v.f[u.space], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if (!V[v]) {
				V[v] = true;
				v.path += dir[r];
				q.push(v);
			}
		}
	}
	return "unsolvable";
}

int main() {
	Puzzle in;
	for (int i = 0; i < N2; ++i) {
		cin >> in.f[i];
		if (in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	string ans = bfs(in);
	cout << ans.size() << endl;

	return 0;
}


Measured memory_bytes: 30612
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

int n,maxi=INT_MIN,cnt=0,ans;
string a,x,y;
set<char> s1,s2;

int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
    
    cin>>n>>a;
    x = "";
    y = a;
    int temp = n;
    for(int i = 1 ;i<temp;i++)
    {
    	cnt=0;
    	s1.clear(),s2.clear();
    	x += y.front();
    	y = a.substr(i,string::npos);
    	for(auto it: x)
    		s1.insert(it);
    	for(auto it : y)
    		s2.insert(it);

    	for(auto it : s2)
    	{
    		if(s1.find(it)!=s1.end())
    			cnt++;
    	}
    	ans = max(ans,cnt);
    }
    cout<<ans;
}
	

Measured memory_bytes: 3640
#include<stdio.h>
#define mod 1000000007
#define ll long long 
int main(){
    ll n, k, ans = 0;
    scanf("%lld%lld",&n,&k);
    for(; k <= n + 1; k++){
        ans += (n - k + 1) * k + 1;
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main()
{
	
int a, b;

char op;


while(scanf("%d %c %d",&a ,&op, &b))
{
int ans;
if(op == '?' )
{
	break;
}


if (op == '+')
{
	ans = a + b;
	

}
if (op == '-')
{
	ans = a - b;
	
}
if (op == '*')
{
	ans = a * b;
	
}
if (op == '/')
{
	ans = a / b;
	
}
printf("%d\n",ans);
}
return 0;

}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
lint n;
cin>>n;
map<lint,lint>mp;
rep(i,n){
    lint a;
    cin>>a;
    mp[a]++;
}
lint ans=0;
    for(auto x:mp){
        if(x.first>x.second)ans+=x.second;
        else if(x.first<x.second)ans+=x.second-x.first;
    }
    cout<<ans;
  }
  
  
     
  

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string s,t;
    cin>>s>>t;
    if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]) {
        printf("YES");
    }
    else printf("NO");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	ll a, b, c; cin >> a >> b >> c;
	rep(i, 0, 10) {
		c = a * c - b;
		printf("%d\n", c);
	}
	return 0;
}


Measured memory_bytes: 256
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 405;
ll a[N], f[N][N];
const ll inf = 4e18 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        if(i) {
            a[i] += a[i - 1];
        }
    }
    rep(l, 2, n + 1) {
        rep(i, 0, n - l + 1) {
            f[i][i + l - 1] = inf;
            rep(k, i, i + l - 1) {
                f[i][i + l - 1] = min(f[i][i + l - 1], f[i][k] + f[k + 1][i + l - 1]);
            }
            f[i][i + l - 1] += a[i + l - 1];
            if(i) {
                f[i][i + l - 1] -= a[i - 1];
            }
            pr(i, i + l - 1, f[i][i + l - 1]);
        }
    }
    cout << f[0][n - 1] << endl;
}

Measured memory_bytes: 1536
macro_rules! input {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input!{$next $($r)*}
    };
}

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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    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! {next,
        n: usize,
        m: usize,
        a: [usize; m],
    }

    let days = n as i64 - a.iter().sum::<usize>() as i64;
    println!("{}", if days >= 0 { days } else { -1 });

}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}


const ll MAX=100001;
vector<pair<ll,ll>> g[MAX];//頂点、頂点、何番目の辺
ll color[MAX];//辺の色
ll k;

void dfs(ll n,ll col){//頂点と、もってきた辺の色。木だから更新順序的にこれで良い
    ll c=1;
    rep(i,g[n].size()){
        if(color[g[n][i].second]!=-1) continue;
        else{
            if(c==col) c++;
            k=max(k,c);
            color[g[n][i].second]=c;
            dfs(g[n][i].first,c);
            c++;
        }
    }
    
}

int main(){
    ll n;
    cin >> n;
    rep(i,n-1){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(make(b,i));
        g[b].pb(make(a,i));
    }
    rep(i,n-1) color[i]=-1;
    k=0;
    dfs(0,0);
    cout << k << endl;
    rep(i,n-1) cout << color[i] << endl;
    
}



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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

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

char f[60][60];
int main(){
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, W) {
            f[i][j] = s[j];
        }
    }
    REP(i,H) REP(j,W) {
        if (f[i][j] == '.') {
            int cnt = 0;
            FOR(k,-1,2) FOR(l,-1,2)
            {
                ll y = i+k;
                ll x = j+l;
                if (-1<y&&y<H&&-1<x&&x<W&&f[y][x]=='#') {
                    cnt++;
                }
            }
            f[i][j] = '0' + cnt;
        }
    }
    REP(i,H) {
        REP(j,W) {
            cout << f[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll MAX = 510000;
const ll MOD = 1000000007;

using Graph = vector<vector<int> >;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    map<ll,ll> m;
    rep(i,M){
      ll c,d; cin >> c >> d;
      c--;
      m[c] += d;
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = m[0];
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + m[nv];
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) cout << dist[v] << endl;
}


Measured memory_bytes: 28148
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d",&a, &b, &c);
	if(a==b+c){
		printf("Yes\n");
	}
	else if(b==a+c){
		printf("Yes\n");
	}
	else if(c==a+b){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
    long long n, ans = 1;
    long double t = 1.0;
    cin >> n;
    vector<long long> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    rep(i, n) {
        t = t * a.at(i);
        if(t > 1e18) {
            ans = -1;
            break;
        }
        ans *= a.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    int res1 = a[n-1];
    int left = -1;
    int right = n;
    while(right - left > 1){
        int mid = left + (right-left)/2;
        if(a[mid] > res1/2){
            right = mid;
        }else{
            left = mid;
        }
    }

    int res2;
    if(left >= 0) res2 = a[left];
    else res2 = a[0];

    if(res1 % 2){
        if(right < n && abs(res1/2 - res2) > abs((res1+1)/2 - a[right])){
            res2 = a[right];
        }
    }else{
        if(right < n && abs(res1/2 - res2) > abs(res1/2 - a[right])){
            res2 = a[right];
        }
        if(left > 0 && abs(res1/2 - res2) > abs(res1/2 - a[left-1])){
            res2 = a[left-1];
        }
    }

    cout << res1 << " " << res2 << endl;
    return 0;
}

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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<vector<int>> adj(n), degree(2, vector<int> (n));
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    ++degree[s[x] - 'A'][y];
    ++degree[s[y] - 'A'][x];
  }
  vector<bool> visit(n);
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    if (!degree[0][i] || !degree[1][i]) {
      q.push(i);
      visit[i] = true;
    }
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : adj[x]) {
      if (!visit[y] && !--degree[s[x] - 'A'][y]) {
        q.push(y);
        visit[y] = true;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!visit[i]) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int btoh(string s){
    if(s.size()!=2)cout<<"error"<<endl;
    int ret=0;
    if('0'<=s[1]&&s[1]<='9')ret+=(s[1]-'0');
    else{
        ret+=10+(int)(s[1]-'a');
    }
    if('0'<=s[0]&&s[0]<='9')ret+=(s[0]-'0')*16;
    else{
        ret+=(10+(int)(s[0]-'a'))*16;
    }
    return ret;
}

double solve(string a,string b,string c,string d,string e,string f){
    int x,y,z;
//    cout<<btoh(a)<<" "<<btoh(b)<<" "<<btoh(c)<<" "<<btoh(d)<<" "<<btoh(e)<<" "<<btoh(f)<<endl;
    x=(btoh(a)-btoh(d)) * (btoh(a)-btoh(d));
    y=(btoh(b)-btoh(e)) * (btoh(b)-btoh(e));
    z=(btoh(c)-btoh(f)) * (btoh(c)-btoh(f));
    
    return sqrt(x+y+z);
}

int main(){
//    string color = {"black","blue",}
    string s;
    while(cin>>s){
        if(s=="0")break;
        string a,b,c;
        a=s.substr(1,2);
        b=s.substr(3,2);
        c=s.substr(5,2);
        string ans="";
        double d=INF;
        
        double t=solve(a,b,c,"00","00","00");
        if(t<d){
            d=t;
            ans="black";
        }
        
        t=solve(a,b,c,"00","00","ff");
        if(t<d){
            d=t;
            ans="blue";
        }
        
        t=solve(a,b,c,"00","ff","00");
        if(t<d){
            d=t;
            ans="lime";
        }
        
        t=solve(a,b,c,"00","ff","ff");
        if(t<d){
            d=t;
            ans="aqua";
        }
        
        t=solve(a,b,c,"ff","00","00");
        if(t<d){
            d=t;
            ans="red";
        }
        
        t=solve(a,b,c,"ff","00","ff");
        if(t<d){
            d=t;
            ans="fuchsia";
        }
        
        t=solve(a,b,c,"ff","ff","00");
        if(t<d){
            d=t;
            ans="yellow";
        }
        
        t=solve(a,b,c,"ff","ff","ff");
        if(t<d){
            d=t;
            ans="white";
        }
        cout<<ans<<endl;
    }
}

/*
 black	00	00	00
 blue	00	00	ff
 lime	00	ff	00
 aqua	00	ff	ff
 red	ff	00	00
 fuchsiaff	00	ff
 yellow	ff	ff	00
 white	ff	ff	ff

 */

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

public class Program
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);
        int[] num = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        Dictionary<int, int> dic = new Dictionary<int, int>();
        foreach (int key in num)
        {
            if (dic.ContainsKey(key)) dic[key]++;
            else dic.Add(key, 1);
        }
        if (dic.Count <= k) { Console.WriteLine(0); return; }

        var sorted = dic.OrderByDescending((x) => x.Value);
        int count = 0;
        int ans = 0;
        foreach (var d in sorted) {
            count++;
            if (count > k)
            {
                ans += d.Value;
            }
        }
        Console.WriteLine(ans);
    }

}


Measured memory_bytes: 43344
#include <stdio.h>


int main(void) 

{

	int a,b,d,r;
	
	double f;


	scanf("%d",&a);

	scanf("%d",&b);

	d=a/b;

	r=a%b;

	f=(double)a/b;

	printf("%d %d %7.6f\n",d,r,f);
	return 0;
}


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

int main() {
  int n,x=0,max_x=0;
  string s;
  cin>>n>>s;
  rep(i,n){
    if(s[i]=='I'){
      x++;
    }else{
      x--;
    }
    max_x=max(x,max_x);
  }
  cout<<max_x<<endl;
}

Measured memory_bytes: 256
ARG_N = gets.to_i
ARG_a = gets.split.map(&:to_i)
ARG_b = gets.split.map(&:to_i)
xa, xb = Array.new(ARG_N), Array.new(ARG_N)
i = 0
OVER = 2**31
while i < ARG_N do
  xa[i] = ARG_a[i] ^ ARG_a[i-1]
  xb[i] = ARG_b[i] ^ ARG_b[i-1]
  i+=1
end
xa += xa
results = []

def kmp_table arr 
  result = Array.new(arr.length)
  result[0] = 0
  j = 0
  1.upto(arr.length-1) do |i|
    result[i] = j
    if arr[i] == arr[j]
      j+=1
    else
      j= 0
    end
  end
  result[arr.length] = j
  result
end

table = kmp_table(xb)
# p xb
# p table

i = 0
j = 0
while i < (ARG_N * 2) -1 do
  # p [i,j]
  if xa[i] == xb[j]
    i+=1
    j+=1
  elsif j == 0
    i+=1
  else
    j = table[j]
  end
  if j == ARG_N
    r = (i-j) % ARG_N
    results.push([r, ARG_a[r]^ARG_b[0]])
    j = table[j]
  end
end
results.each do |re|
  puts "#{re[0]} #{re[1]}"
end

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

int main() {
    int N;
    cin >> N;
    double total = 0;

    for(int i=0; i<N; i++) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC") {
            x *= 380000;
        }
        total += x;
    }
    cout << total << endl;
}



Measured memory_bytes: 3744
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll nCm(ll n, ll m){
    if (m == 0 || m == n)
        return (1);
    else if (m == 1)
        return (n);
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    string s = to_string(n);

    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;

long long int i,j,ans=1;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int INF = 1<<29;
const int mod = 1000000007;

int main(){
	long long int n;
	cin>>n;
	for(i=1;i<=n;i++){
		ans *= i;
		ans = ans %mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define REP(i,a) for(int i=0;i<(a);i++)
using namespace std;

int main(){
	int n,x,d[1000],min=10e6;
  	cin>>n>>x;
  	REP(i,n){
      cin>>d[i];
      x-=d[i];
      min=(min>d[i]?d[i]:min);
    }
  	cout<<(n+(x/min))<<endl;
}

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

int main(void){
    int k, s;
    cin >> k >> s;
    int count = 0;
    int a = 0;
    int i, j, l;
    for(i = 0; i <= k; i++){
        for(j = 0; j <= k; j++){
            l = s-i-j;
            if(l <= k && l >= 0)
                count++; 
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#define MOD 1000000007
typedef long long ll;
using namespace std;

map<ll,ll> mp;

int main(){
  int n;
  ll t;
  cin>>n>>t;
  ll a[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>a[i];
    mp[a[i]]=i;
  }
  ll m=a[1],tmp=0;
  for(int i=1;i<=n;i++){
    m=min(a[i],m);
    tmp=max(tmp,a[i]-m);
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    if(mp[a[i]-tmp]!=0&&mp[a[i]-tmp]<i){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 13568
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]

    if M&1:
        print(-1)
        exit()

    ans = []
    E2i = {}
    num = [0] * (N+1)
    for i in range(M):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)
        ans.append((a, b))
        E2i[a*(N+1)+b] = i
        E2i[b*(N+1)+a] = i
        num[a] += 1

    que = deque()
    que.append(1)
    seen = [-1] * (N+1)
    seen[1] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()

    for v in seq:
        if v == 1:
            continue
        if num[v] & 1:
            p = par[v]
            i = E2i[v*(N+1)+p]
            if ans[i] == (p, v):
                ans[i] = (v, p)
                num[v] += 1
                num[p] -= 1
            else:
                ans[i] = (p, v)
                num[p] += 1
                num[v] -= 1

    for c, d in ans:
        print(c, d)


if __name__ == '__main__':
    main()


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

int main(){
  int N;

  cin >> N;
   cout << fixed << setprecision(5) << endl;
  vector<double> x(N);
  vector<string> u(N);

  for (int i = 0; i < N; i++){
    cin >> x.at(i);
    cin >> u.at(i);
  }

  double jpy = 1;
  double btc = 380000.0;

  double sum = 0;

  for (int i = 0; i < N; i++){
    if (u.at(i) == "JPY"){
      sum += x.at(i) * jpy;
    }
    else if (u.at(i) == "BTC")
    {
      sum += x.at(i) * btc;
    }
    
  }

  cout << sum << endl;
}

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

int main(void){
    map<string, int> count;
    string s;
    int n,ans;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        count[s] ++;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        count[s] --;
    }
    ans = 0;
    for( auto i = count.begin(); i!=count.end();++i){
        ans = max(ans,i->second);
    }
    cout<<ans<<endl;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int s,w;
	cin >> s >> w;
	if(s <= w){
		cout << "unsafe" << endl;
	}else{
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll a;
    int b,c;
    scanf("%lld %d.%d", &a,&b,&c);
    ll A = a;
    ll B = b*100+c;
    ll ans = A*B/100;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3716
N = int(input())
a = list(map(int,input().split()))

c = [0] * 9

for rate in a:
    i = rate // 400
    if i < 8:
        c[i] = 1
    else:
        c[8] += 1

c_sum = sum(c[:8])
c_min = max(c_sum, min(c[8],1))
c_max = c_sum + c[8]

print(c_min, c_max)




Measured memory_bytes: 38256
#include <stdio.h>

int main(void) {
  int A[3][3], N, b[10], C[3][3] = {0};
  int i, j, k;
  int c;
  int ii[3], jj[3];

  scanf("%d %d %d", &A[0][0], &A[0][1], &A[0][2]);
  scanf("%d %d %d", &A[1][0], &A[1][1], &A[1][2]);
  scanf("%d %d %d", &A[2][0], &A[2][1], &A[2][2]);

  scanf("%d", &N);

  for (i = 0; i < N; i++) {
    scanf("%d", &b[i]);
  }

  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        if (A[i][j] == b[k]) {
          C[i][j] = 1;
        }
      }
    }
  }

  for (i = 0; i < 3; i++) {
    c = 0;
    for (j = 0; j < 3; j++) {
      c += C[i][j];
    }
    if (c == 3) {
      printf("Yes");
      return 0;
    }
  }
  for (j = 0; j < 3; j++) {
    c = 0;
    for (i = 0; i < 3; i++) {
      c += C[i][j];
    }
    if (c == 3) {
      printf("Yes");
      return 0;
    }
  }
  c = 0;
  for (i = 0; i < 3; i++) {
    c += C[i][i];
  }
  if (c == 3) {
    printf("Yes");
    return 0;
  }
  c = 0;
  for (i = 0; i < 3; i++) {
    c += C[i][2-i];
  }
  if (c == 3) {
    printf("Yes");
    return 0;
  }
  printf("No");
  return 0;
}

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

int main() {
long long A,B,K ;
    cin >> A >> B >> K;
  if (A>=K)
  cout << A-K << " "<< B << endl;
  else if (A<K&&A+B>=K)
  cout << 0 << " "<< A+B-K << endl;  
  else cout << 0 << " "<< 0 << endl;
}


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

int main(){
    int A, B;
    int sum = 0;
    cin >> A >> B;
    
    if(A>B){
        sum = (A-1)+A;
    cout << sum;
    }
    if(A==B){
        sum = A + B;
    cout << sum;
    }
    if(A<B){
        sum = (B-1) + B;
    cout << sum;
    }
    return 0;
}


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

int main(){
	string S;
	cin >> S;
	int cnt = 0;
	for(int i = 0; i < 3; i++)
	{
		if(S[i] == 'o') cnt++;
	}
	
	cout << 700 + cnt * 100 << endl;
	
	return 0;
}

Measured memory_bytes: 256
from bisect import *
n=int(input())
a=sorted(list(map(int, input().split())))
b=sorted(list(map(int, input().split())))
c=sorted(list(map(int, input().split())))
ans=0
for i in range(n):
    x=bisect_left(a,b[i])
    y=n-bisect_right(c,b[i])
    ans+=x*y
print(ans)

Measured memory_bytes: 22720
const main = input => {
  const S = input.trim();
  if (S[0] === 'R' && S[1] === 'R' && S[1] === 'R' && S[2] === 'R') {
    console.log(3)
  } else if (S[0] === 'R' && S[1] === 'R' || S[1] === 'R' && S[2] === 'R') {
    console.log(2)
  } else if (S[0] === 'R' || S[1] === 'R' || S[2] === 'R') {
    console.log(1)
  } else {
    console.log(0)
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define all(c)              (c).begin(),(c).end()
#define for0(i, n)          for (ll i = 0; i < n; ++i)
#define for1(i, n)          for (ll i = 1; i <= n;++i)
#define for2(i, n)          for (ll i = 1; i < n; ++i)
#define for3(i, k, n)       for (ll i = k; i < n; ++i)
#define input(a, i, n)      for (int i = 0; i < n; ++i) {cin >> a[i]; }
#define output(a, i, n)     for (int i = 0; i < n; ++i) {cout << a[i] << ' '; }
//cout.precision(12);

using namespace std;

int64_t TN = 1;

void solve()
{
    int64_t n, a, b, c, ans = 0;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < n; ++j) {
            if (i * j < n) ans++;
            else break;
        }
    }
    cout << ans;
}

int main()
{
    //cin >> TN;
    for (int i = 0; i < TN; ++i) {
        solve();
    }
    return 0;
}


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

static const int MOD = 998244353;

long long Inv(long long a) {
        long long res = 1;
        long long n = MOD - 2;
        while (n > 0) {
                if (n & 1) res = res * a % MOD;
                a = a * a % MOD;
                n >>= 1;
        }
        return res;
}
const int N = 1010101;
long long fact[N];
long long invfact[N];
void init() {
        fact[0] = 1;
        for (int i = 1; i < N; i ++) fact[i] = (fact[i - 1] * i) % MOD;
        invfact[N - 1] = Inv(fact[N - 1]);
        for (int i = N - 2; i >= 0; i --) invfact[i] = (invfact[i + 1] * (i + 1)) % MOD;
}
long long C(long long n, long long r) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * invfact[n - r] % MOD * invfact[r] % MOD;
}

int main() {
        init();
        int n, m;
        scanf("%d%d", &n, &m);
        if (n < m) swap(n, m);
        long long ans = 0;
        for (int i = 1; i <= m; i ++) {
                long long mul = C(2 * i, i) % MOD;
                mul = mul * C(n + m - 2 * i, n - i) % MOD;
                ans = (ans + mul) % MOD;
        }
        ans = ans * Inv(2 * C(n + m, n)) % MOD;
        ans = (ans + n) % MOD;
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;


ll num[sz];



int main()
{


    ll x,a,b,n,m,p,k,d;

    cin>>x>>a>>b;
    a=-a;
    p=a+b;
   // cout<<p<<endl;


    if(p<=0)cout<<"delicious"<<endl;
    else if(p<=x)cout<<"safe"<<endl;
    else
        cout<<"dangerous"<<endl;




    return 0;
}



Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
  if not (c[i][0] - c[i + 1][0] == c[i][1] - c[i + 1][1] == c[i][2] - c[i + 1][2] and
          c[0][i] - c[0][i + 1] == c[1][i] - c[1][i + 1] == c[2][i] - c[2][i + 1]):
    print('No')
    quit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

string itoa(int i){
    stringstream ss;
    ss << i;
    return ss.str();
}

bool ispali(int n){
    string a = itoa(n);
    return string(a.begin(), a.end()) == string(a.rbegin(), a.rend());
}

int main(){
    int n; cin >> n;
    int d=0;
    while(1){
        int tm = max(0,n-d);
        if(ispali(tm)){
            cout << tm << endl;
            break;
        }
        int tp = n+d;
        if(ispali(tp)){
            cout << tp << endl;
            break;
        }
        d++;
    }
}

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

int main(){
	string n;
	cin >> n;
	bool ans=true;
	if(n[0]!='A')ans=false;
	int cnt=0;
	for(int i=2;i<n.size()-1;++i){
		if(n[i]=='C')cnt++;	
	}
	if(cnt!=1)ans=false;
	for(int i=0;i<n.size();++i){
		if(n[i]!='A'&&n[i]!='C'){
			if(n[i]-'a'<0||n[i]-'a'>25)ans=false;
		}
	}
	if(ans)cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp
print n + ":"
n = n.to_i
k = Math::sqrt(n)
k = k.to_i
for i in 2..k
  while n%i == 0
    print " #{i}"
    n = n/i
  end
end
if n != 1
  puts " #{n}"
else
  puts ""
end

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

using namespace std;

int main(void) {

  long long N;
  cin >> N;
  long long kmax = -999999999999999;
  long long kmin = 999999999999999;
  long long lmax = -999999999999999;
  long long lmin = 999999999999999;
  for (long long i = 0; i < N; i++) {
    long long x, y;
    cin >> x >> y;
    long long k = x + y;
    long long l = y - x;
    if (k > kmax) kmax = k;
    if (k < kmin) kmin = k;
    if (l > lmax) lmax = l;
    if (l < lmin) lmin = l;
  }
  long long ans;
  if ( kmax - kmin > lmax - lmin) {
    ans = kmax - kmin;
  } else {
    ans = lmax - lmin;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3624
D, N = (int(i) for i in input().split())
# D = 2
# N = 100

if N != 100:
    if D == 0:
        print(int(1*N))
    elif D == 1:
        print(int(100*N))
    elif D == 2:
        print(int(10000 * N))

else:
    if D == 0:
        print(101)
    elif D == 1:
        print(10100)
    elif D == 2:
        print(1010000)


Measured memory_bytes: 3060
using static System.Console;
class A{
  static void Main(){
    var s = System.Array.ConvertAll(new string[]{ReadLine(),ReadLine(),ReadLine(),ReadLine()},int.Parse);
    WriteLine((s[1]>s[0]?s[0]:s[1])*s[2]+(s[0]>s[1]?s[0]-s[1]:0)*s[3]);
  }
}


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


int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int A_p = 0;
  int B_p = 0;
  int half;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      A_p += a[i];
    } else {
      B_p += a[i];
    }
  }
  cout << A_p - B_p << endl;
}

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

#define min(a,b) (((a) > (b)) ? (b) : (a))
#define max(a,b) (((a) < (b)) ? (b) : (a))
#define abs(a) (((a) < 0) ? (-(a)) : (a))

constexpr int64_t MOD = 1000000007;
int64_t fact(int64_t n) {
    int64_t ret = 1;
    for(;n>1;n--) {
//printf("n(%ld):%ld\n", n, ret);
        ret = ((ret * n) % MOD);
    }

    return ret % MOD;
}

int main(void) {
    int64_t N,M; 
    int64_t result = 0;
    
    cin >> N >> M;
    if(N == M) {
        result = fact(N);
        result = (result * result) % MOD;
        result = (result * 2) % MOD;
    } else if(abs(N-M) == 1) {
        result = fact(min(N,M));
        result = (result * result ) % MOD;
        result = (result * max(N,M)) % MOD;
    } else {
        result = 0;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n,d;cin>>n>>d;
    ll s=0;
    rep(i,0,n-1){
        ll x,y;cin>>x>>y;
        if(powl(x,2)+powl(y,2)<=powl(d,2)){
            s++;
        }
    }
    cout<<s<<endl;

    return 0;
}





Measured memory_bytes: 3620
import copy

n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append([a,b])

ll=[0]*n

for j in l:
    if h[j[0]-1]>h[j[1]-1]:
        ll[j[1]-1]+=1
    elif h[j[0]-1]==h[j[1]-1]:
        ll[j[1]-1]+=1
        ll[j[0]-1]+=1
    else:
        ll[j[0]-1]+=1

ans=0
for k in ll:
    if k==0:
        ans+=1
print(ans)

Measured memory_bytes: 29240