akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strlen()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	char roman[7] = "MDCLXVI";
	int arabic[7] = {1000, 500, 100, 50, 10, 5, 1};
	char str[101];
	int i, j;

	while (true)
	{
		if (scanf("%s", str) == EOF)
			break;

		int n = 0;
		for (i = 0; i < strlen(str); ++i)
		{
			for (j = 0; j < 7; ++j)
			{
				if (str[i] == roman[j])
				{
					n += arabic[j];
					if (i >= 1 && j < 7 - 1 && str[i - 1] == roman[j + 1])
						n -= arabic[j + 1] * 2;

					else if (i >= 1 && j + 2 < 7 && str[i - 1] == roman[j + 2])
						n -= arabic[j + 2] * 2;
				}
			}
		}

		printf("%d\n", n);
	}

	return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(a,b) for(int i=a;i<b;i++)
#define incl(a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
//#define first ff
//#define second ss
//#define pair<int,int> pii

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

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

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

signed main()
{
    fatafat;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<((0>a+b-n)?(0):(a+b-n));
}

Measured memory_bytes: 256
a,b = gets.chomp.split(" ").map(&:to_i)
ary = gets.chomp.split("")
if ary.find_all{|n| n=="-"}.count !=1
    puts "No"
    exit
end
if  ary.find_index{|n| n =="-"} != a
    puts "No"
else
    puts "Yes"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	long long a,b;
	cin>>a>>b;
	a=a%b;
	a=min(a , b-a);
	cout<<a;
	re 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    ll ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++)ans+=d[i]*d[j];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    s.append(int(input()))
ans = sum(s)
if ans%10 == 0:
    flag = True
    s.sort()
    for x in s:
        if x%10!=0:
            print(ans - x)
            flag = False
            break
    if flag:
        print(0)
else:
    print(ans)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!.toCharArray()
    val i = s.map { it.toInt() + n }
    val c = i.map {
        if (it.toChar() in "ABCDEFGHIJKLMNOPQRSTUVWXYZ") {
            it.toChar()
        } else {
            (it - 26).toChar()
        }
    }
    println(c.joinToString(""))
}

Measured memory_bytes: 31772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int n;
  std::cin >> n;
  std::cout << n * (n + 1) / 2 << std::endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
import itertools

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
ans = [[0 if c=='.' else '#' for c in s] for s in S]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.': continue
        for di, dj in itertools.product([-1,0,1], repeat=2):
            if not 0 <= i+di < H: continue
            if not 0 <= j+dj < W: continue
            if S[i+di][j+dj] == '#': continue
            ans[i+di][j+dj] += 1

for row in ans:
    print(*row, sep='')

Measured memory_bytes: 3572
N , T = input().split()

N = int(N)
T = int(T)

cos_mini = 1001

for i in range(N):

    c,t = input().split()

    c = int(c)
    t = int(t)

    if t <= T and c < cos_mini:

        cos_mini = c


if (cos_mini <= 1000):
    print(cos_mini)
else:
    print("TLE")


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int n,c,d[40][40],m[510][510];
int main(){
    cin>>n>>c;
    lol(i,c)lol(j,c)cin>>d[i][j];
    lol(i,n)lol(j,n)cin>>m[i][j];
    int w[3][40];
    for(int k=0;k<3;k++){
	lol(r,c){
	    w[k][r]=0;
	    lol(i,n)lol(j,n){
		if((i+j)%3==k){
		    w[k][r]+=d[m[i][j]-1][r];
		}
	    }
	}
    }
    int ans=mod;
    lol(i,c)lol(j,c)lol(k,c){
	if(i==j||i==k||j==k)continue;
	int gre=w[0][i]+w[1][j]+w[2][k];
	ans=min(ans,gre);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1280
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut done: bool = false;
    let mut index: u32 = 1;

    while !done {
        let input: u32 = read();

        if input == 0 {
            done = true;
        } else {
            println!("Case {}: {}", index, input);
            index += 1;
        }
    }
}



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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define F(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define endl '\n'

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

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





void solve() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) if (s[i] == '7') {
		puts("Yes");
		return;
	}
	puts("No");
}





int main() {
	ios::sync_with_stdio(false);
	cout << fixed;

#ifdef LOCAL
	double cl = clock();
#endif

	int T = 1;
	while (T--) solve();

#ifdef LOCAL
  cerr << "Time elapsed: " << (clock() - cl) / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3644
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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() {
    input! {
        a: i64,
        b: i64,
        k: usize,
    }
    let mut v = (a..b + 1).take(k).collect::<Vec<_>>();
    v.append(&mut (a..b + 1).rev().take(k).collect::<Vec<_>>());
    let ans = v
        .iter()
        .collect::<std::collections::BTreeSet<_>>()
        .iter()
        .map(|x| x.to_string())
        .collect::<Vec<_>>()
        .join("\n");
    println!("{}", ans);
}


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

string replacementAll( string s, string target, string replacement )
{
    if (!target.empty()) 
    {
        string::size_type pos = 0;
        while ((pos = s.find(target, pos)) != string::npos) 
        {
            s.replace(pos, target.length(), replacement);
            pos += replacement.length();
        }
    }

    return s;
}

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

    s = replacementAll( s, "eraser", "0" );
    s = replacementAll( s, "erase", "0" );
    s = replacementAll( s, "dreamer", "0" );
    s = replacementAll( s, "dream", "0" );

    for( int i=0 ; i<s.length() ; i++ )
    {
        if( s[i] != '0' )
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 512
n = int(input())
u = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
flag = 1
for i in t:
    if i in u:
        if flag == 1:
            flag = 0
            print("Opened by" + " " + str(i))
        else:
            flag = 1
            print("Closed by" + " " + str(i))
    else:
        print("Unknown" + " " + str(i))


Measured memory_bytes: 5644
#include<stdio.h>
long long int gcd(long long int a, long long int b)
{
	long long int r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main()
{
	long long int a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	a--;
	long long int ans = b - a;
	ans -= b / d;
	ans -= b / c;
	ans += a / c;
	ans += a / d;
	long long int g = c * d / gcd(c, d);
	ans += b / g;
	ans -= a / g;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e6+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int n,m;
int need[]={0,2,5,5,4,5,6,3,7,6};
int memo[N];
std::vector<int> a;
int solve(int rem){
	if(rem==0)return 0;

	int &ret = memo[rem];
	if(~ret)return ret;
	ret = -1e9;
	for(int i=m-1;i>=0;i--){
		if(need[a[i]]<=rem){
			ret = max(ret,1+solve(rem-need[a[i]]));
		}
	}

	return ret;
}
void trace(int rem){
	if(rem==0)return;
	int who , mx=0;
	for(int i=m-1;i>=0;i--){
		if(need[a[i]]<=rem){
			if(mx<1+solve(rem-need[a[i]]))mx=1+solve(rem-need[a[i]]),who=a[i];
		}
	}
	printf("%d",who );
	trace(rem-need[who]);
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
      scanf("%d %d",&n,&m);

      a.resize(m);

      for(int i=0;i<m;i++)scanf("%d",&a[i]);

      sort(all(a));

	memset(memo,-1,sizeof(memo));

	solve(n);

	trace(n);
 }

Measured memory_bytes: 4352
x = int(input())
ans = 0
for i in range(1000):
    a = int(i/2)*(-1)**int(i)
    for j in range(1000):
        b = int(j/2)*(-1)**int(j)
        if a**5 - b**5 == x:
            ans = 1
            break
    if ans == 1:
        break
print(a,b)

Measured memory_bytes: 67944
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
//const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9) << flush;
//memset(a, 0, sizeof(a));
//--------------------------

int n;
vector<int> x,y;

int main()
{
	cin >> n;
	for (int i = 0;i < n;i++) {
		int t;
		cin >> t;
		x.push_back(t);
		y.push_back(t);
	}

	sort(y.begin(), y.end());
	for (int i = 0;i < n;i++) {
		int k = lower_bound(y.begin(), y.end(), x[i]) - y.begin();
		if (k < n / 2) {
			cout << y[n / 2] << endl;
		}
		else {
			cout << y[n / 2 - 1] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3948
#include<cstring>
#include<cstdio>
#include<algorithm>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;i++)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;i--)
#define ll long long
#define max(a,b)(a>b?a:b)
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,a[N],ans,o,k;
bool b[N];
int main(){
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	fd(i,1,30){
		o=1<<i;
		k=n;
		fo(j,1,n){
			if(b[j])continue;
			for(;j<k&&(a[j]+a[k]>o||b[k]);)k--;
			if(j<k){
				if(a[j]+a[k]==o){
					b[j]=b[k]=1;
					ans++;k--;
				}
			}
			if(j>=k)break;
		}
		
	}
	
	printf("%d",ans);
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>bool chmax(T &a, const T &b);
template <class T>bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t,std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int a, b;
  cin >> a >> b;
  std::cout << (a + b >= 10 ? "error" : to_string(a + b)) << std::endl;

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

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

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }
  
  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if(n % i == 0){
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }
  
  return res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    int m = i;
    for (int j = i; j < N; j++){
      if (A[j] < A[m]){
        m = j;
      }
    }
    if (i != m){
      swap(A[i], A[m]);
      ans++;
    }
  }
  for (int i = 0; i < N; i++){
    cout << A[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
  cout << ans << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    ll res = LLONG_MAX;
    ll n = s.size();
    rep(i,n){
        if(!i)continue;
        if(s[i] != s[i-1])res = min(res, max(ll(i),n-i));
    }
    if(res == LLONG_MAX)res = n;
    cout << res << endl;
}

Measured memory_bytes: 512
loop do
  n = gets.chomp.to_i
  break if n==0
  mi,ma = 1e10,-1
  sum = 0
  n.times do |i|
    t = gets.chomp.to_i
    sum += t
    mi = [t, mi].min
    ma = [t, ma].max
  end
  sum -= mi
  sum -= ma
  puts sum/(n-2)
end

Measured memory_bytes: 6116
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
typedef struct UnionFind
{
	vector<int> par;

	UnionFind(int N)
	{
		par.resize(N);
		for(int i=0; i<N; i++)
		{
			par[i] = i;
		}
	}

	int root(int x)
	{
		if(par[x]==x)
		{
			return x;
		}
		else
		{
			return par[x] = root(par[x]);
		}
	}

	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)
		{
			return;
		}
		par[rx] = ry;
	}

	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
}UnionFind;

int main()
{
	//Union Find
	int N,M,K;
	cin>>N>>M>>K;

	UnionFind u(N);
	vector<int> Friend(N);
	vector<int> count(N,0);
	vector<int> result(N);

	vector<pair<int,int>> query(M);
	for(int i=0; i<M; i++)
	{
		int _a,_b;
		cin>>_a>>_b;
		int A,B;
		A = min(_a,_b)-1;
		B = max(_a,_b)-1;

		query[i] = make_pair(A,B);
	}
	sort(query.begin(),query.end());
	for(int i=0; i<M; i++)
	{
		int A = query[i].first;
		int B = query[i].second;
		//cout<<A<<","<<B<<endl;
		u.unite(A,B);
		Friend[A]++;
		Friend[B]++;
	}

	for(int i=0; i<N; i++)
	{
		count[u.root(i)]++;
	}
	for(int i=0; i<N; i++)
	{
		result[i] = count[u.root(i)] - Friend[i] -1;
	}

	for(int i=0; i<K; i++)
	{
		int A,B;
		cin>>A>>B;
		A--;
		B--;

		if(u.same(A,B))
		{
			result[A]--;
			result[B]--;
		}
	}
	for(int i=0; i<N; i++)
	{
		cout<<result[i]<<" ";
	}
	cout<<endl;

}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++)
inline int read() {
  static int ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  for (top = 0, ch = gc(); !isalpha(ch); ch = gc());
  while (isalpha(ch)) s[++top] = ch, ch = gc();
  return top;
} 
typedef long long ll;
#define pb push_back
#define rez resize
#define ppp pop_back
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) { x = 1, y = 0; return; }
  exgcd(b, a - a / b * b, y, x), y -= a / b * x;
}
namespace modular {
  const int mod = 998244353;
  int ret;
  inline int add(int a, int b) { return a < mod - b ? a + b : a - mod + b; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a < mod - b ? a + b : a - mod + b; }
  inline void Dec(int &a, int b) { a = a < b ? a - b + mod : a - b ; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) { for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1); return ret; }
  inline int fix(int x) {
    x <= -mod || x >= mod ? x %= mod : 0;
    return x < 0 ? x + mod : x;
  }
  inline int Inv(int a) {
    static int x, y;
    return exgcd(a, mod, x, y), fix(x);
  }
}  using namespace modular;
const int N = 5005;
char s[N], ans[N], tmp[N], mn, str[N << 1];
int n, K, ff = 0;
inline bool chk() {
  for (ri i = 1; i <= n; ++i) if (ans[i] != tmp[i]) return tmp[i] < ans[i];
  return 0;
}
inline void upd() {
  if (!ff || chk()) {
    ff = 1;
    for (ri i = 1; i <= n; ++i) ans[i] = tmp[i];
  }
}
int pw[31];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  pw[0] = 1;
  for (ri i = 1; i <= 30; ++i) pw[i] = pw[i - 1] << 1;
  mn = 'z';
  n = read(), K = read(), Read(s);
  for (ri i = 1; i <= n; ++i) mn = min(mn, s[i]);
  if (K >= 30) {
    for (ri i = 1; i <= n; ++i) cout << mn;
    return 0;
  }
  else {
    for (ri i = 1; i <= n; ++i) str[i] = s[i], str[2 * n - i + 1] = s[i];
    int len = 1;
    for (ri i = 2; i <= n; ++i) len = s[i] == s[i - 1] ? len + 1 : 1;
    for (ri i = n; i <= 2 * n; ++i) {
      if (K == 1) for (ri p = i, j = 1; j <= n; --p, ++j) tmp[j] = str[p];
      else if (pw[K - 1] <= n / len) {
        int up = pw[K - 1] * len;
        for (ri j = 1; j <= up; ++j) tmp[j] = str[i];
        for (ri j = up + 1, p = i - len; j <= n; ++j, --p) tmp[j] = str[p];
      }
      else for (ri j = 1; j <= n; ++j) tmp[j] = str[i];
      upd();
      len = str[i] == str[i + 1] ? len + 1 : 1; 
    }
    for (ri i = 1; i <= n; ++i) cout << ans[i];
  }
  return 0;
}

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

ll dp[200005];
vector<P> opt;

ll solve(int n) {
  if (dp[n] != -1) return dp[n];
  if (n == 0)
    return dp[n] = 1;
  else if (n == 1) {
    int ret = 0;
    for (auto el : opt) {
      if (el.first == 1) ret = 1;
    }
    return dp[n] = ret;
  } else {
    ll ret = solve(n - 1);
    for (auto el : opt) {
      if (n - el.first >= 0) {
        if (n - el.second >= 0) {
          ret = ret + solve(n - el.first) - solve(n - el.second);
        } else {
          ret = ret + solve(n - el.first);
        }
      }
      ret = (ret + MOD) % MOD;
    }
    return dp[n] = ret;
  }
}

int main() {
  rep(i, 200005) dp[i] = -1;

  int n, k;
  cin >> n >> k;
  rep(i, k) {
    int l, r;
    cin >> l >> r;
    opt.emplace_back(l, r + 1);
  }
  cout << solve(n - 1) << endl;
  // rep(i, 5) cout << dp[i] << endl;

  return 0;
}

Measured memory_bytes: 20816
#include <stdio.h>
int main(void){
  int Array[251],heapsize,i;
  scanf("%d",&heapsize);
  for(i=1;i<=heapsize;i++)
    scanf("%d",&Array[i]);

  for(i=1;i<=heapsize;i++){
    printf("node %d: ",i);
    printf("key = %d, ",Array[i]);
    if(i>1)
      printf("parent key = %d, ",Array[i/2]);
    if(i*2<=heapsize)
      printf("left key = %d, ",Array[i*2]);
    if(i*2+1<=heapsize)
      printf("right key = %d, ",Array[i*2+1]);
    printf("\n");
  }

  return 0;
}



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

using namespace std;
typedef long long ll;

ll N,K;
ll A[20];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i];
    ll min_cost = 1e12;
    for(int i=0;i<(1<<N);i++){
        ll cost = 0;
        bitset<15> bt(i);
        if(bt.count() != K) continue;
        ll h = 0;
        for(int j=0;j<N;j++){
            if(bt[j] == 1){
                if(A[j] <= h){
                    cost += h - A[j] + 1;
                    h++;
                }else{
                    h = A[j];
                }
            }else{
                h = max(A[j], h);
            }
        }
        min_cost = min(cost, min_cost);
    }
    cout << min_cost << endl;
    return 0;
}

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

#define int long long

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

  int n;
  cin >> n;

  vector<int> p(n);
  int cnt = 0;
  for ( int i = 0; i < n; i++ ) {
    cin >> p[i];
    if ( p[i] != i+1 ) cnt++;
  }

  if ( cnt <= 2 ) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> s(h); for (int i = 0; i < h; i++) cin >> s[i];
  VV<> a(h - 1);
  auto f = [&](int i, int j) { return s[i][j] == '#'; };
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (f(i, j) + f(i, j + 1) + f(i + 1, j) + f(i + 1, j + 1) & 1) a[i].push_back(j);
    }
    a[i].push_back(w - 1);
  }
  int res = max(h, w);
  V<V<>::iterator> p(h - 1);
  for (int i = 0; i < h - 1; i++) p[i] = a[i].begin();
  V<> b(h - 1), l(h - 1), r(h - 1);
  for (int j = 0; j < w - 1; j++) {
    for (int i = 0; i < h - 1; i++) {
      while (*p[i] < j) ++p[i];
      b[i] = *p[i] - j + 1;
    }
    stack<int> st;
    for (int i = 0; i < h - 1; i++) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      l[i] = b[i] * (i - (!st.empty() ? st.top() : -1));
      st.push(i);
    }
    stack<int>().swap(st);
    for (int i = h - 2; i >= 0; i--) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      r[i] = b[i] * ((!st.empty() ? st.top() : h - 1) - i);
      st.push(i);
    }
    for (int i = 0; i < h - 1; i++) res = max(res, l[i] + r[i]);
  }
  cout << res << '\n';
}

Measured memory_bytes: 20352
#include<bits/stdc++.h>
using namespace std;
queue<char>que;
int main(){
	string s;
	int ans=0;
	cin>>s;
	for(int i=0;i<s.size();i++)que.push(s[i]);
	for(int i=0;i<s.size();i++){
		(que.front()=='+')?ans++:ans--;
		que.pop();
	}cout<<ans<<'\n';
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    int a=n%10;
    int b=(n/10)%10;
    int c=(n/100)%10;
    if(a==7||b==7||c==7)
    cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
using llong = long long;

//===
template<class T, class Compare = less<T>>
struct SparseTable {

    bool builded = false;
    const int n;
    const Compare cmp;
    vector<T> elements;
    vector<vector<int>> table;
    vector<size_t> log2;

    SparseTable():n(0){}
    SparseTable(int n, T v = T(), const Compare &f = Compare()):
        n(n), log2(n + 1), elements(n), cmp(f)
    {
        for (int i = 2; i <= n; i++) log2[i] = log2[i / 2] + 1;
        elements.assign(n, v);
        table.assign(log2[n] + 1, vector<int>(n));
    }

    template<class InputIterator>
    SparseTable(InputIterator first, InputIterator last,
                const Compare &f = Compare()):
        n(distance(first, last)), log2(n + 1), elements(first, last), cmp(f)
    {
        for (int i = 2; i <= n; i++) log2[i] = log2[i / 2] + 1;
        table.assign(log2[n] + 1, vector<int>(n));
        build();
        //table = vector<vector<T>>(logn, vector<T>(first, last));
    }

    void build(void) {
        for (int i = 0; i < n; i++) table[0][i] = i;
        
        for (int i = 0; i < log2[n]; i++) {
            int w = 1 << i;
            for (int j = 0; j + (w * 2) <= n; j++) {
                int l = table[i][j];
                int r = table[i][j + w];

                if (cmp(elements[l], elements[r])) table[i + 1][j] = l;
                else table[i + 1][j] = r;
            }
        }

        builded = true;
    }

    void set(int k, T dat) {
        elements[k] = dat;
        builded = false;
        return;
    }

    //[l, r)
    T fold(int l, int r) {
        if (!builded) build();

        int k = log2[r - l];
        l = table[k][l];
        r = table[k][r - (1 << k)];

        if (cmp(elements[l], elements[r])) return elements[l];
        else return elements[r];
    }

    int size() { return n; }

    T operator[] (const int k) { return elements[k]; }
};
//===

llong N, Q;
llong c[300005];
llong arr[300005];

int main() {
    cin >> N >> Q;
    for (llong i = 0; i < N; i++) {
        cin >> c[i];
        arr[c[i]] = c[i];
    }

    SparseTable<llong, greater<>> RMQ(begin(arr), end(arr));

    for (llong i = 0; i < Q; i++) {
        llong m;
        cin >> m;

        llong ans = 0;
        for (llong j = 0; j <= 300000; j += m) {
            llong l = j;
            llong r = min(300000ll, j + m);

            ans = max(ans, RMQ.fold(l, r) % m);
        }

        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 35520
#include <stdio.h>

int main(){

  int a,b,ans;
  char op;

  while(scanf("%d %c %d",&a,&op,&b)){
    if(op=='+')
     ans=a+b;
    else if(op=='-')
     ans=a-b;
    else if(op=='*')
     ans=a*b;
    else if(op=='/')
     ans=a/b;
    else break;
    printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 600
# -*- coding: utf-8 -*-


def main():
    l, r = map(int, input().split())
    mod = 2019
    ans = mod
    r = min(r, l + mod)

    for i in range(l, r):
        for j in range(i + 1, r + 1):
            candidate = i * j
            candidate %= mod
            ans = min(ans, candidate)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38896
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	int n,k;
	cin>>n>>k;
	int a[n];
	int s = 0;
	int maxi = 0;
	for(int i = 0; i<n; i++){
		cin>>a[i];
		s+=(2*a[i]);
		maxi = max(maxi,a[i]);
	}
	// if(k>=s) {
	// 	cout<<"0\n";
	// 	return;
	// }
	int l = 1;
	int r = maxi;
	while(l<r){
		int m = (l+r)/2;
		int cnt = 0;
		for(int i = 0; i<n; i++){
			int tmp = (a[i]/m)+(a[i]%m != 0);
			cnt+=max(0ll,tmp-1);
		}
		if(cnt<=k) r = m;
		else l = m+1;
	}
	cout<<r<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 5180
#include<iostream>
#include<cstdio>
#define N (4009)
#define MOD (924844033)
using namespace std;

long long n,k,vis[N],tot,g[N],f[N][N][2],fac[N];

int main()
{
	scanf("%lld%lld",&n,&k);
	for (int t=1; t<=2; ++t)
		for (int i=1; i<=k; ++i)
			for (int j=i; j<=n; j+=k)
			{
				tot++;
				if (j!=i) vis[tot]=true; 
			}
	f[0][0][0]=1;
	for (int i=1; i<=2*n; ++i)
		for (int j=0; j<=n; ++j)
		{
			(f[i][j][0]+=f[i-1][j][0]+f[i-1][j][1])%=MOD;
			if (vis[i]) (f[i][j][1]+=f[i-1][j-1][0])%=MOD;
		}
	for (int i=0; i<=n; ++i)
		g[i]=(f[2*n][i][0]+f[2*n][i][1])%MOD;
	
	fac[0]=1;
	for (int i=1; i<=n; ++i) fac[i]=fac[i-1]*i%MOD;
	long long ans=fac[N];
	for (int i=0,j=1; i<=n; ++i,j=-j)
		(ans+=j*g[i]*fac[n-i]%MOD)%=MOD;
	printf("%lld\n",(ans+MOD)%MOD);
}

Measured memory_bytes: 249728
#include <cstdio>
#include <iostream>
#define maxn 100005
using namespace std;
int n,d[maxn],num[maxn];
const int mod = 998244353;
long long ans=1;
long long my_pow(int x,int y){
    long long tmp=1;
    for(int i=1;i<=y;++i)
        tmp = (tmp*x)%mod;
    return tmp;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&d[i]);
        ++num[d[i]];
    }
    if((num[0]!=1) || (d[1]!=0)){
        printf("0");
        return 0;
    }
    for(int i=1;i<n;++i){
        ans = (ans*my_pow(num[i-1],num[i]))%mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1024
N = int(input().strip())
X = list(map(int,input().strip().split(' ')))
sorted_X = sorted(X)
med_l=sorted_X[int(N/2-1)]
med_r=sorted_X[int(N/2)]
for iX in X:
    if iX <= med_l:
        print(med_r)
    elif med_r <= iX:
        print(med_l)
    

Measured memory_bytes: 25476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  ll k,x,y=0,a,b,c,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  ll n,ans=0;
  priority_queue<ll> red,green,non;
  
  cin>>x>>y>>a>>b>>c;
  vector<ll> re(x,0),gr(y,0);
  rep(i,a){
    ll zzzz;
    cin>>zzzz;
    red.push(zzzz);
  }
  rep(i,b){
    ll zzzz;
    cin>>zzzz;
    green.push(zzzz);
  }
  rep(i,c){
    ll zzzz;
    cin>>zzzz;
    non.push(zzzz);
  }
  rep(i,x){
    ans+=red.top();
    re[i]=red.top();
    red.pop();
  }
  rep(i,y){
    ans+=green.top();
    gr[i]=green.top();
    green.pop();
  }
  x--;y--;
  while(non.size()!=0){
    if(x>-1&&y>-1){
    if(re[x]>gr[y]){
      if(gr[y]<non.top()){ans+=non.top()-gr[y];y--;non.pop();}
      else if(re[x]<non.top()){ans+=non.top()-re[x];x--;non.pop();}
      else break;
      }
    else{
      if(re[x]<non.top()){ans+=non.top()-re[x];x--;non.pop();}
      else if(gr[y]<non.top()){ans+=non.top()-gr[y];y--;non.pop();}   
      else break;
      }}
    else if(y>-1){if(gr[y]<non.top()){ans+=non.top()-gr[y];y--;non.pop();}else break;}
    else if(x>-1){if(re[x]<non.top()){ans+=non.top()-re[x];x--;non.pop();}else break;}
    else break;

  }
  cout<<ans<<endl;
  
  //cout<<dp[x-1][y-1]<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll a,b,c,A,B,C;
ll mo=1000000007;
const int CN=401;
ll C_[CN][CN];
ll pat[101][101];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll hoge1d(int a,int A) {
	return a;
}
ll hoge2d(int a,int A,int b,int B) {
	ll ret=0;
	// 2planes
	ret-=a*b;
	// 1planes
	ret+=a*modpow(hoge1d(b,B),A/a);
	ret+=b*modpow(hoge1d(a,A),B/b);
	return (ret+mo)%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,CN) for(j=0;j<=i;j++) C_[i][j]=(j==0||j==i)?1:(C_[i-1][j-1]+C_[i-1][j])%mo;

	cin>>a>>b>>c>>A>>B>>C;
	if(A%a || B%b || C%c) return _P("0\n");
	
	ll ret=0;
	// 3planes
	ret=a*b*c;
	// 2planes
	ret-=a*b*modpow(hoge1d(c,C),A/a*B/b);
	ret-=b*c*modpow(hoge1d(a,A),B/b*C/c);
	ret-=c*a*modpow(hoge1d(b,B),C/c*A/a);
	// 1planes
	ret+=a*modpow(hoge2d(b,B,c,C),A/a);
	ret+=b*modpow(hoge2d(c,C,a,A),B/b);
	ret+=c*modpow(hoge2d(a,A,b,B),C/c);
	ret=(ret%mo+mo)%mo;
	
	// nontribial
	int p,q,p2,q2;
	for(p=A/a;p>=1;p--) for(q=B/b;q>=1;q--) {
		pat[p][q]=C_[A/a][p]*C_[B/b][q]%mo*modpow(c,(A/a-p)*(B/b-q))%mo;
		for(p2=p;p2<=A/a;p2++) for(q2=q;q2<=B/b;q2++) {
			if(p==p2 && q==q2) continue;
			pat[p][q] -= pat[p2][q2]*C_[p2][p]%mo*C_[q2][q]%mo;
		}
		pat[p][q]=(pat[p][q]%mo+mo)%mo;
		ll way=modpow(modpow(b,p)+modpow(a,q)+mo-1,C/c)-modpow(modpow(b,p),C/c)-modpow(modpow(a,q),C/c)+1;
		if(p<A/a && q<B/b) (ret+=a*b*c*(way%mo+mo)%mo*pat[p][q])%=mo;
	}
	
	
	
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1536
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	string ans = "";
	bool yay = 0;
	while(n){
		char u = (char)((n%26) + 'a' - 1);
		if(n%26 == 0){
			u = 'z';
		}
		n -= (u - 'a' + 1); 
		ans = u + ans;
		n /= 26;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

const intt initt = (1 << 31) - 1;

intt n, q;
intt t[maxx << 2], lazy[maxx << 2];

void init () {
    memset (lazy, -1, sizeof (lazy));
}

void relax (intt v, intt l, intt r) {
    t[v] = lazy[v];
    if (l != r)
        lazy[v << 1] = lazy[v << 1 | 1] = lazy[v];
    lazy[v] = -1;
}

void build (intt v, intt l, intt r) {
    if (l == r) {
        t[v] = initt;
        return;
    }
    intt mid = (l + r) >> 1;
    build (v << 1, l, mid);
    build (v << 1 | 1, mid + 1, r);
    t[v] = min (t[v << 1], t[v << 1 | 1]);
}

void update (intt v, intt l, intt r, intt i, intt j, intt val) {
    if (lazy[v] != -1)
        relax (v, l, r);
    if (j < l || i > r)
        return;
    if (i <= l && r <= j) {
        lazy[v] = val;
        relax (v, l, r);
        return;
    }
    intt mid = (l + r) >> 1;
    update (v << 1, l, mid, i, j, val);
    update (v << 1 | 1, mid + 1, r, i, j, val);
    t[v] = min (t[v << 1], t[v << 1 | 1]);
}

intt query (intt v, intt l, intt r, intt i, intt j) {
    if (j < l || i > r)
        return initt;
    if (lazy[v] != -1)
        relax (v, l, r);
    if (i <= l && r <= j)
        return t[v];
    intt mid = (l + r) >> 1;
    return min (query (v << 1, l, mid, i, j),
                query (v << 1 | 1, mid + 1, r, i, j));
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    init();
    cin >> n >> q;
    build (1, 1, n);
    while (q --) {
        intt type, i, j, val;
        cin >> type;
        if (type == 0)
            cin >> i >> j >> val, i ++, j ++, update (1, 1, n, i, j, val);
        else
            cin >> i >> j, i ++, j ++, cout << query (1, 1, n, i, j) << endl;
    }
    return 0;
}

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

dp = [10**5]*(N+1)
dp[0] = 0
dp[1] = 1
s = 6
n = 9
for i in range(2,N+1):
    if 6*s <= i:
        s *= 6
    if 9*n <= i:
        n *= 9
    if i < 6:
        dp[i] = dp[i-1]+1
    elif i < 9:
        dp[i] = min(dp[i-1], dp[i-s])+1
    else:
        dp[i] = min(dp[i-1], dp[i-s], dp[i-n])+1
print(dp[N])

Measured memory_bytes: 67804
import sys
import heapq

input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))
d = [list(map(int,input().split())) for _ in range(m)]

d.sort(key=lambda x:-x[1])
total = sum(A)
heapq.heapify(A)

for i in range(m):
    for j in range(d[i][0]):
        tmp = heapq.heappushpop(A, d[i][1])
        if tmp < d[i][1]:
                total += (d[i][1] - tmp)
        else:
            break

print(total)


Measured memory_bytes: 36120
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double a = (double)n;
		String s = "No";
		for(double i=1; i<10; i++){
			double b = a/i;
			if(b < 10 && b == (int)b){
				s = "Yes";
				break;
			}
		}
		System.out.println(s);   

	}
}

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


void solve(long long K, long long A, long long B){
  bool flag = false;
  for (int i=A; i<=B; i++) if (i % K == 0) flag = true;
  string ans = (flag) ? "OK" : "NG";
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


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

using namespace std;

int main(){
	long long x,k,d;
	scanf("%lld %lld %lld",&x,&k,&d);
	x = abs(x);

	if(x/d >= k){
		x -= k*d;
		printf("%lld\n",x);
		return 0;
	}
	long long y = x/d;
	x -= y*d;
	k -= y;

	if(k%2 == 0){
		printf("%lld\n",x);
	}else{
		printf("%lld\n",min(abs(x-d),x+d));
	}
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = linf;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ll a = i;
			ll b = n / i;
			mins(ans, a + b);
		}
	}
	cout << ans - 2ll << endl;
	return 0;
}

Measured memory_bytes: 256