akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"io"
	"os"
	"strconv"
)

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	sc := NewScanner(os.Stdin)
	n := sc.Int()

	m := make(map[int]int)
	var sum int

	for i := 0; i < n; i++ {
		n := sc.Int()
		m[n]++
		sum += n
	}

	q := sc.Int()
	for i := 0; i < q; i++ {
		b, c := sc.Int(), sc.Int()

		count, ok := m[b]
		if !ok {
			w.WriteString(strconv.Itoa(sum))
			w.WriteByte('\n')
			continue
		}

		sum -= b * count
		sum += c * count
		w.WriteString(strconv.Itoa(sum))
		w.WriteByte('\n')

		delete(m, b)
		m[c] += count
	}
}

// generated by https://github.com/murosan/gollect

type Scanner struct {
	r     io.Reader
	buf   []byte
	delim byte
	size, eof,
	start, end int
}

func NewScanner(r io.Reader) *Scanner { return NewScannerSize(r, 4096) }
func NewScannerSize(r io.Reader, size int) *Scanner {
	return &Scanner{
		r:     r,
		buf:   make([]byte, size),
		delim: ' ',
		size:  size, start: size, end: size,
	}
}

func (s *Scanner) Int() int { return ParseInt(s.bytes()) }

func (s *Scanner) bytes() []byte { b, _ := s.next(); return b }
func (s *Scanner) next() (b []byte, size int) {
	for n := 0; ; {
		for i := s.end; i < s.size; i++ {
			if s.buf[i] == s.delim || s.buf[i] == '\n' || i == s.eof {
				b, size = s.buf[s.start:i], i-s.start
				s.start, s.end = i+1, i+1
				return
			}
		}
		s.end = s.size
		if n++; n == 2 {
			panic("lack of buffer size")
		}
		s.read()
	}
}
func (s *Scanner) read() {
	copy(s.buf, s.buf[s.start:s.end])
	s.end -= s.start
	s.start = 0
	n, _ := s.r.Read(s.buf[s.end:])
	s.eof = s.end + n
}

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}


Measured memory_bytes: 7500
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
struct node{
    int data;
    node *pre,*next;
};
class Link{
public:
    node *head;
    node *tail;
    int num;
    Link(){
        node *temp=new node();
        temp->data=-1;
        temp->pre=temp->next=NULL;
        head=temp;
        num=0;
        tail=head;
    }
    bool insertData(int x){
        node *temp=new node();
        temp->data=x; temp->pre=head;
        if(num==0){
            tail=temp;
            head->next=temp;
            temp->pre=head;
            temp->next=NULL;
        }else{
            temp->next=head->next;
            head->next->pre=temp;
            head->next=temp;
        }
        num+=1;
        return true;
    }
    bool delData(int x){
        node *temph=head;
        while(temph->next&&temph->next->data!=x)
            temph=temph->next;
        if(temph->next){
            //cout<<"FIND IT!!"<<endl;
            if(!temph->next->next){
                temph->next=NULL;
                tail=temph;

            }else{
                temph->next=temph->next->next;
                temph->next->pre=temph;
            }
            num--;
            return true;
        }
        return false;
    }
    bool deleteFirst(){
        if(num<=0) return false;
        if(num==1){
            head->next=NULL;
            tail=head;
        }else{
            head->next=head->next->next;
            head->next->pre=head;
        }
        num--;
        return true;
    }
    bool deletLast(){
        if(num<=0) return false;
        node *tmp=tail->pre;
        tail->pre=NULL;
        tmp->next=NULL;
        tail=tmp;
        num--;
    }
    void show(){
        node *tmp=head->next;
        if(tmp){
            cout<<tmp->data;
            tmp=tmp->next;
        }
        while(tmp){
            cout<<' '<<tmp->data;
            tmp=tmp->next;
        }
        cout<<endl;
    }
};
int main(){
    Link l;
    int n;
    string s;
    int num;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="insert"){
            cin>>num;
            l.insertData(num);
        }else
        if(s=="delete"){
            cin>>num;
            l.delData(num);
        }else
        if(s=="deleteFirst"){
            l.deleteFirst();
        }else
        if(s=="deleteLast"){
            l.deletLast();
        }
        //cout<<"num= "<<l.num<<endl;

    }
    l.show();

}



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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  if(abs(a)>abs(b)){
    ans+=abs(a)-abs(b);
    if(a>0)
      ans++;
    if(b>0)
      ans++;
  }else if(abs(a)<abs(b)){
    ans+=abs(b)-abs(a);
    if(a<0)
      ans++;  
    if(b<0)
      ans++;
  }else{
    ans=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func main() {
	sc.Split(bufio.ScanWords)

	a, b, x := nextInt(), nextInt(), nextInt()

	ct := b/x - a/x

	if a % x == 0 {
		ct++
	}

	fmt.Println(ct)
}

Measured memory_bytes: 640
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

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

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int ans = INT_MAX;
    for(int i = 0; i + 2 < SZ(s); i++){
        string t = s.substr(i, 3);
        function<int(string)> help = [&](string x){
            int n = SZ(x);
            int num = 0;
            for(auto i : x){
                num = num * 10 + (int)(i - '0');
            }
            debug(num);
            return abs(753 - num);
        };
        ans = min(ans, help(t));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int W,H,x,y,r;

  scanf("%d",&W);
  scanf("%d",&H);
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&r);

  
if(W >= x + r && H >= y + r && 0 <= x - r && 0 <= y - r){
printf("Yes\n");
}else{
  printf("No\n");
}


  return 0;
}


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

inline ll Hs(char c){return c - 'a';}

auto f(const vector<int>&v1, const vector<int>&v2){
  for(int i = 0; i < 26; ++i)
    if(v1[i] < v2[i])return true;
  return false;
}

int main(){
  int n; cin >> n;
  map<vector<int>, int>anag;
  ll ans = 0;
  for(int j = 0; j < n; ++j){
    string s; cin >> s;
    vector<int> v(26,0);
    for(int i = 0; i < 10; ++i){
      v[Hs(s[i])]++;
    }
    anag[v]++;
  }

  for(auto&&e:anag){
    ans += (pow(e.second,2)-e.second)/2;
  }

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


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

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	
	if (b + w < a)
	{
		cout << a - (b + w) << endl;
	}
	else if (a + w < b)
	{
		cout << b - (a + w) << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}


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

MOD = 10 ** 9 + 7
dp = [[0] * 4 for i in range(n + 1)]
for i in range(1, n + 1):
    if i == 1:
        dp[i][0] = 0
        dp[i][1] = 1
        dp[i][2] = 1
        dp[i][3] = 8
    else:
        dp[i][0] = (dp[i - 1][0] * 10 + dp[i - 1][1] + dp[i - 1][2]) % MOD
        dp[i][1] = (dp[i - 1][1] * 9 + dp[i - 1][3]) % MOD
        dp[i][2] = (dp[i - 1][2] * 9 + dp[i - 1][3]) % MOD
        dp[i][3] = (dp[i - 1][3] * 8) % MOD

print(dp[n][0])


Measured memory_bytes: 191348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; ++i)

long long f(const string &S) {
    long long res = 0;
    rep(i, 1, S.size()) if(S[i - 1] == S[i]) {
        res++, i++;
    }
    return res;
}

long long solve() {
    string S; cin >> S;
    int K; cin >> K;
    bool all = true;
    rep(i, 1, S.size()) if(S[i - 1] != S[i]) {
        all = false;
    }
    if(all) return K * S.size() / 2;
    long long cnts = f(S);
    long long cntt = f(S + S);
    long long ans = cnts + (cntt - cnts) * (K - 1);
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main extends App {
  println {
    Iterator.continually(readInt).takeWhile(_ != 0).map { n =>
      var max = (0,0)
      for(i<-1 to n) {
        val e = readLine.split(" ").map(_.toInt)
        val sum = e(1)+e(2)
        if(sum > max._2)
          max = (e(0),sum)
      }
      max._1 + " " + max._2
    }.mkString("\n")
  }
}

Measured memory_bytes: 156148
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int n;cin>>n;
    vector<pair<pair<string,int>,int>> s(n);
    rep(n){
        cin>>s[i].first.first>>s[i].first.second;
        s[i].first.second *= -1;
        s[i].second = i+1;
    }
    sort(all(s));
    rep(n) cout << s[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
l,r = map(int,input().split())
import sys

if r-l>=2019:
    print(0)
    sys.exit()
else:
    amari = 2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            amari = min(amari,(i*j)%2019)
    print(amari)

Measured memory_bytes: 9208
#include<iostream>


using namespace std;


int main(){

	int a;
	cin >> a;
	int b;
	cin >> b;
	int c;
	cin >> c;

		int ans;
	if(c-(a-b)<0){
		ans=0;
	}else{
		ans=c-(a-b);
	}
	cout << ans << endl;





}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<vi, int> cnt;
    forn(i, n) {
        string s;
        cin >> s;
        vi word(26);
        for (char c : s) word[c - 'a']++;
        cnt[word]++;
    }
    ll ans = 0;
    for (auto p : cnt) ans += p.snd * 1ll*(p.snd - 1) / 2;
    cout << ans << "\n";
    return 0;
}

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

int main() {
  // ここにプログラムを追記
  string s ; 
  cin >> s ;
  int ans = 0 ; 
  
  if ( s[0] == '1') ans += 1 ; 
  if (s[2] == '1' ) ans += 1 ;
  if (s[1] == '1' ) ans += 1 ; 
  
  cout << ans ; 
  
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
string s;
int main(){
    cin>>s;
    if (s[0]==s[1] && s[1]==s[2]) return puts("Yes")*0;
    if (s[1]==s[2] && s[2]==s[3]) return puts("Yes")*0;
    puts("No");
    return 0;
}
/*ll a[87];
int main(){
    int n;
    a[0]=2,a[1]=1;
    for (int i=2;i<=86;i++) a[i]=a[i-1]+a[i-2];
    read(n);
    cout<<a[n]<<endl;
    return 0;
}*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
const ll INF=1e18L+5;
int main()
{
    ll n,w;
    cin>>n>>w;
   vector<ll>value(n),weight(n);
   int sum_index=0;
   for(int i=0;i<n;i++)
   {
       cin>>weight[i]>>value[i];
   }
   for(int x:value)
   {
       sum_index+=x;
   }
   vector<ll>dp(sum_index+1,INF);
   dp[0]=0;
    for(int item=0;item<n;item++){
            for( int value_already=sum_index-value[item];value_already>=0;value_already--)
            {
        dp[value_already+value[item]]=min(dp[value_already+value[item]],dp[value_already]+weight[item]);
            }

    }
    ll answer=0;
    for(int i=0;i<=sum_index;i++)
    {
        if(dp[i]<=w)
            answer=max(answer,(ll)i);
    }
    cout<<answer<<endl;
    return 0;
}



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

int n, m, q;
int a[N], b[N], c[N];

int p[N];

int fi(int x)
{
    if (x == p[x])
        return x;
    return p[x] = fi(p[x]);
}

void kpc(int x, int y)
{
    x = fi(x);
    y = fi(y);
    p[x] = y;
}

bool solv()
{
    if (m == n - 1)
    {
        for (int i = 0; i < q; ++i)
        {
            if (c[i] == 1)
                return false;
        }
        return true;
    }
    for (int i = 0; i < n; ++i)
        p[i] = i;
    for (int i = 0; i < q; ++i)
    {
        if (c[i] == 0)
            kpc(a[i], b[i]);
    }
    for (int i = 0; i < q; ++i)
    {
        if (c[i] == 1)
        {
            if (fi(a[i]) == fi(b[i]))
                return false;
        }
    }
    set<int> s;
    for (int i = 0; i < n; ++i)
        s.insert(fi(i));
    return (m <= s.size() * 1LL * (s.size() - 1) / 2 + n - s.size());
}

int main()
{
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    if (solv())
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 6528
class common_combinations():
    """
        mod を含む combination を高速に求める関数
        N < 5*10^6 まで対応. それ以上の N の場合は common.combi(n, k) を使用する.
        __init__: nCk を求めるための事前の計算を行う. O(N)
        combinations: nCk を求める. O(1)
    """
    def __init__(self, N=510000, MOD=pow(10, 9) + 7):
        """
            combination を O(1) で計算するための前処理
        """
        self.N = N
        self.MAX_NUM = self.N + 1
        self.MOD = MOD

        self.fac  = [0 for _ in range(self.MAX_NUM)]
        self.finv = [0 for _ in range(self.MAX_NUM)]
        self.inv  = [0 for _ in range(self.MAX_NUM)]

        self.fac[0]  = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1

        for i in range(2, self.MAX_NUM):
            self.fac[i] = self.fac[i-1] * i % self.MOD
            self.inv[i] = self.MOD - self.inv[self.MOD%i] * (self.MOD // i) % self.MOD
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.MOD

    def combinations(self, n:int, k:int):
        """
            combination を計算して返すメソッド
        """
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.MOD) % self.MOD

MOD =  pow(10,9)+7
def MODINV(n:int, MOD=MOD):
    return pow(n, MOD-2, MOD)

def main():
    common = common_combinations(N = 3000)
    S = int(input())
    ans = 0
    for i in range(S):
        R = S - 3*i
        ans += common.combinations(R+i-1, i-1)
    print(ans%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=2E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
vector<LL> a;
void solve(){
    LL sum = 100;
    a.PB(sum);
    rep(i,3760) {
        sum += sum * 0.01;
        a.PB(sum);
    }
    LL n;
    cin>>n;
    cout<<lower_bound(a.begin(),a.end(),n)-a.begin()<<"\n";
}
int main(){
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int p[n];
	for(int i=0;i<n;i++){
			cin>>p[i];
	}
	int count=1;
	int d=p[0];
	
	for(int i=1;i<n;i++){
		if(p[i]<d){
			d=p[i];
		}
		if(p[i]<=p[i-1]&&p[i]<=d){
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
K = int(input())

if K == 1:
    print(1)
    exit(0)

amari = 7%K
for i in range(1, K+1):
    if amari == 0:
        print(i)
        exit(0)
    else:
        amari = (amari*10)+7
        amari = amari%K

print(-1)

Measured memory_bytes: 63188
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++);

int main(){
    int D,G;
    cin >> D >> G;
    int p[11],c[11];
    
    int i,j;
    for(i=0;i<D;i++){
        cin >> p[i] >> c[i];
    }
    ll ans = 1000000;
    int count = 0;
    for(i=0;i<(1<<D);i++){
        count = 0;
        int tmp = 0;
        for(j = 0;j<D;j++){
            if(i&(1<<j)){
                tmp += (j+1)*100*p[j] + c[j];
                count += p[j];
                
            }
        }
        if(ans>=count&&tmp>=G){
            ans = count;
            //cout << ans << endl;
        }else if(tmp<G){
            for(j=D-1;j>=0;j--){
                if(i&(1<<j)){
                    continue;
                }else{
                    int ch = 0;
                    while(tmp<G && p[j]>ch){
                    tmp+=(j+1)*100;
                    count ++;
                    ch++;
                    //cout << tmp <<", " << count<< endl;
                    }
                }
                if(ans>=count&&tmp>=G){
                    ans = count;
                }
            }
        }
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	char[][] f;
	boolean[][] visit;
	int H, W;

	void run() {
		for (;;) {
			H = sc.nextInt();
			W = sc.nextInt();
			if ((H | W) == 0) {
				return;
			}
			f = new char[H][W];
			visit = new boolean[H][W];
			for (int i = 0; i < H; i++) {
				String in = sc.next();
				for (int j = 0; j < W; j++) {
					f[i][j] = in.charAt(j);

				}
			}
			boolean one = true;
			char pre;
			pre = f[0][0];
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (pre != f[i][j]) {
						one = false;
					}
					pre = f[i][j];
				}
			}
			if (one) {
				System.out.println(1);
				continue;
			}

			int cnt = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (!visit[i][j]) {
						dfs(i, j, f[i][j]);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		}
	}

	void dfs(int h, int w, char ob) {
		visit[h][w] = true;
		for (int i = 0; i < 4; i++) {
			int nextH = h + dy[i];
			int nextW = w + dx[i];
			if (inner(nextH, nextW, H, W)) {
				if (!visit[nextH][nextW] && f[nextH][nextW] == ob) {
					dfs(nextH, nextW, ob);
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(char[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;

		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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


int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
bool s = true;
int ans = 0;

while(s){
  int count = 0;
  for(int i=0 ;i<n;i++){
    if(a[i]%2 == 0){
  
    a[i]=a[i]/2 ;
    count++;
    }
  }

  if(count != n){
    s=false;
  }else{
     ans++;
    s=true;
  }
}
cout<<ans<<endl;

  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int MOD=MOD1;
int32_t main()
{
     int n,m;
     cin>>n>>m;
     if(n<m)
     {
     	rep(i,0,m)
     	cout<<n;
     	cout<<endl;
     }
     else
     {
     	 rep(i,0,n)
     	 cout<<m;
     	 cout<<endl;
     }	
     return 0;     
}

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

using namespace std;
using tiii = tuple<int, int, int>;
static constexpr int INF = 1000000000;

static const int dx[] = { -1, 0, 1, 0 };
static const int dy[] = { 0, -1, 0, 1 };

inline bool between(int a, int b, int c){
	return a <= b && b < c;
}

int main(){
	ios_base::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	int y1, x1, y2, x2;
	cin >> y1 >> x1 >> y2 >> x2;
	--x1; --y1; --x2; --y2;
	vector<string> field(h);
	for(int i = 0; i < h; ++i){ cin >> field[i]; }
	vector<vector<array<int, 4>>> grid(h, vector<array<int, 4>>(w));
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			for(int d = 0; d < 4; ++d){ grid[i][j][d] = INF; }
		}
	}
	queue<tiii> q;
	for(int d = 0; d < 4; ++d){
		grid[y1][x1][d] = 0;
		q.emplace(y1, x1, d);
	}
	while(!q.empty()){
		const auto t = q.front();
		q.pop();
		const int y0 = get<0>(t), x0 = get<1>(t), d0 = get<2>(t);
		const int c = grid[y0][x0][d0];
		for(int i = 1; i <= k; ++i){
			const int y = y0 + dy[d0] * i;
			const int x = x0 + dx[d0] * i;
			if(!between(0, y, h) || !between(0, x, w)){ break; }
			if(field[y][x] == '@'){ break; }
			if(grid[y][x][d0] < c + 1){ break; }
			const int d1 = (d0 + 1) & 3, d2 = (d0 + 3) & 3;
			grid[y][x][d0] = c + 1;
			if(i == k){ q.emplace(y, x, d0); }
			if(grid[y][x][d1] > c + 1){
				grid[y][x][d1] = c + 1;
				q.emplace(y, x, d1);
			}
			if(grid[y][x][d2] > c + 1){
				grid[y][x][d2] = c + 1;
				q.emplace(y, x, d2);
			}
		}
	}
	int answer = INF;
	for(int d = 0; d < 4; ++d){
		answer = min(answer, grid[y2][x2][d]);
	}
	if(answer >= INF){ answer = -1; }
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 35716
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, c = 0, tc = 0;
    string S;
    cin >> N >> S;
    REP(i, S.size()) {
        if (S[i] == '(') c++;
        else {
            if (c == 0) tc++;
            else c--;
        }
    }
    REP(i, tc) cout << "(";
    cout << S;
    REP(i, c) cout << ")";
    cout << endl;
    return 0;
}

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

x = [0 for _ in range(n)]
u = [0 for _ in range(n)]

ans = 0

for i in range(n):
    x[i], u[i] = input().split()

    if u[i] == 'JPY':
        x[i] = int(x[i])
        ans += x[i]

    else:
        x[i] = float(x[i])
        ans += 380000.0 * x[i]

print(ans)


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

using namespace std;

int main(void){
    int num[3];
    for(int i=0;i<3;i++){
        cin>>num[i];
    }
    sort(num,num+3);
    cout<<10*num[2]+num[1]+num[0]<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if (x - r < 0) {
    cout<<"No";
  } else if (y - r < 0) {
    cout<<"No";
  } else if (x + r > w) {
    cout<<"No";
  } else if (y + r > h) {
    cout<<"No";
  } else {
    cout<<"Yes";
  }

  cout<<endl;
  return 0;
}



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

typedef long long ll;
const int maxn=10000+5;
const int minn=1000+5;
const int inf=2e9+2;
int n,a[minn],po[maxn];
void solve()
{

    sort(a+1,a+n+1);
    int f=0,tp=inf,t=0,tmin=a[1];
    ll w=0,ans=0;
    for (int i = 1; i <= n; ++i)
    {
        if(po[a[i]]==i){continue;}
        tp=inf;t=1;w=0;
        int f=po[a[i]];
        w+=a[i];
        tp=a[i];
        while(f!=i)
        {
            t++;tp=min(a[f],tp);
            w+=a[f];
            int tm=f;
            f=po[a[f]];
            po[a[tm]]=tm;
        }
        ans+=min(w+(t-2)*tp,w+tp+(t+1)*tmin);
    }
    printf("%lld\n",ans);
}
int main()
{
    scanf("%d",&n);
	for (int i = 1; i <= n; ++i)
    {
        scanf("%d",&a[i]);
        po[a[i]]=i;
    }
    solve();
    return 0;
}


Measured memory_bytes: 3292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>
//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class DLuckyPIN {
    const int N = 1'000;

public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        string str;
        in >> str;
        int res = 0;
        for (int pin = 0; pin < N; ++pin) {
            int first = pin / 100, second = pin / 10 % 10, third = pin % 10;
            bool bfirst = false, bsecond = false, bthird = false;
            for (char c: str) {
                int d = c - '0';
                if (bsecond and d == third) {
                    bthird = true;
                }
                if (bfirst and d == second) {
                    bsecond = true;
                }
                if (d == first) {
                    bfirst = true;
                }
            }
            res += bthird;
        }
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    DLuckyPIN solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, p, a, b, c;
  scanf("%lld%lld%lld", &n, &m, &p);
  vector< pair<ll, ll> > vec[n];
  vector<ll> rev[n];
  ll d[n], d2[n];
  for(i = 0; i < m; ++i) {
    scanf("%lld%lld%lld", &a, &b, &c);
    vec[--a].push_back(make_pair(--b, c - p));
    rev[b].push_back(a);
  }
  bool flg[n], ans = false;
  for(i = 0; i < n; ++i) d[i] = -1e9, flg[i] = false;
  flg[n - 1] = true;
  for(i = 0; i < n; ++i) 
    for(j = 0; j < n; ++j) if(flg[j]) for(k = 0; k < rev[j].size(); ++k)
      flg[rev[j][k]] = true;
  d[0] = 0;
  for(i = 0; i < n; ++i) 
    for(j = 0; j < n; ++j) if(d[j] != -1e9) for(k = 0; k < vec[j].size(); ++k) 
      if(d[vec[j][k].first] < d[j] + vec[j][k].second) d[vec[j][k].first] = d[j] + vec[j][k].second;
  for(i = 0; i < n; ++i) d2[i] = d[i];
  for(i = 0; i < n; ++i) 
    for(j = 0; j < n; ++j) if(d[j] != -1e9) for(k = 0; k < vec[j].size(); ++k) 
      if(d[vec[j][k].first] < d[j] + vec[j][k].second) d[vec[j][k].first] = d[j] + vec[j][k].second;
  for(i = 0; i < n; ++i) if(flg[i] && d2[i] != d[i]) ans = true; 
  if(ans) printf("-1");
  else printf("%lld", d[n - 1] > 0 ? d[n - 1] : 0);
  return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int>p;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		p.push_back(x);
	}
	for (int i = 0; i < n - 1; i++) {
		if (p[i] == p[i + 1]) {
			p[i + 1] = 0;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
res = 0
for i in range(n):
    if a[i] == i + 1:
        res += 1
        if i != n-1:
            a[i],a[i+1] = a[i+1],a[i]
print(res)
        

Measured memory_bytes: 77084
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back 
#define MP make_pair
typedef long long ll;
const ll INF=1<<28;
const ll LINF=1ll<<61;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
ll x,y;
int main()
{
	cin>>x>>y;
	for(int i=50;i>=1;i--)
	{
		ll nx=x+(1ll<<(i-1)),ny=y-(1ll<<i);
		if(ny>=0)
		{
			if(nx<=ny/2)
			{
				x=nx;
				y=ny;
			}
		}
	}
	cout<<min(x,y/2)<<endl;
	return 0;
}

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

using namespace std;

int n, m, x, y;
long long ans;

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(i == 1){
			y = x;
			continue;
		} 
		int j = max(0, x + y - m);
		ans += j, y = max(0, x - j); 
	}	
	printf("%lld", ans);
}

Measured memory_bytes: 3816
#include <iostream>
#include <string>
using namespace std;
int main()
{
    char s;
    cin >> s;
   if ((s - '0') >= 49) { // a~z:49~74 A~Z:17~42
        cout << "a" << endl;
    }
    else {
        cout << "A" << endl;
    }

}

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

int main() {
    long int N;
    cin >> N;
    long int sum = 0;
    long int R = 1;
    while (R * (R + 2) <= N) {
        if (N % R == 0) {
            sum += (N / R) - 1;
        }
        R++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int x,a,b;
	cin >> x >> a >> b;
	if(b<=a){
		cout << "delicious" << endl;
	}else if(b<=(a+x)){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

template<typename T>
struct BIT{
  int n;
  vector <T> d;
  BIT(int n = 0):n(n), d(n+1){}
  void add(int i, T x = 1){
    for (i++; i <= n; i += i&-i){
      d[i] += x;
    }
  }
  T sum(int i){
    T x = 0;
    for (i++; i;i -= i&-i){
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r){
    return sum(r-1)-sum(l-1);
  }
};



int main(){
  int n, q; cin >>n >>q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> pi(n+1,-1);
  vector<vector<int>> ps(n);
  rep(i, n){
    int l = pi[a[i]];
    if (l != -1)ps[l].push_back(i);
    pi[a[i]] = i;
  }
  vector <vector<P>> qs(n);
  rep(qi, q){
    int l, r;
    cin >> l >> r;
    l--; r--;
    qs[l].emplace_back(r, qi);
  }
  vector<int> ans(q);
  BIT<int> d(n);
  for (int x = n-1; x >= 0;--x){
    for (int y :ps[x]) d.add(y, 1);
    for (P query:qs[x]){
      int r = query.first, i = query.second;
      ans[i] = r-x+1-d.sum(r);
    }
  }
  rep(i, q) cout << ans[i] <<endl;
  return 0;
}

Measured memory_bytes: 59960
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#pragma warning (disable: 4996)

int n, t[109], v[109], s[109], p[40009];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) { cin >> t[i]; t[i] *= 2; s[i + 1] = s[i] + t[i]; }
	for (int i = 1; i <= n; i++) { cin >> v[i]; v[i] *= 2; }
	for (int i = 0; i <= s[n + 1]; i++) {
		for (int j = 1; j <= n + 1; j++) { if (s[j] >= i) { p[i] = v[j - 1]; break; } }
		for (int j = 1; j <= n + 1; j++) {
			int dst = abs(s[j] - i);
			p[i] = min(p[i], dst + min(v[j - 1], v[j]));
		}
	}
	int sum = 0;
	for (int i = 0; i <= s[n + 1]; i++)sum += p[i];
	printf("%.12Lf\n", 0.25l*sum);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

map<int,int> b;

int main() {
    int N, K;
    cin >> N >> K;
    
    int a;
    rep(i,N) {
        cin >> a;
        b[a]++;
    }
    
    if(K>=b.size()) {
        cout1(0);
        return 0;
    }
    
    vector<pair<int,int>> ball;
    
    for(auto x:b) {
        ball.push_back({x.second,x.first});
    }
    
    sort(ball.begin(), ball.end());
    
    int ans=0;
    rep(i,ball.size()-K) {
        ans += ball[i].first;
    }
    
    cout1(ans);
}


Measured memory_bytes: 11764
#include<stdio.h>
#include<string.h>
char a[10000];
int b[10000];
int main()
{
	int i,j,k,n,m;
	scanf("%d%d",&n,&m);
	if(n==1&&m!=1)
	printf("Alice");
	else if(m==1&&n!=1)	
	printf("Bob");
	else if(n>m)
	printf("Alice");
	else if(n<m)
	printf("Bob");
	else printf("Draw");
	return 0;
	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var answerList = new List<int>();
            int answer = 0;

            while (true)
            {
                String s = Console.ReadLine();
                string[] strInputList = s.Split();

                int a = int.Parse(strInputList[0]);
                String simbol = strInputList[1];
                int b = int.Parse(strInputList[2]);

                if (simbol.Equals("?"))
                {
                    break;
                }

                switch (simbol)
                {
                    case "+":
                        answer = a + b;
                        break;
                    case "-":
                        answer = a - b;
                        break;
                    case "*":
                        answer = a * b;
                        break;
                    case "/":
                        answer = a / b;
                        break;
                }
                answerList.Add(answer);
            }

            foreach (int value in answerList)
            {
                Console.WriteLine(value);
            }                     
        }
    }
}


Measured memory_bytes: 17832
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors
ans = make_divisors(N-1)
del ans[0]
cand = make_divisors(N)
del cand[0]
for one in cand:
    n = N
    while True:
        if n%one==0:
            n = n//one
        else:
            if n%one==1:
                ans.append(one)
            break

print(len(ans))

Measured memory_bytes: 39024
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K,Q;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read4();
      for(int i=0;i<Q;i++){
              string tmp = Console.ReadLine();
        s.Add(int.Parse(tmp));
      }
      int[] t=new int [N];  
        for(int i=0;i<Q;i++){
t[s[i]-1]++  ;
        }
for(int i=0;i<N;i++){if(Q-t[i]>=K){Console.WriteLine("No");}else{Console.WriteLine("Yes");}}      
      
      //Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
      Q=int.Parse(tmp[2]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}

Measured memory_bytes: 16860
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();


		if (a < 1200) {

			System.out.println("ABC");

		} else {

			System.out.println("ARC");


		}

	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a;
  cin >> a;
  if(a>81)cout << "No" << endl;
  else{
    int ans=0;
    rep(i,9){
      int r=i+1;
      if(a%r==0&&a/r<10)ans=1;
    }
    if(ans==1){
      cout << "Yes" << endl;
    } 
    else cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
N, M = (int(i) for i in input().split())

shop_list = []
for i in range(N):
  shop = [int(i) for i in input().split()] 
  shop_list.append(shop)

shop_list.sort()

money = 0
while(M > 0):
  for shop in shop_list:
    if M > shop[1]:
      money += shop[0] * shop[1]
      M -= shop[1]
    else:
      money += shop[0] * M
      M = 0

print(money)

Measured memory_bytes: 21608