akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
    int row, column;
    scanf("%d %d", &row, &column);

    int sheet[row + 1][column + 1];
    int i, j;

    // prep init sheet
    for(i = 0; i < row + 1; i++)
    {
        for(j = 0; j < column + 1; j++)
        {
            sheet[i][j] = 0;
        }
    }

    int sum;
    for(i = 0; i < row; i++)
    {
        for(j = 0; j < column; j++)
        {
            scanf("%d", &sheet[i][j]);
        }
    }

    // Check if the input was successful
    // printf("\n----TEST----\n");
    // for(i = 0; i < row + 1; i++)
    // {
    //     for(j = 0; j < column + 1; j++)
    //     {
    //         printf("%d ", sheet[i][j]);
    //     }
    //     printf("\n");
    // }

    // input the sum of row
    for(i = 0; i < row; i++)
    {
        sum = 0;
        for(j = 0; j < column; j++)
        {
            sum += sheet[i][j];
            if (j == column - 1)
                sheet[i][column] = sum;
        }
    }

    // input the sum of column
    int all_sum = 0;
    for(i = 0; i < column; i++)
    {
        sum = 0;
        for(j = 0; j < row; j++)
        {
            sum += sheet[j][i];
            if (j == row - 1)
            {
                sheet[row][i] = sum;
                all_sum += sum;
            }
        }
    }

    // input the all_sum
    sheet[row][column] = all_sum;

    // Print out the result
    for(i = 0; i < row + 1; i++)
    {
        for(j = 0; j < column + 1; j++)
        {
            printf("%d", sheet[i][j]);
            j == column ? printf("\n") : printf(" ");
        }
    }
    return (0);
}


Measured memory_bytes: 2060
#include <stdio.h>

int main(void)
{
	int c1,c5,c10,c50,c100,c500,a=0;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	
	c1=1*c1;
	c5=5*c5;
	c10=10*c10;
	c50=50*c50;
	c100=100*c100;
	c500=500*c500;
	
	a=c1+c5+c10+c50+c100+c500;
	
	if(a>=1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	
	return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli q;
vll a,b;

int main(){
  cin >> q;
  for(lli i = 0;i < q;i++){
    lli a,b;
    cin >> a >> b;
    lli c = a*b;
    lli d = 0;
    for(lli bit = 1ll << 30;bit > 0;bit >>= 1){
      if((d|bit)*(d|bit) < c) d |= bit;
    }
    lli sft = 0;
    // cout << d << endl;
    if(d*(d+1) >= c)sft--;
    if(a <= d) sft--;
    if(b <= d) sft--;
    cout << d*2+sft << endl;
  }
  return 0;
}


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

int N;
string S;

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

    int ans = 0;
    for (int i = 1; i < S.length(); i++) {
        string fst = S.substr(0, i);
        string snd = S.substr(i);

        int cnt = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            bool left = false;
            bool right = false; 
            for (int j = 0; j < fst.length(); j++) {
                if (fst[j] == c) {
                    left = true; 
                    break;
                }
            }
            for (int j = 0; j < snd.length(); j++) {
                if (snd[j] == c) {
                    right = true; 
                    break; 
                }
            }
            if (left && right) cnt++;
        }
        ans = max(cnt, ans);
    }

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


Measured memory_bytes: 256
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = []
for k, v in a.items():
    if 4 <= v:
        b.append(k)
    if 2 <= v:
        b.append(k)
else:
    if len(b) <= 1:
        print(0)
    else:
        b.sort()
        print(b[-1] * b[-2])

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

using namespace std;
typedef long long int ll;
ll N1097 = 1000000007LL;

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int ans=0;
    for(int i=1;i<n-1;i++){
        if(min(p[i-1],p[i+1]) < p[i] && max(p[i-1],p[i+1]) > p[i] ){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
m, d =  [ int(v) for v in input().split() ]

ans = 0
for i in range(1,d+1):
    d1 = i % 10
    d10 = i // 10
    if d1 >= 2 and d10 >= 2 and 1 < d1 * d10 <= m:
        ans += 1
print(ans)

Measured memory_bytes: 38384
// Aizu Vol-1 0193: Convenience Store
// 2017.8.25 bal4u@uu

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

typedef struct { int r, c, f; } T;
T shop[25]; int n, S, N;
int R, C;

int hexDistance(int r1, int c1, int r2, int c2)
{
#define abs(a) ((a)>=0?(a):(-(a)))
	int dr, dc, c;
	dr = abs(r2 - r1), dc = abs(c2 - c1);
	if (r2 == r1) return dc;
	if (c2 == c1) return dr;
	if (r2 < r1) c = r2, r2 = r1, r1 = c, c = c2, c2 = c1, c1 = c;
	if (c2 >= c1) {
		c = c1 + (dr+1-(r1&1))/2;
		if (c2 >= c) dr += abs(c-c2);
	} else {
		c = c1 - (dr+(r1&1))/2;
		if (c2 <= c) dr += abs(c-c2);
	}
	return dr;
}

int main()
{
	int i, k, r, c;
	int d[25];

	while (scanf("%d%d", &C, &R) && C) {
		scanf("%d", &S); for (n = 0, i = 0; i < S; i++)
			scanf("%d%d", &shop[n].c, &shop[n].r), shop[n++].f = 0;
		scanf("%d", &N); for (i = 0; i < N; i++)
			scanf("%d%d", &shop[n].c, &shop[n].r), shop[n++].f = 0;
		for (r = 1; r <= R; r++) for (c = 1; c <= C; c++) {
			for (i = 0; i < n; i++) d[i] = hexDistance(shop[i].r, shop[i].c, r, c);
			for (k = -1, i = 0; i < S; i++) if (k < 0 || d[i] < k) k = d[i];
			for (i = S; i < n; i++) if (d[i] < k) shop[i].f++;
		}	
		for (k = -1, i = S; i < n; i++) if (shop[i].f > k) k = shop[i].f;
		printf("%d\n", k);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 110000
using namespace std;

int gcd(int a, int b)
{
	int p, q, r;
	p = min(a, b);
	q = max(a, b);
	while (1)
	{
		r = q % p;
		if (r == 0)
			return p;
		q = p;
		p = r;
	}
}

int main() {
	int N, A[numarr], i;
	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
		if (i != 0)
			A[i] = gcd(A[i - 1], A[i]);
	}
		cout << A[N - 1] << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> a;
  for (int i = 0; i < n; ++i)
  {
    int t;
    cin >> t;
    a.emplace_back(t, i + 1);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i)
    cout << a[i].second << " \n"[i == n - 1];

  return 0;
}


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

const int mod = 1e9+7;
 
main()
{
    int h,w;
    cin>>h>>w;
    char arr[h+1][w+1];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>arr[i][j];
            //cout<<arr[i][j]<<" ";
        }
        //cout<<"\n";
    }
    int dp[h+1][w+1];
    bool f=1,g=1;
    memset(dp,0,sizeof dp);
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i==1)
            {
                if(arr[i][j]=='.' && f) dp[i][j] = 1;
                else f = false;
                continue;
            }
            if(j==1)
            {
                if(arr[i][j]=='.' && g) dp[i][j] = 1;
                else g = false;
                continue;
            }
            if(arr[i][j]=='#') dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod; 
        }
    }
    cout<<dp[h][w];
}

Measured memory_bytes: 5120
n, k = gets.strip.split.map(&:to_i)
#n, k = [10, 0]

result=0
(1..n).each do |b|
  p = n/b
  r = n%b
  result += p*[b-k,0].max + [r-k+1, 0].max
end

result -= n if k.zero?

p result


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int W, H;

pair<bool, int> dfs_count(vvc& field, int x, int y, char c) {
    field[y][x] = c;
    int cnt = 0;
    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (field[sy][sx] == '.') {
                auto retval = dfs_count(field, sx, sy, c);
                if (!retval.first) {
                    return {false, 0};
                }
                cnt += retval.second + 1;
            } else if (field[sy][sx] != c) {
                return {false, 0};
            }
        }
    }
    return {true, cnt};
}

int main() {
    while (cin >> W >> H, W|H) {
        vvc field(H, vc(W));
        REP(y, H) REP(x, W) cin >> field[y][x];
        int b = 0, w = 0;
        REP(y, H) REP(x, W) {
            if (field[y][x] == '.') continue;
            REP(i, 4) {
                vvc copy = field;
                int sx = x + dx[i], sy = y + dy[i];
                if (0 <= sx && sx < W && 0 <= sy && sy < H && field[sy][sx] == '.') {
                    if (field[y][x] == 'B') {
                        auto retval = dfs_count(field, sx, sy, 'B');
                        if (retval.first) {
                            b += retval.second + 1;
                        } else {
                            field = copy;
                        }
                    } else if (field[y][x] == 'W') {
                        auto retval = dfs_count(field, sx, sy, 'W');
                        if (retval.first) {
                            w += retval.second + 1;
                        } else {
                            field = copy;
                        }
                    }
                }
            }
        }
//        REP(y, H) { REP(x, W) { LOG("%c", field[y][x]); } LOG("\n"); }

        cout << b << " " << w << endl;
    }
}

Measured memory_bytes: 3172
using System;
using System.Collections.Generic;
using System.Linq;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {


            double n =s2i(Console.ReadLine());
            n/= 3.0;
            RESULT(Math.Pow(n,3));


        }
    
    



    
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static long s2l(String s)
        {
            return Convert.ToInt64(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 11348
console.log((args=>{
  const [[n],a] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const m = Math.floor(n/2);
  let b = Array(n).fill(NaN), j = n&1||-1;
  for ( let i = 0; i < n; i++ ) {
    b[m-j*(i+1>>1)] = a[i];
    j = -j;
  }
  return b.join` `;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 73892
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> x(N);
	vector<bool> A(N, 1);
	for (int i = 0; i < M; i++) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		x[a].push_back(b);
		x[b].push_back(a);
	}
	queue<int> a;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] != 1||x[i].size()==0)continue;
		A[i] = 0; ans++;
		a.push(i);
		while (a.size() > 0) {
			int y = a.front();
			a.pop();
			for (int j = 0; j < x[y].size(); j++) {
				if (A[x[y][j]] == 1)a.push(x[y][j]);
				A[x[y][j]] = 0;
			}
		}
	}
	for (int i = 0; i < N; i++)if (A[i] == 1)ans++;
	cout << ans << endl;
	
}




Measured memory_bytes: 6520
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

double calc(double t, double v, double l, double r){
    // cout << t << " " << v << " " << l << " " << r << endl;
    if (v - l + v - r < t) return v * t - (v - l) * (v - l) / 2 - (v - r) * (v - r) / 2;
    double p = (r - l + t) / 2;
    // cout << p << endl;
    return p * (2 * l + p) / 2 + (t - p) * (2 * r + t - p) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<double> t(n), v(n);
    REP(i,n) cin >> t[i];
    REP(i,n) cin >> v[i];

    vector<double> lim(n+1, 1e9);
    lim[0] = lim[n] = 0;

    REP(i,n){
        lim[i] = fmin(lim[i], v[i]);
        lim[i+1] = fmin(lim[i+1], v[i]);
    }

    FOR(i,1,n-1) lim[i] = fmin(lim[i], lim[i-1] + t[i-1]);

    FORR(i,n-1,1) lim[i] = fmin(lim[i], lim[i+1] + t[i]);

    double ans = 0;
    REP(i,n){
        ans += calc(t[i], v[i], lim[i], lim[i+1]);
    }

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

    return 0;
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let S = lines.shift().trim();
    let K = lines.shift().trim();
    for (let i = 0; i < S.length && i < K; i++) {
        if (S.charAt(i) > 1) {
            console.log(S.charAt(i));
            return;
        }
    }
    console.log(1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define INF (ll)1e12
#define MOD 1000000007
#define ld long double

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

ld p(ll coin, ll heads);

ll n;
vector<ld> P(3010,0);

vector<vector<ld>> dp(3010,vector<ld>(3010,-10));

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

    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        cin>>P[i];
    }

    ld sum = 0;

    for(ll i=(n+1)/2; i<=n; i++)
    {
        sum += p(n,i);
    }

    printf("%0.10Lf\n", sum);

    return 0;
}

ld p(ll coin, ll heads)
{
    if(dp[coin][heads] > -1)
    {
        return dp[coin][heads];
    }

    if(coin < heads || heads < 0)
    {
        return 0;
    }

    if(coin == 0)
    {
        return dp[coin][heads] = 1;
    }

    return dp[coin][heads] = P[coin]*p(coin-1,heads-1) + (1-P[coin])*p(coin-1,heads);
}


Measured memory_bytes: 142208
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int,int>
#define vvi vector<vector<int> >
#define vpi vector<pii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define INF 0x7fffffff
#define LINF 0x7fffffffffffffff
#define MOD 1000000007
#define mod 998244353
#define lowbit(x) x&(-x)
#define HS 173LL
using namespace std;
int read()
{
	int x=0;
	char ch=getchar();
	while(!isdigit(ch))
		ch=getchar();
	while(isdigit(ch))
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}
const int maxn=1e6+10;
int n,a[maxn],cnt[maxn];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		for(int j=2;j*j<=a[i];j++)
		{
			if(a[i]%j==0)
			{
				++cnt[j];
				while(a[i]%j==0)
				{
					a[i]/=j;
				}
			}
		}
		if(a[i]!=1)
		{
			++cnt[a[i]];
		}
	}
	bool flag1=true,flag2=true;
	for(int i=2;i<=1e6;i++)
	{
		if(cnt[i]>1)
		{
			flag1=false;
		}
		if(cnt[i]==n)
		{
			flag2=false;
		}
	}
	if(flag1)
	{
		cout<<"pairwise coprime"<<endl;
	}
	else if(flag2)
	{
		cout<<"setwise coprime"<<endl;
	}
	else
	{
		cout<<"not coprime"<<endl;
	}
	return 0;
}

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

int a, b, c, d, e;
int main() {
  cin >> a >> b >> c >> d >> e;
  cout << (max(a, 40) + max(b, 40) + max(c, 40) + max(d, 40) + max(e, 40)) / 5 << "\n";
  return 0;
}

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main()
{
  int N=IN(),A=0,diff=0,tallest=0;long total=0;
  while(N--){A=IN();diff=tallest<A?0:tallest-A;total+=1l*diff;if(tallest<A)tallest=A;}
  return OUT(total),0;
}

Measured memory_bytes: 1500
#include<bits/stdc++.h>
#define N 50010
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int n,m;
int a[60];
long long dp[60][3010],sum[60];
int main()
{
	read(n);read(m);
	for(int i=1;i<=n;i++) read(a[i]),sum[i]=sum[i-1]+a[i];
	long long ans=0;
	dp[0][0]=1;
	for(int j=1;j<=n;j++)
		for(int i=j;i>=1;i--)
			for(int k=sum[j];k>=a[j];k--)
				dp[i][k]+=dp[i-1][k-a[j]];
	for(int i=1;i<=n;i++)
		ans+=dp[i][i*m];
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    if(a+b-c >= 0){
        cout << "No" << endl;
        return 0;
    }
    if((a+b-c)*(a+b-c) > 4*a*b){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    rep(i,n)cin >> v[i];
    sort(all(v));
    double ans = v[0];
    rep(i,n){
        if(i == 0)continue;
        ans += v[i];
        ans /= 2;
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            String[] x = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
            String s = scan.next();
            for(int i = 0; i < x.length; i++) {
                if(x[i].equals(s)) {
                    out.println(7-i);
                    return;
                }
            }
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21460
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
//    int N ,L; cin >> N >> L;
    string N; cin >> N;

//    vector<string> vs(N);
//    REP(i, N) cin >> vs.at(i);
//    string O, E; cin >> O >> E;

    cout << N.front();

    cout << N.size() - 2;

    cout << N.back();

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back

#define N 200010
#define MOD 998244353

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

	int n, m, k, a;
	cin >> n >> m;
	int f[m + 1] = {};
	for (int i = 0; i < n; ++i)
	{
		cin >> k;
		for(int j = 0; j < k; ++j)
		{
			cin >> a;
			f[a]++;
		} 
	}
	int c = 0;
	for (int i = 0; i <= m; ++i)
	{
		if(f[i] == n)
			c++;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N int
	fmt.Scan(&N)
	m := map[int]int{}
	sum := 0
	var A int
	for i := 0; i < N; i++ {
		fmt.Scan(&A)
		if _, ok := m[A]; ok {
			m[A]++
		} else {
			m[A] = 1
		}
		sum += A
	}
	var Q int
	fmt.Scan(&Q)
	var B, C int
	for i := 0; i < Q; i++ {
		fmt.Scan(&B, &C)
		sum -= m[B] * (B - C)

		if _, ok := m[C]; ok {
			m[C] += m[B]
		} else {
			m[C] = m[B]
		}
		m[B] = 0
		fmt.Fprintln(wtr, sum)
	}

	_ = wtr.Flush()
}


Measured memory_bytes: 9760
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vl dp(n+1, INF);  // dp[i] : i円払うのに必要な操作回数の最小値
    dp[0] = 0;
    exrep(i, 1, n) {
        for(ll pow6 = 1; pow6 <= i; pow6 *= 6) {
            chmin(dp[i], dp[i-pow6] + 1);
        }
        for(ll pow9 = 1; pow9 <= i; pow9 *= 9) {
            chmin(dp[i], dp[i-pow9] + 1);
        }
    }

    out(dp[n]);
    re0;
}

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

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

    for(int i = 1; i < 10; ++i) for(int j = 1; j < 10; ++j){
        if(i*j == n){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define fi first
#define se second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

//math


const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;

int compute(int x){
	int ans = 1;
	if(x == 0) return 1;
	for(int i = 1; i <= x; i++){
		ans *= i;
		ans %= mod;
	}
	return ans;
}

void solve(){
	int a,b;
	cin >> a >> b;
	if(abs(a-b) > 1){
		cout << 0;
		exit(0);
	}
	int fac;
	if(abs(a-b) == 0){
		fac = 2;
	}else{
		fac = 1;
	}

	int ans = (((compute(a) * fac)%mod)*compute(b))%mod;
	cout << ans << endl;

}

signed main(){
  //clock_t t1 = clock();  
	IOS
	solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[]) {
    int a, b, c;

    std::cin >> a >> b >> c;

    if ( a < b && b < c){
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }


    return 0;
}

Measured memory_bytes: 1156
import numpy as np
def main():
    k, n = map(int, input().split(" "))
    As = list(map(int, input().split(" ")))

    As = np.array(As)

    As_dists = As[1:] - As[:-1]
    #print(As_dists)
    As_dists = np.append(As_dists, As[0] + (k - As[-1]))
    max_dists = np.max(As_dists)
    #print(As_dists)
    #print(max_dists)

    ans = k - max_dists
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

char S[22];
char y[7] = "YAKI";

int main(){
	scanf("%s" , S);
	repp(i,0,4){
		if(S[i] != y[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll n, q;
vector<int>g[214514];
P a[214514], b[214514];
ll sum[214514];
bool memo[224514];
void bfs(ll t) {
	rep(i, g[t].size()) {
		if (!memo[g[t][i]]) {
			sum[g[t][i]] += sum[t];
			memo[g[t][i]] = true;
			bfs(g[t][i]);
		}
	}
}
signed main() {
	cin >> n >> q;
	rep(i, n - 1) {
		cin >> a[i].first >> a[i].second;
		g[a[i].first - 1].push_back(a[i].second - 1);
		g[a[i].second - 1].push_back(a[i].first - 1);
	}
	rep(i, q)cin >> b[i].first >> b[i].second;
	rep(i, q)sum[b[i].first - 1] += b[i].second;
	memo[0] = true;
	bfs(0);
	rep(i, n)cout << sum[i] << " ";
	ggr
}

Measured memory_bytes: 31488
// package app;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();


        // N個のボールをK種類の色で塗る場合、塗り方のが何通りあるか求める。
        // N: 2, K: 2の場合
        // ab,baの2通り
        // N: 2, K: 3の場合
        // ab, ba, ac, ca, bc, cbの6通りがある
        // N: 2, K: 4の場合
        // ab, ba, ac, ca, bc, cb, ad, bd, cd, da, db, dcの12通り

        // N:3, K:2の場合
        // aba, babの2通り
        // N:4, K:2の場合
        // abab, babaの2通り

        // N:3, K:3の場合
        // aba, aca, abc, acb, bab, bcb, bac, bca, cac, cbc, cab, cbaの12通り
        // N:3, K:4の場合
        // aba, aca, ada, abc, abd, acb, acd, adb, adc
        // bab, bcb, bdb, bac, bad, bca, bcd, bda, bdc


        // 数式 num = K * (K - 1) ^ (N - 1)
        long result = (long)(K * Math.pow((K - 1), (N - 1)));

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"math"
)

func walkOnMultiplicationTable(num int) int {

	div := 0
	for i := int(math.Sqrt(float64(num))); i > 1; i-- {
		if num%i == 0 {
			div = i
			break
		}
	}
	if div == 0 {
		return num - 1
	}
	return div + num/div - 2

}

func main() {
	var a int
	fmt.Scan(&a)
	fmt.Println(walkOnMultiplicationTable(a))
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int answer = 0;
		if(n >1) {
			answer += n*(n-1)/2;
		}

		if(m >1) {
			answer += m*(m-1)/2;
		}
		System.out.println(answer);

	}
}

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


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

int main(){
  int N;
  string s;
  int ans=1;
  cin>>N>>s;
  for(int i=0;i<N-1;i++){
    if(s.at(i)!=s.at(i+1)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3712
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[] 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 = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long H, W, K;
    scan(H, W, K);
    string[] S;
    foreach (_; 0 .. H)
        S ~= sread();
    auto st = new long[][](H + 2, W + 2);
    foreach (h; 1 .. H + 1)
    {
        foreach (w; 1 .. W + 1)
        {
            st[h][w] += (S[h - 1][w - 1] == '#');
            st[h][w + 1] = st[h][w];
        }
    }
    foreach (h; 1 .. H + 1)
    {
        st[h + 1][] += st[h][];
        // writeln(st[h]);
    }
    alias count = (long y, long x, long h, long w) => st[y + h][x + w]
        - st[y + h][x] - st[y][x + w] + st[y][x];
    alias Rect = Tuple!(long, "y", long, "x", long, "h", long, "w");

    DList!Rect Q;
    auto ans = new long[][](H, W);
    foreach (ref row; ans)
        row[] = 1;
    Q.insertBack(Rect(0, 0, H, W));
    long id = 1;
    loop_while: while (!Q.empty)
    {
        auto r = Q.back;
        Q.removeBack();
        if (1 < count(r.y, r.x, r.h, r.w))
        {
            foreach (h; 0 .. r.h)
            {
                long a = count(r.y, r.x, h, r.w);
                long b = count(r.y + h, r.x, r.h - h, r.w);
                if (0 < a && 0 < b)
                {
                    id++;
                    foreach (hh; 0 .. h)
                        foreach (ww; 0 .. r.w)
                        {
                            ans[r.y + hh][r.x + ww] = id;
                        }
                    Q.insertBack(Rect(r.y, r.x, h, r.w));
                    Q.insertBack(Rect(r.y + h, r.x, r.h - h, r.w));
                    continue loop_while;
                }
            }
            foreach (w; 0 .. r.w)
            {
                long a = count(r.y, r.x, r.h, w);
                long b = count(r.y, r.x + w, r.h, r.w - w);
                if (0 < a && 0 < b)
                {
                    id++;
                    foreach (hh; 0 .. r.h)
                        foreach (ww; 0 .. w)
                        {
                            ans[r.y + hh][r.x + ww] = id;
                        }
                    Q.insertBack(Rect(r.y, r.x, r.h, w));
                    Q.insertBack(Rect(r.y, r.x + w, r.h, r.w - w));
                    continue loop_while;
                }
            }
        }
    }
    foreach (row; ans)
        row.map!(text).join(' ').writeln();
}


Measured memory_bytes: 5884
#include<stdio.h>
int  main(void){
    int a[3];
    int i,j,tmp,max;
    int s[3];

    for(i=0;i<3;i++){
        if(scanf("%d",&a[i]) == 1);
    }

    for(i=0;i<3;i++){
        for(j=i+1;j<3;j++){
        if(a[i]<a[j]){
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        }
    }

    s[0] = a[0] - a[1];
    s[1] = a[1] - a[2];
    s[2] = a[0] - a[2];

    for(i=0;i<3;i++){
         for(j=i+1;j<3;j++){
        if(s[i]>s[j]){
            tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
        }
         }
    }

    max = s[0] + s[1];

    printf("%d",max);

    return 0;
}

Measured memory_bytes: 128
import collections

n = int(input())
v = list(map(int, input().split()))
v_odd = collections.Counter(v[::2])
v_even = collections.Counter(v[1::2])

if v_odd == v_even and len(v_odd) == 1:
    print(n // 2)
    exit()
if v_odd.most_common()[0][0] != v_even.most_common()[0][0]:
    print(len(v[::2]) - v_odd.most_common()[0][1] + len(v[1::2]) - v_even.most_common()[0][1])
else:
    c1 = len(v[1::2]) - v_even.most_common()[0][1] + len(v[::2]) - v_odd.most_common()[1][1]
    c2 = len(v[1::2]) - v_even.most_common()[1][1] + len(v[::2]) - v_odd.most_common()[0][1]
    print(min(c1, c2))


Measured memory_bytes: 18656
def main():
    n, m, v, p = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)

    def check(x):
        """スコアxの問題が採用されるかどうかを真偽値で返す"""
        # m人全員が投票してもp番目に届かない場合は採用されない
        if x + m < a[p - 1]:
            return False
        # 総投票数
        mv = m * v
        mv -= m * len(a[:p-1])  # p-1番目までの上位全員にm人が投票
        for score in a[p-1:]:
            mv -= min(m, x + m - score)  # p番目以降の全員がx+mになるまで投票
        # mvが0以下でない場合、p番目以降にxより高い最終スコアがあるため採用されない
        return mv <= 0

    left, right = 0, n
    while left < right:
        mid = (left + right) // 2
        if check(a[mid]):
            left = mid + 1
        else:
            right = mid
    print(right)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71448
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int [n];
		int[] b = new int [n];
		int[] c = new int [m];
		int[] d = new int [m];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i=0; i<m; i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		int dist = 0;
		int num = 1;
		for(int i=0; i<n; i++){
			dist = Math.abs(c[0]-a[i])+Math.abs(d[0]-b[i]);
			for(int j=m-1; j>=0; j--){
				if(dist>=(Math.abs(c[j]-a[i])+Math.abs(d[j]-b[i]))){
					num = j+1;
					dist = Math.abs(c[j]-a[i])+Math.abs(d[j]-b[i]);
				}
			}
		System.out.println(num);
		}
	}
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n)){
		int a[n];
		for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
		int t = 1,ans = 0,flag = 0;
		for(int i = 1; i <= n; i++){
			t = a[t];
			ans++;
			if(t == 2) {
				flag = 1;
				break;
			}

		}
		if(flag == 1) printf("%d\n",ans);
		else printf("-1\n");
	}
}

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

int main(void)
{
    char buffer[256];
    int n, min=1000000, max=-1000000;
    long sum = 0;

    fgets(buffer, 7, stdin);
    sscanf(buffer, "%d", &n);
    int current=0, counter = 0;

    while (counter++ < n)
    {
        scanf("%d", &current);
        if (current < min) min = current;
        if (current > max) max = current;
        sum += (long)current;

    }

    printf("%d %d %ld\n", min, max, sum);

    return(0);
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1==M2?0:1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int result = 0;
		for (int i = 0; i <= N; i++) {
			String tmp = String.valueOf(i);
			int sum = 0;
			for (String s : tmp.split("")) {
				int num = Integer.parseInt(s);
				sum += num;
			}
			if (sum >= A && sum <= B) {
				result += i;
			}
		}
		System.out.println(result);
	}
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int N;
int a[3333];
int dp[3333][3333];
int dfs(int x, int y) {
  if (x > y) {
    return  0;
  }
  int &ret = dp[x][y];
  if (ret != -1)
    return ret;

  if ((y - x + 1) % 2 == N % 2) {
    ret = max(dfs(x + 1, y) + a[x], dfs(x, y - 1) + a[y]);
  } else {
    ret = min(dfs(x + 1, y) - a[x], dfs(x, y - 1) - a[y]);
  }
  return ret;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  rep(i, 0, 3333) rep(j, 0, 3333) dp[i][j] = -1;
  cin >> N;
  rep(i, 0, N) { cin >> a[i]; }
  cout << dfs(0, N - 1) << endl;

  return 0;
}


Measured memory_bytes: 87168
N, X, Y = map(int, input().split())

graph = [[] for _ in range(N)]
for i in range(N - 1):
    graph[i].append(i + 1)
    graph[i + 1].append(i)
#
graph[X - 1].append(Y - 1)
graph[Y - 1].append(X - 1)

import heapq

# d_l = [None] * N
# q = [(0, 0)]
# while len(q) > 0:
#     dist, src = heapq.heappop(q)
#     for dst in graph[src]:
#         dist_tmp = dist + 1
#         if d_l[dst] > dist_tmp:
#             d_l[dst] = dist_tmp
#             q.append((dist_tmp, dst))

# d_r = [None] * N
# q = [(0, N - 1)]
# while len(q) > 0:
#     dist, src = heapq.heappop(q)
#     for dst in graph[src]:
#         dist_tmp = dist + 1
#         if d_r[dst] > dist_tmp:
#             d_r[dst] = dist_tmp
#             q.append((dist_tmp, dst))

dist = [[None] * N for _ in range(N)]
for i in range(N):
    for j in range(i, N):
        val = abs(i - j)
        dist[i][j] = val
        val = abs((X - 1) - i) + 1 + abs((Y - 1) - j)
        dist[i][j] = min(dist[i][j], val)
        val = abs((Y - 1) - i) + 1 + abs((X - 1) - j)
        dist[i][j] = min(dist[i][j], val)

cnt = [0] * (N * N + 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        cnt[dist[i][j]] += 1

for i in range(1, N):
    print(cnt[i])

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

int main() {
  int n; cin >> n;
  vector<int>a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  vector<int>check(n+1);
  check.at(0)=0;
  for (int i = 0; i < n-1; i++) {
    if(a.at(i) < a.at(i+1)) check.at(i+1) = 1;
    else check.at(i+1) = 0;
  }
  if (a.at(n-1) >= a.at(n-2)) check.at(n) = 0;

  long long ans = 1000;
  long long kabu = 0;
  for (int i = 1; i <= n; i++) {
    if (check.at(i-1) == 0 && check.at(i) == 1) {
      kabu = ans / a.at(i-1);
      ans -= a.at(i-1) * kabu;  
    }
    if (check.at(i-1) == 1 && check.at(i) == 0) {
      ans += a.at(i-1) * kabu;
      kabu = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632