akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
		if(a<=b){
		 if(a<b){
		  printf("a < b\n");
		 }else{
		  printf("a == b\n");
		 }
		}else{
			printf("a > b\n");
		}
	return 0;
}

Measured memory_bytes: 580
import sys
import bisect
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,M = IL()
a = IL()
b = IL()
xyc = [IL() for i in range(M)]

ans = min(a) + min(b)
for x,y,c in xyc:
  ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

"""
3 2 1
3 5 4
3 5
2 2 2
"""

Measured memory_bytes: 82284
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s, t;
    cin >> s >> t;
    int count = 0;
    rep(i, 3) {
        if (s[i] == t[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int H = in.nextInt();
			int W = in.nextInt();
			String[] C = new String[H];
			for(int i = 0; i < H; i++) {
				C[i] = in.next();
				out.println(C[i]);
				out.println(C[i]);
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 24916
n=int(input())

hund=n//100
amari=n%100

pc_num=amari//5
if pc_num*105>n:
    print(0)
else:
    rest = n-(pc_num*105)
    if rest==0:
        print(1)
    elif rest<100:
        print(0)
    else:
        print(1)


Measured memory_bytes: 2940
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

x = list(itertools.permutations(range(1, n+1)))
a = x.index(tuple(p)) + 1
b = x.index(tuple(q)) + 1

print(abs(b-a))


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c;
	
	
	if (a > b) {
			d = a;
			a = b;
			b = d;
		}
	
	if (b > c) {
			d = b;
			b = c;
			c = d;
		}
	
	if (a > b) {
			d = a;
			a = b;
			b = d;
		
	}
	
	cout << a << " " << b << " " << c << endl;

}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
using namespace std;

int main()
{
  long long int n,a,b,ans=0;
  cin>>n>>a>>b;
  vector <long long int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(i>0){
      ans+=min(a*(x[i]-x[i-1]),b);
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	ll a, b, d;
	char c;
	cin >> a >> b >> c >> d;
	b *= 100;
	b += d;
	a *= b;
	a /= 100;
	cout << a;

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, LR):
    M = 998244353
    memo = [0] *(N+2)
    memo[1] = 1
    memo[1+1] = -1
    for i in range(1, N+1):
        memo[i] += memo[i-1]
        memo[i] %= M
        for l, r in LR:
            ll = min(N+1, i+l)
            rr = min(N+1, i+r+1)
            memo[ll] += memo[i]
            memo[ll] %= M
            memo[rr] -= memo[i]
            memo[rr] %= M

    return memo[N]


def main():
    N, K = read_int_n()
    LR = [read_int_n() for _ in range(K)]
    print(slv(N, K, LR))


if __name__ == '__main__':
    main()


Measured memory_bytes: 80504
a = []
mod = []
sum = 0
last = 0

5.times do
  a.push(gets.to_i)
  mod.push(a.last % 10) if a.last % 10 != 0
end

mod.push(0) if mod.min.nil?

a.each do |i|
  sum += i % 10 == 0 ? i : (i / 10) * 10 + 10
  last = i if i == (i / 10) * 10 + mod.min
end

if mod.min.zero?
  puts sum
else
  puts sum - ((last / 10) * 10 + 10) + last
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	string s; cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
}

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

namespace AtCoder.Beginner068
{
    public class ABC089D
    {
        public static void Main(string[] args)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int H = nums[0];
            int W = nums[1];
            int D = nums[2];
            
            Pos[] PosMap = new Pos[H * W + 1];
            for(int i = 1; i <= H; i++)
            {
                nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                int j = 1;
                foreach(int num in nums)
                {
                    PosMap[num] = new Pos() { X = j, Y = i};
                    j++;
                }
            }
            
            int Q = int.Parse(Console.ReadLine());

            for(int i=1; i<=D; i++)
            {
                long totalCost = 0;
                for(int j=i; j<=W*H; j+=D)
                {
                    if(j != i)
                    {
                        totalCost += Math.Abs(PosMap[j].X - PosMap[j - D].X) + Math.Abs(PosMap[j].Y - PosMap[j - D].Y);
                    }
                    PosMap[j].TotalCost = totalCost;
                }
            }

            for(int i = 1; i <= Q; i++)
            {
                nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int L = nums[0];
                int R = nums[1];
                
                Console.WriteLine(PosMap[R].TotalCost - PosMap[L].TotalCost);
            }
           
        }
    }

    public class Pos
    {
        public int X;
        public int Y;
        public long TotalCost;
    }
}

Measured memory_bytes: 22456
#include <stdio.h>

int main()
{
	int a, b, d, r = 0;
	double f = 0.0;
	
	scanf("%d %d", &a, &b);
	
	d = a/b;
	r = a%b;
	f = (double)a/b;
	
	printf("%d %d %.5f\n", d, r, f);
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

long long bigmod(long long b,long long p,long long m){
    if(p==0)return 1%m;
    long long x=bigmod(b,p/2,m);
    x=(x*x)%m;
    if(p%2==1)x=(x*b)%m;
    return x;
}
ll ex[N];

int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
		ll n,k;
		Int(n,k);

		for(ll gcd=k;gcd>=1;--gcd){
			ll tot_div = k/gcd;
			ll tot_occur = bigmod(tot_div,n,M);
			ll extra=0;
			for(ll j=gcd*2;j<=k;j+=gcd){
				extra+=ex[j];
				if(extra>=M)extra%=M;
			}

			ex[gcd] = (tot_occur - extra + M)%M;
		}

		ll res=0ll;
		for(ll i=1;i<=k;++i){
			res+= (ex[i]*i)%M;
			if(res>=M)res%=M;
		}     
		printf("%lld\n", res);

        //printf("Case %d: ",++te);
    }
    return 0;
}



Measured memory_bytes: 4520
// ABC166B.cpp

#include <iostream>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int snk[110];
    for (int i = 1; i <= n; i++) {
        snk[i] = 0;
    }
    int dk = 0;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> dk;
            snk[dk] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (snk[i] == 0)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;
bool vis[gf];
vi adj[gf];

void dfs(int u)
{
	vis[u] = 1;
	for (int x : adj[u])
		if (!vis[x])
			dfs(x);
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, m;
	cin >> n >> m;
	zip(i, 0, m)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	int cnt = 0;
	rep(i, 1, n)
	{
		if (!vis[i])
		{
			dfs(i);
			cnt++;
		}
	}
	cout << cnt - 1 << en;


	return 0;
}




Measured memory_bytes: 31476
#include <stdio.h>

int main(){
  char S[5];
  int badflag = 0;
  scanf("%s",S);

  for(int i=0;i<3;i++)
    if(S[i]==S[i+1])
      badflag++;

  if(badflag)
    printf("Bad\n");
  else
    printf("Good\n");

  
  return 0;
}


Measured memory_bytes: 128
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define qi queue<int>
#define si stack<int>
#define s string
#define ll long long;
int soma_digitos(int a)
{
    int soma = 0;
    while (a != 0)
    {
        soma += a % 10;
        a /= 10;
    }
    return soma;
}
int main()
{
    sws;
    int n;
    cin >> n;
    int sum = n + 1;
    for (int i = 1, j = n - 1; i <= n && j > 0; i++, j--)
    {
        if (soma_digitos(i) + soma_digitos(j) < sum)
        {

            sum = soma_digitos(i) + soma_digitos(j);
        }
    }
    cout << sum << endl;
}

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

int main(){
    string x;
    cin >> x;
    rep(i, x.length()) cout << 'x';
    cout << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  char S[N];
  for(int i=0; i<N; ++i) cin>>S[i];
  for(int i=0; i<K-1; ++i) cout<<S[i];
  if(S[K-1]=='A') cout<<"a";
  if(S[K-1]=='B') cout<<"b";
  if(S[K-1]=='C') cout<<"c";
  for(int i=K; i<N; ++i) cout<<S[i];
}

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

using namespace std;

#define int long long

vector<int>ans(10001);

int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z=1;z<=100;z++){
               int val=x*x+y*y+z*z+x*y+y*z+x*z;
               if(val<=10000)++ans[val];
            }
        }
    }


    int n;
    cin>>n;

    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    map<P,int> mp;
    vector<vector<int>> g(n*(n-1)/2);
    vector<vector<int>> x(n, vector<int>(n-1));
    rep(i,n) {
        rep(j,n-1) {
            cin>>x[i][j];
            --x[i][j];
        }
    }
    int idx = 0;
    vector<int> h(n*(n-1)/2);
    rep(i,n) {
        rep(j,n-2) {
            int a = x[i][j]; int b = x[i][j+1];
            int t = i;
            int u,v;
            if (t>a) swap(a,t);
            if (!mp.count(P(t,a))) {
                u=idx;
                mp[P(t,a)] = idx;
                idx++;
            }
            else {
                u = mp[P(t,a)];
            }
            t = i;
            if (t>b) swap(t,b);
            if (!mp.count(P(t,b))) {
                v = idx;
                mp[P(t,b)] = idx;
                idx++;
            }
            else {
                v = mp[P(t,b)];
            }
            g[u].push_back(v);
            h[v]++;
        }
    }

    stack<int> st;
    vector<int> topo;
    rep(i,n*(n-1)/2) if (h[i]==0) st.push(i);

    while (st.size()) {
        int v = st.top(); st.pop();
        topo.push_back(v);
        for (auto &&e: g[v]) {
            h[e]--;
            if (h[e] == 0) st.push(e);
        }
    }

    vector<int> dp(n*(n-1)/2);
    for (auto &&e: topo) {
        for (auto&&u: g[e]) {
            chmax(dp[u],dp[e]+1);
        }
    }

    if (topo.size()!=n*(n-1)/2) {
        cout << -1 << '\n';
        return 0;
    }

    int ans = 0;
    rep(i,n*(n-1)/2) chmax(ans,dp[i]);
    cout << ans+1 << '\n';
    return 0;
}

Measured memory_bytes: 68720
#include <cstdio>
#include <cstring>
#include <algorithm>

using int64 = long long;

namespace NetFlow {
  const int N = 5e3 + 10, MAXM = 1e5 + 10;
  const int64 inf = 1ll << 60;
  struct Edge {
    int v,nx;//c:capcity, f:flow
    int64 c, f;
    Edge() {}
    Edge(int v,int64 c,int64 f,int nx):v(v),c(c),f(f),nx(nx) {}
  } E[MAXM];
  int G[N],cur[N],pre[N],gap[N],n,sz;
  int64 dis[N];
  void init(int _n) {
    n=_n,sz=0; memset(G,-1,sizeof(G[0])*n);
  }
  void link(int u,int v,int64 c) {
    E[sz]=Edge(v,c,0,G[u]); G[u]=sz++;
    E[sz]=Edge(u,0,0,G[v]); G[v]=sz++;
  }
  int64 ISAP(int S,int T) {//S -> T
    int64 maxflow=0,aug=inf;
    int flag=false,u,v;
    for (int i=0;i<n;++i)cur[i]=G[i],gap[i]=dis[i]=0;
    for (gap[S]=n,u=pre[S]=S;dis[S]<n;flag=false) {
      for (int &it=cur[u];~it;it=E[it].nx) {
        if (E[it].c>E[it].f&&dis[u]==dis[v=E[it].v]+1) {
          if (aug>E[it].c-E[it].f) aug=E[it].c-E[it].f;
          pre[v]=u,u=v; flag=true;
          if (u==T) {
            for (maxflow+=aug;u!=S;) {
              E[cur[u=pre[u]]].f+=aug;
              E[cur[u]^1].f-=aug;
            }
            aug=inf;
          }
          break;
        }
      }
      if (flag) continue;
      int mx=n;
      for (int it=G[u];~it;it=E[it].nx) {
        if (E[it].c>E[it].f&&dis[E[it].v]<mx) {
          mx=dis[E[it].v]; cur[u]=it;
        }
      }
      if ((--gap[dis[u]])==0) break;
      ++gap[dis[u]=mx+1]; u=pre[u];
    }
    return maxflow;
  }
  bool bfs(int S,int T) {
    static int Q[N];
    memset(dis,-1,sizeof(dis[0])*n);
    dis[S]=0; Q[0]=S;
    for (int h=0,t=1,u,v,it;h<t;++h) {
      for (u=Q[h],it=G[u];~it;it=E[it].nx) {
        if (dis[v=E[it].v]==-1&&E[it].c>E[it].f) {
          dis[v]=dis[u]+1; Q[t++]=v;
        }
      }
    }
    return dis[T]!=-1;
  }
  int64 dfs(int u,int T,int64 low) {
    if (u==T) return low;
    int64 ret=0,tmp;
    int v;
    for (int &it=cur[u];~it&&ret<low;it=E[it].nx) {
      if (dis[v=E[it].v]==dis[u]+1&&E[it].c>E[it].f) {
        if (tmp=dfs(v,T,std::min(low-ret,E[it].c-E[it].f))) {
          ret+=tmp; E[it].f+=tmp; E[it^1].f-=tmp;
        }
      }
    }
    if (!ret) dis[u]=-1; return ret;
  }
  int64 dinic(int S,int T) {
    int64 maxflow=0,tmp;
    while (bfs(S,T)) {
      memcpy(cur,G,sizeof(G[0])*n);
      while (tmp=dfs(S,T,inf)) maxflow+=tmp;
    }
    return maxflow;
  }
}

namespace nf = NetFlow;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  nf::init(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    int64 w;
    scanf("%d%d%lld", &u, &v, &w);
    if (w == 1) w = 1000000000 - 1;
    else w *= 1000000000;
    nf::link(u, v, w);
    nf::link(v, u, w);
  }
  int64 cost = nf::ISAP(0, n - 1);
  cost = cost / 1000000000;
  if (cost > 10000) cost = -1;
  printf("%d\n", (int)cost);
  return 0;
}

Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1e17;
int n,cnt[10],p[10];ll w;;
struct product{ll v,p;}pro[110],qian[10][110];
inline bool cmp(product a,product b){return a.v!=b.v?a.v<b.v:a.p>b.p;}
int main()
{
int i,j;ll xiao=inf;
scanf("%d%lld",&n,&w);
for (i=1;i<=n;i++) scanf("%lld%lld",&pro[i].v,&pro[i].p),xiao=min(xiao,pro[i].v);
sort(pro+1,pro+n+1,cmp);
for (i=1;i<=n;i++) qian[pro[i].v-xiao][++p[pro[i].v-xiao]]=pro[i];
for (i=0;i<4;i++) for (j=1;j<=p[i];j++) qian[i][j].p+=qian[i][j-1].p;
ll a,b,c,d,da=0;
for (a=0;a<=p[0];a++)
for (b=0;b<=p[1];b++)
for (c=0;c<=p[2];c++)
for (d=0;d<=p[3];d++) 
if (a*xiao+b*(xiao+1)+c*(xiao+2)+d*(xiao+3)<=w) da=max(da,qian[0][a].p+qian[1][b].p+qian[2][c].p+qian[3][d].p);
printf("%lld",da); 
}

Measured memory_bytes: 256
package main

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

var help = map[int]int{
	0:  0,
	1:  1,
	2:  3,
	3:  3,
	4:  7,
	5:  7,
	6:  7,
	7:  14,
	8:  22,
	9:  22,
	10: 22,
	11: 33,
	12: 33,
	13: 46,
	14: 60,
}

func main() {
	read := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(read, &n)
	r, d := n/15, n%15

	main := 60 * r * r
	sub := 0
	subarray := make([]int, 15)
	subarray[1] = 15*r + 1
	subarray[2] = 15*r + 2
	subarray[4] = 15*r + 4
	subarray[7] = 15*r + 7
	subarray[8] = 15*r + 8
	subarray[11] = 15*r + 11
	subarray[13] = 15*r + 13
	subarray[14] = 15*r + 14
	for i := 0; i <= d; i++ {
		sub += subarray[i]
	}
	fmt.Fprintln(w, main+sub)
}


Measured memory_bytes: 1832
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <string>

using ll = long long;

using namespace std;

void solve() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> red(a), green(b), color(c);
    for (int i = 0; i < a; ++i) {
        cin >> red[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> green[i];
    }
    for (int i = 0; i < c; ++i) {
        cin >> color[i];
    }
    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(color.rbegin(), color.rend());

    ll ans = 0;
    ll sum = 0;
    ll itr = 0, itc = 0;
    for (int i = 0; i < x; ++i) {
        if (itc == c || red[itr] >= color[itc]) {
            sum += red[itr++];
        } else {
            sum += color[itc++];
        }
    }

    for (int i = 0; i < y; ++i) {
        sum += green[i];
    }

    ans = sum;

    for (int i = y - 1; i >= 0; --i) {
        sum -= green[i];
        if (itr < x && (itc == c || red[itr] >= color[itc])) {
            sum += red[itr++];
        } else if (itc < c) {
            sum += color[itc++];
        }
        ans = max(ans, sum);
    }

    cout << ans << '\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int n, m;
	cin >> n >> m;
	vector<int> yaku;
	for(int i = 1; i <= sqrt(m)+1; i++){
		if(m%i == 0){
			// cout << i << " " << m/i << endl;
			yaku.pb(i);
			yaku.pb(m/i);
		}
	}
	// cout << endl;
	int ans = 0;
  	sort(yaku.begin(), yaku.end());
	for(int i = yaku.size()-1; i >= 0; i--){
		// cout << yaku[i] << " " << m/n << endl;
		if(yaku[i] <= m/n){
			ans = yaku[i];
			break;
		}
	}

  	if(n == 1) cout << m << endl;
	else cout << ans << endl;
	return 0;
}

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

int main() {
	int N;
	int A[100000];
	cin >> N;
	int ans;
	int temp;
	for (int i = 0; i < N; i++) {
		cin >>A[i];
	}
	ans = A[0];
	for (int i = 1; i < N; i++) {
		if (ans > A[i]) {
			temp = A[i];
			A[i] = ans;
			ans = temp;
		}
		while (A[i] % ans != 0) {
			temp = A[i] % ans;
			A[i] = ans;
			ans = temp;
		}
	}

	cout << ans;
	

}

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

int arr[100005];


int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        arr[x]++;
    }
    int cnt=0;
    for(int x=1;x<=100000;x++){
        int ret=0;
        ret+=arr[x-1];
        ret+=arr[x];
        ret+=arr[x+1];
        cnt=max(ret,cnt);
    }
    cout<<cnt;



}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<numeric> 
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int i = 0; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

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

    vector<i64> r(N, 0), g(N, 0), b(N, 0);
    rep(i, N){
        if(S[i] == 'R') r[i]++;
        if(S[i] == 'G') g[i]++;
        if(S[i] == 'B') b[i]++;
    }
    rep(i, N-1) {
        r[i+1] += r[i];
        g[i+1] += g[i];
        b[i+1] += b[i];    
    }

    i64 ans = 0;
    for(int i = 0; i < N ; i++){
        for(int j = i+1; j < N; j++){
            if(S[i] == S[j]) continue;
            set<char> rgb{'R', 'G', 'B'};
            rgb.erase(S[i]);
            rgb.erase(S[j]);
            char Sk = *rgb.begin();

            if(Sk == 'R') ans += (r[N-1] - r[j]); 
            if(Sk == 'G') ans += (g[N-1] - g[j]); 
            if(Sk == 'B') ans += (b[N-1] - b[j]); 
            
            int k = 2*j - i;
            if(k >= N) continue;
            if(Sk == S[k]) ans--;
        }
    }

    Cout(ans);
}


Measured memory_bytes: 3736
#include <cstdio>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
// bs(string &s){int c; s = "";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
// vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

vector<int> sum = {2};

void make_sum(int m) {
	const int l = m / 2 + 1;
	vector<bool> s(l, true);
	for (int i = 3, e = sqrt(m); i <= e; i += 2) {
		if (!s[i / 2])
			continue;
		for (int j = i * i / 2; j < l; j += i)
			s[j] = false;
	}
	for (int i = 1, a = 2; i < l; i++)
		if (s[i]) {
			a += i * 2 + 1;
			sum.push_back(a);
		}
}

int main() {
	make_sum(104750);
	for (int n; (n = in());)
		out(sum[n - 1], '\n');
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    string o, e;
    cin >> o >> e;

    for(int i = 0;e[i] != '\0';i++){
        cout << o[i];
        cout << e[i];
    }

    if(o.length() != e.length()){
        cout << o[o.size()-1];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>

const int coin[6] = { 500,100,50,10,5,1 };

using namespace std;

int main(){
	
	int answer[3][3] = { 0 };

	int in;
	int buf[3] = { 0 };

	for (int i = 0; i < 3; i++) {
		cin >> in;
		buf[i] -= in * 3600;
		cin >> in;
		buf[i] -= in * 60;
		cin >> in;
		buf[i] -= in;
		cin >> in;
		buf[i] += in * 3600;
		cin >> in;
		buf[i] += in * 60;
		cin >> in;
		buf[i] += in;

		answer[i][0] = buf[i] / 3600;
		answer[i][1] = buf[i] % 3600 / 60;
		answer[i][2] = buf[i] % 60;
	}

	

	for (int i = 0; i < 3; i++) {
		cout << answer[i][0] << ' '
			<< answer[i][1] << ' ' 
			<< answer[i][2] << endl;
	}

	return 0;
}


Measured memory_bytes: 3120
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

int32_t C[3][3];
int32_t c_[3][3];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	for (size_t i = 0; i < 3; i++)
		for (size_t j = 0; j < 3; j++)
	{
			in >> C[i][j];
			c_[j][i] = C[i][j];
	}

	bool ok =
		(C[0][1] - C[0][0] == C[1][1] - C[1][0] && C[0][1] - C[0][0] == C[2][1] - C[2][0])//b1-b0
		&& (C[0][2] - C[0][0] == C[1][2] - C[1][0] && C[0][2] - C[0][0] == C[2][2] - C[2][0])//b2-b0
		&& (C[0][2] - C[0][1] == C[1][2] - C[1][1] && C[0][2] - C[0][1] == C[2][2] - C[2][1])//b2-b1

		&& (c_[0][1] - c_[0][0] == c_[1][1] - c_[1][0] && c_[0][1] - c_[0][0] == c_[2][1] - c_[2][0])//b1-b0
		&& (c_[0][2] - c_[0][0] == c_[1][2] - c_[1][0] && c_[0][2] - c_[0][0] == c_[2][2] - c_[2][0])//b2-b0
		&& (c_[0][2] - c_[0][1] == c_[1][2] - c_[1][1] && c_[0][2] - c_[0][1] == c_[2][2] - c_[2][1])//b2-b1
		;
	if (ok) {
		out << "Yes\n";
	}
	else {
		out << "No\n";
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
def nasu(x):
  L = [0]
  t = x
  cnt = 1
  while t != 0:
    if t & 1:
      L.append(cnt)
    t >>= 1
    cnt += 1
  Ans = len(L) - 1

  L.append(H)
  pr = 0
  for i in range(1, W + 1):
    f = True
    for j in range(1, len(L)):
      k = D[L[j]][i] + D[L[j - 1]][pr] - D[L[j]][pr] - D[L[j - 1]][i]
      if k > K:
        pr = i - 1
        Ans += 1
        #print(pr, end = ",")
        break     
    else:
      continue
    for j in range(1, len(L)):
      k = D[L[j]][i] + D[L[j - 1]][pr] - D[L[j]][pr] - D[L[j - 1]][i]
      if k > K:
        return 10 ** 10
  #print(L, Ans)
  return Ans

H, W, K = list(map(int, input().split()))
S = [list(map(int, list(input()))) for _ in range(H)]

N = 2 **(H - 1)

D = [[0] * (W + 1) for _ in range(H + 1)]
for i in range(1, H + 1):
  D[i][1] = S[i - 1][0]

for i in range(1, H + 1):
  for j in range(2, W + 1):
    D[i][j] = D[i][j - 1] + S[i - 1][j - 1]

for i in range(2, H + 1):
  for j in range(W, 1, -1):
    D[i][j] += D[i - 1][j]
  D[i][1] += D[i - 1][1]

Ans = 10 ** 10
for i in range(N):
  Ans = min(Ans, nasu(i))

print(Ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  ll n,d;
  cin >> n >> d;
  ll l = 2*d + 1;
  cout << n / l + (n % l != 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;

    for (int i = 0;; i++) {
        if (A < B) {
            ans += i;
            break;
        }
        B *= 2;
    }
    for (int i = 0;; i++) {
        if (B < C) {
            ans += i;
            break;
        }
        C *= 2;
    }
    if (ans > K) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3472
#23:52

while True:
    taro_cards,hanako_cards = map(int,input().split())
    if taro_cards==0 and hanako_cards==0:
        break
    taros_card = [int(input()) for _ in range(taro_cards)]
    hanakos_card = [int(input()) for _ in range(hanako_cards)]

    diff = sum(taros_card) - sum(hanakos_card)
    taros_card.sort()
    hanakos_card.sort()

    answer_i = 0
    answer_j = 0
    answer_total = 99999
    
    for i in range(taro_cards):
        for j in range(hanako_cards):
            if sum(taros_card) - 2*taros_card[i] == sum(hanakos_card) - 2*hanakos_card[j]  and taros_card[i] + hanakos_card[j] <= answer_total:
                answer_i = taros_card[i] 
                answer_j = hanakos_card[j]
                answer_total = taros_card[i] + hanakos_card[j]
    
    if answer_total == 99999:
        print(-1)
    else:
        print(str(answer_i)  + " "+str(answer_j) )

                

    

    


Measured memory_bytes: 5608
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = (1 .. n).map{readLine()!!.split(" ").map{it.toDouble()}}
    var b = Array<Boolean>(n){false}
    var li = ArrayList<Int>(0)
    var sum : Double = 0.0
    fun dfs(){
        var ch = true
        for(i in 0 until n){
            if(!b[i]){
                ch = false
                b[i] = true
                li.add(i)
                dfs()
                li.remove(i)
                b[i] = false
            }
        }
        if(ch){
            var s : Double = 0.0
            for(i in 1 until n){
                s += Math.sqrt((a[li[i]][0] - a[li[i - 1]][0]) * (a[li[i]][0] - a[li[i - 1]][0]) + (a[li[i]][1] - a[li[i - 1]][1]) * (a[li[i]][1] - a[li[i - 1]][1]))
            }
            sum += s
        }
    }
    dfs()
    println("%.10f".format(sum / (1 .. n).map{it.toDouble()}.reduce{a1, a2 -> a1 * a2}))
}

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

int main(){

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int m;
	cin >> m;
	vector<int> b(m);
	for (int i = 0; i < m; i++) cin >> b[i];
	cout << (lexicographical_compare(a.begin(), a.end(), b.begin(), b.end())?1:0) << endl;
	return 0;
}


Measured memory_bytes: 3096
from collections import  defaultdict

s = input()
x, y = map(int, input().split())

s_splitted = s.split('T')
x -= len(s_splitted[0])

dist = {0: [], 1: []} # 0: x-direction, 1: y-direction
for i, Fs in enumerate(s_splitted[1:]):
    dist[(i+1) % 2].append(len(Fs))

reachable = {0: set([0]), 1: set([0])}

for i in range(2):
    for d in dist[i]:
        temp = []
        for r in reachable[i]:
            temp.append(r+d)
            temp.append(r-d)
        reachable[i] = set(temp)

if x in reachable[0] and y in reachable[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4460
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;

		static void Main(string[] args)
		{
			var n = RI;
			var l = (n / 2) + 1;
			int min = int.MaxValue;
			for (int i = 1;i <= l;i++)
			{
				min = Math.Min(sum(i) + sum(n-i),min);
			}
			Out(min);
		}

		static int sum(int i)
		{
			int ret = 0;
			while(i > 0)
			{
				ret += i % 10;
				i /= 10;
			}
			return ret;
		}
	}
}


Measured memory_bytes: 13140
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let mut h: usize = scan(tokens);
    let mut n: usize = 1;
    let mut ans: usize = 0;
    while h > 1 {
        ans += n;
        h /= 2;
        n *= 2;
    }
    ans += n;
    println!("{}", ans);
}


Measured memory_bytes: 4352
n,x,y = map(int,input().split())

A = list(map(int,input().split()))

#fin = open("rand_11.in","r")

#n,x,y = map(int,fin.readline().split())

#A = list(map(int,fin.readline().split()))

#fin.close()

X = [0]*n
Y = [0]*n
dpX = list(range(n)) 
dpY = list(range(n)) 

for i in range(n):
    X_bound = 10**18+1
    Y_bound = -10**18-1
    for j in range(i+1,n):
        X_bound = min(X_bound,abs(A[j]-A[i]))
        Y_bound = max(Y_bound,abs(A[j]-A[i]))
    X[i] = X_bound
    Y[i] = Y_bound

X[n-1] = -10**18-1
Y[n-1] = 10**18+1

for i in range(n-2,-1,-1):
    if X[dpX[i+1]]>X[i]:
        dpX[i] = dpX[i+1]
    if Y[dpY[i+1]]<Y[i]:
        dpY[i] = dpY[i+1]
#print(max(X))
#print(X)
#print(Y)
#print(dpX)
#print(dpY) 

curr = 0
hisatsuX = []
hisatsuY = []
while curr<n:
    hisatsuX.append(abs(A[-1]-y))
    if X[dpX[curr]]<abs(A[-1]-y):
        curr = n
        x = A[-1]
    else:
        x = A[dpX[curr]]
        curr = dpX[curr]+1
    #print(x)
    hisatsuY.append(abs(A[-1]-x))
    if curr >= n:
        break
    if Y[dpY[curr]]>abs(A[-1]-x):
        curr = n
        y = A[-1]
    else:
        y = A[dpY[curr]]
        curr = dpY[curr]+1
    #print(y)
for i in range(len(hisatsuX)):
    if hisatsuX[i] >= abs(x-y):
        print(hisatsuX[i])
        exit(0)
    if hisatsuY[i] <= abs(x-y):
        print(hisatsuY[i])
        exit(0)
print(abs(x-y))


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

int main() {
    int N, K;
    cin >> N >> K;
    ll ans = pow(N/K, 3);
    if (K % 2 == 0) {
        ans += pow((2*N/K+1)/2, 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
sp = []
for i in range(n):
    s, p = map(str, input().split())
    sp.append([s, int(p), i + 1])

sp.sort(key = lambda x:x[1], reverse = True)
sp.sort(key = lambda x:x[0])

for e in sp:
    print(e[2])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){

    int N, L;
    cin >> N >> L;
    
    int differ = 10000000;
    int ans = 0;
    
    int befor_eat = (L-1)*N + N*(N+1)/2;
    
    for (int i = 1; i <= N; i++) {
        int after_eat = befor_eat - (L+i-1);
        
        int diff = befor_eat - after_eat;
    
        int realdiff = diff;
        
        if (diff < 0) {
            diff = -diff;
        }
        
        if (differ > diff) {
            differ = diff;
            ans = after_eat;
        }
        
    }
    
    cout << ans << endl;
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 256
import os
import sys
import heapq


def solve(n, a):
    res = -10 ** 20
    for i in range(n, 2 * n + 1):
        l = a[0:i]
        r = a[i:3 * n]
        l.sort(reverse=True)
        r.sort()
        res0 = sum(l[0:n]) - sum(r[0:n])
        if res0 > res:
            res = res0
    return res


def find_best(n, a):
    h = list()
    s = 0
    best_s = -10**20
    res = list()
    for i in range(0, 2 * n):
        heapq.heappush(h, a[i])
        s += a[i]
        if len(h) > n:
            m = heapq.heappop(h)
            s -= m
        if len(h) == n:
            if best_s < s:
                best_s = s
            res.append(best_s)
    return res


def solve_large(n, a):
    res = -10 ** 20
    max_l = find_best(n, a)
    b = [-x for x in reversed(a)]
    max_r = find_best(n, b)
    max_r.reverse()
    for l, r in zip(max_l, max_r):
        res0 = l + r
        if res < res0:
            res = res0
    return res


input_file = 'd1.in'
if os.path.exists(input_file):
    sys.stdin = open(input_file)
n = int(input())
a = list(map(int, input().split()))
print(solve_large(n, a))


Measured memory_bytes: 37212
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static long rectangle(int a[]) {
		long s;
		int height = 0, len = 0;
		int n = a.length;

		for (int i = n - 1; i > 0; --i) {
			if (a[i] == a[i - 1]) {
				if (len == 0)
					len = a[i];
				else {
					if (height == 0)
						height = a[i];
					else
						break;
				}
				--i;
			}
		}

		s = (long) len * (long) height;
		return s;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, a[];

		n = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = sc.nextInt();

		sc.close();

		Arrays.sort(a);
		long ans = rectangle(a);

		System.out.println(ans);
	}

}


Measured memory_bytes: 51732