akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<ll> A(N), B(N);
    vector<pair<ll, int>> v;


    REP(i, N) {
        cin >> A[i] >> B[i];
    }
    sort(ALL(A));
    sort(ALL(B));

    if (N % 2) {
        int i = (N + 1) / 2 - 1;
        print(B[i] - A[i] + 1);
    } else {
        int i1 = N / 2 - 1, i2 = N / 2;
        print(B[i2] + B[i1] - A[i2] - A[i1] + 1);
    }
    
}


Measured memory_bytes: 6368
import math
import sys

def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

def f(n):
    return int(n)//2

n,m=map(int,input().split())
a=list(map(f,input().split()))


tmp=1
for i in range(n):
    tmp=(tmp*a[i])//gcd(tmp,a[i])
    if tmp>m:
        print(0)
        sys.exit()


for i in range(n):
    if (tmp//a[i])%2==0:
        print(0)
        sys.exit()

ans=m//(tmp*2)
if m%(tmp*2)>=tmp: ans+=1
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX_K = 1000000000000000000LL;
const ll INF = MAX_K * 2;

int N;
char S[2010];
ll K;
pll dp[2010][2010];

pll dfs(int head, int tail){
  if(dp[head][tail].first >= 0) return dp[head][tail];
  pll res;
  if(head == tail) res = make_pair(1, 1); // 26???????????????
  else if(head > tail) res = make_pair(0, 1);
  else{
    // ?????????????°???????????????????????????????, ?????????????¨??????????
    // ????????§??????10^18(MAX_K)????¶??????????, INF????????°????????????
    if(S[head] == S[tail]){
      // ????????´???, ??????????????????
      res = dfs(head + 1, tail - 1);
      res.first += 2;
    }
    else{
      // head???tail?????????????????????????????????????????¢??¨??????
      // ?????????????????????????????????. ????????´?????????????????????????????????
      pll tmp1 = dfs(head + 1, tail);
      pll tmp2 = dfs(head, tail - 1);
      if(tmp1.first == tmp2.first){
        res = make_pair(tmp1.first + 2, tmp1.second + tmp2.second);
        // INF????????°??????????????????
        if(res.second > MAX_K) res.second = INF;
      }
      else{
        res = min(tmp1, tmp2);
        res.first += 2;
      }
    }
  }
  return dp[head][tail] = res;
}

// DP??????????????????, K?????????palindrome???????????????
void solve(int head, int tail, ll K, string &ans){
  if(head == tail || head > tail){
    if(K != 0) cout<<"NONE"<<endl;
    else{
      string suffix = ans;
      reverse(suffix.begin(), suffix.end());
      if(head == tail) ans += S[head];
      ans += suffix;
      cout<<ans<<endl;
    }
  }
  else{
    // ??????
    if(S[head] == S[tail]){
      ans += S[head];
      solve(head + 1, tail - 1, K, ans);
    }
    else{
      pll tmp1 = dfs(head + 1, tail);
      pll tmp2 = dfs(head, tail - 1);
      // ?°?????????????????????????????????????????????????????????????
      if(tmp1.first < tmp2.first){
        ans += S[head];
        solve(head + 1, tail, K, ans);
      }
      else if(tmp1.first > tmp2.first){
        ans += S[tail];
        solve(head, tail - 1, K, ans);
      }
      else{
        // S[head]??¨S[tail]??§, ???????????§?°?????????????????????????
        if(S[head] < S[tail]){
          if(tmp1.second <= K){
            ans += S[tail];
            solve(head, tail - 1, K - tmp1.second, ans);
          }
          else{
            ans += S[head];
            solve(head + 1, tail, K, ans);
          }
        }
        else{
          if(tmp2.second <= K){
            ans += S[head];
            solve(head + 1, tail, K - tmp2.second, ans);
          }
          else{
            ans += S[tail];
            solve(head, tail - 1, K, ans);
          }
        }
      }      
    }
  }
}

int main(){

  cin>>S;
  N = strlen(S);
  cin>>K;
  // DP??§, ????°????palindrome??¨, ???????????°????¨????
  for(int i = 0;i < 2010; i++)
    for(int j = 0;j < 2010; j++)
      dp[i][j] = make_pair(-1, -1);

  string ans;
  solve(0, N - 1, K - 1, ans);
  
  return 0;
}

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

int main(void)
{
    int n, x;
    scanf("%d %d", &n, &x);
    int m[n];
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d", &(m[i]));
    }
    int remain = x;
    for (size_t i = 0; i < n; i++)
    {
        remain -= m[i];
    }
    sort(m, m + n);
    printf("%d\n", n + remain / m[0]);
    return 0;
}

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

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int cityCount = inpt[0];
        int roadCount = inpt[1];

        int[] cnt = new int[cityCount + 1];

        for (int i = 0; i < roadCount; i++)
        {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            cnt[inpt[0]]++;
            cnt[inpt[1]]++;
        }
        for (int i = 1; i <= cityCount; i++)
        {
            Console.WriteLine(cnt[i]);
        }


    
    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

2 5
1 2
2 1
1 2
2 1
1 2



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long A = scn.nextLong();
		long B = scn.nextLong();
		long C = scn.nextLong();
		long X = scn.nextLong();
		long Y = scn.nextLong();
		long ans = Long.MAX_VALUE;
		for(long i = 0;i <= Math.max(X, Y);i++) {
			ans = Math.min(ans, A * Math.max(0,X-i) + B * Math.max(0,(Y-i)) + C * 2 * i);
		}
		System.out.println(ans);
	}

}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        char si = '0' + i;
        int index1 = find(s.begin(), s.end(), si) - s.begin();
        if (index1 == n) {
            continue;
        }
        for (int k = 0; k < 10; k++) {
            char sk = '0' + k;
            int index2 = find(s.begin() + index1 + 1, s.end(), sk) - s.begin();
            if (index2 == n) {
                continue;
            }
            for (int l = 0; l < 10; l++) {
                char sl = '0' + l;
                if (find(s.begin() + index2 + 1, s.end(), sl) != s.end()) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}

LL a[N],b[N];

int add(LL x){
	for(int i=60;i>=0;i--){
		if(getplc(x,i)){
			if(!a[i]){
				a[i]=x;
				return 1;
			}
			else x^=a[i];
		}
	}
	return 0;
}

char s[N];

void Solve(){
	int cas;
	for(cin>>cas;cas--;){
		int n;
		cin>>n;
		rep(i,1,n){
			cin>>b[i];
		}
		cin>>s+1;

		int ans=0;
		per(i,1,n){
			if(add(b[i])&&s[i]=='1'){
				ans=1;
				break;
			}
		}

		cout<<ans<<'\n';
		for(int i=0;i<=60;i++)a[i]=0;
	}
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3532
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static int function(int n) {
        if (n % 2 == 0) {
            return n / 2;
        }
        return 3 * n + 1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int a = 0;
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i < 1000000; i++) {
            if (i == 1) {
                a = s;
                list.add(a);
                continue;
            }
            a = function(a);
            for (int j = 0; j < i - 1; j++) {
                if (a == list.get(j)) {
                    System.out.println(i);
                    return;
                }
            }
            list.add(a);
        }
    }

}


Measured memory_bytes: 23380
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++

//C++で提出


// cin >>n;     scanf(入力)
// cout <<k;    printf(出力)
// cout <<k<<endl;   (kを出力して改行)
// string s="AAA";    s.size() =3    (sのサイズ)
// vector <int> a;  配列a(サイズは0)
// a.push_back(10); 配列のサイズが一つ増えて一番後ろに10を代入
// A.pop_back();  最後の要素が消去される
// A.begin() 　配列Aの最初の要素　
// sort(A.begin(),A.end());  配列Aの最初の要素から最後の要素(/.)までを小さい順に並び替えてa[0]から代入していく
// reverse(A.begin(),A.end());  配列Aの最初の要素から最後の要素(/.)までを逆の順にしてa[0]から代入していく
// s.substr(3,2)  配列s[3]から2個の文字を抜き出した文字列 (s[3]とs[4])



int main()
{
	string s;

	cin >> s;

	for (int i = 0; i < s.size() - 1; i++) {
		if (s.substr(i, 2) == "AC") {
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
	return 0;



	


}






Measured memory_bytes: 256
# AtCoder Beginner Contest 123
# https://atcoder.jp/contests/abc123
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    tk = lambda i, j, k: '%d %d %d' % (i, j, k)
    X, Y, Z, K = i2nn()
    A = i2nn()
    B = i2nn()
    C = i2nn()
    A.sort()
    A.reverse()
    B.sort()
    B.reverse()
    C.sort()
    C.reverse()
    dic = {}
    fin = set()
    def put(i, j, k):
        if i >= X or j >= Y or k >= Z:
            return
        key = tk(i, j, k)
        if key in fin:
            return
        if key not in dic:
            dic[key] = (A[i] + B[j] + C[k], key, i, j, k)
    put(0, 0, 0)
    for _ in range(K):
        v = max(dic.values(), key=lambda v: v[0])
        dic.pop(v[1])
        fin.add(v[1])
        put(v[2]+1, v[3],   v[4]  )
        put(v[2],   v[3]+1, v[4]  )
        put(v[2],   v[3],   v[4]+1)
        print(v[0])

main()

Measured memory_bytes: 4640
($N,$K)=glob<>;
@V=glob<>;
for$i(-1..$N-1){
	for$j($i+1..$N){
		@_=sort{$a-$b}@V[0..$i,$j..$N-1];
		if(@_<=$K){
			$-=$K-@_;$x=0;$x+=/-/&&$---?0:$_ for@_;
			$\+=$-=$x-$\
		}
	}
}
print


Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sstream>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#define maxsize 100000
#define ERROR -2
#define OK 1
#define maxi 100000
using namespace std;
typedef long long ll;
void f(int i,int a[9])
{
      if(i<3200)
         a[i/400]++;
      else
        a[8]++;
}
int main()
{
    int n,a[9],i,j,sum;
    while(scanf("%d",&n)==1)
    {
        memset(a,0,9*sizeof(a[0]));
        for(i=0;i<n;i++)
            {
                scanf("%d",&j);
                f(j,a);
            }
        for(i=0,sum=0;i<8;i++)
        {
            if(a[i]>0)
                sum++;
        }
        if(sum==0&&a[8]>0)
            printf("%d %d\n",1,a[8]);
        else
        printf("%d %d\n",sum,sum+a[8]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 100000;
vector<pii>vec;
int fa[MAXN + 5];
int find(int x) {
	return fa[x] = (fa[x] == x ? x : find(fa[x]));
}
void unite(int x, int y) {
	int fx = find(x), fy = find(y);
	if( fx != fy )
		fa[fx] = fy;
}
int N, Q; ll M;
int main() {
	scanf("%d%lld%d", &N, &M, &Q);
	for(int i=1;i<=N;i++) fa[i] = i;
	for(int i=1;i<=Q;i++) {
		int A, B, C; scanf("%d%d%d", &A, &B, &C), A++, B++;
		if( C == 0 ) unite(A, B);
		else vec.push_back(make_pair(A, B));
	}
	int cnt = 0;
	for(int i=1;i<=N;i++)
		if( find(i) == i ) cnt++;
	ll P = N - cnt, mx = 1LL*(cnt - 1)*cnt/2 + P;
	if( mx < M ) {
		puts("No");
		return 0;
	}
	ll mn = (vec.empty() ? N - 1 : N);
	if( mn > M ) {
		puts("No");
		return 0;
	}
	for(int i=0;i<vec.size();i++)
		if( find(vec[i].first) == find(vec[i].second) ) {
			puts("No");
			return 0;
		}
	puts("Yes");
}

Measured memory_bytes: 1784
def main():
    H, W = map(int, input().split())
    s = []
    for _ in range(H):
        S = input()
        s.append(S)
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1 if s[0][0] == '#' else 0
    for i in range(1, W):
        dp[0][i] = dp[0][i-1] + 1 if s[0][i] == '#' and s[0][i-1] == '.' else dp[0][i -1]
    for i in range(1, H):
        dp[i][0] = dp[i-1][0] + 1 if s[i][0] == '#' and s[i-1][0] == '.' else dp[i-1][0]
    for i in range(1, H):
        for j in range(1, W):
            if s[i][j] == '.':
                dp[i][j] = min(dp[i][j-1], dp[i-1][j])
            else:
                u = dp[i-1][j]
                r = dp[i][j-1]
                if s[i-1][j] == '.':
                    u += 1
                if s[i][j-1] == '.':
                    r += 1
                dp[i][j] = min(u, r)
    return dp[-1][-1]
print(main())


Measured memory_bytes: 3188
parseInt(x) = parse(Int,x)

function main()
    n, x = map(parseInt, split(readline()))
    a = map(parseInt, split(readline()))

    ans = 1
    d = 0
    for i in 1:n
        d += a[i]
        if d > x
            break
        end
        ans += 1
    end
    println(ans)
end

main()


Measured memory_bytes: 110284
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{
	int n,ans=0;
	cin >> n;
	vector<int> d(n);

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

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			ans += d.at(i)*d.at(j);
		}
	}
	cout << ans << endl;

	return 0;
}



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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

int main() {
	
	fastio;
    
    rd2(string, a, b);
    if(b.size() - a.size() > 1) {
        cout << "No";
        return 0;
    }
    
    for(int i = 0; i < a.size(); i++) {
        if(a[i] != b[i]) {
            cout << "No";
            return 0;
        }
        
    }
    
    cout << "Yes";
    return 0;
    
    
    
    
}

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

int main() {
    int n,T;
    cin >> n >> T;
    int ans = 1001001001;
    rep(i,n) {
        int c,t;
        cin >> c >> t;
        if(t > T) continue;
        ans = min(ans,c);
    }
    if(ans == 1001001001) cout << "TLE" << endl;
    else cout << ans << endl;
}

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

int main()
{
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    if((a==b)||(b==c)||(c==d)){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	cout << pow(n, 3);
	return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a,b,m;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if((a-b)&1) puts("Borys");
	else puts("Alice");
	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 K = sc.nextInt(), T = sc.nextInt();
        int[] A = new int[T];
        for (int i=0;i<T;i++){
            A[i] = sc.nextInt();
        }
        int M = 0;
        for (int i=0;i<T;i++){
            M = Math.max(M, A[i]);
        }
        System.out.println(Math.max(M-1-(K-M), 0));
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb 	push_back
#define ll  long long
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define debug(x) cerr<<#x<<" =: "<<x<<endl;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Find find_by_order
#define Order order_of_key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 mrand(random_device{}());
ll rnd(ll x) { return mrand() % x;}
ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;while(b){if(b&1) ans=ans*a%mod;b>>=1;a=a*a%mod;}return ans;}
ll phi(ll n){ll ans=n;for(ll i=2;i*i<=n;i++){if(n%i==0) {while(n%i==0) n/=i;ans=ans*(i-1)/i;}}if(n>1) ans=ans*(n-1)/n;return ans;}
//head

const int maxn=2e3+7;

string ss[maxn];

ll solve(ll T){
	int h,w,k;
	cin>>h>>w>>k;
	int ans=0;
	for(int i=0;i<h;i++) cin>>ss[i];
	for(int S=0;S<(1<<h);S++){
		for(int t=0;t<(1<<w);t++){
			int res=0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(S&(1<<i)||t&(1<<j)) ;
					else res+=ss[i][j]=='#';
				}
			}
			ans+=res==k;
		}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll T=1;
//    cin>>T;
    for(ll cas=1; cas<=T; cas++) {
        solve(T);
    }
	return 0;
}


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

using namespace std;

// ABC104-A - Rated for Me
int main()
{
    int R;
    cin >> R;

    string ans =
        (R < 1200) ? "ABC" :
        (R < 2800) ? "ARC" : "AGC";
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = (N - 1) / 2;
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    int n,a,b;
    cin>>n>>a>>b;
    a*=n;
    cout<<min(a,b)<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <map>
#include <functional>
#include <math.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

bool compare(pii a, pii b) {
  return a.second > b.second;
}

vector<pii> solve(vi& v) {
  map<int, int> mapka;

  for (auto& it : v) {
    mapka[it]++;
  }

  vector<pii> occurence(mapka.begin(), mapka.end());
  sort(occurence.begin(), occurence.end(), compare);

  return occurence;
}


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

  vector<int> f(n/2);
  vector<int> g(n/2);

  for (int i=0;i<n/2;++i)
    scanf("%d %d", &f[i], &g[i]);


  vector<pii> first = solve(f);
  vector<pii> second = solve(g);

  if (first.size() > second.size()) {
    vector<pii> tmp = first;
    first = second;
    second = tmp;
  }

  if (first.size() == 1) {
    int ans = 0;
    if (second.size() == 1) {
      if (first[0].first == second[0].first) 
        ans += n/2;
    } else {
      if (first[0].first == second[0].first)
        ans += n/2 - second[1].second;
      else
        ans += n/2 - second[0].second;
    }
    printf("%d", ans);
  } else {
    int ans = 0;
    if (first[0].first == second[0].first) {
      ans = min(n/2 - first[0].second + n/2 - second[1].second, n/2 - first[1].second + n/2 - second[0].second);
    } else
      ans = n/2 - first[0].second + n/2 - second[0].second;

    printf("%d", ans);
  }


  return 0;
}


Measured memory_bytes: 3712
import queue 
q=queue.Queue() 
n=int(input()) 
q.put(1)
q.put(2)
q.put(3)
q.put(4)
q.put(5)
q.put(6)
q.put(7)
q.put(8)
q.put(9) 
j=1 
while j<n:
    x=q.get() 
    if x%10!=0:
        q.put(10*x + x%10 -1)
    q.put(10*x+x%10)
    if x%10!=9:
        q.put(10*x +x%10 +1 )
    j+=1 
print(q.get())

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

#define N 100000
#define MAX 1000000000000000000

int main (void)
{
    char s[4];

    scanf("%s", s);

    if ('a' <= s[0] && 'z' >= s[0]) {
        puts("a");
    } else {
        puts("A");
    }

    return 0;
}


Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    //abピザをk枚買ったとき、aピザはmax(x - k,0),bピザはmax(y-k,0)
    int ans = INT_MAX;
    for(int i = 0; i < (int)1e5+1; i++){
        ans = min(ans,2*c*i+a*max(x-i,0)+b*max(y-i,0));
    }
    cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,m;
    cin >> n >> m;
    string a[51],b[51];
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    rep(y,n-m+1){
        rep(x,n-m+1){
            bool ok = true;
            rep(i,m){
                rep(j,m){
                    if(a[y+i][x+j] != b[i][j]) ok = false;
                }
            }
            if(ok){
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long int a,b;
	long int sum = 0;
	int digits = 0;
	int i;
	
	
	for(i=0; i<200; i++){
		scanf("%ld%ld",&a,&b);
		sum = a + b;
		
		//何も入力されない場合、ループを抜ける
		if(a == -1)
			break;
		
		//桁数をカウントする
		while(sum > 0){
			digits++;
			sum = sum / 10; 
		}
		
		printf("%d\n",digits);
		
		//初期化
		digits = 0;
		
		//入力の終わり判定に使う
		a = -1;
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;
    
    vll price(4);
    price[0] = q;
    price[1] = min({q*2, h});
    price[2] = min({q*4, h*2, s});
    price[3] = min({q*8, h*4, s*2, d});

    ll ans = 0;
    for (int i = 3; i >= 0; i--) {
        double l = 2.0/(4-i);
        ans += (ll)(n/l) * price[i];
        n -= (ll)(n/l) * l;
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8'));
  const cache = [1, 1];
  const fib = (n) => cache[n] || (cache[n] = fib(n - 1) + fib(n - 2));
  console.log(fib(n));
})();



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->

bool issqr(int a)
{
  for(int i=1; i<=10000; i++)
  {
    if(i*i == a)
    {
      return true;
      break;
    }
  }

  return false;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

   string a,b;
   cin>>a>>b;

   int ans = stoi(a+b);

   if(issqr(ans))
   {
    cout<<"Yes";
   }

   else
   {
    cout<<"No";
   }



}


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

int main() {
  int N,K,x;
  cin >> N >>K;
  int L=0;
  
  for (int i=0;i<N;i++){
    cin >> x;
    if (x < K-x){
      L += 2*x;
    }
    else{
      L += 2*K-2*x;
    }
  }
  cout << L << endl;
}

Measured memory_bytes: 256
dis = []
dist = [0,0,0,0,0]

for i in range(5):
    dis.append(int(input()))
    a = dis[i] % 10
    if a!=0:
        dist[i] = 10-a
        dis[i] = dis[i]+dist[i]

b = dist.index(max(dist))
print(sum(dis)-dist[b])




Measured memory_bytes: 3060
s = input()

f = (0 < int(s[:2]) < 13)
s = (0 < int(s[2:]) < 13)
ans = 'NA'
if f and s:
    ans = 'AMBIGUOUS'
elif s:
    ans = 'YYMM'
elif f:
    ans = 'MMYY'
print(ans)


Measured memory_bytes: 61836
#include<iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int work;
	work = a;
	a = b;
	b = work;
	work = a;
	a = c;
	c = work;
	cout << a << " " << b << " " << c << "\n";
	return 0;
}


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

int main(){
  int N, c=0;
  int A[111];
  cin >> N;
  for(int i = 0; i <= N; ++i) cin >> A[i];
  
  for(int i = -1; i <= N; ++i){
    if(i % 2 == 0){
      if(A[i] % 2 != 0){
        c = c + 1;
      }
      else{
        c = c + 0;
      }
    }
  }
  cout << c << endl;
}

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

// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] - 1 > sqrt(n)) {
            sum += v[i] - 1;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    int n; cin >> n;
    deque<ll> as(n); 
    rep(i, n) cin >> as[i];
    sort(all(as));
    ll l, r;
    ll ans = 0;
    while (!as.empty()) {
        if (as.size() == 1) {
            ll m = as.front();
            as.pop_back();;
            ans += max(r-m, m-l);
            break;
        }
        ll l2 = as.front(), r2 = as.back();
        if (as.size() == n) {
            ans += r2 - l2;
        } else {
            ans += r2 - l; 
            ans += r - l2;
        } 
        l = l2; 
        r = r2; 
        as.pop_back(); as.pop_front();

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

Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            
            System.out.println(Math.min(a, b) + " " + Math.max(0, a+b-n));
        }
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int G = 1, n;
int c[101][101], d[101]={0};
int first[101], second[101];

void DFS(int u);

int main(){
  int i, j, k, u, v;
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      c[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      c[u-1][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    if(d[i] == 0){
      DFS(i);
    }
  }

  for(i = 0; i < n; i++){
    printf("%d %d %d\n", i+1, first[i], second[i]);
  }
  return 0;
}

void DFS(int u){
  int v; 
  first[u] = G++;
  d[u] = 1;
  for(v = 0; v < n; v++){
    if(c[u][v]==1 && d[v]==0){ 
      DFS(v);
    }
  }   
  second[u] = G++;  
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD9, b / 2) % MOD9;
//     else return a * POW(a * a % MOD9, b / 2) % MOD9;
//   }
// }

int main(){
  string N;
  cin >> N;
  int s = ctoi(N[N.length()-1]);
  string ans;
  if(s==0) ans = "pon";
  else if(s==1) ans = "pon";
  else if(s==2) ans = "hon";
  else if(s==3) ans = "bon";
  else if(s==4) ans = "hon";
  else if(s==5) ans = "hon";
  else if(s==6) ans = "pon";
  else if(s==7) ans = "hon";
  else if(s==8) ans = "pon";
  else if(s==9) ans = "hon";
  cout << ans << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int res = 0;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    while (a % 2 == 0) {
      res++;
      a /= 2;
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
def get_dp(dp,h,n):
    for i in range(1,n,1):
        if i == 1:
            tmp1 = abs(h[i] - h[i-1])
            dp[i] = tmp1
        else:
            tmp1 = abs(h[i] - h[i-1]) + dp[i-1]
            tmp2 = abs(h[i] - h[i-2]) + dp[i-2]
            dp[i] = min(tmp1,tmp2)

    return dp[n-1]

def main():
    n = int(input())
    h = list(map(int,input().split()))
    dp = [0]*(n)
    print(get_dp(dp,h,n))

main()


Measured memory_bytes: 20448
from sys import stdin,stdout
N,K,S = map(int,stdin.readline().split())
A = [0 for i in range(N)]
waste = N - K
wasteval = 1000000000 if S != 1000000000 else 999999999
for i in range(waste):A[i] = wasteval
for i in range(waste,N):A[i] = S
[print(i,end=' ') for i in A ]

Measured memory_bytes: 6184
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,a;
    cin >> n;
    int x[n];
    for(int i=0; i<n; i++){
        cin >>a;
        x[i]=a;
    }
    for(int j=0; j<n; j++){
        if (j>=1) printf(" ");
        printf("%d", x[n-j-1]);
    }
    printf("\n");
}


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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int n, a[100], r;
	double s = 0, m = 1e9;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &a[i]);
		s += a[i];
	}
	s /= n;
	for (i = n - 1; i >= 0; i--) {
		if (m >= fabs(s - a[i])) {
			m = fabs(s - a[i]);
			r = i;
		}
	}
	printf("%d", r);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
      long c = sc.nextLong();
      if(a%2==0)System.out.println(0);
      else if(b%2==0)System.out.println(0);
      else if(c%2==0)System.out.println(0);
      else{
      	long x = Math.max(a,Math.max(b,c));
        long y = Math.min(a,Math.min(b,c));
        long z = a+b+c-x-y;
        System.out.println(y*z);
      }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;

int main () {
    string s; cin >> s;
    if (s == "SUN") cout << "7" << endl;
    if (s == "MON") cout << "6" << endl;
    if (s == "TUE") cout << "5" << endl;
    if (s == "WED") cout << "4" << endl;
    if (s == "THU") cout << "3" << endl;
    if (s == "FRI") cout << "2" << endl;
    if (s == "SAT") cout << "1" << endl;
    return 0;
}

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

using namespace std;

int main(void){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  
  for(int i = 0; i < (ty - sy); i++){
    printf("U");
  }
  
  for(int i = 0; i < (tx - sx); i++){
    printf("R");
  }
  
  for(int i = 0; i < (ty - sy); i++){
    printf("D");
  }
  
  for(int i = 0; i < (tx - sx); i++){
    printf("L");
  }
  
  printf("D");
  
  for(int i = 0; i < (tx+1) - sx; i++){
    printf("R");
  }
  
  for(int i = 0; i < ty - (sy-1); i++){
    printf("U");
  }
  
  printf("L");
  
  printf("U");
  
  for(int i = 0; i < (tx+1) - sx; i++){
    printf("L");
  }
  
  for(int i = 0; i < ty - (sy-1); i++){
    printf("D");
  }
  
  printf("R");
    
  printf("\n");
  return 0;
}


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

int main(){
  int N,X; cin >> N >> X;
  int len=0;
  for(int i=1; i<=N; i++){
    int tmp; cin >> tmp;
    if(len+tmp>X){
      cout << i << endl;
      return 0;
    }
    len+=tmp;
  }
  cout << N+1 << endl;
}

Measured memory_bytes: 256
S = str(input())
N = len(S)
ans = N//2

while ans < N:
  K = ans+1
  start = N-K
  end = K-1
  leng = end-start+1
  C = str(S[start:end+1])
  #print(start,end,C,"0"*leng,"1"*leng)
  if C == "0"*leng or C == "1"*leng:
    ans += 1
  else:
    #print("unko")
    break
print(ans)

Measured memory_bytes: 9216
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9+7;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;
 
ll power(ll n,ll k,ll m){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%m;
        k/=2;
        n=(n*n)%m;
    }
    return ans;
}



int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll T=1;//cin>>T;
    
    while(T--){
        ll k,n;cin>>k>>n;
        ll a[n];
        forn(i,n)cin>>a[i];
        sort(a,a+n);
        vector<ll> v;
        forn1(i,n){
            v.pb(a[i]-a[i-1]);
        }
        v.pb(a[0]+k-a[n-1]);

        sort(ALL(v));
        ll ans=0;
        forn(i,n-1)ans+=v[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3956
from itertools import*
def g():
 n=int(input())
 a=[[s for s in input().split()]for _ in range(n)]
 for b in a:
  b[3:5]=b[4],b[3]
 t=0
 for d,e in combinations(a,2):
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(i)]for i in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:t=1
 print(['Yes','No'][t])
g()


Measured memory_bytes: 5664
#include <stdio.h>

int main() {
  int n, a[55], sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j < i; j++) {
      sum += (a[i] * a[j]);
    }
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String inputString = scanner.nextLine();
		String[] strStdIn = inputString.split(" ", 0);
		List<String> list = Arrays.asList(strStdIn);
		List<Integer> intList = new ArrayList<>();
		
		list.forEach(str -> intList.add(Integer.parseInt(str)));
		
		Collections.sort(intList);
		
		int min0 = intList.get(0);
		int min1 = intList.get(1);
		
		System.out.println(min0 + min1);
		
	}
}

Measured memory_bytes: 26964
using System;
using System.Collections.Generic;

namespace ALDS1_3_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var stack = new Stack<string>();
            foreach (var item in Console.ReadLine().Split(' ')) stack.Push(item);
            Console.WriteLine(Calc(stack));
        }

        static int Calc(Stack<string> stack)
        {
            var top = stack.Pop();
            int a, b;
            switch (top)
            {
                case "+": b = Calc(stack); a = Calc(stack); return a + b;
                case "-": b = Calc(stack); a = Calc(stack); return a - b;
                case "*": b = Calc(stack); a = Calc(stack); return a * b;
                default:return int.Parse(top);
            }
        }
    }
}

Measured memory_bytes: 10160
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 998244353
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010, M=1000005;
ll n,k, a[N], res;
int main()
{
    in1(n);
    k=3*n;
    for(int i=0;i<k;i++)
        in1(a[i]);
    sort(a, a+k);
    for(int i=k-2,j=0; j<n && i>=0;i-=2,j++)
    {
        res+=a[i];
    }
    printf("%lld\n",res);
    return 0;
}
/*

*/


Measured memory_bytes: 2560