akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

int main() {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    if (a <= 0 && b >= 0) printf("Zero\n");
    else {
        if (a >= 0) printf("Positive\n");
        else {
            if (b >= 0) b = -1;
            if ((b-a)%2) printf("Positive\n");
            else printf("Negative\n");
        }
    }
}


Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(void){
    int x,a,b,c,temp;
    cin >> a >> b >> c;
    for(x=a;x<=b;x++){
        if(c%x == 0){
            temp = temp +1;
        }
    }
    cout << temp;
    cout << endl;
}


Measured memory_bytes: 3108
H,W = map(int,input().split())
ans = float("inf")
if H%3!=0:
    ans = W
else:
    ans = 0
if W%3!=0:
    ans = min(ans, H)
else:
    ans = min(ans,0)
#print(ans)
for i in range(1,W):
    Sma = max(i*H, (W-i)*(-(-H//2)))
    Smi = min(i*H, (W-i)*(H//2))
    ans = min(ans, Sma-Smi)

for i in range(1,H):
    Sma = max(i*W, (H-i)*(-(-W//2)))
    Smi = min(i*W, (H-i)*(W//2))
    ans = min(ans, Sma-Smi)
print(ans)

Measured memory_bytes: 40304
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
inline void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
inline void YES(bool b) { cout << (b ? "YES" : "NO") << 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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

struct edge {
    int a,b,len;  // from a to b
    edge(int a,int b,ll l):a(a),b(b),len(l) {}
};

// return value is {} if there is a negative cycle.
vector<ll> bellman_ford(int n,int start,const vector<edge>& v) {
    vector<ll> dist(n,linf);
    dist[start] = 0;
    rep(i,n) {
        for(auto e : v) {
            if(dist[e.a]+e.len < dist[e.b]) {
                dist[e.b] = dist[e.a]+e.len;
                if(i == n-1 && e.b == n-1) return {};
            }
        }
    }
    return dist;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vector<edge> ve;
    rep(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        ve.eb(a,b,-c);
    }
    auto v = bellman_ford(n,0,ve);
    if(v.size() == 0) cout << "inf" << endl;
    else cout << -v[n-1] << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    writeln!(o, "{}", solve(n)).unwrap();
}
pub fn solve(mut n: usize) -> usize {
    fn count_all(len: u32, base: usize) -> usize {
        if len == 0 {
            return 0;
        }
        base.pow(len) + count_all(len - 1, base)
    }
    fn count(ns: &[usize], uses: [bool; 3], use0: bool) -> usize {
        if ns.len() == 0 {
            return 1;
        }
        let n = ns[0];
        let mut base: usize = 0;
        for &u in &uses {
            if u {
                base += 1;
            }
        }
        let exp = (ns.len() - 1) as u32;
        let mut x = 0;
        let mut r = 0;
        if use0 {
            r += count_all(exp, base);
        }
        if uses[0] && n > 3 {
            x += 1;
        }
        if uses[1] && n > 5 {
            x += 1;
        }
        if uses[2] && n > 7 {
            x += 1;
        }
        r += x * base.pow(exp);
        let next = match n {
            3 => uses[0],
            5 => uses[1],
            7 => uses[2],
            _ => false,
        };

        if next {
            r += count(&ns[1..], uses, false);
        }
        r
    }
    let mut ns = Vec::new();
    while n != 0 {
        ns.push(n % 10);
        n /= 10;
    }
    ns.reverse();

    let mut r = count(&ns, [true, true, true], true);
    for i in 0..3 {
        let mut uses = [false; 3];
        uses[i] = true;
        r += count(&ns, uses, true);
    }

    for i in 0..3 {
        let mut uses = [true; 3];
        uses[i] = false;
        r -= count(&ns, uses, true);
    }
    r
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
string n;
cin >> n;
int len=(int)(n.length());
ll g=0,p=0;
rep(i,len){
    if(n[i]=='g')g++;
    else p++;
}

cout << (g-p)/2 << endl;
return 0;
}


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

int main() {
    int n;
    cin >> n;

    vector<string> s(n);
    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> s[i] >> t[i];

    string x;
    cin >> x;

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == x) {
            for(int j = i + 1; j < n; j++) {
                ans += t[j];
            }
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair

// random generator
// mt19937 rndm(time(0));

// ll gcd(ll a, ll b)
// {
//     while (b>0)
//     {
//         ll tmp = a;
//         a = b;
//         b = tmp%b;
//     }
//     return a;
// }


// long long gcd(long long a, long long b) {
//  return a? gcd(b % a, a) : b;
// }


const int M=1e9+7;
ll powmod(ll a,ll b, ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}/* a^b%mod */
const ll N=1e5+10;


int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, m;
    cin>>n>>m;
    vector<pair<ll, ll> >v;
    for(int i=0;i<n;++i) {
        int a, b;
        cin>>a>>b;
        v.pb(mp(a, b));
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(int i=0;i<n;++i) {
        if(m<=0)break;
        if(m>v[i].second) {
            m-=v[i].second;
            ans+=v[i].second*v[i].first;
        }
        else {
            ans+=m*v[i].first;
            m=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}








Measured memory_bytes: 2420
while True:
    h, w = map(int,input().split())
    if h == 0 and w == 0: break
    for i in range(h):
        for j in range(w):
            if ((i+j)%2) == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
//コンパイラ最適化用
#pragma GCC optimize("O3")

#include<iostream>//入出力

using namespace std;
typedef unsigned int ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define MOD 1000000007 //10^9+7:合同式の法


ll s[2001],t[2001],dp[2001][2001]={0};

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;cin>>n>>m;
    REP(i,n){cin>>s[i];}
    REP(i,m){cin>>t[i];}
    REP(i,n+1){dp[i][0]=1;}
    REP(i,m+1){dp[0][i]=1;}
    REP(i,n){
        REP(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]+=(dp[i+1][j]+dp[i][j+1])%MOD;
            }else{
                dp[i+1][j+1]+=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+MOD)%MOD;
            }
        }
    }
    cout<<dp[n][m]<<"\n";
}

Measured memory_bytes: 19156
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;

int main(){
	char a[100];
	for (int i = 0; i < 100; i++)a[i] = 0;

	scanf("%s", a);

	printf("2018/01/%c%c\n", a[8],a[9]);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MAX 200000

int main(){
  int i;
  int maxprf,minprf,gyo,num[MAX];

  scanf("%d",&gyo);
  for(i=0;i<gyo;i++) scanf("%d",&num[i]);

  minprf=num[0];
  maxprf=num[1]-num[0];
  for(i=1;i<gyo;i++){
    if(maxprf<num[i]-minprf) maxprf=num[i]-minprf;
    if(minprf>num[i]) minprf=num[i];
  }

  printf("%d\n",maxprf);
  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int in[1333];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int k=-1;
	n<<=1;
	REP(i, 1000){
		if(i*i-i==n){
			k=i;
			break;
		}
	}
	if(k==-1){
		cout<<"No"<<'\n';
		return 0;
	}
	int s[1333][1333];
	int now=1;
	REP(i, k-1){
		FOR(j, in[i], k-1){
			s[i][j]=now++;
		}
		int tmp=in[i];
		FOR(j, i+1, k){
			s[j][in[j]++]=s[i][tmp++];
		}
	}
	cout<<"Yes"<<'\n';
	cout<<k<<'\n';
	REP(i, k){
		cout<<k-1<<' ';
		REP(j, k-1){
			cout<<s[i][j]<<" \n"[j==k-2];
		}
	}
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    int a,b;
    cin >> a>>b;
    if (a <= 8 & b <= 8)  {
        printf("Yay!");
    } else if( a > 8 | b > 8) {
        printf(":(");
    }
        return 0;
    }


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


#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL n,k,s,x,y;

int main()
{
    scl(n);scl(k);scl(s);
    if(k==n)
    {
        for(int i=0;i<n;i++)cout<<s<<" ";
    }
    else if(s==1)
    {
        y=1e9;
        for(int i=0;i<k;i++)cout<<1<<" ";
        for(int i=k;i<n;i++)cout<<y<<" ";
    }
    else
    {
        for(int i=0;i<=k;i++)
        {
            if(i%2==0)cout<<(s+1)/2<<" ";
            else cout<<s/2<<" ";
        }
        if(s!=1e9)x=1e9;
        else x=(1e9)-1;
        for(int i=k+1;i<n;i++)
        {
            cout<<x<<" ";
        }
    }


    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <deque>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define pb push_back
#define pf push_front
using namespace std;
typedef long long ll;
typedef double db;
const int N = 100005, mod = 1000000007;
ll n;
int m;
deque<int> a, b;
void work(ll x) {
	if (x == 1) return ;
	work(x / 2);
	++ m;
	a.pb(m), b.pb(m);
	if (x & 1) {
		++ m;
		a.pb(m), b.pf(m);
	}
}
int main()
{
	scanf ("%lld", &n);
	work(n + 1);
	printf("%d\n", a.size() + b.size());
	for (auto it = a.begin(); it != a.end(); it ++) printf("%d\n", *it);
	for (auto it = b.begin(); it != b.end(); it ++) printf("%d\n", *it);

	return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

h_d = 30 * H + M / 2
m_d = 6 * M

if h_d >= m_d:
    D = h_d - m_d
else:
    D = m_d - h_d

if D > 180:
    D = 360 - D

if D == 0:
    ans = abs(B - A)
elif D == 180:
    ans = B + A
else:
    ans_sq = A*A + B*B - 2*A*B*math.cos(math.radians(D))
    ans = math.sqrt(ans_sq)
print(ans)

Measured memory_bytes: 9524
#include<bits/stdc++.h>
using namespace std;
long long a,b,x;
long long s,e;
int main()
{
    cin>>a>>b>>x;
    if(a%x==0)
        s=a/x;
    else
        s=a/x+1;
    e=b/x;
    cout<<e-s+1<<endl;
    return 0;
}


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

using namespace std;

int descrescator(int a, int b)
{
    return a > b;
}

int checkFather(vector <int>&goodSlimes, vector <int>&s, int n, vector <int>&viz)
{
    int length = goodSlimes.size(), weAreGoodHere = 0;
    int poz = 0, nr = 0;
    //cout << length << " " << n << "\n";

    for (int i = 0; i < n; i++)
    {
        //cout << viz[i] << " " << i << "\n";
        if (viz[i] == 0)
        {
            if (goodSlimes[poz] > s[i])
            {
                viz[i] = 1; poz++;
                goodSlimes.push_back(s[i]);
            }

            if (poz == length)
            {
                return 1;
                i = n + 1;
            }
        }
        if (i == n - 1)
            return 0;
    }
    //cout << "\n";
    //if (nr == length)
      //  weAreGoodHere = 1;

    return 1;
}

int main()
{
    int n, doiLaN;

    cin >> n;

    doiLaN = 1 << n;

    vector <int> s(doiLaN), goodSlimes, viz(doiLaN, 0);

    for (int i = 0; i < doiLaN; i++)
    {
        cin >> s[i];
    }
    //cout << s[0] << " ";

    sort(s.begin(), s.end(), descrescator);

    //cout << s[0];
    int poz = 0;
    goodSlimes.push_back(s[0]);
    viz[0] = 1;

    while(poz < n)
    {
        if (checkFather(goodSlimes, s, doiLaN, viz) == 0)
            {
                cout << "No\n";
                return 0;
            }

        sort(goodSlimes.begin(), goodSlimes.end(), descrescator);
        poz++;
    }

    cout << "Yes\n";

    return 0;
}


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

using namespace std;

string s;
int ans = 0;

int main()
{
    cin>>s;
    int len = s.length();
    int a = 0;
    int pre = 0,pr = -1;
    for(int i = 0;i < len;i++)
    {
        a = s[i] - 'a' + 1;
        if(a == pre)
        {
            pre = pre * 100 + a;
            pr = a;
        }
        else
        {
            ans++;
            if(pr)
            pre = pre * 100 + a;
            else
                pre = a;
            pr = 0;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int min = 1;
		int max = in.nextInt();
		int gate = in.nextInt();
		int cch;
		for (int i = 0; i < gate; i++) {
			for (int j = 0; j < 2; j++) {
				cch = in.nextInt();
				if (j == 0) {
					if (min < cch) min = cch;
				} else {
					if (max > cch) max = cch;
				}
			}
		}
		in.close();
		int ans = max - min + 1;
		if (ans < 0) ans = 0;
		System.out.println(ans);
	}
}

Measured memory_bytes: 63064
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  string s, t;
  while (cin >> N >> s >> t) {
    int res = 2 * N;
    for (int n = N; n >= 1; n--) {
      if (s.substr(N - n) == t.substr(0, n)) {
        res -= n;
        break;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;
int cnt[50][25];
ll ans1, ans2;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		ll b = 0;
		int p = 0;
		for (int j = 0; j < (int)s.size(); j++)if (s[j] == '.')p = j;
		if (p == 0)p = (int)s.size();
		for (int j = 0; j < p; j++)b += (s[j] - '0')*(ll)1000000000 * (int)pow(10, p - j - 1);
		for (int j = p + 1; j < (int)s.size(); j++)b += (s[j] - '0')*(ll)1000000000 / (int)pow(10, j - p);
		int cnt1 = 0, cnt2 = 0;
		while (b % 2 == 0)cnt1++, b /= 2;
		while (b % 5 == 0)cnt2++, b /= 5;
		cnt[cnt1][cnt2]++;
	}
	for (int i = 0; i < 50; i++)for (int j = 0; j < 25; j++)for (int k = max(0, 18 - i); k < 50; k++)for (int l = max(0, 18 - j); l < 25; l++) {
		if (i == k && j == l)ans2 += (ll)cnt[i][j] * (cnt[i][j] - 1) / 2;
		else ans1 += (ll)cnt[i][j] * cnt[k][l];
	}
	cout << ans1 / 2 + ans2 << endl;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    if(s[0] == t[0])
        ans++;
        if(s[1] == t[1])
            ans++;
        if(s[2] == t[2])
            ans++;
        cout<<ans<<endl;
        return 0;
}


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

const int MOD = 1000000007;

int main()
{
  long long int N, K;
  cin >> N >> K;
  vector<long long> H(N);
  for (int i = 0; i < N; i++)
    cin >> H[i];
  sort(H.begin(), H.end(), greater<long long>());
  long long int cnt = 0;
  for (int i = K; i < N; i++)
    cnt += H[i];
  cout << cnt << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n,d;
	cin>>n>>d;
	d=2*d+1;
	cout<<(n%d==0?n/d:n/d+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll d, c[26], s[365][26], t[365], sc[365], last[26];

// コンテストとその日付をcontest:{日付,日付,...}で保持する
unordered_map<ll, vll> contests;

void input() {
  cin >> d;
  rep(i, 26) { cin >> c[i]; }
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
}

// satisfactory decrease
ll satDec(ll date, ll con) {
  ll ans = 0;
  rep(i, 26) {
    if (i != con) { ans += c[i] * (date - last[i]); }
  }
  return ans;
}

// コンテストconを選んだときの満足度の変化を計算する
// 26回ループで求まる
ll satChange(ll date, ll con) { return s[date][con] - satDec(date, con); }

// 満足度を1日ごとに計算する
void calcSat() {
  ll s = 0;
  rep(i, d) {
    s += sc[i];
    cout << s << endl;
  }
}

void randomImprove(ll cq, ll q2) {
  ll q1 = t[cq];

  ll befq1, nextq1, befq2, nextq2;
  auto cq1Iter = lower_bound(contests[q1].begin(), contests[q1].end(), cq);
  if (cq1Iter - contests[q1].begin() == 0) {
    befq1 = -1;
  } else {
    befq1 = *(cq1Iter - 1);
  }
  if (contests[q1].end() - cq1Iter == 1) {
    nextq1 = d;
  } else {
    nextq1 = *(cq1Iter + 1);
  }

  auto cq2Iter = lower_bound(contests[q2].begin(), contests[q2].end(), cq);
  if (cq2Iter - contests[q2].begin() == 0) {
    befq2 = -1;
  } else {
    befq2 = *(cq2Iter - 1);
  }
  if (contests[q2].end() - cq2Iter == 0) {
    nextq2 = d;
  } else {
    nextq2 = *cq2Iter;
  }

  ll satChange = -s[cq][q1] - c[q1] * (cq - befq1) * (nextq1 - cq) + s[cq][q2] +
                 c[q2] * (cq - befq2) * (nextq2 - cq);
  if (satChange > 0) {
    contests[q1].erase(cq1Iter);
    contests[q2].insert(cq2Iter, cq);
    t[cq] = q2;
  }
}

void solve() {

  clock_t start = clock();

  rep(i, 26) { last[i] = -1; }
  // 貪欲法
  rep(i, d) {
    // 終わったあとのことをシミュレーションしてみて，一番良くなるやつを選ぶ
    ll maxS, maxC;
    rep(j, 26) {
      ll sj = satChange(i, j);
      if (j == 0) {
        maxS = sj;
        maxC = 0;
        continue;
      }
      if (sj > maxS) {
        maxS = sj;
        maxC = j;
      }
    }

    // maxCを選ぶ
    // cout << maxC + 1 << endl;
    last[maxC] = i;
    t[i] = maxC;
    sc[i] = maxS; // satisfactory change
  }

  rep(i, d) { contests[t[i]].push_back(i); }
  srand(time(nullptr));

  while (clock() - start <= 18 / 10 * CLOCKS_PER_SEC) {
    ll cq = rand() % d;
    ll q2 = rand() % 26;
    /*
    cout << cq << endl;
    cout << q2 << endl;
    rep(i, d) {
      cout << t[i];
      if (i != d - 1) { cout << ", "; }
    }
    cout << endl;
    */
    randomImprove(cq, q2);
  }

  rep(i, d) { cout << t[i]+1 << endl; }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3752
import numpy as np

N, M = list(map(int, input().split(' ')))
mat = np.zeros((N, M))
for i in range(N):
  lines = list(map(int, input().split(' ')))
  for j in range(lines[0]):
    mat[i, lines[j+1]-1] += 1

mat_common = np.min(mat, axis=0)
result = np.sum(mat_common)
print(int(result))

Measured memory_bytes: 12500
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;


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

	for (int i = 0; i < n.size()/2; i++) {
		if (n[i] != n[n.size() - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Repi(i, a, b) for(int i = int(a); i < (int)(b); i++)
#define Repl(i, list) for(int i : list)
#define Sort(v) sort(v.begin(), v.end())
#define lli long long int
template<typename _T> void Out(_T x) { cout << x << endl; }
template<typename _T> void PrintVec(vector<_T> vec) { Rep(i, vec.size()) { cout << vec.at(i) << " "; } cout << endl; }

int main()
{
    // input
    int K, S;
    cin >> K >> S;

    // output
    int cnt = 0;
    int z;
    Rep(x, K+1){
        Rep(y, K+1){
            z = S - x - y;
            //cout << x << " " << y << " " << z << endl;
            if (z >= 0 && z <= K) {
                //cout << x << " " << y << " " << z << endl;
                cnt++;
            }
        }
    }

    Out(cnt);

    return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())


#[0], [1], [2]にx, y, hがそれぞれ入る
inf = [list(mi()) for _ in range(N)]

from copy import deepcopy
#ht>=1である情報を1つピックアップ
#ex(example) にその情報を入れる
for eachinf in inf:
  if eachinf[2] >= 1:
    ex = deepcopy(eachinf)
    break

import itertools
#まずpx,pyを決める（productで自動的に決まっている）
for px, py in itertools.product(range(101), repeat=2):
  #px,pyが決まったので、次はその場合のHを求める
  ph = ex[2] + abs(ex[0] - px) + abs(ex[1] - py)
  isrightans = 1
  for x, y, h in inf:
    if h != max(ph - abs(x - px) - abs(y - py),0):
      isrightans = 0
      break
  if isrightans:
    print(px, py, ph)
    exit()

Measured memory_bytes: 41712
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$O = $key->A[0];
$E = $key->X[0][0];
$len = strlen($O);
$ans="";
for($i=0;$i<$len;$i++) {
  $ans = $ans . $O[$i].$E[$i];
}
printf("%s\n",$ans);


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    string s, key;
    vector<int> sub;
    bool flg = true;
    int cnt = 0;

    cin >> s >> key;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < key.size() && j+i < s.size(); j++) {
            if (s[i+j] != key[j]) {
                if (s[i+j] != '?') {
                    flg = false;
                }
            }
            cnt++;
        }
        if (flg && cnt == key.size()) {
            sub.push_back(i);
        }
        flg = true;
        cnt = 0;
    }

    if (sub.empty()) {
        cout << "UNRESTORABLE" << endl;
        return (0);
    }
    else {
        sub[sub.size()-1];

        for (int i = sub[sub.size()-1]; i < sub[sub.size()-1]+key.size(); i++) {
            s[i] = key[i-sub[sub.size()-1]];
        }

        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '?') {
                s[i] = 'a';
            }
        }
    }

    cout << s << endl;

}

Measured memory_bytes: 256
require 'date'

ds = [Date.new(1868, 9, 8), Date.new(1912, 7, 30), Date.new(1926, 12, 25), Date.new(1989, 1, 8)]
$<.each_line do |l|
  d = Date.new *l.split.map(&:to_i)
  case
  when d < ds[0]
    puts 'pre-meiji'
  when d < ds[1]
    puts 'meiji %d %d %d' % [d.year - ds[0].year + 1, d.month, d.day]
  when d < ds[2]
    puts 'taisho %d %d %d' % [d.year - ds[1].year + 1, d.month, d.day]
  when d < ds[3]
    puts 'showa %d %d %d' % [d.year - ds[2].year + 1, d.month, d.day]
  else
    puts 'heisei %d %d %d' % [d.year - ds[3].year + 1, d.month, d.day]
  end
end

Measured memory_bytes: 8972
#11208467
t="abcdefghijklmnopqrstuvwxyz"
s=input()
if s==t[::-1]:print(-1);exit()
if len(s)!=26:
  for i in t:
    if i not in s:print(s+i);exit()
i=25
while s[i-1]>s[i]:i-=1
tt=s[i-1]
ss=list(s[i-1:])
ss.sort()
print(s[:i-1]+ss[ss.index(tt)+1])

Measured memory_bytes: 9052
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n;
  string s;
  set<string> st;
  cin >> n>>s;
  vector<ll> v[10];
  for(int i=0;i<n;i++){
    v[s[i]-'0'].push_back(i);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      auto it = upper_bound(v[j].begin(),v[j].end(),i);
      if(it==v[j].end()) continue;
      ll idx = *it;
      for(int k=0;k<10;k++){
        auto itv = upper_bound(v[k].begin(),v[k].end(),idx);
        if(itv==v[k].end()) continue;
        ll idxv = *itv;
        string val; 
        val += s[i];
        val += s[idx];
        val += s[idxv];
        st.insert(val);
      }
    }
  }
  cout << st.size()<<endl;
}


Measured memory_bytes: 768
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h): #すべての行の塗りつぶし方を2進数で列挙する
 for paint_w in range(2**w): #すべての列の塗りつぶし方を2進数で列挙する
   cnt=0
   for i in range(h): #すべてのi行目j列目の要素についてみる
     for j in range(w):
       if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
         if board[i][j]=='#': #塗りつぶされないマスが黒マスであれば個数を+1する
           cnt+=1
   if cnt==k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
     ans+=1
print(ans)

Measured memory_bytes: 9136
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll out = 0;
    rep(i,N){
        if((i+1)%2==1){
            ll cnt = 0;
            for(ll j=1;j<sqrt(i+1);j++){
                if((i+1)%j==0) cnt++;
            }
            if(cnt==4) out++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

main(){
    string s;cin>>s;
    int g=0,ans=0;
    for(auto c:s){
        if(c=='g'){
            if(g){
                g=0;ans++;
            }
            else g=1;
        }
        else{
            if(g){
                g=0;
            }
            else {
                g=1;ans--;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 512
from sys import stdin
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
import bisect
import heapq


rs = lambda: stdin.readline().strip()
ri = lambda: int(rs())
rsl = lambda: stdin.readline().split()
rim = lambda: map(int, rsl())
ril = lambda: list(rim())

A, B, T = rim()
seconds = A
if T < A:
    print(0)
else:
    cookies = 0
    while seconds <= T:
        cookies += B
        seconds += A

    print(cookies)

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

using namespace std;

int main()
{
    char S[110], T[110];
    cin >> S >> T;
    int len_S = strlen(S);
    char temp[110];
    bool flag = false;
    for(int i = 0; i < len_S; i ++)
    {
        for(int j = 0; j < len_S; j ++)
            temp[j] = S[(i + j) % len_S];
        temp[len_S] = '\0';
        if(strcmp(temp, T) == 0)
        {
            flag = true;
            break;
        }
    }
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve() 
{
    int x , y ;
    cin >> x >> y;
    rep(i,x+1)
    {
        int hell = i*2 + (x - i)*4;
        if(hell==y)
        {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

const int FACT_MAX = 200005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint n;
llint p[5005];
UnionFind uf(5005);
map<llint, llint> mp;
set<llint> S;
vector<llint> vec[2];
llint dp[5005][5005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i];
	
	for(int i = 1; i <= n; i++){
		if(p[i] != -1) uf.unite(i, p[i]);
	}
	for(int i = 1; i <= n; i++){
		mp[uf.root(i)]++;
		if(p[i] == -1) S.insert(uf.root(i));
	}
	
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(S.count(it->first)) vec[0].push_back(it->second);
		else vec[1].push_back(it->second);
	}
	
	llint m = vec[0].size(), ans = modpow(n-1, (int)vec[0].size()) * (llint)vec[1].size() % mod;
	dp[0][0] = 1;
	for(int i = 0; i < m; i++){
		for(int j = 0; j <= m; j++){
			dp[i+1][j] += dp[i][j], dp[i+1][j] %= mod;
			if(j+1 <= m) dp[i+1][j+1] += dp[i][j] * vec[0][i] % mod, dp[i+1][j+1] %= mod;
		}
	}
	for(int i = 2; i <= m; i++){
		ans += dp[m][i] * fact[i-1] % mod * modpow(n-1, m-i) % mod;
		ans %= mod;
	}
	for(int i = 0; i < m; i++) ans += (vec[0][i]-1) * modpow(n-1, m-1) % mod, ans %= mod;
	ans = modpow(n-1, m) * n % mod - ans + mod, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 202928
n, m, x = map(int, input().split())

book = [[0]*(m+1)]*n
result = 10**5 * 13
bit = []

for i in range(n):
    book[i] = list(map(int, input().split()))

for i in range(2**n):
    op = [0]*n
    for j in range(n):
        if ((i >> j) & 1):
            op[n - 1 - j] = 1
    bit.append(op)
    
for i in range(2**n):
    a = bit[i]
    flag = True
    check = [0]*(m+1)
    for j in range(n):
        if a[j] == 1:
            for k in range(m+1):
                check[k] += book[j][k]
    for l in range(1, m+1):
        if check[l] < x:
            flag = False
    if flag == True:
        result = min(result, check[0])
        
if result == 10**5 * 13:
    print(-1)
else:
    print(result)

Measured memory_bytes: 9664
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
//#define int long long

///My functions
void sread ( string &s ){ cin >> s ; s = '_' + s ; }
void sprint ( string &s ){ cout << s.substr( 1 , s.size() ) ; } 

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
long double a ; 
unsigned long long ans , b ; 

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> b >> a ; 
    a *= 100 ; 
    a +=  EPS ; 
    ans = (unsigned long long)a ;

    cout << (unsigned long long)(( ans * b ) / 100 ) ;


    return 0;
}
























Measured memory_bytes: 3772
def print8f(xy):
    from decimal import Decimal, ROUND_HALF_UP
    acc = Decimal("0.00000001")
    x, y = xy
    x = Decimal(str(x)).quantize(acc, rounding=ROUND_HALF_UP)
    y = Decimal(str(y)).quantize(acc, rounding=ROUND_HALF_UP)
    print("{:.8f} {:.8f}".format(x, y))


def kochCurve(p1p2, n, ang):
    from math import sin, cos, radians, sqrt
    if n == 0:
        print8f(p1p2[1])
        return
    p1, p2 = p1p2
    xd3 = (p2[0] - p1[0]) / 3
    yd3 = (p2[1] - p1[1]) / 3
    s = [p1[0] + xd3, p1[1] + yd3]
    t = [p2[0] - xd3, p2[1] - yd3]
    st = sqrt((s[0] - t[0])**2 + (s[1] - t[1])**2)
    u = [s[0] + cos(radians(ang + 60)) * st,
         s[1] + sin(radians(ang + 60)) * st]

    kochCurve([p1, s], n - 1, ang)
    kochCurve([s, u], n - 1, ang + 60)
    kochCurve([u, t], n - 1, ang - 60)
    kochCurve([t, p2], n - 1, ang)


def resolve():
    n = int(input())
    p1p2 = [[0, 0], [100, 0]]
    print8f(p1p2[0])
    kochCurve(p1p2, n, 0)


resolve()



Measured memory_bytes: 6584
#include <iostream>
#include <string>

int main() {
  std::string str;
  std::cin >> str;
  int ca = 0;
  int cb = 0;
  for (int i = 0; i < 3; ++i)
    if (str[i] == 'A') ca += 1;
  	else cb += 1;
  if (ca == 3 || cb == 3) std::cout << "No" << std::endl;
  else std::cout << "Yes" << std::endl;
  
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    ll a,b,c;
    cin >> a >> b >> c;
    if ((c-b-a)<=0) {
        cout << "No" <<endl;
        return;
    }
    ll x = (c-b-a)*(c-b-a);
    auto ans = ((4*a*b) < x) ? "Yes" : "No";
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())
    mod = 10**9+7
    edge = [[] for _ in [None]*n]

    for _ in [None]*(n-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    
    p = -1
    pl = -1
    for i in range(n-1):
        if len(edge[i]) > pl:
            p = i
            pl = len(edge[i])
    
    par = [-2]*n
    par[p] = -1
    tank = []
    new = [p]
    while len(new) > 0:
        tank = []
        for e in new:
            for ko in edge[e]:
                if par[ko] == -2:
                    par[ko] = e
                    tank.append(ko)
        new = tank
    
    d = [-1]*n
    d[p] = k
    tank = []
    new = [p]
    while len(new) > 0:
        tank = []
        for e in new:
            if e == p:
                cnt = 1
            else:
                cnt = 2
            for go in edge[e]:
                if go != par[e]:
                    d[go] = k-cnt
                    cnt += 1
                    tank.append(go)
        new = tank
    
    res = 1
    for e in d:
        res = res*e%mod
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 67400
n = int(input())
a= list(map(int,input().split()))

dp=[0]*n
dp[0] =1000
for i in range(1,n):
    if a[i-1]< a[i]:
        dp[i]= (dp[i-1]//a[i-1])* (a[i]-a[i-1])+ dp[i-1]
    else:
        dp[i]=dp[i-1]
print(dp[n-1])
        

Measured memory_bytes: 8840
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int N = 305;
ld dp[N][N][N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,c1=0,c2=0,c3=0; cin>>n;
    for(int i = 1; i <= n; ++i) {
        int x; cin>>x;
        if(x==1) c1++;
        if(x==2) c2++;
        if(x==3) c3++;
    }
    for(int k = 0; k < N; ++k) 
        for(int j = 0; k+j < N; ++j) 
            for(int i = 0; i+j+k < N; ++i) {
                if(i == 0 && j == 0 && k == 0)
                    continue;
                if(i+j+k > N)
                    continue;
                ld wait = 1.0*n/(i+j+k);
                ld pi = 1.0*i/(i+j+k);
                ld pj = 1.0*j/(i+j+k);
                ld pk = 1.0*k/(i+j+k);
                if(i) 
                    dp[i][j][k] += pi*dp[i-1][j][k];
                if(j)
                    dp[i][j][k] += pj*dp[i+1][j-1][k];
                if(k)
                    dp[i][j][k] += pk*dp[i][j+1][k-1];
                dp[i][j][k] += wait;
            }
    cout.precision(10);
    cout<<fixed<<dp[c1][c2][c3]<<"\n";
}

Measured memory_bytes: 442752
N,M=list(map(int,input().split()))
l=1
r=N
for m in range(M):
    l_,r_ = list(map(int,input().split()))
    l = max(l,l_)
    r = min(r,r_)
    
ans = r-l+1

if ans<0:
    ans=0
print(ans)

Measured memory_bytes: 69824
#include <iostream>
#define ll long long
#define MOD 1000000007
using namespace std;



int main()
{
    int N;
    cin >> N;
    ll A[N];
    ll S[N + 1];
    ll ans = 0;

    for(int i = 0; i < N; i++) cin >> A[i];

    S[0] = 0;
    for(int i = 0; i < N; i++)
    {
        S[i + 1] = S[i] + A[i];
    }

    for(int i = 0; i < N - 1; i++)
    {
        ans += A[i] * ((S[N] - S[i + 1]) % MOD);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6716
import collections
n = int(input())
a = list(map(int,input().split()))
col = collections.Counter(a)

q = int(input())
s=sum(a)
for i in range(q):
  b,c = map(int,input().split())
  s = s - b * col[b] + c * col[b]
  print(s)

  col[c]+=col[b]
  col[b]=0

Measured memory_bytes: 24204
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N; cin>>N;
  vector<int> a(N),b(N),c(N-1);
  for(int i=0;i<N;i++) cin>>a[i], a[i]--;
  for(int i=0;i<N;i++) cin>>b[i];
  for(int i=0;i<N-1;i++) cin>>c[i];
  
  int ans=b[a[0]];
  for(int i=1;i<N;i++){
    ans+=b[a[i]];
    if(a[i-1]+1==a[i]){
      ans+=c[a[i-1]];
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    string s, t; cin>> s >> t;
    int n= s.size(), n2 = t.size();

    int cnt = 0;
    int ans = 1e+9;
    for(int i= 0; i<n-n2+1; i++){
        for(int j= 0; j<n2; j++){
            if(t[j] != s[i+j]) cnt++;
        }
        ans = min(ans, cnt);
        cnt = 0;
    }
    cout<< ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N,M;
  cin >> N >> M;
  if(N == 1 && M == 1)
  {
    cout << 1 << endl;
  }else if( N == 1)
  {
    cout << M-2 <<endl;
  }
  else if(M==1)
  {
    cout << N-2 << endl;
  }
  else cout << (N-2) * (M-2) << endl;
}


Measured memory_bytes: 256