akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }

fn main() {
    let mut sc = Scanner::new();
    let k: i64 = sc.cin();
    put!(
    (1..=k).map(|a|
    (1..=k).map(|b| (1..=k).map(|c| gcd(gcd(a,b),c)).sum::<i64>()).sum::<i64>()).sum::<i64>()
    );
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2132
from sys import exit, stdin

class WeightedUnionFind:
    def __init__(self, n=1, sum_unity=0):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
        self.diff_weight = [sum_unity]*n

    
    def find_root(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find_root(self.par[x])
            self.diff_weight[x] += self.diff_weight[self.par[x]]
            self.par[x] = y
            return y


    def merge(self, x, y, w):
        rx, ry = self.find_root(x), self.find_root(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.diff_weight[rx] = w - self.diff_weight[x] + self.diff_weight[y]
        else:
            self.par[ry] = rx
            self.diff_weight[ry] = -w - self.diff_weight[y] + self.diff_weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1


    def issame(self, x, y):
        return self.find_root(x) == self.find_root(y)


    def diff(self, x, y):
        return self.diff_weight[x] -  self.diff_weight[y]

N, M = [int(_) for _ in stdin.readline().rstrip().split()]

wuf = WeightedUnionFind(N)
for i in range(M):
    l, r, d = [int(_) for _ in stdin.readline().rstrip().split()]
    l -= 1
    r -= 1
    if wuf.issame(l, r):
        diff = wuf.diff(l, r)
        if diff != d:
            print("No")
            exit()
    else:
        wuf.merge(l, r, d)
print("Yes")

Measured memory_bytes: 107680
#include <bits/stdc++.h>
using namespace std;
    long long int check(long long int mid,long long int arr[],int n,long long int k){
		long long int s=0;
		for(int i=0;i<n;i++){
			s=s+((arr[i]+mid-1)/(mid)-1);
		}
		return s<=k;
	}
int main() {
	// your code goes here
	int n;
	cin>>n;
	long long int k;
	cin>>k;
	long long int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);

	long long int l=0,r=arr[n-1]+1;
	long long int mid;
	while(l<r-1){
	mid=(l+r)/2;
	if(check(mid,arr,n,k)){
		//cout<<l<<" "<<mid<<" "<<r<<"\n";
		r=mid;
	}
	else l=mid;
	}
	cout<<r;
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 22;


int n;
int g[maxn][maxn];


void add(ll &x, ll y) {
    x%=mod;
    y%=mod;
    x+=y;
    x%=mod;
}


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

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

    vector<ll> dp(1<<n, 0);//ways to match mask of women
    dp[0]=1;
    
    for (int mask=0; mask<(1<<n); mask++) {
	int i = __builtin_popcount(mask);
	//i men have been used so far, so we're on ith man 0-indexed
	for (int j=0; j<n; j++) {
	    if (!(mask>>j&1)) {
		if (g[i][j]) {
		    add(dp[mask|(1<<j)], dp[mask]);
		}
	    }
	}
    }
    

    ll res = dp[(1<<n)-1];
    res%=mod;
    res+=mod;
    res%=mod;
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll n, m, x1, y1;
    cin >> n >> m >> x1 >> y1;
    vll x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];
    x.push_back(x1);
    y.push_back(y1);
    bool ans = *max_element(x.begin(), x.end()) < *min_element(y.begin(), y.end());
    cout << (ans ? "No War" : "War") << endl;
    return;
}

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500000)
N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append((b, i))
    E[b].append((a, i))
K = max(len(e) for e in E)
print(K)
Ans = [-1] * (N-1)
def dfs(v=1, p=0, p_col=-1):
    col = 1
    for u, idx in E[v]:
        if u!=p: #木構造の逆向きの矢印を除くための条件
            if col == p_col:
                col += 1
            Ans[idx] = col
            #print(p_col)
            dfs(u, v, col) #u;調べる頂点 v;直前に調べた辺で、調べる頂点と結ばれている頂点　col;直前に調べた辺の色番号
            col += 1 #最深部まで調べたら デフォルトの色=最後に調べた辺の色+1とする
            #最深部に繋がった辺の色+1してやれば、次の辺の色は必ず条件を満たしてくれる

dfs()
print("\n".join(map(str, Ans)))


Measured memory_bytes: 85652
#include<bits/stdc++.h>
using namespace std;
const int maxn=2002;
vector<int>m[maxn];
int n,p;
int sum;
int vis[maxn];
void dfs(int cot,int num)
{
    if(num==n)
    {
        sum++;
        return;
    }
    for(int i=0;i<m[cot].size();i++)
    {
        if(vis[m[cot][i]]==0)
        {
            vis[m[cot][i]]=1;
            dfs(m[cot][i],num+1);
            vis[m[cot][i]]=0;
        }
    }
}
int main()
{
    cin>>n>>p;
    for(int i=1;i<=p;i++)
    {
        int v,u;
        cin>>v>>u;
        m[v].push_back(u);
        m[u].push_back(v);
    }
    sum=0;
    vis[1]=1;
    dfs(1,1);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAXN 100010
#define LL long long

int n;
int a[MAXN];

int gcd(int x,int y){
	if(!y) return x;
	return gcd(y,x%y);
}

bool gao(){
	int c0=0,p1;
	for(int i=1;i<=n;i++)
		if(a[i]&1) p1=i;
		else c0++;
	if(c0&1) return 1;
	if(n-c0>1) return 0;
	int g=0;
	for(int i=1;i<=n;i++)
		if(a[i]&1){
			if(a[i]==1) return 0;
			g=gcd(g,a[i]-1);
		}else g=gcd(g,a[i]);
	for(int i=1;i<=n;i++) a[i]/=g;
	return !gao();
}

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	if(gao()) puts("First");
	else puts("Second");
}


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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfl(x) scanf("%I64d",&x)
#define sfd(x) scanf("%lf",&x)
#define sfs(x) scanf("%s",x)
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
int main()
{
    int a,b;
    cin>>a>>b;
    int arr[3]={1,2,3};
    for(int i=0; i<3; i++)
    {
        if(a==1) arr[0]=0;
        if(a==2) arr[1]=0;
        if(a==3) arr[2]=0;
        if(b==1) arr[0]=0;
        if(b==2) arr[1]=0;
        if(b==3) arr[2]=0;
    }
    for(int i=0; i<3; i++)
    {
        if(arr[i]>0) cout<<arr[i];
    }
}



Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl toInt >>= putStrLn

solve :: Int -> String
solve = map f . reverse . unfoldr g 
  where
    f :: Int -> Char
    f 0 = '0'
    f 1 = '+'
    f (-1) = '-'
    g x
      | x == 0 = Nothing
      | otherwise = Just (r-1, q)
      where
        (q,r) = (x+1) `divMod` 3

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll W, N;
ll x[60000];
ll xsum[2][60000];
ll imos[60000];
bool f(int border) {
    //cerr << "---------" << border << "------" << endl;
    for(int i = 0; i < 60000; i++) {
        imos[i] = 0;
    }
    xsum[0][0] = 0;
    xsum[1][0] = 0;
    for(int i = 0; i < N; i++) {
        xsum[0][i+1] = xsum[0][i] + x[i] + 1;
        xsum[1][i+1] = xsum[1][i] + x[i] + border;
    }
    imos[0] = 1;
    imos[1] = -1;
    ll now = 0;
    for(int idx = 0; idx < N; idx++) {
        now += imos[idx];
        if(now == 0) continue;
        //cerr << "-" << idx << "-" << endl;
        if(xsum[0][N] - xsum[0][idx] <= W + 1) return true;
        int ok = N + 1;
        int ng = idx;
        while(abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if(xsum[1][mid] - xsum[1][idx] >= W + border) ok = mid;
            else ng = mid;
        }
        imos[ok]++;
        ng = idx;
        ok = N + 1;
        while(abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if(xsum[0][mid] - xsum[0][idx] > W + 1) ok = mid;
            else ng = mid;
        }
        imos[ok]--;
    }
    return false;
}


void solve() {
    for(int i = 0; i < N; i++) {
        cin >> x[i];
    }
    int ok = W;
    int ng = 0;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if(f(mid)) {
            ok = mid;
        } else ng = mid;
    }
    cout << ok << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> W >> N) {
        if(W == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
vector<ll> a1,b1,c1;
ll t[10];
main(){
  ll n,a,b,c,ans=1e9;
  cin>>n>>a>>b>>c;
  rep(i,0,n)cin>>t[i];

  rep(i,0,powl(4,n)){
    ll k=i,cnt=0;
    a1.clear();
    b1.clear();
    c1.clear();
    while(k>0){
      if(k%4==3)c1.pb(t[cnt]);
      else if(k%4==2)b1.pb(t[cnt]);
      else if(k%4==1) a1.pb(t[cnt]);
      cnt++;
      k/=4;
    }

    if(a1.size()*b1.size()*c1.size()>0){
      ll len=0,tmp=10*(a1.size()+b1.size()+c1.size())-30;
      rep(j,0,a1.size())len+=a1[j];
      tmp+=labs(len-a);
      
      len=0;
      rep(j,0,b1.size())len+=b1[j];
      tmp+=labs(len-b);

      len=0;
      rep(j,0,c1.size())len+=c1[j];
      tmp+=labs(len-c);
      ans=min(ans,tmp);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int num[5];
	while(1){
		bool kawa=1;
		for(int i=0;i<5;i++){
			cin>>num[i];
			if(num[i]!=0)kawa=0;
		}
		if(kawa)break;
		int stop[10000],ans=-1;
		for(int i=0;i<num[0];i++)cin>>stop[i];
		for(int i=0,n=num[4],j=0;i<10001&&j<num[0];i++){
			if(n==stop[j])j++;
			if(j==num[0])ans=i;
			n=(num[1]*n+num[2])%num[3];
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1164
import bisect
 
N = int(input())
L = sorted(list(map(int,input().split())))

ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = bisect.bisect_left(L, L[i] + L[j], j + 1) - 1
        ans += k - j

print(ans)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

const int N=2e5+5;

void solve()
{	
	int a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	int dist=abs(b-a);
	if(w>=v)
	{
		cout<<"NO";
		return;
	}
	int take=(v-w)*t;
	if(take>=dist)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	IOS;

	int t=1;
	//cin>>t;
	while(t--)
		solve();

}

Measured memory_bytes: 3652
import sys
N, Y = map(int, input().split())

x_range = Y // 10000
y_range = Y // 5000

for x in range(x_range + 1):
	if x > N:
		break
	for y in range(y_range + 1):
		if x + y > N :
			continue
		z = N - x - y
		if Y == 10000*x + 5000*y + 1000*z:
			print("%d %d %d" % (x, y, z))
			sys.exit()
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll n,k;
vv64 gr;
ll ans;
v64 com1,com2;
v64 fact;

void dfs(ll v, ll p, ll lev){
	ll count = 0;
	forn(i,(ll)gr[v].size()){
		if(gr[v][i]!=p){
			dfs(gr[v][i],v,min(lev+1,(ll)2));
			count ++;
		}
	}
	if(lev==0){
		ans *= (count>k-1) ? 0 : com1[count];
		ans %= MOD;
	}
	else{
		ans *= (count>k-2) ? 0 : com2[count];
		ans %= MOD;
	}
	ans *= fact[count];
	ans %= MOD;
}

void solve(ll index){
	cin >> n >> k;
	if(k==1){
		if(n==1) cout << 1 << ln;
		else cout << 0 << ln;
		return;
	} 
	com1.pb(1);
	com2.pb(1);
	forsn(i,1,k){
		ll prev = com1[i-1]*(k-i);
		prev %= MOD;
		prev *= mpow(i,MOD-2);
		prev %= MOD;
		com1.pb(prev);
	}
	forsn(i,1,k-1){
		ll prev = com2[i-1]*(k-1-i);
		prev %= MOD;
		prev *= mpow(i,MOD-2);
		prev %= MOD;
		com2.pb(prev);
	}
	ll prev = 1;
	fact.pb(1);
	forsn(i,1,k+1){
		prev = (prev*i)%MOD;
		fact.pb(prev);
	}
	ans = k;
	gr.resize(n+5);
	forn(i,n-1){
		ll t1,t2;
		cin >> t1 >> t2;
		gr[t1].pb(t2);
		gr[t2].pb(t1);
	}
	dfs(1,-1,0);
	cout << ans << ln;
}

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve(i+1);
    return 0;
}

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

long long int comb(long int n){
    if(n <= 1){
        return 0;
    }
    if(n == 2){
        return 1;
    }
    return (((n)*(n-1))/2);

}

int main(){
    long int n, i, aux;
    string s;
    set<string> v;
    map<string, long int> m;
    scanf("%ld", &n);
    for(i = 0; i < n; i++){
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
        v.insert(s);
    }

    set<string>::iterator it;
    long long int arranjo = 0;
    for(it = v.begin(); it != v.end(); it++){
        aux = m[*it];
        if(aux > 1){
            arranjo += comb(aux);
        }
    }
    printf("%lld\n", arranjo);
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = 1e18;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
int n,k;
signed main()
{
    //freopen(file".inp","r",stdin);
    //freopen(file".out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    int arr[n+5];	
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    sort(arr,arr+n);
    int l=-mx, r=mx;
    while(l+1<r)
    {
//    	cout<<l<<endl;
    	int mid=(l+r)>>1;
    	int tmp=0;
    	for(int i=0;i<n;i++)
    	{
//    		cout<<i<<endl;
    		if(arr[i]>0)
			{
			    if(arr[0]*arr[i]>mid)
			    	continue;
			    int ll=0, rr=n;
			    while(ll+1<rr)
			    {
			    	int m=(ll+rr)>>1;
			    	if(arr[i]*arr[m]>mid)
			    		rr=m;
			    	else
			    		ll=m;
				}
				tmp+=rr;
				if(arr[i]*arr[i]<=mid)
					tmp--;
			}
			if(arr[i]==0)
				if(mid>=0)
					tmp+=n-1;
			if(arr[i]<0)
			{
				if(arr[n-1]*arr[i]>mid)
					continue;
				int ll=-1, rr=n-1;
				while(ll+1<rr)
				{
					int m=(ll+rr)>>1;
					if(arr[i]*arr[m]>mid)
						ll=m;
					else
						rr=m;	
				}
				tmp+=n-rr;	
				if(arr[i]*arr[i]<=mid)
					tmp--;
			}	
		}
//		cout<<"here";
//		cout<<tmp<<endl;
		if(tmp>=k*2)
			r=mid;
		else
			l=mid;
	}
	cout<<l+1;
}


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


int main()
{
  int n, k, minv=1;

  cin >> n;
  cin >> k;

  for ( int i=0; i<n; i++ ) {
    if ( 2*minv > minv+k ) {
      minv += k;
    } else {
      minv *= 2;
    }
  }

  cout << minv << endl;
  
  return 0;
}


Measured memory_bytes: 256
'''
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
'''
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  S = input()
  T = input()
  dic = dict()
  bl = True
  for s,t in zip(S,T):
    if (s in dic) and (dic[s] != t):
      bl = False
      break
    dic[s] = t
  
  after = dic.values()
  if len(after)!=len(set(after)):
    bl = False
  
  print('Yes' if bl else 'No')
  
  
  
  
  
if __name__ == '__main__':
  main()

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

int main() {
  int N,K;
  cin >> N;
  cin >> K;
  vector<int> d(K);
  vector<int> A(N);
  int sunuke;
  int ans;
  for (int i = 0; i < K; i++) {
    cin >> d.at(i);
      for (int j=0; j < d.at(i); j++) {
        cin >> sunuke;
        A.at(sunuke-1)=A.at(sunuke-1)+1;
      }
  }
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#n = int(input())
a, b, c = map(str, input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a = a.upper()
b = b.upper()
c = c.upper()
print(a[0]+b[0]+c[0])


Measured memory_bytes: 9000
n = int(input())
ans = 0
for i in range(1,n+1,2):
    cnt = 0
    j = 1
    while True:
        if j**2 == i:
            cnt += 1
            break
        if j**2 > i:
            break
        if i % j == 0:
            cnt += 2
        j += 1
    if cnt == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
a=int(input())
res=1
flag=1
l=list(map(int, input().split()))
for i in l:
    if i==0:
        flag=0
if flag!=0:
    for i in l:
        res*=i
        if res>1000000000000000000:
            res=-1
            break
    if res>1000000000000000000:
        res=-1
else:
    res=0
print(res)
        


Measured memory_bytes: 21636
#include <stdio.h>
int main (){
	int n, jumlahangka = 0;
	scanf ("%d", &n);
	char str[102];
	scanf ("%s", &str);
	for (int i=0;i< n/2;i++){
	if (str[i] == str[i + n/2]){
	
	jumlahangka++;
			
		}
		
	}
	if (n % 2 == 1) {
		printf("No");
		return 0;
	}

	
	jumlahangka == n/2 ? printf ("Yes\n") : printf ("No\n");
return 0;
}

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
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, W = MAP()
wN, vN = [0]*N, [0]*N
for i in range(N):
    wN[i], vN[i] = MAP()

# dp[何個目までから選ぶか][これまでに選んだ荷物の重さ] = これまでに選んだ荷物の価値
dp = [[0] * (W+1) for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        # 真下には常に送る
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j + wN[i] <= W:
            # 重さが制限内なら右下にも送る
            dp[i+1][j+wN[i]] = max(dp[i+1][j+wN[i]], dp[i][j] + vN[i])
print(dp[N][W])


Measured memory_bytes: 125320
using System;

class F
{
	static void Main()
	{
		var M = 1000000007;
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int n = h[0], k = h[1], n2 = n * n;

		var dp = new long[n + 1, n + 1, n2 + 1];
		dp[0, 0, 0] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j <= n; j++)
				for (int t, x = 0; x <= n2; x++)
				{
					if (dp[i, j, x] == 0) continue;
					if (j > 0 && (t = x + 2 * j - 2) <= n2)
					{
						dp[i + 1, j - 1, t] += j * j * dp[i, j, x];
						dp[i + 1, j - 1, t] %= M;
					}
					if ((t = x + 2 * j) <= n2)
					{
						dp[i + 1, j, t] += (2 * j + 1) * dp[i, j, x];
						dp[i + 1, j, t] %= M;
					}
					if ((t = x + 2 * j + 2) <= n2)
					{
						dp[i + 1, j + 1, t] += dp[i, j, x];
						dp[i + 1, j + 1, t] %= M;
					}
				}
		Console.WriteLine(dp[n, 0, k]);
	}
}


Measured memory_bytes: 60128
#include<stdio.h>
int main(void)
{
    double r,Ans1,Ans2;
    scanf("%lf",&r);
    Ans1=(double)r*(double)r*3.14159265358979323846264338327950288;
    Ans2=2*(double)r*3.14159265358979323846264338327950288;
    printf("%f %f",Ans1,Ans2);
    return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
    a[i]=(a[i]+i)%n;
  }
  vi used(n,0),v(n,0);
  int ans=0,t=1;
  rep(i,n)if(used[i]==0){
    int now=a[i],j=i;
    v[j]=t;
    used[j]=1;
    while(1){
      if(used[now]){
    if(v[now]==v[j])ans+=used[j]+1-used[now];
    break;
      }else{
    used[now]=used[j]+1;
    v[now]=v[j];
    j=now;
    now=a[j];
      }
    }
    t++;
    //    cout<<i<<" "<<ans<<endl;
  }
  cout<<ans<<endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a > 0) cout << "Positive" << endl;
  else if(b >= 0) cout << "Zero" << endl;
  else {
    if((b - a + 1) % 2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
}

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

int main() {
    string s,t;
    cin>>s>>t;
    bool flag = true;
    for(int i=0; i<s.size(); i++) {
        if(s[i] != t[i]) flag = false;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int Q, pn[100001], pn2017[100001];
int main() {
  for(int i = 2; i <= 1e5; ++i) pn[i] = 1;
  for(int i = 2; i <= sqrt(1e5); ++i) {
    if(!pn[i]) continue;
    for(int j = 2; i*j <= 1e5; ++j) pn[i*j] = 0;
  }
  for(int i = 2; i <= 1e5; ++i) {
    pn2017[i] = pn2017[i-1]+(pn[i]&&pn[(i+1)/2]);
  }
  scanf("%d", &Q);
  for(int i = 1, l, r; i <= Q; ++i) {
    scanf("%d %d", &l, &r);
    printf("%d\n", pn2017[r]-pn2017[l-1]);
  }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg
#define newl cout<<"\n"
using namespace std;
typedef long long ll;
double T,X;
int main(){
  scan(T);scan(X);
  double t=T/X;
  printf("%.10f\n",t);
  return 0;
}


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


using namespace std;


int const MOD = 1000000007;

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

int mul(int a, int b) {
	return (int) ((long long) a * b % MOD);
}
int const N = 33333;
int const K = 444;

int a[N], f[N][K], pw[N], was[K];

int getf(int x, int y) {
	if (y == 0) return f[x][y];
	int ans = f[x][y];
	add(ans, MOD - f[x][y - 1]);
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	int n, k, m;
	cin >> n >> k >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (int i = 1; i < k; i++) {
		f[0][i] = 1;
		add(f[0][i], f[0][i - 1]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < k; j++) {
			if (j + 1 < k) {
				add(f[i][j], mul(k - j, getf(i - 1, j + 1)));
			}
			add(f[i][j], f[i - 1][j]);
			add(f[i][j], f[i][j - 1]);
		}
	}
	pw[0] = 1;
	for (int i = 1; i <= n; i++) {
		pw[i] = mul(pw[i - 1], k);
	}
	bool ok = false;
	for (int i = 0, j = 0; i < m; i++) {
		while (j < m && !was[a[j]]) {
			was[a[j]] = true;
			j++;
		}
		if (j - i == k) {
			ok = true;
			break;
		}
		was[a[i]] = false;
	}
	if (ok) {
		cout << mul(n - m + 1, pw[n - m]) << '\n';
		return 0;
	}
	for (int i = 0; i < k; i++) was[i] = false;
	int start = 0;
	while (start < m && !was[a[start]]) {
		was[a[start]] = true;
		++start;		
	}
	if (start == m) {
		int ans = 0;
		for (int left = 0; left + m <= n; left++) {
			int right = n - left - m;
			int gLeft = pw[left];
			int bLeft = getf(left, start);
			add(gLeft, MOD - bLeft);
			add(ans, mul(gLeft, pw[right]));
			// cout << "left = " << left << ", ans = " << ans << endl;
			int coef = 1;
			for (int j = start; j < k && j - start <= left; j++) {
				int jLeft = left - (j - start);
				int bLeft = jLeft == 0 ? 1 : f[jLeft - 1][j];
				int gRight = pw[right];
				add(gRight, MOD - getf(right, j));
				add(ans, mul(coef, mul(bLeft, gRight)));
				coef = mul(coef, k - j);
			}
			// cout << "left = " << left << ", ans = " << ans << endl;
		}
		cout << ans << '\n';
	} else {
		int startRight = 0;
		for (int i = 0; i < k; i++) was[i] = false;
		while (startRight < m && !was[a[m - startRight - 1]]) {
			was[a[m - startRight - 1]] = true;
			++startRight;
		}
		// cout << "start = " << start << ", startRight = " << startRight << endl;
		int ans = 0;
		for (int left = 0; left + m <= n; left++) {
			int gLeft = pw[left];
			int bLeft = getf(left, start);
			add(gLeft, MOD - bLeft);
			int right = n - left - m;
			int gRight = pw[right];
			add(gRight, MOD - getf(right, startRight));
			add(ans, mul(gLeft, pw[right]));
			// cout << getf(right, startRight) << endl;
			// cout << "left = " << left << ", ans = " << ans << endl;
			add(ans, mul(bLeft, gRight));
			// cout << "left = " << left << ", ans = " << ans << endl;
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 45440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		string S = GetString();
		string T = GetString();
		int q = GetInt();
		int[] a = new int[q];
		int[] b = new int[q];
		int[] c = new int[q];
		int[] d = new int[q];
		for(int i = 0; i < q; i++)
		{
			a[i] = GetInt();
			b[i] = GetInt();
			c[i] = GetInt();
			d[i] = GetInt();
		}

		int N = S.Length; 
		int M = T.Length;
		int[] csumS = new int[N + 1];
		for(int i = 0; i < N; i++)
		{
			csumS[i + 1] = csumS[i] + ((S[i] == 'A') ? 1 : 2);
			csumS[i + 1] %= 3;
		}

		int[] csumT = new int[M + 1];
		for(int i = 0; i < M; i++)
		{
			csumT[i + 1] = csumT[i] + ((T[i] == 'A') ? 1 : 2);
			csumT[i + 1] %= 3;
		}

		string[] ans = new string[q];
		for(int i = 0; i < q; i++)
		{
			int subS = (csumS[b[i]] - csumS[a[i] - 1] + 3) % 3;
			int subT = (csumT[d[i]] - csumT[c[i] - 1] + 3) % 3;
			ans[i] = (subS == subT) ? "YES" : "NO";
		}

		WriteLine(string.Join("\n" ,ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 23484
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll h,w,n;
  cin>>h>>w>>n;
  ll mn=max(h,w);
  n+=mn-1;
  cout<<n/mn<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	ll i = 0;
	while(1){
		i++;
		if(i*(i+1)/2>=N) break;
	}
	for(int k=1;k<=i;k++){
		if(k!=i*(i+1)/2-N) cout << k << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int h,m,s,n;

    cin>>n;

    s=n%60;
    n/=60;

    m=n%60;
    n/=60;

    h=n%24;

    cout<<h<<":"<<m<<":"<<s<<endl;

    return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string a,b; cin >> a >> b;
  for(int i = 0; i < (int)b.size(); ++i)cout << a[i] << b[i];
  if(a.size() != b.size())cout << a.back();
  cout << endl;
}



Measured memory_bytes: 3600
n, k = map(int, input().split())
arr = list(map(int, input().split()))

max_x = k
i = 0
xy = []
res = 0

while any(arr) > 0 or k > 0:
    sum_arr = sum(a % 2 for a in arr)
    if sum_arr < n / 2:
        xy.append([2 ** i, (n - sum_arr) * 2 ** i, sum_arr * 2 ** i])
    else:
        res += sum_arr * 2 ** i
    arr = [a // 2 for a in arr]
    k //= 2
    i += 1

for a, b, c in xy[::-1]:
    if a <= max_x:
        res += b
        max_x -= a
    else:
        res += c

print(res)


Measured memory_bytes: 14708
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;

int dp[100001][13];
int ex[100001];
int n;
int M = 1e9 + 7;
string S;

int compute(int pos, int mod){
    if(pos == n){
        if(mod == 5) return 1;
        return 0;  
    }

    if(dp[pos][mod] != -1) return dp[pos][mod];
    
    int p = pos;
    int ans = 0;
    
    if(S[p] == '?'){
        for(int j=0;j<10;j++){
            int temp;
            temp = (j + (mod*10)%13) % 13;
            ans = (ans + compute(pos+1, temp))%M;
        }
    }
    else {
        int j = S[p] - '0';
        int temp;
        temp = (j + (mod*10)%13)%13;
        ans = (ans + compute(pos+1, temp))%M;
    }
    return dp[pos][mod] = ans; 
}

int32_t main()
 {
	
    cin>>S;

    n = S.size();
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            dp[i][j] = -1;
        }
    }

    ex[0] = 1;
    for(int i=1;i<n;i++){
        ex[i] = (10*ex[i-1]) % 13;
    }

    int ans = compute(0, 0);

    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 19200
from sys import stdin
def main():
  from builtins import range
  readline = stdin.readline
  h, w = map(int, readline().split())
  s = [readline().rstrip('\r\n') + '#' for _ in range(h)]
  s.append('#' * w)
  ft = [[i] * i for i in range(1000)]
  yoko = [[0] * w for _ in range(h)]
  for i in range(h):
    start = -1
    si = s[i]
    yokoi = yoko[i]
    for j in range(w + 1):
      if si[j] == '#':
        if start != -1:
          t = j - start
          if t < 1000:
            yokoi[start:j] = ft[t]
          else:
            yokoi[start:j] = [t] * t
          start = -1
      else:
        if start == -1:
          start = j
  result = 0
  for i in range(w):
    start = -1
    for j in range(h + 1):
      if s[j][i] == '#':
        if start != -1:
          t = yoko_max + j - start - 1
          if t > result:
            result = t
          start = -1
      else:
        yji = yoko[j][i]
        if start == -1:
          start = j
          yoko_max = yji
        else:
          if yji > yoko_max:
            yoko_max = yji
  print(result)
main()

Measured memory_bytes: 42740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
int dp[100100];
const int INF = 1000100;
int main() {
  int n;
  cin >> n;
  dp[0] = 0;
  for(int i=1; i<=100000; i++){
    dp[i] = INF;
    int power = 1;
    while(power<=i){
      dp[i] = min(dp[i],dp[i-power]+1);
      power *= 6;
    }
    int power2 = 1;
    while(power2<=i){
      dp[i] = min(dp[i],dp[i-power2]+1);
      power2 *= 9;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  ll x;
  cin >> x;
  ll cnt = x/11;
  if(x%11==0){
    cout << cnt*2 << endl;
  }else if(x%11 <= 6){
    cout << cnt*2 + 1 << endl;
  }else{
    cout << cnt*2 + 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  }
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

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

int main(){
    int n;
    lld m;
    scanf("%d %lld", &n, &m);
    lld a[n];
    rep(i, 0, n){
        scanf("%lld", &a[i]);
        a[i] /= 2;
    }
    lld x=1, y;
    int cnt = 0, f = 0;
    int buf = a[0];
    while(buf%2 == 0){
        buf /= 2;
        cnt++;
    }
    rep(i, 1, n){
        buf = a[i];
        int c = 0;
        while(buf%2 == 0){
            buf /= 2;
            c++;
        }
        if(cnt != c){
            f = 1;
        }
    }
    rep(i, 0, n){
        y = x*a[i];
        x = y / gcd(x, a[i]);
    }
    if(f){
        printf("0");
    }else{
        printf("%lld", (m/x + 1)/2);
    }

    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
int main()
{
  char a[10000];
  scanf("%s",&a);
  int p = 0;
  int s = strlen(a);
  for(int i = 0;i < s ; i++)
  { if(a[i]=='2')
  {p++;}
  }
  printf("%d",p);
  return 0;
}

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

int main(int argc, char const *argv[])
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if ((abs(b - a) <= d && abs(c - b) <= d) || (abs(c - a) <= d))	printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  ll a,b,t;
  cin >> a >> b >> t;


  ll ans = 0;


  ans = (t/a) * b;




  cout << ans ;

}




















Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int patition(int [],int,int);

int A[N];

int main(){

  int i,p=0,q=0,r;

  scanf("%d",&r);
  for(i=0;i<r;i++){
    scanf("%d",&A[i]);
  }
  
  q = partition(A,p,r);
  
  return 0;
}

int partition(int A[],int p,int r){

  int i,j,x=0,s=0;

  x=A[r-1];
  if(p==0){
    i=p;
  }else{
    i=p-1;
  }

  for(j=p;j<r-1;j++){
    if(A[j]<=x){
     
      s=A[i];
      A[i]=A[j];
      A[j]=s;
      i++;
    }
  }

  s=A[i];
  A[i]=A[r-1];
  A[r-1]=s;

  for(j=0;j<r;j++){
    if(j>0){
      printf(" ");
    }
    if(i==j){
      printf("[%d]",A[j]);
    } else{
      printf("%d",A[j]);
    }
  }
  
  printf("\n");
  return i+1;
}

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

using namespace std;
int main() {
  string str;
  cin >> str;
  int map[255]={0};
  for(int i=0;i<str.size();i++){
    map[str[i]]++;
  }
  for(int i=0;i<255;i++){
    if(map[i]>1){
      cout << "no" <<endl;
      return 0;
    }
  }
  cout << "yes" <<endl;
}


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

#define mp make_pair
#define pb push_back
#define mp make_pair

bool graph[1000][1000];

vector<int>g[100100];


int main(){
    ll r,g,b,n,mx = 1,mn = 1000;
    cin>>n;
    std::vector<int> v;
    for(int i = 0; i < n;i++){
        cin>>g;
        if(g > mx){
            mx = g;
        }
        if(g < mn){
            mn = g;
        }
    }
    cout<<mx - mn;

    return 0;

}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);
	}
	
	int max;
	int semimax;
	
	if(a[0]>a[1]){
		max=0;
		semimax=1;
	}else{
		max=1;
		semimax=0;
	}
	
	for(int i=2;i<n;i++){
		if(a[i]>a[max]){
			semimax=max;
			max=i;
		}else if(a[i]>a[semimax]){
			semimax=i;
		}
	}
	
	for(int i=0;i<n;i++){
		if(i==max)	printf("%d\n", a[semimax]);
		else	printf("%d\n", a[max]);
	}
	return 0;
}

Measured memory_bytes: 2304
import sys
sys.setrecursionlimit(2 * 10**5)

N = int(input())
h = list(map(int, input().split()))


# 貪欲に極大区間に対して水やりする
def f(y):
    L = next(
        (
            i
            for i, x in enumerate(y)
            if x > 0
        ),
        N
    )
    R = next(
        (
            i
            for i, x in enumerate(y[L:], L)
            if x == 0
        ),
        N
    )
    return (
        0 if L == N else
        1 + f(
            [x for x in y[:L]] +
            [x - 1 for x in y[L:R]] +
            [x for x in y[R:]]
        )
    )


ans = f(h)

print(ans)


Measured memory_bytes: 11372
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint r; cin >> r;
    cout << r * r << "\n";
}

Measured memory_bytes: 256