akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <vector> 

using namespace std;

const int N=15;
typedef long long ll; 

int book[N];//书的价格
int w[N][N]; 
bool st[N];
int v[N];//用于记录每个算法的累加值 
int n,m,x;
int minmon=0x3f3f3f3f;
int summon=0;

void dfs(int u)//u记录已经有几本书在列 
{
	if(u==n) return;//应该走完所有路径才能找到最优解,u是从开始的
	
	for(int j=0;j<m;j++) v[j]+=w[u][j];
	summon+=book[u];
	int flag=1;
	for(int j=0;j<m;j++) if(v[j]<x) flag=0;
	if(flag) 
	{
		if(summon<minmon) minmon=summon;
	}
	dfs(u+1);
	for(int j=0;j<m;j++) v[j]-=w[u][j];
	summon-=book[u];
	dfs(u+1);	
}

int main()
{
//	freopen("input.txt","r",stdin);
	
	scanf("%d%d%d",&n,&m,&x);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&book[i]);
		for(int j=0;j<m;j++) scanf("%d",&w[i][j]);
	}
	dfs(0);
	if(minmon==0x3f3f3f3f) printf("-1");
	else printf("%d",minmon);

	return 0;
}

Measured memory_bytes: 3232
from collections import deque

n,m = map(int,input().split())
ab = [[] for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
    
chk = [0]*n

cnt = 1

for i in range(n):
    if chk[i] == 0:
        chk[i] = cnt
        q = deque()
        q.append(i)
        while len(q) > 0:
            tmp = q.popleft()
            for j in range(len(ab[tmp])):
                if chk[ab[tmp][j]] == 0:
                    q.append(ab[tmp][j])
                    chk[ab[tmp][j]] = cnt
                    
    cnt += 1

li = [0]*(n+2)

#print(chk)

for i in range(n):
    li[chk[i]] += 1
    
print(max(li))

Measured memory_bytes: 108860
#include <stdio.h>

int main(void) {

  int N, X, i;
  do {
    scanf("%d %d", &N, &X);
  } while (N < 1 || N > 100 || X < 1 || X > 10000);

  int L[N];
  for (i = 0; i < N; i++) {
    do {
      scanf("%d", &L[i]);
    } while (L[i] < 1 || L[i] > 100);
  }

  int D[N];
  for (i = 0; i < N + 1; i++) {
    if (i == 0) {
      D[i] = 0;
    } else {
      D[i] = D[i - 1] + L[i - 1];
    }
  }

  int n = 0;
  for (i = 0; D[i] <= X; i++) {
    n++;
  }

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

  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int N, K;
vector<lint> f(const vector<lint>& A) {
    vector<lint> B(N + 2, 0);
    for (int i = 1; i < N + 1; i++) {
        int d = A[i];
        if (d == 0) {
            B[i]++;
            B[i + 1]--;
        } else {
            B[max(i - d, 0)]++;
            B[min(i + d + 1, N + 1)]--;
        }
    }
    for (int i = 0; i <= N; i++) {
        B[i + 1] += B[i];
    }

    return B;
}

int main() {
    cin >> N >> K;
    vector<lint> A(N + 2, 0);
    rep(i, N) cin >> A[i + 1];

    vector<lint> end(N, 0);
    rep(i, N) { end[i] = N; }

    vector<lint> tmp = f(A);

    while (K--) {
        A[0]     = 0;
        A[N + 1] = 0;
        A        = f(A);
        A[0]     = 0;
        A[N + 1] = 0;
        // dump(A);

        bool fin = true;
        for (int i = 0; i < N; i++) {
            if (A[i + 1] != end[i]) {
                fin = false;
                break;
            }
        }

        if (fin) {
            for (int i = 0; i < N; i++) {
                cout << end[i] << " ";
            }
            cout << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++) {
        cout << A[i + 1] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 9512
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
# include <functional>
using namespace std;

int main() {
	int m;
	while (cin >> m&&m != 0) {
		vector<int>fx, fy, px, py;
		int a, b;
		for (int i = 0; i < m; i++) {
			cin >> a >> b;
			fx.emplace_back(a);
			fy.emplace_back(b);
		}
		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			px.emplace_back(a);
			py.emplace_back(b);
		}
		for (int i = 0; i < n; i++) {
			int movex = px[i] - fx[0], movey = py[i] - fy[0];
			int count = 0;
			for (int j = 0; j < m; j++) {
				for (int o = 0; o < n; o++) {
					if (fx[j] + movex == px[o] && fy[j] + movey == py[o]) {
						count++;
					}
				}
			}
			if (count == m) {
				cout << movex << " " << movey << endl;
			}
		}
	}
}

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

int main(){
  int h,w;
  while(true){
    cin >> h >> w;
    if(h==0&&w==0) break;
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
	if(i%2 == 0 && j%2 == 0 || i%2 == 1 && j%2 == 1){
	  cout << "#";
	}else{
	  cout << ".";
	}
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, x, m = rli()
    if x == 0:
        print(0)
        return
    if x == 1:
        print(n)
        return
    l = 0
    memo = {}
    a = x
    nums = []
    while a not in memo:
        # print(l, a)
        nums.append(a)
        memo[a] = l
        l += 1
        a = a*a % m
    st = memo[a]
    k = len(nums)
    if n <= k:
        print(sum(nums[:n]))
        return
    su = sum(nums)
    n -= k
    su2 = sum(nums[st:])
    n2 = n//(k-st)
    ans = su
    ans += n2*su2
    n3 = n%(k-st)
    ans += sum(nums[st:st+n3])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15820
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int INF=2147483647;
int n,k;
double ans,tmp;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int score=i;
		tmp=1.0/n;
		while(score<k){
			score*=2;
			tmp/=2;
		}
		ans+=tmp;
	}
	printf("%.12f\n",ans);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    long long ans=0;
    sort(a+1,a+n+1);
    if(n==1){puts("0");return 0;}
    else if(n==2){printf("%d",a[2]);return 0;}
    else if(n==3){printf("%d",a[2]+a[3]);return 0;}
    int now=n-2;
    ans=a[n];
    for(int i=n-1;i>=1;i--)
        if(now>=2)ans+=2ll*a[i],now-=2;
        else {ans+=a[i]*now;break;}
    printf("%lld",ans);
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

double dp[3005][3005];
double P[3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> P[i];
    }

    dp[0][0] = 1;
    REP(i, N) {
        REP(j, N + 1) {
            dp[i + 1][j] += dp[i][j] * (1.0 - P[i]);
            if (j > 0)
                dp[i + 1][j] += dp[i][j - 1] * P[i];
        }
    }
    
    double ans = 0;
    FOR(i, N + 1, (N + 1) / 2) {
        ans += dp[N][i];
    }
    cout << OF64 << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int H, W;
	int h, w;
	cin >> H >> W;
	cin >> h >> w;
	cout << (H - h)*(W-w) << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    bool p = s[0] == 'R';
    bool q = s[1] == 'R';
    bool r = s[2] == 'R';

    if (p and q and r)
    {
        cout << 3 << '\n';
    }
    else if ((p and q) or (q and r))
    {
        cout << 2 << '\n';
    }
    else if (p or q or r)
    {
        cout << 1 << '\n';
    }
    else
    {
        cout << 0 << '\n';
    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) ((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int main(){
  li a,b,c; cin >>a >>b >>c;
  if(0==(1&a&b&c)){
    print(0); return 0;
  }
  if(a>=max(b,c))a=1;
  else (b>c?b:c)=1;
  print(a*b*c);
}





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

int main(){
   int num1,num2,num3;
   cin >> num1 >> num2 >> num3;

   if (num1<num2 && num1<num3){
      if (num2<num3){
         cout << num1 << " " << num2 << " " << num3 <<"\n";
      }
      else{
         cout << num1 << " " << num3 << " " << num2 <<"\n";
      }
   }
   else if (num2<num1 && num2<num3){
      if (num1<num3){
         cout << num2 << " " << num1 << " " << num3 <<"\n";
      }
      else{
         cout << num2 << " " << num3 << " " << num1 <<"\n";
      }
   }
   else{
      if (num1<num2){
         cout << num3 << " " << num1 << " " << num2 <<"\n";
      }
      else{
         cout << num3 << " " << num2 << " " << num1 <<"\n";
      }
   }

   return 0;
}



Measured memory_bytes: 3112
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long n) {
    return n * (n - 1) / 2;
}

void main() {
    int n; scan(n);
    writeln(calc(n));
}


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

using namespace std;

using ll = long long;

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

    int n, x; cin >> n >> x;
    vector<int> l(n); for (int& y : l) cin >> y;
    int ans = 1;
    vector<int> d(n + 1);
    d[0] = 0;
    for (int i = 0; i < n; i++) {
        d[i + 1] = d[i] + l[i];
        if (d[i + 1] <= x) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        if (A+B>=C) {
            System.out.println(B+C);
            return;
        }
        System.out.println(A+B*2+1);
    }
}


Measured memory_bytes: 21972
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		char[] s = in.next().toCharArray();
		int n = s.length;
		int[][] dp = new int[27][n];
		final int MAX = 20;
		int[][] go = new int[MAX][n];
		for (int i = n - 1; i >= 0; i--) {
			int cur = s[i] - 'a';
			dp[cur][i] = 1;
			for (int need = cur + 1; need < 27; need++) {
				int posAsk = i + dp[need - 1][i];
				if (posAsk >= n) {
					dp[need][i] = Integer.MAX_VALUE / 2;
				} else {
					int askLen = dp[need - 1][posAsk];
					if (askLen >= Integer.MAX_VALUE / 2) {
						dp[need][i] = Integer.MAX_VALUE / 2;
					} else {
						dp[need][i] = dp[need - 1][i] + askLen;
					}
				}
			}
			int posAsk = i + dp[26][i];
			go[0][i] = dp[26][i];
			for (int j = 1; j < MAX; j++) {
				int len = go[j - 1][i];
				if (i + len >= n) {
					go[j][i] = Integer.MAX_VALUE / 2;
				} else {
					go[j][i] = go[j - 1][i] + go[j - 1][i + len];
				}
			}
			for (int j = 0; j < cur; j++) {
				if (posAsk >= n) {
					dp[j][i] = Integer.MAX_VALUE / 2;
				} else {
					dp[j][i] = dp[26][i] + dp[j][posAsk];
				}
			}
		}
		int q = in.nextInt();
		for (int i = 0; i < q; i++) {
			int fr = in.nextInt() - 1;
			int to = in.nextInt() - 1;
			int needLen = to - fr + 1;
			for (int j = MAX - 1; j >= 0; j--) {
				if (needLen > 0 && go[j][fr] <= needLen) {
					needLen -= go[j][fr];
					fr += go[j][fr];
				}
			}
			out.println(needLen == 0 ? "Yes" : "No");
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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

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

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;

    int c[10][10];
    rep(i, 10){
        rep(j, 10){
            cin >> c[i][j];
        }
    }

    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                if(c[i][j] > c[i][k]+c[k][j])
                    c[i][j] = c[i][k] + c[k][j];
            }
        }
    }
    ll ans = 0;
    rep(i, h){
        rep(j, w){
            int a;
            cin >> a;
            if(a >= 0) ans += c[a][1];
        }
    }


    ppp(ans);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# ループを見つけるプログラム？
found = set()
current = 1
log = []
while current not in found:
    found.add(current)
    log.append(current)
    current = a[current - 1]
for i, _log in enumerate(log):
    if (current == _log):
        loop_start = i
        loop_len = len(log) - i
        break
# len(found) * n回移動するとcurrentに移動する
# print('loop_len', loop_len)
# print('loop_start', loop_start)
# print(log[1:])

if (k < loop_start):
    print(log[k])
else:
    k = k - (loop_start)  # ループの先頭へ
    k = k % (loop_len)  # ループを実施
    print(log[loop_start+k])


Measured memory_bytes: 51060
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=list(Counter(a).items())
c.sort(reverse=True)
hen=0
ans=[0]
for a,b in c:
  if b>=4:
    if hen==0:
      ans.append(a**2)
    else:
      ans.append(hen*a)
  elif b>=2:
    if hen==0:
      hen=a
    else:
      ans.append(hen*a)
  else:
    continue
print(max(ans))

Measured memory_bytes: 21412
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  string s; cin>>s;
  int l=s.size();
  if(s[l-1]=='s'){
    cout<<s<<"es"<<endl;
  }else{
    cout<<s<<'s'<<endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
const long double PI = acos(-1.0);
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           vvin d(n,vin(2));
           rep(i,0,n)cin>>d[i][0]>>d[i][1];
           bool ans=false;
           rep(i,0,n-2){
             if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
               ans=true;
             }
           }
           Yes(ans);
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;


int main(void){
    int n;
    ll x[200010];
    ll a[200010];
    a[0]=0;
    
    cin>>n;
    rep(i,n){
        cin>>x[i];
        a[i+1]=a[i]+x[i];
        //cout<<a[i+1]<<endl;
    }

    ll q,R,s,t;
    ll ans=1e18;
    int l=1;
    int r=3;
    REP(i,2,n-1){
        if(r<=i)r=i+1;
        ll fs=a[i];
        ll sc=a[n]-a[i];
        while(a[l+1]<fs/2 and l<i-1)l++;
        while(a[r+1]-a[i]<sc/2 and r<n-1)r++;
        
        q=a[l];
        R=a[i]-a[l];
        s=a[r]-a[i];
        t=a[n]-a[r];
        ans=min(ans,max({q,R,s,t})-min({q,R,s,t}));
        if(l<i-1)ans=min(ans,max({q+x[l],R-x[l],s,t})-min({q+x[l],R-x[l],s,t}));
        if(r<n-1)ans=min(ans,max({q,R,s+x[r],t-x[r]})-min({q,R,s+x[r],t-x[r]}));
        if(l<i-1 and r<n-1)ans=min(ans,max({q+x[l],R-x[l],s+x[r],t-x[r]})-min({q+x[l],R-x[l],s+x[r],t-x[r]}));
        
        //cout<<l<<i<<r<<'|'<<q<<' '<<R<<' '<<s<<' '<<t<<endl;
    }
     
    cout<<ans<<endl;

}


Measured memory_bytes: 3328
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int n, m;
vector<int> idx[N];

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < n ; ++i){
        int a, b;
        scanf("%d%d", &a, &b);
        if(a <= m)idx[a].emplace_back(b);
    }
    ll ans = 0;
    int day = m;
    priority_queue<int> pq;
    for(int day = 1 ; day <= m ; ++day){
        for(auto j : idx[day])pq.emplace(j);
        if(pq.size())ans += pq.top(), pq.pop();
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.SFN", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		vector<int> a (5, 0 );
		stringstream ss (str );
		for (int i = 0; ss >> a[i]; i++ );
		sort (ALL (a ), greater<int>() );
		rep (i, 5 ){
			cout << a[i] << (i != 4 ? ' ' : '\n' );
		} // end rep
	} // end loop
		
	return 0;
}

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

using namespace std;

int main(){
    int a[4];

    string input;
    cin >> input;
    for(int i = 0; i < 4; i++) a[i] = input[i] - '0';

    for(int i = 0; i < 8; i++){
        int sum = a[0];
        string s;
        s = (char)('0' + a[0]);

        for(int j = 0; j < 3; j++){
            if(i & (1<<j)){
                sum += a[j+1];
                s += '+';
                s += (char)('0' + a[j+1]);
            }
            else{
                sum -= a[j+1];
                s += '-';
                s += (char)('0' + a[j+1]);
            }
        }

        if(sum == 7){
            s += "=7";
            cout << s << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split(' '))

MOD = 1000000007

def fib(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a

broken_step = []
p_a = -1
for i in range(M):
    a = int(input())
    if (a - p_a == 1):
        print("0")
        exit()
    else:
        p_a = a
    broken_step.append(a-1)

count_0 = 0
count_1 = 1
next_broken = 0
pre_is_broken = False
for i in range(N):
    if (next_broken >= len(broken_step) or i != broken_step[next_broken]):
        if (pre_is_broken):
            count_0 = 0
            pre_is_broken = False
        else:
            count_0, count_1 = count_1, count_0 + count_1
            count_0 %= MOD
            count_1 %= MOD
    else:
        next_broken+=1
        count_0 = 0
        pre_is_broken = True

print(count_1)


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

int main(){
  int n,a;
  cin >> n;
  cin >> a;
  
  int m;
  m = n / 500;
  
  int l;
  l = n - m * 500;
  
  if (l <= a){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
  
}
  


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

int main() {
  char x;
  cin >> x;
  string str = "aiueo";
  bool p = false;
  
  for (int i = 0; i < str.size(); i++){
    if ( x == str.at(i)) {
      p = true;
      break;
    }
  }
  
  if (p) cout << "vowel" <<endl;
  else cout << "consonant" << endl;
  
 }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
ll n,i,s,S,M;
ll a[200010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i],s+=a[i];
    M=INF;
    for(i=0;i<n;i++)
        S+=a[i],M=min(M,abs(s-2*S));
    cout<<M<<endl;
    return 0;
}

Measured memory_bytes: 1920
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体
//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};
//////////////////ここまでライブラリ///////////////////////

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  
  lin(N);lin(M);
  cout << min(N%M, abs(N%M-M)) << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut v = 1usize;
    for e in a {
        v = v.saturating_mul(e);
    }
    if v > 1_000_000_000_000_000_000 {
        println!("-1");
    } else {
        println!("{}", v);
    }
}


Measured memory_bytes: 4540
#include <iostream>

using namespace std;

int a, b, c, x;

void solve()
{
    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (x == 500*i + 100*j + 50*k) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

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

    solve();

    return 0;
}

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

int main(){
	int N,len,i,A=0,W=0,T=0,R=0;
	char *s[100000];
	char *p;
	char n[3];
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
		scanf("%s",n);
		len=strlen(n);
		p=(char *)malloc(len+1);
		strcpy(p,n);
		s[i]=p;
	}
	
	for(i=0;i<N;i++){
		if(strcmp(s[i],"AC")==0){
			A++;
		}
		else if(strcmp(s[i],"WA")==0){
			W++;
		}
		else if(strcmp(s[i],"TLE")==0){
			T++;
		}
		else if(strcmp(s[i],"RE")==0){
			R++;
		}
	}
	
	{
		printf("AC x %d\n",A);
		printf("WA x %d\n",W);
		printf("TLE x %d\n",T);
		printf("RE x %d",R);
	}
	
	
	return 0;
}


Measured memory_bytes: 5632
s = gets.chomp.split("")
gets.chomp.to_i.times do
  c = gets.chomp.split
  c[1] = c[1].to_i
  c[2] = c[2].to_i
  case c[0]
  when "print"
    (c[1]..c[2]).each do |i|
      print s[i]
    end
    puts
  when "reverse"
    r = []
    (c[1]..c[2]).each do |i|
      r.push(s[i])
    end
    r.reverse!
    (c[1]..c[2]).each do |i|
      s[i] = r[0]
      r.shift
    end
  when "replace"
    r = c[3].split("")
    (c[1]..c[2]).each do |i|
      s[i] = r[0]
      r.shift
    end
  end
end

Measured memory_bytes: 6132
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
	int p, lc, rs;
}node;

node T[MAX];
int i,j,n;


int main(void) {
	int id, k, c, d=0, count, temp;
	
	scanf("%d", &n);
	//initialize
	for (i=0; i<n; i++){
		T[i].p = T[i].lc = T[i].rs = NIL;
	}
	
	for(i=0; i<n; i++){
		scanf("%d %d", &id, &k);
	
		for(j=0; j<k; j++){
			scanf("%d", &c);
		
			if(j==0)
				T[id].lc = c;
			else 
				T[temp].rs = c;
			temp = c;
			T[c].p = id;
		}

	}
	
	for(i=0; i<n; i++){
		printf("node %d: parent = %d, ", i, T[i].p);
		count = i;
		while(T[count].p != NIL){
			d++;
			count = T[count].p;
		}
		printf("depth = %d, ", d);
		d=0;
		if (T[i].p == NIL)
			printf("root, ");
		else if (T[i].lc == NIL)
			printf("leaf, ");
		else printf("internal node, ");
		printf("[");
		c = T[i].lc;
		if (c == NIL)
			printf("]\n");
		else{
			count = 0;
			while(c != NIL) {
				if (count == 0)
					printf("%d", c);
				else 
					printf(", %d", c);
				c = T[c].rs;
				count++;
			}
			printf("]\n");
		}	
	}
	
	return 0;
}



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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int r = count(S.begin(), S.end(), 'R');
    int b = count(S.begin(), S.end(), 'B');
    cout << (r>b ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

char tiles[21][21];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ans=0;
int w,h;

void dfs(int x,int y){
    tiles[x][y]='#';
    ans++;

    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];

        if(0<=nx && nx<w && 0<=ny && ny<h &&
          tiles[nx][ny] == '.') dfs(nx,ny);
    }
}

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

  while(true){
    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
        tiles[i][j]='#';
      }
    }
    ans=0;
    cin >> w >> h;
    if(w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> tiles[j][i];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(tiles[j][i]=='@') dfs(j,i);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2984
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, e =MAP()  #頂点数、辺数
G = [[]for i in range(n)]
for i in range(e):
    fr, to = MAP()#辺の端点、重み
    G[fr-1].append([1,to -1])
    G[to-1].append([1,fr -1])

def djkstra(s,G):
    visited = [False]*n#すでに計算したかどうか 
    d = [INF]*n#最短距離
    former = [INF]*n#経路の一つ前の頂点を記憶
    que = []
    heapq.heappush(que, (0,s,-1))
    while(len(que)>0):
        vs = heapq.heappop(que)
        distance = vs[0]
        vertex = vs[1]
        f = vs[2]
        if visited[vertex]:
            continue
        d[vertex] = distance
        visited[vertex] = True
        former[vertex] = f
        for Gs in G[vertex]:
            if d[Gs[1]] <= distance+Gs[0]:
                continue
            heapq.heappush(que,(distance+Gs[0], Gs[1], vertex))

    return d,former

d, former = djkstra(0,G)
print('Yes')
for i in range(n-1):
    print(former[i+1]+1)


Measured memory_bytes: 153560
n = int(input())
arr = []
for i in range(n):
    arr.append([int(x) for x in input().split()])
for pair in arr:
    a = pair[0]
    b = pair[1]
    t = a*b
    s = int(t ** 0.5)
    if t < 3:
        print(0)
    elif a == b:
        if (a-1) * (b+1) < t:
            print((a-1)*2)
        else:
            print((a-1)*2-1)
    elif s*s == t:
        print((s-1)*2-1)
    elif s*(s+1) < t:
        print(s*2-1)
    else:
        print((s-1)*2)
        

Measured memory_bytes: 3188
function Main(input) {
  const data = input.trim();

  var nums = data.split("");

  var sum = 0;

  for (var bit = 0; bit < 1 << (nums.length - 1); bit++) {
    var tempStr = [nums[0]];
    for (var i = 0; i < nums.length - 1; i++) {
      var num = nums[i + 1];
      if (bit & (1 << i)) {
        //フラグが立っていたら
        tempStr.push(num);
      } else {
        tempStr[tempStr.length - 1] += num; //文字連結
      }
    }
    sum += tempStr.reduce((p, c) => p + parseInt(c), 0);
  }

  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n; cin >> n;
		vector<int> b(n - 1);
		rep(i, b.size()) {
			cin >> b[i];		
		}
		vector<int> a(n);
		a[0] = b[0];
		a[n - 1] = b[n - 2];
		for (int i = 0; i < b.size() - 1; ++i) {
			a[i + 1] = min(b[i], b[i + 1]);
		}
		auto sum = [&](vector<int> b) {
			int ret = 0;
			rep (i, a.size()) {
				ret += a[i];	
			}
			return ret;
		};
		cout << sum(a) << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
use std::cmp::max;
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut k: i64 = s.trim().parse().unwrap();
    let mut ans = 0;
    for i in 1..=k {
        for j in 1..=i {
            for l in 1..=j {
                let n = gcd(i, j);
                let n = gcd(n, l);
                if i == j && j == l {
                    ans += n;
                } else if i == j || i == l || j == l {
                    ans += n * 3;
                } else {
                    ans += n * 6;
                }
            }
        }
    }

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

fn gcd(a: i64, b: i64) -> i64 {
    let (a, b) = (max(a, b), min(a, b));
    if b == 0 {
        return a;
    }

    return gcd(b, a % b);
}


Measured memory_bytes: 2148
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  90
double pi = 3.1415926535897;
int main()
{
	ios
	double r;
	cin>>r;
	r=(2.0l*pi*r);
	printf("%.12lf",r);
	return 0;
}

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

#define ll long long
#define ar array



  int main() {
    int n, k;
    cin >> n >> k;
    int p[1100];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p, p + n);
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin>>n;
  ll a[400000];
  rep(i,3*n)cin>>a[i];
  sort(a,a+3*n,greater<int>());

  ll sum=0;
  int count=0;
  int start=1;
  while(count<n){
    sum+=a[start];
    start+=2;
    count++;
  }

  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k) cout<<k<<endl;
    else if(a+b>=k) cout<<a<<endl;
    else cout<<a-(k-a-b)<<endl;
    return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<int> A(m);
  int sum=0;
  rep(i,m) {
    int a; cin >> a;
    A[i] = a;
    sum += A[i];
  }
  if (n < sum) cout << -1 << endl;
  else cout << n - sum << endl;
}

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

using namespace std;

int main(void){
	
	int a,b;
	cin >> a >> b;
	if(a < 10 && b < 10){
		cout << a*b<<endl;
	}
	else{
		cout << "-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<pair<ll,ll>> v;
vector<ll> A;
ll N,M,tA,B,C,now=0,ans;

int main(){
    cin>>N>>M;
    rep(i,N){
        cin>>tA;
        A.push_back(tA);
    }
    rep(i,M){
        cin>>B>>C;
        v.push_back({C,B});
    }
    sort(ALL(v),greater<pair<ll,ll>>());
    sort(ALL(A));
    pair<ll,ll> p = v[now];
    rep(i,N){
        if(p.first>A[i]){
            ans+=p.first;
            p.second--;
            if(!p.second){
                now++;
                p = v[now];
            }
        }
        else ans+=A[i];
    }
    out(ans);
    
    
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
int n;
string s;
int ans=0;
signed main(){
    cin>>n>>s;
    rep(i,n-2){
        if(s.substr(i,3)=="ABC"){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
total = 0
S = [0] * (N + 1)
for i in range(N):
    total += A[i]
    S[i + 1] = total
S.sort()
ans = 0
pre = float("inf")
for i in range(N + 1):
    if S[i] == pre:
        cnt += 1
        ans += cnt
    else:
        cnt = 0
    pre = S[i]
print(ans)

Measured memory_bytes: 91472
#include "bits/stdc++.h"
using namespace std;
int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int N, L; cin >> N >> L;
  vector<string> S(N); for (auto& s : S) cin >> s;
  sort(S.begin(), S.end());
  for (auto& s : S) cout << s;
  cout << "\n";
  return 0;
}


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

public class Main {

	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = na(n);
		int result = -1;
		double sum = 0;
		for(int ai:a)sum += ai;
		double avg = sum / n;		
		double mingap = Double.MAX_VALUE;
		
		for(int i = 0; i < n; i++) {
			double tmp = Math.abs((double)a[i] - avg);
			if(tmp < mingap) {
				result = i;
				mingap = tmp;
			}
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);

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

    int ans1 = 0, ans2 = 0, ans = 1000;
    for (int i = 0; i < vec.size(); ++i) {
        ans1 += vec[i];
        for (int j = i + 1; j < vec.size(); ++j) {
            ans2 += vec[j];
        }
        if (ans >= abs(ans1 - ans2)) {
            ans = abs(ans1 - ans2);
        }
        ans2 = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608