akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[101010];

int poword(i64 v)
{
	for (int i = 0; i <= 30; ++i) {
		if (v <= (1 << i)) return i;
	}
	return 0;
}

int ord[101010]; bool ispow[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%lld", A + i);
	}

	for (int i = 0; i < N; ++i) {
		ord[i] = poword(A[i]);
		ispow[i] = (A[i] != (1 << ord[i]));
		if (ispow[i]) --ord[i];
	}
	ord[N] = 0;
	ispow[N] = false;

	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		if (ord[i] < ord[i + 1]) {
			// just connect
		} else if (ord[i] == ord[i + 1]) {
			if (ispow[i]) {
				++ret;
				ispow[i + 1] = false;
			}
		} else {
			ret += (ispow[i] ? 1 : 0) + (ord[i] - ord[i + 1]);
			ispow[i + 1] = false;
		}
	}

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


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  int N,M;
  ll ans=0;
  ll dis=1000000000;
  cin >> N >>M;
  ll a[50], b[50],c[50] ,d[50];
  
  for (ll i=0; i<N; i++) {
    cin >> a[i] >> b[i];
  }
  for (ll i=0; i<M; i++) {
    cin >> c[i] >> d[i];
  }
  for (ll i=0; i<N; i++) {
    dis=1000000000;
      for (ll j=0; j<M; j++) {
        if ((abs(a[i]-c[j])+abs(b[i]-d[j]))<dis){
          ans=1+j;
          dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
        }
     }
     cout << ans << endl;
  }
}

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

using namespace std;

long long S[200500];

int main()
{
	int Test=1; while (Test--){
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
      int a; scanf("%d", &a); 
      S[i] = S[i-1] + a;
    }
    long long ans = 0;
    sort(S, S+n+1);
    for(int i = 0; i <= n; ) {
      int j = i;
      while(j <= n && S[i] == S[j]) j++;
      ans += (long long)(j - i - 1) * (j - i) / 2;
      i = j;
    }
    printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1664
n = int(input())
a = [int(i) for i in input().split()]
l = sum(a)
l2 = l / 2
tmp = 0
err = [l,l]
errindex = [0,0]
ans = 0
for i in range(n):
    tmp += a[i]
    if err[0] > l2 - tmp and l2 - tmp >= 0:
        err[0] = l2 - tmp
    if err[1] > tmp - l2 and l2 - tmp <= 0:
        err[1] = tmp - l2

tmp2 = min(err)
tmp3 = int(tmp2)
ans = tmp3 * 2 #+1,-1をそれぞれする回数
if tmp2 - tmp3 > 0:
    ans += 1
print(ans)


Measured memory_bytes: 26220
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 998244353LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double r;
    cin >> r;
    cout << 2 * r * M_PI << '\n';
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a==c-b){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,x;cin>>n>>x;
    vector<int> m(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>m[i];
        sum += m[i];
    }
    sort(m.begin(),m.end());
    int res=n+(x-sum)/m[0];
    cout<<res<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/numeric/interval.hpp>
// #include <boost/numeric/interval/io.hpp>
// #include <boost/intrusive/rbtree.hpp>
// #include <boost/geometry.hpp>
// #include <boost/geometry/geometries/linestring.hpp>
// #include <boost/geometry/geometries/polygon.hpp>
// #include <boost/geometry/geometries/point_xy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace::std;
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cfloat;
// typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 1000000007
#define endl "\n"
template<typename T=lint>T in(){return *istream_iterator<T>(cin);}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint n,m;
    cin>>n>>m;
    multiset<lint> s;
    rep(i,n)s.insert(in());
    rep(i,m){
        auto small=*s.rbegin();
        s.insert((small)/2);
        s.erase(s.find(small));
    } 
    cout<<SUM(s);
}

Measured memory_bytes: 4992
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))
print(dp[-1])

Measured memory_bytes: 13980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = Integer.parseInt(sc.next());
		sc.close();

		//31日の24時間を考慮
		int ans  = 24 + (24 - M);
		System.out.println(ans);
	}
}

Measured memory_bytes: 20948
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


#奇数個のリンゴがあったら先手の勝利
N = INT()
a = [INT() for _ in range(N)]

if any(x%2 for x in a):
	print("first")
else:
	print("second")


Measured memory_bytes: 14412
#! /usr/bin/python3
# A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition)
"""
    3 つの文節の長さを表す整数 A,B,C が与えられるので、
    それらの文節を並び替えて五七五にできるか判定してください。

    入力: A B C
    出力: YES / NO
"""


A, B, C = map(int, input().split())
# 標準入力
list_ABC = [A, B, C]
test_mode = False

if test_mode is True:
    print(list_ABC)


def haiku_TF(x):
    """
    575ができるか判定
    """
    if x in ([5, 7, 5], [7, 5, 5], [5, 5, 7]):
        return True
    return False


if haiku_TF(list_ABC):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,m;
    in(n,m);
    priority_queue<int> price;
    int x;
    rep(i,n){
        in(x);
        price.push(x);
    }
    rep(i,m){
        price.push(price.top()/2);
        price.pop();
    }
    ll ans=0;
    rep(i,n){
        ans+=(ll)price.top();
        price.pop();
    }
    out(ans);
}


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

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

    string S;
    cin >> S;
    S = " " + S + " ";

    int accE[N+2] = {}, accW[N+2] = {};
    for (int i=1; i<=N; i++) {
        accW[i] = accW[i-1];
        if (S[i] == 'W') accW[i]++;
    }
    for (int i=N; i>=1; i--) {
        accE[i] = accE[i+1];
        if (S[i] == 'E') accE[i]++;
    }

    int ans = N;
    for (int i=1; i<=N; i++) ans = min(ans, accW[i-1] + accE[i+1]);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  ll x,k,d; cin >> x >> k >> d;
  if(x < 0) x *= -1;
  if(k < x/d){
    cout << x-k*d;
  }else{
    ll cnt = x/d;
    ll now = x-d*cnt;
    if((k-cnt) % 2 == 0) cout << now;
    else cout << d-now;
  }
  return 0;
}


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

int main() {
  vector <long> A (86,0);
  int N;
  cin >> N;
  A[0] = 2;
  A[1] = 1;
  for ( int i = 2 ; i<=N; i++){
    A[i] = A[i-1] + A[i-2];
  }
  cout << A[N] << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = set(int(input()) for i in range(m))
mod = 1000000007
lis = []
 
if n ==  1 and m == 0:
  print(1)
  exit()
  
if 1 not in a:
  lis.append(1)
  if 2 in a:
    lis.append(0)
  else:
    lis.append(2)
    
elif 1 in a:
  lis.append(0)
  if 2 in a:
    lis.append(0)
  else:
    lis.append(1)
 
 
for i in range(3,n+1):
  if i in a:
    lis.append(0)
  else:
    lis.append((lis[i-2] + lis[i-3])%mod)
    
print(lis[-1])

Measured memory_bytes: 11884
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define eb emplace_back
#define ii pair<int, int> 
#define vii vector<pair<int, int> >
#define fi first
#define se second
const int MOD = (int) 1e9+7;
map<int, vi> dist, cnt;
int n, m;
vector<pair<ii, int> > q;
vii G[200005];
void djk(int s, vi& dist, vi& cnt)
{
	dist.assign(n+5, LLONG_MAX/100000LL);
	cnt.assign(n+5, 0);
	priority_queue<ii, vii, greater<ii> > q;
	q.push({0, s}); dist[s]=0, cnt[s]=1;
	while(!q.empty())
	{
		int d=q.top().fi, u=q.top().se; q.pop();
		if(dist[u]!=d) continue;
		for(auto v: G[u])
		{
			if(dist[u]<LLONG_MAX and dist[v.fi]>dist[u]+v.se)
			{
				cnt[v.fi]=cnt[u];
				dist[v.fi]=dist[u]+v.se;
				q.push({dist[v.fi], v.fi});
			}
			else if(dist[v.fi]==dist[u]+v.se)
			{
				cnt[v.fi]=(cnt[v.fi]+cnt[u])%MOD;
			}
		}
	}
}
signed main()
{
	int s, t;
	cin>>n>>m>>s>>t;
	while(m--)
	{
		int u, v, w;
		cin>>u>>v>>w;
//		cout<<u<<" "<<v<<endl;
		G[u].eb(v, w);
		G[v].eb(u, w);
		q.push_back({{u, v}, w});
	}
	djk(s, dist[s], cnt[s]);
	djk(t, dist[t], cnt[t]);
	int ans=cnt[s][t]*cnt[s][t]%MOD;
	for(auto e: q)
	{
		int u=e.fi.fi, v=e.fi.se, d=e.se;
		if(dist[s][u]+dist[t][v]+d==dist[s][t] and 2*dist[s][u]<dist[s][t] and 2*dist[t][v]<dist[s][t])
		{
			int k=cnt[s][u]*cnt[t][v]%MOD;
			ans = (ans-k*k)%MOD;
		}
		if(dist[s][v]+dist[t][u]+d==dist[s][t] and 2*dist[s][v]<dist[s][t] and 2*dist[t][u]<dist[s][t])
		{
			int k=cnt[s][v]*cnt[t][u]%MOD;
			ans=(ans-k*k)%MOD;
		}
	}
	for(int u=1; u<=n; u++)
	{
		if(2*dist[s][u]==dist[s][t] and 2*dist[t][u]==dist[s][t]) 
		{
			int k=cnt[s][u]*cnt[t][u]%MOD;
			ans = (ans-k*k)%MOD;
		}
	}
	while(ans<0) ans+=MOD;
	cout<<ans;
}


Measured memory_bytes: 28876
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sorted := make([]int, n)
	copy(sorted, a)
	sort.Sort(sort.Reverse(sort.IntSlice(sorted)))
	w := bufio.NewWriter(os.Stdout)
	for _, e := range a {
		ans := sorted[0]
		if e == ans {
			ans = sorted[1]
		}
		fmt.Fprintln(w, ans)
	}
	w.Flush()
}


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

int main() {
  int N;
  cin >> N;
  map<string, int> stats;
  string str;
  for (int i = 0; i < N; i++) {
    cin >> str;
    decltype(stats)::iterator p = stats.find(str);
    if (p == stats.end())
      stats.insert(make_pair(str, 1));
    else
      (p->second)++;
  }
  int max = 0;
  for (decltype(stats)::iterator i = stats.begin(); i != stats.end(); i++) {
    if (i->second > max)
      max = i->second;
  }
  vector<string> electeds;
    for (decltype(stats)::iterator i = stats.begin(); i != stats.end(); i++) {
    if (i->second == max)
      electeds.push_back(i->first);
  }
  sort(electeds.begin(), electeds.end());
  for (auto i = electeds.begin(); i != electeds.end(); i++)
    cout << *i << endl;
}

Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int x = stoi(s.substr(0, 4)) * 10000 + stoi(s.substr(5, 2)) * 100 + stoi(s.substr(8, 2));
  cout << (x <= 20190430 ? "Heisei" : "TBD") << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    int a,b,c;
    cin>>str;
    if((str[2]==str[3])&&(str[4]==str[5]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#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++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

string S;
bool check[26];

int main(){
    cin>>S;
    rep(i,S.length()){
        int temp=S[i]-'a';
        if(check[temp]){
            out("no");
            return 0;
        }
        else{
            check[temp]=1;
        }
    }
    out("yes");
}


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

int main(){
  int N;
  std::string S;
  std::cin >> N >> S;
  if(N == 1 or N == 2){
    std::cout << 0 << std::endl;
    return 0;
  }
  long numR = 0;
  long numG = 0;
  long numB = 0;
  for(int i = 0; i < N; ++i){
    if(S[i] == 'R') ++numR;
    else if(S[i] == 'G') ++numG;
    else ++numB;
  }
  long counter = numR * numG * numB;
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j < N; ++j){
      int k = 2*j - i;
      if(k >= N) break;
      if(S[i] != S[j] and S[j] != S[k] and S[k] != S[i]){
        --counter;
      }
    }
  }
  std::cout << counter << std::endl;


  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int a[100],b[100],c[100];
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		sum+=b[i];
	}
	for(int i=1;i<n;i++)
		cin>>c[i];
	for(int i=1;i<n;i++)
	{
		if(a[i]+1==a[i+1])
			sum+=c[a[i]];
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		line = br.readLine();
		int n = parseInt(line.substring(0, line.indexOf(' ')));
		int t = parseInt(line.substring(line.indexOf(' ') + 1));

		List<String> stations = new ArrayList<String>();
		int[] opens = new int[n - 1];

		for (int i = 0; i < n; i++) {
			String[] tokens = br.readLine().split(" ");
			stations.add(tokens[3]);
			int arrive = minutes(tokens[2]);
			int leave = minutes(tokens[0]);
			if (i < n - 1) {
				opens[i] = arrive;
			}
			if (i > 0) {
				opens[i - 1] = leave - opens[i - 1];
			}
		}

		int c = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n - 1; i++) {
			if (opens[i] >= t) {
				c++;
				sb.append(stations.get(i) + " " + opens[i] + "\n");
			}
		}
		System.out.println(c);
		System.out.print(sb.toString());
	} //end main

	static int minutes(String time) {
		int h = parseInt(time.substring(0, time.indexOf(':')));
		int m = parseInt(time.substring(time.indexOf(':') + 1));
		return h * 60 + m;
	}
}

Measured memory_bytes: 17088
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int n;
	cin >> n;
	int ans = 0;
	Rep(i, n) {
		if (i < 10)ans++;
		elif(i>10&&i < 100 && 11 * (i / 10) > i&&i%10!=0) {
			ans += 2;
		}
		elif(i>10&&i < 100 && i % 11 == 0) {
			ans += 3;
		}
		elif(i > 100 && i < 1000 && i / 100 == i % 10) {
			ans += ((i%100)/10)*2+5;
		}
		elif(i > 100 && i < 1000&&i%10!=0) {
			ans += 2;
			if (i / 100 > i % 10) {
				ans += 20;
			}
		}
		elif(i > 1000 && i < 10000 && i / 1000 == i % 10) {
			ans += ((i % 1000) / 10) * 2 + 25;
		}
		elif(i > 1000 && i < 10000 && i % 10 != 0) {
			ans += 22;
			if (i / 1000 > i % 10) {
				ans += 200;
			}
		}
		elif(i > 10000 && i < 100000 && i / 10000 == i % 10) {
			ans += ((i % 10000) / 10) * 2 + 225;
		}
		elif(i > 10000 && i < 100000 && i % 10 != 0) {
			ans += 222;
			if (i / 10000 > i % 10) {
				ans += 2000;
			}
		}
		elif(i > 100000 && i < 1000000 && i / 100000 == i % 10) {
			ans += ((i%100000)/10)*2+2225;
		}
		elif(i > 100000 && i < 1000000 && i % 10 != 0) {
			ans += 2222;
			if (i / 100000 > i % 10) {
				ans += 20000;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
p = [int(_) for _ in input().split()]
ans = 0

for i in range(1, n-1):
    tmp = p[i]
    p3 = sorted([p[i-1], p[i], p[i+1]])
    if tmp == p3[1]:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
N,M=map(int,input().split())


A=list(map(int,input().split()))
Sum=sum(A)
pop=[]
l=Sum/(4*M)
for i in range(N):
    if(A[i]>=l):
        pop.append(A[i])
        
print("Yes" if len(pop)>=M else "No")

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

int dp[3010];
// kmjp参照
const int MOD = 998244353;

void modadd(int &a, int b){ 
  a = (a+b)%MOD;
}

signed main(void){
  
  int n,S; cin >> n >> S;
  
  int ans =0 ;
  
  for(int i = 0; i < n; i++){ 
    int x; cin >> x;
    for(int j = S-x; j >= 0; j--){ 
      if( j != 0 ){ 
        modadd(dp[j+x],dp[j]);
      }
      else{ 
        modadd(dp[x],i+1);
      }
    }
    
    modadd(ans,dp[S]);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>


typedef struct _xyz {
    int x;
    int y;
    int z;
} xyz;


typedef struct _node {
    std::vector<int> nbr; // zero-based numbering (node_arr[nbr]
} node;


int main(void)
{
    int n, m;
    scanf("%d%d", &n, &m);
    xyz *xyz_arr = (xyz *)std::malloc(sizeof(xyz) * m);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d%d", &xyz_arr[i].x, &xyz_arr[i].y, &xyz_arr[i].z);
    }

    node *node_arr = (node *)std::malloc(sizeof(node) * n);
    for (int i = 0; i < m; i++) {
        node_arr[xyz_arr[i].x - 1].nbr.push_back(xyz_arr[i].y - 1);
        node_arr[xyz_arr[i].y - 1].nbr.push_back(xyz_arr[i].x - 1);
    }

    int count;
    std::vector<bool> memo(n);
    count = 0;
    for (int i = 0; i < n; ++i) {
        if (!memo[i]) {
            /*
             * BFS
             */
            memo[i] = true;
            std::queue<int> q; // zero-based numbering
            q.push(i);
            while (!q.empty()) {
                int j = q.front();
                q.pop();
                for (auto itr = node_arr[j].nbr.begin(); itr != node_arr[j].nbr.end(); ++itr)  {
                    if (!memo[*itr]) {
                        memo[*itr] = true;
                        q.push(*itr);
                    } else {
                        continue;
                    }
                }
            }
            count++;
        } else if (node_arr[i].nbr.empty()) {
            count++;
        } else {
            continue;
        }
    }

    std::cout << count << std::endl;

    return EXIT_SUCCESS;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

inline bool check(ll coef, ll T, ll A, ll a, ll b) {
  return coef * T >= a && coef * A >= b;
}

ll bin(ll T, ll A, ll a,ll b) {
  ll L = 0, R = 100000000LL;
  while( L + 1LL < R ){
    ll coef = ( L + R ) / 2LL;
    if( check(coef,T,A,a,b) ) R = coef;
    else                      L = coef;
  }
  if( check(L,T,A,a,b) ) return L;
  else if( check((L+R)/2LL,T,A,a,b) ) return (L+R)/2LL;
  else return R;
}

int n;
ll T[1010], A[1010];
int main() {
  cin >> n;
  ll a = 1, b = 1;
  rep(i,n) {
    cin >> T[i] >> A[i];
    ll coef = 0;
    //while( !( coef * T[i] >= a && coef * A[i] >= b ) ) ++coef;
    //assert( bin(T[i],A[i],a,b) == coef );
    //coef = bin(T[i],A[i],a,b);
    ll v = a / T[i];
    if( a % T[i] ) ++v;
    ll w = b / A[i];
    if( b % A[i] ) ++ w;
    coef = max(v,w);
    a = coef * T[i];
    b = coef * A[i];
  }
  cout << a+b << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
def data_assignment():
    for i in range(r):
        for j, e in enumerate(map(int, input().split())):
            table[i][j] = e

def total_rows():
    for i, line in enumerate(table):
        table[i][c] = sum(line[:c])


def total_columns():
    for i, line in enumerate(table):
        if i == r:
            break
        for j, element in enumerate(line):
            table[r][j] += element


def table_print():
    for line in table:
        for i, element in enumerate(line):
            if i == c:
                print(element)
            else:
                print(element, end=' ')


r, c = map(int, input().split())
table = [[0 for i in range(c+1)] for j in range(r+1)]
data_assignment()
total_rows()
total_columns()
table_print()



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

int main(){
    int A, B, C, X;
    cin>>A>>B>>C>>X;
    int cnt=0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int n = 0; n <= C;n++){
                if(i*500+j*100+n*50 == X)cnt++;
            }
        }
    }
    cout << cnt << endl;   
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
x = [
    A.each_with_index.inject(0){|sum, (a, index)| sum + a * (-1) ** index},
    A.each_with_index.inject(0){|sum, (a, index)| sum + a * (-1) ** (index + 1)} + 2 * A[0]
]
for i in 2..N-1
    x << x[i-2] + 2 * (A[i-1] - A[i-2])
end
puts x.join(" ")

Measured memory_bytes: 15236
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
const int N=2e5+5;
const int M=1e8;
const ll Max=1e18+1000;
ll a[N];

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

Measured memory_bytes: 3620
#include<stdio.h>

#define INPUT_MAX_NUM (200000)

int main(void)
{
  //input num
  int num = 0;
  //  printf("input num\n");
  scanf("%d", &num);

  //input value
  int r[INPUT_MAX_NUM];
  for (int i = 0; i < num; i++ ) {
    scanf("%d", &r[i]);
  }

  //max value of diff
  /*
  int max_diff;
  max_diff = r[1] - r[0];
  for (int i = 1; i < num; i++ ) {
    for (int j = i; j < num; j++ ) {
      if ( max_diff < r[j] - r[i-1] ) {
        max_diff = r[j] - r[i-1];
      }
    }
  }
  */

  int max_diff = r[1] - r[0];
  int min = r[0];
  for (int i = 1; i < num; i++ ){
    if ( max_diff < r[i] - min ) {
      max_diff = r[i] - min;
    }
    if ( min > r[i] ) {
      min = r[i];
    }
  }
  //printf("max_diff = %d\n", max_diff);
  printf("%d\n", max_diff);

  return 0;
}

Measured memory_bytes: 1804
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  int i;
  for(i=0; i<n; i++) cin>>v[i];
  for(i=1; i<n; i++){
    if(v[i-1]>v[i]+1) break;
    if(v[i-1]<=v[i]) continue;
    v[i]+=1;
  }
  if(i==n) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// i番目の子供まででアメをj個配る
// dp[i+1][j+x] += dp[i][j]
int n, k, a[101], dp[101][100200];

signed main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i];
	dp[0][0] = 1, dp[0][1] = -1;
	rep(i,n) rep(j,100100) {
		(dp[i][j+1] += dp[i][j]) %= mod;
		(dp[i+1][j] += dp[i][j]) %= mod;
		(dp[i+1][min(j+a[i],k)+1] += mod - dp[i][j]) %= mod;
	}
	cout << accumulate(dp[n],dp[n]+k+1,0ll) %mod << endl;
}

Measured memory_bytes: 79360
import sys
import bisect

ss = input()
t = input()
n = len(ss)
cnt = {}
s = ss*2

for i, x in enumerate(s):
    if x not in cnt:
        cnt[x] = []
    cnt[x].append(i)

idx = 0
ten = 0
#print(cnt)
for z in t:
    if z not in ss:
        print(-1)
        sys.exit()

    idx = cnt[z][bisect.bisect_left(cnt[z], idx)] + 1

    if idx>=n:
        idx -= n
        ten += 1

    #print(idx, z, ten)

suffix = idx + ten * n

print(suffix)

Measured memory_bytes: 11892
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;cin>>N;
  
  if(N<1200){
    cout<<"ABC"<<endl;
  }
  else{
    cout<<"ARC"<<endl;
  }
}

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

using namespace std;

typedef long long ll;

int main () {
  int n;
  cin >> n;
  ll ans = 0;
  for (int a = 1; a <= n - 1; a++)
    ans += (n - 1) / a;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
int main(){
	int n,t[100001],time=0;
	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d", &t[i]);
		time+=t[i];
	}
	int m,p[101],x[100001];
	scanf("%d", &m);
	for(int j=1;j<=m;j++){
		scanf("%d%d", &p[j],&x[j]);
		printf("%d\n", time-t[p[j]]+x[j]);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
//long long temp[16]={10,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16}; 
int len;
int sum(char *x,int l,int b)
{
	int i;
	int sumx=0;
	for(i=b;i<l;i++) sumx+=(x[i]-'0');
	return sumx;
}
int main()
{
	char x[16];int sum0,sum1;
	int maxsum,i,begin;
	while(~scanf("%s",x))
	{
		len=strlen(x);begin=0;
		sum0=sum(x,len,begin);
		for(i=1;i<len;i++)
		x[i]='9';
		x[0]=x[0]-1;
		if(x[0]=='0') {begin=1;}
		sum1=sum(x,len,begin);
		maxsum=max(sum0,sum1);
		printf("%d\n",maxsum);
	}
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int a,b,x,y;
  cin >> a >> b;
  
  
  if ( b < 10 ){
    x = a * 10 + b;
  }else if ( b >= 10 && b < 100 ){
    x = a * 100 + b;
  }else{
    x = a * 1000 + b;
  }
  
  y = sqrt(x);
  
  if ( y * y == x ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define pi acos(-1)
using namespace std;
struct node
{
	int x,y;
}cc[200010];
int t;
double ans;
double x1,x2,y11,y2;
int len;
int arr[200010],g[200010];
int n;
bool cmp(node x,node y)
{
	return x.x<y.x;
}
//int erfen(int x)
//{
//	int l,r;
//	l=1,r=t;
//	while(l<r)
//	{
//		int mid=(l+r)>>1;
//		if(g[mid]<=arr[x]) r=mid-1;
//		else l=mid;
//	}
//	return l;
//}
//void work()
//{
//	for (int i=1;i<=t;i++)
//	{
//		arr[i]=cc[i].y;
//	}
//	if (y11>y2)
//	{
//		int mid=(y11+y2+1)/2;
//		for (int i=1;i<=t;i++)
//			arr[i]=mid-(arr[i]-mid);
//	}
//	g[1]=arr[1];  
//    len=1;  
//    for(int i=2;i<=t;++i)
//	{  
//        if(arr[i]>g[len])  
//            g[++len]=arr[i];  
//        else
//		{  
//            int pos=erfen(i);
//            g[pos]=arr[i];  
//        }   
//    }  
//    if (g[1]==0) len=0;
//}
template<class Cmp>  
int LIS (Cmp cmp)  
{  
    static int m, end[200010];  
    m = 0;  
    for (int i=1;i<=t;i++)
	{
		arr[i]=cc[i].y;
	}
	if (y11>y2)
	{
		int mid=(y11+y2+1)/2;
		for (int i=1;i<=t;i++)
			arr[i]=mid-(arr[i]-mid);
	}
    for (int i=1;i<=t;i++)  
    {  
        int pos = lower_bound(end, end+m, arr[i], cmp)-end;  
        end[pos] = arr[i], m += pos==m;  
    }  
    return m;  
}  
int main()
{
	int x,y;
	cin>>x1>>y11>>x2>>y2;

	if (x1>x2) swap(x1,x2),swap(y11,y2);
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		cin>>x>>y;
		if (x>=x1&&x<=x2)
		{
			if (y11>=y2)
			{
				if (y<=y11&&y>=y2) 
					cc[++t].x=x,cc[t].y=y;
			}
			else
			{
				if (y>=y11&&y<=y2) 
					cc[++t].x=x,cc[t].y=y;
			}
		}
	}
//	if (x1==x2) 
//	{
//		for (int i=1;i<=t;i++)
//		    if (cc[i].x==x1) ans=fabs(y2-y11)*100.0+(10*pi-20);
//		printf("%.15lf",ans);
//		return 0;
//	}
//	if (y11==y2) 
//	{
//		for (int i=1;i<=t;i++)
//		    if (cc[i].y==y11) ans=fabs(x2-x1)*100.0+(10*pi-20);
//		printf("%.15lf",ans);
//		return 0;
//	}
	sort(cc+1,cc+t+1,cmp);
//	work();
	int len=LIS(less<int>());
	int minn=min(fabs(x2-x1),fabs(y2-y11))+1;
	if (len==minn)    ans=fabs(x2-x1)*100.0+fabs(y2-y11)*100.0-(20-5*pi)*(len-1)+(10*pi-20);
	else ans=fabs(x2-x1)*100.0+fabs(y2-y11)*100.0-(20-5*pi)*len;
    printf("%.15lf",ans);
}

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

using namespace std;

typedef long long ll;

const int N(2e5 + 9);

int T, n, m, ans;

int main()
{
    cin>>n>>m;
    cout<<(n - 1) / (2 * m + 1) + 1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<queue>
using namespace std;
int n,m;
int main()
{
cin>>n>>m;
cout<<(n-1)*(m-1);
	return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;ll p=1000000007;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int x,y,z;cin>>x>>y>>z;
    if(x+y+z>=22)cout<<"bust";
    else cout<<"win";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    vector<int> A, B;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int b;
        cin >> b;
        B.push_back(b);
    }

    if (lexicographical_compare(A.begin(), A.end(), B.begin(), B.end()))
    {
        cout << '1' << endl;
    }
    else
    {
        cout << '0' << endl;
    }
}


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

using namespace std;

int main(){
  int a,b;
  char A,B;
  string C;

  cin >>a >>b ;
  vector< vector<char> > c(a,vector<char>(b));
  for(int i = 0 ; i < a; i++){
    for(int j = 0; j< b; j++){
      cin >> c[i][j];
    }
  }
  for(int i = 0; i< c.size() ;i++){
    int f = 0;
    for(int j = 0 ;j < c[0].size(); j++){
      if(c[i][j] == '#') f= 1;
    }
    if(f == 0){
      c.erase(c.begin() + i);
      i--;
    }
  }
  for(int j = 0; j< c[0].size() ;j++){
    int f = 0;
    int i;
    for(i = 0 ;i < c.size(); i++){
      if(c[i][j] == '#') f= 1;
    }
    if(f == 0){
      for(int k = 0 ; k < c.size(); k++){
        c[k].erase(c[k].begin()+j);
      }
      j--;
    }
  }
  for(int i = 0 ; i< c.size();i++){
    for(int j = 0 ; j< c[0].size(); j++){
      cout << c[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
        node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
        return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
        return;
      }
      if (node[x].rank < node[y].rank) {
        node[x].par = y;
      } else {
        node[y].par = x;
        if (node[x].rank == node[y].rank) {
          ++node[x].rank;
        }
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}

#define ll long long
#define gc getchar_unlocked
#define pc putchar_unlocked

int read_int() {
    char c = gc();
    while((c < '0' || c > '9') && c != '-') c = gc();
    int ret = 0, neg = 0;
    if (c == '-') neg = 1, c = gc();
    while(c >= '0' && c <= '9') {
        ret = 10 * ret + c - 48;
        c = gc();
    }
    return neg ? -ret : ret;
}

ll read_ll() {
    char c = gc();
    while((c < '0' || c > '9') && c != '-') c = gc();
    ll ret = 0;
    int neg = 0;
    if (c == '-') neg = 1, c = gc();
    while(c >= '0' && c <= '9') {
        ret = 10 * ret + c - 48;
        c = gc();
    }
    return neg ? -ret : ret;
}
  
int main(void) {
  int size = read_int();
  int n_query = read_int();
  int n_block = read_int();

  std::vector<uint64_t> query(n_query);
  std::vector<int> block(n_block);
  
  for (int i = 0;i < n_query; ++i) {
    query[i] = read_ll();
  }
  
  for (int i = 0;i < n_block; ++i) {
    block[i] = read_int();
  }
  
  const int mask = (1 << 30) - 1;

  uint64_t res = 123456789;
  for(int b: block) {
    procon::UnionFind uf(size);
    for (int i = 0; i < n_query; ++i) {
      uint64_t q = query[(b + i) % n_query];
      const int com = q >> 60;
      const int x = (q >> 30) & mask;
      const int y = (q >> 0) & mask;
      assert(0 <= x && x < size);
      assert(0 <= y && y < size);
      if (com) {
        res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
      } else {
        uf.unite(x, y);
      }
    }
  }
  printf("%llu\n", res);
  return 0;
}


Measured memory_bytes: 11528
#include <bits/stdc++.h>
using namespace std;
int main(void){
   vector<int>vec(5);
   vector<int>ans(5);
   int sum=0;
   int ma=0;
   for(int i=0;i<5;i++){
       cin>>vec[i];
       sum+=(vec[i]+9)/10*10;
       ans[i]=10-vec[i]%10;
       if(ans[i]==10)continue;
       else ma=max(ma,ans[i]);
   }
   cout<<sum-ma<<endl;
}

Measured memory_bytes: 256
def main():
  n=int(input())
  v=list(map(int,input().split()))
  w=sorted(v)

  ans=(w[0]+w[1])/2
  for i in range(2,n):
    ans=max(ans,ans/2+w[i]/2)
  print(ans)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 3060
#include <iostream>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};




double d, n, m;

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

  double k;

  if (d == 0) {
    k = 1 / n;
  } else {
    k = 2 * (n - d) / (n * n);
  }

  //cout << k << "\n";

  double ans = k * (m - 1);

  printf("%.10f\n", ans);
}

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

typedef long long ll;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<vector<ll>> graph(n);
    for(i = 0;i < n;++i){
        ll u,k,v;
        cin >> u >> k;
        --u;
        for(j = 0;j < k;++j){
            cin >> v;
            --v;
            graph.at(u).push_back(v);
        }
    }
    queue<ll> que;
    vector<ll> visit(n,false);
    que.push(0);
    visit.at(0) = true;
    vector<ll> ans(n,-1);
    ans.at(0) = 0;
    while(!que.empty()){
        ll s = que.front();
        que.pop();
        ll dis = ans.at(s);
        for(i = 0;i < graph.at(s).size();++i){
            ll g = graph.at(s).at(i);
            if(visit.at(g)){
                continue;
            }
            ans.at(g) = dis+1;
            visit.at(g) = true;
            que.push(g);
        }
    }
    for(i = 0;i < n;++i){
        cout << i+1  << " " << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func solve(n int, s []string) int {
	for i := 0; i < n; i++ {
		chars := strings.Split(s[i], "")
		sort.Strings(chars)
		s[i] = strings.Join(chars, "")
	}
	sort.Strings(s)

	ans := 0
	left := 0
	for left < n {
		right := left + 1
		for right < n {
			if s[left] != s[right] {
				break
			}
			right++
		}
		m := right - left
		ans += m * (m - 1) / 2
		left = right
	}

	return ans
}

func main() {
	n, _ := strconv.Atoi(input())
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = input()
	}
	fmt.Println(solve(n, s))
}


Measured memory_bytes: 7168