akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c, d = map(int, input().split())
    graph[a].append((b, c, d))
    graph[b].append((a, c, d))
query = [[int(x) for x in input().split()] for _ in range(Q)]

depth = [0] * (N+1)
U = 17
ancestor = [[0] * (U+1) for _ in range(N+1)]

q = [(1, 0, 0)]
while q:
    qq = []
    for x, d, parent in q:
        depth[x] = d
        ax = ancestor[x]
        ax[0] = parent
        for i in range(d.bit_length()-1):
            ax[i+1] = ancestor[ax[i]][i]
        for y, _, _ in graph[x]:
            if y == parent:
                continue
            qq.append((y, d+1, x))
    q = qq

def LCA(x, y):
    dx = depth[x]
    dy = depth[y]
    if dx > dy:
        x, y = y, x
        dx, dy = dy, dx
    diff = dy - dx
    while diff:
        step = diff & (-diff)
        y = ancestor[y][step.bit_length()-1]
        diff -= step
    while x != y:
        j = 0
        while ancestor[x][j] != ancestor[y][j]:
            j += 1
        if j == 0:
            return ancestor[x][0]
        x = ancestor[x][j-1]
        y = ancestor[y][j-1]
    return x

tasks = [[] for _ in range(N+1)]
for i, (x, y, u, v) in enumerate(query):
    tasks[u].append((i, x, y, 1))
    tasks[v].append((i, x, y, 1))
    tasks[LCA(u, v)].append((i, x, y, -2))

answer = [0] * Q

def dfs(x = 1, sums = [0] * (N+1), nums = [0] * (N+1), total = 0, parent = 0):
    for i, c, d, coef in tasks[x]:
        answer[i] += coef * (total - sums[c] + nums[c] * d)
    for y, c, d in graph[x]:
        if y == parent:
            continue
        sums[c] += d
        nums[c] += 1
        total += d
        dfs(y, sums, nums, total, x)
        sums[c] -= d
        nums[c] -= 1
        total -= d
    return

dfs()

print('\n'.join(map(str, answer)))


Measured memory_bytes: 219616
#include <bits/stdc++.h>
using namespace std;
typedef complex <double> C;

class Point{
public:
  double x;
  double y;
  Point operator + (Point p)const{
    return (Point){x + p.x, y + p.y};
  }
  bool operator < (Point p)const{
    return x*x + y*y < p.x*p.x + p.y*p.y;
  }
};


bool throughO(Point p, Point v){
  //  if(abs(v.x) < 1e-7 ){
  //    return abs(p.y) < 1e-7;
  //  }

  return abs(p.x*v.y-p.y*v.x) < 1e-8;

  //  double a = v.y / v.x;
  //  return abs(p.y - a*p.x) < 0.0000001;
}


int main(void){
  double D;
  while(cin >> D&&D){


    Point p, v;
    double ans = 0;

    cin >> p.x >> p.y >> v.x >> v.y;
    double len = sqrt(p.x * p.x + p.y * p.y);


    if(!throughO(p, v) ){
      cout << "impossible" << endl;
      //impossible
      continue;
    }

    double naiseki = -p.x * v.x + -p.y * v.y;
    if(abs(naiseki - len*sqrt(v.x*v.x + v.y*v.y)) > 0.000001){
      ans = 1 + (1 - len);
    }else{
      ans = len;
    }
    if(ans < D + 0.000001)
      printf("%.10f\n", ans);
    else
      cout << "impossible" << endl;
    //impossible
  }
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	bool flags[31];
	fill(flags,flags+31,false);
	for(int i = 0; i < 28; i++){
		int num;
		cin >> num;
		flags[num] = true;
	}

	for(int i = 1; i <= 30; i++){
		if(!flags[i]){
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
function main()
  n=parse(Int,readline())
  m=vcat([(x->parse(Int,x)).(split(i))' for i in readlines()]...)
  print(sum([sqrt((m[i,1]-m[j,1])^2+(m[i,2]-m[j,2])^2) for i=1:n for j=1:n])/n)
end
main()

Measured memory_bytes: 184236
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(3),b(3);
    cin >> a[0] >> a[1] >> a[2];
    cin >> b[0] >> b[1] >> b[2]; 
    vector<ll> dp(n+1,-1);
    dp[0] = n;
    rep(i,0,3){
        rep(j,0,n){
            if(dp[j]<0 || (j+a[i])>n) continue;
            chmax(dp[j+a[i]],dp[j]+b[i]-a[i]);
        }
    }
    ll m = 0;
    rep(i,0,n+1){
        chmax(m,dp[i]);
    }
    dp.assign(m+1,-1);
    dp[0] = m;
    rep(i,0,3){
        rep(j,0,m+1){
            if(dp[j]<0 || (j+b[i])>m) continue;
            chmax(dp[j+b[i]],dp[j]+a[i]-b[i]);
        }
    }
    ll ans = 0;
    rep(i,0,m+1){
        chmax(ans,dp[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int get_ans(long long X){
	int ret = 0;
	if(X<0)return ret;
	
	while(X!=0){
		ret += X%10;
		X/=10;
	}
	
	return ret;
}

int main(){
	
	long long N;
	cin>>N;
	
	int ans = 0;
	
	for(int i=0;i<18;i++){
		string s = to_string(N);
		reverse(s.begin(),s.end());
		for(int j=0;j<i;j++)s[j] = '0';
		reverse(s.begin(),s.end());
		
		long long x = stoll(s);
		
		ans = max({ans,get_ans(x),get_ans(x-1)});
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n,m; cin>>n>>m;
	vector<int> ok;
	char ch;
	For(i,0,n){
		cin>>ch;
		if(ch=='0') ok.emplace_back(n-i);
	}
	sort(all(ok));
	int now=0;
	vector<int> ans;
	while(now!=n){
		int nxt=*prev(upper_bound(all(ok),now+m));
		if(nxt==now){
			cout<<"-1\n";
			return 0;
		}
		ans.emplace_back(nxt-now);
		now=nxt;
	}
	reverse(all(ans));
	For(i,0,sz(ans)-1) cout<<ans[i]<<" \n"[i==sz(ans)-1];
	return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int n, a[100000];

int gcd(int x, int y) {
	while (x != y) {
		if (x%y == 0) {
			x = y;
		}
		else if (y%x == 0) {
			y = x;
		}
		else if (x > y) {
			x -= y*(x/y);
		}
		else if (y > x) {
			y -= x*(y/x);
		}
	}
	return y;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int p = gcd(a[0], a[1]);
	for (int i = 2; i < n; i++) {
		p = gcd(p, a[i]);
	}
	cout << p;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main{

    static int[][] dp;
    public static void main(String[] args){
        Scanner ir=new Scanner(System.in);
        outer:
        for(;;){
            int n=ir.nextInt();
            if(n==0){
                System.exit(0);
            }
            int[] a=new int[n];
            for(int i=0;i<n;i++){
                a[i]=ir.nextInt();
            }
            dp=new int[n][n];
            int MIN=-(1<<30);
            for(int i=0;i<n;i++){
                Arrays.fill(dp[i],MIN);
                dp[i][i]=0;
            }
            System.out.println(dfs(0,n-1,a));
        }
    }

    static int dfs(int l,int r,int[] a){
        if(l>=r){
            return 0;
        }
        if(dp[l][r]>=0){
            return dp[l][r];
        }
        int res=dfs(l+1,r,a);
        for(int i=l+1;i<=r;i++){
            if(Math.abs(a[l]-a[i])<=1&&dfs(l+1,i-1,a)==i-l-1){
                res=Math.max(res,2+dfs(l+1,i-1,a)+dfs(i+1,r,a));
            }
        }
        return dp[l][r]=res;
    }
}


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



int main(){
  const long long C = 1000000007;
  int N;
  cin >> N;
  vector<int> V(N);
  long long sum = 0;
  for(int i= 0; i<N; i++){
    int A;
    cin >> A;
    V[i] = A;
    sum += A;
  }
  
  sum -= V[0];
  
  long long sum_mod;
  for(int i= 0; i<N; i++){
    long long X;
    X = V[i]*(sum%C);
    X %= C;
    sum_mod += X;
    //sum_mod %= C;
    sum -= V[i+1];
  }
  
  cout << sum_mod%C << endl;
    
}




Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	char s[300005];
	scanf("%s", s);
	int s1=0,s2=0;
	for (int i=0; i<n; i++)	if (s[i]=='E') ++s2;
	int ans=1<<30;
	for (int i=0; i<n; i++) {
		if (s[i]=='E') --s2;
		ans=min(ans,s1+s2);
		if (s[i]=='W') ++s1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
/**
 *    author        : Saurav Paul 
 *    created       : August 15, 2020 6:11 PM
 *    Problem Name  : C - Walking Takahashi
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc175/tasks/abc175_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

void solve(){

    ll X , K , D ;
    cin >> X >> K >> D ;

    X = abs(X) ;

    ll can_divide = min(K,X/D) ;
    X -= (D*can_divide) ;
    K -= can_divide ;

    if(K&1){
        X = abs(X - D) ;
    }
    cout << X << endl ;

}

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


Measured memory_bytes: 3664
#ふぇー
import sys
def 解():
    L=int(input())
    aA=[int(_) for _ in sys.stdin.readlines()]
    dp = [0]*5
    for i in range(L):
        i生 = aA[i]
        bA = i生 % 2
        i偶 = (2 if i生 == 0 else bA)
        i奇 = (1 if i生 == 0 else ( 0 if bA else 1) )
        dp[4] = min(dp[:]) + i生
        dp[3] = min(dp[:4]) + i偶
        dp[2] = min(dp[:3]) + i奇
        dp[1] = min(dp[:2]) + i偶
        dp[0] = dp[0] + i生
    print(min(dp))
解()


Measured memory_bytes: 25244
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

struct PriorityQueue
{
  int heap[2000001];
  int size = 0;

  void maxHeapify(int i)
  {
    int left = i * 2;
    int right = i * 2 + 1;
    int largest;

    if (left <= size && heap[left] > heap[i])
      largest = left;
    else
      largest = i;
    if (right <= size && heap[right] > heap[largest])
      largest = right;

    if (largest != i)
    {
      swap(heap[i], heap[largest]);
      maxHeapify(largest);
    }
  }

  void insert(int n)
  {
    size++;
    heap[size] = n;
    int i = size;
    while (i > 1 && heap[i / 2] < heap[i])
    {
      swap(heap[i], heap[i / 2]);
      i /= 2;
    }
  }

  int extract()
  {
    if (size < 1)
      return -1;
    int max = heap[1];
    heap[1] = heap[size];
    size--;
    maxHeapify(1);
    return max;
  }
} pq;

int main()
{
  int tmp;
  char order[7];

  while (true)
  {
    scanf("%s", order);
    if (order[2] == 'd')
      break;
    if (order[0] == 'i')
    {
      scanf("%d", &tmp);
      pq.insert(tmp);
    }
    else
      printf("%d\n", pq.extract());
  }

  return 0;
}

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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

main(){
    int n, m, k;
    cin >> n >> m >> k;
    for(int x = 0; x <= n; ++x){
        for(int y = 0; y <= m; ++y){
            if(m*x + n*y - 2*x*y == k) return puts("Yes"), 0;
        }
    }
    puts("No");
}


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

using namespace std;

int main()
{
  int n, x, ans, A[100], t;
  t = 0;
  while (true)
  {
    ans = 0;
    cin >> n >> x;

    if (n == 0 && x == 0)
      break;

    for (int i = 1; i <= n; i++)
    {
      for (int j = 1; j <= n; j++)
      {
        if (i == j)
          continue;
        for (int k = 1; k <= n; k++)
        {
          if (j == k || i == k)
            continue;

          if (i + j + k == x)
            ans++;
        }
      }
    }
    ans /= 6;
    A[t] = ans;
    t++;
  }

  for (int i = 0; i < t; i++)
  {
    cout << A[i] << endl;
  }
}


Measured memory_bytes: 3100
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n%M) * (f(n - 1) % M);
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll K, A, B; cin >> K >> A >> B;

	for (ll n = A; n <= B; n++) {
		if (n % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
}


Measured memory_bytes: 11028
import math
a, b, n = list(map(int,input().split()))
if b > n:
    print(math.floor(a*n/b))
elif n < 2*b - 1:
    print(max(math.floor(a*n/b)-a,math.floor(a*(b-1)/b)))
else:
    print(a+math.floor((-1)*a/b))

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

using namespace std;

int main(void) {
    long long n, w;

    cin >> n >> w;

    vector<pair<long long, long long>> v(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        sum += v[i].second;
    }

    vector<long long> dp(sum + 1, 1e18L + 5);
    dp[0] = 0;

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (long long j = sum; j >= v[i].second; j--) {
            dp[j] = min(dp[j], dp[j - v[i].second] + v[i].first);
            if (dp[j] <= w) ans = max(ans, j);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
(n,i),a,*q=$<.map{_1.split.map &:to_i}
b=(0..u=n).map{_1&-_1}
d=b.map{[]}
z=q.map{d[_2]<<[_1-1,~i-=1]}
a.map{t=$*[_1]||u+=1
(b[t]-=1;t+=t&-t)until t>n
d[$*[_1]=i+=1].map{|x,y|z[y]=u-n
(z[y]-=b[x];x&=x-1)while x>0}}
p *z

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 600;

int n, m, cut_from = -1, cut_to = -1;
vector<int> graph[N_MAX];
vector<double> expected(N_MAX, -1.0);

void dfs_expected(int node, vector<double> &expected) {
    if(node == n-1) {
        expected[n-1] = 0.0;
        return;
    }
    expected[node] = 0.0;
    int cnt = 0;
    for(int child: graph[node]) {
        if(node == cut_from && child == cut_to) continue;
        if(expected[child] < 0.0-EPS) dfs_expected(child, expected);
        expected[node] += expected[child] + 1.0;
        ++cnt;
    }
    expected[node] /= double(cnt);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> m;
    int x, y;
    for(int i=0;i<m;++i){
        cin >> x >> y;
        graph[x-1].push_back(y-1);
    }

    dfs_expected(0, expected);
    for(int i=0;i<n;++i) {
        cerr << "expected[" << i+1 << "] = " << expected[i] << endl; 
    }

    double ans = expected[0];
    double cut_expected = -1.0;
    for(int i=0;i<n;++i) {
        if(graph[i].size() <= 1) continue;
        cut_from = i;
        cut_expected = -1.0;
        for(int child: graph[i]) {
            if(cut_expected < expected[child]) {
                cut_to = child;
                cut_expected = expected[child];
            }
        }
        vector<double> dp(n, -1.0);
        dfs_expected(0, dp);
        ans = min(ans, dp[0]);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


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

int H,W;
char C[310][301];
int main(){
	cin >> H >> W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> C[i][j];
		}
	}
	int ans = 0;
	int dp[H+1][H+1] = {{0}},cost[H+1][H+1] = {{0}};
	for(int i=1;i<W;i++){
		for(int j=0;j<=H;j++){
			for(int k=0;k<=H;k++){
				dp[j][k] = 1e9;
				cost[j][k] = 0;
			}
		}
		for(int j=0;j<H;j++){
			for(int k=1;j+k<=H;k++){
				if(C[j+k][i]==C[k][i+1]) cost[0][j]++;
			}
			int c = 0;
			for(int k=H-j;k>0;k--){
				cost[c+1][j+c+1] = cost[c][j+c] - (C[j+k][i]==C[k][i+1]);
				c++;
			}
		}
		for(int j=0;j<H;j++){
			for(int k=1;j+k<=H;k++){
				if(C[j+k][i+1]==C[k][i]) cost[j][0]++;
			}
			int c = 0;
			for(int k=H-j;k>0;k--){
				if(j==0) continue;
				cost[j+c+1][c+1] = cost[j+c][c] - (C[j+k][i+1]==C[k][i]);
				c++;
			}
		}
		cost[0][0] /= 2;
/*		for(int j=0;j<=H;j++){
			for(int k=0;k<=H;k++){
				cout << cost[j][k] << (k!=H? " ":"\n");
			}
		}
		cout << endl;
*/		dp[0][0] = 0;
		dp[1][0] = cost[0][0];
		dp[0][1] = cost[0][0];
		for(int j=0;j<H;j++){
			for(int k=0;k<H;k++){
				dp[j+1][k] = min(dp[j+1][k],dp[j][k]+cost[j][k]);
				dp[j][k+1] = min(dp[j][k+1],dp[j][k]+cost[j][k]);
				dp[j+1][k+1] = min(dp[j+1][k+1],min(dp[j][k+1]+cost[j][k+1],dp[j+1][k]+cost[j+1][k]));
			}
		}
		ans += dp[H][H];
	}
	cout << ans << endl;
}

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

int main(){
	int a,b;
	
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}else if(a>b){
		cout<<"a > b"<<endl;
}else{
	cout<<"a == b"<<endl;
}

	
	
return 0;
}





Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
cout<<(n*(n+1)/2);
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
int main()
{
	int N;
	while( ~scanf(" %d",&N) ){
		int num = N / 3;
		printf("%d\n",num);
	}
}

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int K,N,sub;
  vector<int> A(200000),interval(200000);

  scanf("%d %d",&K,&N);
  REPI(N)
    scanf("%d",&A[i]);
  
  REPI(N-1)
  {
    interval[i] = A[i+1] - A[i];
  }

  interval[N-1] = A[0] + K - A[N-1];
  
  sub = 0;
  
  REPI(N)
    sub = max(sub,interval[i]);

  printf("%d\n",K-sub);

  return 0;
}

Measured memory_bytes: 4664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int ans = 0;
    while(true){
        string s;
        cin >> s;
        if(s=="\0") break;
        for(int i= 0; i < s.size(); i++){
            int a = 0;
            if(s[i] >= '0' && s[i] <= '9'){
                while(s[i] >= '0' && s[i] <= '9'){
                    a *= 10;
                    a += (s[i]-'0');
                    i++;
                }
                ans += a;
            }
        }
    }
    cout << ans << endl;
}


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

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        k: i64,
        a: i64,
        b: i64,
    }
    if k <= a || a + 2 >= b {
        println!("{}", 1 + k);
    } else {
        println!("{}", b + (b - a) * ((k - a - 1) / 2) + (k - a + 1) % 2);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;

    K--;
    S[K] = S[K] - 'A' + 'a';
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;


const int maxN=2e5+10;
int a[maxN],n;

void solve(){
    cin>>n;
    int t=0;
    for(int i=0;i<n;++i)cin>>a[i] , t^=a[i];
    for(int i=0;i<n;i++)cout<<(a[i]^t)<<" ";
    cout<<"\n";
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 4332
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    long long h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << ((w+1)/2)* ((h+1)/2) + (w/2) * (h/2) << endl;
    return 0;
}

Measured memory_bytes: 256
let pronounce n =
  if n mod 10 = 3 then "bon"
  else if n mod 10 = 0 || n mod 10 = 1 || n mod 10 = 6 || n mod 10 = 8 then "pon"
  else "hon"

let () = Scanf.scanf "%d" (fun n -> Printf.printf "%s\n" (pronounce n))

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int t;
    if(a == c)
    t = abs(b - d);
    else if(a > c){
        if(b >= d)
        t = (24 - (a - c))*60 + (b - d);
        else
        t = (24 - ((a - 1) - c))*60 + 60 - (d - b);
    }
    else if( c > a){
        if(d >= b)
        t = (c -a)*60 + d -b;
        else
        t = (c - 1 - a)*60 + 60 - (b - d);
    }
    cout << t - e ;
}









Measured memory_bytes: 3660
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public class Main {
    static final ByteBuffer buf = ByteBuffer.allocate(1000000);
    static final ReadableByteChannel in = Channels.newChannel(System.in);
    static final int NAME = 0;
    static final int T = 1;// top;
    static final int B = 2;// Bottom;
    static final int L = 3;// left;
    static final int R = 4;// right;
    static final int UNDERS = 5;

    public static void main(String[] args) throws IOException {
	init();
	int n = getInt();
	for (int i = 0; i < n; i++) {
	    int h = getInt();
	    int w = getInt();
	    byte[][] box = new byte[h][w];
	    int[][] item = new int[7][6];
	    int count = 0;
	    for (int y = 0; y < h; y++) {
		getLine(box[y]);
		for (int x = 0; x < w; x++) {
		    final byte c = box[y][x];
		    if (c != '.') {
			for (int k = 0; k < 7; k++) {
			    if (item[k][NAME] == 0) {
				item[k][NAME] = c;
				item[k][T] = item[k][B] = y;
				item[k][L] = item[k][R] = x;
				count++;
				break;
			    } else if (item[k][NAME] == c) {
				if (item[k][B] != y) {
				    item[k][B] = y;
				}
				if (x < item[k][L]) {
				    item[k][L] = x;
				} else if (item[k][R] < x) {
				    item[k][R] = x;
				}
				break;
			    }
			}
		    }
		}
	    }
	    boolean isSUSPICIOUS = false;
	    for (int num = 0; !isSUSPICIOUS && num < count; num++) {
		for (int y = item[num][T]; !isSUSPICIOUS && y <= item[num][B]; y++) {
		    for (int x = item[num][L]; !isSUSPICIOUS
			    && x <= item[num][R]; x++) {
			final byte parts = box[y][x];
			if (parts != item[num][NAME]) {
			    if (parts == '.') {
				isSUSPICIOUS = true;
			    } else {
				int partsNum;
				for (int j = 0; j < count; j++) {
				    if (item[j][0] == parts) {
					partsNum = j;
					isSUSPICIOUS = !setUnders(item, num,
						partsNum);
					break;
				    }
				}
			    }

			}
		    }
		}
	    }
	    System.out.println(isSUSPICIOUS ? "SUSPICIOUS" : "SAFE");

	}

    }

    private static boolean setUnders(int[][] item, int num, int partsNum) {
	if (num == partsNum) {
	    return false;
	}
	for (int i = 0; i < 7; i++) {
	    if ((item[num][UNDERS] & getLayer(i)) != 0) {
		if (!setUnders(item, i, partsNum)) {
		    return false;
		}
	    }
	}
	item[partsNum][UNDERS] |= getLayer(num);
	return true;
    }

    static int getLayer(int i) {
	return 1 << i;
    }

    static void init() throws IOException {
	buf.clear();
	in.read(buf);
	buf.flip();
    }

    static int getInt() {
	byte b = buf.get();
	while (b < '0' || '9' < b) {
	    b = buf.get();
	}
	int result = 0;
	while ('0' <= b && b <= '9') {
	    result = result * 10 + (b - '0');
	    b = buf.get();
	}
	return result;
    }

    static void getLine(byte[] array) {
	byte b = buf.get();
	while (b != '.' && (b < 'A' || 'Z' < b)) {
	    b = buf.get();
	}
	buf.position(buf.position() - 1);
	buf.get(array);
    }
}

Measured memory_bytes: 30508
#include <stdio.h>
/*
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_A
*/

void insertionSort(int arr[], int len);
void show(int arr[], int len);

int main(int argc, char const *argv[])
{
    int len;
    scanf("%d", &len);

    int arr[1000] = {0};
    for (int i = 0; i < len; ++i)
        scanf("%d", &arr[i]);

    insertionSort(arr, len);

    return 0;
}

void insertionSort(int arr[], int len)
{
    int j;
    int v;
    for (size_t i = 1; i < len; i++)
    {
        show(arr, len);

        v = arr[i];
        j = i - 1;
        while (j >= 0 && arr[j] > v)
        {
            arr[j + 1] = arr[j];
            j--;
        }
        arr[j + 1] = v;
    }
    show(arr, len);
}

void show(int arr[], int len)
{
    for (size_t i = 0; i < len; i++)
    {
        printf("%d", arr[i]);
        if (i != len - 1)
            printf(" ");
        else
            printf("\n");
    }
}


Measured memory_bytes: 2076
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

int n,k,d[12];

int main()
{
    ///freopen("INA.txt","r",stdin);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    cin>> n >> k;

    for(int i=1;i<=k;i++){
        int a;
        cin>> a;
        d[a]=1;
    }

    for(int i=n;i<=99999;i++){
        int num=i,f=1;
        while(num!=0){
            int digit = num%10;
            num/=10;
            if(d[digit]==0){
                f=1;
            }
            else{
                f=0;
                break;
            }

        }
        if(f==1){
            cout<< i << endl;
            break;
        }
    }


    return 0;
}



Measured memory_bytes: 3528
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;

long long even[61], odd[61];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 61; i++) {
		even[i] = 0;
		odd[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		for (int j = 0; j < 61; j++) {
			if (a & 1LL << j) odd[j]++;
			else even[j]++;
		}
	}
	long long ans = 0;
	for (int i = 0; i < 61; i++) {
		long long tmp = odd[i] * even[i];
		for (int j = 0; j < i; j++) {
			tmp = (tmp * 2) % MOD;
		}
		ans = (ans + tmp) % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

ll a[100001] = {};
ll s[100001] = {};
int main() {
	ll n; cin >> n;

	ll s1 = 0;
	ll s2 = 0;
	ll cnt1 = 0;
	ll cnt2 = 0;

	repe(i, 1, n) {
		ll l; cin >> l;
		a[i] = l;
		s1 += l;
		s2 += l;

		if (i % 2 == 1)
		{
			if (s1 <= 0) {
				cnt1 += 1 - s1;
				s1 = 1;
			}

			if (s2 >= 0) {
				cnt2 += s2+ 1;
				s2 = -1;
			}
		}
		else {
			if (s1 >= 0) {
				cnt1 += s1 + 1;
				s1 = -1;
			}

			if (s2 <= 0) {
				cnt2 += 1 - s2;
				s2 = 1;
			}
		}
	}

	cout << min(cnt1, cnt2) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

bool comp(pi A, pi B){
    // if(A.F==B.F){
    //     return A.S>B.S;
    // }
    // else{
    //     A.F<B.F;
    // }
    return A.F<B.F;
}

int32_t main(){
    ios::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    vector<pair<int, int> >AB;
    for(int i=0;i<n;i++){
        int A, B;
        cin>>A>>B;
        AB.PB({A,B});
    }
    sort(AB.begin(),AB.end(),comp);
    priority_queue<int>pq;
    int ans=0;
    int I=0;
    // deb(AB);
    for(int i=1;i<=m;i++){
        // deb(i);
        // deb(I);
        while(I<n){
            // deb("I");
            // deb(I);
            if(AB[I].F>i){
                break;
            }
            else{
                pq.push(AB[I].S);
                I++;
            }
        }
        if(pq.size()!=0){
        auto T=pq.top();
        ans+=T;
        pq.pop();
        }
        
    }
    cout<<ans<<"\n";


    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector< vector< pair<int, int> > > edge;
  edge = vector< vector< pair<int, int> > >(n);
  for(int i = 0; i < n-1 ; i++){
    vector<int> tmp = vector<int>(3);
    cin >> tmp[0] >> tmp[1] >> tmp[2];
    tmp[0]--;
    tmp[1]--;
    edge[tmp[0]].push_back(make_pair(tmp[1], tmp[2]));
    edge[tmp[1]].push_back(make_pair(tmp[0], tmp[2]));
  }
  vector< int > cost(n, -1);
  queue< int > q;
  for(int i = 0; i < n; i++){
    if(cost[i] != -1) continue;
    q.push(i);
    cost[i] = 0;
    while(!q.empty()){
      int k = q.front();
      q.pop();
      for(auto a : edge[k]){
        if(cost[a.first] == -1){
          q.push(a.first);
          cost[a.first] = cost[k] + a.second;
//          cout << k << " " << a.first << " " << cost[a.first] << endl;
        }
      }
    }
  }

  for(int i = 0; i < n ; i++){
    if(cost[i] % 2 == 0 || cost[i] == -1){
      cout << '1' << endl;
    }
    else cout << '0' << endl;
  }
}


Measured memory_bytes: 6784
n = int(input())
a = list(map(int, input().split()))
import math

ans = 1
flag = 0
a.sort()

for i in range(n):
    ans = ans * a[i] // 1
    if ans > 10**18:
        flag = 1
        break



if flag == 1:
    print(-1)
else:
    print(ans)

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

using namespace std;

/**************************************************************/
#define int          long long
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define ff           first
#define ss           second
#define err(x)       cerr << #x << " is : " << x << endl
#define endl         "\n"



const int MOD   =   1e9 + 7;
const int N     =   1e6 + 20;
const int big   =   1e14;
/***************************************************************/

void solve()
{
    int l , r , m;
    cin >> l >> r >> m;
    int cnt = 0;
    for(int i = l ; i <= r ; i++)
        if(i % m == 0)
            cnt++;

    cout << cnt << endl;
    return;
}


int32_t main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
   //cin >> t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w, n, a, direction = 1, tate = 0, yoko = 0;
  cin >> h >> w >> n;
  vector<vector<int>> c(h, vector<int>(w, 0));
  for (int i = 0; i < n; i++) {
    cin >> a;
    for (int j = 0; j < a; j++) {
      c[tate][yoko] = i + 1;
      if (direction == 1) {
        if (yoko < w - 1) {
          yoko++;
        }
        else if (yoko == w - 1) {
          direction = -1;
          tate++;
        }
      }
      else if (direction == -1) {
        if (yoko > 0) {
          yoko--;
        }
        else if (yoko == 0) {
          direction = 1;
          tate++;
        }
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << c[i][j];
      if (j == w - 1) cout << endl;
      else cout << ' ';
    }
  }
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		int N = s.length();
		TreeMap<Character, Character> StoT = new TreeMap<>();
		TreeMap<Character, Character> TtoS = new TreeMap<>();
		for (int i = 0; i < N; i++) {
			// First Observation for every character in S they can only map to one unique
			// character of T
			if (StoT.containsKey(s.charAt(i)) && StoT.get(s.charAt(i)) != t.charAt(i)) {
				System.out.println("No");
				return;
			}
			// Second Observation for every character in T they can only map to one unique
			// character of S
			if (TtoS.containsKey(t.charAt(i)) && TtoS.get(t.charAt(i)) != s.charAt(i)) {
				System.out.println("No");
				return;
			}
			StoT.put(s.charAt(i), t.charAt(i));
			TtoS.put(t.charAt(i), s.charAt(i));
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 32512
#include<stdio.h>
int gcd(int x, int y){
  if(x<y){
    int w=x;
x=y;
y=w;
}
if(x%y!=0)return gcd(y,x%y);
else return y;
}
int main(void){
  int k,sum=0;
scanf("%d",&k);
for(int a=1;a<=k;a++){
	for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
int ab=gcd(a,b);
sum+=gcd(ab,c);
}
    }
}
  printf("%d",sum);
  return 0;
}



Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    set<int> s;
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    cout<<s.size();
}



Measured memory_bytes: 256
#include <cstdio>

int a, b, c;
int cnt[201];

void solve()
{
    cnt[a+100]++;
    cnt[b+100]++;
    cnt[c+100]++;

    for (int i = 0; i < 201; i++) {
        if (cnt[i] == 1) {
            printf("%d\n", i-100);
        }
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);          
           
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        
        System.out.println(String.valueOf(s1.charAt(0)).toUpperCase() + String.valueOf(s2.charAt(0)).toUpperCase() + String.valueOf(s3.charAt(0)).toUpperCase());
         
    }            
}
        
        
        

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

int main() {

	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int l, r; cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
// C - Synthetic Kadomatsu
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main(){
	int N; cin>>N;
	vi A(3); for(int i=0; i<3; ++i) cin>>A[i];
	vi L(N); for(int i=0; i<N; ++i) cin>>L[i];

	int ans = INT_MAX, E = 1<<(N*2);
	for(int i=0; i<E; ++i){

		vi B(3), C(3);
		for(int j=0; j<N; ++j){
			int b = (i>>(j*2)) & 3;
			if(b==3) continue;// not use
			++C[b];
			B[b] += L[j];
		}

		if(min({B[0], B[1], B[2]})!=0){//each requires at least one
			int sum = 0;
			for(int j=0; j<3; ++j){
				sum += abs(A[j] - B[j]);
				if(C[j]>=2) sum += (C[j] - 1) * 10;
			}
			ans = min(ans, sum);
		}

	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  int n = s.length();
  if (n & 1) {
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < n; i += 2) {
    if (s.substr(i, 2) != "hi") {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;
class Main{
	static int keta=0;
	static int kotae=0;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		int N=Integer.parseInt(a);
		keta=a.length();
		tansaku(keta,1,3L,N);
		tansaku(keta,1,5L,N);
		tansaku(keta,1,7L,N);
		System.out.println(kotae);
	}
	static void tansaku(int depth,int now_depth,long atai,int N) {
		long tmp=atai;
		boolean[] sgs=new boolean[3];
		for(int i=0; i<now_depth; i++) {
			int a=(int)(tmp%10);
			sgs[(a-3)/2]=true;
			tmp/=10;
		}
		if(sgs[0]&&sgs[1]&&sgs[2]&& atai<=N) {
			kotae++;
		}
		if(now_depth+1<=depth) {
			tansaku(keta,now_depth+1,atai*10+3,N);
			tansaku(keta,now_depth+1,atai*10+5,N);
			tansaku(keta,now_depth+1,atai*10+7,N);
		}
	}
}

Measured memory_bytes: 23380
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    n,a,b,c,d = LI()

    x = int((b-a+d*(n-1))/(c+d))
    if x < 0 or x > n-1:
        print('NO')
        return
    z = c * x - d * (n-1-x)
    if z <= b - a <= z + (d-c) * (n-1):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38636
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC opatimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int const mod = 1e9 + 7;

inline int safe_mul(const int x, const int y) {
    return x * 1LL * y % mod;
}

inline void safe_add(int& x, const int y) {
    x += y;
    if (x >= mod)
        x -= mod;
}

inline int safe_pow(int x, int y) {
    int res = 1;
    for (; y > 0; y >>= 1) {
        if (y & 1)
            res = safe_mul(res, x);
        x = safe_mul(x,x);
    }
    return res;
}


inline int safe_inv(const int x){
    return safe_pow(x, mod - 2);
}

int const maxn = 200005;
int f[maxn];

int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

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

    f[0] = 1;
    for (int i = 1; i <= max(a,b); ++i) {
        f[i] = f[i - 1];
        f[i] = safe_mul(f[i], safe_inv(i));
        f[i] = safe_mul(f[i], n - i + 1);
    }

    int ans = safe_pow(2, n);
    safe_add(ans, mod - 1);

    safe_add(ans, mod - f[a]);
    safe_add(ans, mod - f[b]);
    cout << ans << endl;
}


Measured memory_bytes: 1024