akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 3e5 + 123;
int n, m, k, R[n0], C[n0];
vector <int> r[n0];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n >> m >> k;
	for (int i = 1; i <= k; i++) {
		int x, y;
		cin >> x >> y;
		R[x]++, C[y]++;
		r[x].pb(y);
	}
	set <array <int, 2>> st;
	for (int i = 1; i <= m; i++)
		st.insert({C[i], i});
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j : r[i]) {
			st.erase({C[j], j});
			ans = max(ans, R[i] + C[j] - 1);
		}
		if (!st.empty()) {
			auto P = *(--end(st));
			ans = max(ans, R[i] + P[0]);
		}
		for (int j : r[i])
			st.insert({C[j], j});
	}
	cout << ans;
}


Measured memory_bytes: 36444
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
dif = []
pos = []
ans = 0

if n >= m:
    print(0)
elif n == 1:
    print(x[-1] - x[0])
else:
    for i in range(m - 1):
        dif.append([x[i + 1] - x[i], i])

    dif.sort(reverse = True)

    for i in range(n - 1):
        pos.append(dif[i][1])

    pos.sort()

    ans += x[pos[0]] - x[0]
    for i in range(n - 2):
        ans += x[pos[i + 1]] - x[pos[i] + 1]
    ans += x[m - 1] - x[pos[-1] + 1]

    print(ans)


Measured memory_bytes: 21272
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans="";
    for(int i=sy;i<ty;i++) ans+="U";
    for(int i=sx;i<tx;i++) ans+="R";
    for(int i=sy;i<ty;i++) ans+="D";
    for(int i=sx;i<tx;i++) ans+="L";
    ans+="L";
    for(int i=sy;i<ty;i++) ans+="U";
    ans+="U";ans+="R";
    for(int i=sx;i<tx;i++) ans+="R";
    ans+="D";ans+="R";
    for(int i=sy;i<ty;i++) ans+="D";
    ans+="D";ans+="L";
    for(int i=sx;i<tx;i++) ans+="L";
    ans+="U";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn main() {
    let st = input_one::<String>().unwrap();
    let st = st.split_ascii_whitespace().collect::<Vec<_>>();
    let (s, t) = (st[0].clone(), st[1].clone());
    let (a, b) = input_pair::<usize>();
    let u = input_one::<String>().unwrap();
    if u == s {
        println!("{} {}", a - 1, b);
    } else {
        println!("{} {}", a, b - 1);
    }
}


Measured memory_bytes: 2160
def f(n,k):
  if k<1: return 1
  if n<10:
    if k<2: return n
    return 0
  d,m=n//10,n%10
  return f(d,k-1)*m+f(d-1,k-1)*(9-m)+f(d,k)
print(f(int(input()),int(input())))

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

int minCost(vector < int > &nums, int k) {
  int n = nums.size();
  vector < int > dp(n, -1);
  dp[0] = 0;
  int minCost = INT_MAX;
  for (int i = 1; i < n; i++) {
    minCost = INT_MAX;
    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) {
        minCost = min(dp[i - j] + abs(nums[i] - nums[i - j]), minCost);
      }
    }
    dp[i] = minCost;
  }

  return dp[n - 1];
}

int main() {
  int n;
  cin>>n;
  int k;
  cin>>k;
  vector < int > nums(n, 0);
  for (int i = 0; i < n; i++) {
    cin>>nums[i];
  }

  cout<<minCost(nums, k)<<endl;

  return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll dp[60][60][3000];
//配るDP
int main(){
    cout << fixed << setprecision(10);
    ll n;
    ll a;
    cin >> n >> a;
    vector<ll> v(n);
    dp[0][0][0] = 1;
    rep(i,n) cin >> v[i];
    rep(i,n){
        rep(k,n*a+1){
            rep(j,60){
                if(dp[i][j][k] == 0) continue;
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k + v[i]] = dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    /*rep(j,10){
        rep(k,35) cout << dp[n-1][j][k] << " ";
        cout << endl;
    }*/
    for(int j=1;j < 51; j ++){
        ans += dp[n][j][j*a];
    }

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

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

int main() {
  int N, x;
  cin >> N;
  int sum = 0;
  
  for(int i = 0;i < N; i++){
    int l, r;
    cin >> l >> r;
    x = (r - l) +1;
    sum += x;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  ll n, m; cin >> n >> m;
  Vll a(n);
  rep(i, n) cin >> a[i];

  UnionFind uf(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }

  map<int, Vll> cost;
  rep(i, n) {
    cost[uf.find(i)].push_back(a[i]);
  }

  int k = cost.size();
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }

  Vll z;
  ll ans = 0;
  for (auto e : cost) {
    sort(all(e.second));
    reverse(all(e.second));
    ans += e.second.back();
    e.second.pop_back();
    z.insert(z.end(), all(e.second));
  }

  if (z.size() < k-2) {
    cout << "Impossible" << endl;
    return 0;
  }

  sort(all(z));
  rep(i, k-2) ans += z[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12416
package main

import (
  "fmt"
)

func main() {
  var a int
  var b int
  var c int
  
  fmt.Scan(&a, &b, &c)
  
  if c >= a-b {
	fmt.Println(c - (a-b))
  } else {
      fmt.Println(0)
  }
}

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

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    for(auto& ss : s) cin >> ss;

    vector<vector<int>> sum(h, vector<int>(w + 1));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            sum[i][j + 1] += sum[i][j] + (s[i][j] == '#');
        }
    }

    vector<vector<int>> ans(h, vector<int>(w, -1));
    auto checkw = [&] (int y, int l, int r) {
        bool check = true;
        for(int i = l; i < r; ++i) {
            check &= ans[y][i] == -1;
        }
        return check;
    };
    for(int i = 0, col = 1; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s[i][j] != '#') continue;
            int l = j;
            while(l > 0 && sum[i][j + 1] - sum[i][l - 1] <= 1 && ans[i][l - 1] == -1) {
                l--;
            }
            int r = j;
            while(r < w && sum[i][r + 1] - sum[i][j] <= 1 && ans[i][r] == -1) {
                r++;
            }
            int t = i;
            while(t > 0 && sum[t - 1][r] - sum[t - 1][l] == 0 && checkw(t - 1, l, r)) {
                t--;
            }
            int b = i;
            while(b + 1 < h && sum[b + 1][r] - sum[b + 1][l] == 0 && checkw(b + 1, l, r)) {
                b += 1;
            }
            for(int y = t; y <= b; ++y) {
                for(int x = l; x < r; ++x) {
                    ans[y][x] = col;
                }
            }
            col += 1;
        }
    }

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cout << ans[i][j] << " \n"[j + 1 == w];
        }
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3560
a, b = map(int, input().split())
o1 = o2 = o3 = -1
for i in range(a+1):
    for j in range(a-i+1):
        k = a-i-j
        if b == i*10000+j*5000+k*1000:
            o1 = i
            o2 = j
            o3 = k
            break
print(o1, o2, o3)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define N 100010
#define p_b push_back

using namespace std;

bool ans;
int n;
vector<int> e[N];
int f[N],sz[N];

void dfs(int u,int fa){
	int i,v;
	f[u]=1;
	for(i=0;i<e[u].size();i++)
	if(e[u][i]!=fa){
		dfs(e[u][i],u);
		if(f[e[u][i]]){f[u]=0; sz[u]++;}
	}
}

void dfs2(int u,int fa,int t){
	int i;
	sz[u]+=t; if(sz[u]) f[u]=0; else f[u]=1;
	if(!sz[u] || sz[u]>=2) ans=1;
	
	for(i=0;i<e[u].size();i++)
	if(e[u][i]!=fa){
		if(sz[u]-f[e[u][i]]<=0) dfs2(e[u][i],u,1); else dfs2(e[u][i],u,0);
	}
}

int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		e[x].p_b(y); e[y].p_b(x);
	}
	dfs(1,0);
	dfs2(1,0,0);
	if(ans) puts("First"); else puts("Second");
	return 0;
}

Measured memory_bytes: 6656
l,c = gets.chomp.split.map(&:to_i)
ary_c = Array.new
sum_y_col = Array.new(c,0)
l.times{|li|
  ary_li = gets.chomp.split.map(&:to_i)
  c.times{|ci|
    sum_y_col[ci] += ary_li[ci]
  }
  ary_li << ary_li.inject(:+)
  ary_c << ary_li

 }
sum_y_col << sum_y_col.inject(:+)
ary_c << sum_y_col

ary_c.each_with_index{ |y,yi|
    y.each_with_index{|x,xi|
      print x
      print " " if xi != c
    }
    puts
}



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

using namespace std;

int main()
{int up,north,west,east,south,down,temp;
 cin>> up>>south>>east>>west>>north>>down;
  //for(int i=1;i<=n;i++)
  //{ 
  	string b;
  	cin>>b;
  	for(int i=0;i<b.size();i++)
  	{ 
	  
  	if(b[i]==78)
	  {
		temp=up;
		up=south;
		south=down; 
		down=north;
		north=temp;
	
	  }
    if(b[i]==87)
		{
		temp=up;
		up=east;
		east=down;
		down=west;
		west=temp;	
		}
    if(b[i]==83)
	 	{
		temp=up;
		up=north;
		north=down;
		down=south;
		south=temp;

		}
    if(b[i]==69)
		{
		temp=up;	
		up=west;
		west=down;
		down=east;
		east=temp;
		}
	}
  	
  //}
  cout<<up<<endl;
//}	
	
		return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long int
#define inf 1000000000000
#define MOD 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define tc(t) int t; cin >> t; while (t--)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;
int main()
{
	IOS
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	string s, t;
	cin >> s;
	cin >> t;
	int m = s.length();
	int n = t.length();
	int dp[m + 1][n + 1];
	for (int i = 0; i <= m; i++)
	{
		dp[i][0] = 0;
	}
	for (int i = 0; i <= n; i++)
		dp[0][i] = 0;
	vector<char> vec;
	int i, j;
	for (i = 1; i <= m; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (s[i - 1] == t[j - 1])
			{
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	i = m, j = n;
	while (i > 0 && j > 0)
	{
		if (s[i - 1] == t[j - 1])
		{
			char ch = s[i - 1];
			vec.pb(ch);
			i--, j--;
		}
		else if (dp[i - 1][j] > dp[i][j - 1])
			i--;
		else
			j--;
	}
	//cout << dp[m][n] << endl;
	for (i = vec.size() - 1; i >= 0; i--)
	{
		cout << vec[i];
	}

}

Measured memory_bytes: 35456
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n,t;
    cin >> n >> t;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    map<int,int>mp;
    int ma = -1;
    int mi = INT_MAX;
    for(int i = n-1; i >= 0; i--){
        ma = max(ma, a[i]);
        mi = max(mi, a[i]);
        mp[ma-a[i]]++;
    }
    int ans = 0;
    for(auto x:mp)ans = x.second;
    cout << ans << endl;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line
int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	map<ll,ll> mp;
	ll ans = 0;
	rep(i,n){
		ans += mp[i - a[i]] ;
		mp[a[i]+i] ++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 27344
# import sys
# sys.setrecursionlimit(99999)

def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def num_reachable(n):
    return n * (n - 1) // 2


n, m = map(int, input().split())
edges = []

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

size = [1 for _ in range(n + 1)]
group = [i for i in range(n + 1)]


def find_group(x):
    c = []
    p = x
    while True:
        pp = group[p]
        if pp == p:
            break
        else:
            c.append(p)
            p = pp
    for i in c:
        group[i] = pp
    return pp

ans = []
not_reachable = n * (n - 1) // 2
reachable_node = []
ans.append(not_reachable)

count = not_reachable
reachable = 0
for _ in range(m - 1):
    a, b = edges.pop()
    if count > 0:
        ra = find_group(a)
        rb = find_group(b)
        if rb != ra:
            s_ra = size[ra]
            s_rb = size[rb]
            new_size = s_ra + s_rb
            reachable += num_reachable(new_size) - num_reachable(s_ra) - num_reachable(s_rb)
            size[ra] = new_size
            group[rb] = ra
        count = not_reachable - reachable
    ans.append(count)

for _ in range(len(ans)):
    print(ans.pop())




Measured memory_bytes: 68824
#include<iostream>
using namespace std;
int main(){
    int matrix[100][100] = {{}};
    int vector[100]={};
    int n, m, i, j, total;
    cin >> n >> m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> matrix[i][j];
        }
    }
    for(i=0;i<m;i++) cin >> vector[i];
    for(i=0;i<n;i++){
        total = 0;
        for(j=0;j<m;j++) total += matrix[i][j]*vector[j];
        cout << total << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto& i : v)
    {
        cin >> i;
    }
    int count = 0;

    while (true)
    {
        if (all_of(v.begin(),v.end(), [](int x) { return x % 2 == 0; }))
        {
            count++;
            for (auto& i : v)
            {
                i = i / 2;
            }
        }
        else
        {
            break;
        }

    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
               5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
const LL UnUseMethod=10e10;
LL count[2]={0};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
LL GCD(LL a,LL b){return !b?a:GCD(b,a%b);}
LL Mult(LL x,LL y,LL mod)
{LL temp=x*y-(LL)((long double)x/mod*y+1e-8)*mod;return temp<0?temp+mod:temp;}
LL BinaryModularPower(LL base,LL pow,LL mod)
{
  LL x=1;
  while(pow){if(pow&1){x=Mult(x,base,mod);}base=Mult(base,base,mod);pow>>=1;}
  return x;
}
LL f(LL x,LL mod,LL c){return (Mult(x,x,mod)+c)%x+1;}
void Exp(LL x,LL y){count[1]=0;while(!(x%y)){count[1]++;x/=y;}count[0]=x;return;}
int MillerRabin(const LL a)
{
  if(a==2)return 1;
  if(a%2==0||a==1)return 0;
  static int pr[7]={2,325,9375,28178,450775,9780504,1795265022};
  LL u=a-1,t=0,p=1;
  while(!(u&1)){u>>=1;t++;}
  for(int i=0;i<7;++i)
  {
    p=pr[i]%a;
    if(!p)return 1;
    LL x=BinaryModularPower(p,u,a);
    if(x==1)continue;
    for(int j=0;x!=a-1&&j<t;++j)
    {
      x=Mult(x,x,a);
      if(x==1)return 0;
    }
    if(x==a-1)continue;
    return 0;
  }
  return 1;
}
LL PollardRho(LL n,LL a)
{
  srand((unsigned int)time(NULL));
  LL x=rand()%n,y=x,gcd=1,k=0,i=1;
  while(gcd==1)
  {
    k++;
    x=Mult(x,x,n)+a;if(x>=n)x-=n;
    gcd=GCD(x>y?x-y:y-x,n);
    if(k==i){y=x;i<<=1;}
  }
  if(gcd==n)return PollardRho(n,a+1);
  return gcd;
}
int main(void)
{
  LL a=0,p=1,q=-1,N=IN();
  if(N<=1)return puts("0"),0;
  Exp(N,2);a=e[count[1]];N=count[0];
  Exp(N,3);a+=e[count[1]];N=count[0];
  while(q*q<=UnUseMethod)
  {
    p+=6,q+=6;
    Exp(N,p);a+=e[count[1]];N=count[0];
    Exp(N,q);a+=e[count[1]];N=count[0];
  }
  if(N<=UnUseMethod){if(N>1){a++;}return printf("%lld\n",a),0;}
  if(MillerRabin(N)){a++;return printf("%lld\n",a),0;}
  while(N>=UnUseMethod)
  {
    p=PollardRho(N,0);
    while(!MillerRabin(p))p=PollardRho(p,p);
    Exp(N,p);a+=e[count[1]];N=count[0];
  }
  if(MillerRabin(N)){a++;}return printf("%lld\n",a),0;
}

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

int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  // 数字0～9がSにおいて現れる位置を記録
  vector<vector<int>> A(10);
  for (int i = 0; i < N; i++)
  {
    A.at(int(S.at(i) - '0')).push_back(i);
  }
  int cnt = 0;
  // 3桁のパスワード、全1000通りについて、それがSから得られるかを調べる
  // O(N)のアルゴリズム
  for (int i = 0; i < 10; i++)
  {
    for (int j = 0; j < 10; j++)
    {
      for (int k = 0; k < 10; k++)
      {
        if (A.at(i).size() == 0)
        {
          continue;
        }
        int first = A.at(i).at(0);
        int second = -1;
        for (int l = 0; l < A.at(j).size(); l++)
        {
          if (A.at(j).at(l) > first)
          {
            second = A.at(j).at(l);
            break;
          }
        }
        if (second == -1)
        {
          continue;
        }
        int third = -1;
        for (int l = 0; l < A.at(k).size(); l++)
        {
          if (A.at(k).at(l) > second)
          {
            third = A.at(k).at(l);
            break;
          }
        }
        if (third == -1)
        {
          continue;
        }
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 200000
int prime[N+5],tot;
bool vis[N+5];
void shai()
{
	vis[1]=1;
	int i,j;
	for(i=2;i<=N;i++){
		if(!vis[i])
			prime[++tot]=i;
		for(j=1;j<=tot;j++){
			long long tmp=1ll*i*prime[j];
			if(tmp>N) break;
			vis[tmp]=1;
			if(i%prime[j]==0)break;
		}
	}
}
int main()
{
	shai();
	int n;
	scanf("%d",&n);
	for(;n<=N;n++)
		if(!vis[n]){printf("%d",n);return 0;}
}

Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


int a[3];

int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = 0;
	ans += a[2] - a[1];
	a[0] += ans;
	a[1] += ans;
	if ((a[2] - a[0]) % 2 == 0) {
		cout << ans + (a[2] - a[0]) / 2 << endl;
	}
	else {
		cout << ans + (a[2] - a[0]) / 2+2 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 201001;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

}


Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<string> map(H);
  for ( int i = 0; i < map.size() ; i++){
    cin >> map.at(i);
  }
  vector<int> row = { -1 , 0 , 1};
  vector<int> column = { -1 , 0 , 1};
  for ( int i = 0 ; i < map.size(); i++){
    for ( int j = 0 ; j < map.at(0).size(); j++){
      if ( map.at(i).at(j) == '.'){
        int count = 0;
      	for ( int x : row ){
       	 for ( int y : column){
          	if (0 <= (i + x) && (i + x) < H && 
                0 <= (j + y) && (j + y ) < W &&
                map.at(i + x).at(j + y) == '#' ) count++;
       	 }
      	}
        string s = to_string(count);
        map.at(i).at(j) = s.at(0);
      }
    }
  }
  
  for ( string x : map ){
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<stack>
#include<cmath>
#include<set>
//#define ll long long
using namespace std;
const int maxn=100010;
const int INF=1000000000;
set<int> st;

int main()
{
    int n,i,j,k,a,b;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        if(st.count(a)==0)
            st.insert(a);
        else
            st.erase(a);
    }
    cout<<st.size();
    return 0;
}


Measured memory_bytes: 4864
"""
ABC 086
"""
import math
a,b = map(str,input().split())
c = a+b
d = int(c)
n = math.ceil(math.sqrt(d))
flag = False
for i in range(1,n+1):
    if d == i * i:
        flag = True
        break

if(flag):
    print('Yes')
else:
    print("No")


Measured memory_bytes: 9136
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxN = 300000;
const int INF = maxN*2; // tmp num
int main(){
  int N;
  string S;
  cin >> N >> S;
  int Ecnt[maxN+1];
  int Wcnt[maxN+1];
  Wcnt[0] = 0;
  for(int i=0;i<N;i++)
    Wcnt[i+1]=Wcnt[i]+(S[i]=='W'?1:0);
  Ecnt[N] = 0;
  for(int i=N-1;i>=0;i--)
    Ecnt[i]=Ecnt[i+1]+(S[i]=='E'?1:0);
  int ans = INF;
  for(int i=0;i<N;i++){ // leader
    cerr<< i << ": "<< Wcnt[i] << ", " << Ecnt[i+1]<<endl;
    ans = min(ans, Wcnt[i]+Ecnt[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3076
#!/usr/bin/env python
# coding: utf-8

import queue

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, h = rli()
    la = []
    lb = []
    for _ in range(n):
        a, b = rli()
        la.append(a)
        lb.append(b)
    a = max(la)
    lb = sorted([b for b in lb if b > a], reverse=True)
    ans = 0
    for b in lb:
        h -= b
        ans += 1
        if h <= 0:
            break
    if h > 0:
        ans += (h+a-1) // a
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 13736
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	switch s {
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	case "SUN":
		fmt.Println(7)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    string S;
    cin >> S;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int l, r, d;
  cin >> l >> r >>d;
  int cnt = 0;
  for(int i=1; i*d<=r; i++){
    if(i*d>=l) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3624
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    def popcount(x):
        '''xの立っているビット数をカウントする関数
        (xは64bit整数)'''

        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
        x = x + (x >> 8) # 16bitごと
        x = x + (x >> 16) # 32bitごと
        x = x + (x >> 32) # 64bitごと = 全部の合計
        return x & 0x0000007f
    
    N=I()
    Xst=input()
    
    #メモ化
    dp=[0]*(N+5)
    for i in range(1,N+5):
        X=i
        X=X%popcount(X)
        dp[i]=dp[X]+1 
       
    a=Xst.count("1")
    #a+1,a-1でしか割らない
    if a==0:
        for i in range(N):
            print(1)
        exit()
    elif a==1:
        for i in range(N):
            if Xst[i]=="1":
                print(0)
            else:
                if i!=(N-1):
                    print(1)
                else:
                    if Xst[-1]=="0":
                        print(2)
        exit()
    
    remp=[0]*(N+1)
    remm=[0]*(N+1)
    
    remp[0]=1%(a+1)
    remm[0]=1%(a-1)
    
    for i in range(1,N+1):#
        remp[i]=(2*remp[i-1])%(a+1)
        remm[i]=(2*remm[i-1])%(a-1)
    
    Xremp=0
    Xremm=0
    for i in range(N):
        if Xst[i]=="1":
            Xremp+=remp[N-i-1]
            Xremm+=remm[N-i-1]
    Xremp%=(a+1)
    Xremm%=(a-1)
    
    #print(Xremp,Xremm)
    
    for i in range(N):
        if Xst[i]=="0":
            Xrem2=(Xremp+remp[N-i-1])%(a+1)
        else:
            Xrem2=(Xremm-remm[N-i-1])%(a-1)
        
        print(dp[Xrem2]+1)
    
    
    
        

main()


Measured memory_bytes: 79200
def times(hs):
    if len(hs) == 0:
        return 0
    if len(hs) == 1:
        return hs[0]

    minh = min(hs)
    mini = hs.index(minh)

    hs = [h - minh for h in hs]

    return minh + times(hs[:mini]) + times(hs[mini+1:])

_ = input()
hs = list(map(int, input().split()))

print(times(hs))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int n;
    int a[114514];
    int ans = 0;
    int m = 1000000000;
    int c = 0;
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        m = min(abs(a[i]), m);
        ans += abs(a[i]);
        if (a[i] < 0) {
            c++;
        }
    }
    if (c % 2 == 0) {
        cout << ans;
    } else {
        cout << ans - m - m;
    }
    cout << endl;
    return 0;
    
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }

  return x;
}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
  }
  
  if(k<u->key){
    return treeSearch(u->left,k);
  }else{
    return treeSearch(u->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right!=NIL){
    return treeMinimum(x->right);
  }

  y=x->parent;

  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }

  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL){
    y=z;
  }else{
    y=treeSuccessor(z);
  }

  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }

  if(x!=NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    root=x;
  }else if(y==y->parent->left){
    y->parent->left=x;
  }else{
    y->parent->right=x;
  }

  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;

  if(y==NIL){
    root=z;
  }else if(z->key<y->key){
    y->left=z;
  }else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);

  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
from heapq import heappop, heappush
def resolve():
    n = int(input())
    S = [None] * n
    C = [None] * n
    for i in range(n):
        S[i], C[i] = input().split()
        C[i] = int(C[i])
    for i in range(n):
        S.append(S[i][::-1])
        C.append(C[i])

    # id[i][j] : index of S[i][j:]
    id = [[] for _ in range(2 * n)]
    N = 1
    for i in range(2 * n):
        for j in range(len(S[i])):
            id[i].append(N)
            N += 1

    # make graph
    E = [[] for _ in range(N)]
    for i, ni in product(range(2 * n), repeat = 2):
        if i // n == ni // n:
            continue
        for j in range(len(S[i])):
            now = S[i][j:]
            edge = S[ni]
            if not (now.startswith(edge) or edge.startswith(now)):
                continue
            if len(now) > len(edge):
                E[id[i][j]].append((id[i][j + len(edge)], C[ni]))
            elif len(now) < len(edge):
                E[id[i][j]].append((id[ni][len(now)], C[ni]))
            else:
                E[id[i][j]].append((0, C[ni]))

    # Dijkstra
    dist = [INF] * N
    queue = []
    for i, c in enumerate(C):
        dist[id[i][0]] = c
        heappush(queue, (c, id[i][0]))
    while queue:
        d, v = heappop(queue)
        if d != dist[v]:
            continue
        for nv, w in E[v]:
            if dist[nv] > d + w:
                dist[nv] = d + w
                heappush(queue, (d + w, nv))

    ans = dist[0]
    for i in range(2 * n):
        for j in range(len(S[i])):
            T = S[i][j:]
            if T == T[::-1]:
                ans = min(ans, dist[id[i][j]])
    if ans == INF:
        ans = -1
    print(ans)
resolve()

Measured memory_bytes: 75184
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

const long long INF = numeric_limits<long long>::max();

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    long long ans = INF;
    for (int i = k - 1; i < n; i++) {
        if (x[i] <= 0) {
            ans = min(ans, abs(x[i - k + 1]));
        } else if (0 <= x[i - k + 1]) {
            ans = min(ans, abs(x[i]));
        } else if (abs(x[i - k + 1]) <= abs(x[i])) {
            ans = min(ans, 2 * abs(x[i - k + 1]) + abs(x[i]));
        } else {
            ans = min(ans, 2 * abs(x[i]) + abs(x[i - k + 1]));
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b) for(int i=(a);i>=(b);i--)
#define FORZ(i,a) for(int i=0;i<(a);i++)
#define FORZi(i,a) for(int i=(a)-1;i>=0;i--)
#define trav(a,x) for (auto& a: x)
#define what_is(x) cout << #x << " is " << x << "\n";

#define printl(a) cout << a << "\n";
#define prints(a) cout << a << " ";
#define printall(x) FORZ(i,sz(x))prints(x[i])
#define nextl cout << "\n"

#define in(a) cin >> a;

inline void io_setup(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

int main(){
  io_setup();
  string s;
  cin >> s;
  if(s=="ABC")cout << "ARC" << "\n";
  else cout << "ABC" << "\n";
}

/*
  `-.    .-'
     :  :
  --:--:--
   :  :
.-'    `-.  ~LaKsHiTh_
*/


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<int> A(X), B(Y), C(Z);
    vector<int> AB, ans;
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<>());
    for (int i = 0; i < min(3000LL, X * Y); i++) {
        for (int j = 0; j < Z; j++) {
            ans.push_back(AB[i] + C[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<>());
    for (int i = 0; i < K; i++) {
        cout << ans[i] << endl;
    }
}


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


int main() {
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  while(1) {
    c -= b;
    if(c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3632
// In the name of god

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 1e6 + 10;
const int MAXLG = 18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;
string t;
string s;

int main()
{
    fast_io;
    cin >> t;
    for(int i = 0;i < t.size();i++){
        if(t[i] == '?')
            s+="D";
        else
            s+=t[i];
    }
    cout << s << endl;
}



Measured memory_bytes: 3868
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int k, i = 0;
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();
        String a;
        a = sc.next();
        if( k < a.length())
        {
            while ( k > 0)
            {
                System.out.print(a.charAt(i));
                i++;
                --k;
            }
            System.out.print("...");
        }
        else
        {
            System.out.print(a);
        }
    }
}


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


int main(){
    string s;
    cin >> s;
    ll n=s.size();
    if(s[n-1]=='s') s+="es";
    else s+="s";
    cout << s << endl;
    return 0;
}  


Measured memory_bytes: 3616
import numpy as np


def factorize(N):
    up = int(np.sqrt(N))+2
    out = {}

    for i in range(2,up):
        if N%i == 0:
            temp = N
            count = 0
            while(True):
                N = N//i
                count += 1
                if N%i != 0:
                    break
            out[i] = count
        else:
            continue
    if N != 1:
        out[N] = 1
    return out

n = int(input())
f = factorize(n)
# print(f)

ans = 0
base = 1
for key in f.keys():
    while f[key] >= base:
        ans += 1
        f[key]-= base
        base += 1
    base = 1
print(ans)

Measured memory_bytes: 27136
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    x: i32,
    y: i32,
  }
  let mut ans = "No";
  for i in 0..=x {
    if i*2 + (x-i)*4 == y {
      ans = "Yes";
    }
  }
  
  println!("{}",ans);
}


Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }
    long N;

    private void solve() {
        try {
            this.N = sc.nextInt();
            System.out.println(dfs("0"));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private long dfs (String s) {
        if (Long.parseLong(s) > N) return 0;
        long ret;
        if (s.contains("7") && s.contains("5") && s.contains("3")) {
            ret = 1;
        } else {
            ret = 0;
        }
        List<String> list = new ArrayList<>();
        list.add("7");list.add("5");list.add("3");
        for (String ss: list) {
            if (s.equals("0")) {
                ret += dfs(ss);
            } else {
                ret += dfs(s + ss);
            }
        }
        return ret;
    }


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

    private int gcd(int[] param) {
        final int len = param.length;
        int g = gcd(param[0], param[1]);
        for (int i = 1; i < len - 1; i++) {
            g = gcd(g, param[i+1]);
        }
        return g;
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 38908
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int k=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==k)
		{
			k++;
		}
	}
	if(k!=1)
	cout<<n-k+1;
	else
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

int const N = 4e3 + 41;
int const MOD = 1e9 + 7;

int n, k, dp[N][N], pref[N][N];

void add(int &a, int b){
	a += b;
	if(a >= MOD){
		a -= MOD;
	}
}

int bp(int x, int d){
	if(!d){
		return 1;
	}
	if(d&1){
		return x * 1LL * bp(x, d-1) % MOD;
	}
	int r = bp(x, d/2);
	return r * 1LL * r % MOD;
}

void recalcPref(int id){
	for(int i=0;i<=n;++i){
		pref[id][i] = dp[id][i];
		if(i > 0){
			add(pref[id][i], pref[id][i-1]);
		}
	}
}

int getPref(int l, int r, int id){
	if(l > r){
		return 0;
	}
	int ret = pref[id][r];
	if(l > 0){
		ret -= pref[id][l-1];
		if(ret < 0){
			ret += MOD;
		}
	}
	return ret;
}

void solve(){
	dp[1][k-1] = (n - k - 1 >= 0 ? bp(2, n - k - 1) : 1);
	for(int i=2;i<=n;++i){
		recalcPref(i-1);
		for(int j=0;j<=n;++j){
			add(dp[i][j], getPref(j, n-i+1, i-1));
		}
	}

	printf("%d\n",dp[n][0]);
}

void read(){
	scanf("%d %d",&n,&k);
}



void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();


	return 0;
}

Measured memory_bytes: 47488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll k; cin >> n >> k;
  vector<ll> A(n), sum(n+1);
  rep(i, n) {
    cin >> A[i];
    sum[i+1] = sum[i] + A[i];
  }
  vector<pair<ll, int>> v;
  rep(i, n+1) {
    v.push_back({sum[i]-k*i, i});
  }
  sort(all(v));
  BinaryIndexedTree<int> bit(n+1);
  ll ans = 0;
  rep(i, n+1) {
    ans += bit.sum(v[i].second);
    bit.add(v[i].second, 1);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 10548
#include <stdio.h>

int main(void)
{
	float weight;
	
	while (scanf("%f", &weight) != EOF){
		if (weight <= 48.0){
			puts("light fly");
		}
		else if (weight <= 51.0){
			puts("fly");
		}
		else if (weight <= 54.0){
			puts("bantam");
		}
		else if (weight <= 57.0){
			puts("feather");
		}
		else if (weight <= 60.0){
			puts("light");
		}
		else if (weight <= 64.0){
			puts("light welter");
		}
		else if (weight <= 69.0){
			puts("welter");
		}
		else if (weight <= 75.0){
			puts("light middle");
		}
		else if (weight <= 81.0){
			puts("middle");
		}
		else if (weight <= 91.0){
			puts("light heavy");
		}
		else {
			puts("heavy");
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(void){
    int a,b = 0;
    cin >> a >> b;
    int mm = a+b;
    if(mm < a-b){
        mm = a-b;
    }
    if(mm < a*b){
        mm = a*b;
    }
    cout << mm;
}

Measured memory_bytes: 256