akhauriyash/Code-Regression huggingface dataset:
/* 
    Author : Jeff Ahn
    Sun 14 Jun 2020 02:28:16 PM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const map<T,T> &vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_map<T,T>&vec){ os<< "{"; for (auto p : vec) os << "(" << p.first << "," << p.second << "), "; os << "}"; return os; }

int a[200010];
int p[1000010];

signed main() {
  fastio;
  int n;
  cin >> n;
  set<int> st;
  rep(i, n) 
  {
    cin >> a[i];
  }
  if (st.size() == 1) { cout << 0 << endl; return 0; }
  sort(a, a+n);
  memset(p, 0, sizeof(p));
  int res = 0;
  for (int i = 0; i < n; i++)
  {
    int s = a[i];
    if (st.count(s)) {
      p[s] = 1; continue;
    }
    if (p[s] == 0)
    {
      for (int j = 2 * s; j <= a[n-1]; j += s) 
      {
        p[j] = 1;
      }
    }
    st.insert(s);
  }
  for (auto s : st) {
    if (p[s] == 0) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 22360
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 100000000


using namespace std;

string t = "AKIHABARA";

string s;
int main()
{
    //COMinit();
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    int now = 0;
    for (int i = 0; i < s.size(); ++i) {
        while (now < t.size() && s[i] != t[now]) {
            if (t[now] == 'A')
                ++now;
            else {
                cout << "NO\n";
                return 0;
            }
        }
        if (now == t.size()) {
            cout << "NO\n";
            return 0;
        }
        ++now;
    }
    while (now < t.size()) {
        if (t[now] == 'A')
            ++now;
        else {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return  0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

ll mE(ll x, ll y, ll p = mod){
    if(y==0)
        return 1;
    if(y == 1)
        return x;
    if(y&1){
        /// y is odd, so (x*(x^(y-1)))%p
        return (x*mE(x, y-1, p))%p;
    } else {
        /// y is even, so (x^(y/2))^2
        ll c = mE(x, y/2, p);
        return (c*c)%p;
    }
}

void solve(){
    ll n, k;
    cin>>n>>k;
    ll ans = 0ll;
    ll mn, mx;
    rep(i, k, n + 1){
        mn = ((i*(i - 1ll))%mod*(mE(2, mod-2ll)))%mod;
        mx = ((n*i)%mod - ((i*(i - 1ll))%mod*(mE(2, mod-2))))%mod;
        ans = (ans + (mx - mn + 1ll))%mod;
    }
    cout<<(ans + mod)%mod;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    vector<bool> flag(n, false);
    int cor = 0, pen = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (flag[p] == true) continue;
        if (s[0] == 'W') {
            ++cnt[p];
        } else {
            flag[p] = true;
            ++cor;
            pen += cnt[p];
        }
    }
    cout << cor << " " << pen << endl;
    return 0;
}



Measured memory_bytes: 640
import math
import sys
from collections import Counter
import bisect
readline = sys.stdin.readline


def main():
    cnt = 0
    n = int(readline().rstrip())
    L = sorted(list(map(int, readline().rstrip().split())))
    for a in range(0, n - 2):
        for b in range(a + 1, n - 1):
            k = L[a] + L[b]
            index = bisect.bisect_left(L, k)
            cnt += index - b - 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9612
from collections import deque
S = input()
Q = int(input())
k = 1
d = deque(S)
for _ in range(Q):
    query = input()
    if query.startswith('1'):
        k *= -1
    elif query.startswith('2'):
        t, f, c = query.split()
        if f == '1':
            if k > 0:
                d.appendleft(c)                
            else:
                d.append(c)
        elif f == '2':
            if k > 0:
                d.append(c)
            else:
                d.appendleft(c)
d = list(d)
if k > 0:
    print(''.join(d))
else:
    print(''.join(d[::-1]))


Measured memory_bytes: 72664
#include<iostream>
#include<cstdio>
#include<vector> 
using namespace std;
int a,b;
int s;
vector<int>h,v;
int w;
bool ans[4010];
void solve()
{
	if((int)h.size()<=1)
	{
		w=h[0];
		return;
	}
	v.clear();
	char op;
	for(int i=0;i+1<h.size();i+=2)
	{
		printf("? %d %d\n",h[i],h[i+1]);
		cin>>op;
		if(op=='Y')v.push_back(h[i+1]);
	}
	if((int)h.size()&1)v.push_back(h[(int)h.size()-1]);
	h=v;
	solve();
}
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=b)
	{
		printf("Impossible");
		return 0;
	}
	for(int i=0;i<a+b;i++)h.push_back(i);
	solve();
	ans[w]=true;
	char op;
	for(int i=0;i<a+b;i++)
	{
		if(i==w)continue;
		printf("? %d %d\n",w,i);
		cin>>op;
		if(op=='Y')ans[i]=true;
	}
	printf("! ");
	for(int i=0;i<a+b;i++)printf("%d",ans[i]?1:0);
	return 0;
} 

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

#define pb push_back
#define INF 1e9+9

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

	int n, x;	cin >> n;
	vector<int>T;
	for(int i=0; i<n; i++)	
		cin >> x, T.pb(x);	
	vector<int>DP(n, INF);
	DP[0] = 0;
	for(int i=0; i<n; i++)
		for(int j : {i+1, i+2})
			if(j<n)
			DP[j] = min(DP[j], DP[i]+abs(T[i]-T[j]));
	cout << DP[n-1];
	return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include<vector>

using namespace std;

int N, K;
vector<int> D;

bool CHECK(int n) {

	if (n < N) { return false; }

	while (n > 0) {
		int m = n % 10;
		for (int k = 0; k < K; k++) {
			if (D[k] == m) { return false; }
		}
		n = n / 10;
	}
	return true;
}

int main(void) {

	cin >> N>>K;

	int tmp;
	for (int i = 1; i <= K; i++) {
		cin >> tmp; D.push_back(tmp);
	}

	int ans;
	for (int i = N; i <= 99999; i++) {
		//cout << i << endl;
		if (CHECK(i)) { ans = i; break; }
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, k, x, y, sum = 0;
	scanf("%d %d %d %d", &n, &k, &x, &y);
	if(n > k)
		sum = k * x + (n - k) * y;
	else
		sum = n * x;
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 128
<?php 
	$N = fgets(STDIN);
	$A = explode(' ', trim(fgets(STDIN)));
	$ans = "APPROVED";
	for ($i = 0; $i < $N; $i++) {
		if($A[$i]%2 == 0){
        	if($A[$i]%3 != 0 && $A[$i]%5 != 0) {
            	$ans = "DENIED";
            }
        }
	}
	echo $ans;
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,k,q;
  cin>>n>>k>>q;
  std::vector<int64_t> vec(n,k);
  for (int i = 0; i < q; ++i)
  {
    int64_t tmp;
    cin>>tmp;
    tmp--;
    vec[tmp]++;
  }
  for (int i = 0; i < n; ++i)
  {
    if(vec[i]>q){
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
//const bool is_in = container.find(element) != container.end();
int main()
{
	zapp;
	ll x;
	cin>>x;
	ll a,b;
	for(a=-200;a<200;a++)
	{
		for(b=-200;b<200;b++)
		{
			if((a*a*a*a*a) - (b*b*b*b*b) == x)
			{
				cout<<a<<" "<<b<<"\n";
				exit(0);
			}
		}
	}
}



Measured memory_bytes: 3560
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, z: usize, w: usize, a: [usize; n]);
    let f = |x, y| if x > y { x - y } else { y - x };
    if n == 1 {
        println!("{}", f(a[0], w));
        return;
    }
    let c = f(a[n - 1], w);
    let d = f(a[n - 2], a[n - 1]);
    println!("{}", max(c, d));
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2192
N, A, B = gets.split(" ").map(&:to_i)
if A % 2 == B % 2
  puts (B - A) / 2 
else
  if N - A < B - 1
    puts ((2 * N- A - B + 1) / 2)
  else
    puts ((A + B - 1) / 2)
  end
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	static char str[100000];
	scanf("%[a-z .]",str);
	for(int i = 0; str[i]; i++) {
		if('a' <= str[i] && str[i] <= 'z') str[i]+='A'-'a';
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    int a,b,x;
    cin >> a >> b >> x;

    x -= a;
    if(x >= 0){
	if(b >= x)YES;
	else NO;
    }else NO;
    
    return  0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    let a=if a==1 {300000}else if a==2 {200000}else if a==3 {100000}else {0};
    let b=if b==1 {300000}else if b==2 {200000}else if b==3 {100000}else {0};
    println!("{}",if a+b==600000{1000000}else{a+b})
}

Measured memory_bytes: 2152
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for j in range(m)]
for i in range(n):
    dist = []
    x = ab[i][0]
    y = ab[i][1]
    for j in range(m):
        dist.append(abs(x - cd[j][0]) + abs(y - cd[j][1]))

    print(dist.index(min(dist))+1)

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vi a(n);
	REP(i, n) cin >> a[i];
	sort(ALL(a));
	int ma = a[n - 1];
	int index = int(lower_bound(ALL(a), ma / 2 + 1) - a.begin());
	int r = min(a[index], ma - a[index]);
	if(r <= min(a[index - 1], ma - a[index - 1])) index--;
	cout << ma << " " << a[index] << "\n";
	return 0;
}


Measured memory_bytes: 640
from math import floor, sqrt
if __name__ == "__main__":
    Q = int(input())
    acc = [0]*(10**5+1)
    primes = set([2])
    for i in range(3,10**5+1):
        fl = True
        for j in range(2, floor(sqrt(i))+1):
            if i % j == 0:
                fl = False
                break
        acc[i] = acc[i-1]
        if fl:
            primes.add(i)
            if (i+1)//2 in primes:
                acc[i] += 1
    for q in range(Q):
        l, r = map(int,input().split())
        print(acc[r]-acc[l-1])

Measured memory_bytes: 10440
while(n=gets.to_i)>0
d=[[0,0]]*n
r=0...n
p r.map{gets;w=0;(d=r.map{|j|h,w=$_[j]<?.?[0,0]:[d[j][0]+1,w+1];[h,[h,w,d[j-1][1]+1].min]}).map{|h,s|s}.max}.max
end

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(h[i] >= K){
            ans++;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
#include<cstdio>

int main(){
	int a, b;
	scanf("%d%d",&a,&b);
	if((a + b)%3 == 0){
		printf("Possible");
	}
	else if(a%3 == 0){
		printf("Possible");
	}
	else if(b%3 == 0){
		printf("Possible");
	}
	else{
		printf("Impossible");
	}
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int n = 1;
    while (true) {
        if (n >= b) {
            break;
        }
        n -= 1;
        n += a;
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll productmod(ll x, ll y){
  if(x*y >= MOD) return (x*y) % MOD;
  else return x*y;
}

ll powmod(ll a, ll t){
    ll ret = 1;
    while(t){
        if(t & 1){
            ret = productmod(ret, a);
        }
        a = productmod(a, a);
        t >>= 1;
    }
    return ret;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n,m;
    cin >> n >> m;
    cout << powmod(n, m) << endl;
}



Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#define int long long
using namespace std;
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
signed main(){
	int n, k;
	cin >> n >> k;
	if (k % 2 == 0)cout << mypow(n / k, 3) + mypow((n + k / 2) / k, 3) << endl;
	else cout << mypow(n / k, 3) << endl;
	system("PAUSE");
	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int n,k;
cin>>n>>k;
int x[n+1];
rep(i,n){
    cin>>x[i];
}
int ans=0;
rep(i,n){
    ans+=min(x[i],k-x[i])*2;
}
cout<<ans<<endl;
  return 0;
}


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

int main() {
    int N, X, Y;

    cin >> N >> X >> Y;

    int count[N - 1];

    for(int i = 0; i < N; i++) {
        count[i] = 0;
    }

    for(int i = 1; i < N; i++) {
        for(int j = i + 1; j <= N; j++) {
            int dist = j - i;
            if(i <= X && j >= Y) {
                dist = j - i - (Y - X - 1);
            } else if(i <= X && j > X && j < Y) {
                if(((X - i) + 1 + (Y - j)) < dist) {
                    dist = (X - i) + 1 + (Y - j);
                }
            } else if(i > X && i < Y && j > X && j < Y) {
                if(((i - X) + 1 + (Y - j)) < dist) {
                    dist = (i - X) + 1 + (Y - j);
                }
            } else if(i > X && i < Y && j >= Y) {
                if(((i - X) + 1 + (j - Y) < dist)) {
                    dist = (i - X) + 1 + (j - Y);
                }
            }
            count[dist - 1] += 1;
        }
    }

    for(int i = 0; i < N - 1; i++) {
        cout << count[i] << endl;
    }

    return 0;
}

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


int main() {

  int H,W,A,B;
  cin >> H >> W >> A >> B;
  
  for(int i = 1;i <= H;i++) {
    if(i <= B) {
      for(int j = 1;j <= A;j++) cout << 1;
      for(int j = 1;j <= W-A;j++) cout << 0; 
    }else {
      for(int j = 1;j <= A;j++) cout << 0;
      for(int j = 1;j <= W-A;j++) cout << 1; 
    }

    cout << endl;
  }

}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if((N == 1 && A != B) || (B < A)) {
        cout << 0 << endl;
    }else if(N == 1 || N == 2){
        cout << 1 << endl;
    }else{
        cout << (B - A) * (N - 2) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10**9 + 7
A = [int(input()) for _ in range(M)]
pat = [0] * (N+3)
pat[1] = 1
pat[2] = 2
for i in range(3, N+1):
    pat[i] = (pat[i-1] + pat[i-2]) % MOD
if M == 0:
    print(pat[N] % MOD)
else:
    steps = []
    if len(A) > 1:
        for i in range(M-1):
            d = A[i+1] - A[i]
            if d > 2:
                steps.append(d-2)
            elif d == 1:
                steps.append(0)
    if A[0] != 1:
        steps = [A[0] - 1] + steps
    if A[-1] != N-1:
        steps += [N - A[-1] - 1]
    ans = 1
    for s in steps:
        ans = (ans * pat[s]) % MOD
    print(ans)

Measured memory_bytes: 11824
N = int(input().strip())
AB = []
for i in range(N):
    AB.append(tuple(map(int, input().strip().split())))
AB.sort(key=lambda x: x[1])
t = 0
a = []
for i in AB:
    t += i[0]
    if t > i[1]:
        a.append("NO")

if "NO" in a:
    print("No")
else:
    print("Yes")

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

int n, x;


void solve(){
    int ans[2 * n];
    if (x == 1 || x == 2 * n - 1){
        cout << "No" << endl;
        return ;
    }
    cout << "Yes" << endl;
    x -= 1;
    for(int i = 0; i < 2 * n - 1; i++){
        ans[(n + i - 1) % ( 2 * n - 1)] = x + 1;
        x++;
        x = x % ( 2 * n - 1); 
    }
    for(int i = 0; i < 2 * n - 1; i++){
        cout << ans[i] << endl;
    }
    return ;
}

int main(){
    cin >> n >> x;
    solve();
    return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
using namespace std;
 
int n,m,an=1e9;
int d[1002];
int c[1002];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>d[i];
    for(int i=0;i<m;i++)cin>>c[i];
    vector<vector<int> >vec(m+2,vector<int>(n+2,1e9));
    vec[0][0]=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            vec[i+1][j]=min(vec[i+1][j],vec[i][j]);
            vec[i+1][j+1]=min(vec[i+1][j+1],vec[i][j]+c[i]*d[j]);
        }
    }
    for(int i=0;i<=m;i++)
        an=min(an,vec[i][n]);
    cout<<an<<endl;
}

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

int main() {
    int N;
    int x[3], y[3];
    
    cin >> N;
    x[0] = 0; x[1] = 0; x[2] = 0;
    string ans = "Yes";
    
    for (int i = 0; i < N; ++i){
        cin >> y[0] >> y[1] >> y[2];
        
        int time = y[0] - x[0];
        int dist = abs(y[1] - x[1]) + abs(y[2] - x[2]);
        
        if(dist > time | time % 2 != dist % 2){
            ans = "No";
            break;
        }
        
        x[0] = y[0];
        x[1] = y[1];
        x[2] = y[2];
    }
    cout << ans << endl;
    return 0;
}

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

int a[2][2019], ans;
string s;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    for (int i = 0; i < s.length(); i++){
        int n = s[i]-'0';
        a[i%2][n] += 1;
        for (int j = 0; j < 2019; j++){
            a[i%2][(j*10+n)%2019] += a[(i+1)%2][j];
            a[(i+1)%2][j] = 0;
        }
        ans += a[i%2][0];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3804
from copy import copy
n = int(input())
t = list(map(int,input().split()))
m = int(input())

p = []
x = []

while True:
  try:
    tp,tx = map(int,input().split())
    p.append(tp)
    x.append(tx)
    
  except:
    break
    
for i in range(m):
  T = copy(t)
  T[p[i]-1] = x[i]
  print(sum(T))
  

Measured memory_bytes: 3444
from collections import deque


def f(n, dm, g, ind, a, b):
    q = deque([a, b])
    d = [-1] * n
    d[a] = 0
    d[b] = 0
    while q:
        p = q.popleft()
        for node in g[p]:
            if d[node] == -1:
                d[node] = d[p] + 1
                q.append(node)
    l = [0] * (dm // 2 + 1)
    if a == b:
        l[0] = ind[a]
    for i in range(n):
        l[d[i]] = max(l[d[i]], ind[i] - 1)
    res = 1
    for x in l[:-1]:
        res *= x
    return res


n = int(input())
g = [[] for _ in range(n)]
ind = [0] * n
for i in range(n - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    ind[a - 1] += 1
    g[b - 1].append(a - 1)
    ind[b - 1] += 1
s = [0]
d = [-1] * n
d[0] = 0
while s:
    p = s.pop()
    for node in g[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            s.append(node)
m = max(d)
idx = d.index(m)
s = [idx]
d1 = [-1] * n
d1[idx] = 0
while s:
    p = s.pop()
    for node in g[p]:
        if d1[node] == -1:
            d1[node] = d1[p] + 1
            s.append(node)
diam = max(d1)
idx = d1.index(diam)
s = [idx]
d2 = [-1] * n
d2[idx] = 0
while s:
    p = s.pop()
    for node in g[p]:
        if d2[node] == -1:
            d2[node] = d2[p] + 1
            s.append(node)
if diam & 1:  # 直径が奇数
    c = []
    t = diam // 2 + 1
    print(t, end=' ')
    for i in range(n):
        if d1[i] <= t and d2[i] <= t:
            c.append(i)
    ans = f(n, diam, g, ind, c[0], c[1]) * 2
    print(ans)
else:
    t = diam // 2
    print(t + 1, end=' ')
    for i in range(n):
        if d1[i] <= t and d2[i] <= t:
            c = i
    ans = f(n, diam, g, ind, c, c)
    for node in g[c]:
        ans = min(ans, f(n, diam, g, ind, c, node) * 2)
    print(ans)


Measured memory_bytes: 40688
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();
		long x = Math.min(b-1,n);
		long ans = a*x/b;	
		System.out.println(ans);
	 }
}

Measured memory_bytes: 35712
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    while(true){
        string Ns = to_string(N);
        char i = Ns[0]; bool ok = true;
        for(auto d : Ns){
            if(d != i){
                ok = false; break;
            }
        }
        if(ok) {cout << N << endstr; return 0;};
        N++;
    }
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
com = min(X, Y)
min_cost = min(A+B, C*2)

if min_cost * max(X, Y) < min_cost * com  + A * (X - com) + B * (Y - com):
    print(min_cost * max(X, Y))
else:
    print(min_cost * com  + A * (X - com) + B * (Y - com))

Measured memory_bytes: 3064
#include <stdio.h>
 
int G[100][100],d[100],v[100];
int getMST(int);
 
int main(){
  int n,i,j;
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  printf("%d\n",getMST(n));
 
  return 0;
}
 
int getMST(int n){
  int i,j,k=1,min,minp,sum=0;
   
  d[0]=0;
  v[0]=1;
 
  for(i=1;i<n;i++) v[i]=0;
 
  while(1){
    min = 2001;
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
    if(G[d[i]][j]<min && G[d[i]][j] != -1 && v[j] != 1){
      min = G[d[i]][j];
      minp = j;
    }
      }
    }
     
    if(k==n) break;
    d[k] = minp;
    v[minp] = 1;
    sum += min;
    k++;
  }
 
  return sum;
}

Measured memory_bytes: 636
x = int(input())

if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
else:
    print(1)


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


int main() {
	
	int N;
	int cnt = 0;
	cin >> N;
	vector<int> p(N);
	for(auto &i : p) cin >> i;
	for(int i=0; i<N; i++){
		if (p.at(i) != i+1) cnt++;
	}
	
	if (cnt <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect
from itertools import accumulate
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
D = list(accumulate(N - bisect(C, b) for b in reversed(B))) + [0]
print(sum(D[N - bisect(B, a) - 1] for a in A))


Measured memory_bytes: 24052
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
 
int main(void) {
	int N, K, V;
	std::cin >> N >> K;
 
	std::unordered_map<int, int> mymap;
 
	for (int i = 0; i < N; i++) {
		std::cin >> V;
		if (mymap.find(V) == mymap.end()) {
			mymap[V] = 1;
		} else {
			int v = mymap[V];
			mymap[V] = v + 1;
		}
	}
 
	std::vector<int> count;
	for (std::unordered_map<int, int>::iterator it = mymap.begin();
			it != mymap.end(); ++it) {
		count.push_back(it->second);
	}
	std::sort(count.begin(), count.end());
	int res = 0;
  if (count.size() > K)
	for (int i = 0; i < count.size() - K; i++) {
		res += count[i];
	}
	std::cout << res;
	return 0;
}

Measured memory_bytes: 10312
#include <bits/stdc++.h>
#define REP(i,low,high) for(register int i=(low);i<=(high);++i)
#define PER(i,high,low) for(register int i=(high);i>=(low);--i)
using namespace std;

static int n; long long cell[100010];

int main()
{
	scanf("%d",&n);
	REP(i,1,n) scanf("%lld",cell+i);
	sort(cell+1,cell+n+1);
	int ans=0; long long sum=0;
	REP(i,1,n)
	{
		sum<<1<cell[i]?ans=1:++ans;
		sum+=cell[i];
	}
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 1024
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t D, T, S;
  cin >> D >> T >> S;
  if (S * T >= D) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int[] num = new int[3];
        num[0] = Integer.parseInt(str[0]);
        num[1] = Integer.parseInt(str[1]);
        num[2] = Integer.parseInt(str[2]);
        for(int i = 0; i<3; i++){
            int indexMin = i;
            for(int k = i + 1; k<3; k++){
                if(num[k] < num[indexMin]){
                    indexMin = k;
                }
            }
            int swp = num[i];
            num[i] = num[indexMin];
            num[indexMin] = swp;
        }
        System.out.println(num[0] +" "+ num[1] +" "+ num[2]);

    }
}

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

long c2(long n) {
  return n * (n - 1) / 2;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> MA;
  for (int i = 0, a; cin >> a; i++) A.at(i) = a, MA[a]++;

  long sum = 0;
  for (auto ma : MA) sum += c2(ma.second);

  for (int i = 0; i < N; i++) {
    cout << sum - c2(MA[A.at(i)]) + c2(MA[A.at(i)] - 1) << "\n";
  }
}

Measured memory_bytes: 8320
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

#print(A,B)
add = 0
for i in range(len(B)):
    if B[i] > A[i]:
        add += A[i]
        B[i] -=  A[i]
        if A[i+1] > B[i]:
            add+=B[i]
            A[i+1] -= B[i]
        else:
            add += A[i+1]
            A[i+1] = 0
    else:
        add+=B[i]
        B[i] = 0
    #print(A,B,add)
    
#add += min(A[-1],B[-1])
print(add)

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,k;
	cin >> n >> k;
	if(k==0){
		ANS((ll)n*n);
		return 0;
	}
	ll ans = 0;
	FOR(i,k+1,n+1){
		ans += (ll)(n/i) * max(0, i-k);
		ans += max(0, (n%i) - k + 1);
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
*A, = map(int, input().split())
A.sort()

# Aの累積和を求めておく
S = [0]
x = 0
for a in A:
    x += a
    S.append(x)


def lower(x):
    # A[i]<xなるiの個数
    left = -1
    right = n
    while right-left > 1:
        mid = (left+right)//2
        if A[mid] < x:
            left = mid
        else:
            right = mid
    return right


def lower_pair(x):
    # A[i]+A[j]<xなる(i,j)の個数
    cnt = 0
    for a in A:
        cnt += lower(x-a)
    return cnt


# A[i]+A[j]のm番目に大きい値を求める
# lower_pair(x)<n**2-mなる最大のxを求めればよい
left = 2*min(A)
right = 2*max(A)
while right-left > 1:
    mid = (left+right)//2
    if lower_pair(mid) < n**2-m:
        left = mid
    else:
        right = mid
x = left

# A[i]+A[j]>=xとなる(i,j)の個数とA[i]+A[j]の総和を求める
k = n**2-lower_pair(x)
s = 0
for a in A:
    cnt = lower(x-a)
    s += (n-cnt)*a+S[n]-S[cnt]

print(s-(k-m)*x)


Measured memory_bytes: 61632
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =3e5+6;
void solve(){
	string s1;
	cin>>s1;
	string s2;
	cin>>s2;
	if ( s2.sz()==s1.sz()+1&&s2.substr( 0,s1.sz())==s1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
//	#ifndef ONLINE_JUDGE
//		cin.tie(NULL);
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int V=200000;
vector<int> G[V],R[V];

int main()
{
    int N,K,L;
    scanf(" %d %d %d", &N, &K, &L);

    rep(i,K)
    {
        int p,q;
        scanf(" %d %d", &p, &q);
        --p;
        --q;
        G[p].pb(q);
        G[q].pb(p);
    }

    rep(i,L)
    {
        int r,s;
        scanf(" %d %d", &r, &s);
        --r;
        --s;

        R[r].pb(s);
        R[s].pb(r);
    }

    vector<int> vis(N,-1);
    int con=0;
    rep(i,N)
    {
        if(vis[i]>=0) continue;

        vis[i]=con;
        queue<int> que;
        que.push(i);
        while(!que.empty())
        {
            int v=que.front();
            que.pop();
            rep(j,G[v].size())
            {
                int nx=G[v][j];
                if(vis[nx]==-1)
                {
                    vis[nx]=con;
                    que.push(nx);
                }
            }
        }

        ++con;
    }

    vector<int> ans(N,1);
    vector<bool> vis2(N,false);
    rep(i,N)
    {
        if(vis2[i]) continue;

        vis2[i]=true;
        vector<int> cc;
        cc.pb(i);
        queue<int> que;
        que.push(i);
        while(!que.empty())
        {
            int v=que.front();
            que.pop();
            rep(j,R[v].size())
            {
                int nx=R[v][j];
                if(!vis2[nx])
                {
                    vis2[nx]=true;
                    que.push(nx);
                    cc.pb(nx);
                }
            }
        }

        map<int,int> ct;
        rep(j,cc.size()) ++ct[vis[cc[j]]];
        rep(j,cc.size()) ans[cc[j]] = ct[vis[cc[j]]];
    }

    rep(i,N)
    {
        if(i) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 19604
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 9; i++ {
		if div := n % i; div == 0 {
			if ans := n / i; ans <= 9 {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

template <class T>
class BinaryIndexedTree{
private:
    int n;
    vector<T> bit;

    T _sum(int i){
        T res = 0;
        while(i) {res += bit[i]; i -= i & -i;}
        return res;
    }

    void _add(int i, T x){
        while(i<=n) {bit[i] += x; i += i & -i;}
    }

public:
    T sum(int i){
        return _sum(i+1);
    }

    void add(int i, T x){
        _add(i+1, x);
    }

    BinaryIndexedTree() : n(0){}

    explicit BinaryIndexedTree(size_t _n, T _def=0) : n(_n){
        bit.resize(n+1, _def);
    }
};

class FSilverFoxVsMonster {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        lint D, A;
        in>>N>>D>>A;
        vc<pii> P(N);
        for(auto& p : P) in>>p.first>>p.second;
        sort(ALL(P));
        BinaryIndexedTree<lint> bit(N+1);
        lint ans = 0;
        REP(i, N){
            lint cnt = bit.sum(i);
            if(cnt>=(P[i].second+A-1)/A) continue;
            P[i].second -= A * cnt;
            int left = i, right = N;
            while(1<right-left){
                int mid = (left+right) >> 1;
                if(P[mid].first<=P[i].first+2*D) left = mid;
                else right = mid;
            }
            lint need = (P[i].second+A-1) / A;
            ans += need;
            bit.add(i, need);
            bit.add(right, -need);
        }
        out<<ans<<'\n';
    }
};


int main() {
	FSilverFoxVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6336
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  cout << to_string((1 <= a && a <= 9 && 1 <= b && b <= 9) ? a * b : -1) << endl;
  
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i];
    rep(i, n) p[i] = i;
    double sum = 0.0;
    int cnt = 0;
    do
    {
        rep(i, n - 1)
        {
            int xx = x[p[i]] - x[p[i + 1]];
            int yy = y[p[i]] - y[p[i + 1]];
            sum += sqrt(xx * xx + yy * yy);
        }
        cnt++;
    } while (next_permutation(p.begin(), p.end()));
    printf("%.10f\n", sum / cnt);
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define ll long long
#define mod 998244353
#define N 500010
using namespace std;
ll fac[N],inv[N];
ll ksm(ll a,ll b=mod-2)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll q=ksm(a,b>>1);
	if(b&1) return q*q%mod*a%mod;
	return q*q%mod;
}
ll C(int a,int b)
{
	if(b>a || b<0) return 0;
	if(a==b || b==0) return 1;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int mn=max(n,m);
	fac[0]=1;
	for(int i=1;i<=mn;i++) fac[i]=fac[i-1]*i%mod;
	inv[mn]=ksm(fac[mn]);
	for(int i=mn-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	mn=min(n,m);
	ll ans=0;
	for(int i=0;i<=mn;i++)
	ans=(ans+(i&1?-1:1)*C(n,i)*C(m,i)%mod*fac[i]%mod*ksm(n+1,m-i)%mod*ksm(m+1,n-i)%mod+mod)%mod;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <ctype.h>

int cmp(const void *a, const void *b) { return *(int*)a - *(int*)b; }
int max(int a, int b) { return a >= b ? a : b; }
int min(int a, int b) { return a <= b ? a : b; }
int dsum(int x) { int r=0; while(x){ r+=(x%10); x/=10; } return r;}
void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; return; }

int main(void) {
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d\n",a*b);
  return 0;
}


Measured memory_bytes: 2108
import math

def isPrime(x):
	for i in range(2,int(math.sqrt(x))+1):
		if x%i == 0:
			return 0
	return 1

n=int(input())
ans=0
for i in range(n):
	x=int(input())
	if isPrime(x):
		ans+=1
print(ans)



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

int main()
{
    int m,d;
    cin >> m >> d;
    int ans = 0;
    if(m>=4){
        for(int k=4;k<=m;k++){
            for(int i=2;i<=d/10;i++){
                if(i>k){
                    break;
                }
                else{
                    if(i==d/10){
                        if(d%10>=2){
                            for(int j=2;j<=d%10;j++){
                                if(i*j==k){
                                    ans++;
                                    break;
                                }
                            }
                        }
                    }
                    else{
                        for(int j=2;j<=9;j++){
                            if(i*j == k){
                                ans++;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5  + 10;
long long dp[MAXN][3], a[MAXN][3];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) {
					continue;
				}
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
			}
		}
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int N, M;
vector<vector<int>> G;

int dp[100001];
int rec(int v) {
  if(dp[v] > -1) return dp[v];
  int result = 0;
  for (auto nv: G[v]) {
    chmax(result, rec(nv)+1);
  }
  dp[v] = result;
  return dp[v];
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());

  for (int i=0;i<M;++i) {
    int x,y;
    cin >> x >> y;
    --x;--y;
    G[x].push_back(y);
  }

  for (int i=0;i<N;++i) dp[i] = -1;
  int result = 0;
  for (int i=0;i<N;++i) {
    chmax(result, rec(i));
  }
  cout << result << endl;

}

Measured memory_bytes: 11032