akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    double s = 100;

    while (scanner.hasNext()) {
      int w = scanner.nextInt();
      for (int ii = 0; ii < w; ii++) {
        s = Math.ceil(s * 1.05);
      }
      System.out.println((int)(s * 1000));
    }
  }
}

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

#define lli long long int
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());

int main(void) {
  lli h, u, sum = 0;
  cin >> h;
  u = log2(h);
  for(int i = 0;i <= u;i++) {
    sum += pow(2, i);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d,e,f,total,sugar,w,s;
    double maxi = -1;
    cin>>a>>b>>c>>d>>e>>f;


    for(int i =0;100*a*i<=f;i++){
        for(int j =0;100*a*i + 100*b*j<=f;j++){
            w = 100*(a*i+b*j);
            if(w==0) continue;


            for(int x = 0;w + x*c<=f;x++){
                for(int y = 0;w+x*c + y*d<=f;y++){
                    s = x*c + y*d;
                    if((100*s) >w*e) continue;
                    double den = (double)s/w;
                    if(den >maxi){
                        maxi = den;
                        total = s+w;
                        sugar = s;
                    }
                }
            }
        }
    }
    cout<<total<<" "<<sugar<<endl;















}















































Measured memory_bytes: 256
#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;
}
char s[1100],t[1100];
int ans = 0x3f3f3f3f;
int main()
{
	scanf("%s%s",s+1,t+1);
	int n = strlen(s+1),m = strlen(t+1);
	for(int i = 0;i <= n-m;i++){
		int sum = 0;
		for(int j = 1;j <= m;j++){
			if(s[i+j] != t[j]) sum++; 
		}
//		cout << sum << endl;
		ans = min(sum,ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3656
// C - Bugged
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()

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

	int MAX = 0;
	vi S(N+1);
	for(int i=1; i<=N; ++i){
		cin>>S[i];
		MAX += S[i];
	}

	sort(all(S));

	int maxi = 0;
	vi dp(MAX+1);
	for(int i=1; i<=N; ++i){
		int s = S[i];
		for(int j=MAX; j>=s; --j){
			dp[j] = max(dp[j], dp[j-s] + s);
			int c = dp[j];
			if(c%10 == 0) c = 0;
			maxi = max(maxi, c);
		}
	}
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    FOR(i,1,n+1){
        int cur=i;
        double p=1.0/n;
        while(cur<k){
            cur*=2;
            p/=2;
        }
        ans+=p;
    }
    cout<<setprecision(12)<<fixed<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(void) {
	int w, h, n; cin >> w >> h >> n;
	int s = 0, t = 0;
	int i;
	int x[n], y[n], a[n];

	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	for (i = 0; i < n; i++) {
		if (a[i] == 1) { s = max(s, x[i]); }
		else if (a[i] == 2) { w = min(w, x[i]); }
		else if (a[i] == 3) { t = max(t, y[i]); }
		else if (a[i] == 4) { h = min(h, y[i]); }
	}

	if (w - s <= 0) { cout << "0" << endl; }
	else if (h - t <= 0) { cout << "0" << endl; }
	else { cout << (h - t)*(w - s) << endl; }
  
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $len, $cnt);
$rules = [];
for ($i=0; $i < $cnt; $i++) { 
    fscanf(STDIN, '%d %d', $tar, $val);
    $rules[] = [$tar => $val];
}

for ($i=0; $i < 1000; $i++) {
    $nums = array_map('intval', str_split($i)); 
    if (count($nums) < $len) {
        continue;
    }
    $flag = true;
    foreach ($rules as $rule) {
        foreach ($rule as $key => $value) {
            if ($nums[$key-1] !== $value) {
                $flag = false;
                break;
            }
        }
    }
    if ($flag) {
        echo $i."\n";
        exit;
    }
}
echo (-1)."\n";

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end(), greater<int>());
	rep(i, n) {
		if (a[i] == b[0]) cout << b[1] << endl;
		else cout << b[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
using System;

namespace AtBC179
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            int k = n.Length;
            string s = n.Substring(k - 1);
                if (s == "s")
            {
                Console.WriteLine(n + "es");
            }
            else
            {
                Console.WriteLine(n + "s");
            }
        }
    }
}

Measured memory_bytes: 25800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

bool is_prime(int N){
  for(int p=2; p*p<=N; p++){
    if(N%p==0) return false;
  }
  return true;
}

int main(){
  int Q;
  cin >> Q;
  vector<int> l(Q), r(Q);
  rep(i,Q) cin >> l[i] >> r[i];
  int num[100010]={0};
  for(int N=3; N<=100000; N+=2){
    num[N]=num[N-2];
    if(is_prime(N)&&is_prime((N+1)/2)) num[N]++;
  }
  rep(i,Q){
    int L=l[i], R=r[i];
    if(L==1) cout << num[R] << endl;
    else cout << num[R]-num[L-2] << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    string s;
    int K;
    set<string> st;
    cin >> s;
    cin >> K;
    string str;
    for(int i=0; i < s.size(); i++){
        for(int j=1; j <= K; j++){
            str = s.substr(i, j);
            st.insert(str);
        }
    }

    /*for(auto itr = st.begin(); itr != st.end(); ++itr) {
        std::cout << *itr << endl;      // イテレータの指す先のデータを表示
    }*/

    auto itr = st.begin();

    for(int i=1; i<K; i++){
        itr++;
    }

    cout << *itr << endl;

    //cout << s.size() << endl;
    /*std::string str("012345");
    std::string sub = str.substr(2, 3);     //  [2] の位置から3文字切り出す
    std::cout << sub << "\n";   234*/ 
    return 0;
}

Measured memory_bytes: 1664
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
d1 = (A1 - B1) * T1
d2 = d1 + (A2 - B2) * T2
if (d1 > 0 and d2 > 0) or (d1 < 0 and d2 < 0):
    print(0)
    exit()
if d2 == 0:
    print('infinity')
    exit()
d1 = abs(d1)
d2 = abs(d2)
if d1 % d2 == 0:
    print(d1 // d2 * 2)
else:
    print(1 + d1 // d2 * 2)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;

typedef long long ll;

int main(){
  ll n,x,res=0,ans=0;
  scanf("%lld %lld",&n,&x);

  do{
    if(x<n-x){
      x=n-x;
    }
    res=n-x;
    ans+=res*3*(x/res);
    n=n-res*(x/res);
    x=res;
  }while(n%x!=0);

  printf("%lld\n",ans);
  return 0;
}


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

using namespace std;
int main() {
	
	string S,T;
	int count = 0;

	cin >> S;
	cin >> T;

	for (int i = 0; i < 3; i++)
	{
		if (T.substr(i, 1) == S.substr(i, 1))
			count++;
	}
	cout << count;

}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x, y, z := r.nextInt(), r.nextInt(), r.nextInt()

	fmt.Fprintln(stdout, z, x, y)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
cout << fixed << setprecision(12);
double q,w,e,r;
cin>>q>>w>>e>>r;
ll ca=0;
double cb=q*w/2;
if(q/2==e&&w/2==r){
cout<<cb<<" "<<1<<endl;}
else
cout<<cb<<" "<<0<<endl;}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char S;
  int x =0;
  cin>>S;
  if(S=='A')
  {
    x=x+1;
  }else if(S=='B')
  {
    x=x+1;
  }else if(S=='C')
  {
    x=x+1;
  }else if(S=='D')
  {
    x=x+1;
  }else if(S=='E')
  {
    x=x+1;
  }else if(S=='F')
  {
    x=x+1;
  }else if(S=='G')
  {
    x=x+1;
  }else if(S=='H')
  {
    x=x+1;
  }else if(S=='I')
  {
    x=x+1;
  }else if(S=='J')
  {
    x=x+1;
  }else if(S=='K')
  {
    x=x+1;
  }else if(S=='L')
  {
    x=x+1;
  }else if(S=='M')
  {
    x=x+1;
  }else if(S=='N')
  {
    x=x+1;
  }else if(S=='O')
  {
    x=x+1;
  }else if(S=='P')
  {
    x=x+1;
  }else if(S=='Q')
  {
    x=x+1;
  }else if(S=='R')
  {
    x=x+1;
  }else if(S=='S')
  {
    x=x+1;
  }else if(S=='T')
  {
    x=x+1;
  }else if(S=='U')
  {
    x=x+1;
  }else if(S=='V')
  {
    x=x+1;
  }else if(S=='W')
  {
    x=x+1;
  }else if(S=='X')
  {
    x=x+1;
  }else if(S=='Y')
  {
    x=x+1;
  }else if(S=='Z')
  {
    x=x+1;
  }
  if(x==0)
  {
    cout<<'a'<<endl;
  }else
  {
    cout<<'A'<<endl;
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P, ll>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    int n, cnt = 0;
    cin >> n;
    vector<int> ans(n*2);
    vector<string> res(n*2);
    string s, t;
    cout << "?";
    for(int i=0;i<n;i++){
        cout << " " << i+1;
    }
    cout << endl;
    cnt++;
    cin >> res[0];
    if(res[0] == "Red"){
        res[n] = "Blue";
    }else{
        res[n] = "Red";
    }
    int x = 0;
    int L=0,R=n;
    while(abs(L-R)>1){
        int m = (L+R)/2;
        cout << "?";
        for(int i=0;i<n;i++){
            cout << " " << (i+m)%(2*n)+1;
        }
        cout << endl;
        cnt++;
        cin >> t;
        if(t == "-1") return 0;
        res[m] = t;
        if(t == res[0]){
            L = m;
        }else{
            R = m;
        }
    }
    x = R;
    if(res[x] == "Red"){
        ans[x-1] = 2;
        ans[x+n-1] = 1;
    }
    else{
        ans[x-1] = 1;
        ans[x+n-1] = 2;
    }
    for(int i=0;i<2*n && cnt < 210; i++){
        if((i >= x && i < x+n )|| ans[i] != 0) continue;
        cout << "? " << i+1;
        for(int j=0;j<n-1;j++){
            cout << " " << (j+x)%(2*n)+1;
        }
        cout << endl;
        cnt++;
        cin >> t;
        if(t == "-1") return 0;
        if(t == "Red") ans[i] = 1;
        else ans[i] = 2;
    }
    vector<int> r, b;
    for(int i=0;i<2*n && cnt < 210;i++){
        if(ans[i] == 1) r.push_back(i);
        else if(ans[i] == 2) b.push_back(i);
    }
    for(int i=0;i<n-1 && cnt < 210; i++){
        cout << "?";
        for(int j=0;j<n/2;j++){
            cout << " " << r[j]+1;
        }
        for(int j=0;j<n/2;j++){
            cout << " " << b[j]+1;
        }
        cout << " " << (i+x)%(2*n)+1 << endl;
        cnt++;
        cin >> t;
        if(t == "-1") return 0;
        if(t == "Red") ans[(i+x)%(2*n)] = 1;
        else ans[(i+x)%(2*n)] = 2;
    }
    cout << "! ";
    for(int i=0;i<n*2;i++){
        cout << (ans[i]==1 ? 'R':'B');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 724
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, k: usize,
        av: [usize; n]
    };

    for i in k..n {
        let res = if av[i] > av[i - k] { "Yes" } else { "No" };
        println!("{}", res);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 4756
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define gcd __gcd
using namespace std;
int n,k;
int how(int a) {
  if(k>=a) {
    return 1;
  }
  else {
    a-=k;
    if(a%(k-1)) {
      return a/(k-1)+2;
    }
    else {
      return a/(k-1)+1;
    }
  }
}
signed main() {
  cin>>n>>k;
  int ans=inf;
  if(n%2) {
    for(int i=1;i<=n/2+1;i++) {
      if(i==1) {
        ans=min(ans,how(n-i+1));
      }
      else {
        ans=min(ans,how(i)+how(n-i+1));
      }
    }
  }
  else {
    for(int i=1;i<=n/2;i++) {
      if(i==1) {
        ans=min(ans,how(n-i+1));
      }
      else {
        ans=min(ans,how(i)+how(n-i+1));
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
S = input()
now = "R"
now_num = 0
my_list = []

for i in range(len(S)):
    if S[i] == "R":
        if now == "L":
            my_list.append(now_num)
            now = "R"
            now_num = 1
        else:
            now_num += 1
    elif S[i] == "L":
        if now == "R":
            my_list.append(now_num)
            now = "L"
            now_num = 1
        else:
            now_num += 1
my_list.append(now_num)

for i in range(0, len(my_list), 2):
    for j in range(my_list[i] - 1):
        print(0, end =" ")
    sum = my_list[i] + my_list[i + 1]
    if sum % 2 == 0:
        print(sum // 2, end =" ")
        print(sum // 2, end =" ")
    elif my_list[i] % 2 == 0:
        print(sum // 2, end =" ")
        print(sum // 2 + 1, end =" ")
    else:
        print(sum // 2 + 1, end =" ")
        print(sum // 2, end =" ")
    for j in range(1, my_list[i + 1]):
        print(0, end =" ")


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,n,m;
  cin>>a>>n>>m;
  Int ans=0;
  for(Int y=0;y<=100;y++){
    if(y+a==0) continue;
    Int x=1;
    for(Int i=0;i<n;i++){
      x*=y+a;
      if(x>m) break;
    }
    if(x>m) continue;
    string s=to_string(x);
    Int z=0;
    for(char c:s) z+=c-'0';
    ans+=y==z;
  }
  cout<<ans<<endl;
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int N, cnt = 0, ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i += 2) {
        cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                cnt++;
            }
        }
        if (cnt == 8) {
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 256
N,M=map(int,input().split())
l=[]
for i in range(M):
    x,y=map(int,input().split())
    l.append([x,y])

def comb(n):
    return n*(n+1)//2

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
        self.size = [1] * N
        self.connection = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        self.connection -= (comb(self.size[ra]) + comb(self.size[rb]))
        self.connection += comb(self.size[ra] + self.size[rb])
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(N)
ans = [N*(N-1)//2]

l.reverse()
for a,b in l:
    a,b = a-1,b-1
    uf.unite(a,b)
    ans.append(ans[0] - uf.connection)

ans.reverse()
for i in range(1,M+1):
    print(ans[i])

Measured memory_bytes: 28620
from networkx import *
N = int(input())
E1 = [list(map(int,input().split())) for n in range(N-1)]
Q,K = map(int,input().split())
E2 = [list(map(int,input().split())) for q in range(Q)]
G = Graph()

for a,b,c in E1:
  G.add_edge(a-1,b-1,weight=c)

D = shortest_path_length(G,target=K-1,weight="weight")

for x,y in E2:
  print(D[x-1]+D[y-1])

Measured memory_bytes: 207996
// /**
// *    author:  Dooloper
// *    created: 12.04.2020 20:51:07
// **/

// #include <iostream>
// #include <vector>
// #include <map>
// #include <string>
// #include <utility>
// #include <algorithm>

// using namespace std;
// typedef unsigned long ll;

// ll GCD(int a, int b, int c,int k){
//     if(a == b== c)return __gcd(__gcd(a,b),c);
//     else return __gcd(__gcd(a,b),c)*k;
// }

// int main() {
//    cin.tie(0);
//    int K;cin>>K;

//    ll sum = 0;

//     sum += 1;
//    int a = 1;
//    int b = 1;
//    int c = 1;

//    for(int i = 0;i < K; i++){
//     //    sum += __gcd(__gcd(a,b),c);
//        a++;
//        sum += GCD(a,b,c, K);
//        b++;
//        sum += GCD(a,b,c, K);
//        c++;
//        sum += GCD(a,b,c, K);
//    }
//     // sum = GCD(1,1,1);
//    cout<<sum <<endl;
//    return 0;
// }
/**
*    author:  Dooloper
*    created: 12.04.2020 20:51:07
**/

/**
*    author:  Dooloper
*    created: 12.04.2020 20:51:07
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;
typedef unsigned long ll;

int main() {
   cin.tie(0);
    ll N;cin>>N;
    ll sum = 0;

    for (ll i = 0; i < N + 1; i++)
    {
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }else{
            sum += i;
        }
    }
    

    cout<<sum << endl;
   return 0;
}



Measured memory_bytes: 3632
// AOJ 2876 Anagram
// 2018.4.16 bal4u
 
#include <stdio.h>

#define HASHSIZ 350003
typedef struct { int a, f; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int insert(int a, int k)
{
	int  r;
	HASH *p = hash + a % HASHSIZ;
	while (p->a) {
		if (p->a == a) {
			r = p->f, p->f += k;
			if (p->f == 0) return -1;
			return !r;
		}
		if (++p == hashend) p = hash;
	}
	p->a = a, p->f = k;
	return 1;
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int a[100002];
int ans[100002], sz;

int main()
{
	int N, i, cnt;
	int *f, *b;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();

	cnt = 0, f = a, b = a+N-1;
	for (i = 1; i <= N; i++) {
		cnt += insert(*f++,  1);
		cnt += insert(*b--, -1);
		if (!cnt) ans[sz++] = i;
	}

	printf("%d", ans[0]);
	for (i = 1; i < sz; i++) printf(" %d", ans[i]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 4964
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
struct BIT {
    vector<LL> bit; int n;
    void init(int _n) {
        n = _n;
        bit.clear(); bit.resize(n + 1, 0);
    }
    LL q(int x) {
        LL ret = 0;
        while (x > 0) {
            ret = max(ret, bit[x]);
            x -= x & (-x);
        }
        return ret;
    }
    void m(int x, LL v) {
        while (x <= n) {
            bit[x] = max(bit[x], v);
            x += x & (-x);
        }
    }
} solver;
void marmot0814() {
    int n; cin >> n;
    solver.init(n);
    vector<int> h(n);
    for (auto &v : h) cin >> v;
    vector<LL> a(n);
    for (auto &v : a) cin >> v;
    LL ans = 0;
    for (int i = 0 ; i < n ; i++) {
        LL x = solver.q(h[i]);
        ans = max(ans, x + a[i]);
        solver.m(h[i], x + a[i]);
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 7124
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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 gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll a,b;
  cin >> a >> b;
  ll h = b-a-1;
  ll w=0;
  rep1(i,h){
   w+=i; 
  }
  pri(w-a);




  return 0;
}


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

int main()
{
  int n;

  while (cin >> n, n){
    int card[201] = {0};
    for (int i = 0; i < n; i++){
      int x;
      cin >> x;
      card[x] = 1;
    }

    int a, b;
    bool f = false;
    a = b = n;

    while (a != 0 && b != 0){
      int fir = 0;
      f = !f;
      for (int i = 1; i <= 2 * n; i++){
        if (f && card[i] == 1 && fir < i){
          fir = i;
          a--;
          card[i] = -1;
          f = false;
          if (a == 0) break;
        }
        if (!f && card[i] == 0 && fir < i){
          fir = i;
          b--;
          card[i] = -1;
          f = true;
          if (b == 0) break;
        }
      }
    }

    int ans = 0;
    for (int i = 1; i <= 2 * n; i++){
      if (card[i] != -1) ans++;
    }

    cout << (a?0:ans) << endl << (b?0:ans) << endl;
  }
}

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

typedef long long ll;
const int Maxn = 500;

int N, Mod;

vector<pair<int, int> > p;
ll f[Maxn + 5][Maxn + 5];

inline int F(int i) {
	static int ret = 2 * N - 1;
	while(ret >= 0 && i * i + ret * ret > 4 * N * N)
		ret--;
	return ret + 1;
}
inline int G(int i) {
	static int ret = 2 * N - 1;
	while(ret >= 0 && i * i + ret * ret >= N * N)
		ret--;
	return ret + 1;
}

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d", &N, &Mod);
	for(int i = 0; i <= 2 * N - 1; i++) {
		if(i < N) p.push_back(make_pair(G(i), F(i)));
		else p.push_back(make_pair(F(i), 0));
	}
	sort(p.begin(), p.end());
	ll ans = 0;
	for(int k = 0; k <= N; k++) {
		memset(f, 0, sizeof f);
		f[0][0] = 1;
		int cnt1 = 0, cnt2 = 0;
		for(int i = 0; i < (int)p.size(); i++) {
			for(int j = 0; j <= k; j++)
				if(p[i].second == 0) {
					f[i + 1][j] = (f[i + 1][j] + f[i][j] * (p[i].first - j - cnt1) % Mod) % Mod;
				} else {
					if(j < k) f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j] * (p[i].first - j - cnt1) % Mod) % Mod;
					f[i + 1][j] = (f[i + 1][j] + f[i][j] * (p[i].second - N - k - (cnt2 - j)) % Mod) % Mod;
				}
			if(p[i].second == 0) cnt1++;
			else cnt2++;
		}
		if(k % 2) ans = (ans - f[p.size()][k] + Mod) % Mod;
		else ans = (ans + f[p.size()][k]) % Mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2176
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        flag = true;
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
ans = 700 + 100*s.count('o')
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<cstring>
using namespace std;
const int N=200020;
long long s,n,a[N],ans=0;
int main()
{
	cin>>n;
	//memset(last,0,sizeof(last));
	for(int i=1;i<=n;i++) cin>>a[i];
	long long j=0;
	long long suma=0,sumb=0;
	for(int i=1;i<=n;i++)
	{
		while(j+1<=n&&sumb+a[j+1]==(suma^a[j+1]))
		{
			suma^=a[j+1];
			sumb+=a[j+1];
			j++;
		}
		ans+=j-i+1;
		suma^=a[i];
		sumb-=a[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
    int n;
    long a[10010];
    long num[30];
    long counter;
    counter = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a+n);    
 
    for (int i = 1; i < 30; ++i){
      num[i] = pow(2,i);
      }
  
     for(int j = 0;j < n;j++){
         if(a[j] % num[20] == 0){
           a[j] = a[j] / num[20];
           counter = counter + 20;
         } 
       }
  
     for(int j = 0;j < n;j++){
         if(a[j] % num[10] == 0){
           a[j] = a[j] / num[10];
           counter = counter + 10;
         } 
       }
  
     for (int i = 1; i < 10; ++i){
       for(int j = 0;j < n;j++){
         if(a[j] % num[i] == 0){
           counter = counter + 1;
         } 
       }
      }
  
    cout << counter << endl;
  
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int a[3];
	rep(i, 0, 3) cin >> a[i];

	sort(a, a + 3);

	int res = 0;
	while(a[2] - a[0] > 1) {
		res += (a[2] - a[0]) / 2;
		a[0] += (a[2] - a[0]) / 2 * 2;
		sort(a, a + 3);
	}

	if(a[2] - a[1] == 1) res++;
	else if(a[2] == a[1] && a[1] - a[0] == 1) res += 2;

	cout << res << endl;


}


Measured memory_bytes: 256
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def swap(a:Array[Int],i:Int,j:Int) = {
    val temp = a(i)
    a(i) = a(j)
    a(j) = temp
  }

  def bubbleSort(a:Array[Int]) = {
    var cnt = 0
    for(i<-0 until a.length){
      for(j<-0 until a.length-i-1) {
        if(a(j) > a(j+1)) {
          swap(a,j,j+1)
          cnt+=1
        }
      }
    }
    cnt
  }

  def main(args:Array[String]) = {
    var n = 0
    val b = new ArrayBuffer[Int]
    while({n=readInt;n}!=0) {
      val a = for(i<-1 to n) yield readInt
      b += bubbleSort(a.toArray)
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 43824
#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 long long ll;

const int MAX_SIZE = 10000;

struct edge{
	int to;
	int cost;
	int enemy;
};

class Situation{
public:
	int cost;
	int node;
	int money;

	Situation(int cost_,int node_,int money_){
		cost=cost_;
		node=node_;
		money=money_;
	}
	Situation();

	bool operator<(const Situation &s)const{
		return s.cost < this->cost;
	}
};

int V;

const int MAX_V = 101;

vector<edge> G[MAX_V][MAX_V];
//  éêÉ écèàzÅ½Çè­Å¬RXg
int d[MAX_V][MAX_V];
const int INF = 100000000;

//int prevv[MAX_V];
int L;
int N;
int M;

void dijkstra(int s){
	priority_queue<Situation> que;
	for(int i = 0; i < MAX_V; i++)
		fill(d[i],d[i]+MAX_V,INF);
	d[s][L] = 0;
	que.push(Situation(0,s,L));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int node = p.node;
		int money=p.money;
		if(d[node][money] < p.cost)
			continue;
		for(int i = 0; i < G[node][money].size(); i++){
			edge e = G[node][money][i];
			// ¨àðgÁÄìµÄàç¤ê
			if(money-e.cost>=0){
				if(d[e.to][money-e.cost] > d[node][money]){
					d[e.to][money-e.cost] = d[node][money];
					que.push(Situation(d[e.to][money-e.cost],e.to,money-e.cost));
				}
			}
			// ìÈµÌê
			if(d[e.to][money]>d[node][money]+e.enemy){
				d[e.to][money]=d[node][money]+e.enemy;
				que.push(Situation(d[e.to][money],e.to,money));
			}
		}
	}
}

int main(){

	while(cin>>N>>M>>L&&!(N==0&&M==0&&L==0)){
		for(int i = 0; i < MAX_V; i++)
			for(int j = 0; j < MAX_V; j++)
				G[i][j].clear();
		int from,to,cost,enemy;
		for(int i = 0; i < M; i++){
			cin>>from>>to>>cost>>enemy;
			from--;
			to--;
			edge e;
			e.cost=cost;
			e.to=to;
			e.enemy=enemy;
			
			for(int i = 0; i < MAX_V; i++)
				G[from][i].push_back(e);
			e.to=from;
			for(int i = 0; i < MAX_V; i++)
				G[to][i].push_back(e);
		}
		dijkstra(0);
		int minCost=INF;
		for(int i = 0; i < MAX_V; i++)
			minCost=min(minCost,d[N-1][i]);
		cout<<minCost<<endl;
	}

	return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
signed main(){
  int K;cin>>K;
  rep(i,K)cout<<"ACL";
}

Measured memory_bytes: 3560
#include <iostream>

using namespace std;

typedef long long int ll;

int main()
{
	ll a,b;
	cin >> a >> b;
	if(a*b<=0) cout << "Zero" << endl;
	else if(a>0 && b>0) cout << "Positive" << endl;
	else{
		if((abs(a-b)+1)%2==0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
c=[list(map(int,input().split()))for i in range(3)]
x=[0]*3
y=[0]*3
for i in range(3):
    y[i]=c[0][i]-x[0]
    for j in range(3):
        x[i]=c[i][0]-y[0]
judge=True
for i in range(3):
    for j in range(3):
        if x[i]+y[j]!=c[i][j]:
            judge=False
if judge:
    print("Yes")
else:
    print("No")

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    if (a * a * b == x) {
        printf("0.0\n");
    } else if (a * a * b / 2.0 <= x) {
        double y = x - a * a * b / 2.0;
        double tb = (y * 2) / (a * a);
        double rad = atan2(a, b-tb);
        printf("%.10f\n", 90 - rad / M_PI * 180);
    } else {
        double ta = (x * 2) / (a * b);
        double rad = atan2(ta, b);
        printf("%.10f\n", 90 - rad / M_PI * 180);
    }

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] x = line.split(" ");
		int a = Integer.parseInt(x[0]);
		int b = Integer.parseInt(x[1]);
		System.out.println(a * b + " " + (2 * a + 2 * b));
	}

}

Measured memory_bytes: 26040
f = lambda:map(int,input().split())
n,m = f()
ls,lc = [],[]
for i in range(m):
  s,c = f()
  ls.append(s)
  lc.append(c)
  if n>1 and s==1 and c==0:
    print(-1); exit()
la = [-1]*n
for i in range(n):
  if i+1 not in ls:
    la[i] = 0
  for j in range(m):
    if ls[j]==i+1:
      if la[i]>=0 and la[i]!=lc[j]:
        print(-1); exit()
      else:
        la[i] = lc[j]
if n>1 and la[0]==0:
  la[0]=1
print(''.join(map(str,la)))

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

const int N = 1e5 + 5;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c;
    cin>>a>>b>>c;
    if(b/a>=c)cout<<c<<endl;
    else cout<< b/a<<endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextUInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextUInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 20;
    static Stream Stream;
    static byte[] buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static Reader() { Stream = Console.OpenStandardInput(); }

    private static void Read()
    {
        Stream.Read(buffer, 0, BUF_SIZE);
    }

    private static byte Next { get { if (ptr == buffer.Length) { Read(); ptr = 0; } return buffer[ptr++]; } }

    public static int NextUInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; byte next;
            do { next = Next; } while (next < 48);
            do { res = res * 10 + next - 48; next = Next; } while (48 <= next);
            return res;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

struct point{
  int b, c, d;
};

vector<vector<point>> points;
int n, m, q;

int dfs(int k, vi now, int last){
  int ret = 0;
  if(k == n){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < points[i].size(); j++){
        if(now[points[i][j].b] - now[i] == points[i][j].c) ret += points[i][j].d;
      }
    }
    return ret;
  }
  for(int i = last; i <= m; i++){
    vi temp = now;
    temp.push_back(i);
    ret = max(ret, dfs(k+1, temp, i));
  }
  return ret;
}

int main(){
  // start-----------------------------------------------
  cin >> n >> m >> q;
  points = vector<vector<point>>(n);
  for(int i = 0; i < q; i++){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    points[a-1].push_back({b-1, c, d});
  }
  cout << dfs(0, vi{}, 1) << endl;

  // end-----------------------------------------------
}


Measured memory_bytes: 3632
import Control.Applicative

main :: IO ()
main = getLine >> solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve = f 0
  where
    f ct (x:_:xs)
      | odd x = f (ct + 1) xs
      | otherwise = f ct xs
    f ct [x]
      | odd x = ct + 1
      | otherwise = ct
    f ct [] = ct


Measured memory_bytes: 3980
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

using DVector = vector<double>;

double Average(DVector& vec) {
   double sumVal{0};
   for (auto element : vec) {
      sumVal += element;
   }
   return sumVal / vec.size();
}

double Variance(DVector& vec) {
   double sumVal{0}, average{Average(vec)};
   for (auto element : vec) {
      sumVal += pow(average - element, 2);
   }
   return sumVal / vec.size();
}

double StdDev(DVector& vec) {
   return sqrt(Variance(vec));
}

int main() {

   int n{};

   while (cin >> n, n > 0) {
      
      DVector s(n, 0);
      
      for (int i = 0; i < n; ++i) {
         cin >> s[i];
      }
      
      cout << fixed << StdDev(s) << endl;
   }

   return 0;

}

Measured memory_bytes: 3292
n, y = map(int, input().split())

def fun(n, y):
    for i in range(y//10000+1):
        for j in range((y - 10000*i)//5000+1):
            k = (y - 10000*i - 5000*j)//1000
            if i + j + k == n:
                return print(i, j, k)
                break

    return print(-1, -1, -1)

fun(n, y)

Measured memory_bytes: 38768
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


    bool check[200001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    

    
    ll N;
    cin >> N ;
    vector<ll> a;
    vector<pair<ll,ll> >  fromto;
    map<ll,ll> idx;
    rep(i,N){
        ll inp; cin >> inp;
        a.pb(inp);
        idx[inp] = i;
        fromto.pb(mp(i,i));
    }
    
    ll ans = 0;
    for(ll i = N; i>=1; i--){
        ll index = idx[i];

        ll l = index;
        ll r = index;
        
        check[index] = true;
        if(index == 0){
            l = 0;
        }
        else{
            if(check[index-1] == true){
                l = fromto[index-1].first;
            }
        }
        
        if(index == N-1){
            r = N-1;
        }
        else{
            if(check[index+1] == true){
                r = fromto[index+1].second;
            }
        }
        
        fromto[l] = mp(l,r);
        fromto[r] = mp(l,r);
        
        ll left = index - l + 1;
        ll right = r - index +1;
        ans += (left* right*a[index]);
        
    }
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 18400
n, x = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
eat_count = 0
for i in range(1,n):
    eat = a[i] + a[i-1] - x
    if eat > 0:
        a[i] = max(0, a[i]-eat)
        eat_count += eat
print(eat_count)

Measured memory_bytes: 14252
class Mountain
    @data
    def initialize
        @data = []
        while input = gets
            @data << input.to_i
        end
    end
    def sort_data
        @data.sort!.reverse!
    end
    def get_data
        return @data
    end
end

class Main
    def run
        m = Mountain.new
        m.sort_data
        d = m.get_data
        flg = 0
        d.map{|hoge|
            flg = flg + 1
            p hoge
            if (flg == 3) 
                break
            end
        }
    end
end

Main.new.run;

Measured memory_bytes: 6096