akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void KCity() {
	int n,m;
	cin >> n >> m;
	cout << ((n - 1) * (m - 1)) << endl;


}
int main() {

	KCity();
	return 0;
}


Measured memory_bytes: 256
import math

def getPrimes(X):
    primes = []
    limit = math.sqrt(X)
    data = [i + 1 for i in range(1, X)]
    while True:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [d for d in data if d % p != 0]

def getNextPrime(primes, X):
    while True:
        if primes[-1] == X:
            return X
        if any([X % p == 0 for p in primes]):
            X += 1
        else:
            return X
        
X = int(input())
primes = getPrimes(X)
print(getNextPrime(primes, X))

Measured memory_bytes: 7448
from collections import deque
h , w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
p = 1
d = deque()
for i in range(n):
    for j in range(a[i]):
        if len(d) == w:
            print(*d)
            d = deque()
            p *= -1
        if p == 1:
            d.append(i+1)
        elif p == -1:
            d.appendleft(i+1)
if len(d) != 0:
    print(*d)

Measured memory_bytes: 4080
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdint.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int ,int> pp;
typedef long long ll;
const ll MOD = 1000000007;
int ans[400][400];

int main(){
    int h, w, k;
    cin>>h>>w>>k;
    vector<string> v;

    string s;
    for(int i = 0; i < h; i++){
        cin>>s;
        v.push_back(s);
    }
    int now = 0;
    int q = 0;
    for(int i = 0; i < h; i++){
        int p = 0;
        now++;
        ans[i][0] = now;
        if(v[i][0] == '#') p++;
        q = p;
        for(int j = 1; j < w; j++){
            if(v[i][j] == '.' || p == 0){
                ans[i][j] = ans[i][j -1];
                if(v[i][j] == '#'){
                    p++;
                    q++;
                }
            }else{
                ans[i][j] = ans[i][j -1] + 1;
                now++;
                p++;
                q++;
            }
        }
        if(q == 0 && i > 0){
            for(int j = 0; j < w; j++){
                ans[i][j] = ans[i-1][j];
            }
            now--;
        }
        if(q == 0 && i == 0){
            now--;
        }
    }
    int ii;
    int br = 0;
    for(ii = 0; ii < h; ii++){
        for(int j = 0; j < w; j++){
            if(v[ii][j] =='#'){
                br = 1;
                break;
            }
        }
        if(br == 1) break;
    }
    for(int i = ii; i > 0; i--){
        for(int j = 0; j < w; j++){
            ans[i-1][j] = ans[ii][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i, n) cin>>v[i];
    int ans=0;
    rep(i, n){
        if(v[i]==i+1) {
            ans++;
            int tmp=v[i];
            v[i]=v[i+1];
            v[i+1]=tmp;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    cout << n/3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : R - Walk
*/
 
int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  const int MOD = 1e9 + 7;

  int n; ll k; cin >> n >> k;
  vvi g(n, vi(n));
  for(auto &v : g)
    for(auto &i : v)
      cin >> i;

  function<vvi(vvi, vvi)> mul = [&](const vvi &a, const vvi &b){
    vvi c(a.size(), vi(b[0].size()));
    for(int i = 0; i < a.size(); i++)
      for(int j = 0; j < a[0].size(); j++)
        for(int k = 0; k < b[0].size(); k++)
          c[i][k] = (c[i][k] + a[i][j] * (ll)b[j][k]) % MOD;
    return c;
  };

  function<vvi(vvi, ll)> exp = [&](const vvi &g, ll k){
    if(k == 1) return g;
    vvi half = exp(g, k/2);
    vvi ans = mul(half, half);
    if(k % 2) ans = mul(ans, g);
    return ans;
  };

  vvi paths = exp(g, k);
  // cout << slow() << '\n' << slow2() << '\n';
  cout << accumulate(paths.begin(), paths.end(), 0, [](int sum, auto &v) { return accumulate(v.begin(), v.end(), sum, [](int x, int y) { return (x + y) % MOD;});});

  return cout << endl, 0;
}

Measured memory_bytes: 1024
#include<set>  
#include<map>  
#include<cmath>  
#include<cstdio>  
#include<queue>
#include<vector>  
#include<cstring>  
#include<climits>  
#include<iostream>  
#include<algorithm>  
using namespace std; 
#define eps 1
#define MAXN 100000
int read(){  
	int f=1,x=0;  
    char c=getchar();  
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}  
    while('0'<=c&&c<='9') x=x*10+c-'0',c=getchar();  
    return f*x;  
}
bool top[30];
int main(){
	top[getchar()-'a']=1;
    top[getchar()-'a']=1;
	top[getchar()-'a']=1;
	getchar();
	if(top['a'-'a']&&top['b'-'a']&&top['c'-'a'])printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin >> n >> m;
    vvl a(n,vl(n,0));
    rep(i,m){
        int x,y; cin >> x >> y;
        x--;y--;
        a[x][y]=1;
        a[y][x]=1;
    }
    vector<int> b(n);
    rep(i,n)b[i]=i;
    //debug(b);
    ll res = 0;
    do{
        ll is_res = true;
        if(a[0][b[1]] == 0)is_res=false;
        rep1(i,n-1){
            if(a[b[i]][b[i+1]] == 0)is_res = false;
        }
        if(is_res)res++;
    }while(next_permutation(b.begin()+1,b.end()));
    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[99];
int a[99];
int main(){
	scanf("%s",s);
	ll n=strlen(s);
	rep(i,0,n)if(a[s[i]-'a']++){
		puts("no");
		return 0;
	}
	puts("yes");
}

Measured memory_bytes: 128
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, v = rm()
b, w = rm()
t = ri()
if v - w == 0:
  print('NO')
  exit()
if 0 <= abs(a-b) / (v-w) <= t:
  print('YES')
else:
  print('NO')



Measured memory_bytes: 27076
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n_max=2*(10**6+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
else:
  n=(x+y)//3
  if x<n or y<n:
    print(0)
  else:
    print(comb(n,x-n))

Measured memory_bytes: 71404
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
#define N 3010
using namespace std;
int n,a[N],d[N];
int head[N],zhead[N],ap=1;
struct ways{
	int now,next;
}way[N<<1];
inline int rd(){
    int x;
    scanf("%d",&x);return x;
}
inline void link(int u,int v){
	way[++ap].now=v;way[ap].next=head[u];head[u]=ap;d[u]++;
    way[++ap].now=u;way[ap].next=zhead[v];zhead[v]=ap;
}
int xu[N],sg[N],cnt,vis[N];
void work(){
	int i,j;
	n=rd();
	for(i=1;i<=n;i++)
	a[i]=rd();
	int x,y;
	for(i=1;i<n;i++)
	{x=rd(),y=rd();
	if(a[x]>a[y])link(x,y);
	else if(a[x]<a[y])link(y,x);
    }
    int fir=1,las=0,to;
    for(i=1;i<=n;i++){
	  if(d[i]==0)xu[++las]=i,sg[i]=0;//必败
    }
    for(;fir<=las;fir++){
    	x=xu[fir];
    	for(y=zhead[x];to=way[y].now,y;y=way[y].next)
    	if((--d[to])==0)
    	xu[++las]=to;
		++cnt;
		for(y=head[x];to=way[y].now,y;y=way[y].next)
		vis[sg[to]]=cnt;
		for(y=0;vis[y]==cnt;y++);
		sg[x]=y;
    }
    for(i=1;i<=n;i++)
    if(sg[i])printf("%d ",i);
    
}
int main(){
	work();
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
using namespace std;
vector<pair<int,int> >data;

int check(int d,int i)
{
  if(i>=data.size()|| d<=0)
    return 0;
  int ans=check(d,i+1);  
  if(data[i].first<=d)
    ans=max(ans,data[i].second+check(d-data[i].first,i+1));
  
  return ans;
}

int main()
{
  int d;
  cin>>d;
  int x;
  cin>>x;
  for(;x--;)
    {
      string a;
      int p;
      cin>>a>>p;
      if(a=="D")
	data.push_back(make_pair(1,p));
    }
  int y;
  cin>>y;
  for(;y--;)
    {
      string a;
      int p;
      cin>>a>>p;
      if(a=="DD")
	data.push_back(make_pair(2,p));
    }
  cout<<check(d,0)<<endl; 
}

Measured memory_bytes: 1216
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		
		double taxrate = 1.08;
		double temp1 = (double)(N - 1) / taxrate;
		double temp2 = (double)(N + 1) / taxrate;
		int tp1 = (int)Math.floor(temp1);
		int tp2 = (int)Math.floor(temp2);
		int result = -1;
		for (int i = tp1; i <= tp2; ++i) {
			if (Math.floor(i * taxrate) == N) {
				result = i;
				break;
			}
		}
		String results = result == -1 ? ":(" : Integer.toString(result);
		
		System.out.println(results);
		
	}
	
	
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int x,y;
    cin>>x>>y;
    vs ans;
    REP(i,50){
        ans.pb(string(100,'#'));
    }
    REP(i,50){
        ans.pb(string(100,'.'));
    }
    REP(i,x-1){
        ans[i/50*2][i%50*2]='.';
    }
    REP(i,y-1){
        ans[51+i/50*2][i%50*2]='#';
    }
  	cout<<100<<" "<<100<<endl;
    REP(i,100){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		final double eps = 1e-10;
		Scanner scan = new Scanner(System.in);
		double x1, y1, x2, y2, x3, y3, x4, y4;
		while(scan.hasNextDouble()){
			x1 = scan.nextDouble(); y1 = scan.nextDouble();
			x2 = scan.nextDouble(); y2 = scan.nextDouble();
			x3 = scan.nextDouble(); y3 = scan.nextDouble();
			x4 = scan.nextDouble(); y4 = scan.nextDouble();
			double vax = x2 - x1, vay = y2 - y1;
			double vbx = x4 - x3, vby = y4 - y3;
			if(Math.abs(vax * vbx + vay * vby) < eps){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 21484
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, A, B;
	cin >> N >> A >> B;

	vector<Int> X(N);
	for (Int i = 0; i < N; i++) {
		cin >> X[i];
	}
	Int ans = 0;
	for (Int i = 1; i < N; i++) {
		ans += min(B, A * (X[i] - X[i - 1]));
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}


Measured memory_bytes: 3620
def resolve():
    n, k = map(int, input().split())
    s = input()

    unhappy = 0
    if s[0] == 'L':
        unhappy += 1

    if s[-1] == 'R':
        unhappy += 1

    for i in range(n-1):
        if s[i:i+2] == 'RL':
            unhappy += 2

    print(min(len(s)-1, len(s)-(unhappy-2*k)))

resolve()

Measured memory_bytes: 39408
import heapq
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
hq = [-a[0]]
ans = 0
for i in range(1, n):
    ans -= heapq.heappop(hq)
    heapq.heappush(hq, -a[i])
    heapq.heappush(hq, -a[i])
print(ans)


Measured memory_bytes: 100072
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    d = d * 2 + 1;
    if (n % d)
        cout << n / d + 1;
    else
    {
        cout << n / d;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
while 1 > 0:
    height, width = map(int, raw_input().split())
    if height == 0 and width == 0:
        break
    for i in range(width):
        sys.stdout.write("#")
    print ""
    for i in range(height - 2):
        sys.stdout.write("#")
        for j in range(width - 2):
            sys.stdout.write(".")
        sys.stdout.write("#")
        print ""
    for i in range(width):
        sys.stdout.write("#")
    print ""
    print

Measured memory_bytes: 6444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,sum=0;
    cin>>a>>b>>c;
    
    sum=a+b+c;
    
    if(sum>=22){cout<<"bust"<<endl;}
    else{cout<<"win"<<endl;}
    return 0;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
P = list(map(int,input().split()))

mx = P[0]
mn = mx
count = 0

cut = deque(list(filter(lambda x:mx >= x,P)))
ans = deque()

ln = len(cut)

for a in range(ln):
    num = cut.popleft()
    if mx >= num:
        mx = num
        count += 1
    else:
        continue

print(count)

Measured memory_bytes: 25252
#include <unistd.h>
#include <vector>

#define N 1000000
const int mod = 998244353;

int n;
int A[N+1];

char ibuf[1600100];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');
  return x;
}

char buf[20];
char *bufe = buf;

void write_uintll(long long int x){
  int i;
  static char tmp[14];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


/*
\sum_{i<j} lcm(Ai,Aj)
\sum_{i<j} Ai Aj / gcd(Ai,Aj)
\sum_{d} 1/d \sum_{i<j: gcd(Ai, Aj) = d} Ai Aj

f(d) = \sum_{i,j: gcd(Ai, Aj) = d} Ai Aj
F(d) = \sum_{i,j: d | gcd(Ai, Aj)} Ai Aj
F(d) = \sum_{i,j: d | Ai, d | Aj)} Ai Aj
F(d) = (\sum_{i: d | Ai} Ai)^2
\sum_{d} 1/d \sum_{n: d|n} m(n/d) F(n)
\sum_{n} F(n) \sum_{d: d|n} 1/d m(n/d)
\sum_{n} F(n)/n \sum_{d: d|n} n/d m(n/d)
\sum_{n} F(n)/n \sum_{d: d|n} d m(d)
\sum_{d: d|n} d m(d) = \sum_{d: p|d|n} d m(d) + \sum_{d: d|n/p^k} d m(d)
= \sum_{d: d|n/p^k} pd m(pd) + \sum_{d: d|n/p^k} d m(d)
= \sum_{d: d|n/p^k} d m(d) - pd m(d)
=(1-p0)(1-p1)...(1-pm)
*/

int inv[N+1];
int phi[N+1];
std::vector<int> primes;

int main(){
  int r, s;

  inv[1] = 1;
  for(int i=2;i<=N;i++) inv[i] = (long long) (mod - mod/i) * inv[mod%i] % mod;
  phi[1] = 1;
  for(int i=2;i<=N;i++){
    if(!phi[i]){
      phi[i] = mod+1-i;
      for(int j=2*i;j<=N;j+=i){
        if(phi[j]) phi[j] = (long long) phi[j] * (mod+1-i) % mod;
        else phi[j] = mod+1-i;
      }
      primes.push_back(i);
    }
    phi[i] = (long long) phi[i] * inv[i] % mod;
  }

  
  readall();
  n = read_uint();
  s = 0;
  for(int i=0;i<n;i++){
    int x = read_uint();
    A[x]++;
    s += x;
    if(s >= mod) s -= mod;
  }

  for(int i=1;i<=N;i++){
    A[i] = (long long) i * A[i] % mod;
  }
  for(int p: primes){
    for(int i=N/p; i; i--){
      A[i] += A[i*p];
      if(A[i] >= mod) A[i] -= mod;
    }
  }

  r = mod-s;
  for(int i=1;i<=N;i++){
    r = (r + (long long) A[i] * A[i] % mod * phi[i]) % mod;
  }

  write_uintll(r&1?(r+mod)/2:r/2);
  writeall();

  return 0;
}


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

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

	sort(enemies.begin(), enemies.end(),greater<>());

	long long ans=0;
	for(int i=k;i<n;i++)ans+=enemies[i];
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var inputValue = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			var N = inputValue[0];
			var D = inputValue[1];
			var answer = 0;

			for(int i = 0; i < N; i++)
			{
				var value = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
				var a = value[0];
				var b = value[1];

				long addValue = (a * a) + (b * b);
				double root = Math.Sqrt(addValue);

				if(root <= D)
				{
					answer++;
				}
			}

			Console.WriteLine(answer);
		}
	}
}

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

#define int long long

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

string s;

signed main() {
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  for (int i = 1; i < s.size(); i++) {
    string cand = s.substr(0, s.size() - i);
    if (cand.size() % 2 == 1) continue;
    string b = cand.substr(0, cand.size() / 2);
    string a = cand.substr(cand.size() / 2, cand.size() / 2);
    if (b == a) ans = max(ans, (ll)cand.size());
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e6;
const int K = 15;

int n, k, x, temp;
int dis[K];
bool valid;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> n >> k;
        while(k--) {
            cin >> x;
            dis[x] = true;
        }
        for(int i = n; i <= N; i++) {
            temp = i;
            valid = true;
            while(temp) {
                if(dis[temp % 10]) valid = false;
                temp /= 10;
            }
            if(valid) {
                cout << i << "\n";
                return;
            }
        }
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 3636
// C - Connect Cities
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;

int main(){
	int n, m; cin>>n>>m;
	dsu d(n);
	while(m--){
		int a, b; cin>>a>>b;
		d.merge(a-1, b-1);
	}
	auto g = d.groups();
	cout<< g.size() - 1 <<endl;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x,y;
	cin>>x>>y;
	if(x%y==0)cout<<-1<<endl;
	else{
		cout<<x<<endl;
	}
	return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long int a,b,c,d;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    long long int x,y,z,p;
    x=a*c;
    y=a*d;
    z=b*c;
    p=b*d;
    
    if(x<y){
        x=y;
        
    }
    if(x<z){
        x=z;
        
    }
     if(x<p){
           x=p;
           
       }
   // long long int x,y;
    
    cout<<x<<endl;
    
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  long H;
  cin >> H;
  long cnt =0;
  for(;;){
    if(H==1)
      break;
    else{
    H = (long)H/2;
    cnt++;}
    }
  //cout<< cnt<<endl;
  long ans = pow(2,(cnt+1)) -1;
  cout<< ans <<endl;
}




Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

comb = []
count = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
                comb.append([i, j, k])
for i in range(len(comb)):
    if x == 500*comb[i][0] + 100*comb[i][1] + 50*comb[i][2]:
        count += 1

print(count)


Measured memory_bytes: 16500
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var dag = new long[3];
            var row = new long[3];
            var col = new long[3];
            for (var i = 0; i < 3; ++i)
            {
                var cij = Sarray();
                for (var j = 0; j < 3; ++j)
                {
                    dag[j] += cij[(i + j) % 3];
                    if (i == 0)
                        col[j] = 2 * cij[j];
                    else
                        col[j] -= cij[j];
                }
                row[i] = 2 * cij[0] - cij[1] - cij[2];
            }
            if (dag.All(d => d == dag[0]) && row.All(r => r == row[0]) && col.All(c => c == col[0]))
                WriteLine("Yes");
            else
                WriteLine("No");
        }
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28160
#include<stdio.h>

#define MAX 100005
#define NIL -1
struct node{int p,l,r;};
struct node T[MAX];
int n,H,D[MAX];

int getDepth(int u){
  int d=0;
  for(;T[u].p != NIL;d++)u=T[u].p;
  return d;
}

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);
  if(T[u].p == NIL)printf("root, ");
  else if(T[u].l == NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}


int main(){
  int i,j,d,v,c,l;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].r=T[i].l=NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].l=c;
      else T[l].r = c;
      l=c;
      T[c].p=v;
    }
  }
  H=0;
  for(i=0;i<n;i++){
    D[i]=getDepth(i);
    if(D[i]>H)H=D[i];
  }
  for(i=0;i<n;i++)
    print(i);
    return 0;
  
}



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

int main()
{
    // 入力
    int N;
    cin >> N;

    int ans = 0;
    if(N%10 == 2 || N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9){
        cout << "hon" << endl;
    }else if(N%10 == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const ll INF = 1e18;
const int MAXN = 505;

int n;
ll w[MAXN][MAXN],f[MAXN][MAXN],sum1[MAXN][MAXN],sum2[MAXN][MAXN];

ll getVal1(int a,int b,int c,int d){
	return sum1[b][d] - (c == 0 ? 0 : sum1[b][c - 1]) - (a == 0 ? 0 : sum1[a - 1][d]) + (a == 0 || c == 0 ? 0 : sum1[a - 1][c - 1]);
}

ll getVal2(int a,int b,int c,int d){
	return sum2[b][d] - (c == 0 ? 0 : sum2[b][c - 1]) - (a == 0 ? 0 : sum2[a - 1][d]) + (a == 0 || c == 0 ? 0 : sum2[a - 1][c - 1]);
}

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(i != j)
			    scanf("%d",&w[i][j]);
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++)
		    sum1[i][j] = sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1] + w[i][j];
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++)
		    sum2[i][j] = sum2[i - 1][j] + sum2[i][j - 1] - sum2[i - 1][j - 1] + (i < j ? w[i][j] : 0);
	}
	for(int i = 1;i <= n;i++){
		f[i][1] = getVal2(0,i,0,i);
		for(int j = 2;j <= i;j++){
			f[i][j] = INF;
			for(int k = 1;k < j;k++)
				f[i][j] = min(f[i][j],f[j - 1][k] + getVal2(j,i,j,i) + getVal1(j,i,0,k - 1));
		}
	}
	ll ans = INF;
	for(int i = 1;i <= n;i++)
	    ans = min(ans,f[n][i]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#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 ll long long
#define pb(a) push_back(a)

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int N;
  if(b<=9){
    N = 10*a+b;
  }
  else if(b<=99){
    N = 100*a +b;
  }
  else{
    N = 1000*a+b;
  }
  double n = sqrt(N);
  for(int i = 3; i < 100101; i++){
    if(i == n){
      cout << "Yes" << endl;
      return 0;
      
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    total_T_in_A = [0] * (N+1)
    total_T_in_B = [0] * (M+1)

    for i in range(1, N+1):
        total_T_in_A[i] = total_T_in_A[i-1] + A[i-1]

    for i in range(1, M+1):
        total_T_in_B[i] = total_T_in_B[i-1] + B[i-1]

    result = 0
    for i in range(N+1):
        # A から i 冊読むときにかかる時間
        i_A_T = total_T_in_A[i]
        
        if K < i_A_T:
            continue

        if K == i_A_T:
            result = max(result, i)
            continue

        rem_T = K - i_A_T

        # total_T_in_B は累積和を格納した、ソート済の配列
        # B_i <= rem_T < B_i+1 となるような B_i を二分探索によって探す
        first = total_T_in_B[1]
        last = total_T_in_B[M]
        if rem_T < first:
            result = max(result, i)
            continue
        if last <= rem_T:
            result = max(result, i + M)
            continue

        # assume that first <= rem_T <= last
        first = 1
        last = M
        while first < last:
            if abs(last - first) <= 1:
                break
            mid = (first + last) // 2
            if rem_T < total_T_in_B[mid]:
                last = mid
            else:
                first = mid
        result = max(result, i + first)

    print(result)

main()


Measured memory_bytes: 118104
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll K, A, B;
  cin >> K >> A >> B;
  if(K <= A) cout << 1 << endl;
  else if(A <= B) cout << -1 << endl;
  else {
    cout << (K - B - 1) / (A - B) * 2 + 1 << endl;
  }
  return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename F> long long discrete_binary_search(long long ok, long long ng, const F &check) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int N, K;
int A[220000], F[220000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> A[i]; }
    sort(A, A + N);
    rep(i, N) { cin >> F[i]; }
    sort(F, F + N), reverse(F, F + N);
    cout << discrete_binary_search((int) 1e13, -1, [&](int x) {
        int sum = 0;
        rep(i, N) {
            sum += max(0LL, A[i] - x / F[i]);
        }
        return sum <= K;
    }) << endl;
}

Measured memory_bytes: 3328
(defun solve (N)
  (let (x y)
    (do ((i (isqrt N) (1- i)))
	((zerop i) "No")
      (multiple-value-bind (x y) (floor N i)
	  (if (and (= y 0) (< x 10))
	      (return "Yes") )))))

(princ (solve (read)))

Measured memory_bytes: 3816
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod

it = InverseTable(mod, 10**6)

for ai in A:
    pro=lcm(pro,ai)
for ai in A:
    ans+=it.In[ai]
    ans%=mod
print((pro*ans)%mod)

# pro2=1
# for ai in A:
#     pro2=(pro2*ai)%mod
#     pro=gcd(pro,ai)
# for ai in A:
#     count+=pro//ai
#     count%=mod
# print(count)

Measured memory_bytes: 131884
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;


int main() {
	map<int, int> mp;
	long long int a,b,c;
	string str;
	cin >> a>>b;
	if (a*b <= 0) {
		cout << "Zero";
	}
	else if (a > 0 && b > 0) {
		cout << "Positive";
	}
	else if (b < 0 && a<0) {
		if ((b - a + 1) % 2 == 0) { cout << "Positive"; }
		else {
			cout << "Negative";
		}
	}
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		LinkedList<Double> list=new LinkedList<Double>();
		while(sc.hasNext()) {
			list.add(sc.nextDouble());
		}
		Collections.sort(list);
		ln(list.get(list.size()-1)-list.get(0));
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, a;
  cin >> n >> k;
  a = 1;
  for (int i = 0; i < n; i++) {
    if (a < k) {
      a *= 2;
    }
    else {
      a += k;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;

//-----------------------------------------------------------------------

int N,Q;
int bit[100010];

void add(int k,int x)
{   
    for(;k<=N;k+=k&-k) bit[k]+=x;
}
int getSum(int k)
{   
    int ret=0;
    for(;k>0;k-=k&-k) ret+=bit[k];
    return ret;
}

signed main()
{
    cin>>N>>Q;
    while(Q--)
    {
        int type,x,y; cin>>type>>x>>y;
        if(type==0)
            add(x,y);
        else
            cout<<getSum(y)-getSum(x-1)<<endl;
    }
}



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

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

string a,b,c,ans;

int main(){
    cin >> a >> b >> c;
    ans += a[0];
    ans += b[1];
    ans += c[2];

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	static List<Integer> adj[];
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
	
		int[][] dp = new int[n+1][2];
		//int n = Integer.parseInt(str.nextToken());
		// 0 is black 1 is white
		adj = new ArrayList[n+1];
		for(int i =1; i <= n; i++) adj[i] = new ArrayList();
		for(int i =0 ; i <n-1; i++)
		{
			StringTokenizer str = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(str.nextToken());
			int b = Integer.parseInt(str.nextToken());
			adj[a].add(b);
			adj[b].add(a);
			
			
		}
		pair ans = dfs(1,-1);
		System.out.println((ans.getFirst()+ans.getSecond())%1000000007);
		
		
		
	}
	
	static pair dfs(int a, int parent)
	{
		long all_white = 1;
		long smthg_black = 0;
		for(int b: adj[a])
		{
			if(b != parent)
			{
				pair p = dfs(b, a);
				long memo = all_white;
				all_white = mul(all_white, p.getSecond());
				smthg_black =( mul(memo, p.getFirst()) + mul(smthg_black,p.getFirst() + p.getSecond()))%1000000007;
			}
		}
		return new pair(all_white, (all_white + smthg_black)%1000000007);
	}
	static long mul(long a, long l)
	{
		return (a*l)%1000000007;
	}

}
class pair
{
	long a, b;
	public pair(long a, long b)
	{
		this.a = a;
		this.b = b;
	}
	public long getFirst()
	{
		return this.a;
	}
	public long getSecond()
	{
		return this.b;
	}
}


Measured memory_bytes: 76352
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string T;

  cin >> T;

  rep(i, T.size()) {
    if (T[i] == '?') {
      if ((T[i - 1] == 'P') && (T[i + i] == '?')) {
        T[i] = 'D';
      }

      else if ((T[i - 1] == 'D') && (T[i + 1] == '?')) {
        T[i] = 'P';
      } else
        T[i] = 'D';
    }
  }

  cout << T << endl;
}


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

using namespace std;

typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; )
    {
        int j = i;
        while (j < n && a[j] == a[i]) j++;
        ans += (j - i) / 2;
        i = j;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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 namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long,long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll a; cin >> a;
    string b;
    cin >> b;
    b = b.substr(0,1) + b.substr(2,2);
    cout << a * stol(b)/100 << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

string S;
LL ans = 0;
void solve(int now, LL sum){
	if(now == S.size()) ans += sum;
	for(int i=0; i<S.size()-now; i++){
		solve(now+i+1, sum+stoll(S.substr(now,i+1)));
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> S;
	solve(0, 0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int A, B;
    cin >> A >> B;
    int count = 0;
    for(int i=A; i<=B; i++)
    {
        string str = to_string(i);
        if ((str[0] == str[4]) && (str[1] == str[3])) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256