akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T>
using MaxHeap = priority_queue<T, vector<T>, less<T>>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline void input(vector<T> &vec) {
    for (auto &e: vec) {
        cin >> e;
    }
}

template <class T>
inline void input(vector<vector<T>> &mat) {
    for (auto &vec: mat) {
        input(vec);
    }
}

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &strm, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        strm << e << delim[&e == &vec.back()];
    }
    return strm;
}

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(string, s);
    
    for (auto &e: s) e = 'x';

    print(s);

    return 0;
}


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

int main()
{
	int N, cnt = 0;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}

	for (int i = 0; i < N - 1; i++)
	{
		for (int j = N - 1; j >= i + 1; j--)
		{
			if (A.at(j) < A.at(j - 1))
			{
				swap(A.at(j), A.at(j - 1));
				cnt++;
			}
		}
	}
	for (int i = 0; i < N; i++)
	{
		if (i != N - 1)
			cout << A.at(i) << ' ';
		else
			cout << A.at(i) << endl;
	}
	cout << cnt << endl;
}


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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

void Main() {
    int64_t n, q, l, r, tmp = 0;
    string s;
    cin >> n >> q >> s;
    vector<int> memo(n, 0);
    rep(i, n-1) {
        if(s[i] == 'A' && s[i+1] == 'C') {
            memo[i+1] = 1;
        } else {
            memo[i+1] = 0;
        }
    }
    rep(i, n) {
        memo[i] += tmp;
        tmp = memo[i];
    }
    rep(i, q) {
        cin >> l >> r; l--; r--;
        cout << memo[r] - memo[l] << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
			int a = Math.Abs(input[0] - input[1]);
			int b = Math.Abs(input[0] - input[2]);
			if (a < b) Console.WriteLine("A");
			else Console.WriteLine("B");
		}
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
int main()
{ int a,b,c,d,k,t;
while(~scanf("%d %d %d %d",&a,&b,&c,&d))
{    if(a>b)
    {

     t=b*c;
     k=(a-b)*d;
     printf("%d\n",t+k);}
     else
     printf("%d\n",a*c);
}

return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxN = 101;
/*
	input:
	6
	5 2 4 6 1 3
	output:
	5 2 4 6 1 3
	2 5 4 6 1 3
	2 4 5 6 1 3
	2 4 5 6 1 3
	1 2 4 5 6 3
	1 2 3 4 5 6
*/

int T[maxN];
int N;

void printT(){
	for(int i = 0;i < N - 1;i++)cout << T[i] << " ";
	cout << T[N - 1];
}

int main(){
	int num;
	cin >> N;
	for(int i = 0;i < N;i++){
		cin >> num;
		T[i] = num;
	}
	int j;
	for(int i = 0;i < N;i++){
		j = 0;
		while(T[j] < T[i] && j < i)j++;
		int value = T[i];
		for(int k = i;k > j;k--)T[k] = T[k - 1];
		T[j] = value;
		printT();
		cout << endl;
//		if(i != N - 1)cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n * a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int N,M,a,b,c;
scanf("%d", &N);

if(100<N || N<999)
{
    a=N%10;
    M=N/10;
    b=M%10;
    c=M/10;
    if(a==7 || b==7 || c==7)
    {
        printf("Yes");
    }
    else{
        printf("No");
    }
}
else{
    printf("input is not right");
}
}

Measured memory_bytes: 1716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int nm[][] = new int[n][m];
		int ml[][] = new int[m][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				nm[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				ml[i][j] = sc.nextInt();
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				ans = 0;
				for (int k = 0; k < m; k++) {
					ans += nm[i][k] * ml[k][j];
				}
				if(j!=l-1) {
					System.out.print(ans + " ");
				}else {
					System.out.print(ans);
				}
			}
			System.out.println();
		}
	}
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	string s;
	cin >> s;
	if(s == "KIHBR") cout <<"YES" << endl;
	else if(s == "AKIHBR") cout <<"YES" << endl;
	else if(s == "KIHBAR") cout <<"YES" << endl;
	else if(s == "AKIHBAR") cout <<"YES" << endl;
	else if(s == "KIHABR") cout <<"YES" << endl;
	else if(s == "AKIHABR") cout <<"YES" << endl;
	else if(s == "KIHABAR") cout <<"YES" << endl;
	else if(s == "AKIHABAR") cout <<"YES" << endl;
	else if(s == "KIHBRA") cout <<"YES" << endl;
	else if(s == "AKIHBRA") cout <<"YES" << endl;
	else if(s == "KIHBARA") cout <<"YES" << endl;
	else if(s == "AKIHBARA") cout <<"YES" << endl;
	else if(s == "KIHABRA") cout <<"YES" << endl;
	else if(s == "AKIHABRA") cout <<"YES" << endl;
	else if(s == "KIHABARA") cout <<"YES" << endl;
	else if(s == "AKIHABARA") cout <<"YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 3548
N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
# dp[0], dp[1] = 0, abs(h[1] - h[0])
dp[0] = 0
for i in range(1,N):
    dp[i] = dp[i-1] + abs(h[i]-h[i-1])
    if i > 1:
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]),dp[i-1] + abs(h[i]-h[i-1]))

print(dp[N-1])

Measured memory_bytes: 13980
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define PI 3.1415926535897932384626
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(all(a));
	bool flag = true;
	if (a[n - 1] > a[0] * 2) flag = false;
	for (int i = a[n - 1] / 2 + 1; i <= a[n - 1]; i++) {
		if (mp[i] < 2) flag = false;
	}
	if (a[n - 1] % 2 == 0 && mp[a[n - 1] / 2] != 1) flag = false;
	if (a[n - 1] % 2 == 1 && mp[a[n - 1] / 2 + 1] != 2) flag = false;
	cout << (flag ? "Possible" : "Impossible") << endl;
} 

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int x, a;
  	cin >> x >> a; 
	if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

int ans[10007];

int computa(int a, int b, int c){
	return a*a + b*b + c*c + a*b + a*c + b*c;
}

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

	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			for(int k = 1; k <= 100; k++){
				int p = computa(i, j, k);
				if(p <= 10000){
					ans[p]++;
				}
			}
		}
	}


	int n; cin >> n;

	for(int i = 1; i <= n; i++)
		cout << ans[i] << '\n';

	return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	int now = 0;
	rep(i,s.size()){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
		else {
			now += s[i] - '0';
			if(now == k){
				cout << 1 << endl;
				return 0;
			}
		}
	}

}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    vector<int> V = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << V.at(K-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    n = n % k
    print(min(n % k, abs(n - k)))
    
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 1;
  ll mx = 1e18;
  rep(i, n) {
    if(a[i] == 0) {
      ans = 0;
      break;
    }
    if(ans > mx / a[i]) {
      ans = -1;
      break;
    }
    ans *= a[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n,m,aa=100000,ab=100000;
  int th[200],hh[200];

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0)break;
    aa = 100000;
    ab = 100000; 
    int tsum=0,hsum=0;
    for(int i=0;i<n;i++){cin>>th[i]; tsum+=th[i];}
    for(int i=0;i<m;i++){cin>>hh[i]; hsum+=hh[i];}
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(tsum-th[i]+hh[j] == hsum-hh[j]+th[i]){
	  if(th[i]+hh[j] < aa + ab){
	  aa = th[i];
	  ab = hh[j];
	  }
	} 
      }
    }
 if(aa != 100000 && ab != 100000)cout << aa << " " << ab << endl;
      else cout << "-1" << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

using namespace std;

int F(unsigned long long int A,unsigned long long int B){
  return max(log10(A),log10(B))+1;
}

int main(void){
  unsigned long long int N,i;
  int ans=INF;
  cin >> N;
  for(i=1;i<sqrt(N+1);i++){
    if(N%i==0){
      ans=min(ans,F(i,N/i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	string s;cin>>s;
	s[3]='8';
	cout<<s<<endl;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string n;int k;cin>>n>>k;
  int dig=n.size();
  int i,j;
  vector<int> num(dig);
  rep(i,dig)num[i]=n[i]-'0';
  vector<vector<int>> dp0(dig+1,vector<int>(k+1,0));
  vector<vector<int>> dp1(dig+1,vector<int>(k+1,0));
  dp1[0][0]=1;
  for(i=1;i<=dig;i++)
  {
    for(j=0;j<=k;j++)
    {
      if(num[i-1]==0)
      {
        dp0[i][j]+=dp0[i-1][j];
        if(j-1>=0)dp0[i][j]+=dp0[i-1][j-1]*9;
        dp1[i][j]+=dp1[i-1][j];
      }
      else
      {
        dp0[i][j]+=dp0[i-1][j]+dp1[i-1][j];
        if(j-1>=0)
        {
          dp0[i][j]+=dp0[i-1][j-1]*9;
          dp0[i][j]+=dp1[i-1][j-1]*(num[i-1]-1);
          dp1[i][j]+=dp1[i-1][j-1];
        }
      }
    }
  }
  cout<<dp0[dig][k]+dp1[dig][k]<<endl;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int x=Integer.parseInt(scan.next());
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int n=(x-a)/b;
    		
    		System.out.print(x-a-(n*b));
 
     
    }
    }
// end 

Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int get_gcd(int a, int b)
{
    if (a % b == 0)
        return b;
    return get_gcd(b, a % b);
}

vector<int> get_all_divisor(int N)
{
    vector<int> res;
    for (int i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            if (i * i == N)
            {
                res.push_back(i);
            }
            else
            {
                res.push_back(i);
                res.push_back(N / i);
            }
        }
    }
    return res;
}

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> v(N);

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &v[i]);
    }

    if (N == 2)
    {
        printf("%d\n", max(v[0], v[1]));
        return 0;
    }

    int gcd = v[0];
    for (int i = 1; i < N; i++)
    {
        gcd = get_gcd(gcd, v[i]);
    }

    for (int i = 0; i < N; i++)
    {
        v[i] /= gcd;
    }

    //if changed number is v[0]
    int ans = v[1];
    for (int i = 2; i < N; i++)
    {
        ans = get_gcd(ans, v[i]);
    }

    //if changed number is not v[0]
    vector<int> vd = get_all_divisor(v[0]);
    for (int x : vd)
    {
        int nskip = 0;
        for (int i = 1; i < N; i++)
        {
            if (v[i] % x != 0)
            {
                nskip++;
                if (nskip > 1)
                    break;
            }
        }

        if (nskip == 1)
        {
            ans = max(ans, x);
        }
    }

    printf("%d\n", ans * gcd);
}

Measured memory_bytes: 640
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    Y = list(map(int, input().split()))

    X_com = 0
    for i in range(1, N+1):
        X_com += (i - 1) * X[i-1] - (N - i) * X[i-1]

    Y_com = 0
    for i in range(1, M+1):
        Y_com += (i - 1) * Y[i-1] - (M - i) * Y[i-1]

    return (X_com * Y_com) % (10**9 + 7)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 19308
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI

int main() {
    int64_t x;cin>>x;
    /*
    vector<int> kou;
    for(int i=1; i<=x; ++i){
        if(x%i==0) kou.push_back(i);
    }

    for(int i: kou){
        rep(A,100){
            int B=A-i;
            int64_t sum=pow(A,5)-pow(B,5);
            if(sum==x) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
        for(int A=-1;A>=-120;--A){
            int B=A-i;
            int64_t sum=(A-B)*pow(A+B,2)*(A*A-A*B+B*2);
            if(sum==x) {
                cout << A << " " << B << endl;
                return 0;
            }
        }

    }*/
    rep(A,200){
        if((pow(A,5)-x)>=0){
            for(int B=0; B<=200;++B){
                int64_t sum=pow(A,5)-pow(B,5);
                if(sum==x) {
                    cout << A << " " << B << endl;
                    return 0;
                }
            }
        }
        else{
            for(int B=0; B>=-200;--B){
                int64_t sum=pow(A,5)-pow(B,5);
                if(sum==x) {
                    cout << A << " " << B << endl;
                    return 0;
                }
            }
        }
    }
    /*
    for(int i=0;i<=110;++i){
        int zan=pow(i,5)-x;
        int b=int(log10(zan)/log10(5.0));
        if(zan==pow(b,5)){
            cout << i << " " << b << endl;
            return 0;
        }
    }
    for(int i=-1;i>=-110;--i){
        int zan=pow(i,5)-x;
        int b=log(zan)/log(5);
        if(zan==pow(b,5)){
            cout << i << " " << b << endl;
            return 0;
        }
    }*/
}





Measured memory_bytes: 4072
<?php
while (true) {
        list($x, $y) = fscanf(STDIN, "%d %d");
        if ($x === 0 && $y === 0) break;
        if ($x < $y) {
                echo "$x $y",PHP_EOL;
        } else {
                echo "$y $x",PHP_EOL;
        }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int A;

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

  std::cin >> N;

  int mx = 0;

  for(int i=0;i<N;++i){
      std::cin >> A;

      if(A - 1 == mx){
          mx = A;
      }
  }

  int res = -1;

  if(mx > 0){
      res = N - mx;
  }

  std::cout << res << std::endl;
}


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

int main() {
	int N;
	cin >> N;
	double sum=0;
	double arr[N];
	for (int i=0; i<N; i++){
		cin>>arr[i];
		sum += arr[i];
	}
	double avg = round(sum/N);
	int total=0;
	for (int i=0; i<N; i++){
		total+= (avg-arr[i])*(avg-arr[i]);
	}
	cout << total<< endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		if(S.charAt(0) == S.charAt(1)) {
			System.out.println("Bad");
		} else if(S.charAt(1) == S.charAt(2)) {
			System.out.println("Bad");
		} else if(S.charAt(2) == S.charAt(3)) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
		
		
	}
}


Measured memory_bytes: 23380
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){


//  int n,x,y;
//  cin>>n>>x>>y;
//  cout<< max(1,min(n,x+y-n+1)) <<" "<< min(n, x+y-1)<<endl;



// }

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

  int n;
  cin>>n;
  n%=1000;
  n = (1000-n)%1000;
  cout<<n<<"\n";
}



Measured memory_bytes: 3144
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int q=sc.nextInt();
    String s=sc.next()+"#";
    int[] a=new int[n+1];
    for(int i=0;i<n;i++){
      a[i+1]=a[i];
      if(s.charAt(i)=='A'&&s.charAt(i+1)=='C'){
        a[i+1]++;
      }
    }
//    System.out.println(Arrays.toString(a));
    for(int i=0;i<q;i++){
      int f=sc.nextInt();
      int t=sc.nextInt();
      if(a[t]!=a[t-1]){
        System.out.println(a[t]-a[f-1]-1);
      }else{
        System.out.println(a[t]-a[f-1]);
      }
    }
  }
}

Measured memory_bytes: 59984
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

string s[20];
ll h,w;

ll f(int sx, int sy, int ex, int ey)
{
    vector<vector<ll>> dp(h,vector<ll>(w,-1));
    queue<pair<int,int>> q;
    q.push({sx,sy});
    dp[sx][sy]=0;
    while(!q.empty())
    {
        int x=q.front().fi;
        int y=q.front().se;
        q.pop();
        if(x==ex && y==ey) return dp[x][y];
        repf(i,0,4)
        {
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(nx>=0 && nx<h && ny>=0 && ny<w && s[nx][ny]=='.' && dp[nx][ny]==-1)
            {
                q.push({nx,ny});
                dp[nx][ny]=dp[x][y]+1;
            }
        }
    }
    return -1;
}

int main()
{
    IOS; 
    cin>>h>>w;
    repf(i,0,h) cin>>s[i];
    ll ans=0;
    repf(i,0,h)
    {
        repf(j,0,w)
        {
            if(s[i][j]=='#') continue;
            repf(k,0,h)
            {
                repf(l,0,w)
                {
                    if(s[k][l]=='#') continue;
                    ans=max(ans,f(i,j,k,l));
                }
            }
        }
    }
    cout<<ans<<endl;
}  

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int n,a,b,w;
	scanf("%d %d %d",&n,&a,&b);
	w=n*a;
	if(w<b){
		printf("%d\n",w);
	}
	else{
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll kai(ll x){
  if(x == 1) return 1;
  return x * kai(x-1) % MOD;
}

int main(){
  ll N; cin >> N;
  if(N < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let vec: Vec<u32> = read_vec();
    let k = vec[0] + vec[1];
    if k % 2 == 1 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", k / 2);
    }
}


Measured memory_bytes: 4352
unittest
{
	assert( [ "CODEFESTIVAL" ].parse.expand.solve == "CODE FESTIVAL" );
	assert( [ "POSTGRADUATE" ].parse.expand.solve == "POST GRADUATE" );
	assert( [ "ABCDEFGHIJKL" ].parse.expand.solve == "ABCD EFGHIJKL" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return s[ 0 .. 4 ] ~ ' ' ~ s[ 4 .. $ ];
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
 
#define N 8
#define WHITE -1
#define BLACK 1
 
int r[N], cl[N], dpos[2*N-1] , dneg[2*N-1];
bool X[N][N];

void Ansplot() {
  int i,j;
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) {
      if(X[i][j]) {
        if(r[i] != j) return;
      }
    }
  }
  
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) printf("%s", (r[i] == j) ? "Q":"." );
    printf("\n");
  }
}
 
void recursive(int i) {
  if(i == N) {
    Ansplot
();
    return;
}
 
int j;
for(j=0;j<N;j++) {
  if(BLACK == cl[j] ||
     BLACK == dpos[i+j] ||
     BLACK  == dneg[i-j+N-1]) continue;
 
     r[i] = j; cl[j] = dpos[i+j] = dneg[i-j+N-1] = BLACK;
 
     recursive(i+1);
     r[i] = cl[j]=dpos[i+j] = dneg[i-j+N-1] = WHITE;
 
}
}
 
int main() {

  int i,j,k;
  for(i = 0;i<N;i++) r[i] = WHITE, cl[i] = WHITE;
  for(i=0;i<2*N-1;i++) dpos[i] = WHITE; dneg[i] = WHITE;
  
  for(i = 0;i<N;i++){
    for(j=0;j<N;j++) X[i][j] = false;
  }
  
  scanf("%d\n", &k);

  for(i = 0;i<N;i++) {
    int r,c; scanf("%d%d\n", &r,&c );
    X[r][c] = true;
  }
 
  recursive(0);
 
  return 0;
}

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

using namespace std;

typedef long long         ll;
typedef pair <int,int>    ii;
typedef vector <int>      vi;
typedef vector <int,int>  vii;

#define INF 2000000000
#define pb push_back
#define what_is(x) cerr <<#x<<" is "<<x<<endl;

int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
    int n;
    cin>>n;
    int a=n%10;
    n/=10;
    int b=n%10;
    n/=10;
    int c=n%10;
    n/=10;
    int d=n%10;
    int k=0;
    if(a==2) k++;
    if(b==2) k++;
    if(c==2) k++;
    if(d==2) k++;
    cout<<k;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  vector<int> vec(3);
  for (int i = 0; i < 3; i++)
  {
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  cout<<abs(vec[0] - vec[1]) +abs(vec[2] - vec[1])<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N;

int main(){
cin >> N;

if(N == 0)cout << 1;
if(N == 1)cout << 0;
}

Measured memory_bytes: 3640
//                        Bismillahir Rahmanir Rahim
//ALGO:
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define MX 1000010
#define mod 1000000007
#define dout if(debug) cout
#define FR(i, n) for(int i=0; i<n; i++)
#define FOR(i, n) for(int i=1; i<=n; i++)
const double Pi=acos(-1);
using namespace std;
int debug=01;
bitset<10000001>pr;
int pl[664580], s;
void sieve(int mx)
{
    for(int p=4; p<=mx; p+=2)pr[p]=1;
    for(int p=3; p*p<=mx; p+=2)if(!pr[p])if(p<=sqrt(mx))for(int i=p*p; i<=mx; i+=p)pr[i]=1;
    for(int i=2; i<=mx; i++)if(!pr[i])pl[s++]=i;
}
void solve(){
    sieve(1000000);
    int n, c=1;
    cin>>n;
    for(int i=2; i<n; i++){
        int x=i, y=1;
        for(int j=0; pl[j]*pl[j]<=x; j++){
            int t=1;
            while(!(x%pl[j])){
                x/=pl[j];
                t++;
            }
            y*=t;
        }
        if(x!=1)y*=2;
        c+=y;
    }
    cout<<c;
}
int main() {
    Fast
    int tst=1;
    //cin>>tst;
    for(int T=1; T<=tst; T++){
        //cout<<"Case "<<T<<": ";
        solve();
    }
}


Measured memory_bytes: 4116
//package april2020;

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {
//	static long[] dp;
	static int n;
	static long MOD = (long)1e9+7;
//	static ArrayList<Integer>[] graph;
//	static HashSet<Integer> visited;
//	static long[][] dp;
//	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
		FastReader scn = new FastReader();
		OutputStream out = new BufferedOutputStream ( System.out );
		int n = scn.nextInt();
		char[] k=scn.next().toCharArray();
		long[][] dp = new long[n+1][n+1],pref = new long[n+1][n+1];
		dp[1][1] = 1;
		for(int len=2;len<=n;len++) {
			for(int i =1;i<=len-1;i++) {
				pref[len-1][i]=pref[len-1][i-1]+dp[len-1][i];
			}
			for(int b=1;b<=len;b++) {
				int l,r;
				if(k[len-2]=='<') {
					l=1;
					r = b-1;
				}else {
					l=b;
					r=len-1;
				}
				
				if(l<=r) {
					dp[len][b] =(dp[len][b]+pref[len-1][r]-pref[len-1][l-1])%MOD;
				}
				
//				for(int a = 1;a<=len-1;a++) {
//					int real_a = a;
//					if(a>=b) {
//						real_a++;
//					}
//					if((real_a<b)!=(k[len-2]=='<')) {
//						continue;
//					}
//					dp[len][b] = (dp[len][b]+dp[len-1][a])%MOD;
//				}
			}
		}
		long ans =0;
		for(int b =1;b<=n;b++) {
			ans = (ans+dp[n][b])%MOD;
		}
		out.write((ans+"\n").getBytes());
		out.close();
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 182592
#include <stdio.h>

#define MAX_NUM 1000000007

int main(void) {
	long long int h, w;
	scanf("%lld %lld", &h, &w);

	if ((h == 1) || (w == 1)) {
		printf("1\n");
	}
	else if ((h % 2 == 0) || (w % 2 == 0)) {
		printf("%lld\n", h * w / 2);
	}
	else {
		printf("%lld\n", (h / 2 + 1) * (w / 2 + 1) + (h / 2) * (w / 2));
	}


	return 0;
}

Measured memory_bytes: 128
# int(input()) # 入力が1つ
from math import ceil
n, a, b = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

monster = []
for i in range(n):
    monster.append(int(input()))

def check(monster, t):
    temp = []
    for i in range(n):
        temp.append(monster[i] - b * t) 
    ans = 0
    for i in range(n):
        if temp[i] > 0:
            ans += ceil(temp[i] / (a - b))
    if ans <= t:
        return True
    return False

l = 0
r = 10 ** 10
ans = 10 ** 10
while l <= r:
    mid = (l + r) // 2
    if check(monster, mid):
        ans = min(ans, mid)
        r = mid - 1
    else:
        l = mid + 1
print(ans)

Measured memory_bytes: 119128
#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 x,y; cin>>x>>y;
    int xg=1,yg=1;
    V g2={4,6,9,11};
    if(x==2) xg=3;
    if(y==2) yg=3;
    rep(i,0,4){
        if(x==g2[i])xg=2;
        if(y==g2[i])yg=2;
    }
    if(xg==yg) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    n = int(input())
    arry = [list(map(int, input().split())) for _ in range(n)]
    ans = [arry[0]]

    for i in range(1, n):
        a, b = arry[i]
        if a >= ans[i-1][0] and b >= ans[i-1][1]:
            ans.append([a, b])
        else:
            num = max(-(-ans[i-1][0] // a), -(-ans[i-1][1] // b))
            a *= num
            b *= num
            ans.append([a, b])
    print(sum(ans[-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	v := make([]float64, n)
	for i := range v {
		fmt.Scan(&v[i])
	}

	sort.Float64s(v)
	ans := v[0]
	for _, x := range v[1:] {
		ans = (ans + x) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
ll a[100001];
int main(){
    cin>>n;
    int cnt=0;
    ll sum=0;
    int mn=1000100010;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0) ++cnt;
        sum+=abs(a[i]);
        mn=min((ll)mn,abs(a[i]));
    }
    if(cnt%2==0){
        cout<<sum<<endl;
    }
    else{
        cout<<sum-mn*2<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
/*Author- Soumak Poddar*/

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define um unordered_map
#define mp make_pair
#define pb push_back

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

   #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("error.txt", "w", stderr);
      freopen("output.txt", "w", stdout);
   #endif
   
   int t=1;
   // cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"Time Taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}
void solve()
{
   int n;
   cin>>n;
   int dp[n+1];
   int h[n];
   for(int i=0;i<n;i++)
      cin>>h[i];
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(int i=2;i<n;i++)
      dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
   cout<<dp[n-1];
}

Measured memory_bytes: 4552
#include <bits/stdc++.h>
#define INF 1e9

using namespace std;

int h,w,c;
int col[10][10];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool b[10][10];

bool contain(int y,int x){
    return (y>=0 && y<h && x>=0 && x<w);
}

int dfs(int y,int x){
    if(col[y][x]!=c)return 0;
    if(b[y][x])return 0;
    b[y][x]=true;
    int res=0;
    for(int i=0;i<4;i++){
        if(!contain(y+dy[i],x+dx[i]))continue;
        res+=dfs(y+dy[i],x+dx[i]);
    }
    return res+1;
}

void update(int y,int x,int cc,int color){
    col[y][x]=color;
    for(int i=0;i<4;i++){
        if(!contain(y+dy[i],x+dx[i]))continue;
        if(col[y+dy[i]][x+dx[i]]!=cc)continue;
        update(y+dy[i],x+dx[i],cc,color);
    }
}

int solve(int color,int t){
    if(t==5){
        if(color==c){
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    b[i][j]=false;
                }
            }
            return dfs(0,0);
        }
        else return 0;
    }
    int res=0;
    int tmp[10][10];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            tmp[i][j]=col[i][j];
        }
    }
    for(int i=1;i<=6;i++){
        if(i==color)continue;
        update(0,0,col[0][0],i);
        res=max(res,solve(i,t+1));
        for(int j=0;j<h;j++){
            for(int k=0;k<w;k++){
                col[j][k]=tmp[j][k];
            }
        }
    }
    return res;
}

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

    while(1){
        cin>>h>>w>>c;
        if(h==0)break;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>col[i][j];
            }
        }
        int ans=solve(col[0][0],0);
        cout<<ans<<endl;
    }

}



Measured memory_bytes: 3120
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn gcd(a: u64, b: u64) -> u64 {
    let mut a = a;
    let mut b = b;
    loop {
        if b == 0 {
            return a;
        }
        a %= b;
        if a == 0 {
            return b;
        }
        b %= a;
    }
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
fn main() {
    input! { n, m: u64, mut a :[u64; n] };
    let mut x = 1;
    while a.iter().all(|x| x & 1 == 0) {
        for i in 0..n {
            a[i] /= 2;
        }
        x *= 2;
    }
    if a.iter().any(|x| x & 1 == 0) {
        println!("{}", 0);
        return;
    }
    let mut r = x / 2;
    for i in 0..n {
        r = lcm(r, a[i]);
    }
    println!("{}", m / r - m / (r * 2));
}


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

#define fi first
#define se second
#define ll long long

const int N = 200200;
const int block = 444;

using namespace std;

int n;
int tim;
int a[N];
int ans[N];
int tin[N];
int tout[N];
int t[4 * N];
bool dead[N];
vector < int > v[N];

void dfs(int x, int p)
{
        tin[x] = ++tim;
        for(int y: v[x]){
                if(y == p){
                        continue;
                }
                dfs(y, x);
        }
        tout[x] = tim;
}

void upd(int x, int l, int r, int g, int y)
{
        if(l == r){
                t[x] = y;
                return;
        }
        int m = (l + r) / 2;
        if(g <= m){
                upd(x * 2, l, m, g, y);
        }
        else{
                upd(x * 2 + 1, m + 1, r, g, y);
        }
        t[x] = min(t[x * 2], t[x * 2 + 1]);
}

void upd(int x)
{
        if(dead[x]){
                return;
        }
        upd(1, 1, n, tin[x], 1e9);
        dead[x] = true;
        for(int y: v[x]){
                if(dead[y]){
                        continue;
                }
                upd(1, 1, n, tin[y], y);
        }
}

int get(int x, int l, int r, int tl, int tr)
{
        if(tl > tr){
                return 1e9;
        }
        if(l == tl && r == tr){
                return t[x];
        }
        int m = (l + r) / 2;
        return min(get(x * 2, l, m, tl, min(m, tr)), get(x * 2 + 1, m + 1, r, max(m + 1, tl), tr));
}

void solve(int x, int p, int mx)
{
        ans[x] = ans[p] + 1 - dead[x];
        upd(x);
        while(true){
                int y = get(1, 1, n, tin[x], tout[x]);
                if(y > mx){
                        break;
                }
                ans[x]++;
                upd(y);
        }
        for(int y: v[x]){
                if(y == p){
                        continue;
                }
                solve(y, x, max(mx, x));
        }
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 1; i < n; i++){
                int x, y;
                cin >> x >> y;
                v[x].push_back(y);
                v[y].push_back(x);
        }
        for(int i = 0; i < 4 * N; i++){
                t[i] = 1e9;
        }
        dfs(1, 1);
        dead[1] = true;
        for(int x: v[1]){
                solve(x, 1, 1);
        }
        for(int i = 2; i <= n; i++){
                cout << ans[i] << " \n"[i == n];
        }
}




Measured memory_bytes: 27648