akhauriyash/Code-Regression huggingface dataset:
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = { parent = nil; left = nil; right = nil; depth = nil; height = nil }

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1) in
  doit 0

let set_depth t root =
  let rec doit i d =
    if i = nil then ()
    else begin
      t.(i).depth <- d;
      doit t.(i).left (d + 1);
      doit t.(i).right (d + 1)
    end in
  doit root 0

let set_height t root =
  let rec doit i =
    t.(i).height <- max
      (if t.(i).left = nil then 0 else doit t.(i).left + 1)
      (if t.(i).right = nil then 0 else doit t.(i).right + 1);
    t.(i).height in
  doit root |> ignore

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else
      let (l, r) = (t.(t.(i).parent).left, t.(t.(i).parent).right) in
      if l <> nil && l <> i then l
      else if r <> nil && r <> i then r
      else nil in
  let degree i = (if t.(i).left = nil then 0 else 1) + (if t.(i).right = nil then 0 else 1) in
  t |> Array.iteri (fun i _ ->
    "node " ^ string_of_int i
    ^ ": parent = " ^ string_of_int t.(i).parent
    ^ ", sibling = " ^ string_of_int (sibling i)
    ^ ", degree = " ^ string_of_int (degree i)
    ^ ", depth = " ^ string_of_int t.(i).depth
    ^ ", height = " ^ string_of_int t.(i).height
    ^ (if t.(i).parent = nil then ", root"
       else if t.(i).left = nil && t.(i).right = nil then ", leaf"
       else ", internal node")
    ^ "\n"
    |> print_string)

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
    t.(id).left <- l;
    t.(id).right <- r;
    if l <> nil then t.(l).parent <- id;
    if r <> nil then t.(r).parent <- id;
  done;
  let root = search_root t n in
  set_depth t root;
  set_height t root;
  print t

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

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

    ll N;
    cin >> N;
    vll x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];

    rep(i, N){
        ll tmp = x[i];
        x[i] = x[i] + y[i];
        y[i] = tmp - y[i];
    }
    ll ans = max(*max_element(all(x))-*min_element(all(x)), *max_element(all(y))-*min_element(all(y)));
    cout << ans << endl;
}


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


int main() {
    string s;
    cin >> s;
    if (s.at(0) != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    if (count(s.begin()+2, s.end()-1, 'C') != 1) {
        cout << "WA" << endl;
        return 0;
    }

    string::iterator c_it = find(s.begin()+2, s.end()-1, 'C');

    for (string::iterator it = s.begin()+1; it != s.end(); it++) {
        if (it == c_it) continue;
        if ('A' <= *it && *it <= 'Z') {
            cout << "WA" << endl;
            return 0;
        } 
    }
    cout << "AC" << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
data = [[int(x) for x in input().split()] for _ in range(n)]

pats = [(x,y,z) for x in [-1,1] for y in [-1,1] for z in [-1,1]] # +++,++-,...,---
score = lambda sgns, vals: sum([s * x for(s, x) in zip(sgns, vals)])  # i.e.x+y-z
result = max(sum(sorted((score(pat, row) for row in data), reverse=True )[:m]) for pat in pats)
print(result)

Measured memory_bytes: 3292
def main():
    s = input()
    x, y = map(int, input().split())
    sl = s.split('T')
    dx = list(map(len, sl[::2]))
    dy = list(map(len, sl[1::2]))
    nx = dx.pop(0)
    ny = 0
    dx.sort(reverse=True)
    dy.sort(reverse=True)
    for xx in dx:
        if x >= nx:
            nx += xx
        else:
            nx -= xx
    for yy in dy:
        if y >= ny:
            ny += yy
        else:
            ny -= yy
    print('YNeos'[nx != x or ny != y::2])


main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  int N;
  cin >> N;
  long long a;
  long long p = 1;
  long long ans = 0;
  REP(i,N){
    cin >> a;
    if( a < p ) continue;
    if( a == p ){
      p++;
    }else{
      long long num = (a-1) / p;
      long long rem = a - p * num;
      ans += num;
      if( p == 1 ) p++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
require 'set'

N = gets.chomp.to_i
A = Array.new(N){Set.new}
h = Array.new(N){Array.new(2,0)}
i = 0
while i < N
  h[i][0] = i
  i += 1
end

str = gets.split
a,b = str[0].to_i-1, str[1].to_i-1
A[a].add(b)
A[b].add(a)
h[a][1] += 1
h[b][1] += 1

i = N-2
while i > 0
  str = gets.split
  a,b = str[0].to_i-1, str[1].to_i-1
  A[a].add(b)
  A[b].add(a)
  h[a][1] += 1
  h[b][1] += 1
  i -= 1
end
h.sort! {|a,b| a[1] <=> b[1]}
g = Array.new
i = 1
while h[i][1] == 1
  g.push(h[i-1][0])
  i += 1
end

str = gets.split
i = 0
c = Array.new(N)
while i < N
  c[i] = str[i].to_i
  i += 1
end

c.sort!
sum = c.inject(:+)
sum -= c[N-1]
x = 0
d = Array.new

t = 0
s = 0
while x < N
  t = g.pop
  A[t].each do |val|
    s = val
  end
  A[t].delete(s)
  A[s].delete(t)
  d.push(t)
  x += 1
  while A[s].size == 1
    t = s
    A[t].each do |val|
      s = val
    end
    d.push(t)
    A[s].delete(t)
    A[t].delete(s)
    x += 1
    if A[s].size == 0
      d.push(s)
      x += 1
    end
  end
end
e = Array.new(N)
for i in 0...N
  e[d[i]] = c[i]
end

puts sum
print e[0]
i = 1
while i < N
  print " "
  print e[i]
  i += 1
end
puts

Measured memory_bytes: 8696
#include<stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define chmax(p,q)(p=max(p,q))

int dp1[3010][3010];//dp1[i][j]=前からi個使ってj分以内に得られる最大価値
int dp2[3010][3010];//dp2[i][j]=後からi個使ってj分以内に得られる最大価値
int a[3010],b[3010];
int ans;
int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	rep(i,0,n)scanf("%d%d",a+i,b+i);
	rep(i,0,n){
		rep(j,0,t)dp1[i+1][j]=dp1[i][j];
		rep(j,0,t-a[i])chmax(dp1[i+1][j+a[i]],dp1[i][j]+b[i]);
		rep(j,0,t)dp2[i+1][j]=dp2[i][j];
		rep(j,0,t-a[n-1-i])chmax(dp2[i+1][j+a[n-1-i]],dp2[i][j]+b[n-1-i]);
	}
	rep(i,0,n)rep(j,0,t)chmax(ans,dp1[i][j]+dp2[n-1-i][t-1-j]+b[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 70912
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int x; cin>>x;
	x-=x%5;
	ll c=x/500;
	x+=c*500;
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][] a = new int[2][n];
    for(int i = 0;i<2;i++){
      for(int j = 0;j<n;j++){
        a[i][j] = sc.nextInt();
      }
    }
    int max = 0;
    int total = a[1][n-1];
    for(int i = 0;i<n;i++){
      total += a[0][i];
    }
    max = total;
    for(int i = 0;i<n-1;i++){
      total+=a[1][n-1-i-1];
      total-=a[0][n-1-i];
      max = Math.max(max,total);
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 36092
n = int(input())

l=[]
for i in range(n):
    x, y = [int(i) for i in input().split()]
    l.append([x, y])

def kyori(a, b): # 2座標間の距離を求める関数
    return ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5

soukyori = 0
for j in range(n):
    for k in range(j, n):
        soukyori = soukyori + kyori(l[j],l[k])
#print(soukyori)

print(soukyori * 2 / n) # ?


Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t N;
int64_t x[9], y[9];

double dist(int64_t i, int64_t j) 
{
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy, 0.5);
}

void solve()
{
	std::cin >> N;
	for (int64_t i = 1; i <= N; i++) {
		std::cin >> x[i] >> y[i];
	}

	std::vector<int64_t> town(N);
	for (int64_t i = 0; i < N; i++) {
		town[i] = i + 1;
	}

	double sum = 0.0;

	do
	{
		for (int64_t i = 0; i < N - 1; i++){
			sum += dist(town[i], town[i + 1]);
		} 
	} while(std::next_permutation(town.begin(), town.end()));

	int64_t fac = 1;
	for (int64_t i = 2; i < N + 1; i++)
	{
		fac *= i;
	}

	std::cout << sum / fac << std::endl;

}

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


Measured memory_bytes: 4204
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T ll
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

vector<int>v[100005];

int main(){
    IOS

  	int n,m;
  	cin>>n>>m;
    int a,b;
  	FOR(i,1,n){
        cin>>a>>b;
        v[a].pb(b);
    }
    priority_queue<int,vector<int>>pq;
    ll ans=0;
    ROF(i,m,1){
        FOR(j,0,sz(v[m-i+1])-1){
            pq.push(v[m-i+1][j]);
        }
        if(pq.empty()){
            continue;
        }
        ans+=pq.top();
        //cout<<i<<" "<<pq.top()<<endl;
        pq.pop();
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 5632
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<string, int>mp;
	int N; cin >> N;
	REP(i, N) {
		string S; cin >> S;
		VSORT(S);
		mp[S]++;
	}
	ll ans = 0;
	for (auto x : mp) {
		if (x.second >= 2) {
			ans += (x.second - 1)*x.second / 2;
		}
	}
	print(ans);
 }



Measured memory_bytes: 11264
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }

        int max = Arrays.stream(a).boxed().max(Comparator.naturalOrder()).get();
        int min = Arrays.stream(a).boxed().min(Comparator.naturalOrder()).get();
        System.out.println(max - min);
    }

}


Measured memory_bytes: 27344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c;
 cin>>a>>b;
 
 if(a%3==0||b%3==0||(a+b)%3==0)
 	cout<<"Possible"<<endl;
 else
 	cout<<"Impossible"<<endl;
  
 return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long double a,b;
  cin>>a>>b;
  long long int ans=floor(a*b);
  cout<<ans<<endl;
}

Measured memory_bytes: 3728
A,B=map(int,input().split())
a=A/0.08
b=(A+1)/0.08
c=B/0.1
d=(B+1)/0.1
if b<=c or d<=a:
  print(-1)
else:
  t=max(a,c)
  if t==int(t):
    print(int(t))
  else:
    print(int(t)+1)

Measured memory_bytes: 39828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;



 
int main(){
    ll N, K; cin >> N >> K;
    bitset<40> k(K+1);
    vector<bitset<40>> A(N);
    for(ll i = 0; i < N; i++) {
        ll x; cin >> x;
        bitset<40> temp(x);
        A[i] = temp;
    }
    vector<int> Set(40);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 40; j++){
            if(A[i][j] == 1) Set[j]++;
        }
    }

    ll Max = 0;

    for(ll i = 39; i >= 0; i--){
        bitset<40> tempK = k;
        if(tempK[i] == 0) continue;
        tempK.reset(i);
        if(tempK.to_ullong() > K) continue;
        for(ll j = i-1; j >= 0; j--){
            if(Set[j] > N - Set[j]) tempK.reset(j);
            else tempK.set(j);
        }
        if(tempK.to_ullong() > K) continue;
        ll ans = 0;
        for(ll j = 0; j < N; j++){
            ans += (tempK ^ A[j]).to_ullong();
        }
        Max = max(ans, Max);
    }
    cout << Max << endl;
}


Measured memory_bytes: 1024
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int n, ans;

int f(int x) {
	int ret = 0;

	while (x > 0) {
		ret += (x % 10);
		x /= 10;
	}

	return ret;
}

void solve() {                   
	scanf("%d", &n);
	ans = 10000000;

   	for (int i = 1; i < n; ++i) {
   		ans = min(ans, f(i) + f(n - i));
   	}

   	printf("%d\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}	

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair< int , int > P;
int main(){
  int n;
  vector< P > vc;
  while(scanf("%d",&n) , n){
    vc.resize(2 * n);
    for(int i = 0 ; i < n ; i++ ){
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      vc[2*i] = P( h*3600 + m*60 + s, 1);
      scanf("%d:%d:%d", &h, &m, &s);
      vc[2*i+1] = P( h*3600 + m*60 + s, -1);
    }
    sort(vc.begin(),vc.end());
    int ret = 0, ans = 0;
    for(int i = 0 ; i < 2 * n ; i++ ){
      ret += vc[i].second;
      ans = max( ans, ret);
    }
    printf("%d\n", ans);
  }
}

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

int main() {
  
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 1;
  
  for(int i = 0; i < N-1; i++) {
    if(S.at(i) != S.at(i+1)) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3676
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;


public class Main{
	Scanner sc;
	
	void solve(){
		sc = new Scanner(System.in);
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		while(true){
			String str[] = sc.next().split(",");
			
			int num = Integer.parseInt(str[0]);
			int res = Integer.parseInt(str[1]);
			if(num == 0 && res == 0)break;
			
			map.put(num, res);
		}
		
		Integer[] list = new Integer[map.size()];
		Arrays.fill(list, 0);
		map.values().toArray(list);
		Arrays.sort(list);
		
		HashMap<Integer, Integer> rank = new HashMap<Integer, Integer>();
		int num = 0;
		for(int i=list.length-1; 0<=i; --i){
			if(rank.containsKey(list[i])){
			}else{
				rank.put(list[i], ++num);
			}
		}
		
		while(sc.hasNext()){
			System.out.println(rank.get(map.get(ni())));
		}
		
		sc.close();
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	public static void main(String[] args){
		new Main().solve();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
import sys
from itertools import accumulate
input = lambda: sys.stdin.readline().rstrip('\r\n')

mod = int(pow(10, 9) + 7)

n = int(input())
a = list(map(int, input().split()))
x = a[:]
b = a[::-1][:]
b = list(accumulate(b))
a = b[::-1][:]
ans = 0
for i in range(n - 1):
    ans += (x[i] * a[i + 1]) % mod
print(ans % mod)

Measured memory_bytes: 32704
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }

    ll ok(ll mid , vector<ll>& a){
        int n=a.size();
        ll ans=0;
        for(int i=0;i<n;i++){
            ans+=(ll)(mid^a[i]);
        }
        return ans;
    }
 
    void solve (){
        int n;
        cin>>n;
        int ok=0;
        int total=0;
        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            if(x==y){
                total++;
            }
            else{
                total=0;
            }
            if(total==3)
                ok=1;
        }
        if(ok){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int a[2010];

struct Node{
	int data;
	
	Node(int data) : data(data) {};
	
	Node operator*(const Node r) const{
		return data < r.data ? *this : r;
	}
} e(INF);

struct SegmentTree{
	vector<Node> seg;
	int sz = 1;
	
	SegmentTree(int n){
		while(sz < n) sz *= 2;
		seg.assign(sz * 2, e);
	}
	
	void update(int k, int x){
		k += sz - 1;
		seg[k] = Node(x);
		
		while(k){
			k = (k - 1) / 2;
			seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
		}
	}
	
	int get(int a, int b){
		return _get(a, b, 0, 0, sz).data;
	}
	
	Node _get(int a, int b, int k, int l, int r){
		if(b<=l||r<=a) return e;
		if(a<=l&&r<=b) return seg[k];
		
		return _get(a, b, 2 * k + 1, l, (l + r) / 2) * _get(a, b, 2 * k + 2, (l + r) / 2, r);
	}
};

int main(){
	ll n,t; cin >> n >> t;
	REP(i,0,n) cin >> a[i];
	SegmentTree seg(n);
	REP(i,0,n) seg.update(i, a[i]);
	
	
	ll mi = LINF;
	REP(i, 0, n){
		ll sum = i * t;
		REP(j, 0, n){
			ll pos = LINF;
			if(j - i >= 0) pos = seg.get(j - i, j + 1);
			else pos = min(seg.get(0, j + 1), seg.get(n + (j - i), n));
			
			sum += pos;
		}
		mi = min(mi, sum);
	}
	
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int k;
  cin >> k;
  cout << (k / 2) * ((k + 1) / 2) << endl;
}


Measured memory_bytes: 256
/**********
*DP
*Sofice
*2020/7/15
*************/
#include<bits/stdc++.h>
using namespace std;
int n, a;
int maxv = INT_MIN, minv;

int main() {
    scanf("%d", &n);  
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        if (i == 0)    minv = a;
        if (i > 0) {
            maxv = max(maxv, a - minv);
            minv = min(minv, a);
        }
    }
    printf("%d\n", maxv);
    

    //system("pause");
    return 0;
}


Measured memory_bytes: 3220
import heapq

N, M = map(int, input().split())
A = [-x for x in map(int, input().split())]

heapq.heapify(A)
for i in range(M):
    tmp = -heapq.heappop(A)
    tmp = tmp // 2
    heapq.heappush(A, -tmp)
    # print(A)
print(-sum(A))



Measured memory_bytes: 14184
inpl = lambda: list(map(int,input().split()))

N,x = inpl()
A = sorted(inpl())

i = 0
while i < N:
	if x < A[i]:
		break
	else:
		x -= A[i]
		i += 1

if i == N and x > 0:
	print(N-1)
else:
	print(i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
#define MOD 1000000007

void Main(){
  map<ll,int> mp;
  int n;
  cin>>n;
  rep(i,n){
    ll a;
    cin>>a;
    if(mp[a]==1){
      cout<<"NO"<<endl;
      return;
    }
    mp[a]=1;
  }
  cout<<"YES"<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


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

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

    vector<ll> a(n);

    rep(i,n){
        cin >> a.at(i);
        if(i>k-1)
        {
            cout << (a.at(i - k) < a.at(i) ? "Yes" : "No") << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4768
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, k) = read!(usize, usize);
    let s: String = read!(String);
    let sc: Vec<char> = s.chars().collect();

    let ans: String = sc
        .into_iter()
        .enumerate()
        .map(|(i, x)| {
            if i + 1 == k {
                if x == 'A' {
                    'a'
                } else if x == 'B' {
                    'b'
                } else {
                    'c'
                }
            } else {
                x
            }
        })
        .collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = 1)
p.append(-1)
pc = 0
q.sort(reverse = 1)
q.append(-1)
qc = 0
r.sort(reverse = 1)
r.append(-1)
rc = 0
count = x + y
ans = 0
while count > 0:
    if x > 0 and y > 0:
        if max(p[pc], max(q[qc], r[rc])) == p[pc]:
            ans += p[pc]
            x -= 1
            count -= 1
            pc += 1
        elif max(q[qc], r[rc]) == r[rc]:
            ans += r[rc]
            rc += 1
            count -= 1
        else:
            ans += q[qc]
            qc += 1
            count -= 1
            y -= 1
    elif y > 0:
        if max(q[qc], r[rc]) == r[rc]:
            ans += r[rc]
            rc += 1
            count -= 1
        else:
            ans += q[qc]
            qc += 1
            count -= 1
            y -= 1
    elif x > 0:
        if max(p[pc], r[rc]) == r[rc]:
            ans += r[rc]
            rc += 1
            count -= 1
        else:
            ans += p[pc]
            pc += 1
            count -= 1
            x -= 1
print(ans)

Measured memory_bytes: 106056
use std::io;


fn read_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf);
    let trlen = buf.trim_right().len();
    buf.truncate(trlen);
    if let Ok(v) = buf.parse::<i64>() {
        v
    } else {
        panic!("Failed to read integer")
    }
}


fn main() {
    let n = read_int() as usize;
    let mut sum = 0;
    let mut ans = 0;
    for _ in 0..n {
        let curr = read_int();
        if curr == 0 {
            ans += sum / 2;
            sum = 0;
        } else {
            sum += curr;
        }
    }
    ans += sum / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdlib>
#include <cstdio>
#include <cstring>

struct node{
	unsigned int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

//NodePointer listSearch( unsigned int key ){
//	/* your code */
//}

void init(){
  nil = (NodePointer)malloc( sizeof( struct node ) );
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
	NodePointer cur = nil->next;
	int isf = 1;
	while( true ) {
		if ( cur == nil ) {
			break;
		}

		if ( isf == 0) {
			printf(" ");
		}
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode( NodePointer node ){
	NodePointer tmp = node->prev;
	if ( tmp != nil ) {
		tmp->next = node->next;
		tmp->next->prev = tmp;
	}
	else {
		nil->next = node->next;
		nil->next->prev = nil;
	}
	free( node );
}

void deleteFirst(){
	NodePointer t = nil->next;
	deleteNode(t);
}

void deleteLast(){
	NodePointer node = nil->prev;
	if ( node->prev != nil ) {
		nil->prev = node->prev;
	}
	else {
		nil->prev = nil;
	}
	deleteNode( node );
}

void delete_( int key ){
	NodePointer node = nil->next;
	while ( node != nil ) {
		if ( node->key == key ) {
			deleteNode(node);
			break;
		}
		node = node->next;
	}
}


void insert(int key){
	NodePointer x;
	x = (NodePointer)malloc(sizeof(struct node));
	x->key = key;
	x->prev = nil;

	NodePointer y = nil->next;
	nil->next = x;
	x->next = y;
	y->prev = x;

	if ( nil->prev == nil ) {
		nil->prev = x;
	}
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++ ){
		scanf("%s%d", com, &key);
		if ( com[0] == 'i' ) {
			insert(key); np++; size++;
		}
		else if ( com[0] == 'd' ) {
			if (strlen(com) > 6){
				if ( com[6] == 'F' ) {
					deleteFirst();
				}
				else if ( com[6] == 'L' ) {
					deleteLast();
				}
			}
			else {
				delete_(key); nd++;
			}
			size--;
		}
	}

	printList();
	return 0;
}



Measured memory_bytes: 33936
import itertools
import math

N = int(input())
xy  = [[int(i) for i in input().split()] for j in range(N)]
distance = [[0 for j in range(N)] for i in range(N)]
for i in range(N):
    for j in range(N):
        xi = xy[i][0]
        yi = xy[i][1]
        xj = xy[j][0]
        yj = xy[j][1]
        d = math.sqrt((xi-xj)**2+(yi-yj)**2)
        distance[i][j] = d
        distance[j][i] = d

print(sum([sum(i) for i in distance])/N)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=300;
int dp1[maxn];
int dp2[maxn];
int w[maxn];
int v[maxn];
struct node{
    int w;
    int v;
}p[maxn];
bool cmp(struct node a,struct node b){
    if(a.v==b.v) return a.w<b.w;
    return a.v<b.v;
}
int a[3][200];
int dp[3];
int main()
{
    int i,j;
    int n;
    while(cin>>n){
        memset(dp,0,sizeof(dp));
        memset(a,0,sizeof(a));
        for(i=1;i<=2;i++){
            for(j=1;j<=n;j++) cin>>a[i][j];
        }
        int sum=0;
        int ans=0;
        for(i=1;i<=n;i++) sum=sum+a[2][i];
        int s1=0;
        for(i=1;i<=n;i++){
            s1=s1+a[1][i];
            sum=sum-a[2][i-1];
            ans=max(ans,sum+s1);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

#define inf (int)(1e9) 

using namespace std;

int absm(int x){
	if(x < 0){
		return -x;
	}else{
		return x;
	}
}

int main(){
	int N,tmp;
	std::vector<int> a;
	std::vector<int> b;
	std::vector<int> c;

	cin >> N;

	for(int i=0; i<N; i++){
		cin >> tmp;
		a.push_back(tmp);
	}

	b.push_back(absm(0 - a[0]));
	for(int i=1; i<N; i++){
		b.push_back(absm(a[i-1] - a[i]));
	}
	b.push_back(absm(a[N-1] - 0));

	int sum = 0;
	for(int i=0; i<N+2; i++){
		sum = sum + b[i];
	}

	c.push_back(sum - b[0] - b[1] + absm(0 - a[1]));
	for(int i=1; i<N-1; i++){
		c.push_back(sum - b[i] - b[i+1] + absm(a[i-1] - a[i+1]));
	}
	c.push_back(sum - b[N] - b[N-1] + absm(a[N-2]));


	for(int i=0; i<c.size(); i++){
		cout << c[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 2552
#n=int(input())
n,k=map(int,input().split())
a=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

l=[1]
s=set(l)
for i in range(k):
    x=a[l[i]-1]
    if x in s:
        break
    else:
        l.append(x)
        s.add(x)

b=l.index(x)
c=len(l)-b
print(l[((k-b)%c)+b])


Measured memory_bytes: 113824
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-') f = 1;ch = getchar();}
	while(isdigit(ch)) {x = x*10 + ch - '0';ch = getchar();}
	return f?-x:x;
}
const int N = 2e5+ 100;
char ch[N];
int main() 
{
	scanf("%s",ch+1);
	int n = strlen(ch+1);
	if(ch[n] == 's') ch[++n] = 'e',ch[++n] = 's';
	else ch[++n] = 's';
	for(int i = 1;i <= n;i++) printf("%c",ch[i]);
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template<class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template<class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

bool dpw[3100];
bool dps[3100];
signed main() {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    REP(i,3001) {
        REP(j,3001) {
            if(100*a*i+100*b*j<=3000) {
                dpw[100*a*i+100*b*j]=1;
            }
        }
    }
    REP(i,3001) {
        REP(j,3001) {
            if(c*i+d*j<=3000) {
                dps[c*i+d*j]=1;
            }
        }
    }

    double mx=0;
    int W=100*a,S=0;
    REP(w,3001) {
        if(!dpw[w]) continue;
        REP(s,3001) {
            if(!dps[s]) continue;
            if(w+s<=f && 100*s<=w*e) {
                if(chmax(mx,s*100/(double)(w+s))) {
                    W=w;
                    S=s;
                }
            }
        }
    }
    cout<<W+S<<" "<<S<<endl;
    return 0;
}


Measured memory_bytes: 384
//

//  watch.cpp

//  practice

//

//  Created by jack on 2/17/19.

//  Copyright © 2019 jack. All rights reserved.

//



#include <iostream>



#include <cstdio>

#include <cmath>

int a[6];

void north(){
    
    int b[6];
    
    for (int i=0; i<6; i++) {
        
        b[i]=a[i];
        
    }
    
    a[0]=b[4];
    
    a[4]=b[5];
    
    a[5]=b[1];
    
    a[1]=b[0];
    
}

void east(){
    
    int b[6];
    
    for (int i=0; i<6; i++) {
        
        b[i]=a[i];
        
    }
    
    a[2]=b[0];
    
    a[0]=b[3];
    
    a[3]=b[5];
    
    a[5]=b[2];
    
}

void horizontal(){
    
    int c[6];
    
    for (int i=0; i<6; i++) {
        
        c[i]=a[i];
        
    }
    
    a[3]=c[4];
    
    a[1]=c[3];
    
    a[2]=c[1];
    
    a[4]=c[2];
    
}











int main(){
    int n;
    for(int i=0; i<6; i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&n);
    int q[n][2];
    for (int i=0; i<n; i++) {
        scanf("%d%d",&q[i][0],&q[i][1]);
    }
    
    for (int i=0; i<n; i++) {
        if (a[0]!=q[i][0]) {
            if (a[2]==q[i][0]||a[3]==q[i][0]) {
                while (a[0]!=q[i][0]) {
                    east();
                }
            }else{
                while (a[0]!=q[i][0]) {
                    north();
                }
            }
        
            
        }
        while (a[1]!=q[i][1]) {
            horizontal();
        }
        printf("%d\n",a[2]);
    }

    return 0;
    
}


Measured memory_bytes: 3188
n = int(raw_input())
S = map(int,raw_input().strip().split(' '))

comp = 0

def merge_sort(S):
    if len(S) <= 1:
        return S
    S1,S2 = split(S)
    return merge(merge_sort(S1),merge_sort(S2))

def split(S):
    mid = len(S)/2
    return S[:mid],S[mid:]

def merge(S1,S2):
    S = []
    S1.append(100000000000)
    S2.append(100000000000)
    global comp
    i = 0
    j = 0
    for k in range(len(S1)+len(S2)-2):
        comp += 1
        if S1[i] <= S2[j]:
            S.append(S1[i])
            i += 1
        else:
            S.append(S2[j])
            j += 1
    return S

sorted_S = merge_sort(S)
for s in sorted_S:
    print s,
print
print comp

Measured memory_bytes: 50016
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
#define ll long long
const int maxn = 3e5 + 9;
map<int, bool> mmp;
int main() {
    int a;
    cin >> a;
    int i;
    for (i = 0; i < a; i++) {
        int x;
        scanf("%d", &x);
        if (mmp[x])
            break;
        else {
            mmp[x] = 1;
        }
    }
    if (i != a) printf("NO\n");
    else
        printf("YES\n");
    return 0;
}

Measured memory_bytes: 9600
using System;
using System.Linq;
using System.Text;

namespace Graph_I
{
    class Graph
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var G = new int[n][];
            for (int i = 0; i < n; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var row = token[0]-1;
                G[row] = new int[n];
                for (int j = 0; j < token[1]; j++)
                    G[row][token[2 + j]-1] = 1;
            }

            var str = new StringBuilder();
            for (int i = 0; i < n; i++)
                str.Append(string.Join(" ", G[i].Select(s=>s.ToString()).ToArray())).Append("\n");
            Console.Write(str.ToString());
        }
    }
}

Measured memory_bytes: 10008
#include <stdio.h>

int main(void){
    int rooms[4][3][10];
    int n, b, f, r, v;

    for (int i=0; i<4; i++){
        for (int j=0; j<3; j++){
            for (int k=0; k<10; k++){
                rooms[i][j][k]=0;
            }
        }
    }

    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        rooms[b-1][f-1][r-1] += v;
    }

    for (int i=0; i<4; i++){
        if (i) printf("####################\n");
        for (int j=0; j<3; j++){
            for (int k=0; k<10; k++){
                printf(" %d", rooms[i][j][k]);
            }
            printf("\n");
        }
    }
   return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for (int d=a;d<=b;d++) {
        if (c%d == 0) {
            count++;
        }
    }
    cout << count <<endl;
    return 0;
}





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

using namespace std;
//using namespace std::chrono;

#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<long long>

typedef long long ll;

void print(vi v){
    cout<<"Contents of vector:\n";
    for(auto x : v) cout<<x<<" ";
    cout<<endl<<endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
    //ifstream cin("lmio_1991_3e1_seka_01.in"); ofstream cout("lmio_1991_3e1_seka_01.out");///cia failai

    //int T; cin>>T;
    int T = 1;

    for(int it = 1; it<=T; it++){
        int n; cin>>n;
        if(n >= 30) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long 
#define vi vector<int>
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;

const int N=5e5+1;

ll n,k;

int solve(ll num){
    int dig=1;
    ll rem=k;
    while(num>=rem){
        rem*=k;
        dig++;
    }
    return dig;
}

int main(){
    cin>>n>>k;
    cout<<solve(n);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr unsigned long long Mod = 1000000007;
unsigned long long arr[26] = {};

void dfs(int begin, unsigned long long acc, unsigned long long& ans)
{
  for (int i = begin; i < 26; ++i)
  {
    unsigned long long tmp = (acc * arr[i]) % Mod;
    ans = (ans + tmp) % Mod;
    dfs(i + 1, tmp, ans);
  }
}

int main()
{
  int N;
  std::cin >> N;
  std::string S;
  std::cin >> S;

  for (auto& c: S)
    ++arr[c - 'a'];

  unsigned long long ans = 0;
  dfs(0, 1, ans);
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
using namespace std;
int dp[3005][3005],lst[3005][3005];
string a,b;
int main(int argc, char** argv) {
	cin >> a >> b;
	int n=a.size(),m=b.size();
	a=' '+a,b=' '+b;
	int mx=-1,x,y;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i]==b[j])
			{
				dp[i][j]=dp[i-1][j-1]+1;
				lst[i][j]=i*10000+j;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				if(dp[i][j]==dp[i-1][j]) lst[i][j]=lst[i-1][j];
				else lst[i][j]=lst[i][j-1];
			}
			if(dp[i][j]>mx)
			{
				mx=dp[i][j];
				x=i,y=j;
			}
		}
	}
	string ans="";
	for(int i=1;i<=mx;i++)
	{
		ans=a[x]+ans;
		int t=lst[x-1][y-1];
		x=t/10000,y=t%10000;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 70784
import itertools

n = int(input())
a = [i for i in range(n)]
x,y = [0]*n , [0]*n
for i in range(n):
    x[i],y[i] = map(int,input().split())
r = list(itertools.permutations(a,len(a)))

ans = 0
for i in r:
    for j in range(1,n):
        ans += ( (x[i[j]] - x[i[j-1]]) ** 2 + (y[i[j]] - y[i[j-1]]) ** 2 ) ** 0.5
        
print(ans / len(r))

Measured memory_bytes: 45808
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int r,g,b;
	cin>>r>>g>>b;
	if((g*10+b)%4==0){
		ce("YES")
	}else{
		ce("NO")
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++) 
#define _For(i,a,b) for(int i=a;i>=b;i--)
#define LL long long 
const int N = 300005;
int bb,n,aa;
LL ans;
int a[N];
vector<int> v;
bool cmp(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>aa>>bb;
	int k=n;
	for(int i=1;i<=n;i++)
	a[i]=i;
	if(k-bb+1<aa||(aa+bb>n+1)||(n*1ll>1ll*aa*bb)||(aa==1&&bb!=n||bb==1&&aa!=n)){
		cout<<-1<<endl;
		exit(0);
	}
	else{
		int qaq=1,tn=0;
		while(k>aa){
			int t=0;
			if(k-bb+1>=aa)
			k=k-bb+1,t=bb;
			else{
				int ssb=n-qaq+1-(aa-tn)+1;
				k=k-ssb+1;
				t=ssb;
			}
			sort(a+qaq,a+t+qaq,cmp);
			qaq+=t;
			tn++;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<a[i];
		if(i!=n)
		cout<<" ";
	}
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
using namespace std;
using ll=long long ;
int main()
{
    int n;
    cin>>n;
    vector<ll> arr(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    ll dp[n+1][n+1];
    vector<ll> pref(n+1);
    for(int i=1;i<=n;i++)
    {
        pref[i]=pref[i-1]+arr[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=10e16;
        }
    }
    for(int i=n;i>=1;i--)
    {
        for(int j=i;j<=n;j++)
        {
            if(i==j)
            dp[i][j]=0;
            else
            {
                // dp[i][j]=;
                for(int k=i;k<j;k++)
                {
                    dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pref[j]-pref[i-1]);
                }
            }
        }
    }
    cout<<dp[1][n];

}

Measured memory_bytes: 4440
if __name__ == '__main__':
    n, m = map(int, input().split())
    es = [None] * n
    for i in range(n):
        es[i] = []

    for a, b in (map(lambda x: int(x) - 1, input().split()) for _ in range(m)):
        es[a].append(b)
        es[b].append(a)

    if m % 2:
        print(-1)
        quit(0)

    mst_es = [None] * n
    for i in range(n):
        mst_es[i] = set()
    st = []
    used = [False] * n
    st.append(0)
    used[0] = True
    degrees = [0] * n
    num_edges = [0] * n
    while st != []:
        v = st.pop()
        for u in es[v]:
            if used[u]:
                if v not in mst_es[u] and u < v:
                    print(u + 1, v + 1)
                    degrees[u] += 1
            else:
                num_edges[u] += 1
                num_edges[v] += 1
                used[u] = True
                a, b = (u, v) if u < v else (v, u)
                st.append(u)
                mst_es[a].add(b)
                mst_es[b].add(a)

    st = [v for v in range(n) if num_edges[v] == 1]
    while st != []:
        v = st.pop()
        if num_edges[v] < 1:
            continue
        for u in mst_es[v]:
            a, b = (v, u) if degrees[v] % 2 == 1 else (u, v)
            print(a + 1, b + 1)
            degrees[a] += 1
        num_edges[u] -= 1
        num_edges[v] -= 1
        mst_es[v].remove(u)
        mst_es[u].remove(v)
        if num_edges[u] == 1:
            st.append(u)



Measured memory_bytes: 49516