akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll MAXN = 101024;

ll x[MAXN];
ll v[MAXN];

ll f[MAXN];
ll g[MAXN];

ll ff[MAXN];
ll gg[MAXN];

int main() {
    ll n,c; cin>>n>>c;
    x[0] = 0; v[0] = 0;
    x[n+1] = c; v[n+1] = 0;
    for(ll i = 1; i <= n; ++i) {
        cin>>x[i]>>v[i];
    }

    ll ene = 0;
    ll fmax = 0;
    for(ll i = 1; i <= n; ++i) {
        ene += v[i];
        if(ene > x[i]) {
            fmax = max(fmax, ene - x[i]);
        }
        f[i] = fmax;
        ff[i] = ene;
    }

    ene = 0;
    fmax = 0;
    for(ll i = n; i >= 1; --i) {
        ene += v[i];
        if(ene > x[n+1] - x[i]) {
            fmax = max(fmax, ene - (x[n+1] - x[i]));
        }
        g[i] = fmax;
        gg[i] = ene;
    }

    ll res = 0;
    for(ll i = 2; i <= n+1; ++i) {
        ll p = gg[i] + f[i-1];
        ll m = 2 * (x[n+1] - x[i]);
        if(p > m) res = max(res, p - m);
    }

    for(ll i = 0; i <= n-1; ++i) {
        ll p = ff[i] + g[i+1];
        ll m = 2 * x[i];
        if(p > m) res = max(res, p - m);
    }

    cout << res << endl;

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;



int main(){
    int N; cin >> N;
    string S; cin >> S;
    for(int i=0; i<(int)S.size(); i++){
        char ch=(S[i]-'A'+N)%26+'A';
        cout << ch;
    }
    cout << endl;
    return 0;
}

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


using namespace std;


int main() {
   int N, K;
   scanf("%d %d", &N, &K);
   int  rec = N / K;
   int rem = N % K;
   int max = rem + rec;
   int min = rec;
   int diff = max - min;

printf("%d\n", diff);



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    string s; cin >> s;
    int cnt = 0;
    for ( int i = 1 ; i < s.size(); i++ ){
        if ( i % 2 == 0){
            if ( s[i] != s[0]) cnt++;
        }
        else{ if ( s[i] == s[0]) cnt++;}
    }
  	int ans = s.size();
    ans = min(cnt,ans-cnt);
    cout << ans << endl;
}

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

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

	int ans1 = (N * (N - 1)) / 2;
	int ans2 = (M * (M - 1)) / 2;
	cout << ans1 + ans2 << endl;
}

Measured memory_bytes: 256
/**
 *   author: malviyanshiv
 *   created: 09 January 2019  23:27:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 100005

typedef long long ll;
typedef pair< int, int > PII;

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

vector< vector<double> > dp(3000, vector<double>(3000, -1));
vector<double> ph(3000);

double cal(int n, int k ){
    if( n < k )
        return 0;
    if( k == 0 || n == 0)
        return 1;
    if( dp[n][k] >= 0 )
        return dp[n][k];
    else
        return dp[n][k] = cal(n-1, k-1)*ph[n] + cal(n-1, k)*(1-ph[n]);
}


int main(){
	optimizeIO();
    int n;
    cin >> n;
    REP(i, 1, n+1)
        cin >> ph[i];
    double v = ph[1];
    dp[1][1] = v;
    REP(i, 2, n+1){
        v = v * ph[i];
        dp[i][i] = v;
    }

    printf("%0.10f", cal(n, n/2+1));


	return 0;
}


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

int main(){
	ll a,b,n;
	cin >> a >> b >> n;
	ll test = min(b-1,n);
	cout << floorl(a*test/b) << endl;
}

Measured memory_bytes: 3752
n,k = map(int,input().split())
li1 = [0]*n
li2 = []
for i in range(n):
    li1[i] += i+1
for i in range(k):
    S = input()
    li2 += input().split()
li3 = [int(s) for s in li2]
diff = set(li1) ^ set(li3)
print(len(diff))


Measured memory_bytes: 9624
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 解説
S = sys.stdin.buffer.readline().decode().rstrip()
N = len(S)

cs = [0] * N
h = 0
for i, c in enumerate(S):
    h ^= 1 << (ord(c) - ord('a'))
    cs[i] = h


def dump(h):
    import numpy as np
    print(np.binary_repr(h, 26))


def dumpdp(dp):
    for k in dp.keys():
        if dp[k] < INF:
            dump(k)
            print(dp[k])
    print()


# dp[h]: それまでのハッシュが h である位置以前の分割方法の最小値
dp = defaultdict(lambda: INF)
dp[0] = 0
dp[cs[0]] = 1
for i in range(1, N):
    # print(S[i - 1])
    # dumpdp(dp)

    h = cs[i]
    if h == 0:
        continue
    d = 1
    while d < (1 << 26):
        # i から h^d の位置までまとめて 1 つ切り出せる
        dp[h] = min(dp[h], dp[h ^ d] + 1)
        d <<= 1

if cs[-1] == 0:
    print(1)
else:
    print(dp[cs[-1]])


Measured memory_bytes: 357328
#include <iostream>

int main(){
    int a, b = 0;
    std::cin >> a >> b;
    if(a-b>0){
        std::cout << "a" << " > " << "b" << std::endl;
    }else if(a-b<0){
        std::cout << "a" << " < " << "b" << std::endl;
    }else if(a==b){
        std::cout << "a" << " == " << "b" << std::endl;
    }
    return 0;
}



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

using namespace std;

int n, m, x;
int c[15];
int res = 1e9;
int a[15][15];
vector<int> ans;

void f(int i)
{
    //  cout << i << endl;
    if (i == n)
    {
        vector<int> A(m, 0);
        int sum = 0;
        for (int j = 0; j < ans.size(); j++)
        {
            sum += c[ans[j]];
            for (int k = 0; k < m; k++)
            {
                A[k] += a[ans[j]][k];
            }
        }

        for (int j = 0; j < m; j++)
        {
            if (A[j] < x)
            {
                return;
            }
        }

        res = min(res, sum);
        return;
    }

    ans.push_back(i);
    f(i + 1);
    ans.pop_back();
    f(i + 1);

    return;
}

int main()
{
    cin >> n >> m >> x;

    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    // cout << "Iji2" << endl;

    f(0);

    if (res == 1e9)
    {
        cout << -1 << endl;
    }
    else
        cout << res << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

int main(){
    ll r,D,x;
    cin >> r>>D>>x;
    ll keep=x;
    for(int i=0;i<10;i++){
        x=keep;
        keep=r*x-D;
        cout << (ll)keep << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int fc(const vector<int> &v, int i, int j){
  int res = v.size() - (lower_bound(ALL(v), j) - v.begin());
  int t = j - i;
  t += j;
  auto itr = lower_bound(ALL(v), t);
  if(itr != v.end() && *itr == t)res--;
  return res;
}

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vector<int>> v(3, vector<int>());
  rep(i, s.size()){
    if(s.at(i) == 'R') s.at(i) = 0;
    if(s.at(i) == 'G') s.at(i) = 1;
    if(s.at(i) == 'B') s.at(i) = 2;
  }
  ll ans = 0;
  rep(i, n) v.at(s.at(i)).push_back(i);
  rep(i, n)rep2(j, i+1, n){
    if(s.at(i) == s.at(j)) continue;
    rep(l, 3){
      if(s.at(i) != l && s.at(j) != l) ans += fc(v.at(l), i, j);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
long long M = 1e9+7;
long long power(long long a, long long p)
{
    if(p==0) return 1;
    long long ans= power(a,p/2);
    ans =(ans * ans) % M;
    if(p%2) ans = (ans*a) % M;
    return ans;
}

bool isPrime(long long n)
{
    if (n <= 1)
        return false;
    for (long long i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
long long SieveOfEratosthenes(long long n, long long a)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (long long p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (long long i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (long long p=2; p<=n; p++)
       if (prime[p])
       {
           if(a%p==0)
           {
               return (a-p);
           }
       }
}
long long nCr(int n, int r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}
//int vis[51][51];
//int x[]={1,0,0,-1};
//int y[]={0,1,-1,0};
/* void dfs_visit(long long n,long long a, long long b)
{
    vis[a][b]=1;
    for(int i=0; i<4; i++)
    {

        int p=a+x[i];
        int q=b+y[i];
        if(p>=0 && p<n && q>=0 && q<n && vis[p][q]==0)
        {
           // cout<<p<<" "<<q<<endl;
            vis[p][q]=1;
            dfs_visit(n,p,q);
        }
    }
}
*/
long long fun(long long a)
{
    long long co=1,res=0;
    while(a>0)
    {
        if(a%2==0)
        {
            res=co;
        }
        a/=2;
        co++;
    }
    return res;
}

int main()
{
    IOS;
    long long a,b,c,d,e,h,l,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
   // vector<string>vs;
   // vector<string>vs1;
    //map<long long,long long>mp;
    //set<long long>s;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
   // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    //int x[]={1,1,1,0,0,-1,-1,-1};
    //int y[]={0,1,-1,1,-1,1,-1,0};
    //int x[]={1,0,0,-1};
    //int y[]={0,1,-1,0};
    cin>>n;
    a=100;
    for(int i=1; ; i++)
    {
        a+=((a/100));
        if(a>=n)
        {
            b=i;
            break;
        }
    }
    cout<<b<<endl;
    return 0;
}


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

int main() {
    ll k, x, d;

    cin >> x >> k >> d;
    if (x >= 0 && (double) sqrt(x) >= (double) sqrt(k) * (double) sqrt(d))
        cout << x - k * d;
    else if (x <= 0 && (double) sqrt(k) * (double) sqrt(d) <= sqrt(abs(x)))
        cout << abs(x + k * d);
    else {
        ll moves = k - (x / d + 1);
        ll start = x - ((x / d  + 1) * d);
        ll next = start + d;
        if (x < 0)
            start = x + ((abs(x) / d + 1) * d), moves = k - (abs(x) / d + 1), next = start - d;

        if (moves % 2)
            cout << abs(next) << " ";
        else
            cout << abs(start) << " ";
    }

    return 0;
}


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

int main() {
  int n, a, b, a_score, b_score;
  while (true) {
    a_score = 0;
    b_score = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    int i;
    for (size_t i = 0; i < n; i++) {
      cin >> a >> b;
      if (a == b) {
        a_score += a;
        b_score += b;
      } else if (a > b) {
        a_score += a + b;
      } else {
        b_score += a + b;
      }
    }
    cout << a_score << " " << b_score << endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	int cnt = 0;
	rep(i, n) { ans += abs(a[i]); if (a[i] < 0) cnt++; }
	if (cnt & 1) {
		int mn = inf;
		rep(i, n) mins(mn, abs(a[i]));
		ans -= mn * 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    vector<vector<int>> dp(h,vector<int>(w,0));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(i==0){
                if(j==0){
                    dp[i][j]=(s[i][j]=='#');
                }else{
                    dp[i][j]=dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#');
                }
            }else{
                if(j==0)dp[i][j]=dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#');
                else{
                    dp[i][j]=min(dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'),dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 384
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};
use std::{cmp, fmt};

fn main() {
    let a_s: Vec<u64> = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        let n = sc.next();
        sc.vec(n)
    };
    let r = a_s.into_iter().map(|a| a.trailing_zeros()).sum::<u32>();
    println!("{}", r);
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << min(A,B) + min(C,D) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String t = sc.next();
	int[] pin = new int[s.length()];

	if(s.contains(t)) System.out.println(0);
	else {
	    for(int i=0; i<t.length(); i++){
		for(int i2=i; i2<s.length()-t.length()+i+1; i2++){
		    t=t+" ";
		    s=s+" ";
		    if(s.substring(i2,i2+1).equals(t.substring(i, i+1)))pin[i2-i]++;
		    t=t.trim();
		    s=s.trim();
		}		
	    }
	    int max=0;
	    for(int i=0; i<s.length(); i++){
		if(pin[i]>max){
		    max=pin[i];
		}
	    }		
	    System.out.println(t.length()-max);
	}
    }
}


Measured memory_bytes: 58184
N, K, Q = map(int, input().split())
lst1 = [K] * N
lst2 = [Q] * N
for _ in range(Q):
    n = int(input()) - 1
    lst2[n] -= 1
for i in range(N):
    if lst1[i] - lst2[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7396
from decimal import Decimal
import math
a, b, h, m = map(int, input().split())
# 角度を求める
m1 = Decimal(6)
h1 = Decimal(1) / Decimal(2)
m2 = Decimal(m1) * Decimal(m)
h2 = Decimal(h) * Decimal(30) + Decimal(h1) * Decimal(m)
# 余弦定理
ans = Decimal(a ** 2 + b ** 2 - 2 * a * b *
              math.cos(math.radians(abs(h2 - m2)))) ** (Decimal(1) / Decimal(2))
print('{: .10f}'.format(ans))

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int x,y; cin >> x >> y;
	if(y>=2*x && y<=4*x && y%2==0){
		cout << "Yes" << endl;
	} else cout << "No" << endl;
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    string s;
    while(1) {
        s=to_string(n);
        if (s[0]==s[1]&&s[1]==s[2]) {
            cout<<s<<endl;
            return 0;
        }
        n++;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    double n, k;
    cin >> n >> k;
    double ret = 0;
    for(int i=1;i<=n;i++){
       double tmp=1.0/n;
       int now =i;
       while(now<k){
           now*=2;
           tmp/=2;
       }
       ret+=tmp;
    }
    cout << fixed << setprecision(10);
    cout << ret;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    string s,t;
    cin>>s>>t;
    if(s==t.substr(0,s.size())&&s.size()+1==t.size()){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3632
#include <cstdio> 
#include <cmath>
#include <iostream>
using namespace std;

int N, M;
int L[300010], R[300010];
int l, r;
int l1[100010], r1[100010];
int sq;
double E = 1e-6;
int tree[300000];
int left2[300000], right2[300000];
int m;
int del[100010];

void addTree(int nd, int ll, int rr)
{
	if(ll<=left2[nd] && rr>=right2[nd]){
		tree[nd] ++;
		return ;
	}
	if(ll>right2[nd] || rr<left2[nd])
		return ;
	addTree(2*nd, ll, rr);
	addTree(2*nd+1, ll ,rr);
}


void solve()
{
	int i, j;
	m = 1;
	while(m<M)
		m *= 2;
	for(i=0; i<m; i++){
		left2[m+i] = i+1;
		right2[m+i] = i+1;
	}
	for(i=m-1; i>=1; i--){
		left2[i] = left2[2*i];
		right2[i] = right2[2*i+1];
	}
	
	int n;
	sq = (int)(sqrt(1.0*M)) + 1;
	for(i=0; i<N; i++){
		l = L[i], r = R[i];
		n = 0;
		int rsq = (int)(sqrt(1.0*r)) + 1;
		//for(j=1; j<=r && j<=sq; j++){
		for(j=1; j<=rsq; j++){
			l1[n] = (l-1)/j+1;
			r1[n] = r/j;
			if(l1[n] <= r1[n] && r1[n]>rsq){
				if(l1[n] < rsq+1)
					l1[n] = rsq+1;
				n ++;
			}
		}
		for(j=0; j<n/2; j++){
			swap(l1[j], l1[n-1-j]);
			swap(r1[j], r1[n-1-j]);
		}
		for(j=0; j<n; j++)
			del[j] = 0;
		int now = 0;
		for(j=1; j<n; j++){
			if(l1[j]<=r1[now]+1){
				r1[now] = r1[j];
				del[j] = 1;
			}
			else{
				now = j;
			}
		}
		for(j=0; j<n; j++){
			if(del[j] == 0)
				addTree(1, l1[j], r1[j]);
		}
		//for(j=1; j<=sq&&j<=r; j++){
		for(j=1; j<=sq&&j<=rsq; j++){
			if(r/j - (l-1)/j > 0)
				tree[m+j-1] ++;
		}
	}
	
	for(i=1; i<=M; i++){
		int sum = 0;
		int nd = m+i-1;
		while(nd>=1){
			sum += tree[nd];
			nd /= 2;
		}
		printf("%d\n", sum);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &N, &M);
	for(i=0; i<N; i++)
		scanf("%d%d", &L[i], &R[i]);
	solve();
	return 0;
}

Measured memory_bytes: 7424
use std::io::stdin;

fn insertion_sort(array:&mut Vec<i32>){
    //println!("{:?}",array);
    print_array(array.to_vec());
    for i in 1 .. array.len(){
      //①位置決定
      let mut insertpos:usize=114514;
      for j in (0..i).rev(){
          if array[j]<array[i]{
            insertpos=j+1;
            break;
          }
          if j==0{
            insertpos=0;
          }
      }
      //②挿入
      for j in (insertpos..i).rev()
      {
        array.swap(j,j+1);
      }
      print_array(array.to_vec());
    }
    //print_array(array.to_vec());
}

fn main() {
  //入力を受け取ってi32に変換
  let n:i32 = readline().parse().unwrap();
  //println!("{}",n);
  //let mut array=vec![5,4,3,2,1];
  let mut array=readline_as_vec();
  insertion_sort(&mut array);
}

fn print_array(array:Vec<i32>){
  let mut array_content=String::new();
  for a in array{
    array_content += &a.to_string();
    array_content += " ";
  }
  println!("{}",array_content.to_string().trim_right());
}
fn readline()->String
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  //改行コードの削除
  s.trim_right().to_owned()
}

fn readline_as_vec()->Vec<i32>
{
  let mut s = String::new();
  stdin().read_line(&mut s).unwrap();
  //改行コードの削除
  s=s.trim_right().to_owned();
  let mut read_vec:Vec<i32>=Vec::new();
  //空白で分割
  for chr in s.split_whitespace(){
    read_vec.push(chr.parse::<i32>().unwrap());
  }
  read_vec
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
class Dice():
	def __init__(self,li):
		self.directionList = li
		self.top   = 1
		self.south = 2
		self.east  = 3
		self.west  = 4
		self.norse = 5
		self.low   = 6

	def get_top(self):
		return self.directionList[self.top-1]

	def advance_dice(self,direction):
		if direction == "E":
			tmp = self.top
			self.top = self.west
			self.west = self.low
			self.low = self.east
			self.east = tmp
		elif direction == "S":
			tmp = self.top
			self.top = self.norse
			self.norse = self.low
			self.low = self.south
			self.south = tmp
		elif direction == "W":
			self.advance_dice("E")
			self.advance_dice("E")
			self.advance_dice("E")
		elif direction == "N":
			self.advance_dice("S")
			self.advance_dice("S")
			self.advance_dice("S")

if __name__ == '__main__':
	li = list(map(int,input().split()))
	direction = list(input())
	dice  = Dice(li=li)
	for i in range(len(direction)):
		dice.advance_dice(direction[i])

	print(dice.get_top())


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl

int main() {
  ll N;
  ll A[5];  // A B C D E
  ll time[5];
  cin >> N;
  FOR(i, 0, 5) cin >> A[i];

  ll rep = 5;
  ll prev = 10000000000000LL;
  ll max_time = -1;
  //自分より後に出てきた数字に注目
  FOR(i, 0, 5) {
    time[i] = (N + (A[i] - 1)) / A[i];
    time[i] = max((long long)1, time[i]);  // 0を除去
    CHMAX(max_time, time[i]);
  }

  cout << max_time + 4 << endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define INF 10101010

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<int> a(m);
	rep(i,m) std::cin >> a[i];
	int mc[10] = {0,2,5,5,4,5,6,3,7,6};
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(10,-INF));
	dp[0] = std::vector<int>(10,0);
	for(auto& i:a) {
		for(int j=0;j<=n-mc[i];j++) {
			if(dp[j][0]==-INF) continue;
			std::vector<int> tmp = dp[j];
			tmp[0]++; tmp[i]++;
			if(dp[mc[i]+j][0] == tmp[0]) {
				bool re = false;
				for(int k=9;k>0;k--) {
					if(dp[mc[i]+j][k] == tmp[k]) continue;
					re = dp[mc[i]+j][k]<tmp[k];
					break;
				}
				if(re) dp[mc[i]+j] = tmp;
			}
			else if(dp[mc[i]+j][0] < tmp[0]) {
				dp[mc[i]+j] = tmp;
			}
		}
	}
	std::string ans = "";
	for(int i=1;i<=9;i++) {
		while(dp[n][i]>0) {
			ans = std::to_string(i) + ans;
			dp[n][i]--;
		}
	}
	print(ans);
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[610][610];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a%c==0&&b%d==0){
		printf("No\n");return 0;
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		p[i][j]=1000;
		if(i%c==c-1&&j%d==d-1)p[i][j]=-c*d*1000+999;
	}
	printf("Yes\n");
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(j)printf(" ");
				printf("%d",p[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstdlib>

typedef long long ll;

int main(){
    ll N, K;
    scanf("%lld %lld", &N, &K);

    ll *in;
    in = (ll *)malloc(sizeof(ll) * N);

    ll res;
    ll target;
    for(ll i=0; i<N; i++){
        scanf("%lld", &in[i]);
        if(in[i] == 1){
            target = i;
        }
    }

    ll former = target;
    ll latter = (N-1) - target;

    res = former / (K-1);
    ll former_res = former % (K-1);
    res += latter / (K-1);
    ll latter_res = latter % (K-1);

    if((former_res + latter_res + 1) > K){
        res += 2;
    }else if((former_res + latter_res) == 0){
        ;
    }else{
        res += 1;
    }

    printf("%lld\n", res);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m; cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL a,b,c,d;
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
int main()
{
	a=read();b=read();c=read();d=read();
	cout<<max(max(a*c,a*d),max(b*c,b*d))<<'\n';
}

Measured memory_bytes: 3632
#include <stdio.h>

typedef struct {
	char name[8];
	int num;
} PRODUCT;

PRODUCT product[8192];

int cmp(PRODUCT *A, PRODUCT *B)
{
	int len_a = strlen(A->name);
	int len_b = strlen(B->name);
	
	if (len_a == len_b){
		return (strcmp(A->name, B->name));
	}
	
	if (len_a < len_b){
		return (-1);
	}
	
	return (1);
}

int main(void)
{
	int i, n;
	int j, k = 0;
	char name[8];
	int num;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s %d", name, &num);
		
		for (j = 0; j < k; j++){
			if (strcmp(name, product[j].name) == 0){
				product[j].num += num;
				break;
			}
		}
		
		if (j == k){
			strcpy(product[k].name, name);
			product[k].num = num;
			k++;
		}
	}
	
	qsort(product, k, sizeof(PRODUCT), cmp);
	
	for (i = 0; i < k; i++){
		printf("%s %d\n", product[i].name, product[i].num);
	}
	
	return (0);
}

Measured memory_bytes: 644
/// Author: Wang, Yen-Jen
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  string s2 = "";
  for (char c : s) {
    if (c == 'x')
      continue;
    s2 = s2 + c;
  }
  string s3 = s2;
  reverse(s3.begin(), s3.end());
  if (s2 != s3) {
    cout << "-1\n";
    return 0;
  }
  int ans = 0;
  for (int i = 0, j = (int)s.size() - 1; i <= j; i++, j--) {
    int c1 = 0, c2 = 0;
    while (i <= j && s[i] == 'x') {
      c1++;
      i++;
    }
    while (i <= j && s[j] == 'x') {
      c2++;
      j--;
    }
    if (i > j)
      break;
    else
      ans += abs(c1 - c2);
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{
    int n, a[100001];
    int cnt2 = 0, cnt4 = 0;

    scanf("%d", &n );

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

    for ( int i = 0; i < n; ++i ) {
        if ( a[i] % 4 == 0 ) {
            cnt4++;
        } else if ( a[i] % 2 == 0 ) {
            cnt2++;
        }
    }

    cnt2 /= 2;

    if ( cnt2 + cnt4 >= n / 2 ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

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

    //mapに代入し、各要素をカウント
    string Si; 
    map<string, int> poll;
    for(int i = 0; i < N; i++){
        cin >> Si;
        poll[Si] ++;  
    }
    
    //valueの最大値探す
    int  max_value = 0;
    for(auto i = poll.begin(); i != poll.end(); i++){
        max_value = max(i-> second, max_value);
    }

    //valueが最大値と等しければ出力
    for(auto i = poll.begin(); i != poll.end(); i++){
        if(i-> second == max_value){
            cout << i-> first << endl;
        }
    }
}

Measured memory_bytes: 25216
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])
max = 0
if B<N:
    K = B
    for i in range(-1, 2):
       if max< (int(A * (K + i) / B) - A * int((K + i) / B)):
           max = int(A * (K + i) / B) - A * int((K + i) / B)
else:
    K = N
    for i in range(-1, 1):
        if max< (int(A * (K + i) / B) - A * int((K + i) / B)):
            max = int(A * (K + i) / B) - A * int((K + i) / B)
print(max)

Measured memory_bytes: 9236
n = int(input())
dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(n):
    s = input()
    dic[s] += 1
for key in ['AC', 'WA', 'TLE', 'RE']:
    print('{0} x {1}'.format(key, dic[key]))
    

Measured memory_bytes: 69936
a,b = gets.chomp.split(" ").map(&:to_i);

tmp = -1
if a < b then
 tmp = a
 a = b
 b = tmp
end

count_a = 1
count_b = 0
space = 0

cake = ['a']

for num in 1..15 do
    if cake[num-1] != 'a' && count_a < a then
        cake[num] = 'a'
        count_a += 1
    elsif cake[num-1] != 'b' && count_b < b then
        cake[num] = 'b'
        count_b += 1
    else
        cake[num] = ' '
        space += 1
    end
end

if count_a == a && count_b == b then
    print 'Yay!'
else
    print ':('
end



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

main(){
    int H=1, W=1;
    while(H&&W){
        cin >> H >> W;
        if(H&&W){
            for(int i=0; i<H; ++i){
                for(int j=0; j<W; ++j) cout << ((!i)||(i==H-1)?"#":((!j)||(j==W-1)?"#":"."));
                cout << endl;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3052
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC129C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NM = CIN.LongArray();
            long[] A = new long[NM[1]];
            for (int i = 0; i < NM[1]; i++)
            {
                A[i] = CIN.Long();
            }

            Dictionary<long, bool> AI = new Dictionary<long, bool>();
            foreach (long l in A)
            {
                if (AI.ContainsKey(l))
                {
                    continue;
                }
                AI.Add(l, true);
            }

            long[] dp = new long[NM[0] + 1];
            dp[0] = 1;
            for (int i = 1; i <= NM[0]; i++)
            {
                if (AI.ContainsKey(i))
                {
                    dp[i] = 0;
                    continue;
                }

                dp[i] = dp[i - 1];
                if (i > 1)
                {
                    dp[i] = (dp[i] + dp[i - 2]) % 1000000007;
                }
            }

            Console.WriteLine(dp[NM[0]]);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 22880
#include <stdio.h>

int main(){
  int A,B,i,j,kaisu,count,digit1,total_count=0,testing_count;
  char digit[5],buf[5];

  scanf("%d%d",&A,&B);
  for(i=A;i<=B;i++){
    digit1=i;
    for(j=10000,kaisu=0;kaisu<5;kaisu++,j/=10){
      digit[kaisu]=digit1/j+48;
      digit1-=(digit[kaisu]-48)*j;
    }

    for(count=0;count<5;count++){
      buf[count]=digit[4-count];
    }

    for(count=0,testing_count=0;count<5;count++){
      if(buf[count]==digit[count])testing_count++;
      if(testing_count==5)total_count++;
    }

  }

  printf("%d",total_count);

  return 0;
}


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

int digit(int n)
{
  int d = 0;
  while (n > 0) {
    n /= 10;
    d++;
  }
  return d;
}

int main()
{
  int n, s = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (digit(i) % 2 == 1) s++;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let n: i32 = read::<i32>();
    let mut a_vec = read_vec::<i32>();

    a_vec.sort();
    a_vec.dedup();

    if n != a_vec.len() as i32 {
        println!("NO")
    } else {
        println!("YES");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i, n){
        cin >> a[i];
    }
    sort(all(a), greater<int>());

    int alice = 0, bob = 0;
    rep(i, n){
        if(i % 2 == 0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }

    cout << alice -  bob << endl;


    return 0;
}


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

int main(){
  int N;
  N = 5;

  vector<int> vec(N);

  for (int i = 0; i < N; i++)
  {
    cin >> vec.at(i);
  }
  int time = 0;
  int tmp;
  for (int i = 0; i < N - 1; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      if (vec.at(i) % 10 < vec.at(j) % 10){
        tmp = vec.at(j);
        vec.at(j) = vec.at(i);
        vec.at(i) = tmp;
      }
    }    
  }
  
  int cnt = 0;
  for (int i = N - 1; i > -1; i--){
    if (vec.at(i) % 10 == 0){
      time += vec.at(i);
      cnt += 1;
    }
  }

  for (int i = 0; i < N - cnt; i++)
  {
    if (i == N - 1 - cnt){
      time += vec.at(i);
    }
    else
    {
      time += vec.at(i);
      time += 10 - vec.at(i) % 10;
    }
    
  }
  
  cout << time << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n, m, q; std::cin >> n >> m >> q;
    vvi s(n, vi(n));
    map<int, int> cnt;
    rep(i, m) {
        int l, r; std::cin >> l >> r;
        --l, --r;
        s[l][r]++;
    }
    rep(i, n) rep(j, n) {
        if (j-1 >= 0) s[i][j] += s[i][j-1];
    }
    rep(i, q) {
        int p, q; std::cin >> p >> q;
        --p, --q;
        int ans = 0;
        srep(i, p, q+1) {
            ans += s[i][q] - (p-1 < 0 ? 0 : s[i][p-1]);
        }
        std::cout << ans << "\n";
    }
}


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

typedef long long ll;

//ソート済の配列に対して、クエリの値がどこに当たるか調査。
//配列とクエリを入力、queryより小さい数字の最大値の位置を出力として返す。
//queryより小さい数字がない場合は-1を返す。
int func_ascending(vector<int>& input_arr, int query)
{
    if (query <= input_arr[input_arr.size() - 1]) return -1;
    return upper_bound(input_arr.begin(), input_arr.end(), query, greater<int>()) - input_arr.begin();
}

int main()
{
    int n;
    cin >> n;
    vector<int> a, b;
    for (int i = 0; i < n; i++)
    {
        int tmp; cin >> tmp;
        a.push_back(tmp);
    }


    for (int i = 0; i < n; i++)
    {
        if (i == 0){
            b.push_back(a[i]);
            continue;
        }

        //どの数字b[]よりも小さい場合
        if (b[b.size() - 1] >= a[i]){
            b.push_back(a[i]);
        } else {
            int k = func_ascending(b, a[i]);
            //printf("%d %d %d\n", k, i , a[i]);
            b[k] = a[i];
        }

    }
    cout << b.size() << endl;

}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int bubbleSort(int A[],int N){
bool flag=true;
	int j,node,ans=0;
	while(flag){
	flag=false;
		for(j=N-1;j>0;j--){
			if(A[j]<A[j-1]){
			node=A[j];
				A[j]=A[j-1];
				A[j-1]=node;
				ans++;
				flag=true;
			}
			
		}
	}
	return ans;
}

main(){
	int n,i,ans;
	scanf("%d",&n);
	int A[n];
	for(i=0;i<n;i++)
	scanf("%d",&A[i]);
	ans=bubbleSort(A,n);
	for(i=0;i<n;i++){
	    if(i==n-1){
	printf("%d",A[i]);
	        break;
	    }
	printf("%d ",A[i]);}
	printf("\n%d\n",ans);
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct mei{
  int l,r;
  bool operator <(mei &q){
      return r-l<q.r-q.l;
  }
};
int n,m,ans;
mei a[300005];
int bit[100005];
void add(int x,int y){
    while(x<=m){
        bit[x]+=y;
        x+=(x&-x);
    }
}
int sum(int x){
    int res=0;
    while(x>0){
        res+=bit[x];
        x-=(x&-x);
    }
    return res;
}
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i].l,&a[i].r);
    }
    ans=n;
    sort(a,a+n);
    int k=0;
    for(int i=1;i<=m;i++){
        while(k<n&&a[k].r-a[k].l+1<i){
            add(a[k].l,1);
            add(a[k].r+1,-1);
            k++;
            ans--;
        }
        int s=ans;
        for(int j=i;j<=m;j+=i){
            s+=sum(j);
        }
        printf("%d\n",s);
    }
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<map>
using namespace std;main(){map<string,int>T;int n,k,s,v;string z,x,y;while(cin>>n&&n>0){while(n--){cin>>z>>v;T[z]=v;}cin>>n;while(n--){cin>>z>>k;s=0;while(k--){cin>>x;s+=T[x];}T[z]=min(T[z],s);}cin>>y;cout<<T[y]<<endl;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

struct edge
{
    int to,cost;
};

struct eda
{
    int from,to,cost;
};

vector<edge> G[MAX_N];
int stsize[MAX_N];

//vを根とする各頂点の部分木のサイズ
int subtree_size(int v,int p)
{
    int c = 1;
    rep(i,G[v].size()){
        int w = G[v][i].to;
        if(w == p){
            continue;
        }
        c += subtree_size(G[v][i].to,v);
    }
    stsize[v] = c;
    return c;
}

P centroid(int v,int p,int t)    //最大部分木の頂点数,頂点番号
//v:v以下の頂点について,p:親(startは-1),t:連結成分の数
{
    P res = P(INF,-1);
    int s = 1,m = 0;
    rep(i,G[v].size()){
        int w = G[v][i].to;
        if(w == p){
            continue;
        }
        res = min(res,centroid(w,v,t));
        m = max(m,stsize[w]);
        s += stsize[w];
    }
    m = max(m,t-s);
    res = min(res,P(m,v));
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<eda> vec;
    rep(i,n-1){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        vec.pb((eda){a-1,b-1,c});
        G[a-1].pb((edge){b-1,c});
        G[b-1].pb((edge){a-1,c});
    }
    ll sm = 0;
    int ans = subtree_size(0,-1);
    P p = centroid(0,-1,n);
    ans = subtree_size(p.se,-1);
    if(n % 2 == 0 && p.fi == n/2){
        rep(i,n-1){
            eda e = vec[i];
            int cnt = min(stsize[e.from],stsize[e.to]);
            sm += 2*(ll)cnt*e.cost;
        }
        rep(i,G[p.se].size()){
            if(stsize[G[p.se][i].to] == n/2){
                sm -= G[p.se][i].cost;
                cout << sm << endl;
                break;
            }
        }
    }else{
        rep(i,n-1){
            eda e = vec[i];
            int cnt = min(stsize[e.from],stsize[e.to]);
            sm += 2*(ll)cnt*e.cost;
        }
        int mn = INF;
        rep(i,G[p.se].size()){
            mn = min(mn,G[p.se][i].cost);
        }
        cout << sm-mn << endl;
    }
    return 0;
}


Measured memory_bytes: 16692
def main():
    n = int(input())
    l = list(map(int, input().split()))

    max_l = max(l)
    l.remove(max_l)

    sum_exc_l = sum(l)

    if max_l < sum_exc_l:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<bool> d(101);
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    d.at(a)=true;
  }
  
  int ans = 0;
  for(int i=0;i<101;i++)if(d.at(i))ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256