akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int h, n, p, m, k;
	scanf("%d%d%d%d%d", &h, &n, &p, &m, &k);
	vector<int> v(h, -1);
	for(int i = 0; i < m; ++i){
		int a, b;
		scanf("%d%d", &a, &b);
		v[a - 1] = b - 1;
	}

	double cmb[512][512] = {};
	for(int i = 0; i < 512; ++i){
		cmb[i][0] = 1;
		for(int j = 1; j <= i; ++j){
			cmb[i][j] = cmb[i - 1][j - 1] + cmb[i - 1][j];
		}
	}

	int rst = h - m;
	vector<vector<double> > dp1(k + 1, vector<double>(n)), dp2;
	dp2 = dp1;
	dp1[k][p - 1] = 1;
	for(int g = h - 1; g >= 0; --g){
		if(v[g] == -1){
			dp2[0] = dp1[0];
			for(int i = 1; i <= k; ++i){
				double pr1 = 1 - cmb[rst - 1][i] / cmb[rst][i];
				double pr2 = pr1 / (n - 1);
				for(int j = 0; j < n; ++j){
					dp2[i][j] = dp1[i][j] * (1 - pr1);
				}
				dp2[i - 1][0] += (dp1[i][0] * (n - 2) + dp1[i][1]) * pr2;
				dp2[i - 1][n - 1] += (dp1[i][n - 1] * (n - 2) + dp1[i][n - 2]) * pr2;
				for(int j = 1; j < n - 1; ++j){
					dp2[i - 1][j] += (dp1[i][j] * (n - 3) + dp1[i][j - 1] + dp1[i][j + 1]) * pr2;
				}
			}
			dp1.swap(dp2);
			--rst;
		}
		else{
			for(int i = 0; i <= k; ++i){
				swap(dp1[i][v[g]], dp1[i][v[g] + 1]);
			}
		}
	}
	double ans = *max_element(dp1[0].begin(), dp1[0].end());
	printf("%.9f\n", ans);
}

Measured memory_bytes: 3296
//https://beta.atcoder.jp/contests/arc095/tasks/arc095_a
#include <bits/stdc++.h>
using namespace std;
pair<int,int> v[200001];
int ans[200001] = {};

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i].first;
        v[i].second = i;
    }
    sort(v+1,v+1+n);
    int a = v[n/2+1].first;
    int b = v[n/2].first;
    for(int i=1;i<=n;i++)
    {
        int idx = v[i].second;
        if(i <= n/2) ans[idx] = a;
        else ans[idx] = b;
    }
    for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 4480
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

// std::cmp::Reverse doesn't have Clone.
#[derive(Eq, PartialEq, Clone)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let n: usize = util::get();

    let mut maximum = 1;
    let mut sum = 1;
    while sum < n {
        maximum += 1;
        sum += maximum;
    }

    let mut n = n;
    for x in (1..maximum + 1).rev() {
        if n >= x {
            n -= x;
            println!("{}", x);
        }
    }
}


Measured memory_bytes: 4476
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  n -= k;
  k--;
  n = ceil((double)n / k);
  cout << n + 1 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 10

typedef struct node *link;
struct node{
	int key;
	link left,right;
};

link In(link head,link z){
	link y=NULL;
	link x=head;
	
	while(x!=NULL){
		y=x;
		if(z->key < x->key)x=x->left;
		else x=x->right;
	}
	
	if(y==NULL)head=z;
	else if(z->key < y->key)y->left=z;
	else y->right=z;
	return head;
}

void P(link u){
	if(u==NULL)return;
	printf(" %d",u->key);
	P(u->left);
	P(u->right);
}

void I(link u){
	if(u==NULL)return;
	I(u->left);
	printf(" %d",u->key);
	I(u->right);
}

int F(link u,int key){
	if(u==NULL)return 0;
	if(u->key==key)return 1;
	if(u->key>key)return F(u->left,key);
	return F(u->right,key);
}

int S(link u){
	if(u->left==NULL)return u->key;
	return S(u->left);
}

link D(link u,int key){
	if(u==NULL)return NULL;
	if(u->key==key){
		if(u->left==NULL && u->right==NULL)return NULL;
		else if(u->right==NULL){
			return u->left;
		}else if(u->left==NULL){
			return u->right;
		}else{
			u->key=S(u->right);
			u->right=D(u->right,u->key);
		}
	}else if(u->key >key){
		u->left=D(u->left,key);
	}else{
		u->right=D(u->right,key);
	}
	return u;
}

int main(void){
	int m,i,key;
	char cmd[MAX];
	link head=NULL,z;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s",cmd);
		if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			z = malloc(sizeof(*z));
			z->key=key;z->left=NULL;z->right=NULL;
			head=In(head,z);
		}else if(!strcmp(cmd,"print")){
			I(head);
			printf("\n");
			P(head);
			printf("\n");
		}else if(!strcmp(cmd,"find")){
			scanf("%d",&key);
			if(F(head,key)!=0)printf("yes\n");
			else  printf("no\n");
		}else if(!strcmp(cmd,"delete")){
			scanf("%d",&key);
			head=D(head,key);
		}
	}
	return 0;
}



Measured memory_bytes: 14204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, int>;

ll solve() {
    ll W, H, p;
    cin >> W >> H;
    vector<pii> PQ; // P:[0,W), Q:[W,W+H)
    for ( int i = 0; i < W+H; i++ ) {
        cin >> p;
        PQ.push_back(pii(p,i));
    }
    sort(PQ.begin(), PQ.end());
    ll w = W + 1, h = H + 1;
    ll ans = 0;
    for ( auto p : PQ ) {
        if ( p.second < W ) {
            ans += p.first * h;
            w--;
            if ( w == 0 ) break;
        } else {
            ans += p.first * w;
            h--;
            if ( h == 0 ) break;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main()
{
    long long int n , m , ans ;
    cin >> n >> m ;
    n = n%m ;
    ans = m - n;
    if(n > ans)
    {
        cout << ans << endl ;
    }
    else
    {
        cout << n ;
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll inv_mod(ll a, ll MOD)
{
    ll b = MOD, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t*b;   swap(a,b);
        u -= t*v;   swap(u,v);
    }
    u %= MOD;
    if(u < 0) u+= MOD;
    return u;
}

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    const ll MOD = 1e9+7;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    vector<ll> inv(n-1);
    rep(i,n-1){
        inv[i] = inv_mod(i+1, MOD);
    }
    ll tmp = 1;
    rep(i,n-1){
        tmp *= (i + 1);
        tmp %= MOD;
    }
    vector<ll> bun(n-1);
    rep(i,n-1) bun[i] = tmp*inv[i]%MOD;
    vector<ll> wa(n-1);
    wa[0] = bun[0];
    rep(i,n-2){
        wa[i + 1] = wa[i] + bun[i + 1];
        wa[i + 1] %= MOD;
    }
    ll ans = 0;
    rep(i,n-1){
        ans += (x[i+1] - x[i])*wa[i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6312
A = list(map(str, input().split(" ")))
op = {"+":lambda x, y:x+y, "-":lambda x,y:x-y, "*":lambda x,y:x*y}
stack = []

for i, z in enumerate(A):
    if z not in op:
        stack.append(z)
        continue
    y = int(stack.pop())
    x = int(stack.pop())
    stack.append(op[z](x,y))
print(stack[0])
    
    
    


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+'){
        cout<<a+b<<endl;
    }
    else{
        cout<<a-b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "sardine" ].parse.expand.solve == "xxxxxxx" );
	assert( [ "xxxx" ].parse.expand.solve == "xxxx" );
	assert( [ "gone" ].parse.expand.solve == "xxxx" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return 'x'.repeat( s.length ).array;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var x, y int
	fmt.Scan(&x, &y)

	a := 0
	for i := 0; i < x+1; i++ {
		if (i*2+(x-i)*4 == y) && y <= 100 {
			fmt.Println("Yes")
			a = 1
			break
		}
	}
	if a == 0 {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1772
s = input()
 
stack = []
for c in reversed(s):
  stack.append(c)
  if len(stack) > 7:
    print('NO')
    break  
  if len(stack) >= 5 and ''.join(reversed(stack)) in ('erase', 'dream', 'eraser', 'dreamer'):
    stack = []
else:
  print('NO' if stack else 'YES')

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

long long int gcd(long long int a, long long int b){
    long long int x,y;
    x=a; y=b;
    if(x<y) swap(x,y);
    while(y>0){
        x=x%y;
        swap(x,y);
    }
    return x;
}

int main(){
    int n; cin >> n;
    long long int ans,t; cin >> ans;
    for(int i=1;i<n;i++){
        cin >> t;
        ans = ans / gcd(ans,t) *t;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;ll c;cin>>c;
    vector<ll> x(n),v(n);
    for(int i=0;i<n;i++) cin>>x[i]>>v[i];
    vector<ll> su(n,0),rev(n,0);
    su[0]=v[0],rev[n-1]=v[n-1];
    for(int i=1;i<n;i++) su[i]=su[i-1]+v[i];
    for(int i=n-2;i>=0;i--) rev[i]=rev[i+1]+v[i];
    vector<ll> su2(n,0),rev2(n,0);
    su2[0]=su[0]-x[0];rev2[n-1]=rev[n-1]-(c-x[n-1]);
    for(int i=1;i<n;i++) su2[i]=max(su2[i-1],su[i]-x[i]);
    for(int i=n-2;i>=0;i--) rev2[i]=max(rev2[i+1],rev[i]-(c-x[i]));
    ll res=0;
    for(int i=0;i<n-1;i++){
        ll tmp=0;
        tmp=su[i]-2*x[i]+rev2[i+1];
        res=max(res,tmp);
        res=max(res,su[i]-x[i]);
    }
    res=max(res,su[n-1]-x[n-1]);
    for(int i=n-1;i>=1;i--){
        ll tmp=0;
        tmp=rev[i]-2*(c-x[i])+su2[i-1];
        res=max(res,tmp);
        res=max(res,rev[i]-(c-x[i]));
    }
    res=max(res,rev[0]-(c-x[0]));
    cout<<res<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for (int i = 0; i < M; ++i) cin >> s[i] >> c[i];
  
  if (N == 1) {
    if (M == 0) cout << 0 << endl;
    else {
      int memo = c[0];
      bool ans = true;
      for (int i = 1; i < M; ++i) {
        if (memo != c[i]) ans = false;
      }
      if (ans) cout << c[0] << endl;
      else cout << -1 << endl;
    }
  }
  if (N == 2) {
    if (M == 0) cout << 10 << endl;
    else {
      int a = -1; // 10 の位
      int b = -1; // 1 の位
      bool ans = true;
      for (int i = 0; i < M; ++i) {
        if (s[i] == 1) {
          if (a != -1 && c[i] != a) ans = false;
          else a = c[i];
        }
        if (s[i] == 2) {
          if (b != -1 && c[i] != b) ans = false;
          else b = c[i];
        }
      }
      
      if (a == 0) ans = false;
      if (a == -1) a = 1;
      if (b == -1) b = 0;
      
      if (ans) cout << 10 * a + b << endl;
      else cout << -1 << endl;
    }
  }
  if (N == 3) {
    if (M == 0) cout << 100 << endl;
    else {
      int a = -1; // 100 の位
      int b = -1; // 10 の位
      int d = -1; // 1 の位
      bool ans = true;
      for (int i = 0; i < M; ++i) {
        if (s[i] == 1) {
          if (a != -1 && c[i] != a) ans = false;
          else a = c[i];
        }
        if (s[i] == 2) {
          if (b != -1 && c[i] != b) ans = false;
          else b = c[i];
        }
        if (s[i] == 3) {
          if (d != -1 && c[i] != d) ans = false;
          else d = c[i];
        }
      }
      
      if (a == 0) ans = false;
      if (a == -1) a = 1;
      if (b == -1) b = 0;
      if (d == -1) d = 0;
      
      if (ans) cout << 100 * a + 10 * b + d << endl;
      else cout << -1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int main() {
  int N, M; cin >> N >> M;
  vector<ll> S(N);
  rep(i, 0, N) cin >> S[i];
  vector<ll> T(M);
  rep(i, 0, M) cin >> T[i];
  vector<vector<ll>> dp(N + 1, vector<ll>(M + 1,0));
  vector<vector<ll>> acum(N + 1, vector<ll>(M + 1, 0));
  ll ans = 0;

  rep(i, 0, N){
    rep(k, 0, M){
      if(S[i] == T[k]) dp[i + 1][k + 1] = acum[i][k] + 1 % MOD;
      else dp[i + 1][k + 1] = 0;
      acum[i + 1][k + 1] = acum[i][k + 1] + acum[i + 1][k] - acum[i][k] + dp[i + 1][k + 1] % MOD;
      ans += dp[i + 1][k + 1];
      ans %= MOD;
    }
  }

  ans = ans + 1 % MOD;

  cout << ans << endl;

}

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

int a;
int b;
int c = 0;

int main() {
  string str;
  cin >> str;
  for(int i = 0; i < (int)str.size(); i++){
      char ch = str[i];
      if(ch == 'A' && c == 0){
        a = i;
        c = 1;
      }
      if(ch == 'Z' && c == 1){
        b = i;
      }
  }

cout << b - a + 1 << endl;  

}

Measured memory_bytes: 640
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>k>>n; ll A[n+9], B[n+9];
    for(i=1; i<=n; i++)
        cin>>A[i];
    for(i=1; i<n; i++)
    {
        B[i] = A[i+1]-A[i];
    }

    B[n] = k-A[n]+A[1];

   // for(i=1; i<=n; i++) cout<<B[i]<<" "; cout<<endl;

    ll ans = 1e18, tot = 0;

    for(i=1; i<=n; i++) tot+=B[i];

    for(i=1; i<=n; i++)
    {
        v = tot-B[i]; ans = min(ans, v);

        x = i-1; if(x==0) x = n;
        v = tot-B[x]; ans = min(ans, v);
    }

    cout<<ans<<endl;

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdbool.h>
#include <math.h>
int main(void){
 double x1,y1,x2,y2;
 scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
 printf("%.8f\n",sqrt(pow(fabs(x1-x2),2)+pow(fabs(y1-y2),2)));
 return 0;
}



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

signed main(){
  
  int N;
  cin>>N;
  
  int sum = 0;
  
  for(int i=1;i<=N;i++){
    
    if( i % 3 == 0 || i % 5 == 0 ) continue;
    
    sum += i;
    
  }

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


Measured memory_bytes: 3604
rate = int(input())

if rate >= 400 and 600 > rate:
    print(8)
elif rate >= 600 and 800 > rate:
    print(7)
elif rate >= 800 and 1000 > rate:
    print(6)
elif rate >= 1000 and 1200 > rate:
    print(5)
elif rate >= 1200 and 1400 > rate:
    print(4)
elif rate >= 1400 and 1600 > rate:
    print(3)
elif rate >= 1600 and 1800 > rate:
    print(2)
elif rate >= 1800 and 2000 > rate:
    print(1)

Measured memory_bytes: 9040
import java.util.*;

public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			int digit = sc.nextInt();
			if((a|digit) == 0) break;
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(a);
			int ansi = -1,ansj = -1;
			for(int k=1; k < 22; k++){
				String astr = "" + a;
				StringBuilder sb =new StringBuilder();
				int len = astr.length();
				for(int i = len; i < digit; i++){
					sb.append("0");
				}
				sb.append(astr);
				//System.out.println("astr= " + astr + "a = " + a);
				char [] small = sb.toString().toCharArray();
				Arrays.sort(small);
				String smallstr = new String(small);
				StringBuilder work = new StringBuilder(smallstr);
				work.reverse();
				char [] big = work.toString().toCharArray();
				String bigstr = new String(big);

				//System.out.println("str= " + bigstr + " " + smallstr);
				int bigint = Integer.parseInt(bigstr);
				int smallint = Integer.parseInt(smallstr);
				a = bigint - smallint;
				if(list.contains(a)){
					ansi = k;
					break;
				}
				list.add(a);
			}
			//find a ansj
			for(int i=0; i < list.size();i++){
				if(list.get(i) == a){
					ansj = i;
					break;
				}
			}
			//debug
//			for(int i=0; i < list.size();i++){
//				System.out.print(list.get(i) + " ");
//			}
			System.out.println(ansj + " " + a +  " " + (ansi - ansj));
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}

}

Measured memory_bytes: 12000
#include<stdio.h> 
int main()
{
  int a,b,c,ans;
  scanf("%d %d %d",&a,&b,&c);
  int t1,t2,t3;
  t1=a+b;
  t2=b+c;
  t3=a+c;
  if(t1>=t2)
  {
    if(t2>=t3)
      ans=t3;
    else
      ans=t2;
  }
  else
  {
    if(t1<=t3)
      ans=t1;
    else
      ans=t3;
  }
  printf("%d\n",ans); 
  return 0;
}

Measured memory_bytes: 128
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := getInt(), getInt()
	if a < 10 && b < 10 {
		out(a * b)
		return
	}
	out(-1)
}


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

#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll n;
    cin >> n;

    vector<bool> primeb(1000001, true);

    primeb[0] = false;
    primeb[1] = false;

    for(int i = 2; i <= 1000000; i++){
        if(primeb[i]){
            for(int j = i + i; j <= 1000000; j = j + i){
                primeb[j] = false;
            }
        }
    }

    vector<int> prime;

    for(int i = 2; i <= 1000000; i++){
        if(primeb[i]){
            prime.push_back(i);
        }
    }

    int primeSize = prime.size();

    int ans = 0;

    vector<int> currentPrime(primeSize);

    rep(i, primeSize){
        currentPrime[i] = prime[i];
    }

    int index = 0;

    while(index < primeSize){
        if(n % currentPrime[index] == 0){
            n = n / currentPrime[index];
            currentPrime[index] *= prime[index];
            ans++;
        }else{
            index++;
        }
    }

    index = 0;

    while(index < primeSize){
        if(n % prime[index] == 0){
            n = n / prime[index];
        }else{
            index++;
        }
    }

    if(n != 1) ans++;
    

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4180
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N;
vector<int> Eto[201010];
int P[201010];
int A[201010];
//---------------------------------------------------------------------------------------------------
void pre() { // 葉を刈る
    queue<int> que;
    rep(i, 1, N + 1) if (Eto[i].size() == 0) que.push(i);
    while (!que.empty()) {
        int cu = que.front(); que.pop();
        if (0 <= A[cu]) continue;

        set<int> s;
        int ng = 0;
        fore(to, Eto[cu]) {
            if (A[to] < 0) ng = 1;
            s.insert(A[to]);
        }

        if (ng) continue;

        int g = 0;
        while (s.count(g)) g++;

        A[cu] = g;
        que.push(P[cu]);
    }
}
//---------------------------------------------------------------------------------------------------
bool check(int i, int x) {
    int pre = x;
    int cu = P[i];
    while (cu != i) {
        set<int> s;
        s.insert(pre);
        fore(to, Eto[cu]) s.insert(A[to]);
        int g = 0;
        while (s.count(g)) g++;
        pre = g;
        cu = P[cu];
    }

    set<int> s;
    s.insert(pre);
    fore(to, Eto[i]) s.insert(A[to]);
    int g = 0;
    while (s.count(g)) g++;
    
    return g == x;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 1, N + 1) {
        int p; cin >> p;
        Eto[p].push_back(i);
        P[i] = p;
    }
    rep(i, 1, N + 1) A[i] = -1;

    pre();

    int fixid = 0;
    rep(i, 1, N + 1) if (A[i] < 0) fixid = i;

    set<int> s;
    fore(to, Eto[fixid]) s.insert(A[to]);
    int fir = 0;
    while (s.count(fir)) fir++;
    int sec = fir + 1;
    while (s.count(sec)) sec++;

    string ans = "IMPOSSIBLE";
    if (check(fixid, fir)) ans = "POSSIBLE";
    else if (check(fixid, sec)) ans = "POSSIBLE";

    cout << ans << endl;
}

Measured memory_bytes: 11904
A, B = map(int, input().split(' '))

def is_palindromic(n):
    s, t = n % 10, (n // 10000) % 10
    u, v = (n // 10) % 10, (n // 1000) % 10
    if s == t and u == v:
        return True
    return False

count = 0
for n in range(A, B+1):
    if is_palindromic(n):
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

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

    int N;
    cin >> N;
    set<string> st;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;
        st.insert(S);
    }

    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19276
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, T, A;
    cin >> N >> T >> A;
    int H[N];
    REP(i, N) cin >> H[i];

    double m = 1000000;
    int ans = 0;
    REP(i, N) {
        double c = (double)T - (double)(H[i]) * 0.006;
        c = abs((double)A - c);
        if (c < m) {
            m = c;
            ans = i + 1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

struct Info
{
    std::string name;
    int age;
    int num;

    Info(std::string inputted_name, int inputted_age, int in_num)
    {
        name = inputted_name;
        age = inputted_age;
        num = in_num;
    }
    bool operator<(const Info &another) const
    {
        if(name != another.name){
            return name < another.name;//
        }else{
            return age > another.age;
        }
    };
    //2つのconstを付けないとコンパイルエラーになるので注意!!
};
int main() {
    int N; cin >> N;
    vector<Info>rest;

    rep(i,N){
        string S; int rate; cin >> S >> rate;
        rest.emplace_back(Info(S, rate, i+1));
    }

    sort(rest.begin(), rest.end());

    for(auto itr : rest){
        cout << itr.num << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int a,b,c,t,maxi,ans;

int main()
{
  scanf("%d%d%d%d",&a,&b,&c,&t);
  if(b<c)
    {
      std::swap(b,c);
    }
  if(a<b)
    {
      std::swap(a,b);
    }
  while(t--)
    {
      a=a*2;
    }
  printf("%d\n",a+b+c);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;

void go() {
	string res = "UNRESTORABLE";
	string s,t;
	cin >> s >> t;
	for(int i = 0; i <= (int)s.length()-(int)t.length(); i++) {
		bool f = true;
		string tmp = s;
		for(int j = 0; j < t.length(); j++) {
			if(s[i+j]=='?' || s[i+j]==t[j]) ;
			else f = false;
			tmp[i+j] = t[j];
		}
		if(f) {
			for(int j = 0; j < tmp.length(); j++) if(tmp[j]=='?') tmp[j] = 'a';
			if(res=="UNRESTORABLE" || res > tmp) res = tmp;
		}
	}
	cout << res << endl;
}
 
int main() {
	go();
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	int n,k;
	cin>>n>>k;
	int h[n];
	rep(i,n)cin>>h[i];
	sort(h,h+n);


	ll ans=MAX;
	rep(i,n-k+1){
		if(ans>h[i+k-1]-h[i])ans=h[i+k-1]-h[i];
	}

	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 640
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

R = I()
G = I()

x = 2*G-R
print(x)

Measured memory_bytes: 74468
S = input()
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)

Measured memory_bytes: 3444
# coding: utf-8
n = int(input())
li = list(map(int, input().split()))
f = 1

for x in li:
    if x % 2 == 0 and (x % 3 != 0 and x % 5 != 0):
        f = 0

if f:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 38384
def main():
    n,m = map(int,input().split())
    dp = [0 for i in range(n+1)]
    mod = 10**9+7
    for i in range(m):
        a = int(input())
        dp[a] = -1
    dp[0] = 1
    if dp[1]!=-1:
        dp[1] = 1
    for i in range(2,n+1):
        if dp[i]==-1:
            continue
        if dp[i-1]!=-1 and dp[i-2]!=-1:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] = dp[i]%mod
        elif dp[i-1]!=-1 and dp[i-2]==-1:
            dp[i] = dp[i-1]
        elif dp[i-1]==-1 and dp[i-2]!=-1:
            dp[i] = dp[i-2]
        else:
            dp[i] = 0
    print(dp[-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 12836
str = input()
num = int(input())
for i in range(num):
    line = input()
    if line.startswith("print"):
        op,a,b = line.split()
        print(str[int(a):int(b)+1])
    elif line.startswith("replace"):
        op,a,b,c = line.split()
        x = str[0:int(a)]
        y = c
        z = str[int(b)+1:]
        str = x + y +z
    elif line.startswith("reverse"):
        op,a,b = line.split()
        x = str[0:int(a)]
        y = str[int(a):int(b)+1]
        y = y[::-1]
        z = str[int(b)+1:]
        str = x + y + z



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

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x)ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const ll pos = replacedStr.find(from);
    const ll len = from.length();
 
    if (pos == (ll)std::string::npos || from.empty()) {
        return replacedStr;
    }
 
    return replacedStr.replace(pos, len, to);
}


signed main() {
    ll k;
    cin >> k;
    ll x = 0;
    for (int i = 1; i <= k + 1; i++) {
        x = (x * 10 + 7) % k;
        if (x == 0) {
            mes(i);
            re0;
        }
    }
    mes(-1);
   
    
    
}

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

int main() {
  char x;
  cin >> x;

  if (x == 'T') {
    cout << 'A' << endl;
  }
  else if (x == 'A') {
    cout << 'T' << endl;
  }
  else if (x == 'G') {
    cout << 'C' << endl;
  }
  else {
    cout << 'G' << endl;
  }
}


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

public class Main extends Template{
	public void solve() throws IOException{
		int n = nextInt();
		int t = nextInt();
		int e = nextInt();
		int[] x = new int[n];
		for(int i = 0; i < n; i++){
			x[i] = nextInt();
			if( Math.ceil((double)(t-e)/x[i]) <= Math.floor((double)(t+e)/x[i]) ){
				System.out.println(i+1);
				return;
			} 
		}
		System.out.println(-1);
		
	}
	
	public static void main(String[] args){
		new Main().run();
	}
}

abstract class Template implements Runnable{
	public abstract void solve() throws IOException;
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run(){
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	
	public double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	public long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}
		

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 int R,G,B,N;
 cin>>R>>G>>B>>N;
 int cnt=0;
 for(int i=0;i<=N/R;i++){
	 for(int j=0;j<=(N-i*R)/G;j++){
		 if((N-i*R-j*G)%B==0){cnt++;}
		 }
	 }
 
 cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int n;
	int a[5000];

	while(cin >> n) {
		if(n==0)
			break;
		for(int i=0; i<n; i++) {
			cin >> a[i];
		}
		int max=a[0];
		for(int i=0; i<n; i++) {
			int t=0;
			for(int j=i; j<n; j++) {
				t+=a[j];
				if(t>max)
					max=t;
			}
		}
		cout << max << endl;
	}

	return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n;
    cin >> n;
    string s[n];
    F(i,0,n) cin >> s[i];
    sort(s,s+n);
    int cnt[n]={};
    int ind=0;
    for(int i=0;i<n;){
        if(s[i]==s[i+1]){
            ++i;
            ++cnt[ind];
        }
        else{
            ++i;
            ind=i;
        }
    }
    int M=0;
    F(i,0,n){
        M=max(M,cnt[i]);
    }
    F(i,0,n){
        if(M==cnt[i]){
            cout << s[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 15104
from heapq import heappush, heappop

n, m = map(int, input().split())
a_list = list(map(int, input().split()))

hqueue = []
for a in a_list:
    heappush(hqueue, -a)

for i in range(m):
    max_item = -(-heappop(hqueue) // 2)
    heappush(hqueue, max_item)

cost = 0
for i in range(n):
    cost += -heappop(hqueue)

print(cost)


Measured memory_bytes: 14180
object Main extends App {

  val Array(n, a, b) = io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = (1 to n).foldLeft(0)( (acc,i) => {
    val sum = (1 to 5).foldLeft((i,0))( (acc,_) => {
      (acc._1 / 10, acc._2 + (acc._1 % 10))
    })._2
    if(a <= sum && sum <= b ) acc + i else acc
  })

  println(ans)
}

Measured memory_bytes: 31996
N, M = gets.split.map(&:to_i)
array = []

def isOK(p,t,l)
    sum = 0
    t.each{|x| sum += l[x-1]}
    return sum % 2 == p
end

M.times{
    target = gets.split.map(&:to_i)
    target.shift
    array.push(target)
}
plist = gets.split.map(&:to_i)

list = [0,1].repeated_permutation(N).to_a
array.each.with_index{|target_list,index|
    list.select!{|x|
        isOK(plist[index], target_list, x)
    }
}

puts list.size

Measured memory_bytes: 3964
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s1,s2;
ll n,m,ans,tmp;
vector<ll>v[26];
int main(void){
    cin>>s1>>s2;
    n=s1.size();
    m=s2.size();
    for(int i=0;i<n;i++){
        v[s1[i]-'a'].push_back(i+1);
    }
    for(int i=0;i<m;i++){
        ll t=s2[i]-'a';
        if(v[t].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        ll itr=upper_bound(v[t].begin(),v[t].end(),tmp)-v[t].begin();
        //cout<<tmp<<itr<<ans<<endl;
        if(itr==v[t].size()){
            if(tmp!=0)ans+=n;
            tmp=v[t][0];
        }
        else if(tmp<v[t][itr]){
            tmp=v[t][itr];
        }
        else {
            tmp=v[t][0];
            ans+=n;
        }
    }
    cout<<ans+tmp<<endl;
}


Measured memory_bytes: 1724
//=====================================================================================================================================//
//Al_Qatil 
#include <bits/stdc++.h>
//g++ code.cpp -o /x
using namespace std;
#define ll long long
using ii=tuple<ll, ll>;
#define pb push_back
#define For(i,n) for(ll  i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(a,b,c) for(ll a=b;a<c;a++)
#define M 1000000007
#define vi vector<ll> 
#define vvi vector<vi>
#define int long long
#define rl(t) ll t;cin>>t;
#define rs(t) string t;cin>>t;

//=====================================================================================================================================//
//set <ll> :: iterator itr;
// if (b.find(a[i]) != b.end())
//Multiset
//multiset<int, greater<int>> h;
//auto it = h.lower_bound(x);
//if (it == h.end()) cout << "-1\n";
// priority queue .. queue in des order  :-> priority_queue<tuple<int, bool>> q;
const int N = 2e5 + 10, inf = 1e9 + 42;
//=====================================================================================================================================//
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return (res * res * a)%M;
    else
        return (res * res)%M;
}
signed main() 
{   
    fast;
    ll n,m;
    cin>>n>>m;
    string s[n];
    For(i,n)cin>>s[i];
    ll a[n][m]={0};
    ll c=0;
    a[0][0]=1;
    f(i,1,n)
    {
        if(s[i][0]=='#')a[i][0]=0;
            else a[i][0]=a[i-1][0];
    }
    f(i,1,m)
    {
        if(s[0][i]=='#')a[0][i]=0;
        else a[0][i]=a[0][i-1];
    }
    f(i,1,n)
    {
        f(j,1,m)
        {
            if(s[i][j]=='#')a[i][j]=0;
            else a[i][j]=(a[i-1][j]+a[i][j-1])%M;
        }
    }
    cout<<a[n-1][m-1]<<endl;
}

//======================================================================================================================================//

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    int x,n,tool;
    set<int>a;
    cin>>x>>n;
    for(int i=0; i<n; i++)
    {
        cin>>tool;
        a.insert(tool);
    }
    for(int i=x,j=x;; i++,j--)
    {
        if(a.find(i)!=a.end()&&a.find(j)==a.end())
        {
            cout<<j;
            return 0;
        }
        else if(a.find(j)!=a.end()&&a.find(i)==a.end())
        {
            cout<<i;
            return 0;
        }
        else if(a.find(j)==a.end()&&a.find(i)==a.end())
        {
            cout<<j;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      double output = (1.0 / one.get(0)) + (1.0 / one.get(1));
      myout(1 / output);
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 33172
#include <iostream>

using namespace std;
using ll = long long;

int main(){
  ll n, m;
  cin >> n >> m;
  ll maxl = 1, minr = n;
  for(ll i=0; i<m; ++i){
    ll l, r;
    scanf("%ld%ld", &l, &r);
    if(maxl < l) maxl = l;
    if(minr > r) minr = r;
  }
  ll res;
  if(minr < maxl) res = 0;
  else res = minr - maxl + 1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256