akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	fflush(stdout);
	return 0;
}

class C_data {
public:
	int id = 0;
	int cnt = 0;

	static bool asc_cnt(const C_data& a, const C_data& b) {
		return a.cnt < b.cnt;
	}
};

static void C_task()
{
	int N;
	get1int(N);

	std::vector<C_data> seq(N);
	for (int i = 0; i < N; i++) {
		int a;
		get1int(a);
		seq[i].id = i + 1;
		seq[i].cnt = a;
	}

	std::sort(seq.begin(), seq.end(), C_data::asc_cnt);

	for (int i = 0; i < N; i++) {
		printf("%d ", seq[i].id);
	}
	printf("\n");
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int x[1010], y[1010], r[1010];
int n;
double D[1010][1010];
double dis[1010];
int chk[1010];

void solve(){
	scanf("%d%d%d%d", x+1, y+1, x+2, y+2);
	scanf("%d", &n);
	for(int i=3;i<=n+2;i++)scanf("%d%d%d", x+i, y+i, r+i);
	n += 2;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ll L = (ll)(x[i] - x[j]) * (x[i] - x[j]) + (ll)(y[i] - y[j]) * (y[i] - y[j]);
			if(L <= (ll)(r[i] + r[j]) * (r[i] + r[j]))D[i][j] = 0;
			else D[i][j] = sqrt(L) - r[i] - r[j];
		}
	}
	for(int i=2;i<=n;i++)dis[i] = 1e14;
	for(int i=1;i<=n;i++){
		int mn = -1;
		for(int j=1;j<=n;j++)if(chk[j] == 0){
			if(mn == -1 || dis[mn] > dis[j])mn = j;
		}
		for(int j=1;j<=n;j++)if(chk[j] == 0){
			if(dis[mn] + D[mn][j] < dis[j])dis[j] = dis[mn] + D[mn][j];
		}
		chk[mn] = 1;
	}
	printf("%.12f", dis[2]);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll h,w;
    cin>>h>>w;
    vector<string> a(h);
    vector<bool> bx(w,0),by(h,0);
    for(ll i=0;i<h;i++){
        cin>>a[i];
        for(ll j=0;j<w;j++){
            if(a[i][j]=='#'){
                by[i]=1;
                bx[j]=1;
            }
        }
    }
    for(ll i=0;i<h;i++){
        if(by[i]){
            for(ll j=0;j<w;j++){
                if(bx[j]){
                    cout<<a[i][j];
                }
            }
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}




int main() {
  int n;
  cin >> n;
  vector<ll> A(n);
  ll a,now1=0,cnt1=0,now2=0,cnt2=0;
  rep(i,n) cin >> A[i];

  rep(i,n) {
    now1 += A[i];
    now2 += A[i];
    if (now1<=0) {
      cnt1+=abs(now1)+1;now1=1;
    }
    if (now2>=0) {
      cnt2+=abs(now2)+1;now2=-1;
    }
    swap(now1,now2);swap(cnt1,cnt2);
  }
  cout << min(cnt1,cnt2) << endl;
}

Measured memory_bytes: 1024
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	ll := make([]int, n)
	rr := make([]int, n)
	ll[0] = aa[0]
	rr[n-1] = aa[n-1]
	for i := 0; i < n-1; i++ {
		ll[i+1] = gcd(ll[i], aa[i+1])
	}

	for i := n - 1; i > 0; i-- {
		rr[i-1] = gcd(rr[i], aa[i-1])
	}
	var ans cint
	for i := 0; i < n; i++ {
		if i == 0 {
			ans.maxAs(cint(rr[1]))
			continue
		}
		if i == n-1 {
			ans.maxAs(cint(ll[n-2]))
			continue
		}
		ans.maxAs(cint(gcd(ll[i-1], rr[i+1])))
	}
	fmt.Fprintln(writer, ans)
}

func gcd(m, n int) int {
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}

type cint int64

func (ct *cint) minAs(x cint) *cint {
	*ct = ct.min(x)
	return ct
}
func (ct *cint) maxAs(x cint) *cint {
	*ct = ct.max(x)
	return ct
}
func (ct cint) min(x cint) cint {
	if ct > x {
		return x
	}
	return ct
}
func (ct cint) max(x cint) cint {
	if ct < x {
		return x
	}
	return ct
}


Measured memory_bytes: 6120
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  REP(i, k, n)
  {
    Yes(a[i] > a[i - k]);
  }
}

int main()
{
  init_main();
  solve();
}

Measured memory_bytes: 3984
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=t=j=0;d=[0]*h
 while w-j:
  i=c=0;j+=1
  while h-i:
   d[c]+=s[i][~j]>'0'
   if d[c]>k:d=[0]*h;f=t<j;r-=h*w*~-f-1;t=j;j-=f;break
   c+=b>>i&1;i+=1
 m+=r+c,
print(min(m))

Measured memory_bytes: 42332
n = int(input())
x = set()
cnt = 1
x.add(n)

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Measured memory_bytes: 2940
input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
h = input[2].to_i
m = input[3].to_i

hour = h / 12.0 + ((m / 60.0) / 12.0)
minute = m / 60.0
diff = (hour - minute).abs
diff = 1 - diff if diff > 1 - diff
angle = diff * 360

puts Math.sqrt(a ** 2 + b ** 2 - 2 * (a * b * Math.cos(angle * Math::PI/180)))

Measured memory_bytes: 14752
// bfs atcoder088-d

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> g(h);
  int black = 0;

  for (int i = 0; i < h; i++) {
    cin >> g[i];
    for (int j = 0; j < w; j++) {
      black += g[i][j] == '#';  //塗りつぶされているところをカウント
    }
  }

  queue<pair<int, int>> q;
  q.emplace(0, 0);

  vector<vector<int>> dist(h, vector<int>(w, -1));  //二次元ベクターを定義
  dist[0][0] = 0;

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

  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int k = 0; k < 4; k++) {
      int yy = y + dy[k];
      int xx = x + dx[k];
      if (yy < 0 || xx < 0 || yy >= h || xx >= w) continue;  //はみ出た場合
      if (g[yy][xx] == '#') continue;    //塗りつぶされている場合
      if (dist[yy][xx] != -1) continue;  //訪問済みの場合
      dist[yy][xx] = dist[y][x] + 1;     //初期位置からの移動距離
      q.emplace(yy, xx);
    }
  }

  if (dist[h - 1][w - 1] == -1) {
    cout << -1 << endl;
  } else {
    cout << (h * w) - dist[h - 1][w - 1] - black - 1 << endl;
  }
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 100010;
const int MAXM = 50;

int c[MAXM], t[MAXN], a[MAXN];
long long b[MAXN];

int main ()
{
    int n, k;
    scanf ("%d%d", &n, &k);
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%d%lld", &a[i], &b[i]);
    }
    int cnt = 0;
    while (k)
    {
        cnt ++;
        c[cnt] = k % 2;
        k >>= 1;
    }
    if (!cnt)
    {
        cnt ++;
        c[cnt] = 0;
    }
    long long ans = 0;
    for (int i = cnt; i >= 1; i --)
    {
        t[i] = c[i];
    }
    long long tmp = 0;
    for (int j = 1; j <= n; j ++)
    {
        if (a[j] < (1 << cnt))
        {
            bool flag = true;
            for (int k = cnt; k >= 1; k --)
            {
                if ((t[k] == 0) && (a[j] & (1 << (k - 1))))
                {
                    flag = false;
                }
            }
            if (flag)
            {
                tmp += b[j];
            }
        }
    }
    if (tmp > ans)
    {
        ans = tmp;
    }
    for (int i = 1; i <= cnt; i ++)
    {
        if (c[i] == 1)
        {
            t[i] = 0;
            long long tmp = 0;
            for (int j = 1; j <= n; j ++)
            {
                if (a[j] < (1 << cnt))
                {
                    bool flag = true;
                    for (int k = cnt; k >= i; k --)
                    {
                        if ((t[k] == 0) && (a[j] & (1 << (k - 1))))
                        {
                            flag = false;
                        }
                    }
                    if (flag)
                    {
                        tmp += b[j];
                    }
                }
            }
            if (tmp > ans)
            {
                ans = tmp;
            }
            t[i] = 1;
        }
    }
    printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1408
N,K=map(int,input().split())

alist=[]
slist=[0]
for i in range(N):
  a=int(input())
  alist.append(a)
  slist.append(slist[-1]+a)
#print(alist)
#print(slist)

splist=[]
for i in range(N+1):
  splist.append(slist[i]-i*K)
#print(splist)

#compress splist to spdic
sp_asc=sorted(list(set(splist)))
#print(sp_asc)
cnt=1
spdic={}
for sp in sp_asc:
  spdic[sp]=cnt
  cnt+=1
#print(spdic)
  
#A1～Aiまでの和 O(logN)
def BIT_query(idx):
  res_sum = 0
  while idx > 0:
    res_sum += BIT[idx]
    idx -= idx&(-idx)
  return res_sum
#Ai += x O(logN)
def BIT_update(idx,x,n):
  while idx <= n:
    BIT[idx] += x
    idx += idx&(-idx)
  return

answer=0
BIT=[0]*(len(spdic)+1)
for i in range(N+1):
  idx=spdic[splist[i]]
  answer+=BIT_query(idx)
  BIT_update(idx,1,len(spdic))
  #print(i,answer)
  
print(answer)

Measured memory_bytes: 111320
N = int(input())
profit = [list(map(int, input().split())) for i in range(N)]
#dp[i][p] をi日目にｐをしたときのi日目までの最大値
#dpを初期化
dp = [[0 for j in range(3)] for i in range(N)]
for p in range(3):
    dp[0][p] = profit[0][p]

#dpの更新
for i in range(1,N):
    for p in range(3):
        dp[i][p] = max(dp[i-1][p-1],dp[i-1][p-2]) + profit[i][p]
print(max(dp[-1]))

Measured memory_bytes: 47384
#include <bits/stdc++.h>
#define ll long long
#define PRIME 1000000007
#define PI 3.14159265358979323846;
using namespace std;
int combinatorics(int n, int r)
{
	if(n<r)return 0;if(n<0)return 0;
	if(r==0)
		return 1;
	return n*combinatorics(n-1,r-1)/r;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int sx, sy,  tx,  ty;
	cin>>sx>>sy>>tx>>ty;
	for(int i=1;i<=(tx-sx);i++)
	{
		cout<<"R";
	}
	for(int i=1;i<=(ty-sy);i++)
	{
		cout<<"U";
	}
	for(int i=1;i<=(tx-sx);i++)
	{
		cout<<"L";
	}
	for(int i=1;i<=(ty-sy);i++)
	{
		cout<<"D";
	}
	cout<<"L";
	for(int i=1;i<=(ty-sy+1);i++)
	{
		cout<<"U";
	}
	for(int i=1;i<=(tx-sx+1);i++)
	{
		cout<<"R";
	}
	cout<<"DR";
	for(int i=1;i<=(ty-sy+1);i++)
	{
		cout<<"D";
	}
	for(int i=1;i<=(tx-sx+1);i++)
	{
		cout<<"L";
	}
	cout<<"U";
}	

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

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

int main(){
    ll N,Y;
    cin >> N >> Y;
    int ans = 0;
    for(int i = 0; i <= N; i++){
        for(int j =0; j <= N-i; j++){
            int z = N - i - j;
//             if(z >= 0 && z <= N){
            int mo = 10000*i + 5000*j + 1000*z;
            
            if(Y == mo){
                cout << i << " "<< j << " " << z << endl;
                return 0;
//             }
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}



Measured memory_bytes: 256
def collecting_balls(N: int, K: int, X: list)->int:
    dist = 0
    for x in X:
        if x < K - x:
            # ボールはロボット A よりなので
            # A を動かす
            dist += 2 * x
        else:
            # ボールはロボット B よりなので
            # B を動かす
            dist += 2 * (K-x)
    return dist


if __name__ == "__main__":
    N = int(input())
    K = int(input())
    X = [int(s) for s in input().split()]
    ans = collecting_balls(N, K, X)
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a;
	string s;
	cin>>a>>s;
	if(a<3200)
	{
		cout<<"red";
	}
	else
	{
		cout<<s;
	}	
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        PriorityQueue<Task> queue = new PriorityQueue<>(new Comparator<Task>() {
            @Override
            public int compare(Task o1, Task o2) {
                return Integer.compare(o1.b, o2.b);
            }
        });

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            queue.add(new Task(a, b));
        }

        boolean isFinish = true;
        int time = 0;
        while (!queue.isEmpty()){
            Task task = queue.poll();
            time += task.a;
            if (time > task.b) {
                isFinish = false;
                break;
            }
        }

        System.out.println(isFinish ? "Yes" : "No");
    }

    static class Task {
        int a, b;

        Task(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

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

using namespace std;
using namespace __gnu_pbds;

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

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

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;

    int n=s.length();
    int ans=n;
    s="2"+s;
    for(int i=1;i<s.length()-1;i++){
        if(s[i]!=s[i+1]){
            int t=max(i,n-i);
            ans=min(ans,t);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	}
}

class Process {

	public Process(String name,int time) {
		this.name = name;
		this.time = time;
	}

	public String name;
	public int time;
}

Measured memory_bytes: 61760
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	sort.Ints(a)
	med := (a[len(a)-1] + 1) / 2
	mind, ans := int(1e9)+1, a[0]
	// fmt.Println("n", n, "a", a, "med", med)
	for i := 1; i < len(a); i++ {
		if mind > abs(a[i]-med) && a[len(a)-1] > a[i] {
			mind = abs(a[i] - med)
			ans = a[i]
		}
	}
	fmt.Println(a[len(a)-1], ans)
}
func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}


Measured memory_bytes: 3072
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    ans = 1
    for i in range(1, N+1):
      ans *= i
      ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62948
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct EdgeD
{
	int to;
	ll cost;
};

void calcShortestD(vector<vector<EdgeD>>& G, int s, int maxV, vector<ll>& d)
{
	for (auto i = 0; i < maxV; ++i)
	{
		d.push_back(LLONG_MAX);
	}
	d[s] = 0;

	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
	q.push({ 0, s });

	while (!q.empty())
	{
		auto p = q.top();
		q.pop();
		auto v = p.second;
		if (d[v] < p.first)
		{
			continue;
		}

		for (auto& e : G[v])
		{
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				q.push({ d[e.to], e.to });
			}
		}
	}
}



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

	vector<vector<EdgeD>> G(N);
	for (auto i = 0; i < N - 1; ++i)
	{
		int a, b;
		ll c;
		cin >> a >> b >> c;
		--a;
		--b;
		G[a].push_back({ b, c });
		G[b].push_back({ a, c });
	}

	int Q, K;
	cin >> Q >> K;
	--K;

	vector<ll> d;
	calcShortestD(G, K, N, d);

	vector<ll> ans;
	for (auto i = 0; i < Q; ++i)
	{
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		ans.push_back(d[x] + d[y]);
	}

	for (auto i = 0; i < Q; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 11632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
ll a[200005],b[200005],s[600005],dp[200005];
ll rohan(ll ss,ll se,ll l,ll r,ll si)
{
    if(ss>se || ss>r || se<l)return 0;
    if(ss>=l && se<=r)return s[si];
    ll mid=(ss+se)/2;
    return max(rohan(ss,mid,l,r,2*si),rohan(mid+1,se,l,r,2*si+1));
}
void update(ll ss,ll se,ll x,ll y,ll si)
{
    if(ss>se)return;
    if(ss==se && ss==x){s[si]=y;return;}
    ll mid=(ss+se)/2;
    if(mid>=x)
    update(ss,mid,x,y,2*si);
    else
    update(mid+1,se,x,y,2*si+1);
    s[si]=max(s[2*si+1],s[2*si]);
}
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=1;i<=n;i++)cin>>b[i];
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        dp[a[i]]=rohan(1,n,1,a[i]-1,1)+b[i];
        update(1,n,a[i],dp[a[i]],1);
    }
    for(i=1;i<=n;i++)ans=max(ans,dp[i]);
    cout<<ans;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<math.h>
int main(void){
    double r,S,L;
    scanf("%lf",&r);
    S = r*r * M_PI;
    L = 2*r * M_PI;
    printf("%9.6f %9.6f\n",S,L);
    return 0;
}


Measured memory_bytes: 2104
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// // 整数の入力
		// int a = sc.nextInt();
		// // スペース区切りの整数の入力
		// int b = sc.nextInt();
		// int c = sc.nextInt();
		// // 文字列の入力
		// String s = sc.next();
		// // 出力
    // System.out.println((a+b+c) + " " + s);
    int N = sc.nextInt();
    int A = sc.nextInt();
    System.out.println(N % 500 <= A ? "Yes" : "No");
	}
}

Measured memory_bytes: 21972
import numpy as np

def test():
    D = 1e18
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return 0
    s = 1
    for i in A:
        s *= i
        if s > D:
            print(-1)
            return 0
    print(s)
    return 0

if __name__ == "__main__":
    test()


Measured memory_bytes: 39868
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int m;
inline int read(){
	int u=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){u=u*10+c-'0';c=getchar();}
	return u*f;
}

struct node{
	int l,r,bo;
}p[maxn];
int ans,n;
bool cmpl(node x,node y){
	return (x.l==y.l?x.r>y.r:x.l<y.l);
}
bool cmpr(node x,node y){
	return x.r>y.r;
}
int l=0,r=0;
int main(){
	n=read();m=read();
	for(int i=1;i<=n;i++)p[i].l=read(),p[i].r=read();
	sort(p+1,p+n+1,cmpl);l=1;r=m;
	for(int i=1;i<=n;i++){
		if(l>m)break;
		if(l<=p[i].l){
			l++;
			p[i].bo=1;
			ans++;
		}
	}
	sort(p+1,p+n+1,cmpr);
	for(int i=1;i<=n;i++){
		if(r<l)break;
		if(r>=p[i].r&&!p[i].bo){
			ans++;r--;
			p[i].bo=1;
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
fun main(args:Array<String>) {
//    val mod = 1000000007L
    val mod = 2019
    var (L, R) = readLine()!!.split(" ").map(String::toLong)

    if (L/mod != R/mod) {
        println(0)
        return
    }
    L %= mod
    R %= mod

    var min = mod

    for (l in L until R) {
        for (r in l + 1..R) {
            min = Math.min(((l*r)%mod).toInt(), min)
        }
    }
    println(min)
}

Measured memory_bytes: 37744
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {

    int N;
    cin >> N;
    
    int cnt = 0; 
    int a_cnt = 0; 
    int b_cnt = 0; 
    int ab_cnt = 0; 
    for(int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s[0] == 'B' && !(s[s.size()-1] == 'A')) b_cnt ++;
        if (!(s[0] == 'B') && s[s.size()-1] == 'A') a_cnt ++;
        if (s[0] == 'B' && s[s.size()-1] == 'A') ab_cnt ++;
        for(int j = 0; j < s.size()-1; j++) {
            if (s[j] == 'A' && s[j+1] == 'B') cnt++;
        }
    }

    int ans = cnt;
    if (ab_cnt == 0)
        ans += min(a_cnt, b_cnt);
    else
        if (a_cnt + b_cnt > 0)
            ans += ab_cnt + min(a_cnt, b_cnt);
    
    if (a_cnt + b_cnt == 0)
        ans += max(0, ab_cnt - 1);

    // cout << cnt << a_cnt << b_cnt << endl;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin >> s;
  int a = 0,b = 0,c = 0;
  for(int i = 0; i < 3; i++){
	if(s[i] == 'a')
  		a++;
    if(s[i] == 'b')
      b++;
    if(s[i] == 'c')
      c++;
  }
  if(a == 1 && b == 1 && c == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  


Measured memory_bytes: 256
// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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, chars) => { read_value!($next, String).chars().collect::<Vec<char>>()
           };

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        c: [(i64, [usize; m]); n],
    }

    let mut result = Vec::new();
    result.push((0, vec![0; m]));

    for (val_i, exp_i) in c {
        let mut result_temp = Vec::new();
        for (val, exp) in result {
            let mut exp_temp = exp.clone();
            for i in 0..exp_temp.len() {
                exp_temp[i] += exp_i[i];
            }

            result_temp.push((val + val_i, exp_temp));

            result_temp.push((val, exp));
        }
        result = result_temp;
    }

    let mut min_value = i64::max_value();
    for (v, exp) in result {
        if (exp.iter().all(|&e| e >= x)) && (min_value > v) {
            min_value = v;
        }
    }
    if min_value == i64::max_value() {
        min_value = -1;
    }

    println!("{}", min_value);
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

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

    vector<int> ans(N, 0);
    if (N > 1) ans[0] = 1;
    bool flag = true;
    rep (i, M) {
        int s, c;
        cin >> s >> c;
        s--;

        if (N > 1 && s == 0) {
            if (ans[s] != 1 && ans[s] != c) {
                flag = false;
                break;
            }
        }
        else {
            if (ans[s] != 0 && ans[s] != c) {
            flag = false;
            break;
        }
        }

        if (N > 1 && s == 0 && c == 0) {
            flag = false;
            break;
        }

        ans[s] = c;
    }

    if (flag) {
        rep(i, N) {
            cout << ans[i];
        }
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,0,N) cin >> a[i];
    map<int,int> mpl,mpr;
    vector<int> ans;

    for(int l = 0; l < N; l++){
        int r = (N - 1) - l;
        if(mpr.find(a[l]) != mpr.end()){
            if(mpr[a[l]] == 1) mpr.erase(a[l]);
            else mpr[a[l]]--;
        }else{
            mpl[a[l]]++;
        }
        if(mpl.find(a[r]) != mpl.end() ) {
            if(mpl[a[r]] == 1) mpl.erase(a[r]);
            else mpl[a[r]]--;
        }else{
            mpr[a[r]]++;
        }
        if(mpr.empty() && mpl.empty()){
//            cout << l + 1 << " ";
            ans.push_back(l+1);
        }

    }
    rep(i,0,ans.size()){
        cout << ans[i];
        if(i != ans.size() - 1){
            cout << " ";
        }else{
            cout << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 4072
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    string s = to_string(b);
    a = a*pow(10,s.length())+b;
    int c = floor(sqrt(a));
    if (a == c*c) PRINT("Yes");
    else PRINT("No");
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			if (N == 0) break;
			int[] P = new int[N];
			for (int i = 0; i < N; ++i) {
				P[i] = sc.nextInt();
			}
			int[] t = new int[N * (N + 1) / 2 + N + 1];
			int pos = 0;
			for (int i = 0; i < N; ++i) {
				for (int j = i; j < N; ++j) {
					t[pos++] = P[i] + P[j];
				}
			}
			for (int i = 0; i < N; ++i) {
				t[pos++] = P[i];
			}
			Arrays.sort(t);
			int ans = 0;
			int r = t.length - 1;
			for (int i = 0; i <= r; ++i) {
				while (r >= 0 && t[i] + t[r] > M) {
					--r;
				}
				if (r >= 0) ans = Math.max(ans, t[i] + t[r]);
			}
			System.out.println(ans);
		}
	}
}

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

int dfs(int a){
  if( a == 1 ){ return 1;}
  
  return 2*dfs(a/2)+1;
  
}

signed main(void){
  int H; cin >> H;
  
  cout << dfs(H) << endl;
  
  return 0;
}

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

#define ntest 0

using namespace std;
int n, m, res, u ,v;
vector<int> g[201000];
int visited[201000];
void dfs(int u, int &cnt) {
    visited[u] = 1;
    ++cnt;
    for (auto &v : g[u])
        if(!visited[v]) dfs(v, cnt);
}
void solve() {
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    res = 1;
    for (int i = 1; i <= n; ++i) {
        if (!visited[i]) {
            int cnt = 0;
            dfs(i, cnt);
            res = max(res, cnt);
        }
    }
    cout << res << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 24624
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	sort( A.begin(), A.end() );
	int pos = 0;
	int ans = 0;
	while(pos<N){
		int res = upper_bound(A.begin(), A.end(), A[pos]) -A.begin();
		ans += (res-pos)&1;
		pos = res;
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 640
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var hh= ToIntArray(input.ReadLine(), n);

        var max = 0;
        var c = 0;

        for(int i=0; i<n; i++) {
            var h = hh[i];
            if (h >= max) c++;
            max = Math.Max(h, max);
        }

        return c;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll modpow(long long a, long long n, long long mod2) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod2;
        a = a * a % mod2;
        n >>= 1;
    }
    return res;
}

int main() {
    int ans = 1000000;
    string s;
    cin >> s;
    for (int i = 0; i < s.size()-2; ++i) {
        string tmp;
        tmp += s[i];
        tmp += s[i+1];
        tmp += s[i+2];
        int t = atoi(tmp.c_str());
        ans = min(ans,abs(753-t));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    int add = A + B;
    int sub = A - B;
    int mul = A * B;

    System.out.println(Math.max(add, Math.max(sub, mul)));
  }
}


Measured memory_bytes: 23636
//
//  main.cpp
//  B - FizzBuzz Sum
//
//  Created by Hashizo on 2020/04/12.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	unsigned long long ans = 0;
	
	ll n;
	cin >> n;
	
	FOR(i, 1, n+1) {
		if ((i % 3) == 0 || (i % 5) == 0) {
			continue;
		}
		else {
			ans += i;
		}
	}

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


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(l)))
	ans := 0
	for i := 0; i < k; i++ {
		ans += l[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
num = int(input());

mylist_1=[];
mylist_2=[];
mylist_3=[];
mylist_4=[];
mylist_5=[];
mylist_6=[];
mylist_7=[];
mylist_8=[];
mylist_9=[];
mylist_10=[];

for i in range(num):
  s = input();
  if len(s) == 1:
    mylist_1.append(s);
  elif len(s) == 2:
    mylist_2.append(s);
  elif len(s) == 3:
    mylist_3.append(s);
  elif len(s) == 4:
    mylist_4.append(s);
  elif len(s) == 5:
    mylist_5.append(s);
  elif len(s) == 6:
    mylist_6.append(s);
  elif len(s) == 7:
    mylist_7.append(s);
  elif len(s) == 8:
    mylist_8.append(s);
  elif len(s) == 9:
    mylist_9.append(s);
  elif len(s) == 10:
    mylist_10.append(s);
    

m1 = len(list(set(mylist_1)));
m2 = len(list(set(mylist_2)));
m3 = len(list(set(mylist_3)));
m4 = len(list(set(mylist_4)));  
m5 = len(list(set(mylist_5)));
m6 = len(list(set(mylist_6)));
m7 = len(list(set(mylist_7)));
m8 = len(list(set(mylist_8)));
m9 = len(list(set(mylist_9)));
m10 = len(list(set(mylist_10)));

m = m1 + m2 + m3 + m4 + m5 + m6 + m7 + m8 + m9 + m10;
print(m);


Measured memory_bytes: 36044
#include <iostream>

using namespace std;

int main(void) {
    int n;
    cin >> n;
    long a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    long min, max, sum;
    min = max = sum = a[0];
    
    for (int i = 1; i < n; ++i) {
        if (a[i] < min)
            min = a[i];
        if (a[i] > max)
            max = a[i];
        sum += a[i];
    }
    cout << min << ' ' << max << ' ' << sum << '\n';
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long pos = 0;
  for(int i=0;i<=X;i++){
    pos += i;
    if( pos >= X ){
      cout << i << endl;
      return 0;
    }
  }  
}

Measured memory_bytes: 3604
# ABC 136 E
import math

N, K = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)

P = [1,S]
for k in range(2,math.floor(math.sqrt(S))+1):
    if S % k == 0:
        P.append(k)
        P.append(S//k)
P = sorted(P)[::-1]

for e in P:
    t = []
    u = []
    for a in A:
        if a%e != 0:
            t.append(a%e)
            u.append(e-a%e)
    t = sorted(t)
    if len(t) == 0:
        print(e)
        exit(0)
    else:
        p = [f for f in t]
        for k in range(1,len(t)):
            p[k] += p[k-1]
        m = [e-f for f in t]
        for k in range(1,len(t)):
            m[-k-1] += m[-k]
        for k in range(len(t)-1):
            if p[k] == m[k+1] and p[k] <= K:
                print(e)
                exit(0)


Measured memory_bytes: 3188
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	let
		a = read $ take 2 s
		b = read $ drop 2 s
		ym = solve b
		my = solve a
	putStrLn $ if
		| ym && my -> "AMBIGUOUS"
		| ym && not my -> "YYMM"
		| not ym && my -> "MMYY"
		| otherwise -> "NA"

solve m = 1 <= m && m <= 12

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#define inf -2147483647
using namespace std;
struct info
{
    int l,r,d;
}s[400005];
int n,m;
int flag = 1;
int dis[100005],visited[100005];
int first[400005],nexti[400005];
void dfs(int t)
{
    if(!flag)return;
    int k = first[t];
    while(k != -1)
    {
        if(!flag)return;
        if(!visited[s[k].r])
        {
            dis[s[k].r] = dis[s[k].l] + s[k].d;
            visited[s[k].r] = 1;
            dfs(s[k].r);
        }
        else if(s[k].d != dis[s[k].r] - dis[s[k].l])
        {
            flag = 0;
            return;
        }
        k = nexti[k];
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 0;i < m;i ++)
    {
        scanf("%d%d%d",&s[i].l,&s[i].r,&s[i].d);
        nexti[i] = first[s[i].l];
        first[s[i].l] = i;
        s[i + m].r = s[i].l;
        s[i + m].l = s[i].r;
        s[i + m].d = -s[i].d;
        nexti[i + m] = first[s[i + m].l];
        first[s[i + m].l] = i + m;
    }
    for(int i = 1;i <= n;i ++)
    {
        if(!visited[i])
        {
            visited[i] = 1;
            memset(dis,0,sizeof(int) * (n + 1));
            dfs(i);
        }
    }
    if(flag)printf("Yes");
    else printf("No");
}


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

int main(){
  int H,W,K;cin>>H>>W>>K;
  vector<string> c(H);
  rep(i,H)cin>>c[i];
  int ans=0;

  for(int i=0; i<(1<<H); i++){
    for(int j=0; j<(1<<W); j++){
      
      int cnt = 0;
      for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
          if(i&(1<<h) || j&(1<<w))continue;
          if(c[h][w]=='#')cnt++;
        }
      }

      if(cnt==K)ans++;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3640
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    sc.nextLine()
    val heights = sc.nextLine.split(" ").map(_.toInt)
    println((1 to heights.max).map {
      h => heights.map(i => if (h <= i) 1 else 0).mkString.split("0").filterNot(_ == "").length
    }.sum)
  }
}


Measured memory_bytes: 27976