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

using namespace std;

string mines(vector<string>&m, int n, int k, int i, int j){
    if(m[i][j] == '#') return "#";
    int sum = 0;
    if(i-1 >= 0 && j-1 >= 0){ if(m[i-1][j-1] == '#') sum++; }
    if(i-1 >= 0)            { if(m[i-1][j]   == '#') sum++; }
    if(i-1 >= 0 && j+1 < k) { if(m[i-1][j+1] == '#') sum++; }
    if(j-1 >= 0)            { if(m[i][j-1]   == '#') sum++; }
    if(j+1 < k)             { if(m[i][j+1]   == '#') sum++; }
    if(i+1 < n && j-1 >= 0) { if(m[i+1][j-1] == '#') sum++; }
    if(i+1 < n)             { if(m[i+1][j]   == '#') sum++; }
    if(i+1 < n && j+1 < k)  { if(m[i+1][j+1] == '#') sum++; }
    ostringstream ss;
    ss << sum;
    return ss.str();
}

int main(){

    int n, k;
    cin >> n >> k;

    vector<string> m;

    for(int i = 0; i < n; i++){
	string s;
	cin >> s;
	m.push_back(s);
    }

    for(int i = 0; i < n; i++){
	for(int j = 0; j < k; j++){
	    cout << mines(m, n, k, i, j);
	}
	cout << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char ch;
  int a,b;
  cin >> a;
  while(1){
    cin >> ch;
    if(ch == '=')break;
    cin >> b;
    if(ch == '+'){
      a = a+b;
    }else if(ch == '-'){
      a = a-b;
    }else if(ch == '*'){
      a = a*b;
    }else if(ch == '/'){
      a = a/b;
    }
  }
  cout << a << endl;
}

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

int main() {
	string S;
	long long int K, Inf = 0;
	cin >> S >> K;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != '1') {
			Inf = i;
			break;
		}
	}
	if (Inf < K) cout << S[Inf];
	else cout << '1';
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int[][] points = new int[N][2];
        for(int i = 0; i < N; i++) {
            points[i][0] = sc.nextInt();
            points[i][1] = sc.nextInt();
        }

        Arrays.sort(points, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                long s1 = o1[0] + o1[1];
                long s2 = o2[0] + o2[1];
                return -1 * Long.compare(s1, s2);
            }
        });

        long ans = 0;
        for(int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                ans += points[i][0];
            } else {
                ans -= points[i][1];
            }
        }

        System.out.println(ans);
    }
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n), b(n);
  int sum = 0;
  int mn = inf;
  bool flag = true;
  rep(i, n) {
    cin >> a[i] >> b[i];
    sum += a[i];
    flag &= a[i] == b[i];
    if(a[i] > b[i]) chmin(mn, b[i]);
  }
  if(flag) cout << 0 << endl;
  else cout << sum-mn << endl;

  return 0;
}


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


int a[110];
int dp[100010];
int n;

int pobeda(int k)
{
    if(dp[k]!=0) return dp[k];
    for(int i = 0; i < n && a[i] <= k; i++)
    {
        if(pobeda(k - a[i]) == 2)
        {
            dp[k] = 1;
            return 1;
        }
    }
    dp[k] = 2;
    return 2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >>a[i];
        dp[a[i]] = 1;
    }
    dp[0] = 1;
    sort(a, a+n);
    if(pobeda(k) == 1) cout << "First";
    else cout << "Second";
    
    
    
    return 0;
}

Measured memory_bytes: 3712
import qualified Data.ByteString.Char8 as C
import Data.Maybe (fromJust)
import Data.Ratio
import Data.List 

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  as <- getParms
  let (sw,s) = select as
  putStrLn $ show sw ++ " " ++ show s

type SW = Int -- SugarWater
type S  = Int -- Sugar

ratio :: (SW, S) -> Maybe (Ratio Int)
ratio (a,b) = if a==0 then Nothing 
                      else Just (b % a) 

combinations :: [Int] -> [(SW,S)]
combinations [a,b,c,d,_e,f] 
  = [(w + s,s)
      | let fa = f `div` (100*a)
      , na <- [0 .. fa]
      , let fb = (f-100*a*na) `div` (100*b)
      , nb <- [0 .. fb]
      , let w = 100*(a*na + b*nb)
      , let fc = (f-w) `div` c
      , nc <- [0 .. fc]
      , let fd = (f-w-c*nc) `div` d
      , nd <- [0 .. fd]
      , let s = c*nc + d*nd
      , na + nb > 0
      ]

select :: [Int] -> (SW,S)
select as@[a,b,c,d,e,f] = h e ls l
  where
    (l:ls) = combinations as

    h :: Int -> [(SW,S)] -> (SW,S) -> (SW,S)
    h _ []     best     = best
    h e (m:ms) best
      | rmax < ratio best = h e ms m
      | rmax == rm      = m
      | rmax <  rm      = h e ms best
      | ratio best < rm
          && rm < rmax  = h e ms m
      | otherwise       = h e ms best
      where
        rm = ratio m
        rmax = ratio (e+100, e)


Measured memory_bytes: 1916
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
xyz = [LIST() for _ in range(N)]
ans = []
for i in range(0, 2):
	for j in range(0, 2):
		for k in range(0, 2):
			if i == 0:
				k_x = 1
			else:
				k_x = -1
			if j == 0:
				k_y = 1
			else:
				k_y = -1
			if k == 0:
				k_z = 1
			else:
				k_z = -1
			tmp = [x*k_x+y*k_y+z*k_z for x, y, z in xyz]
			tmp.sort(reverse=True)
			ans.append(sum(tmp[0:M]))
print(max(ans))


Measured memory_bytes: 4060
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long LL;

const int MN = 100005;

int N, M;
int a[MN], b[MN];
int c[MN];

int B[MN * 2];
void Add(int i) { for (; i <= N * 2; i += i & -i) ++B[i]; }
int Qur(int i) { int A = 0; for (; i; i -= i & -i) A += B[i]; return A; }

inline bool check(int x) {
	for (int i = 1; i <= N; ++i)
		c[i] = c[i - 1] + (a[i] >= x);
	memset(B, 0, sizeof B);
	LL Sum = 0, NN = (LL)N * (N + 1) / 2;
	for (int i = 1; i <= N; ++i) {
		Add(2 * c[i - 1] - (i - 1) + N);
		Sum += Qur(2 * c[i] - i + N);
	}
	return Sum * 2 >= NN;
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
		scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + N + 1);
	M = unique(b + 1, b + N + 1) - b - 1;
	int lb = 1, rb = M, mid, ans = 0;
	while (lb <= rb) {
		mid = lb + rb >> 1;
		if (check(b[mid])) ans = mid, lb = mid + 1;
		else rb = mid - 1;
	}
	printf("%d\n", b[ans]);
	return 0;
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


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

    unordered_set<int> s;
    int x;
    for (int i = 0; i < 3; ++i) {
        cin >> x;
        s.insert(x);
    }
    cout << (s.size() == 2 ? "Yes" : "No") << endl;


    return 0;
}



Measured memory_bytes: 896
def main():
    import sys
    input = sys.stdin.readline

    S_raw = input().rstrip('\n')

    S = [int(s) for s in S_raw]
    N = len(S)
    ans = 0
    dp0 = [0] * (N+1)
    dp1 = [0] * (N+1)
    dp1[0] = 1
    for i in range(N):
        s = S[i]
        dp0[i+1] = min(dp0[i] + s, dp1[i] + s+1)
        dp1[i+1] = min(dp1[i] + min(s+2, 9-s), dp0[i] + 1 + min(s, 10-s))
    print(min(dp0[-1], dp1[-1]+1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 125864
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;



long long mod(const long long &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
long long mat[61][50][50] = {};
int n;
long long k;



int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		mat[0][i][i] = 1;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> mat[1][i][j];
		}
	}
	for (int l = 2; l < 61; l++)
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{

				int temp = 0;
				for (int k = 0; k < n; k++)
				{
					temp = mod(temp += mod(mat[l-1][k][j]*mat[l-1][i][k]));
				}
				mat[l][i][j] = temp;
			}
		}
	}
	long long an[61][50][50] = {};
	for (int i = 0; i < n; i++)
	{
		an[0][i][i] = 1;
	}
	int mem=0;
	for (int  i = 0; i < 100; i++)
	{
		if (!k)break;
		if (k&(long long) 1) {
			for (int j = 0; j < n; j++)
			{
				for (int k = 0; k < n; k++)
				{
					int temp = 0;
					for (int l = 0; l < n; l++)
					{
						temp = mod(temp += mod(an[i][l][k] * mat[i + 1][j][l]));
					}
					an[i+1][j][k] = temp;
				}
			}
		}else {
			for (int j = 0; j < n; j++)
			{
				for (int k = 0; k < n; k++)
				{
					an[i+1][j][k] = an[i][j][k];
				}
			}
		}
		mem = i+1;
		k >>= 1;
	}
	long long ans = 0;
	for (int  i = 0; i < n; i++)
	{
		for (int  j = 0; j < n; j++)
		{
			ans = mod(ans += an[mem][i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688
#include <cstdio>

int p[100010];

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

  long long S = 0;
  for(int i = 0; i < N; i++) S += p[i];

  if(S % (1LL * N * (N + 1) / 2) != 0){
    puts("NO"); return 0;
  }

  long long T = S / (1LL * N * (N + 1) / 2);

  bool v = true;

  p[N] = p[0];
  for(int i = 0; i < N; i++){
    int D = p[i + 1] - p[i];
    long long V = T - D;
    if(V < 0 || V % N != 0) v = false;
  }

  puts(v ? "YES" : "NO");
  return 0;
}


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

int main()
{
    long a[3];
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;
    sort(a, a + 3);
    for (int i = 0; i < k; i++) {
        a[2] *= 2;
    }
    long sum = a[0] + a[1] + a[2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
//author Forsaken
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 1e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % mod;
		base = base * base % mod;
		index >>= 1;
	}
	return res;
}
ll f[maxn + 5], res;
vector<int> g[maxn + 5];
int n, k;
void dfs(int u, int father, bool flag) {
	int son = g[u].size() - 1;
	if (son > k - 2)res = 0;
	else res = res * f[k - 2] % mod * quick_pow(f[k - 2 - son], mod - 2) % mod;
	for (auto v : g[u]) {
		if (v == father)continue;
		dfs(v, u, 1);
	}
}
int main()
{
	cin >> n >> k;
	f[0] = 1;
	for (int i = 1; i <= k; ++i)f[i] = f[i - 1] * i % mod;
	for (int i = 1, u, v; i < n; ++i) {
		u = read_int(), v = read_int();
		g[u].push_back(v), g[v].push_back(u);
	}
	ll sz = 1 + g[1].size();
	if (sz > k) {
		cout << 0 << endl;
		return 0;
	}
	else {
		res = f[k] * quick_pow(f[k - sz], mod - 2) % mod;
		for (auto v : g[1])dfs(v, 1, 0);
	}
	cout << res << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define ll          long double
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  cout<<setprecision(10)<<fixed<<n*n*n/27<<"\n";
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


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

constexpr lint mod=1e9+7;

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

	lint dp[100010][4]={};
	dp[0][0]=1;

	for(int i=0;i<S.size();i++)
	{
		for(int j=0;j<4;j++)
		{
			if(S[i]=='?')dp[i+1][j]+=dp[i][j]*3;
			else dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=mod;
		}

		if(S[i]=='A' || S[i]=='?')dp[i+1][1]+=dp[i][0];
		dp[i+1][1]%=mod;
		if(S[i]=='B' || S[i]=='?')dp[i+1][2]+=dp[i][1];
		dp[i+1][2]%=mod;
		if(S[i]=='C' || S[i]=='?')dp[i+1][3]+=dp[i][2];
		dp[i+1][3]%=mod;
	}

	cout << dp[S.size()][3] << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#define MAX 501
using namespace std;

int main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    double p[MAX], q[MAX];
    p[0] = -1;
    for (int i = 1; i <= n; i++)
    {
        scanf("%lf", &p[i]);
    }
    for (int i = 0; i < n + 1; i++)
    {
        scanf("%lf", &q[i]);
    }

//    const int n = 5;
//      double p[n + 1] = {-1,0.15,0.1,0.05,0.1,0.2};
//     double q[n + 1] = {0.05,0.1,0.05,0.05,0.05,0.1};

    double e[MAX][MAX] = {0};
    double w[MAX][MAX] = {0};
    for (int i = 1; i <= n + 1; i++)
    {
        e[i][i - 1] = q[i - 1];
        w[i][i - 1] = q[i - 1];
    }

    int j = 0;
    for (int l = 1; l <= n; l++)
    {
        for (int i = 1; i <= n - l + 1; i++)
        {
            j = i + l - 1;
            e[i][j] = (1 << 21);
            w[i][j] = w[i][j - 1] + p[j] + q[j];
            for (int r = i; r <= j; r++)
            {
                double t = e[i][r - 1] + e[r + 1][j] + w[i][j];
                if (t < e[i][j])
                {
                    e[i][j] = t;
                }
            }
        }
    }
    printf("%lf", e[1][n]);

    return 0;
}



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

int main()
{
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < K; i++)
    {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ff first
#define ss second
#define ii pair<int,int>
#define lp(x,y) for(ll i=x;i<y;i++)
#define pb push_back
const int N = 200 * 1000 + 11;
 
 
int main() 
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll k,count=0;
    cin>>k;
    ll a=7,t=1,check=0;
    if(k%2==0) cout<<"-1";
    else
    {
    while(t)
    {
        check++;
        if(a<k) {a=a*10 + 7; count++;}
        else 
        {
            if(a%k==0) {count++; break;}
            else
            {
                ll q= a/k;
                ll p= k*q;
                ll t=a-p;
                a= t*10 + 7;
                
                count++;
            }
            
        }
        if(check==99999999){count=-1;break;}
    }
    cout<<count;
    }
}

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

using namespace std;

#define pb push_back

typedef long long ll;

ll dist[101][101];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(i == j){
                dist[i][j] = 0;
            }
            else{
                dist[i][j] = 10e6;
                dist[j][i] = 10e6;
            }
        }
    }
    int a[m], b[m], c[m];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        dist[a[i]-1][b[i]-1] = c[i];
        dist[b[i]-1][a[i]-1] = c[i];
    }
    for(int k = 0; k < n; k++)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(dist[a[i]-1][b[i]-1] < c[i]){
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN 100100
struct hoge {
  int t, x, y;
};
hoge a[MAXN];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  REP(i, N) { cin >> a[i].t >> a[i].x >> a[i].y; }
  //  bool ok = true;
  hoge now = {0, 0, 0};
  REP(i, N) {
    hoge diff = {a[i].t - now.t, a[i].x - now.x, a[i].y - now.y};
    bool flg = (2 + (diff.x + diff.y) % 2) % 2 == diff.t % 2 && abs(diff.x) + abs(diff.y) <= diff.t && abs(diff.x) <= diff.t && abs(diff.y) <= diff.t;
    if (!flg) {
//      cerr << i << " " << diff.x << " " << diff.y << " " << diff.t;
      print("No");
      return 0;
    }
    now = a[i];
  }
  print("Yes");
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	long long a,b,c,temp,lcm,first,last;
	while((scanf("%llu %llu",&a,&b)) != EOF)
	{
		first = a;
		last = b;
		if(a > b)
		{
			temp = a;
			a = b;
			b = temp;
		}
		while(b % a)
		{
			c = b % a;
			b = a;
			a = c;
			
		}
		lcm = (first * last) / a;
		printf("%llu %llu\n",a,lcm);
	}
	return 0;
}

Measured memory_bytes: 604
#include<stdio.h>

int main(){
    int i,j,k,N,l;
    scanf("%d",&N);
    int b[101]={0};
    for(i=0;i<N;i++){
        scanf("%d",&b[i]);
    }
    int ans[101]={0};

    int flag=0;
    int bflag=0;
    int out=0;

    for(j=0;j<N&&out==0;j++){
        for(i=0;i<N-j;i++){
            if(b[i]==i+1&&b[i]>ans[j]){
                ans[j]=b[i];
                k=i;
                flag+=1;
            }
        }
        
        if(bflag==flag){
            out=1;
            flag=0;
        }
        
        bflag=flag;
        /*
        printf("j=%d\n",j);
        for(l=0;l<N;l++){
            printf("%d ",b[l]);
        }
        printf("\n");
        */
        for(;k<N;k++){
            b[k]=b[k+1];
        }
        

    }

    if(flag==0){
        printf("-1\n");
    }

    if(flag!=0){
        for(k=0;k<N;k++){
            printf("%d\n",ans[N-k-1]);
        }
    }
    

    return 0;
}

Measured memory_bytes: 128
def compose_number?(array, num)
  if array.size == 1
    return array[0] == num
  end
  return true if compose_number?(array[1..-1], num)
  return true  if num - array[0] == 0
  true if compose_number?(array[1..-1], num - array[0])
end

input = []
while (n = gets.to_i) != 0 do
  input << gets.split.map(&:to_i)
end
ss = input[0]
tt = input[1]
result = tt.map do |i|
  if compose_number?(ss, i)
    'yes'
  else
    'no'
  end
end
result.each do |i|
  puts i
end



Measured memory_bytes: 6880
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int,int> PI;
const int N=200005;
int a[N];
int n;
bool ok[N];
int id;
struct qq
{
	int f[N];
	vector<PI> vec[N];
	int lb (int x)	{return x&(-x);}
	void modify (int x,int c)
	{
		while (x<=n)
		{
			if (f[x]<c)	{vec[id].push_back({x,f[x]});f[x]=c;}
			x+=lb(x);
		}
	}
	int query (int x)
	{
		int lalal=0;
		while (x>=1)	{lalal=max(lalal,f[x]);x-=lb(x);}
		return lalal;
	}
	void upd ()
	{
		int siz=vec[id].size();
		for (int u=0;u<siz;u++) f[vec[id][u].first]=vec[id][u].second;
	}
}A,B,C;
//A:奇数     B:偶数 
void Init ()
{
	int mn=n+1;for (int u=1;u<=n;u++)	{ok[u]=(a[u]<mn);mn=min(mn,a[u]);}
	for (int u=n;u>=1;u--)
	{
		id=u;int t,t1;
		if (ok[u])//这是一个特殊点 
		{
			t=A.query(a[u]);if (t&1) A.modify(a[u],t+2);
			t=B.query(a[u]);B.modify(a[u],t+2);
		}
		else
		{
			t=A.query(a[u]),t1=B.query(a[u]);
			A.modify(a[u],t1+1);
			if (t&1) B.modify(a[u],t+1);
			
			t=C.query(a[u]);C.modify(a[u],t+1);
		}
	}
}
int lena,lenb,Q;
int Mn;
int h[2];
bool check ()
{
	bool tf=false;
	int x=lena-lenb+Q;
	if (x>=0)
	{
		if (x&1) tf|=(A.query(h[1])>=x);
		else tf|=(B.query(h[1])>=x);
	}
	x=lenb-lena+Q;
	if (x>=0)
	{
		if (x&1) tf|=(A.query(h[0])>=x);
		else tf|=(B.query(h[0])>=x);
	}
	return tf;
}
int main()
{
	scanf("%d",&n);
	for (int u=1;u<=n;u++) scanf("%d",&a[u]);
	for (int u=1;u<=n;u++) a[u]=n-a[u]+1;
	Init();
	h[0]=h[1]=n;
	for (int u=1;u<=n;u++) Q=Q+ok[u];
	if (!check())	{printf("-1\n");return 0;}
	for (int u=1;u<=n;u++)
	{
	//	printf("YES:%d\n",u);
		id=u;A.upd();B.upd();C.upd();
		Q=Q-ok[u];
		//这一位填0
		lena=lena+(h[0]>=a[u]);
		if (check())	{h[0]=min(h[0],a[u]);printf("0");continue;}
		lena=lena-(h[0]>=a[u]);
		lenb=lenb+(h[1]>=a[u]);
		h[1]=min(h[1],a[u]);
		printf("1");
	}
	return 0;
}

Measured memory_bytes: 54912
def matrix(X):
    m = [[0 for i in range(len(X))] for j in range(len(X))]

    for l in range(2, len(X) + 1):
        for i in range(0, len(X) - l + 1):
            j = i + l - 1
            m[i][j] = min(m[i][k] + m[k + 1][j] + X[i][0]*X[k][1]*X[j][1] for k in range(i, j))

    print m[0][len(X) - 1]

n = input()
X = []

for i in range(n):
    X.append(map(int, raw_input().split()))

matrix(X)

Measured memory_bytes: 6584
#include<stdio.h>
#include<stdlib.h>



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



int main()
{
	int num[ 10 ] ;

	int i = 10 ;
	while( i-- )
	{
		scanf( "%d" ,&num[ i ] ) ;
	}


	qsort( num ,10 ,sizeof( int ) ,cmp ) ;



	printf( "%d\n%d\n%d\n" ,num[ 0 ] ,num[ 1 ] ,num[ 2 ] ) ;


	return 0 ;
}

Measured memory_bytes: 604
N, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
  print(N)
else:
  while sum(a) > x:
    a.remove(max(a))
  l = len(a)
  if l == N:
    print(l - 1)
  else:
    print(l)

Measured memory_bytes: 3060
n = io.read"*n"
v = {io.read((("*n"):rep(n)):match(("(*n)"):rep(n)))}
c = {io.read((("*n"):rep(n)):match(("(*n)"):rep(n)))}
r = 0
for i=1,n do
	x = v[i]-c[i]
	r = x<0 and r or x+r
end
print(r)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 998244353;

vector<int64> fact(11234), inv(11234);
int64 K, N;

int64 mpow(int64 a, int64 b){
	if(b == 0) return 1;
	if(b%2) return a*mpow(a, b-1)%mod;
	int64 ret = mpow(a, b/2);
	return ret*ret%mod;
}

void init(int64 N, int64 K){
	fact[0] = 1;
	inv[0] = 1;
	FOR(i, 1, 11234){
		fact[i] = fact[i-1]*i%mod;
		inv[i] = mpow(fact[i], mod-2);
	}
}

int64 comb(int64 a, int64 b){
	if(a < b){
		return 0;
	}
	return fact[a]*inv[b]%mod*inv[a-b]%mod;
}

int64 calc2(int64 N, int64 k, int64 x){ 
	int64 res = 0;
	REP(i, min(x+1,N+1)){
		res = (res+mpow(2, i)*comb(x, i)%mod*comb(N-i+k+i-1, N-i)%mod)%mod;
	}
	return res;
}

int64 calc(int64 N, int64 k){ 
	int64 res = 0;
	int32 p = K-abs(K+1-k);
	if(p%2){
		res += calc2(N, K-p, p/2);
		res %= mod;
		res = (res+calc2(N-1, K-p, p/2)%mod)%mod;
	}else{
		res += calc2(N, K-p, p/2);
		res %= mod;
	}
	return res;
}


int main(void){
	cin >> K >> N;
	init(N, K);
	FOR(i, 2, 2*K+1){
		cout << calc(N, i) << endl;
	}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X;
    cin >> X;
    ll ans = 1;
    rep2(i, 1, 100) {
        rep2(j, 2, 6) {
            if (ll(pow(i, j) <= X)) {
                ans = max(ans, (ll) pow(i, j));
            }
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

namespace Mylib{
    using namespace std;
}

int main(void){
    using namespace std;
    int N,R;
    
    cin >> N >> R;
    
    if(N>=10){
        cout << R << endl;
    }else{
        cout << R+100*(10-N) << endl;
    }
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
LL x;
/**********************************************/

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

    cin >> x;

    LL num = x / 11;
    if(num*11 == x) cout << num*2 << endl;
    else cout << (num*11 + 6 >= x ? num*2+1 : num*2+2) << endl;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int mini = 1000000;
    int tmp = 6;
    rep(i,0,n+1){
        int a=0;
        int cnt=i;
        while(cnt>0){
            a += cnt % 6;
            cnt /= 6;
        }
        cnt = n-i;
        while(cnt>0){
            a += cnt%9;
            cnt /= 9;
        }
        mini = min(mini,a);
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1ll;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    mint ans=0;
    init();
 for(ll i=0;i<=n;i++){
     ll d=a*i;
     if(k-d<0)break;
     if((k-d)%b!=0)continue;
     ans+=COM(n,i)*COM(n,(k-d)/b);
 }
 cout<<ans<<"\n";
}

Measured memory_bytes: 50456
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		final double pie =  3.141592653589;
		Double d = sc.nextDouble();
		System.out.println(String.format("%.6f %.6f",d*d*pie ,2*d*pie));
	}
}

Measured memory_bytes: 28000
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>
 
int main()
{
    long long a{}, b{}, c{};
    std::cin >> a >> b >> c;

    const auto r = c - a - b;
    if (r <= 0) {
        std::cout << "No" << std::endl;
        return 0;
    }
    const auto l2 = 4 * a * b;
    const auto r2 = r * r;
    std::cout << ((l2 < r2) ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(Q)]

distance_map = defaultdict(dict)

for a, b, c in ABC:
    distance_map[a][b] = c
    distance_map[b][a] = c

k_dist = {K: 0}

target = deque(distance_map[K].items())
while target:
    t, distance = target.pop()
    k_dist[t] = distance
    for v in map(lambda x: (x[0], x[1] + distance),filter(lambda x: x[0] not in k_dist, distance_map[t].items())):
        target.append(v)

# print(k_dist)

for x,y in XY:
    print(k_dist[x]+k_dist[y])


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

mt19937 rng( (int)chrono::steady_clock::now().time_since_epoch().count() );

bool ask(int a, int b) {
  cout << "? " << a << ' ' << b << '\n'; cout.flush();
  char inp; cin >> inp; return inp == 'Y';
}

int findHonestPerson(vector<int> &candidate) {
  if (!sz(candidate) ) return -1;
  if (sz(candidate) == 1) return candidate.back();

  int rem = -1;
  if (sz(candidate) & 1) rem = candidate.back();

  vector<int> nCandidate;
  for (int i = 0; i + 1 < sz(candidate); i += 2) if (ask(candidate[i], candidate[i + 1]) ) nCandidate.emplace_back(candidate[i + 1]);

  candidate.swap(nCandidate);
  nCandidate.clear();
  nCandidate.shrink_to_fit();
  int ret = findHonestPerson(candidate);
  if (!(~ret) ) ret = rem;
  return ret;
}

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

  int a, b; cin >> a >> b;

  if (a <= b) return cout << "Impossible\n", 0;

  vector<int> candidate(a + b); iota(all(candidate), 0);
  int honestPerson = findHonestPerson(candidate);

  vector<char> ans(a + b);
  for (int i = 0; i < a + b; ++i) {
    if (i ^ honestPerson) ans[i] = (ask(honestPerson, i) ? '1' : '0');
    else ans[i] = '1';
  }

  cout << "! ";
  for (const auto &i : ans) cout << i;
  cout << '\n'; cout.flush();

  return 0;
}


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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

//累積和　ユークリッド　gcd 最大公約数

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

int main() {
    int N;
    cin >> N;
    vl A(N);
    REP(i,N) cin >> A[i];

    //累積gcdを作成
    vl forward(N+1),backward(N+1);
    forward[0]=0;
    backward[N]=0;

    FOR(i,0,N){
        forward[i+1]= gcd(forward[i],A[i]);
    }

    FORR(i,0,N){
        backward[i]=gcd(backward[i+1],A[i]);
    }

    ll ans=0;

    FOR(i,0,N){
        ans = CHMAX(ans,gcd(forward[i],backward[i+1]));
    }

    cout << ans << endl;





}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	}
	if (a > b) {
		printf("a > b\n");
	}
	if (a == b) {
		printf("a == b\n");
	}


	return 0;
}



Measured memory_bytes: 2040
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
int N; cin >> N;
vector<int> a(N);
rep(i,N) cin >> a[i];
int ans ,sum;
sum = 0;
ans = 100000000;
rep(i,100){
	rep(j,N){
		sum +=(i-a[j]) * (i-a[j]);
	}
	ans = min(ans,sum);
	sum = 0;
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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

ll x, cnt = 100;

int main() {

	cin >> x;

	int i = 0;
	while (cnt < x) {
		i++;
		cnt += cnt * 0.01;
	}

	cout << i << endl;

	return 0;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**7)
s=raw_input()
t=raw_input()

len_s=len(s)
len_t=len(t)

s="@"+s
t="_"+t


dp=[ [ 0 for j in range(len_t+1) ] for i in range(len_s+1)   ]
S=""
l=0

for i in range(1,len_s+1):
	for j in range(1,len_t+1):
		if s[i]==t[j]:
			dp[i][j]=dp[i-1][j-1]+1
		else:			
			dp[i][j]=max( dp[i-1][j] , dp[i][j-1] )


ans=""
def lcs(i,j):
	global ans
	if dp[i][j]==0:
		return
	else:
		if s[i]==t[j]:
			lcs(i-1,j-1)
			ans+=s[i]
		else:
			if dp[i-1][j]>=dp[i][j-1]:
				lcs( i-1, j )
			else:
				lcs( i, j-1)

lcs(len_s, len_t)
print ans

Measured memory_bytes: 106268
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func f(n int) int {
	N := n + 1
	d := N / 2
	ret := 0
	// out("d", d, "n", n)
	if N%2 == 1 {
		ret = (d % 2) ^ n
	} else {
		ret = d % 2
	}
	return ret
}

func f2(a, b int) int {
	n := b - a + 1
	ans := 0
	if a%2 == 1 {
		ans ^= a
		a++
		n--
	}
	d := n / 2
	if n%2 == 1 {
		ans ^= (d % 2) ^ b
	} else {
		ans ^= d % 2
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	A, B := getInt(), getInt()

	// out(f(A - 1))
	// out(f(B))
	//	out(f(A-1) ^ f(B))
	out(f2(A, B))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
  cin >> a >> b >> c;
/*  if((a+b+c)%3==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
  */
  if((a+b)==c || (c+b)==a ||(a+c)==b){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


void solve() {
    ll N;cin>>N;
    if(N%2==1){
        print(0);return;
    }
    ll ans=0;
    for(int i=10;i<=1e18;i*=5){
        ans+=N/i;
    }
    print(ans);
}

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


Measured memory_bytes: 256
#include<stdio.h>

int N, result=0;

int main(void) {
	scanf("%d", &N);
	int a[N+1];
	for(int i=1; i<N+1; i++) {
		scanf("%d", &a[i]);
	}
	for(int i=1; i<N+1; i++) {
		if(a[a[i]] == i) {
			result++;
			a[i] = -1;
		}
	}
	printf("%d\n", result);
	return 0;
}


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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// typedef struct 
// {
//     ll h;
//     ll v;
// } box;


// int cmp_qwe(const void*a, const void*b){return ((box*)b)->a - ((box*)a)->a;}

// ll dp[3000][3000];
// box u[2000];

int main(){
  ll s,w;

  scanf("%lld%lld", &s, &w);

  if (s <= w)
  {
      printf("unsafe\n");
  }
  else
  {
      printf("safe\n");
  }
  
  
  

  return 0;
}

Measured memory_bytes: 1664
MAX = 10 ** 10
def m():
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(1,n):
        a[i] += a[i-1]
    ans = MAX
    left_i = 0
    right_i = 2
    for mid in range(1,n-2):
        while left_i < mid and abs(a[left_i+1] - (a[mid]-a[left_i+1])) < abs(a[left_i] - (a[mid]-a[left_i])):
            left_i += 1

        if right_i <= mid:
            right_i = mid+1

        while right_i < n-1 and abs((a[right_i+1] - a[mid]) - (a[n-1] - a[right_i+1])) < abs((a[right_i] - a[mid]) - (a[n-1] - a[right_i])):
            right_i += 1
        p = a[left_i]
        q = a[mid] - a[left_i]
        r = a[right_i] - a[mid]
        s = a[n-1] - a[right_i]
        ans = min(ans, max(p,q,r,s) - min(p,q,r,s))
    return ans

print(m())

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

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		 // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {

	ll mod = 1000000007;
	ll n; cin >> n;
	const ll p = 1000;
	vector<ll> num(n + 1, 0);
	for (ll i = 1; i <= n; i++) {
		vector<pair<long long, long long>> a_prime;  // a^x ならば { a, x }
		a_prime = prime_factorize(i);
		for (ll i = 0; i < a_prime.size(); i++) {
			num[a_prime[i].first] += a_prime[i].second;
		}
	}
	ll ans = 1;
	for (ll i = 1; i <= n; i++) {
		if (num[i] == 0) {

		}
		else {
			ans *= (num[i] + 1);
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3560
n, m = map(int, input().split())

cakes = [[int(x) for x in input().split()] for _ in range(n)]

ans = 0
for i in range(8):
  cakes_sub = []
  key = [1, 1, 1]
  for j in range(3):
    if (i>>j)&1:
      key[j] = -1.
  for j in range(n):
    k = [0]*3
    for p in range(3):
      k[p] = key[p]*cakes[j][p]
    l = sum(k)
    cakes_sub.append([l]+k)
  cakes_sub.sort(reverse=True)
  a, b, c = 0, 0, 0
  for j in range(m):
    a += cakes_sub[j][1]
    b += cakes_sub[j][2]
    c += cakes_sub[j][3]
  sub = a+b+c
  if ans < sub:
    ans = sub

print(int(ans))

Measured memory_bytes: 3444