akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
while n > 1
  cnt = 0
  min = a[0]
  flg = false
  1.upto(n-1) do |i|
    flg = true if a[i] != a[i] % min
    a[i] = a[i] % min
    if a[i] == 0
      cnt += 1
    end
  end
  n = n - cnt
  a = a.sort[cnt..-1]
  if !flg
    break
  end
end
puts a[0]

Measured memory_bytes: 25416
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
#include<utility>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc105_b(){
    //入力
    int r;
    cin >> r;

    //処理

    //出力
    if(r<1200) cout << "ABC" << enter;
    else if(r<2800) cout << "ARC" << enter;
    else cout << "AGC" << enter;
    return 0;
}

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


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let abc: Vec<(usize, usize, i64)> = (0..m)
        .map(|_| {
            let a = input();
            let b = input();
            let c = input();
            (a, b, c)
        })
        .collect();

    let mut cost = vec![vec![i32::max_value() as i64; n + 1]; n + 1];
    for i in 1..n + 1 {
        cost[i][i] = 0;
    }
    for i in 0..m {
        let (a, b, c) = abc[i];
        cost[a][b] = c;
        cost[b][a] = c;
    }

    for k in 1..n + 1 {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                cost[i][j] = std::cmp::min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    let mut ans = 0;
    for i in 0..m {
        let (a, b, c) = abc[i];
        if cost[a][b] < c {
            ans += 1;
        }
    }

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


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

using namespace std;

long long int n, m, k, dau = 1, cuoi = -1, giua, a[200005];

bool Check(long long int m)
{
    long long int number = 0;
    for(long long int i = 1; i <= n; ++i)
    {
        number += a[i]/m;
        if(a[i] % m == 0)
            number--;
    }
    if(number <= k)
        return true;
    else
        return false;
}

long long int TKNP(long long int a[],long long int n,long long int k)
{
    while(dau <= cuoi)
    {
        giua = (dau + cuoi)/2;
        if(Check(giua) == true)
        {
            m = giua;
            cuoi = giua - 1;
        }
        else
            dau = giua + 1;
    }
    return m;
}

int main()
{
  //  freopen("Bao.inp","r", stdin);
    cin >> n >> k;
    for(long long int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        cuoi = max(a[i], cuoi);
    }
    cout << TKNP(a,n,k);
    return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;


void solve() {

    int n, W;
    cin >> n >> W;
    ll wt[n], val[n];
    for (int i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
    }

    ll dp[n + 1][W + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= W; j++) {
            if (j - wt[i-1] >= 0) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wt[i-1]] + val[i-1]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[n][W] << endl;


}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 82412
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
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 B_task();

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

static void B_task()
{
	int N;
	get1int(N);
	
	double inv = 0.0;
	int a;
	for (int i = 0; i < N; i++) {
		get1int(a);
		inv += 1.0 / (double)a;
	}

	printf("%.6lf", (1.0 / inv));
}


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

int main(void){
  char c[3][3];
  char s[3] = {'\0'};
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
      cin >> c[i][j];
  for(int i = 0; i < 3; i++)
    s[i] += c[i][i];
  printf("%s\n", s);
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)

typedef long long ll;
const int maxn=1e5+5;

int main()
{
    ll k;
    scanf("%lld",&k);
    int n=50;
    cout << n << endl;
    ll res=k%50;
    ll x=k/50-1;
    ll cnt=res;
    for(ll i=1;i<=50;i++)
    {
        if(cnt>0)
        {
            printf("%lld ",i+50-res+1+x );
            cnt--;
        }
        else
            printf("%lld ",i-res+x);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int n, r;
    
    cin >> n >> r;

    int i;
    for (i = 0; n > 0; n/=r, i++)
        ;
    cout << i << endl;

    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
program caddi2018d
  implicit none
  integer n
  integer, dimension(:), allocatable :: a

  read *, n
  allocate(a(n))
  read *, a
  if (minval(trailz(a)).eq.0) then
     print '(a)', 'first'
  else
     print '(a)', 'second'
  end if
end program caddi2018d


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << 0 << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int Roundup(int a,int b){
    return (a+b-1)/b;
}


signed main(void){
    int A,B;
    cin >> A >> B;
    A--;B--;
    cout << Roundup(B,A) << endl;
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            Console.WriteLine(48 - NextInt());
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL D, T, S;
	cin >> D >> T >> S;

	if(S*T >= D){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;

}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
 
long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}

bool check(int diff, int time) {
  return diff >= 0 || rand() >= (-diff) * (clock()-time) * 1.4;
}

int main() {
  int n;
  cin >> n;
  vector<int> c(26), last(26, -1);
  vector<array<int, 26>> s(n);
  
  for (int i = 0; i < 26; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1), max_score(-1e9);
    for (int j = 0; j < 26; ++j) neg -= c[j] * (i - last[j]);
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  
  // stochastic
  time_t time = clock();
  while ((clock()-time)<=1.9*CLOCKS_PER_SEC) {
    if (rand() & 1) {
      int dd(rand() % n), ot(options[dd]), tt;
      do { tt = rand() % 26; } while (ot == tt);
      
      options[dd] = tt;
      long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                          options, dd, tt, ot);
      
      if (check(ns,time)) {
        total += ns;
      } else {
        options[dd] = ot;
      }
    } else {
      continue;
      int dd1 = rand() % n;
      int ot1 = options[dd1];
      int dd2, ot2;
      do { dd2 = rand() % n; ot2 = options[dd2]; } while (ot1 == ot2);
      
      options[dd1] = ot2;
      long long ns1 = calc(n, c[ot2], c[ot1], s[dd1][ot2], s[dd1][ot1],
                          options, dd1, ot2, ot1);
      options[dd2] = ot1;
      long long ns2 = calc(n, c[ot1], c[ot2], s[dd2][ot1], s[dd2][ot2],
                          options, dd2, ot1, ot2);
      
      if (check(ns1+ns2,time)) {
        total += ns1 + ns2;
      } else {
        options[dd1] = ot1;
        options[dd2] = ot2;
      }
    }
  }
  
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    deque<int> a = {};
    REP(i,n){
        int t;
        cin >> t;
        if(t==0){
            int d,x;
            cin >> d >> x;
            if(d==0){
                a.push_front(x);
            }
            else{
                a.push_back(x);
            }
        }
        else if(t == 1){
            int x;
            cin >> x;
            print(a[x]);
        }
        else{
            int d;
            cin >> d;
            if(d==0){
                a.pop_front();
            }
            else{
                a.pop_back();
            }
        }
    }


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 6248
#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 <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
bool IsOK(ll len){
        map<string,ll> m;
        rep(i,0,N){
            if(m[S.substr(i,len)]==0){
                m[S.substr(i,len)]=i+len;
            }else{
                if(i>=m[S.substr(i,len)]){
                    return true;
                }
            }
        }
        return false;
}
int main(){
    cin>>N;
    rep(i,1,10)rep(j,1,10){
        if(i*j == N){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main() {

    int inf=1e8;
    int maxi=10001;
    int dp[maxi];
    for(int i=0; i<maxi; i++){
        dp[i] = inf;
    }
    dp[0]=0;

    int h,n; 
    cin >> h >> n;

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

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

    for(int i=0; i<n; i++){
        a = v[i].first;
        b = v[i].second;

        for(int i=a; i<maxi; i++){
            dp[i]=min(dp[i], dp[i-a]+b);
        }
    }

    int ans = dp[h];
    for(int i=h; i<maxi; i++){
        ans=min(dp[i], ans);
    }
    
    cout << ans;



/*    
    vector<pair<int, int>> vc;
    int x;
    cin >> x;
    int s=x;
    while(x--){
        int a,b;
        cin >> a >> b;
        vc.push_back(pair<int, int>(a,b));
    }
    pair<int,int> p = vc[s-1];
    cout << p.first << ' ' << p.second << endl;
*/
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,a,b=MI()
ans=(n//(a+b))*a+min(n%(a+b),a)
print(ans)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
  int N;
  int ans = 0;
  int max = 0;
  cin >> N;
  int a[2][N];
  for(int j = 0; j < 2; j++){
    for(int i = 0; N > i; i++){
      cin >> a[j][i];
    }
  }
  for(int k = 0; k < N; k++){
    for(int i = 0; i <= k; i++){
      ans += a[0][i];
    }
    for(int j = k; j < N; j++){
      ans += a[1][j];
    }
    if(max < ans){
      max = ans;
    }
    ans = 0;
  }
  cout << max << '\n';
  return 0;
}

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

//define ll long long;
//define ar array;

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

    long long n;
    cin >> n;
    if (n%1000 == 0){
        cout << 0 << endl;
    }
    else {
        cout << 1000 - n%1000 << endl;
    }


    return 0;
}



Measured memory_bytes: 3648
// @uthor........ _|EE|_

#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define u_set unordered_set<int>
#define pb push_back
#define M 1000000007
#define endl "\n"
#define BRISK ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

signed main()
{
    BRISK;
    int x,y,z;
    cin>>x>>y>>z;
    int t = x;
    x = y;
    y = t;
    t = x;
    x = z;
    z = t;
    cout<<x<<" "<<y<<" "<<z; 
}


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

using namespace std;

int main(int argc, char* argv[])
{

	int N,K;
	string str;

	cin >> N >> K;
	cin >> str;

	for(int i=0;i<str.length();i++){
		if (i == K-1) {
			cout << (char)(str[i] + 0x20);
		}else{
			cout << str[i];
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = sc.nextInt();
		for(int x = 0; x <= n; x++) {
			for(int y = 0 ; x+y <= n ; y++) {
				int z=n-x-y;
				if((10000*x + 5000*y +1000*z)==sum) {
					StringBuilder sb = new StringBuilder();
					sb.append(x);
					sb.append(" ");
					sb.append(y);
					sb.append(" ");
					sb.append(z);
					System.out.println(sb.toString());
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");

	}
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); sc.next();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = Integer.parseInt(sc.next());
		int[] b = new int[n]; Arrays.fill(b, 0);
		int[] c = new int[n]; Arrays.fill(c, 0);
		int min = -1;
		int count = 0; int max = 0; int dis = 0; int ans = 0;
		for (int i = n-1; i >= 0; i--) {
			if(max < a[i]) {
				count = 1;
				max = a[i];
			}else if(max == a[i]){
				count++;
			}else {
				b[i] = max;
				c[i] = count;
				dis = Math.max(max-a[i], dis);
			}
		}
		for (int i = 0; i < n; i++) {
			if(min == -1) {
				if(b[i]-a[i] == dis) {
					min = b[i];
					ans += c[i];
				}
			}else {
				if((b[i]-a[i]==dis)&&(min != b[i])) {
					min = b[i];
					ans += c[i];
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int a, b; cin >> a >> b;
  string s; cin >> s;

  for(int i=0; i<s.size(); ++i) {
    if(i == a) {
      if(s.at(i) != '-') drop("No");
    } else {
      if(s.at(i) == '-') drop("No");
    }
  }
  cout << "Yes" << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
// const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

const int mod = 998244353;

vector<int> cnt(3010);
int a[3010];

int main () {

    int n,s;cin>>n>>s;

    rep(i,n) cin>>a[i];

    ll ans=0;


    rep(i,n) {
        cnt[0]++;
        vector<int> cnt_n(3010);
        rep(j,s+1) {
            cnt_n[j]=(cnt_n[j]+cnt[j])%mod;
            if (j+a[i]<=s) {
                cnt_n[j+a[i]]=(cnt_n[j+a[i]]+cnt[j])%mod;
            }
        }
        cnt=cnt_n;
        ans=(ans+cnt[s])%mod;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <string>
using namespace std;


class CombinationGenerator {
  int MAX_N_;
  int MOD_;
  long long* fac;
  long long* finv;
  long long* inv;

  public:
  CombinationGenerator(int MAX_N, int MOD) {
    MAX_N_ = MAX_N; MOD_ = MOD;
    fac = new long long[MAX_N];
    finv = new long long[MAX_N];
    inv = new long long[MAX_N];
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }
  ~CombinationGenerator() {
    delete[] fac;
    delete[] finv;
    delete[] inv;
  }
  long long get(long long n, long long r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD_) % MOD_;
  }
};

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  const int MOD = 1000000007;
  const int M = 26;

  int K;
  cin >> K;
  assert(K >= 1);

  string S;
  cin >> S;
  const int N = S.size();
  assert(N >= 1);

  CombinationGenerator c(K+N, MOD);

  long long ans = 0;
  for (int i = K + N; i >= N; i--) {
    ans = (ans + (c.get(i-1, N-1) * modpow(M-1, i - N, MOD) % MOD) * modpow(M, K+N-i, MOD) % MOD) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51156
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_N = 3e5 + 10;
char S[max_N];
int pref[max_N], suff[max_N];

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

    cin >> (S + 1);

    for (int i = 2; i <= N; ++i) {
        pref[i] = pref[i - 1] + (S[i - 1] == 'W');
    }

    for (int i = N - 1; i >= 1; --i) {
        suff[i] = suff[i + 1] + (S[i + 1] == 'E');
    }

    int ans = N + 1;
    for (int i = 1; i <= N; ++i) {
        ans = min(ans, pref[i] + suff[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
namespace Program
{
    class Test1
    {
        static void Main()
        {
            int count = 1;
            string a = Console.ReadLine();
            int N = int.Parse(a);
            string[] bb = new string[N];
            for (int i=0;i<N;i++ )
            {
                bb[i] = Console.ReadLine();
            }
            int[] bbb = bb.Select(int.Parse).ToArray();
            Array.Sort(bbb);
            List<int> aaa = new List<int>(bbb);
            aaa.RemoveAt(0);
            aaa.Add(bbb[0]);
            for (int i=1;i<bbb.Length;i++)
            {
                if (bbb[i - 1] < bbb[i])
                {
                    aaa.RemoveAt(0);
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;
import java.util.function.LongSupplier;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	};
	public static void main(String[] __){
		int n,p;
		while((n=s.nextInt())+(p=s.nextInt())!=0){
			int pl[]=new int[n],st=p,i=0;
			while(pl[i]!=p){
				if(st>0) {
					st--;
					pl[i]++;
				}else {
					st=pl[i];
					pl[i]=0;
				}
				i=(i+1)%n;
			}
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 26640
/* -------------------------------------------------

Author :- Vaibhav Pal
College :- Northern India Engineering College, New Delhi
Coding Handle :- underdog_eagle
Title :-

----------------------------------------------------*/
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000         
#define nl '\n'
#define sp ' '
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define bg begin()
#define en end()
#define fo(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)

inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
inline ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main()
{
	FAST_IO
    /*#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
    #endif*/

	string str;
	cin >> str;
	int cnt = (str[0] == '1') + (str[1] == '1') + (str[2] == '1');
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using ll=long long;
const ll maxn=1e3+1;
const ll mod=1e9+7;
ll H,W,dp[maxn][maxn];
int main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)
	for(int j=0;j<W;j++)
	{
		char c;cin>>c;
		if(c=='#')dp[i][j]=-1;
	}
	for(int j=W-1;j>=0;j--)
	for(int i=H-1;i>=0;i--)
	{
		if(dp[i][j]==-1)continue;
		if(i==H-1&&j==W-1)dp[i][j]=1;
		else if(j==W-1)dp[i][j]=((dp[i+1][j]==-1?0:dp[i+1][j]))%mod;
		else if(i==H-1)dp[i][j]=((dp[i][j+1]==-1)?0:dp[i][j+1])%mod;
		else dp[i][j]=(((dp[i+1][j]==-1)?0:dp[i+1][j])+((dp[i][j+1]==-1)?0:dp[i][j+1]))%mod;
	}
	cout<<dp[0][0]<<endl;
	return 0;
}

Measured memory_bytes: 8064
import Control.Monad

main = do
    [h, w] <- map read . words <$> getLine
    as <- replicateM h getLine :: IO [String]
    putStrLn $ concat $ replicate (w + 2) "#"
    mapM_ putStrLn $ map (\x -> "#" ++ x ++"#") as
    putStrLn $ concat $ replicate (w + 2) "#"

Measured memory_bytes: 1404
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		double n = sc.nextInt();
		double d = sc.nextInt() * 2 + 1;
		sc.close();
		double ans = Math.ceil(n/d);
		System.out.println((int)ans);
	}
}


Measured memory_bytes: 35576
#include <cstdio>
#include <algorithm>
typedef long long ll;
inline ll rd(){
    ll x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=100002,S=100000;
const ll mod=1e9+7;
int n,k;
ll a[N],ans;
ll fac[N],inv[N];
inline ll fpow(ll b,ll p=mod-2){
	ll ans=1,tmp=b;
	while(p){
		if(p&1)ans=ans*tmp%mod;
		tmp=tmp*tmp%mod;
		p>>=1;
	}
	return ans;
}
inline ll C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=rd(),k=rd();
	for(int i=1;i<=n;i++)a[i]=rd();
	std::sort(a+1,a+n+1);
	fac[0]=1;
	for(int i=1;i<=S;i++)fac[i]=fac[i-1]*i%mod;
	inv[S]=fpow(fac[S]);
	for(int i=S-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=1;i<=n;i++){
		if(i-1>=k-1)ans+=a[i]*C(i-1,k-1),ans%=mod;
		if(n-i>=k-1)ans-=a[i]*C(n-i,k-1),(ans+=mod)%=mod;
	}
	printf("%lld\n",ans);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string r;
    string l;

    int cnt_r = 0;
    int cnt_l = 0;
    for (int i = 0; i<n; i++){
        if (s.at(i)=='('){
            cnt_l += 1;
        }
        else if (s.at(i)==')' and cnt_l!=0){
            cnt_l -= 1;
        }
        else if (s.at(i)==')' and cnt_l==0){
            cnt_r += 1;
        }
    }

    for (int i = 0; i<cnt_r; i++){
        l.push_back('(');
    }
    for (int i = 0; i<cnt_l; i++){
        r.push_back(')');
    }
    cout << l + s + r << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N=100 ;
ll a[N],b[N],c[N],d[N];
ll n,h;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>h;
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        c[i]=a[i];
        d[i]=b[i];
    }
    sort(c,c+n);
    sort(d,d+n);
    ll area=3999999999000000001;
    //cout<<area<<endl;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=0;k<n;k++)
            {
                for(int l=k+1;l<n;l++)
                {
                    int cnt=0;
                    for(int q=0;q<n;q++)
                    {
                        if(a[q]<=c[j]&&a[q]>=c[i]&&b[q]>=d[k]&&b[q]<=d[l])
                            cnt++;
                    }
                    if(cnt>=h)
                        area=min(area,(c[j]-c[i])*(d[l]-d[k]));
                }
            }
        }
    }
    cout<<area<<endl;
    return 0;

}


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

const int N = 100010;
const int ONE_BILLION = 1000000000;

int tree[N];

int main() {
	int n, k;
	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; ++i) {
		scanf("%d", tree + i);
	}

	sort(tree, tree + n);

	deque<int> dq;
	int optimal = ONE_BILLION;

	for (int i = 0; i < n; ++i) {
		dq.push_back(tree[i]);
		if (dq.size() > k) {
			dq.pop_front();
		}
		if (dq.size() == k) {
        	if (dq.back() - dq.front() < optimal) {
				optimal = dq.back() - dq.front();
			}
        }
	}

	printf("%d\n", optimal);
}

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

const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int cnt = 0, min_v = INF;
  rep(i, n) {
    min_v = min(min_v, p[i]);
    if (min_v == p[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100010
 
int main(){
    int Tc,N,K,x[MAX],a[MAX];
    cin >> Tc;
    while(Tc--){
	cin >> N >> K;
	for(int i = 0 ; i < N ; i++){
	    cin >> x[i];
	}
	for(int i = 1 ; i < N ; i++){
	    a[i-1] = x[i]-x[i-1];
	}
	sort(a,a+N-1);
	int res = 0;
	for(int i = 0 ; i < N-K ; i++){
	    res += a[i];
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

constexpr Int mod = 998244353;
vector<Int> fact, ifact, comb;
Int inv(Int n){
    Int p = mod - 2;
    Int t = n;
    Int res = 1;
    for(;p>0; p>>=1){
        if(p & 1) res = res * t % mod;
        t = t * t % mod;
    }
    return res;
}

int main(){
    Int n, a, b, k; cin >> n >> a >> b >> k;
    fact.resize(n+1);
    fact[0] = 1;
    for(Int i=1; i<=n; ++i) fact[i] = i * fact[i-1] % mod;
    ifact.resize(n+1);
    for(Int i=1; i<=n; ++i) ifact[i] = inv(fact[i]);
//    for(Int i=1; i<=n; ++i) cout << i << " " << ifact[i] << "\n";
    comb.resize(n+1);
    comb[0] = 1;
    for(Int i=1; i<=n-1; ++i) comb[i] = fact[n] * ifact[i] % mod * ifact[n-i] % mod;
//    for(Int i=1; i<=n-1; ++i) cout << i << " " << comb[i] << "\n";
    comb[n] = 1;
    Int ans = 0;
    for(Int i=0; i<=n; ++i){
        if(k - i*a >= 0 && (k - i*a) % b == 0){
            Int j = (k - i*a) / b;
            if(j > n) continue;
            ans = (ans + comb[i] * comb[j] % mod) % mod;
//            cout << i << " " << j << " " << ans << "\n";
        }
    }
    cout << ans << "\n";
//    cout << inv(1) << " " << inv(2) << " " << inv(998244352) << "\n";
}

Measured memory_bytes: 7296
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main()
{
  int n;
  string input;

  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    queue<bool> base;
    int out = 0, pt = 0;
    while (out < 3){
      cin >> input;
      if (input == "HIT"){
        base.push(true);
        if (base.size() == 4){
          pt += base.front();
          base.pop();
        }
      }
      else if (input == "HOMERUN"){
        pt += base.size() + 1;
        while (!base.empty()){
          base.pop();
        }
      }
      else if (input == "OUT"){
        out++;
      }
    }
    printf("%d\n", pt);
  }

  return (0);
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int main(){
	
	ll inf=1e9+5;
	ll n; cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	vector<ll> dp(n,inf);
	dp[0]=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<i+3;j++){
		if(j<n) dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		if(j<n) dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}

	cout<<dp[n-1];
cout<<"\n";
return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 100 + 3, inf = 1e9 + 10;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	string s;cin>>s;
	if(s[0]!=s[1] or s[1]!=s[2])cout<<"Yes\n";
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int R = 1e9 + 7; 

int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) break;
        ll dp[n + 1];
        dp[0] = 1, dp[1] = 2, dp[2] = 4;
        for (int i = 3; i < n; i++) {
            dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
        } 
        ll ans = (364 + ((dp[n - 1] + 9) / 10)) / 365;
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
  int x1,y1,x2,y2,dx,dy;
  cin >> x1 >> y1 >> x2 >> y2;

  dx=x2-x1;
  dy=y2-y1;

  cout << x2-dy << " " << y2+dx << " " << x1-dy << " " << y1+dx << endl;
}

Measured memory_bytes: 384
s = gets.chomp
s += "<"
sum = 0
prev_dir = s[0]
run = 0
prev_run = 0
for i in 0...s.length do
  if s[i] == prev_dir
    run += 1
  else
    if s[i] == "<"
      if prev_run < run
        sum += (prev_run - 1) * prev_run / 2
        sum += run * (run + 1) / 2
      else
        sum += prev_run * (prev_run + 1) / 2
        sum += (run - 1) * run / 2
      end
    end
    prev_run = run
    run = 1
  end
#  puts "#{prev_run} #{run} #{prev_dir} #{s[i]} #{sum}"
  prev_dir = s[i]
end
sum += (run - 1) * run / 2
puts sum


Measured memory_bytes: 3340
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int n;
    cin >> n;
    Vec<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long int count = v[0] - 1;
    long long int min_num = 2;

    //cout << "I = 0" << ", " << count << endl;
    for (int i = 1; i < n; i++) {
        if (v[i] == min_num) {
            min_num++;
            continue;
        } else if (v[i] < min_num) {
            continue;
        } else {
            count += (v[i] / min_num);
            if (v[i] % min_num == 0) {
                count--;
            }
        }
        //cout << "I = " << i << ", " << count << endl;
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 640
n, m = gets.chomp.split.map(&:to_i)

a = []
n.times do
  a << gets.chomp.split.map(&:to_i)
end

b = []
m.times do
  b << gets.to_i
end

a.each do |_a|
  puts _a.zip(b).map{ |f, s| f * s }.inject(:+)
end

Measured memory_bytes: 8932
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    rep (i, n - 2) {
        if (s.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    string s;
    cin>>s;
    int ans=0;
    int st=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A'){
            st=i;
            break;
        }
    }
    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='Z'){
            ans=i-st;
            break;
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 640
<?php
/*
    Problem URL : http://abc047.contest.atcoder.jp/tasks/abc047_b
    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d %d", $W, $H, $N);
$E_END = $W;
$W_END = 0;
$N_END = $H;
$S_END = 0;


for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d %d", $x, $y, $a);
    switch ($a) {
        case "1":
            $W_END = max($W_END, $x);
            break;
        case "2":
            $E_END = min($E_END, $x);
            break;
        case "3":
            $S_END = max($S_END, $y);
            break;
        case "4":
            $N_END = min($N_END, $y);
            break;
    }
}

// echo "{$W_END} {$E_END}\n";
// echo "{$S_END} {$N_END}\n";

if ($W_END > $E_END) { 
    echo "0\n";
} elseif ($S_END > $N_END) {
    echo "0\n";
} else {
    echo ($W_END - $E_END) * ($S_END - $N_END) . PHP_EOL;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int sum = 0;
  for (int i = 0; i < A + 1; ++i) {
    for (int j = 0; j < B + 1; ++j) {
      for (int k = 0; k < C + 1; ++k) {
        if (X == (i * 500 + j * 100 + k * 50)) {
          ++sum;
        }
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
char s[100050];
int fail;
int maxlen;
const char tp[4][10]={"eraser ","erase ","dreamer ","dream "};
const int len[4]={6,5,7,5};
bool dfs(int pos)
{
	if(pos==maxlen) return 1;
	for(int i=3;i>=0;i--)
	{
		bool flag=1;
		for(int j=0;tp[i][j]!=' ';j++)
			if(pos+j>=maxlen || tp[i][j]!=s[pos+j])
			{flag=0;break;}
		if(flag)
		{
			if(dfs(pos+len[i])) return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%s",s);
	maxlen=strlen(s);
	bool ans=dfs(0);
	if(ans) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
 
int main(void){
    double R;
 
    cin >> R;
 
    cout << (R*2)*M_PI << endl;
 
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;
typedef unsigned long long ull;

int main(void) {
	ull n;
	cin >> n;
	for (ull i = sqrt(n); i >= 1; --i) {
		if (n % i == 0) {
			cout << i + n / i - 2;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.math, std.algorithm, std.range;

// indexから始めるstringのstartIndexを返す
ulong calculateIndex( ulong index ) {
  index--;
  ulong sum = 0;
  ulong sumNumDiv3 = 0;
  ulong sumNumDiv5 = 0;
  ulong sumNumDiv15 = 0;
  ulong digit = 1;
  while ( 10 ^^ digit < index ) {
	immutable ulong ulim = ( 10 ^^ digit ) - 1;
	immutable ulong numDiv3 = ulim / 3 - sumNumDiv3;
	immutable ulong numDiv5 = ulim / 5 - sumNumDiv5;
	immutable ulong numDiv15 = ulim / 15 - sumNumDiv15;
	immutable ulong rest = ulim - ( 10 ^^ ( digit - 1 ) - 1 ) - numDiv3 - numDiv5 + numDiv15;
	sum += ( numDiv3 + numDiv5 ) * 4 + rest * digit;
	sumNumDiv3 += numDiv3;
	sumNumDiv5 += numDiv5;
	sumNumDiv15 += numDiv15;
	digit++;
  }
  immutable ulong numDiv3 = index / 3 - sumNumDiv3;
  immutable ulong numDiv5 = index / 5 - sumNumDiv5;
  immutable ulong numDiv15 = index / 15 - sumNumDiv15;
  immutable ulong rest = index - ( 10 ^^ ( digit - 1 ) - 1 ) - numDiv3 - numDiv5 + numDiv15;
  sum += ( numDiv3 + numDiv5 ) * 4 + rest * digit;
  return sum + 1;
}

ulong binarySearch( immutable ulong n ) {
  ulong left = 0;
  ulong right = 10UL ^^ 18;
  while ( right > left + 1 ) {
	immutable ulong middle = ( left + right ) / 2;
	immutable ulong val = calculateIndex( middle );
	if ( val < n ) {
	  left = middle;
	} else if ( val > n ) {
	  right = middle;
	} else {
	  return middle;
	}
  }
  if ( calculateIndex( left + 1 ) <= n ) {
	left++;
  }
  return left;
}

ulong calculateDigit( ulong n ) {
  return convert( n ).length;
}

string convert( ulong n ) {
  if ( n % 15 == 0 ) return "FizzBuzz";
  else if ( n % 3 == 0 ) return "Fizz";
  else if ( n % 5 == 0 ) return "Buzz";
  else return to!string( n );
}

void main()
{
  immutable ulong n = to!ulong( strip( readln ) );
  solve( n );
}

void solve( ulong n ) {
  ulong index = binarySearch( n );
  ulong startIndex = n - calculateIndex( index );
  ulong sum = calculateDigit( index ) - startIndex;
  write( convert( index )[ startIndex .. $ ] );
  index++;
  
  while ( sum < 20UL ) {
	ulong endIndex = min( calculateDigit( index ), 20UL - sum );
	write( convert( index )[ 0 .. endIndex ] );
	index++;
	sum += endIndex;
  }
  writeln();
}

Measured memory_bytes: 1056