akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define cont continue
#define inf ll(1e18)
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}
int main()
{
	ios;
	ll n,m,x;
	cin>>n>>m>>x;
	ll cost[n+1],skill[n+1][m+1];ll i,j;vtr<ll> sum(m+1,0);bool fg=1;
	for(i=1;i<=n;i++)
	{
		cin>>cost[i];
		for(j=1;j<=m;j++)cin>>skill[i][j],sum[j]+=skill[i][j];
	}
	for(i=1;i<=m;i++)
	{
		if(sum[i]<x)
		{
			fg=0;break;
		}
	}
	if(!fg)cout<<-1;
	else
	{
		ll mask=(1<<n);ll ct=0;ll ans=inf,bit;
		for(i=0;i<mask;i++)
		{
			ct=0;vtr<ll> sk(m+1,0);bool fg=1;
			for(bit=0;bit<n;bit++)
			{
				if(i&(1<<bit))
				{
					ct+=cost[bit+1];
					for(j=1;j<=m;j++)
					{
						sk[j]+=skill[bit+1][j];
					}
				}
			}
			for(j=1;j<=m;j++)
			{
				if(sk[j]<x){fg=0;break;
				}
			}
			if(fg)
			{
				ans=min(ans,ct);
			}
		}cout<<ans;
	}
}

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

int main() {

	int n; cin >> n;
	vector<ll> a(n + 1);
	vector<ll> b(n);
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] <= a[i]) {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		else { // a[i] < b[i]
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
			if (b[i] <= a[i + 1]) {
				ans += b[i];
				a[i + 1] -= b[i];
				b[i] = 0;
			}
			else {  // a[i + 1] < b[i]
				ans += a[i + 1];
				b[i] -= a[i + 1];
				a[i + 1] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4764
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)

    if op == '?' :
        break
    if op == '+' :
        print(a+b)
    elif op == '-' :
        print(a-b)
    elif op == '*' :
        print(a*b)
    elif op == '/' :
        print(a//b)
    


Measured memory_bytes: 5596
loop do
  n = gets.to_i
  break if n == 0

  pn = Array.new
  n.times do |i|
    m, *ps = gets.chomp.split.map &:to_i
    pn[i] = ps
  end
  k, *ks = gets.chomp.split.map &:to_i

  index = nil;
  num = 0
  pn.each_with_index do |ps, i|
    if ks.all? {|p| ps.include? p }
      index = i + 1
      num += 1
    end
  end
  puts num == 1 ? index : -1
end

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

long long q, h, s, d, n;

int main() {
  cin >> q >> h >> s >> d >> n;
  h = min(h, 2 * q);
  s = min(s, 2 * h);
  d = min(d, 2 * s);
  cout << (n / 2) * d + (n & 1) * s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<pair<i64, i64>> ps(N);
  vector<i64> xs(N), ys(N);
  REP(i, N) {
    cin >> ps[i].first >> ps[i].second;
    xs[i] = ps[i].first;
    ys[i] = ps[i].second;
  }
  std::sort(ps.begin(), ps.end());
  std::sort(xs.begin(), xs.end());
  std::sort(ys.begin(), ys.end());
  i64 mina = numeric_limits<i64>::max();
  REP(xi, xs.size()) {
    REP(xj, xi) {
      REP(yi, ys.size()) {
        REP(yj, yi) {
          i64 ar =
              (__int128_t)(xs[xi] - xs[xj]) * (__int128_t)(ys[yi] - ys[yj]);
          int cnt = 0;
          REP(k, N) {
            auto [xk, yk] = ps[k];
            if (xk >= xs[xj] && xk <= xs[xi] && yk >= ys[yj] && yk <= ys[yi])
              ++cnt;
          }
          if (cnt >= K) {
            mina = min(mina, ar);
          }
        }
      }
    }
  }
  cout << (i64)(mina) << endl;
}

Measured memory_bytes: 3632
//tenka1_2019_a.cpp
//Tue Apr 30 16:36:32 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if (a<c && c<b){
		cout << "Yes" << endl;
	}else if (a>c && c>b){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: Vec<(String, i32, usize)> = (0..n).map(|i| (read(), read(), i)).collect();

    // 点数で降順ソート
    let mut b: Vec<(i32, String, usize)> = Vec::new();
    for i in 0..n {
        b.push((-a[i].1, a[i].0.clone(), a[i].2));
    }
    b.sort();

    // 市名でソート
    let mut a: Vec<(String, i32, usize)> = Vec::new();
    for i in 0..n {
        a.push((b[i].1.clone(), b[i].0, b[i].2));
    }
    a.sort();
    
    for i in a {
        println!("{}", i.2 + 1);
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

long long A, B, C;
int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	//cout << sqrt(A) << " " << sqrt(B) << " " << sqrt(C) << " " << sqrt(A) + sqrt(B) << endl; 
	if (C < A + B) {
		printf("No\n");
		return 0;
	}
	if (4*A*B < (C - A - B)*(C - A - B)) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 11:07:19 2019

@author: Yamazaki Kenichi
"""

N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
ABC = [0,A,B,C]
def basen(x,n):
    if x//n >0:
        return basen(x//n,n)+str(x%n)
    return str(x%n)

x = []
ans = 10**5
for i in range(4**N):
    k = basen(i,4).zfill(N)
    if any(k.count(c)<1 for c in '123'):
        continue
    abc = ABC[:]
    for j in range(N):
        abc[int(k[j])] -= l[j]
    ans = min(ans,
              (N-k.count('0')-3)*10
              +abs(abc[1])+abs(abc[2])+abs(abc[3]))
print(ans)

Measured memory_bytes: 3188
var
  i,n,j,k,s,t:longint;
  a:array[0..10000] of longint;
begin
  readln(n,k);
  for i:=1 to n do read(a[i]);
  for i:=1 to n-1 do
    for j:=i+1 to n do
    if a[i]<a[j] then begin t:=a[i];a[i]:=a[j];a[j]:=t;end;
  for i:=1 to k do inc(s,a[i]);
  writeln(s);
end.

Measured memory_bytes: 128
n = int(input())
d = dict()
S = list()
ans = list()
for _ in range(n):
    s = input()
    S.append(s)
    d[s] = 0
for s in S:
    if s in d:
        d[s] += 1
d = sorted(d.items(),key = lambda x:x[1], reverse = True)
max = d[0][1]
for word in d:
    if word[1] == max:
        ans.append(word[0])
    else:
        break
ans.sort()
for w in ans:
    print('{}\n'.format(w))

Measured memory_bytes: 44804
#include <cstdio>
 
int main(){
 
  int N[3],t;
  scanf("%d %d %d",&N[0],&N[1],&N[2]);
  if(N[0]==N[1])t=2;
  else if(N[1]==N[2])t=0;
  else t=1;
  printf("%d\n",N[t]);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

void solve() {
    int H,W;
    cin >> H >> W;
    // printf("%d %d\n",H,W);
    map<int, int> s;
    multiset<int> vals;

    rep(i, W) s[i] = i;
    // for(auto t : s){
    //     DEBUG(t.fi);
    //     DEBUG(t.sc);
    // }
    rep(i, W) vals.insert(0);
    // for(s
    int l,r;
    // DEBUG("hoge");
    rep(i,H) {
        cin >> l >> r;
        l--;
            // printf("%d %d\n",l,r);
        // DEBUG(l);
        // DEBUG(r);
        auto it = s.lower_bound(l);
            // printf("%d %d\n",it->first,it->second);

        int mr = -1;
        while (it != s.end() && it->first <= r) {
            mr = max(mr, it->second);
            int x = it->first - it-> second;
            vals.erase(vals.find(x));
            s.erase(it++);
        }
        // DEBUG(i);
        // for(auto t : s){
        //     DEBUG(t.fi);
        //     DEBUG(t.sc);
        // }
        if (mr != -1 && r < W) {
            vals.insert(r-mr);
            s[r] = mr;
        }
        int ans = -1;
        if (vals.size() > 0) {
            ans = *vals.begin() + (i+1);
        }
        print(ans);
    }
}   

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 22368
s = [int(input()) for i in range(5)]
k = int(input())
c = 0 
for i in range(5):
    for j in range(i+1,5):
        t = s[j] -s[i]
        if t > k:
            c = 1
        else:
            continue

if c == 0:
    print("Yay!")
else:
    print(":(")

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

int main(){
	string s;
	vector<string> w;

	while(cin >> s){
		if(s=="hoge") break;
		
		if( s.find("peach",0) != string::npos){
			unsigned i = s.find("peach",0);
			s.replace( i , 5 , "apple" );
		}else if( s.find("apple",0) != string::npos){
			unsigned i = s.find("apple",0);
			s.replace( i , 5 , "peach" );
		}
		w.push_back(s);
	}
	for(int i=0 ; i<w.size() ; i++){
		cout << w[i];
		if(i==w.size()-1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

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

	R := nextInt()
	C := nextInt()
	K := nextInt()

	g := [3010][3010]int{}
	for i := 0; i < K; i++ {
		r := nextInt()
		c := nextInt()
		v := nextInt()
		g[r][c] = v
	}

	dp := [3010][3010][5]int{}
	for i := 1; i <= R; i++ {
		for j := 1; j <= C; j++ {
			for k := 3; k >= 0; k-- {
				dp[i][j][k] = max(
					dp[i][j][k],
					dp[i][j-1][k],
				)

				dp[i][j][k+1] = max(
					dp[i][j][k+1],
					dp[i][j][k]+g[i][j],
				)

				if k < 3 {
					dp[i+1][j][0] = max(
						dp[i+1][j][0],
						dp[i][j][k]+g[i][j],
					)
				}
			}
		}
	}

	ans := 0
	for k := 0; k <= 3; k++ {
		ans = max(ans, dp[R][C][k])
	}
	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

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


Measured memory_bytes: 442304
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int a;
	cin >> a;
	cout << 1 - a << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
string out="";
rep(i,s.size()){
    switch (s[i])
    {
    case '0':
        out+='0';
        break;
    case '1':
        out+='1';
        break;
    default:
        if(out.size()>0)out.erase(out.end()-1);
        break;
    }
}
cout<<out<<endl;
return 0;
}

Measured memory_bytes: 256
// Last Change: 04/19/2020 21:13:13.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const double PI = acos(-1);

int main() {
  double R;
  cin >> R;
  cout << std::fixed << std::setprecision(15) << 2 * R * PI << endl;
}


Measured memory_bytes: 3264
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a;
  bitset<64> flg;
  unsigned long long tmp;
  unsigned long long mask;
  int q;
  int c,i;
  flg = 0;
  cin >> q;

  for(ii=0;ii<q;ii++){
    cin >> c;
    switch(c){

    case 0:
      cin >> i;
      if(flg.test(i)){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
      break;
    case 1:
      cin >> i;
      tmp = flg.to_ullong();
      //flg = flg |(1 << i);
      tmp = tmp |(1LL << i);
      flg = tmp;
      //flg.set(i);
      break;
    case 2:
      cin >> i;
      tmp = flg.to_ullong();
      tmp = tmp & ~(1LL << i);
      flg = tmp;
      //flg.reset(i);
      break;
    case 3:
      cin >> i;      
      tmp = flg.to_ullong();
      mask = (1LL << i);
      tmp = (tmp & ~(1LL << i)) | (mask ^ tmp);
      //tmp |= ((tmp & mask) ^ mask);
      flg = tmp;
      //flg.flip(i);
      break;
   case 4:
     tmp = flg.to_ullong();
     if(tmp == 0xffffffffffffffff){
     //if(flg.all()){
       cout << 1 << endl;
     }
     else{
       cout << 0 << endl;
     }
     break;
    case 5:
      tmp = flg.to_ullong();
      if(tmp != 0){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }      
      break;
    case 6:
      tmp = flg.to_ullong();
      if(tmp == 0){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }      
      break;
    case 7:
      cout << flg.count() << endl;
      break;
    case 8:
      cout << flg.to_ulong() << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 3080
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
    }
    let mut prod = 0f64;
    for i in 1..n+1 {
        let mut cnt = 0f64;
        let mut acc = i;
        loop {
            if acc >= k {
                break
            } else {
                cnt += 1f64;
                acc *= 2;
            }
        }
        prod += 0.5f64.powf(cnt)
    }
    let ans = 1f64 / n as f64 * prod;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    --x;--y;
    vector<int>ans(n,0);
    rep(i,n){
    	vector<int>dist(n,inf);
    	queue<int>q;
    	auto push=[&](int v,int d){
    		if(dist[v]!=inf)return;
    		dist[v]=d;
    		q.push(v);
    	};
    	push(i,0);
    	while(!q.empty())
    	{
    		int v=q.front();q.pop();
    		int d=dist[v];
    		if(v-1>=0)push(v-1,d+1);
    		if(v+1<n)push(v+1,d+1);
    		if(x==v)push(y,d+1);
    		if(y==v)push(x,d+1);
    	}
    	rep(j,n)ans[dist[j]]++;
    }
    rep(i,n-1)cout<<ans[i+1]/2<<endl;;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 114514114514810
using namespace std;
int n,m,a[2010],b[2010];long long c[2010],d[1010];
bool FNS(){
	rep(i,n+1)d[i]=-INF;d[1]=0;
	rep(i,n+1)rep(j,m){
		if(d[b[j]]<d[a[j]]+c[j]&&d[a[j]]!=INF){
			d[b[j]]=d[a[j]]+c[j];
			if(i==n&&b[j]==n)return 0;
		}
	}
	return 1;
}
int main(){
	cin>>n>>m;
	rep(i,m)cin>>a[i]>>b[i]>>c[i];
	if(FNS())cout<<d[n]<<endl;
	else cout<<"inf"<<endl;
	return 0;
}


Measured memory_bytes: 256
n, *a = map(int, open(0).read().split())
a = sorted([0,24]+a)
for i in range(1, n+1, 2): a[i] = 24-a[i]
a.sort()
ans = 24
for i in range(n+1): ans = min(ans, abs(a[i]-a[i+1]))
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std; typedef long long ll; const int MINF=-1e9; typedef pair<int,int> P;

int main() {
  string s; cin>>s; int n=s.size();
  int an=n, ss=0;
  for(int i=0;i<n;i++) {
    if (s[i]=='S') {
      ss++;
    } else {
      if (ss>0) ss--, an-=2;
    }
  }
  cout<<an<<endl;
}

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

int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if(a==0)
	{
		cout<<0;
		return 0;
	}
	
	long long s=n/(a+b)*a,c=n%(a+b);
	if(c>=a)
		cout<<s+a;
	else
		cout<<s+c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector> 
using namespace std;
int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<int>> t(w, vector<int>(h));
	for (int i = 0; i<w; i++)
	{
		for (int j = 0; j<h; j++)
		{
			t.at(i).at(j) = { 0 };
		}

	}
	for (int i = 0; i<n; i++)
	{
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1)
		{
			for (int j = 0; j<x; j++)
			{
				for (int k = 0; k<h; k++)
				{
					t.at(j).at(k) = { 1 };
				}
			}
		}
		else if (a == 2)
		{
			for (int j = x; j<w; j++)
			{
				for (int k = 0; k<h; k++)
				{
					t.at(j).at(k) = { 1 };
				}
			}
		}
		else if (a == 3)
		{
			for (int j = 0; j<y; j++)
			{
				for (int k = 0; k<w; k++)
				{
					t.at(k).at(j) = { 1 };
				}
			}
		}
		else
		{
			for (int j = y; j<h; j++)
			{
				for (int k = 0; k<w; k++)
				{
					t.at(k).at(j) = { 1 };
				}
			}
		}

	}
	int ans = 0;
	for (int i = 0; i<w; i++)
	{
		for (int j = 0; j<h; j++)
		{
			if (t.at(i).at(j) == 0)
			{
				ans++;
			}

		}

	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  int k=(n-1)/300+1;
  int u[k];
  int cnt=0;
  rep(i,k-1){
    u[i]=a[cnt];
    cnt++;
    rep(j,299){
      u[i]=gcd(u[i],a[cnt]);
      cnt++;
    }
  }
  u[k-1]=a[cnt];
  cnt++;
  while(cnt<n){
    u[k-1]=gcd(u[k-1],a[cnt]);
    cnt++;
  }
  int ans=0;
  rep(i,n){
    int t=i/300;
    int y;
    if(t!=0){
      y=u[0];
      rep(j,k-1){
        if(j+1!=t)y=gcd(y,u[j+1]);
        else{
          rep(l,300){
            if(300*(j+1)+l>=n)continue;
            if(300*(j+1)+l==i)continue;
            y=gcd(y,a[300*(j+1)+l]);
          }
        }
      }
      ans=max(ans,y);
    }
    else{
      int f=0;
      rep(q,n){
        if(q==i)continue;
        if(f==0)f=a[q];
        else f=gcd(f,a[q]);
        
      }
      ans=max(ans,f);
    }
  }
  cout << ans << endl;
}  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m,i,j,k=0,f,x,y,q,a,b,c,d;

    cin>>n;

    k=n%10;

    if(k==2 || k==4 || k==5 || k==7 || k==9){

        cout<<"hon"<<endl;
    }
    else if(k==3){

            cout<<"bon"<<endl;

    }
    else{

        cout<<"pon"<<endl;
    }

}




Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N,K,S=map(int,input().split())
    if S<10**9:
        L=[S]*K+[S+1]*(N-K)
    else:
        L=[S]*K+[S-1]*(N-K)


    print(*L)

resolve()

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;

//global-----------------------------------------------------------------------------------------------------------------------
char a[ 10000 ];
map<string, int> ar;
int most_lengh = 0;
string most_str;
//#define DEBUG
//function--------------------------------------------------------------------------------------------------------------------

int main() {
	while ( scanf( "%s", a ) != EOF ) {
		string str = (string)a;
		ar[ str ]++;
		if ( most_lengh < str.size() ) {
			most_lengh = str.size();
			most_str = str;
		}
		
	}
	string ans;
	int b = 0;
	map<string, int>::iterator it;
	for ( it = ar.begin(); it != ar.end(); it++ ) {
		if ( b < it->second ) {
			b = it->second;
			ans = it->first;
		}
	}
	cout << ans << " " << most_str << "\n";
	return 0;
}

Measured memory_bytes: 1196
import random
import time
import copy
start = time.time()
D = int(input())
s = [[0 for j in range(26)] for i in range(D)]
c = list(map(int, input().split(" ")))
result = []
total = -10000000
for i in range(D):
    a = list(map(int, input().split(" ")))
    for j, k in enumerate(a):
        s[i][j] = int(k)
while(1):
    result_tmp = []
    total_tmp=0
    last = [0 for i in range(26)]
    for i in range(D):
        score = [0 for i in range(26)]

        for j in range(26):
            score[j] = s[i][j]
            for k in range(26):
                if j != k:
                    score[j] -= (i + 1 - last[k]) * c[k]
        score_sort = sorted(score, reverse=True)
        score_max = score_sort[0]

        tmp = []
        for j in range(26):
            if score_max >= 0 and score_max*0.95 <= score[j]:
                tmp.append(j)
            if score_max < 0 and score_max*1.05 <= score[j]:
                tmp.append(j)

        score_max = random.choice(tmp)

        result_tmp.append(score_max)
        last[score_max] = i + 1
        total_tmp += score[score_max]
    if total < total_tmp:
        total=total_tmp
        result = result_tmp.copy()
    end = time.time()
    if end - start > 1.8:
        break
for i in range(D):
    print(result[i]+1)


Measured memory_bytes: 87272
fn input_line() -> Vec<String> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).unwrap();
  return buf
    .split_whitespace()
    .map(|word| String::from(word))
    .collect();
}

fn main() {
  let inputs = input_line();
  let n: i32 = inputs[0].parse().unwrap();
  let d: i64 = inputs[1].parse().unwrap();
  let mut x: Vec<i64> = Vec::new();
  let mut y: Vec<i64> = Vec::new();
  for _ in 0..n {
    let inputs = input_line();
    x.push(inputs[0].parse().unwrap());
    y.push(inputs[1].parse().unwrap());
  }

  let mut ans = 0;
  let d2 = d.pow(2);
  for i in 0..n {
    let i: usize = std::convert::TryFrom::try_from(i).unwrap();
    if x[i].pow(2) + y[i].pow(2) <= d2 {
      ans += 1;
    }
  }
  println!("{}", ans);
}

Measured memory_bytes: 5468
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[1000001],id[1000001];
bool cmp(int x,int y) {return a[x] < a[y];}
int main() {scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) id[i] = i; sort(id+1,id+n+1,cmp);
for(int i=1;i<=n;i++) printf("%d ",id[i]);
}

Measured memory_bytes: 5248
char a[500][501];m[500][500];main(i,j,k,x,y,r,M){
for(;scanf("%d%d",&y,&x),x;printf("%d\n",r)){
	for(j=0;j<y;j++)scanf("%s",a[j]);
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++)if(a[j][i]=='.')r++;else r=0;
	for(r=i=0;i<x;i++)for(j=0;j<y;j++)for(M=99,k=j;k<y;k++){
		if(M>m[k][i])M=m[k][i];
		if(r<M*(k-j+1))r=M*(k-j+1);
	}
}exit(0);}

Measured memory_bytes: 1824
N = int(input())

from collections import defaultdict
def factorize(n):
    dd = defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        while n%i==0 and n>0:
            dd[i]+=1
            n//=i
    if n>1:
        dd[n]+=1
    return dd

dd = factorize(N)

def check(num):
    count = 0
    for i in range(1,101):
        if count > num:
            break
        count += i
    return i-2

ans = 0
for key in dd:
    ans +=check(dd[key])

print(ans)

Measured memory_bytes: 66192
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,a[110],i,j;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=(1<<29);
  for(i=0;i<n;i++){
    int sum=0,sum1=0;
    for(j=0;j<i;j++){
      sum+=a[j];
    }
    for(j=i;j<n;j++){
      sum1+=a[j];
    }
    ans=min(ans,abs(sum-sum1));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	new A().doIt();
    }
    class A{
    	void doIt(){
    		int n = sc.nextInt();
    		ArrayList<String> array = new ArrayList<String>();
    		for(int i = 0;i < n;i++){
    			array.add(sc.next());
    		}
    		int m = sc.nextInt();
    		boolean open = true;
    		for(int i = 0;i < m;i++){
    			String str = sc.next();
    			if(array.contains(str)){
    				if(open){
    					System.out.println("Opened by "+str);
    					open = false;
    				}else{
    					System.out.println("Closed by "+str);
    					open = true;
    				}
    			}else{
    				System.out.println("Unknown "+str);
    			}
    		}
    	}
    }
}

Measured memory_bytes: 28540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rep1(i,n) for(int i=1; (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
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; }
const long long llINF = 1LL<<60;
const int INF = 1e9;

int main(){
    //int n; cin >> n;
    //vector<int> v(n); rep(i,n) cin >> v[i];
    string s; cin >> s;
    int cnt=0, flg=1;
    for(int i=0; i<4; ++i){
      for(int j=0; j<4; ++j){
        if(s[i]==s[j]) cnt++;
      }
      if(cnt!=2){cout << "No"; flg=0; break;}
      cnt=0;
    }
    if(flg)cout << "Yes";

    return 0;
}

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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(begin(a), end(a));

    int r = a.back();
    int idx = lower_bound(begin(a), end(a), r / 2) - begin(a);
    const int mid = r / 2;
    int sub = a[idx] - mid - (n & 1);
    if(idx > 0 && sub > mid - a[idx - 1]) {
        idx--;
    }

    if(idx == n - 1) idx--;

    cout << r << ' ' << a[idx] << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define TRUE "War"
#define FALSE "No War"

void output(int b) {
  puts(!b ? TRUE : FALSE);
}

int main() {
  int N, M, X, Y;
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  
  int xMax = -100;
  
  for (int i = 0; i < N; i++) {
    int x;
    scanf("%d", &x);
    if (xMax < x) xMax = x;
  }
  int yMin = 100;
  
  for (int i = 0 ; i < M; i++) {
    int y;
    scanf("%d", &y);
    if (yMin > y) yMin = y;
  }
  output(
    (X < xMax + 1 && yMin <= Y) &&
    xMax < yMin
  );
  return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    int n,a,b;
    cin>>n>>a>>b;

    cout<<min(n*a,b)<<endl;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n,0);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    if(k==1) {
        cout << "0" << endl;
        return 0;
    }

    mint res=0;
    mint num=1;
    for(int i = k-1; i<=n; ++i){
        if(i>k-1){
            num*=i;
            num/=(i-k+1);
        }
        mint temp = a[i];
        temp *= num;
        res += temp;
    }
    reverse(a.begin(),a.end());
    num=1;
    for(int i = k-1; i<=n; ++i){
        if(i>k-1){
            num*=i;
            num/=(i-k+1);
        }
        mint temp = a[i];
        temp *= num;
        res -= temp;
    }
    cout << res.x << endl;
}

Measured memory_bytes: 640
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B = input().split()
A = int(A)
B = int(float(B)*10000)

B = round(B,-2)
ans = (A*B)//10000

# print(A,B,ans)
print(int(ans))
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int main(){
    int N;
    string ans="";
    cin >> N;
    //while(N < 10){
        N = N % 10;
    //}
    if(N == 2 || N == 4 || N == 5 || N == 7 || N== 9){
        ans ="hon";
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        ans ="pon";
    }else{
        ans = "bon";
    }
    cout << ans << endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] arr = new long[n];
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextLong();
        }
        long[] dp = new long[n];
        dp[0] = 0;
        if (n == 1) {
            System.out.println(0);
        }
        dp[1] = Math.abs(arr[1] - arr[0]);
        for (int i=2; i<n; i++) {
            dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]), dp[i-2]+Math.abs(arr[i]-arr[i-2]));
        }
        System.out.println(dp[n-1]);
    }
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end(),greater<int>());
    int ans = 0;
    for(int i = 0; i  < k; i++){
        ans += l[i];
    }
    cout << ans << endl;
}

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

const int N = 1e5+10;
ll n, m, x;
bool f[N];
void solve(){
    cin >> n >> x >> m;
    ll s = x;
    vector<ll>a;
    while(f[s]!=1) {
        a.push_back(s);
        f[s] = 1;
        s = (s * s)%m;
    }
    vector<ll>cycle;
    while(a.back() != s)
        cycle.push_back(a.back()), a.pop_back();
    if(a.size())
        a.pop_back();
    cycle.push_back(s);


    //for(int i:a)
        //cout << i << " ";
    //cout << "\n";
    //for(int i:cycle)
        //cout << i << " ";
    //cout << "\n";
    //return;


    reverse(cycle.begin(), cycle.end());


    if(n <= (int)a.size()) {
        ll ans = 0;
        for(int i=0;i<n;++i)
            ans += a[i];
        cout << ans << "\n";
        return;
    }
    n -= (int)a.size();
    ll rem = 0;
    for(int i=0;i<(n%(int)cycle.size());++i)
        rem += cycle[i];
    ll ans = accumulate(a.begin(), a.end(), 0LL) + (n/(int)cycle.size())*(accumulate(cycle.begin(), cycle.end(), 0LL)) + rem;

    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0; }



Measured memory_bytes: 4360
#include<stdio.h>
using namespace std;

int main(){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
int x=c-a,y=d-b;
printf("%d %d %d %d\n",c-y,d+x,a-y,b+x);
  return 0;
}


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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

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

int main() {
  ll A,B,ans;
  cin >> A >> B;
  ans = A-2*B;
  if(ans<0) ans = 0;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3644
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	// mahakal(),fast;
	int r ;
	cin>> r ;
	cout<<fixed;
	long double ans = 2*3.14*r;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
typedef long long LL;
const LL maxn=1e6+9,inf=0x3f3f3f3f,mod=2019;
inline LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
LL T,n,L,R;
int main(){
	L=Read(); R=Read();
	LL len(R-L+1);
	if(len>=2019) puts("0");
	else{
		LL ans(inf);
		for(LL i=L;i<=R;++i){
			for(LL j=L;j<=R;++j){
				if(i==j) continue;
				ans=std::min(ans,i%mod*(j%mod)%mod);
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int b, r, g, c, s, t;
    
    while (1){
        scanf("%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t);
        
        if (b + r + g + c + s + t == 0){
            break;
        }
        
        printf("%d\n", 100 - (t - s) * 3 + c * 2 + g * 7 + 15 * (b + r) + 15 * 5 * b + 15 * 3 * r + (b * 5 + r * 3));
    }
    
    return (0);
}

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

using namespace std;

using ll = long long;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k << endl;
    }
    else if (k <= a + b) {
        cout << a << endl;
    }
    else {
        cout << a - (k - (a + b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
/*

Name: Krishan Kant Agnihotri
FROM: University school of information and technology

*/
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define FOR(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
using namespace std;
;
//use it with unordered_map<T,T,custom_hash> safe_map
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int cnt = 0 ; 
    for(int i= l;i<=r;i++){
        if(i%d==0)
        cnt++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3600
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main(){
  string s,t;
  
  cin >> s >> t;
  ll ii;
  vector<ll> sLen,tLen;
  
  sLen.resize(26);
  tLen.resize(26);
  
  for(ii=0;ii<s.length();ii++){
    sLen[s[ii]-'a']++;
    tLen[t[ii]-'a']++;
  }

  sort(sLen.begin(),sLen.end());
  sort(tLen.begin(),tLen.end());
  int flg =0;
  for(ii=0;ii<26;ii++){

    if(sLen[ii] == tLen[ii]){

    }
    else{
      flg = 1;
    }
    
  }
  if(flg == 1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int ac = 0;
  int wa = 0;
  vector<bool> ans(N, false);
  vector<int> tmp_wa(N, 0);
  rep(i, M) {
    int p;
    string S;
    cin >> p >> S;
    if (ans[p] == false && S == "AC") {
      ac++;
      wa += tmp_wa[p];
      ans[p] = true;
    }
    if (S == "WA") tmp_wa[p]++;
  }
  cout << ac << " " << wa << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <climits>
#include <list>

using namespace std;

int main()
{
	string str, left, right;
	int m, num = 0;
	list<string> ans;
	while (cin >> str) {
		if (str == "-") break;
		num++;
		cin >> m;
		int *h = new int[m];
		for (int i = 0; i < m; i++) {
			cin >> h[i];
			left = str.substr(0, h[i]);
			right = str.substr(h[i], str.length() - h[i]);
			str = right + left;
		}
		ans.push_back(str);
	}
	for (auto itr = ans.begin(); itr != ans.end(); ++itr) {
		cout << *itr << "\n";
	}
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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


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

const int mod = 1e9+7;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i=0; i < y; ++i) {
        res = res * x % mod;
    }
    return res;
}

// 包除原理
int main()
{
    int n;
    cin >> n;
    ll ans;
    ans = powmod(10,n)-2*powmod(9,n)+powmod(8,n);
    ans %= mod;
    ans = (ans+mod)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596