akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

k = INT()
a, b = MAP()
for i in range(a, b + 1):
    if i % k == 0:
        print('OK')
        exit()
print('NG')

Measured memory_bytes: 68376
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (a, b, t) => {
  // ...
  return Math.floor(t / a) * b
}
const main = (input) => {
  const [a, b, t] = input.split(" ")
  return solve(a, b, t)
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

if (process.env.NODE_ENV === "test") {
  // module.exports = (input) => solve(input.trim())
  // main(``)
  // solve(1, [2, 3, 4])
}


Measured memory_bytes: 9420
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));
$cnt=0;
for($j=1;$j<=$N;$j=$j+2) {
  $res=0;
  for($i=1;$i<=$j;$i++) {
    if (($j % $i)==0)
      $res++;
  }
  if ($res==8) $cnt++;
}
printf("%d\n",$cnt);


Measured memory_bytes: 3828
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n,k=map(int,input().split())
v1=list(map(int,input().split()))
v2=v1[::-1]
r=min(n,k)
ans=0
for i in range(r+1):
    for j in range(i+1):
        tmp=v1[:j]+v2[:i-j]
        tmp.sort()
        for l in range(min(k-i,i)):
            if tmp[l]<0:
                tmp[l]=0
        ans=max(ans,sum(tmp))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
string S;
int main() {
    cin >> S;
    if(S=="ABC") {
        cout << "ARC" << endl;
    }else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

static long long sum(long long min, long long max) {
	return (min + max) * (max - min + 1) / 2;
}

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

	long long ans = 0;
	long long min, max;

	for (int i = K; i <= N + 1; i++) {
		min = sum(0, i - 1);
		max = sum(N - i + 1, N);
		ans += (max - min + 1);
		ans %= 1000000007;
	}

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


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9+7;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int dp[101000];  // 自分の番にi個の石の状態で回ってきた場合、勝ち(1)か負け(0)かまだわからないか(-1)

int main(){
    int N, K;
    int a[100];
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    for(int i = 0; i <= K; i++){
        dp[i] = -1;
    }

    dp[0] = 0;
    for(int i = 1; i <= K; i++){
        bool canWin = false;
        for(int j = 0; j < N; j++){
            if(i < a[j]){
                break;
            }
            if(dp[i-a[j]] == 0){
                canWin = true;
            }
        }
        if(canWin){
            dp[i] = 1;
        }
        else{
            dp[i] = 0;
        }
    }

    if(dp[K] == 1){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }








    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

/*
void dfs1(int n, mat &G, vec &level){
    int k(0);
    stack<int> sta;
    rep(i, n) {
        if(level[i] != -1) continue;
        level[i] = -2;
        sta.push(i);
        while (!sta.empty()) {
            int v = sta.top(); sta.pop();
            if (v < 0) {
                level[- v - 1] = k++;
            } else {
                sta.push(- v - 1);
                for (int to : G[v]) {
                    if (level[to] == -1) {
                        level[to] = -2;
                        sta.push(to);
                    }
                }
            }
        }
    }
}
 */

void dfs1(int v, int &k, mat &G, vec &level){
    level[v] = -2;
    for(int to : G[v]){
        if(level[to] == -1) dfs1(to, k, G, level);
    }
    level[v] = k++;
}

void dfs2(int n, mat &G, vector<bool> &used, vec &ord, mat &res){
    stack<int> sta;
    Rrep(i, n){
        int s = ord[i];
        if(!used[s]){
            used[s] = true;
            vec temp(0);
            sta.push(s);
            while(!sta.empty()){
                int v = sta.top(); sta.pop();
                temp.push_back(v);
                for(int to : G[v]) {
                    if(!used[to]) {
                        used[to] = true;
                        sta.push(to);
                    }
                }
            }
            res.push_back(temp);
        }
    }
}
/*
void dfs2(int v, mat &G, vector<bool> &used, vec &res){
    used[v] = true;
    res.push_back(v);
    for(int to : G[v]) if(!used[to]) dfs2(to, G, used, res);
}
 */

void scc(mat &G, mat &res){
    int n = G.size();
    mat G_rev(n, vec(0));
    rep(u, n) rep(v, (int)G[u].size()) G_rev[G[u][v]].push_back(u);
    vec level(n, -1), ord(n);
    vector<bool> used(n, false);
    //dfs1(n, G, level);
    int k(0);
    rep(i, n) if(level[i] == -1) dfs1(i, k, G, level);
    rep(i, n) ord[level[i]] = i;
    dfs2(n, G_rev, used, ord, res);
    /*
    Rrep(i, n) {
        if(!used[ord[i]]) {
            vec temp(0);
            dfs2(ord[i], G_rev, used, temp);
            res.push_back(temp);
        }
    }
     */
}

int main() {
    cin>>N>>M;
    mat G(N, vec(0));
    rep(i,M){
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
    }
    mat scc_list(0);
    scc(G, scc_list);
    printf("%d\n", (int)scc_list.size());
    for(vec v : scc_list){
        int n = v.size();
        printf("%d ", n);
        rep(i, n) printf("%lld%c", v[i], " \n"[i == n - 1]);
    }
}


Measured memory_bytes: 83168
#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;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> s(m);
	vector<char> c(m);
	rep(i, m) cin >> s[i] >> c[i];
	for (int i = 0; i <= 999; ++i) {
		string tmp = to_string(i);
		if (tmp.size() != n) continue;
		bool elf = true;
		rep(j, m) {
			if (tmp[s[j] - 1] != c[j]) elf = false;
		}
		if (elf) {
			cout << tmp << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
open Batteries
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
let s = read_line()|>explode
let t = read_line()|>explode
let rec loop lst lst2 result =
  match (lst, lst2) with
  | ([],[]) -> result
  | (first :: rest, first2 :: rest2) -> if first = first2 then loop rest rest2 (result) else loop rest rest2 (result+1)
  | _ -> result
let _ = Printf.printf "%d\n" @@ loop s t 0

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

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int) (x).size())
#define ALL(x) x.begin(), x.end()
#define debug(x) cerr << #x" = " << x << endl

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef unsigned long long u64;
typedef vector<int> VI;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
template <typename T> void read(T & x) {
	int f = 1; char ch; x = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x *= f;
}

const int N = 201234;

int n, p[N], q[N], f[N], g[N];

int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(p[i]), q[p[i]] = i, f[i] = 1;
	for (int i = 1; i <= n; i++)
		if(q[p[i] - 1] < i)
			f[i] = f[q[p[i] - 1]] + 1;
	cout << n - *max_element(f + 1, f + n + 1) << endl;
	return 0;
}





Measured memory_bytes: 2688
#include <stdio.h>
int main() {
	int a[5],i,j;
	for(i=0;i<5;i++) scanf("%d",&a[i]);
	for(i=0;i<4;i++)
		for(j=i+1;j<5;j++)
			if (a[i]<a[j]) { int t=a[i]; a[i]=a[j]; a[j]=t;	}	
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>

int main(void)
{
    int s, f, b;

    scanf("%d", &s);

    f = s / 100; b = s % 100;

    if ((f > 12 || f == 0) && (b > 12 || b == 0)) {
        printf("NA");
    } else if ((f > 12 || f == 0) && b <= 12 ) {
        printf("YYMM");
    } else if (f <= 12 && (b > 12 || b == 0)) {
        printf("MMYY");
    } else {
        printf("AMBIGUOUS");
    }

    return 0;
}


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

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

int main(){

	int n, h, max = 0, cont = 0;
	scanf("%d", &n);
	while (n--){
		scanf("%d ", &h);
		if (h >= max){
			max = h;
			cont ++;
		}
	}
	printf("%d\n", cont);
	return 0;
}

Measured memory_bytes: 3824
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n,a,b = map(int,input().split())
s = input()
cnt = 0
cnt_b = 0
for i in range(len(s)):
    if s[i] == "c":
        print("No")
    elif s[i] == "a":
        if cnt < a + b:
            print("Yes")
            cnt += 1
        else:
            print("No")
    else:
        if cnt < a + b and cnt_b<b:
            print("Yes")
            cnt += 1
            cnt_b += 1
        else:
            print("No")


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

int main()
{
	ll N, P, Q, res = -INF, tmp = 0;
	cin >> N >> P >> Q;
	vector<ll> C(N), add(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		tmp += C[i];
	}
	for (int i = 0; i < N; i++) {
		add[i] = Q * P - C[i] - i * P;
	}
	sort(add.begin(), add.end());
	res = max(res, tmp);
	for (int i = 0; i < N; i++) {
		tmp += add[N - 1 - i] + P * i * 2;
		res = max(res, tmp);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10724
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Skip
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var input = GetArrayIntInput();
                int x = input[1];
                var xs = new List<int>(Console.ReadLine().Split().Select(int.Parse)) { x }.ToList();
                xs.Sort();
                var list = new List<int>();
                for (int i = 0; i < xs.Count - 1; i++)
                {
                    list.Add(xs[i + 1] - xs[i]);
                }

                for (int i = 0; i < list.Count - 1; i++)
                {
                    int gcd = GCD(list[i], list[i + 1]);
                    list[i + 1] = gcd;
                }
                CWrite(list[list.Count - 1]);
            }
        }

        static int GCD(int x, int y)
        {
            if (y > x)
            {
                int tmp = x;
                x = y;
                y = tmp;
            }
            int mod = x % y;
            while (mod != 0)
            {
                x = y;
                y = mod;
                mod = x % y;
            }
            return y;
        }
        static string[] GetArrayCharInput() => Console.ReadLine().Split();
        static int[] GetArrayIntInput() => Console.ReadLine().StringToIntArray();
        static int GetIntInput() => Console.ReadLine().ToInt();
        static void CWrite<T>(T str) => Console.WriteLine(str);

    }

    class SetConsole : IDisposable
    {
        StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static int[] StringToIntArray(this string str) =>
            str.Split().Select(int.Parse).ToArray();
        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 22752
str = gets.chomp
q = gets.chomp.to_i
for i in 1..q do
  input = gets.chomp.split(" ")
  case input[0]
  when "print" then
    a,b = input[1].to_i, input[2].to_i
    printf("%s\n",str[a,b-a+1])
  when "reverse" then
    a,b = input[1].to_i, input[2].to_i
    str = str[0,a] + str[a,b-a+1].reverse + str[b+1,str.size-(b+1)]
  when "replace" then
    a,b,p = input[1].to_i, input[2].to_i,input[3] 
    str = str[0,a] + p + str[b+1,str.size-(b+1)]
  end
end


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

#define SEG_LEN (1<<20)
int seg[SEG_LEN*2][26];
int N;
string S;

void start(int ind){
  int new_c=S.at(ind)-'a';
  
  ind+=SEG_LEN;
  seg[ind][new_c]++;
  while(1){
    ind/=2;
    if(ind==0)  break;
    for(int i=0;i<26;i++){
      seg[ind][i]=seg[ind*2][i]+seg[ind*2+1][i];
    }
  }
}
void change(int ind,char c){
  int pre_c=S.at(ind)-'a';
  S.at(ind)=c;
  int new_c=S.at(ind)-'a';
  
  ind+=SEG_LEN;
  seg[ind][pre_c]--;
  seg[ind][new_c]++;
  while(1){
    ind/=2;
    if(ind==0)  break;
    for(int i=0;i<26;i++){
      seg[ind][i]=seg[ind*2][i]+seg[ind*2+1][i];
    }
  }
}
int sum(int l,int r){
  l+=SEG_LEN;
  r+=SEG_LEN;
  vector<bool> ans(26,false);
  while(l<r){
    if(l%2==1){
      for(int i=0;i<26;i++){
        if(seg[l][i]>0) ans.at(i)=true;
      }
      l++;
    }
    l/=2;
    if(r%2==1){
      for(int i=0;i<26;i++){
        if(seg[r-1][i]>0) ans.at(i)=true;
      }
      r--;
    }
    r/=2;
  }
  
  int cnt=0;
  for(int i=0;i<26;i++){
    if(ans.at(i)) cnt++;
  }
  return cnt;
}

int main(){
  int Q;
  cin >> N >> S >> Q;
  for(int i=0;i<N;i++)  start(i);
  
  for(int i=0;i<Q;i++){
    int q;
    cin >> q;
    if(q==1){
      int i;
      char c;
      cin >> i >> c;
      change(i-1,c);
    }
    else if(q==2){
      int l,r;
      cin >> l >> r;
      cout << sum(l-1,r) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 110724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    while(1){
        ll a;cin>>a;
        string op;cin>>op;
        ll b;cin>>b;
        if(op=="?")return;
        if(op=="+")cout<<a+b<<endl;
        if(op=="-")cout<<a-b<<endl;
        if(op=="*")cout<<a*b<<endl;
        if(op=="/")cout<<a/b<<endl;
    }
}

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



Measured memory_bytes: 3124
#include <algorithm>
#include <iostream>
#include <queue>

#define ll long long
#define MAX_N 100005

using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> P(N);
  priority_queue<ll> que;

  for (int i = 0; i < N; i++) {
    cin >> P[i].first >> P[i].second;
  }
  sort(P.begin(), P.end());

  ll ans = 0, index = 0;
  for (int i = 1; i <= M; i++) {
    while (index < N && P[index].first <= i) {
      que.push(P[index++].second);
    }
    if (!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2936
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int k; cin >> k;
    if(k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return;
    }
    int cur = 7, cnt = 1;
    while(true) {
        if(cur % k == 0) {
            cout << cnt << endl;
            return;
        }
        cur *= 10;
        cur += 7;
        cur %= k;
        ++ cnt;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double r,ans1,ans2;
cin>>r;
	ans1=r*r*3.141592653589;
	ans2=r*2*3.141592653589;
	printf("%f %f\n",ans1,ans2);
	return 0;
}

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

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

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 110;
const int MAXM = 10010;

int n, p[MAXN];

int main() {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%d",&p[i]);
  }

  int sol = 0;
  for (int i = MAXM; i; i--) {
    int tmp = 0;
    FOR(j, 1, n) {
      if (p[j] != i) {tmp = 0; continue;}
      if (p[j] == p[j - 1] && !tmp) {sol++; tmp = 1;}
      else tmp = 0;
    }
  }

  cout << sol << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(void){
    string s;
    cin  >> s;
    int count = 0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='1'){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y<< endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    new Main().run();
  }

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

  private void run() {
    int N = Integer.parseInt(sc.next());
    boolean approved = true;
    for (int i = 0; i < N; i++) {
      int num = Integer.parseInt(sc.next());
      if (num % 2 == 0) {
        if (!(num % 3 == 0 || num % 5 == 0)) {
          approved = false;
          break;
        }
      }
    }

    if (approved) {
      System.out.println("APPROVED");
    } else {
      System.out.println("DENIED");
    }
  }
}


Measured memory_bytes: 24148
from copy import deepcopy
from collections import deque
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    n = int(input())
    par = [-1] * n
    uvw = {e:[] for e in range(n)}

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        uvw[u].append((u, v, w))
        uvw[v].append((v, u, w))
        unite(u, v)
    root_node = roots()[0]
    color = [-1] * n
    color[root_node] = 0
    node_next = deque()
    node_next.append(root_node)
    node_next_next = deque()
    node_seen = set()

    while len(node_seen) < n:
        while node_next:
            node_togo = node_next.popleft()
            if node_togo in node_seen:
                continue
            else:
                node_seen.add(node_togo)
            # 次の層のノード群情報を取得し、「次にみるノードlist」にいれる。
            node_adj = uvw[node_togo]
            node_next_next += [i[1] for i in node_adj]
            # 次の層を処理＝色塗りする
            for adj in node_adj:
                if adj[1] in node_seen or color[adj[1]] != -1:
                    continue
                if adj[2] % 2 == 0:
                    color[adj[1]] = color[node_togo]
                else:
                    color[adj[1]] = color[node_togo] ^ 1
        node_next = deepcopy(node_next_next)
        node_next_next = deque()
    print(*color, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 120036
#include <iostream>

using namespace std;

struct card{
	char c;
	char i;
};

void buttle(struct card A[],int N)
{
//	card temp;
	for (int i=0;i<N;i++)
	{
		for (int j=N-1;j>=i+1;j--)
		{
			if (A[j-1].i>A[j].i) 
			{
			 card temp=A[j];
				A[j]=A[j-1];
				A[j-1]=temp;
		    }
		}
	}
}

void selection(struct card B[],int N)
{
	int mini;
	card temp;
	for (int i=0;i<N;i++)
	{
		mini=i;
		for (int j=i;j<N;j++)
		{
			if(B[j].i<B[mini].i) mini=j;
		}
		temp=B[i];B[i]=B[mini];B[mini]=temp;
	} 
}

void print(struct card A[],int N)
{
	for (int i=0;i<N;i++)
	{
		if (i>0) cout<<" ";
		cout<<A[i].c<<A[i].i;
	}
	cout<<endl;
}

bool compare(struct card A[],struct card B[],int N)
{
	for (int i=0;i<N;i++)
	{
		if (B[i].c!=A[i].c) return false;
	//	else return true;
	} 
	return true;
}

int main ()
{
	card A[100],B[100];
	int N;
	cin>>N;
	for (int i=0;i<N;i++)
	{
		cin>>A[i].c>>A[i].i;
	}
	for (int i=0;i<N;i++) B[i]=A[i];
	
	buttle (A,N);
	selection(B,N);
	
	print(A,N);
	cout<<"Stable"<<endl;
	
	print (B,N);
	if (compare(A,B,N)) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
	
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    int n;

    cin >> n;

    ll arr[n];

    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }

    ll res = 0;

    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if(arr[i]+arr[j] > arr[k] && arr[i]+arr[k] > arr[j] && arr[j]+arr[k] > arr[i] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k])
                {
                    res++;
                }
            }
        }
    }

    cout << res;

    return 0;


}


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

int a[200000];

int main()
{
	int n;
	int cnt = 1;
	int maxv = 0;
	int max2 = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] > max2)
		{
			if (a[i] >= maxv)
			{
				if (a[i] == maxv)
					cnt++;
				else
				{
					cnt = 1;
					max2 = maxv;
					maxv = a[i];
				}
			}
			else
				max2 = a[i];
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] < maxv)
			printf("%d\n", maxv);
		else
		{
			if (cnt > 1)
				printf("%d\n", maxv);
			else
				printf("%d\n", max2);
		}
	}
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int edit(string x, string y) {
    int n = x.length();
    int ans =0;
    for(int i=0;i<n;i++) {
        if(x[i]!=y[i]) {
            ans++;
        }
    }
    return ans;
}
int main() {

    jaldi

    string s;
    string t;
    cin>>s;
    cin>>t;
    int n=s.length();
    int m=t.length();
    int mini = INT_MAX;
    for(int i=0;i<=(n-m);i++) {
        string t1 = s.substr(i,m);
        mini = min(mini, edit(t,t1));
    }
    cout<<mini<<'\n';
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


int n, a, b, c ,d;
map<int, int> ans;
int f(int val)
{
    if(ans.count(val))return ans[val];
    int cost = INF;
    if(val< cost/d) cost=val*d;

    for(int i=0;i<3;i++)
    {
        int k= vector<int>{2, 3, 5}[i];
        int p= vector<int>{a, b, c}[i];

        if(val%k==0)
        {

            set_min(cost,f(val/k)+p);
        }
        else{
            set_min(cost, f(val/k )+ p+(val-val/k*k)*d);
            set_min(cost, f((val+k-1)/k)+p- (val-(val+k-1)/k*k)*d);
        }

    }
    return ans[val]=cost;

}

void solve()
{

    cin>>n>>a>>b>>c>>d;
    ans.clear();
    ans[0]=0;
    ans[1]=d;

    cout<<f(n)<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 4664
/*
NAME: jinxiaoguang
LANG: C++
TASK:
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
//#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int inff=0x80000000;
const int infz=0x7fffffff;
const int mod=1e9+7;

int main()
{
int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",a*a-b);
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int n;

  cin>>n;

  cout<<n*32<<endl;

  return 0;

}



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

const int MX = 300005;

using namespace std;

int a[MX];

int main()
{
	int n, odd = 0, evn = 0;
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d", &a[i]);
		if(i&1) odd += a[i];
		else evn += a[i];
	}
	if(n & 1)
	{
		int l = 1, r = 300000000, mid, ans;
		auto check = [=](int need)
		{
			int sum = a[1];
			for(int i=2; i<=n; i+=2)
			{
				if(sum >= need) sum = max(sum+a[i+1]-a[i], a[i+1]);
				else sum += a[i+1]-a[i];
			}
			return sum >= need;
		};
		while(l < r)
		{
			mid = (l+r+1) / 2;
			if(check(mid)) l = ans = mid;
			else r = ans = mid-1;
		}
		printf("%d %d\n", evn+ans, odd-ans);
	}
	else printf("%d %d\n", max(odd, evn), min(odd, evn));
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
	int INF = 1 <<24;
	class C{
		int x,y;

		public C(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h) == 0)break;
			int sx = -1, sy = -1, gx = -1, gy = -1;
			ArrayList<ArrayList<C>> data = new ArrayList<ArrayList<C>>();
			for(int i = 0; i <= 5; i++){
				data.add(new ArrayList<Main.C>());
			}
			for(int i = 0; i < h; i++){
				String s = sc.next();
				for(int j=0; j < w; j++){
					char c = s.charAt(j);
					if(Character.isDigit(c)){
						data.get(c - '0').add(new C(j, i));
					}
					else if(c == 'S'){
						sx = j;
						sy = i;
					}
					else if(c == 'G'){
						gy = i;
						gx = j;
					}
				}
			}
			
			//NA
			int co = 0;
			int capa = 0;
			for(int i = 1; i < data.size(); i++){
				if(data.get(i).size() > 0){
					co++;
				}
				capa = Math.max(capa, data.get(i).size());
			}
			if(co < 4){
				System.out.println("NA");
				continue;
			}
			
			int min = INF;
			int minind = -1;
			for(int first = 1; first <= 5; first++){
				int [][] dp = new int[6][capa];
				for(int i = 0; i < 6; i++){
					Arrays.fill(dp[i], INF);
				}
				int len = (first == 5 ? 1 : first + 1);
				for(int i = 0; i < data.get(len).size();i++){
					int dis = Math.abs(sx - data.get(len).get(i).x) + Math.abs(sy - data.get(len).get(i).y);
					dp[len][i] = dis;
				}
				
				for(int times = 1; times <= 3; times++){
					int next = (len + times  > 5 ? len + times - 5 : len + times);
					int prev = (next - 1 == 0 ? 5 : next - 1);
					for(int i = 0; i < data.get(prev).size(); i++){
						if(dp[prev][i] == INF) continue;
						for(int j = 0; j < data.get(next).size(); j++){
							int nextdis = dis(data.get(prev).get(i), data.get(next).get(j));
							dp[next][j] = Math.min(dp[next][j], nextdis + dp[prev][i]);
						}
					}
				}
				
				int last = (first - 1 == 0 ? 5 : first  -1);
				int res = INF;
				for(int i = 0; i < data.get(last).size(); i++){
					C pos = data.get(last).get(i);
					int  value = Math.abs(pos.x - gx) + Math.abs(pos.y - gy);
					res = Math.min(res, dp[last][i] + value);
				}
				
				if(res < min){
					minind = first;
					min = res;
				}
			}
			System.out.println(minind + " " + min);
		}
	}


	private int dis(C c, C c2) {
		int res = Math.abs(c.x - c2.x) + Math.abs(c.y - c2.y);
		return res;
	}


	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
S = int(input())


def collatz(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


collatz_list = []
collatz_set = set()
num = S
ans = 1
while True:
    if num in collatz_set:
        break
    else:
        collatz_list.append(num)
        collatz_set.add(num)
        num = collatz(num)
        ans += 1
print(ans)

Measured memory_bytes: 3060
mod = 10**9 +7
n, a, b = map(int, input().split())

lis = []
on = 0 + n
count = 0
while on > 0:
  if on & 1 == 1:
    lis.append(count)
  count += 1
  on >>= 1

two = [2]
for _ in range(count-1):
  two.append(two[-1]*two[-1]%mod)

ans = 1
for item in lis:
  ans = ans * two[item] %mod

op = mod-2
invlis = []
count = 0
while op > 0:
  if op & 1 == 1:
    invlis.append(count)
  count += 1
  op >>= 1


def modinv(N):
  if N == 1:
    return 1
  else:
    res = 1
    Nlis = []
    for _ in range(count):
      Nlis.append(N%mod)
      N = N*N%mod
    for item in invlis:
      res = res * Nlis[item] %mod
    return res

ans_a = 1
for k in range(n-a+1, n+1):
  ans_a = ans_a*k%mod
amother = 1
for k in range(2, a+1):
  amother = amother * k % mod
ans_a = ans_a*modinv(amother)%mod

ans_b = 1
for k in range(n-b+1, n+1):
  ans_b = ans_b*k%mod
bmother = 1
for k in range(2, b+1):
  bmother = bmother * k % mod  
ans_b = ans_b*modinv(bmother)%mod

print((ans-ans_a-ans_b-1)%mod)

Measured memory_bytes: 9244
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int n;
vector<string> v;
int count(int line){
  int res = 0;
  int i = 0;
  while(v[line][i++]=='.') res++;
  return res;
}
int calc(int& line,int depth){
  if(v[line][depth]=='+'){
    int ret=0;
    line++;
    while(line<n && count(line)==depth+1){
      ret += calc(line,depth+1);
    }
    return ret;
  }
  else if(v[line][depth]=='*'){
    int ret=1;
    line++;
    while(line<n && count(line)==depth+1){
      ret *= calc(line,depth+1);
    }
    return ret;
  }
  else return v[line++][depth]-'0';
}
int solve(){
    int line = 0;
    int ans = calc(line,0);
    return ans;
}
int main(){
  while(cin >> n,n){
    v.resize(n);
    rep(i,n) cin >> v[i];
    cout << solve() << endl;
  }
  return 0;
}



Measured memory_bytes: 3160
// Rakib (CSE'19)
         
        #include<bits/stdc++.h>
         
         
        #define               ll               long long
        #define               boost_           ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        #define               pb               push_back
        #define               ull              unsigned long long
        #define               read(i,n,a)      for(i=0;i<n;++i) cin>>a[i];
        #define               show(i,a)        for(auto i:a) cout<<i<<" "; cout<<endl;
        #define               dpoint(n)        cout<<showpoint<<fixed<<setprecision(n);
         
        using namespace std;
         
        int gcd(int x,int y){
            if(!y) return x;
            return gcd(y,x%y);
        }
        bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }
        bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }
        bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }
        bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }
        bool sortcol( const vector<int>& v1, const vector<int>& v2 ) { return v1[0] < v2[0]; }

        ll proceed(){
           
           ll n;
           cin >> n;
           ll a[n],b[n],i;

           for(i=0;i<n;++i){
               cin >> a[i] >> b[i];
           }

           for(i=0;i+2<n;++i){
               if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]){ cout << "Yes" << endl; return 0;} 
           }


           cout << "No " << endl;

           return 0;
       }
            //** Main **//
         
        int main(){
         
                boost_;
                int t=1,i=0;
               // cin >> t;
                while(t--){
         
                    proceed();
         
                }
         
                return 0;
        }

Measured memory_bytes: 3636
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ans = ""
while n > 0:
    m = n%26
    nya = m-1 if m-1 >= 0 else 25
    ans += chr(ord('a') + nya)
    n -= nya
    n//=26
print(ans[::-1])


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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  vector<vector<ll>> dp(65, vector<ll>(3, 0));
  dp[64][0] = 1;
  for (ll i = 63; i >= 0; i--) {
    if (n & (1LL << i)) {
      dp[i][0] += dp[i + 1][0];
      dp[i][1] += dp[i + 1][0] + dp[i + 1][1];
      dp[i][2] += 2 * dp[i + 1][1] + 3 * dp[i + 1][2];
    }
    else {
      dp[i][0] += dp[i + 1][0] + dp[i + 1][1];
      dp[i][1] += dp[i + 1][1];
      dp[i][2] += dp[i + 1][1] + 3 * dp[i + 1][2];
    }
    dp[i][0] %= MOD;
    dp[i][1] %= MOD;
    dp[i][2] %= MOD;
  }
  
  cout << (dp[0][0] + dp[0][1] + dp[0][2]) % MOD << '\n';
}

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

int n, k, w[100010];

bool ok(int P){
  int x = 0, y = 1;
  for(int j=0; j<n; j++){
    if(w[j] > P){
      return 0;
    }
    else{
      if(x+w[j] <= P){
	x += w[j];
      }
      else{
	y++;
	x = w[j];
      }
    }
  }
  if(y<=k) return 1;
  else return 0;
}

int main(){
  cin >> n >> k;
  for(int i=0; i<n; i++){
    cin >> w[i];
  }

  int l = 0, h =1000100000;
  while(l+1 < h){
    int m = (l+h)/2;
    if(ok(m)){
      h = m;
    }
    else{
      l = m;
    }

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

}

    
#if 0
?????????h???100000???????????????????¨???????????????????, ??\???????????????????????§???????????£?????¨????????¨?????????????????????. h??????????????§????????°??§????????¨?????????????????¨???????????£???.
  ???????????????1???????¨??????§?????£???.
#endif
  

Measured memory_bytes: 1532
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int gcd(int a, int b)
{
	while (a % b != 0) {
		a = a % b;
		std::swap(a, b);
	}
	return b;
}

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int K;
	int result = 0;
	std::cin >> K;

	for (int i = 1; i <= K; ++i)
		for (int j = 1; j <= K; ++j)
			for (int k = 1; k <= K; ++k)
				result += gcd(gcd(i, j), k);
	std::cout << result << "\n";
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		List<String> list = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			list.add(scan.next());
		}

		List<String> fillteredList = list.stream().distinct().collect(Collectors.toList());

		if(fillteredList.size() == list.size()) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}

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

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N){
        ans += (i + 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize, d: usize,
        x: [[i64; d]; n],
    }

    let dist2: Vec<_> = (0..n)
        .map(|i| {
            (0..n)
                .map(|j| {
                    x[i].iter()
                        .zip(x[j].iter())
                        .map(|(&i, &j)| (i - j) * (i - j))
                        .sum::<i64>()
                })
                .collect::<Vec<_>>()
        })
        .collect();

    let mut count = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            if dist2[i][j] == ((dist2[i][j] as f64).sqrt() as i64).pow(2) {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


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

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

    int cnt = 0, j = 0, tmp;

    for (int i = 1; i <= n; i++) {
        cin >> tmp;

        j++;
        if (j == k) cnt++, j = 1;
    }

    if (j != 1) cnt++;

    cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long K = long.Parse(str[1]);
        long[] cnt = new long[100000 + 1];

        for(int i = 0; i < N; i++){
            str = Console.ReadLine().Split(' ');
            int A, B;
            A = int.Parse(str[0]);
            B = int.Parse(str[1]);
            cnt[A] += B;
        }

        for(int i = 1; i <= 100000; i++){
            if(K <= cnt[i]){
                Console.WriteLine(i);
                break;
            }
            K -= cnt[i];
        }
    }
}

Measured memory_bytes: 15832
#include<iostream>
using namespace std;
int main(){
    int house[4][3][10]={{{}}};
    int n;
    int a,b,c,d;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b >> c >> d;
        house[a-1][b-1][c-1] += d;
    }
    for(int j=0;j<4;j++){
        for(int k=0;k<3;k++){
            for(int l=0;l<10;l++){
                cout << " " << house[j][k][l];
            }
            cout << endl;
        }
        if(j<3) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n;cin >> n;
    vector<int> w(n);
    rep(i,n)cin >> w[i];

    int sum = accumulate(ALL(w),0);
    int ans = INF;
    for(int i=0;i<n;i++){
        int tmp = accumulate(w.begin(),w.begin()+i+1,0);
        int ansT = abs(tmp - (sum - tmp));
        ans = min(ans,ansT);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, C, X, Y;
    scan(A, B, C, X, Y);
    long a = max(X, Y) * 2 * C;
    long b = X * 2 * C + max(0, Y - X) * B;
    long c = Y * 2 * C + max(0, X - Y) * A;
    long d = X * A + Y * B;
    // writeln(a, b, c, d);
    writeln(min(a, b, c, d));
}


Measured memory_bytes: 256