akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <functional>
using namespace std;

vector<int> Centroid(int root, const vector<vector<int>> &g, const vector<bool> &dead) {
        int alive_cnt = 0;
        map<int, int> alive_node;
        { 
                function<void (int, int)> count_alive = [&](int u, int prev) {
                        alive_node[u] = alive_cnt ++;
                        for (auto v : g[u]) if (v != prev && !dead[v]) {
                                count_alive(v, u);
                        }
                };
                count_alive(root, -1);
        }
        vector<int> centroid;
        vector<int> sz(alive_cnt);
        function<void (int, int)> dfs = [&](int u, int prev) {
                int x = alive_node[u];
                sz[x] = 1;
                bool is_centroid = true;
                for (auto v : g[u]) if (v != prev && !dead[v]) {
                        dfs(v, u);
                        int y = alive_node[v];
                        sz[x] += sz[y];
                        if (sz[y] > alive_cnt / 2) is_centroid = false;
                }
                if (alive_cnt - sz[x] > alive_cnt / 2) is_centroid = false;
                if (is_centroid) centroid.push_back(u);
        };
        dfs(root, -1);
        return centroid;
}

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<int>> g(n);
        vector<vector<pair<int ,int>>> gg(n);
        for (int i = 0; i < n - 1; i ++) {
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
                gg[a].emplace_back(b, c);
                gg[b].emplace_back(a, c);
        }
        long long ans = 0;
        vector<int> sz(n);
        function<void (int, int)> dfs = [&](int u, int prev) {
                sz[u] = 1;
                for (auto e : gg[u]) {
                        int v = e.first, cost = e.second;
                        if (v == prev) continue;
                        dfs(v, u);
                        sz[u] += sz[v];
                        ans += min(sz[v], n - sz[v]) * (long long) 2 * cost;
                }                                 
        };
        dfs(0, -1);
        vector<bool> dead(n);
        auto centroid = Centroid(0, g, dead);
        if (centroid.size() == 1) {
                int mi = 0x3f3f3f3f;
                for (auto e : gg[centroid[0]]) {
                        mi = min(mi, e.second);
                }
                ans -= mi;
        } else {
                for (auto e : gg[centroid[0]]) {
                        if (e.first == centroid[1]) {
                                ans -= e.second;
                                break;
                        }
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int f = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x & 1) f = 1;
    }
    cout << (f ? "first" : "second") << endl;
    return 0;
}

Measured memory_bytes: 384
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL num[500005];
LL pos[500005];
LL dia[500005];

int main()
{
	LL n, d;
	scanf("%lld %lld", &n, &d);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &num[i]);
	}

	pos[0] = 0;
	LL now = 0;
	for (int i = 1; i <= n; i++) {
		LL nxt;
		if (now > d) nxt = now - num[i];
		else nxt = now + num[i];
		if (ABS(nxt - d) < ABS(now - d)) now = nxt;
		pos[i] = now;
	}



	LL curSum = 0;
	dia[n + 1] = curSum;
	for (int i = n; i >= 1; i--) {
		if (num[i] <= 2 * curSum + 1) {
			curSum += num[i];
		}
		dia[i] = curSum;
	}

	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int u;
		scanf("%d", &u);
		if (pos[u - 1] == d) {
			printf("NO\n");
			continue;
		}

		LL diff = ABS(d - pos[u - 1]); // 1..diff
		// can I make all of 1..diff with num[u+1]...num[n]?
		if (diff <= dia[u + 1]) printf("NO\n");
		else printf("YES\n");

	}
	return 0;
}


Measured memory_bytes: 13696
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  unordered_map<ll, usll> R;
  REP(i, 0, M) {
    ll a, b;
    cin >> a >> b;
    if (R.find(a) == R.end()) {
      R.emplace(a, usll{b});
    } else {
      R[a].emplace(b);
    }
    if (R.find(b) == R.end()) {
      R.emplace(b, usll{a});
    } else {
      R[b].emplace(a);
    }
  }

  vll D(N + 1, -1);
  D[1] = 0;
  deque<pll> Q;
  for (const auto& r : R[1]) {
    D[r] = 1;
    Q.emplace_back(r, 1);
  }

  while (!Q.empty()) {
    ll x = Q[0].first;
    ll d = Q[0].second;
    Q.pop_front();

    for (const auto& r : R[x]) {
      if (D[r] != -1) {
        continue;
      }

      D[r] = x;
      Q.emplace_back(pll(r, d + 1));
    }
  }

  cout << "Yes" << endl;
  REP(i, 2, N + 1) {
    cout << D[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 32056
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.contains("RRR")) System.out.println(3);
        else if(s.contains("RR")) System.out.println(2);
        else if(s.contains("R")) System.out.println(1);
        else System.out.println(0);
    }
}

Measured memory_bytes: 35592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();
	int A[300][300];
	int R[300][300];
	rep(i, N) rep(j, M) {
		A[i][j] = getint();
		A[i][j]--;
		R[i][A[i][j]] = j;
	}

	bool C[300][310] = {};
	int doko[300] = {};
	int kotae = 1e9;
	rep(j, M) {
		int B[300] = {};
		rep(i, N) B[A[i][doko[i]]]++;
		auto saidaip = max_element(B, B + M);
		kotae = min(kotae, *saidaip);
		int kesu = saidaip - B;
		rep(i, N) {
			C[i][R[i][kesu]] = true;
			while (C[i][doko[i]]) doko[i]++;
		}
	}

	co(kotae);

	Would you please return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int ans = 0, num = 0;
	for(int i = 0;i < 3;i++){
		if(s[i] == 'R') num++;
		else{
			ans = max(num, ans);
			num = 0;
		}
	}
	ans = max(num, ans);
	cout<<ans<<'\n';
	return 0;
}
//ios_base::sync_with_stdio(false);
//cin.tie(0);
//tod-ngen


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

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var p = (int)1e9 + 7;
            var dict = new Dictionary<int, int>();
            for (var i = 0; i < N; i++)
            {
                if (!dict.ContainsKey(A[i])) dict[A[i]] = 0;
                dict[A[i]]++;
            }
            var ok = true;
            if (N % 2 == 0)
            {
                foreach (var x in dict)
                {
                    if (x.Key % 2 == 0) ok = false;
                    if (x.Value != 2) ok = false;
                }
            }
            else
            {
                var ZeroIs1 = dict[0] == 1;
                dict.Remove(0);
                var elements = true;
                foreach (var x in dict)
                {
                    if (x.Key % 2 == 1) elements = false;
                    if (x.Value != 2) elements = false;
                }
                ok = ZeroIs1 && elements;
            }
            var answer = 0L;
            if (ok)
            {
                answer = 1;
                for (var i = 0; i < N / 2; i++)
                {
                    answer *= 2;
                    answer %= p;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 37884
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int INF = 100000;
typedef pair<int, int> P;
int main()
{
    long long N;
    cin>>N;
    long long a[5];
    for(int i=0; i<5; i++){
        cin>>a[i];
    }
    sort(a,a+5);
    long long m=(N+a[0]-1)/a[0];
    cout<<4+m<<endl;
}


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

int main()
{
	long long int nn, tmp;
	scanf("%lld", &nn);
	long long int aa[nn - 1];
	for(int ii = 0;ii < (nn - 1);ii++)
	{
		aa[ii] = 0;
	}
	for(int ii = 0;ii < (nn - 1);ii++)
	{
		scanf("%lld", &tmp);
		aa[tmp - 1]++;
	}
	for(int ii = 0;ii < (nn - 1);ii++)
	{
		printf("%lld\n", aa[ii]);
	}
	puts("0\n");
	return 0;
}

Measured memory_bytes: 3292
#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;
    vector<pair<int,int>> xys;
    rep(i, n) {
        int x,y; cin >> x >> y;
        xys.emplace_back(x,y);
    }
    sort(all(xys));
    map<pair<int, int>, int> mp;
    int mxcount = 0;
    rep(i, n-1) {
        rng(j, i+1, n) {
            int dx = xys[j].first - xys[i].first;
            int dy = xys[j].second - xys[i].second;
            // cout << i << "," << j << "," << dx << "," << dy << endl;
            mxcount = max(mxcount, ++mp[{dx, dy}]);
        }
    }
    cout << n-mxcount << endl;
    return 0;
}

Measured memory_bytes: 384
fun main() {
    var (x, y) = readLine()!!.split(" ").map { it.toInt() }

    when {
        y == 0 -> println("No")
        x == 0 -> println("No")
        y < x -> println("No")
        y % 2 == 0 && y in x * 2.. x * 4 -> println("Yes")
        else -> println("No")
    }
}

Measured memory_bytes: 36392
def main():
    n, *a = map(int, open(0).read().split())

    a = [0] + a
    b = [0] * (n + 1)
    for i in range(1, n+1)[::-1]:
        if i * 2 > n:
            b[i] = a[i]
        else:
            rem = 0
            for j in range(i * 2 , n + 1, i):
                rem = rem ^ b[j]
            b[i] = rem ^ a[i]

    b = b[1:]
    m = sum(b)
    print(m)
    for i, cur_b in enumerate(b, start=1):
        if cur_b == 1:
            print(i, end=' ')
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 8364
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std;

long long my_abs(long long a){
    return a < 0 ? -a : a;
}


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
    
    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    if(my_abs(A-B)>1000000000000000000) cout << "Unfair" << endl;
    else {
        long long ans = A-B;
        if(K%2) ans *= -1;
        cout << ans << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define st_ct static_cast // <>
#define TEST uint _ {}; cin >> _; while (_--)
#define deb(x) cerr << #x << " -> " << x
#define deb2(x,y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ")"
#define deb3(x,y,z) cerr << "(" << #x << ", " << #y << ", " << #z << ") -> (" << x << ", " << y << ", " << z << ")"
#define debVV(V) cerr << #V << ":\n" << V << endl; // 2D

// 1D
template<typename T>
istream& operator>>(istream &is, vector<T> &A) {
    for (T &v: A)
        is >> v;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<T> &A) {
    for (T const &v: A)
        os << v << " ";
    return os;
}

template<typename T>
void vtrV(const vector<T> &A)
{ for (T const &val: A) cout << val << endl; }

// 2D
template<typename T>
istream& operator>>(istream &is, vector<vector<T>> &A) {
    for (vector<T> &i: A)
        for (T &j: i)
            is >> j;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            os << j << " ";
        os << endl;
    }
    return os;
}

template<typename T>
void vvtrNS(const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            cout << j;
        cout << endl;
    }
}

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }

const double PI {3.1415926535897932384626433832795};
const int MOD {static_cast<int>(1e9 + 7)};
const double EPS {1e-9};

/* -------------------------------------------------------- */
/* -------------------------------------------------------- */

//

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.setf(std::ios::boolalpha);
    cout<<std::fixed;
    cout<<std::setprecision(6); // default
    /* -------------------------------- */

    string s {};
    string t {};
    cin >> s >> t;
    if (!t.empty())
    	t.erase(s.size(), 1);
    // deb2(s, t) << endl;
    cout << (t == s ? "Yes": "No") << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<atcoder/all>
int main(){int n,q,t,u,v,i;std::cin>>n>>q;atcoder::dsu s(n);for(i=0;i<q;i++){std::cin>>t>>u>>v;if(t)std::cout<<s.same(u,v)<<std::endl;else s.merge(u,v);}}

Measured memory_bytes: 3468
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            if (Math.floor(i * 1.08) == n) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(":(");
    }

}

Measured memory_bytes: 21716
import sys
import os
import re
import datetime

card = {}

N = int(input())
for _ in range(N):
	s = input()
	if s in card:
		card[s] += 1
	else:
		card[s] = 1
		
M = int(input())
for _ in range(M):
	t = input()
	if t in card:
		card[t] -= 1
	else:
		card[t] = -1

maxCount = 0
#print(card)
for count in card:
	maxCount = max(maxCount, max(card.values()))

print(maxCount)


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 N;
    cin >> N;
    map<i64,i64> min_idx,count;
    vector<i64> num;
    rep(i,0,N){
        i64 a;
        cin >> a;
        num.push_back(a);
        ++count[a];
        if(min_idx.find(a)==min_idx.end()) min_idx[a]=i;
    }

    sort(num.begin(),num.end());
    num.erase(unique(num.begin(),num.end()),num.end());

    vector<i64> ans(N);
    for(int i=num.size()-1; i>=1; --i){
        i64 d=num[i]-num[i-1];
        ans[min_idx[num[i]]]+=d*count[num[i]];
        min_idx[num[i-1]]=min(min_idx[num[i-1]],min_idx[num[i]]);
        count[num[i-1]]+=count[num[i]];
    }
    ans[min_idx[num[0]]]+=num[0]*count[num[0]];

    rep(i,0,N) cout << ans[i] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 15092
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
	cin>>a;
	cin>>b;
	cin>>c;
	int con=1;
	int ad=a.size(),be=b.size(),cf=c.size();
	int d=0,e=0,f=0;
	while(true){
		if(con==1){
			if(ad==d){
				cout<<"A"<<endl;
				break;
			}
			else if(a[d]=='b'){
				con++;
			}
			else if(a[d]=='c'){
				con+=2;
			}
			d++;
		}
		else if(con==2){
			if(be==e){
				cout<<"B"<<endl;
				break;
			}
			else if(b[e]=='a'){
				con--;
			}
			else if(b[e]=='c'){
				con++;
			}
			e++;
			
		}
		else if(con==3){
			if(cf==f){
				cout<<"C"<<endl;
				break;
			}
			else if(c[f]=='a'){
				con-=2;
			}
			else if(c[f]=='b'){
				con--;
			}
			f++;
		}
	}
}


Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = 0
end
for i = 1, m * 2 do
  local a = io.read("*n")
  t[a] = t[a] + 1
end
for i = 1, n do print(t[i]) end


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

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int n = iin();
    iout(n * 800 - (int)(n / 15) * 200);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


Measured memory_bytes: 128
import Control.Applicative
import Data.List
import qualified Data.Set as Set

main = do
    n <- readLn
    list <- sequence (replicate n readLn)
    print $ solve n list

solve :: Int -> [Int] -> Int
solve n list = if mod s 10 /= 0 
                 then s
                 else (if x == [] then 0 else s - minimum x)
    where s = sum list
          x = filter (\y -> mod y 10 /= 0) list



Measured memory_bytes: 1020
N = int(input())
d = {}

for i in range(N):
  tmp = input()
  
  d[tmp] = d.get(tmp,0) + 1
  
m = max(d[i] for i in d)
max_list = [i for i in d if d[i] == m]

print("\n".join(sorted(max_list)))

Measured memory_bytes: 34140
fn main() {
    let _ = read::<i32>();
    let mut v = read_vec::<f64>();

    // 降順ソート
    v.sort_by(|a, b| a.partial_cmp(b).unwrap());

    let ans: f64 = v[1..].iter().fold(v[0], |sum, e| (sum + e) / 2.0);

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

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T  {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap())
    .collect()
}

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

int main() {
  int hi,lo,m,n,a,i,k,d[100];
  while(cin >> n && n!=0) {
	  for (i=0;i<n;i++) cin >> d[i];
	  cin >> a;
	  hi=n-1; lo=k=0;
	  while(hi>=lo) {
	  k++; m=(hi+lo)/2; 
	  if (d[m]<a) lo=m+1; else if (d[m]>a) hi=m-1; else break;
	  if (hi==lo) { k++; break;}
	   }
	  cout << k << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int ans = 0;
		for (int k = 0; k < 29; k++) {
			int m = 1 << (k + 1);
			int[] c = new int[n];
			for (int i = 0; i < n; i++) {
				c[i] = b[i] % m;
			}
			Arrays.sort(c);

			int min = m / 2;
			int max = m - 1;
			long cnt = 0;
			for (int i = 0; i < n; i++) {
				int ai = a[i] % m;
				int mina = min - ai;
				int maxa = max - ai;
				if (mina < 0) {
					mina += m;
					int idxc = ceiling(c, mina);
					cnt += n - idxc;
					int idxf = floor(c, maxa);
					cnt += idxf + 1;
				} else {
					int idxc = ceiling(c, mina);
					int idxf = floor(c, maxa);
					cnt += idxf - idxc + 1;
				}
			}
			if (cnt % 2 == 1) {
				ans += 1 << k;
			}
		}
		System.out.println(ans);
	}

	static int floor(int[] array, int val) {
		int ok = -1;
		int ng = array.length;
		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] <= val) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		return ok;
	}

	static int ceiling(int[] array, int val) {
		int ok = array.length;
		int ng = -1;
		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] >= val) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		return ok;
	}
}


Measured memory_bytes: 67680
#include<stdio.h>
int main(void){
    int i,len,p,u,y,e=0,g,r[6],s,m=0,q,z=0;
    char x[100];
    for(i=0;i<6;i++){
    	scanf("%d",&r[i]);
    }
    scanf("%d",&p);
    for(g=0;g<p;q++){
    	scanf("%d %d",&u,&y);
    	if(u==6&&y==2){
    		printf("4\n");
    		g++;
    	}else if(u==6&&y==4){
    		printf("5\n");
    		g++;
    	}else if(u==6&&y==5){
    		printf("3\n");
    		g++;
    	}else if(u==6&&y==3){
    		printf("2\n");
    		g++;
    		break;
    	}else{
    	while(r[0]!=u){
    	s=r[0];
    	r[0]=r[4];
    	r[4]=r[5];
    	r[5]=r[1];
    	r[1]=s;
    	m++;
    	if(m==7){
    		break;
    	}
    	}
    while(r[1]!=y){
    	s=r[1];
    	r[1]=r[2];
    	r[2]=r[4];
    	r[4]=r[3];
    	r[3]=s;
    	if(m==7){
    		while(r[0]!=u){
    	s=r[0];
    	r[0]=r[4];
    	r[4]=r[5];
    	r[5]=r[1];
    	r[1]=s;
    		}
    	}
    }
    	if(r[0]==u&&r[1]==y){
    		printf("%d\n",r[2]);
    		g++;
    	}
    	}
    }
    return 0;
}

Measured memory_bytes: 608
#include <iostream>

using namespace std;

int main(){
  int a[3][3];
  int N;
  int b[10];
  bool c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      c[i][j] = false;
    }
  }

  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> a[i][j];
    }
  }
  cin >> N;
  for(int k=0;k<N;k++){
    cin >> b[k];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(b[k] == a[i][j]){
          c[i][j] = true;
          i=3;
          j=3;
        }
      }
    }
  }

  bool bingo = false;

  //row
  for(int i=0;i<3;i++){
    bingo = c[i][0]*c[i][1]*c[i][2];
    if(bingo) break;
  }
  if(!bingo){
    for(int i=0;i<3;i++){
      bingo = c[0][i]*c[1][i]*c[2][i];
      if(bingo) break;
    }
  }
  if(!bingo){
    bingo = c[0][0]*c[1][1]*c[2][2]+c[2][0]*c[1][1]*c[0][2];
  }

  if(bingo){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  // bool a[3];
  // a[0] = true;
  // a[1] = false;
  // a[2] = false;

  // if(a[0]*a[1]*a[2] == true){
  //   cout << "True" << endl;
  // }else if(a[0]+a[1]+a[2] == true){
  //   cout << "hoge" << endl;
  // }else{
  //   cout << "none" << endl;
  // }


  return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n,m;cin>>n>>m&&n|m;){
		string s; cin>>s;
		vi ls(m),rs(m);
		rep(i,m) cin>>ls[i]>>rs[i],ls[i]--;

		{
			vector<tuple<int,int>> ts;
			int pl=-1,pr=-1;
			rep(i,m) if(pr<rs[i]){
				if(pl<ls[i])
					ts.emplace_back(ls[i],rs[i]);
				else
					ts.back()=mt(ls[i],rs[i]);
				tie(pl,pr)=ts.back();
			}
			int first=get<0>(ts[0]),last=get<1>(ts.back());
			s=s.substr(first,last-first);
			n=s.size();
			m=ts.size();
			ls.resize(m),rs.resize(m);
			rep(i,m){
				tie(ls[i],rs[i])=ts[i];
				ls[i]-=first,rs[i]-=first;
			}
		}

		vi zcount(n+1),ocount(n+1);
		rep(i,n){
			zcount[i+1]=zcount[i];
			ocount[i+1]=ocount[i];
			(s[i]=='0'?zcount:ocount)[i+1]++;
		}

		vvi dp(n+1,vi(n+1));  // [文字数]['0'の使用回数]
		dp[0][0]=1;

		ls.push_back(n);
		rep(k,m){
			repi(i,ls[k],min(rs[k],ls[k+1]))
				rep(j,i+1){
					if(j+1<=zcount[rs[k]])
						(dp[i+1][j+1]+=dp[i][j])%=MOD;
					if(i+1-j<=ocount[rs[k]])
						(dp[i+1][j]+=dp[i][j])%=MOD;
				}
			repi(i,rs[k],ls[k+1])
				rep(j,i+1){
					if(s[i]=='0')
						(dp[i+1][j+1]+=dp[i][j])%=MOD;
					else
						(dp[i+1][j]+=dp[i][j])%=MOD;
				}
		}

		cout<<dp[n][zcount[n]]<<endl;
	}
}


Measured memory_bytes: 35712
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int p[n+1];
  int count=0;
  for(int i=0;i<n;i++)
  scanf("%d",&p[i]);
  for(int i=0;i<n;i++){
    if(p[i]!=i+1){
      //printf("%d %d pi,i+1\n",p[i], i+1 );
      count++;
    }
    if(count>2){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, K;
    cin >> N >> K;

    --N; --K;
    cout << (N+K-1)/K << endl;
}

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

int main() {
  string s;
  cin >> s;

  for(char c='a'; c<='z'; c++) {
    if(std::count(s.begin(), s.end(), c) == 0) {
      cout << c << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 512
/*for better*/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define M 998244353
#define inf 1e9+10
using namespace std;

ll dp[100005];

int main()
{
    fast; 
    string s,t,ans="";
    int i,j,n,m;
    cin>>s>>t;
    n=s.size();
    m=t.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));

    f(i,1,n+1)
    	f(j,1,m+1)
    	{
    		if(s[i-1]==t[j-1])
    			dp[i][j]=dp[i-1][j-1]+1;
    		else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    		
    	}

    j=m;i=n;
    while(i>0 and j>0)
    {
   		if(dp[i][j]!=dp[i-1][j] and dp[i][j]!=dp[i][j-1])
   		{
   			ans+=s[i-1];
   			j--;i--;
   		}
   		else if(dp[i][j]==dp[i-1][j])
   			i--;
   		else if(dp[i][j]==dp[i][j-1])
   			j--;
   	}
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n,0),vv(n,0);
    vector<vector<ll> > ss(n);
    ll a,b;
    ll q=0;
    ll r=0;
    ll x;
    for(i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        v[a]++;
        v[b]++;
        ss[a].pb(b);
        ss[b].pb(a);
    }
    for(i=0;i<n;i++){
        if(v[i]%2==1){
            cout<<"No"<<endl;
            return 0;
        }
        if(v[i]>=4) {
            q++;
            vv[i]=1;
        }   
        if(v[i]>=6) r++;
    }

    if(r>=1){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(q<=1){
        cout<<"No"<<endl;
        return 0;
    }
    if(q>=3){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    
        for(i=0;i<n;i++){
            if(vv[i]==1) x=i;
        }
        for(i=0;i<ss[x].size();i++){
            ll p=ss[x][i];
            ll back=x;
            while(vv[p]==0){
                if(ss[p][0]==back) {
                    back=p;
                    p=ss[p][1];
                }
                else {
                    back=p;
                    p=ss[p][0];
                }
            }
            if(p==x) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    

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

Measured memory_bytes: 7296
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    d = i_input()
    c_list = i_list()
    s_list = i_row_list(d)

    last_list = [0] * 26

    for day in range(1,d+1):
        result = 0
        max_point = -INF
        for i in range(26):
            plus_point = s_list[day-1][i]
            minus_point = 0
            for j in range(26):
                if i == j:
                    continue
                minus_point += c_list[j] * (day - last_list[j])
            sum_point = plus_point - minus_point
            if sum_point > max_point:
                result = i + 1
                max_point = sum_point
        print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3596
//A
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const long long mod=998244353;
long long dp[3030][3030];
int main()
{
	long long a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	dp[a][b]=1;
	for(int i=b+1;i<=d;i++)
		dp[a][i]=(dp[a][i-1]*a%mod)%mod;
	for(int i=a+1;i<=c;i++){
		dp[i][b]=(dp[i-1][b]*b%mod)%mod;
		for(int j=b+1;j<=d;j++){
			dp[i][j]=((dp[i-1][j]*j)%mod+(dp[i][j-1]*i%mod)%mod-(dp[i-1][j-1]*(((i-1)*(j-1))%mod))%mod+mod)%mod;
		}
	}
	printf("%lld",dp[c][d]);
}

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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(c-a) <= d){
		cout << "Yes" << endl;
	}else if(abs(b-a)<=d && abs(c-b)<=d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main() {
    int N;
    int a[110];  // 最大 100 個ですが余裕をもたせます
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) { // Alice のターン
            Alice += a[i];
        }
        else { // Bob のターン
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
	ll n,i,j;
	cin>>n;
	ll a[51],ans=0;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(i!=j){
				ans=ans+(a[i]*a[j]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x1,y1,x2,y2;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    printf("%d %d %d %d",x2-(y2-y1),y2+(x2-x1),x1-(y2-y1),y1+(x2-x1));
    return 0;
}

Measured memory_bytes: 3860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static FastReader fr = new FastReader();
    private static PrintWriter out=new PrintWriter(System.out);

    private static long MOD = 1000000007;
    private static long[][] dp;
    private static boolean[] visited;
    private static long calculate(int current, int[] arr, int k, int total){
        if(current >= arr.length && k == 0) {
            dp[current][k] = 1;
            return 1;
        }
        if(k == 0) {
            dp[current][k] = 1;
            return 1;
        }
        if(current >= arr.length) {
            dp[current][k] = 0;
            return 0;
        }

        if(dp[current][k] != -1) return dp[current][k];

        int min = Math.min(arr[current], k);

        long ans = 0;

        if(!visited[current]){
            visited[current] = true;
            for(int i = 0; i <= total; i++){
                calculate(current + 1, arr, i, total);
            }
            for(int i = 1; i <= total; i++){
                dp[current + 1][i] += dp[current + 1][i - 1];
                //dp[current + 1][i] %= MOD;
            }
        }

        ans += dp[current + 1][k] - (k - min - 1 >= 0 ? dp[current + 1][k - min - 1] : 0);
        ans %= MOD;

        dp[current][k] = ans;
        return ans;
    }

    public static void main(String[] args) throws IOException {
        StringBuilder sb = new StringBuilder();
        // code goes here
        int n = fr.nextInt();
        int k = fr.nextInt();
        int[] arr = fr.nextIntArray(n);
        dp = new long[n + 1][k + 1];
        visited = new boolean[n];
        for(int i = 0; i < n + 1; i++){
            Arrays.fill(dp[i], -1);
        }
        sb.append(calculate(0, arr, k, k));
        System.out.print(sb.toString());
    }

    static class FastReader{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

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

        public int[] nextIntArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }

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

        public long[] nextLongArray(int n) {
            long[] a=new long[n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 136956
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	N := nextInt()
	a := nextInts(N)
	abs_max := 0
	am_idx := 0
	for i := 0; i < N; i++ {
		if abs(abs_max) < abs(a[i]) {
			abs_max = a[i]
			am_idx = i
		}
	}
	var out bytes.Buffer
	out.WriteString(fmt.Sprintf("%d\n", 2*N-1))
	for i := 0; i < N; i++ {
		out.WriteString(fmt.Sprintf("%d %d\n", am_idx+1, i+1))
	}
	for i := 1; i < N; i++ {
		if abs_max > 0 {
			out.WriteString(fmt.Sprintf("%d %d\n", i, i+1))
		} else {
			out.WriteString(fmt.Sprintf("%d %d\n", N-i+1, N-i))
		}
	}
	out.WriteTo(os.Stdout)
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func printInts(out []int, str string) {
	var bb bytes.Buffer
	for i := range out {
		bb.WriteString(strconv.Itoa(out[i]))
		bb.WriteString(str)
	}
	fmt.Println(bb.String())
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<stdio.h>
int main (){
int a=0,b=0,c=0,k = 3;
scanf ("%d%d%d",&a,&b,&c);
if (a==b || b==c || c==a){
k = k-1;
}
if( a==b && b==c ){
k = k-1;
}
printf ("%d",k);
return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int T=500;

signed main(){
	int K=read();
	vector<vi> ans;
	if(K<=T){
		int n=K;
		REP(i,n)
			ans.EB(n,i);
	}else{
		int n=T;
		ans.resize(n,vi(n,-1));
		int head=0;
		REP(i,n){
			int a=head;
			if(n+i<K)
				head++;
			int b=head++;
			REP(j,n){
				ans[(i+j)%n][j]=j%2==0?a:b;
			}
		}
		assert(head==K);
	}
	int n=ans.size();
	print(n);
	REP(i,n)REP(j,n)
		print(ans[i][j]+1,j==n-1?1:2);
}


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

int ite;
int n;
string ex;

ll num();
ll L();
ll exp();
ll fac();

ll num() {
	assert(ite < n && isdigit(ex[ite]));
	ll res = 0;
	while (ite < n && isdigit(ex[ite])) {
		res += ex[ite] - '0';
		ite++;
	}
	return res;
}

ll L() {
	ll res = num();
	while (ite < n) {
		if (ex[ite++] == '+') {
			res += num();
		}
		else {
			assert(ex[ite - 1] == '*');
			res *= num();
		}
	}
	return res;
}

ll exp() {
	ll res = fac();
	while (ite < n) {
		assert(ex[ite] == '+');
		ite++;
		res += fac();
	}
	return res;
}

ll fac() {
	ll res = num();
	while (ite < n && ex[ite] == '*') {
		ite++;
		res *= num();
	}
	return res;
}

int main()
{
	ll val;
	cin >> ex >> val;
	n = ex.size();
	bool l = L() == val;
	ite = 0;
	bool m = exp() == val;
	cout << (m ? l ? 'U' : 'M' : l ? 'L' : 'I') << endl;
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    if(a+b <= 2*c){
        if(x > y){
            cout << min(y*(a+b) + (x-y)*a,x*(a+b)) << endl;
        }else{
            cout << min(x*(a+b) + (y-x)*b,y*(a+b)) << endl;
        }
    }else{
        if(x > y){
            cout << min(y*(2*c) + (x-y)*a,x*(2*c)) << endl;
        }else{
            cout << min(x*(2*c) + (y-x)*b,y*(2*c)) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256