akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        long n=sc.nextLong();
        long a=sc.nextLong();
        long b=sc.nextLong();
        long all=0;
        all+=n/(a+b)*a;
        if(n%(a+b)>a)
            all+=a;
        else
            all+=n%(a+b);
        System.out.println(all);

    }
}





Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
using namespace std;
long long keta(long long a, long long b){
    if(a>b){
        long long cnt=0;
        while(a!=0){
            a /= 10;
            cnt++;
        }
        return cnt;
        return 0;
    }else{
        long long cnt=0;
        while(b!=0){
            b /= 10;
            cnt++;
        }
        return cnt;
        return 0;
    }
}
int main(){
    long long n, a, b, ans=1e15;
    cin >> n;
    for(long long i=1LL; i*i<=n; i++){
        if(n%i!=0) continue;
        else{
            a = i;
            b = n/i;
        }
    }
    cout << keta(a,b) << endl;
    return 0;
}

Measured memory_bytes: 3608
n = int(input())
t_ = 0
xy_ = [0,0]
for _ in range(n):
    t, *xy = map(int, input().split())
    ta = t - t_
    xya = [abs(xy[0]-xy_[0]), abs(xy[1]-xy_[1])]
    if sum(xya) > ta or (ta - sum(xya))%2 != 0:
        print("No")
        break
    t_ = t
    xy_ = xy
else:
    print("Yes")

Measured memory_bytes: 9164
n, k = map(int, input().split())

a = 10 ** 9 + 7
ans = 0
small = 0
big = 0
for i in range(0 , k):
    big += n - i
    small += i
    
for i in range(k, n + 1):
    ans += big - small + 1
    big += n - i
    small += i

print((ans + 1) % a)


Measured memory_bytes: 9184
"""
challenge case

in:
3
1 3
2 3

out:
1
1
1
"""

from collections import deque

def main():
	N, *AB = map(int, open(0).read().split())
	B = AB[1::2]

	E = [[] for _ in range(N + 1)]
	for a, b in zip(*[iter(AB)] * 2):
		E[a].append(b)

	Q = deque([1])
	C = [0] * (N + 1)
	while Q:
		v = Q.popleft()
		c = 0
		for u in E[v]:
			c += 1 + (c + 1 == C[v])
			C[u] = c
			Q.append(u)

	print(max(C))
	for b in B:
		print(C[b])

main()

Measured memory_bytes: 25900
#include <bits/stdc++.h>
#define ll long long
#define st string
#define db double
#define mem(x, y) memset(x, y, sizeof(x))
#define REP(i, n) for(int i = 1; i <= n; i ++)
#define REP0(i, n) for(int i = 0; i < n; i ++)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define dow(i, a, b) for(int i = a; i >= b; i --)
#define REPG(i, u) for(int i = head[u]; ~i; i = e[i].next)
#define zx puts("!!!");
#define mp(x, y) make_pair(x, y)
#define pii pair<int, int>

using namespace std;
const int N = 3e5 + 5;
int asdf = 0, head[N], fa[N], f[N * 3], deg[N];
struct edge{ int to, next; } e[N * 5]; void add(int u, int v) { e[++asdf] = (edge){ v, head[u] }; head[u] = asdf; }
map<int, int>g[N];
queue<pii>q;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

int main()
{
	mem(head, -1);
	int n; scanf("%d", &n); REP(i, n) fa[i] = i;
	int u, v;
	REP(i, 2 * n - 2) { 
		scanf("%d%d", &u, &v), add(u, v), add(v, u), g[u][v] ++, g[v][u] ++;
		deg[u] ++; deg[v] ++;
		if(g[u][v] == 2) q.push(mp(u, v));
	}
	REP(x, n - 1) { bool fl = 0; pii nw; int fx, fy;
		while(!q.empty()) {
			nw = q.front(); q.pop();
			fx = find(nw.first), fy = find(nw.second);
			if(fx != fy) { fl = 1; break; }
		} if(!fl) { puts("NO"); return 0; }
		if(deg[fx] > deg[fy]) swap(fx, fy);
		fa[fx] = fy; g[fx][fy] = g[fy][fx] = 0;
		deg[fy] --; deg[fx] --; REPG(i, fx) {
			int v = find(e[i].to); if(v == fy || !g[fx][v]) continue;
			g[fx][v] = g[v][fx] = 0; deg[fx] --;
			g[v][fy] ++; g[fy][v] ++; deg[fy] ++; if(g[v][fy] == 1) add(v, fy), add(fy, v);
			if(g[v][fy] == 2) q.push(mp(v, fy));
		}
	} puts("YES");
 	return 0;
}

/*

3
1 2
2 3
1 3
3 2

5
1 2
2 3
3 4
4 5
3 4
2 4
1 4
1 5

*/

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

typedef long long ll;

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

    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int ans = 0;

    while(true)
    {
        bool flag = false;
        rep(i, n){
            if((a.at(i) % 2) != 0) flag = true;
            a.at(i) /= 2;
        }
        if(flag) break;
        ans++;
    }

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

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

int main()
{
    int N;
    cin>>N;
    vector<int>A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        B[A[i]-1]=i+1;
    }
    for(int i=0;i<N;i++){
        cout<<B[i]<<" ";
    }

}

Measured memory_bytes: 1536
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


ll up(dd n){
    ll k=(ll)n;
    if(abs(k-n)<EPS)return k;
    else return k+1;
}
struct obj{
    dd l,r;
    ll num;
};

ll n;
void calc(vector<ll>&vv,ll *dp){
    vector<dd>v(n);
    rep(i,0,n-1)v[i]=log((dd)vv[i])/log((dd)4.0);
    
    deque<obj>set;
    ll cnt=0;
    for(ll i=n-1;i>=0;i--){
        dd val=v[i];
        ll c=1;
        while(!set.empty()&&val+EPS>set[0].l){
            ll kai=up(val-set[0].l);
            cnt+=set[0].num*kai;
            c+=set[0].num;
            val=set[0].r+kai;
            set.pop_front();
        }
        set.push_front({v[i],val,c});
        dp[i]=cnt;
    }
}

int main(){fastio
    cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    vector<ll>v;
    rep(i,0,n-1)v.pb(a[i]);
    ll d1[n],d2[n];
    calc(v,d1);
    //rep(i,0,n-1)cout<<d1[i]<<" ";cout<<endl;
    vector<ll>w;
    reverse(v.begin(),v.end());
    calc(v,d2);
    rep(i,0,(n-1)/2){
        swap(d2[i],d2[n-1-i]);
    }
    ll ans=inf;
    rep(i,0,n){
        ll sum=i;
        if(i-1>=0)sum+=2*d2[i-1];
        if(i<=n-1)sum+=2*d1[i];
        //cout<<sum<<" ";
        chmin(ans,sum);
    }cout<<endl;
    //rep(i,0,n-1)cout<<d1[i]<<"   ";cout<<endl;
    //rep(i,0,n-1)cout<<d2[i]<<"   ";cout<<endl;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 19512
use std::io::{stdin, Read};

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

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

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let rgb: Vec<usize> = it
        .next()
        .unwrap()
        .chars()
        .map(|c| match c {
            'R' => 0,
            'G' => 1,
            'B' => 2,
            _ => unreachable!(c),
        })
        .collect();
    let mut fr = vec![vec![]; 3];
    for i in 0..3 {
        fr[i] = (0..n).filter(|&j| rgb[j] == i).collect::<Vec<_>>();
    }
    let mut ret = 0;
    for i in 2..n {
        let ri = rgb[i];
        for offset in 0..2 {
            let ni = fr[(ri + 1 * (offset + 1)) % 3]
                .binary_search(&i)
                .unwrap_or_else(|x| x);
            for &j in &fr[(ri + 1 * (offset + 1)) % 3][..ni] {
                let c = fr[(ri + 2 * (offset + 1)) % 3]
                    .binary_search(&j)
                    .unwrap_or_else(|x| x);
                ret += c;
            }
        }
    }
    for i in 0..n {
        for j in 1..n {
            if let (ai, Some(&bi), Some(&ci)) = (rgb[i], rgb.get(i + j), rgb.get(i + j + j)) {
                if ai != bi && ai != ci && bi != ci {
                    ret -= 1;
                }
            }
        }
    }
    println!("{}", ret);
}

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

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


Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int k, a, b;
	cin >> k >> a >> b;
	if (a <= b - b % k) {
		cout << "OK\n";
	} else {
		cout << "NG\n";
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<typename T> struct BinaryIndexedTree {
  vector<T> bit;
  BinaryIndexedTree(int n) : bit(n + 1, 0) {}
  T sum(int i) {
    T s = 0;
    for (; i > 0; i -= i & -i) s += bit[i];
    return s;
  }
  void add(int i, T x) {
    for (; i <= bit.size(); i += i & -i) bit[i] += x;
  }
};

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

  int n, q; cin >> n >> q;
  BinaryIndexedTree<ll> bit(n);
  for (int i = 0; i < q; ++i) {
    int com, x, y; cin >> com >> x >> y;
    if (com) {
      cout << bit.sum(y) - bit.sum(x - 1) << endl;
    } else {
      bit.add(x, y);
    }
  }
  return 0;
}



Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int ans;
  int a,b,c;
  cin >> a >> b >> c;
  if(a != b  && b!= c && a != c) ans = 3;
  else if(a != b || b != c || c != a) ans=2;
  else ans = 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];

    long r;
    int k = K;
    while (k <= N) {
        ++r;
        k += K;
    }
    r ^^= 3;

    if (K % 2 == 0) {
        long s;
        k = K / 2;
        while (k <= N) {
            ++s;
            k += K;
        }
        r += s^^3;
    }

    writeln(r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    char ch[n+1];
    strcpy(ch,s.c_str());
    for(int i=0;i<n-2;i++)
    {
        if(ch[i]=='A'&&ch[i+1]=='B'&&ch[i+2]=='C')
            {
                cnt++;
                i++;
            }
    }
    cout<<cnt;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  ll n, m;
  cin >> n >> m;
  vector<ll> v(n, 0);
  for(int i = 0; i < n; i++) cin >> v[i];
  vector<ll> sum;
  sum.push_back(0);
  for(int i = 0; i < n; i++)
  {
    sum.push_back(sum[i] + v[i]);
  }
  for(int i = 0; i < n+1; i++)
  {
    sum[i] %= m;
  }
  // sum.erase(sum.begin());
  map<int, int> mp;
  ll count = 0;
  for(int i = 0; i <= n; i++)
  {
    count += mp[sum[i]];
    mp[sum[i]]++;
  }

  cout << count << endl;


}

Measured memory_bytes: 4724
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if((100*a + 10*b + c) % 4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
				
		}
		
		
		sc.close();
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 1e9+7;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;


int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll n,x,d;
	cin>>n>>x>>d;
	
	if(x == 0  && d == 0)
	{
		cout<<1<<endl;
		return 0;
	}
	if(d == 0)
	{
		cout<<n+1<<endl;
		return 0;
	}
	if(d < 0)
	{
		d = -d;
		x = -x;

	}
	map<ll,vector<pair<ll,ll>>> range;
	set <ll> modulos;

	for(ll i = 0; i<=n ; i++)
	{
		//taking groups of i elements , it turns out they form a group starting from beg and then incrementing by d everytime, finally ending at start+shift
		pair<ll,ll> p;
		ll beg = (i)*x + (((i-1)*(i))/2)*d;
		ll shift = (i)*(n-i)*d;

		p = mp(beg,beg+shift);
		//intervals starting at same modulo d may possibly intersect etc. hence we use a map to vector
		range[((beg%d)+d)%d].pb(p);
		modulos.insert(((beg%d)+d)%d);
	}

	ll cnt = 0;
	for(auto itr : modulos)
	{
		
		sort(range[itr].begin(),range[itr].end());
		
		ll curl = range[itr][0].ff , curr = range[itr][0].ss;
		for(ll i = 0; i<range[itr].size(); i++)
		{
			ll l = range[itr][i].ff , r = range[itr][i].ss;
			if(l<=curr)
			{
				curr = max(r,curr); //merging segments if l of one lies within r of first
			}
			else
			{
				
				cnt+= abs((curr-curl)/d) + 1; //in range r to l, clearly (r-l)/d + 1 elements are there 
											  //as elements will be of form start , start+d...start+k*d;
				curr = r;
				curl = l;

			}

			if(i == range[itr].size()-1)
			{
				//special case when we reach end of loop, no matter what, we must count the distinct elements given to us by the current maintained l,r
				cnt+= abs((curr-curl)/d) + 1;
			}
		}
	}

	cout<<cnt<<endl;
	return 0;
	
}

Measured memory_bytes: 31488
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    lint N;
    cin >> N;
    lint ans=powmod(10,N);
    ans=(ans+powmod(8,N)+MOD)%MOD;
    ans=(ans-powmod(9,N)+MOD)%MOD;
    ans=(ans-powmod(9,N)+MOD)%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    map<char,int>m;
    rep(i,s.size()){
        if(m.count(s.at(i))){
            m[s.at(i)]++;
        }else{
            m[s.at(i)]++;
        }
    }
    for (auto p :m) {
        auto key = p.first;
        auto value = p.second;
    // key, valueを使う
        if(value!=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3624
package main

import "fmt"

func cols(n int) int {
	cnt := 0
	for n > 0 {
		cnt++
		n /= 10
	}
	return cnt
}

func main() {
	var N int
	fmt.Scan(&N)
	ans := 0
	for i := 1; i <= N; i++ {
		if cols(i)%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: f64 = 0.0;
    for i in 1..n + 1 {
        let mut a: f64 = 1.0 / n as f64;

        let mut count: u32 = 0;
        let mut p = i;
        while p < k {
            p *= 2;
            count += 1;
        }

        let a = (1.0 / n as f64) * (1.0 / 2_u32.pow(count) as f64);
        ans += a;
    }

    return ans.to_string();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define YES printf("YES\n")
#define NO printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e15;
const int M = (1e9)+7;
const ll N = (1e9);  // check the limit, man
int main()
{
    int i,n,k,s,m;
    in3(n,k,s);
    m=s+1;
    if(s==N)
        m=1;
    rep(i,k)
        pr(s);
    rep(i,n-k)
        pr(m);
    lin;
}






Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace shoboi_program
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] inputStrArray = Console.ReadLine().Split(' ');

            Int32 nnn = 0;
            Int32.TryParse(inputStrArray[0], out nnn);
            Int32 mmm = 0;
            Int32.TryParse(inputStrArray[1], out mmm);

            // N個の偶数ボール　// M個の奇数ボールがある
            // 2つ選んで足したら偶数になるのは何通り？

            // 偶数2個 or 奇数2個の組み合わせを求める
            Int32 xCombi = (nnn * (nnn - 1))/2;
            Int32 yCombi = (mmm * (mmm - 1))/2;

            Console.Write("{0}", xCombi + yCombi); // 文字や数値の出力
        }
    }
}

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

using namespace std;

int n;
double p;
vector<double> v;
double dp[3000][1501];
double more_heads(int i, int left)
{
    if(left==0)
        return 1;
    if(i==n && left)
        return 0;

    if(dp[i][left]!=-1)
        return dp[i][left];
    else
        return dp[i][left]=more_heads(i+1,left-1)*v[i] + more_heads(i+1,left)*(1-v[i]);
}

int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>p;
        v.push_back(p);
    }

    for(int i=0; i<=n; i++)
        for(int j=0; j<=(n+1)/2; j++)
            dp[i][j]=-1;

    cout<<setprecision(10)<<more_heads(0,(n+1)/2)<<endl;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    int q;
    cin >> q;

    deque<char> dq;

    int start = 0;
    for (auto x: s)dq.push_back(x);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;

        if (t == 1)start ^= 1;
        else {
            int f;
            cin >> f;

            char ch;
            cin >> ch;

            if (f == 1) {
                if (start == 1)dq.push_back(ch);
                else dq.push_front(ch);
            } else {
                if (start != 1)dq.push_back(ch);
                else dq.push_front(ch);
            }
        }
    }
    if (start == 1) {
        for (int i = dq.size() - 1; i >= 0; i--)cout << dq[i];
    }
    else for(auto x: dq)cout << x;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<vector>
#include<string>
using namespace std;
string s;
int mi,hi,ans;
int main(){
  cin>>s;
  hi=0;
  mi=s.size()-1;
  while(mi>=hi){
    if(s[hi]==s[mi]){hi++;mi--;}
    else if(s[hi]=='x'){ans++;hi++;}
    else if(s[mi]=='x'){ans++;mi--;}
    else {cout<<-1<<endl;return 0;}
  }
  cout<<ans<<endl;
  return 0;
}


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

string A,B,C;
int main (){
    cin >> A >> B >> C;
    int a=0,b=0,c=0;
    char x = 'a';
    while(true){
        if (x == 'a') {
            x = A[a];
            a++;
            if( A.length() < a) {
                cout << 'A' << endl;
                return 0;
            }
        } else if( x == 'b') {
            x = B[b];
            b++;
            if( B.length() < b) {
                cout << 'B' << endl;
                return 0;
            }
        } else {
            x = C[c];
            c++;
            if( C.length() < c) {
                cout << 'C' << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #define int long long
using namespace std;
int C(int x,int y){
    int ans = 1;
    for(int i = x,j =0; j<y; i--,j++)
        ans*=i;
    int dom = 1;
    for(int i =1; i<=y; i++)
        dom*=i;
    return (ans/dom);

}
 main()
{
    int n,m;
    cin>>n>>m;
    cout<<C(n,2) + C(m,2)<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;

int n, k;
int a[N];
int cnt[N];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int ite = 0; ite < 100; ite++) {
        if (ite == k) break;
        memset(cnt, 0, sizeof cnt);
        for (int i = 1; i <= n; i++) {
            cnt[max(1, i - a[i])] += 1;
            cnt[min(n, i + a[i]) + 1] -= 1;
        }
        for (int i = 1; i <= n; i++) {
            cnt[i] += cnt[i - 1];
            a[i] = cnt[i];
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << " "; 
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5228
#include<iostream>
#include<string>
#include<stack>
using namespace std;

int main() {
	string s;
	while(1) {
		getline(cin, s);
		if(s.length()==1 && s[0]=='.') break;
		
		bool ok = true;
		stack<int> st;
		for(int i=0; i<s.length() && ok; ++i) {
			if(s[i]=='(') {
				st.push(0);
			}else if(s[i]=='[') {
				st.push(1);
			}else if(s[i]==')') {
				if(st.empty() || st.top()!=0) ok = false;
				st.pop();
			}else if(s[i]==']') {
				if(st.empty() || st.top()!=1) ok = false;
				st.pop();
			}
		}
		cout << (st.empty() && ok ? "yes" : "no") << endl;
	}
	return 0;
}

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


using namespace std;

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


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


    int c = abs(a - b);

    cout << (c * (c + 1)) / 2 - max(a, b) << '\n';


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int n, k[105], ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	for (int i = 0; i < n; ++i) {
		for (int j = n - 1; j > i; --j) {
			if (k[j] < k[j - 1]) {
				swap(k[j - 1], k[j]);
				++ans;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		cout << k[i];
		if (i != n - 1) { cout << " "; }
		else { cout << endl; }
	}
	cout << ans << endl;
}



Measured memory_bytes: 3124
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define SQR(X) ( (X) * (X) )



int main()
{
   long i,j,k,l;
   long n;
   static int tarou,hanako;
   char t[103],r[103];


   cin >> n;

   for(i=0;i<n;i++) {
      cin >> t; 
      cin >> r;
      if(strcmp(t,r) > 0)
         tarou += 3;
      else if(strcmp(t,r) < 0)
         hanako += 3;
      else {
         tarou++; hanako++;
      }
   }

   printf("%d %d\n",tarou,hanako);

      


   return 0;
}

Measured memory_bytes: 1148
str = []
m = []
h = []

while True:
    str_value = input()
    if str_value == "-":
        break
    else:
        str.append(str_value)
        m_value = int(input())
        m.append(m_value)
        h_row = []
        for i in range(m_value):
            h_value = int(input())
            h_row.append(h_value)
        h.append(h_row)

for index,i in enumerate(str):
    for j in h[index]:
        i = i[j:]+i[0:j]
    print(i)


Measured memory_bytes: 5600
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, k, now;
  double ans = 0.0;
  scanf("%lld%lld", &n, &k);
  for(i = 1; i <= n; ++i) {
    now = i;
    while(now < k) now *= 2;
    ans += (double)i / now;
  }
  printf("%.12lf", ans / n);
  return 0;
}

Measured memory_bytes: 128
A,B,C,D = map(int,input().split())
if A <= C:
  if D <= B:
    print(D-C)
  elif C <= B:
    print(B-C)
  else:
    print(0)
else:
  if B <= D:
    print(B-A)
  elif A <= D:
    print(D-A)
  else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#define ll long long
using namespace std;

int main(){
  ll n,k,max; cin >> n;
  k = (ll)pow(n,0.5);
  max=1;
  
  for(int i=2; i<=k; i++){
    if(n%i==0){max=i;}
  }
  
  cout<<max+n/max-2;
  
  return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A2175
Title Whist
*/
#include <stdio.h>
#include <string.h>
//Global data section
char trump;
char *grade="23456789TJQKA";
char card[4][13][2];
//
compare_same_suit(char n1,char n2)
{
        int p1,p2;
        p1=strchr(grade,n1)-grade;
        p2=strchr(grade,n2)-grade;
        return((p1>p2)?1:0);
}
compare2(char * a,char * b,char trump,char base)
{
        if(a[1]==b[1])
                return(compare_same_suit(a[0],b[0]));
        if(a[1]==trump)
                return(1);
        if(b[1]==trump)
                return(0);
        if(a[1]==base)
                return(1);
        return(0);

}
int compare_trick(char * n,char * e,char * s,char * w,char trump,char base)
{
#ifdef DEBUG2
        printf("%.2s %.2s %.2s %.2s %c %c\n",n,e,s,w,trump,base);
#endif
        int ret;
        ret =compare2(n,e,trump,base);
        ret+=compare2(n,s,trump,base);
        ret+=compare2(n,w,trump,base);
        if(ret==3)
                return(0);  //N
        ret =compare2(e,n,trump,base);
        ret+=compare2(e,s,trump,base);
        ret+=compare2(e,w,trump,base);
        if(ret==3)
                return(1); //E
        ret =compare2(s,n,trump,base);
        ret+=compare2(s,e,trump,base);
        ret+=compare2(s,w,trump,base);
        if(ret==3)
                return(2); //E
        ret =compare2(w,n,trump,base);
        ret+=compare2(w,s,trump,base);
        ret+=compare2(w,e,trump,base);
        if(ret==3)
                return(3);
}
main()
{
        int i,j,dealer,ew,ns,win;

        while(EOF!=scanf("%c",&trump) && trump != '#')
        {
                for(i=0;i<4;i++)
                        for(j=0;j<13;j++)
                                scanf("%s ",&card[i][j][0]);

                dealer=0;
                ew=0;ns=0;
                for(i=0;i<13;i++)
                {
                        win=compare_trick(card[0][i],card[1][i],
                                          card[2][i],card[3][i],
                                          trump,card[dealer][i][1]);
#ifdef DEBUG
                        printf("WIN=%c %c %c\n",
                               "NESW"[win],card[win][i][0],card[win][i][1]);
#endif
                        dealer=win;
                        if(win & 1)
                                ew++;
                        else
                                ns++;
                }
                if(ns>ew)
                        printf("NS %d\n",ns-6);
                else
                        printf("EW %d\n",ew-6);
        }
return(0);
}

Measured memory_bytes: 548
N = int(input())
A = input()
B = input()
C = input()
total = 0
for i in range(N):
  aaa = set()
  aaa.add(A[i])
  aaa.add(B[i])
  aaa.add(C[i])
  ans = len(aaa) -1
  total += ans
print(total)
  

Measured memory_bytes: 9184
#include <cassert>
#include <algorithm>
#include <cstdio>

static const size_t n_max = 1000;
static struct {
  int x, y, r;
} dp[2][n_max+1];

int main() {
  size_t n;
  for (;;) {
    scanf("%zu\n", &n);
    if (!n)
      return 0;
    int r = 0;
    for (size_t i = 0; i < 2; i++)
      for (size_t j = 0; j <= n; j++) {
        dp[i][j].x = 0;
        dp[i][j].y = 0;
        dp[i][j].r = 0;
      }
    for (size_t i = 0; i < n; i++) {
      for (size_t j = 1; j <= n; j++) {
        switch (getchar()) {
          case '.':
            dp[(i+1)%2][j].x = 1 + dp[(i+1)%2][j-1].x;
            dp[(i+1)%2][j].y = 1 + dp[i%2][j].y;
            dp[(i+1)%2][j].r = 1 + std::min(dp[(i+1)%2][j-1].x, std::min(dp[i%2][j].y, dp[i%2][j-1].r));
            break;
          case '*':
            dp[(i+1)%2][j].x = 0;
            dp[(i+1)%2][j].y = 0;
            dp[(i+1)%2][j].r = 0;
            break;
        }
        r = std::max(r, dp[(i+1)%2][j].r);
      }
      assert(getchar() == '\n');
    }
    printf("%d\n", r);
  }
}

Measured memory_bytes: 2704
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int r;
  cin >> r;
  cout << r * r << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int x, y, a, b;
    cin >> x >> y;
    string ans = "No";
    rep(i, x + 1){
        if(i * 2 + (x - i) * 4 == y){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

inline int add(int x , int y){return (x%mod + y%mod)%mod;}
inline int mul(int x , int y){return (x%mod *1LL* y%mod)%mod;}

int n;
vector<int>tree[100005];
int dp[100005][2];

void dfs(int x , int p = -1){

    dp[x][0] = dp[x][1] = 1;

    for(int u : tree[x]){
        if(u == p)continue;

        dfs(u,x);

        dp[x][0] = mul(dp[x][0] , add(dp[u][0],dp[u][1]));

        dp[x][1] = mul(dp[x][1] , dp[u][0]);
    }

}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    scn(n);
    for(int i=1; i<n; i++){
        int x,y;
        scn2(x,y);
        tree[x].pb(y);
        tree[y].pb(x);
    }

    dfs(1,-1);

    cout<<add(dp[1][0],dp[1][1]);

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+1;

int main()
{
	int n;
	cin >> n;
	double a[n];
	long double sum = 0;
	for(int i=0; i<n; i++) cin >> a[i], sum += 1/a[i];
	cout << fixed << setprecision(5) << 1 / sum << endl;
}
	


Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

	int n,m;
  cin>>n>>m;
  priority_queue<int>pq;
  rep(i,n){
    int a;cin>>a;
    pq.push(a);
  }
  while(m--)if(!pq.empty()){
      int p=pq.top();
      pq.pop();
      p/=2;
      if(p)pq.push(p);
    }
    int s=0;
    while(!pq.empty()){
      s+=pq.top();
      pq.pop();
    }
    cout<<s<<endl;
}


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

int main(){
  int N;
  cin >> N;
  int count = 0;
  for(int i = 0; i < N; i++){
    int ai;
    cin >> ai;
    if(i%2 == 0 && ai%2 == 1){
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
char a[205], b[205];
char s[205];
int main(){
	cin>>a+1;
	cin>>b+1;
	int ok = 1;
	int n = strlen(a+1);
	int t  = 0;
	while(true){
		t++;
		if(t > n){
			ok = 1;
			break;
		}
		if(strcmp(a+1, b+1) == 0) {
			ok = 2;
			break;
		}
		int x = a[n];
		for(int i = n; i > 1; i--){
			a[i] =  a[i-1];
		}
		a[1] = x;
	}
	if(ok == 2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int l,r,d;
	int ans=0;
	cin >>l>>r>>d;
	for(int i=l;i<=r;i++){
		if(i%d==0){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	vector<int> c(4);
	for (int i = 0; i < 3; ++i) {
		int a, b;
		cin >> a >> b;
		++c[a - 1];
		++c[b - 1];
	}

	sort(c.begin(), c.end());
	if (c[0] == c[1] and c[0] == 1 and c[2] == c[3] and c[2] == 2) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}

	return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <math.h>

int main (){
  double x1, y1, x2, y2;
  double distance;

  scanf ( "%lf %lf %lf %lf", &x1, &y1, &x2, &y2 );

  distance = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

  printf("%lf\n", distance);

}

Measured memory_bytes: 1816
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cstring>

using namespace std;

int main()
{
	long long a, b, u, v, t;

	scanf("%lld %lld", &a, &u);
	scanf("%lld %lld", &b, &v);
	scanf("%lld", &t);

	if (u <= v)
	{
		printf("NO\n");
	}

	else
	{
		const long long dist = abs(a - b);
		const long long speed = u - v;

		if (dist <= speed * t)
		{
			printf("YES\n");
		}

		else
		{
			printf("NO\n");
		}
	}

 	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, count = 0;
    cin >> n >> m;
    vector<ll> h(n);
    map<ll, ll> good;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
        good[i] = 1;
    }
    for(int i = 0; i < m; i++) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        if(h[x] < h[y]) {
            good[x] = false;
        } else if(h[x] > h[y]) {
            good[y] = false;
        } else {
            good[x] = false;
            good[y] = false;
        }
    }
    for(int i = 0; i < n; i++) {
        if(good[i]) {
            count++;
        }
    }
    cout << count << "\n";
    return 0; 
}

Measured memory_bytes: 25908
n= int(input())
dp=[2000000000]*(n+1)
dp[0]=0

for i in range(n+1):
    k=1
    while k<=i:
        dp[i]=min(dp[i],dp[i-k]+1)
        k*=6
    k=9
    while k<=i:
        dp[i]=min(dp[i],dp[i-k]+1)
        k*=9
print(dp[n])


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

main(){
  int h,w;cin >> h >> w;
  string board[h];for(int i=0;i<h;i++) cin >> board[i];
  const int dy[4]={0,1,0,-1};
  const int dx[4]={1,0,-1,0};
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j] == '.') continue;
      
      if(board[i][j] == '#'){
        bool check = false;
        for(int k=0;k<4;k++){
          int ny = j + dy[k];
          int nx = i + dx[k];
          if(ny<0 || ny>=w) continue;
          if(nx<0 || nx>=h) continue;
          if (board[nx][ny] == '#'){
            check = true;
          }
        }
        if(check){
          continue;
        } else {
          cout << "No" << endl;
          return 0;
        }
      }
      
    }
  }
  cout << "Yes" << endl;
  return 0;
}




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

int K, a[555][555];

int main(void) {
  scanf("%d", &K);
  if(K == 1) {
    printf("1\n1\n");
    return 0;
  }
  int n = (K + 1) / 2;
  if(n & 1) n++;
  for(int i = 0; i < n; i += 2) {
    for(int j = 0; j < n; j++) {
      a[i][j] = (i + j) % n + 1;
    }
  }
  for(int i = 1; i < n; i += 2) {
    for(int j = 0; j < n; j++) {
      a[i][j] = a[i - 1][j] + n;
      if(a[i][j] > K) {
	a[i][j] = a[i - 1][(j + 1) % n];
      }
    }
  }
  printf("%d\n", n);
  for(int i = 0; i < n; i++, puts("")) {
    for(int j = 0; j < n; j++) {
      printf("%d ", a[i][j]);
    }
  }
  return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#define N 20
int main(void){
  int i,n,l[N]={0},max,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",l+i);
  }
  max=l[0];
  sum+=l[0];
  for(i=1;i<n;i++){
    if(l[i]>max){
      max=l[i];
    }
    sum+=l[i];
  }
  sum-=max;
  if(max<sum){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

int n, m, p[101010], y[101010];
vector<vector<int>> pref(101010, vector<int>(0));

int main(){
  cin >> n >> m;
  rep(i, m){
    cin >> p[i] >> y[i];
    pref.at(p[i]).push_back(y[i]);
  }
  rep(i, n + 1){
    sort(pref.at(i).begin(), pref.at(i).end());
  }
  rep(i, m){
    auto itr = lower_bound(pref.at(p[i]).begin(), pref.at(p[i]).end(), y[i]);
    int num = itr - pref.at(p[i]).begin();
    long long res = p[i] * 10e5 + num + 1;
    cout << setfill('0') << setw(12) << res << endl;
  }
  return 0;
}


Measured memory_bytes: 7808
from collections import deque

n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]
arr = []

def f(p):
    if len(p) == n+1:
        arr.append(p[:-1])
        return
    while p[-1] <= m:
        f(p + [p[-1]])
        p[-1] += 1

f([1])

ans = 0
for p in arr:
    score = 0
    for a, b, c, d in queries:
        if p[b-1] - p[a-1] == c:
            score += d
    ans = max(ans, score)

print(ans)


Measured memory_bytes: 23212