akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

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

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

fn vs(a: &mut Vec<Vec<usize>>, n: usize, p1: usize, p2: usize, done: &mut Vec<bool>) -> bool {
    if done[p2 - 1] {
        a[p1 - 1].push(p2);
        done[p1 - 1] = true;
        return false;
    } else if let Some(p3) = a[p2 - 1].pop() {
        if p1 != p3 {
            done[p1 - 1] = true;
            a[p1 - 1].push(p2);
            return vs(a, n, p2, p3, done);
        }
        done[p1 - 1] = true;
        done[p2 - 1] = true;
        return true;
    }
    false
}

fn day(a: &mut Vec<Vec<usize>>, n: usize) -> u32 {
    let mut done: Vec<bool> = vec![false; n];
    let mut cnt: u32 = 0;
    for p1 in 1..(n + 1) {
        if done[p1 - 1] {
            continue;
        } else if let Some(p2) = a[p1 - 1].pop() {
            if vs(a, n, p1, p2, &mut done) {
                cnt += 1;
            }
        }
    }
    cnt
}

fn all(a: &mut Vec<Vec<usize>>, n: usize) -> i32 {
    let mut vs_cnt: u32 = 0;
    let mut day_cnt: i32 = 0;

    while vs_cnt < ((n * (n - 1)) / 2) as u32 {
        let tmp = day(a, n);
        if tmp == 0 {
            day_cnt = -1;
            break;
        } else {
            vs_cnt += tmp;
        }
        day_cnt += 1;
    }

    return day_cnt;
}

fn main() {
    let n: u32 = read();
    let av: Vec<u32> = read_vec();
    let mut pv: Vec<(u32, u32)> = vec![];
    for i in 0..av.len() {
        pv.push((av[i], (i + 1) as u32));
    }
    pv.sort_by(|a, b| a.0.partial_cmp(&(b.0)).unwrap());
    for i in 0..pv.len() {
        print!("{}", pv[i].1);
        if i == pv.len() - 1 {
            println!("");
        } else {
            print!(" ");
        }
    }
}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int x; cin >> x;
    int ans = 0;
    for(int i = 1;i <= x;i++){
        if(to_string(i).length() % 2 != 0) ans++;
    }
    cout << ans;
}


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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,m;cin>>n>>m;
  string s;cin>>s;
  reverse(s.begin(),s.end());
  vector<int> ans;
  int now=0;
  while(now<n){
    int a=0;
    for(int i=1;i<=m;i++)if(s[now+i]=='0')a=i;
    if(a==0)fin(-1);
    now+=a;
    ans.push_back(a);
  }
  reverse(ans.begin(),ans.end());
  for(int p:ans)cout<<p<<" ";cout<<endl;
}


Measured memory_bytes: 1528
k, n = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0]*n
for i in range(n-1):
	b[i] = a[i+1]-a[i]
b[n-1] = k - a[n-1] + a[0]
print(k-max(b))

Measured memory_bytes: 26444
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	ll n,x,t;
        	cin>>n>>x>>t;
        	if(n%x==0){
        		cout<<(n/x)*t;
        	}
        	else{
        		cout<<(n/x+1)*t;
        	}
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3800
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll N;
vector< ll > A;
set< ll > X;
map< ll, vector< ll > > Lmap;
map< ll, vector< ll > > Rmap;

signed main()
{
  ll cnt = 0;

  cin >> N;

  REP(i, N)
  {
    ll ai;
    cin >> ai;

    // Li = i + Ai
    ll l = i + ai;
    Lmap[l].push_back(i);
    // Rj = j - Aj
    ll r = i - ai;
    Rmap[r].push_back(i);

    // とりうるXを保存
    X.insert(l);
    X.insert(r);
  }

  for (auto x : X)
  {
    // cout << "x: " << x << endl;
    // DEBUG_VEC(Lmap[x]);
    // DEBUG_VEC(Rmap[x]);
    cnt += Lmap[x].size() * Rmap[x].size();
  }

  cout << cnt << endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  long long p = 0;
  p += A[0] / 2;
  A[0] %= 2;
  for(int i = 1; i < N; i++){
    if(A[i - 1] > 0 && A[i] > 0){
      A[i]--;
      p++;
    }
    p += A[i] / 2;
    A[i] %= 2;
  }
  
  cout << p << endl;
  
  return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef

main :: IO ()
main = do
  [a,b,c] <- map read . words <$> getLine :: IO [Int64]
  let eatablePoisonous = c `min` (a+b+1)
  print $ eatablePoisonous + b
  


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

void solve()
  {

  }

int main()
  {
  string a, b;
  cin >> a >> b;
  b.pop_back();
  cout << (a == b ? "Yes" : "No") << endl;
  }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

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

void Main(){
	int n; cin >> n;
	priority_queue<int> red;
	priority_queue<int, vector<int>, greater<int>> white;
	string s; cin >> s;
	rep(i,n){
		if(s[i] == 'R'){
			red.push(i);
		}else{
			white.push(i);
		}
	}
	int ans = 0;
	while(!red.empty() && !white.empty()){
		int w = white.top();
		white.pop();
		int r = red.top();
		red.pop();

		if(r < w){
			cout << ans << endl;
			return;
		}
		white.push(r);
		red.push(w);
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4744
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 200000
#define MO 1000000007
#define INF 0x3FFFFFFF
using namespace std;
int n,X,Y;
int c[MAXN+5],w[MAXN+5];
int fact[MAXN+5],inv[MAXN+5];
int minpos[MAXN+5],minval[MAXN+5];//代表的是某种颜色的最小重量以及球的编号
int cnt[MAXN+5];
bool vis[MAXN+5];
vector<int> G[MAXN+5];
int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		minval[i]=INF;
	fact[0]=1;
	for(int i=1;i<=MAXN;i++)
		fact[i]=1LL*fact[i-1]*i%MO;
	inv[MAXN]=PowMod(fact[MAXN],MO-2);
	for(int i=MAXN-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;
}
void DFS(int u)//使用DFS求出所有的与mnp1联通的球
{
	vis[u]=true;
	for(int i=0;i<(int)G[u].size();i++)
	{
		int v=G[u][i];
		if(vis[v]==false)
			DFS(v);
	}
}
int C(int a,int b)
{
	return 1LL*fact[a]*inv[b]%MO*inv[a-b]%MO;
}
int main()
{
	Init();
	scanf("%d %d %d",&n,&X,&Y);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&c[i],&w[i]);
		if(minval[c[i]]>w[i])
		{
			minval[c[i]]=w[i];
			minpos[c[i]]=i;
		}
	}
	for(int i=1;i<=n;i++)
		if(i!=minpos[c[i]]&&w[i]+minval[c[i]]<=X)
			G[i].push_back(minpos[c[i]]),G[minpos[c[i]]].push_back(i);//同种颜色的建图
	int mn1=INF,mn2=INF;
	int mnp1,mnp2;
	//先找最小值 
	for(int i=1;i<=n;i++)
		if(w[i]<mn1)
			mn1=w[i],mnp1=i;
	//再找与最小值颜色不同的最小值 
	for(int i=1;i<=n;i++)
		if(w[i]<mn2&&c[i]!=c[mnp1])
			mn2=w[i],mnp2=i;
	for(int i=1;i<=n;i++)
	{
		if(i==mnp1)//全局最小球当然不需要和自己连边
			continue;
		if(c[i]!=c[mnp1]&&w[i]+w[mnp1]<=Y)//与最小球颜色不同
			G[i].push_back(mnp1),G[mnp1].push_back(i);
		if(mn2!=INF&&c[i]!=c[mnp2]&&w[i]+w[mnp2]<=Y)//与最小球颜色相同 eles if也可以
			G[i].push_back(mnp2),G[mnp2].push_back(i);
	}
	DFS(mnp1);
	for(int i=1;i<=n;i++)
		if(vis[i]==true)
			cnt[c[i]]++;
	int tot=0,ans=1;
	for(int i=1;i<=n;i++)
		tot+=cnt[i];
	for(int i=1;i<=n;i++)
		if(cnt[i])
		{
			ans=1LL*ans*C(tot,cnt[i])%MO;//用法二求出答案
			tot-=cnt[i];
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 17904
from collections import defaultdict, deque
v,n=map(int,input().split())
es=[]
l=[[]for i in range(v)]
for i in range(n-1+v):
    a,b=[int(j)-1 for j in input().split()]
    es.append((a,b))
    l[a].append(b)
#頂点は0~v-1

outs = defaultdict(list)
ins = defaultdict(int)
for v1, v2 in es:
    outs[v1].append(v2)
    ins[v2] += 1

q = deque(v1 for v1 in range(v) if ins[v1] == 0)
res = []
while q:
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append(v2)

ans=[0]*v
s=set()
for i in res[::-1]:
    s.add(i)
    for j in l[i]:
        if j in s:
            ans[j]=i+1
            s.remove(j)

print('\n'.join(map(str,ans)))

Measured memory_bytes: 63972
#include <stdio.h>
#include <string.h>

int main(void) {
  char S[4];
  scanf("%s", S);

  int N = strlen(S);
  if(N == 2) {
    printf("%s\n", S);
  } else {
    printf("%c%c%c\n", S[2], S[1], S[0]);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end() 
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout  
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';


const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ull MOD = 1e9 + 7;
const int N = (int)(5e5) + 1;


inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, m;
ll dp[1001][1001];
char g[1001][1001];

ll rec(int x, int y)
{
	if (g[x][y] == '#')return 0;
	if (x == n - 1 && y == m - 1) return 1;

	ll& dp = ::dp[x][y];
	if (dp != -1) return dp;
	dp = 0;
	if (x + 1 < n)
	{
		dp = rec(x + 1, y);
	}
	dp %= MOD;
	if (y + 1 < m)
	{
		dp += rec(x, y + 1);
	}
	dp %= MOD;
	return dp;
}

int main()
{

	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf(" %c", g[i] + j);
		}
	}

	memset(dp, -1, sizeof(dp));

	printf("%lld", rec(0, 0));
}

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

typedef int ll;

#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}

ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;

	int cnt=0;
	while (1) {
		if(a%2==1 || b%2==1 || c%2==1 || cnt==100000000)
			break;
		int p=a,q=b;
		a=b/2+c/2;
		b=p/2+c/2;
		c=q/2+p/2;
		cnt++;
	}	

	if(cnt==100000000) {
		cout<<"-1\n";
	}
	else
		cout<<cnt<<endl;
}

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


using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(t.size()-s.size()==0&&s.compare(t)==0)
        {

        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  string s;
  cin >> s;
  
  int ans = MOD;
  REP(i,26){
    int pre = s.size();
    int cnt = -1;
    RREP(j,s.size()){
      if(s[j]-'a' != i) continue;
	  cnt = max(cnt,pre-j-1);
      pre = j;
    }
    if(pre == s.size()) continue;
    cnt = max(cnt,pre);
    ans = min(ans,cnt);
  }
   
  cout << ans << endl;

  return 0;
}

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

int M(vector<int> A){
	int m = 0;
	int c = 0;
	int d = A[1] - A[0];
	while(1){
		for(int i = m + 1; i < A.size(); i++){
			c++;
			if(A[i] - A[m] < 0){
				m = i;
				break;
			}
			if(A[i] - A[m] > d){
				d = A[i] - A[m];
			}
		}
		if(c >= A.size() - 1) break;
	}
	return d;
}

int main(){
	int n;
	cin >> n;
	vector<int> A;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
	cout << M(A) << endl;
	return 0;
}

Measured memory_bytes: 2848
def degit(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num //= 10
    return sum

num_list = []
while True:
    a = int(input())
    if a != 0:
        num_list.append(a)
    else:
        break

for i in num_list:
    print(degit(i))



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll f(ll x, ll y, ll z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}
int main(){
    ll n;   cin >> n;

    rep(q, n){
        ll res=0, tar=q+1;
        FOR(i, 1, n){
            if(6*i*i==tar) res += 1;
            else if(tar<6*i*i) break;
        }
        FOR(i, 1, n){
            if(tar<3*i*i) break;
            FOR(j, i+1, n){
                ll obj = 3*i*i+j*j+2*i*j;
                if(obj==tar) res += 3;
                else if(tar<obj) break;
            }
        }
        FOR(i, 1, n){
            if(tar<3*i*i) break;
            FOR(j, 1, i){
                ll obj = 3*i*i+j*j+2*i*j;
                if(obj==tar) res += 3;
                else if(tar<obj) break;
            }
        }
        FOR(i, 1, n){
            if(tar<i*i) break;
            FOR(j, i+1, n){
                ll obj = i*i+j*j+i*j;
                if(tar<obj) break;
                FOR(k, j+1, n){
                    ll obj2 = obj+k*k+i*k+k*j;
                    if(obj2==tar) res += 6;
                    else if(tar<obj2) break;
                }
            }
        }
        //cout << tar << ' '; 
        cout << res << endl;
    }

}


Measured memory_bytes: 3568
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=1000010;
int p[N],a[N],n,k,d[N],tot,ans[N];
vector<int>G[N];
priority_queue<int,vector<int>,greater<int> >Q;
void Add(int u,int v){G[u].push_back(v);d[v]++;}
int t[N<<1];
void modify(int o,int l,int r,int pos,int v){
	if(l==r){t[o]=v;return;}
	int mid=(l+r)>>1;
	if(pos<=mid)modify(o<<1,l,mid,pos,v);
	else modify(o<<1|1,mid+1,r,pos,v);
	t[o]=min(t[o<<1],t[o<<1|1]);
}
int query(int o,int l,int r,int posl,int posr){
	if(posl>posr)return t[0];
	if(posl<=l && r<=posr)return t[o];
	int mid=(l+r)>>1,ret=t[0];
	if(posl<=mid)ret=min(ret,query(o<<1,l,mid,posl,posr));
	if(mid<posr)ret=min(ret,query(o<<1|1,mid+1,r,posl,posr));
	return ret;
}
int main(){
	n=gi();k=gi();
	for(int i=1;i<=n;i++)p[i]=gi(),a[p[i]]=i;
	memset(t,127/3,sizeof(t));
	for(int i=n;i;i--){
		int x=query(1,1,n,a[i]+1,min(n,a[i]+k-1));
		if(x<t[0])Add(a[i],a[x]);
		x=query(1,1,n,max(1,a[i]-k+1),a[i]-1);
		if(x<t[0])Add(a[i],a[x]);
		modify(1,1,n,a[i],i);
	}
	for(int i=1;i<=n;i++)if(!d[i])Q.push(i);
	while(!Q.empty()){
		int u=Q.top();Q.pop();ans[u]=++tot;
		for(int v:G[u]){d[v]--;if(!d[v])Q.push(v);}
	}
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 64256
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
using namespace std;
int a[110000];
int main(){
	int h,n,i;
	scanf("%d%d",&h,&n);
	int ans=0;
	for(i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		ans+=x;
	}
	if(ans>=h)
	printf("Yes\n"); 
	else
	printf("No\n");
}

Measured memory_bytes: 128
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    h, w = ns()
    mat = [list(input()) for _ in range(h)]
    dp = [[0 for _ in range(w)] for __ in range(h)]
    dp[0][0] = 1

    def calc(x, y, val):
        if x >= w or y >= h:
            return
        if mat[y][x] == "#":
            return
        dp[y][x] += val
        dp[y][x] %= MOD
        return

    for y in range(h):
        for x in range(w):
            calc(x + 1, y, dp[y][x])
            calc(x, y + 1, dp[y][x])
    print(dp[h - 1][w - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 127720
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

struct node {
	int parent;
	int depth;
	int sib;
	int dmax;
	int left;
	int right;
};

vector<node> tree;

void update_depth(int ind, int d) {
	if (ind < 0) {
		return;
	}
	tree[ind].depth = d;
	tree[ind].dmax = d;
	update_depth(tree[ind].left,d+1);
	update_depth(tree[ind].right,d+1);
	return;
}

int main(void) {
	int n;
	cin >> n;
	tree = vector<node>(n);
	for (int i = 0; i < n; ++i) {
		tree[i].parent = -1;
		tree[i].sib = -1;
	}
	int id;
	for (int i = 0; i < n; ++i) {
		cin >> id;
		cin >> tree[id].left >> tree[id].right;
		if (tree[id].left >= 0) {
			tree[tree[id].left].sib = tree[id].right;
			tree[tree[id].left].parent = id;
		}
		if (tree[id].right >= 0) {
			tree[tree[id].right].sib = tree[id].left;
			tree[tree[id].right].parent = id;
		}
	}
	int root;
	for (int i = 0; i < n; ++i) {
		if (tree[i].parent < 0) {
			root = i;
			break;
		}
	}
	update_depth(root,0);

	vector< pair<int,int> > nl(n);
	for (int i = 0; i < n; ++i) {
		nl[i].first = tree[i].depth;
		nl[i].second = i;
	}
	sort(nl.begin(),nl.end());
	int par;
	for (int i = 0; i < n; ++i) {
		par = tree[nl[n-i-1].second].parent;
		if (par >= 0) {
			tree[par].dmax = max(tree[nl[n-i-1].second].dmax,tree[par].dmax);
		}
	}

	for (int i = 0; i < n; ++i) {
		cout << "node " << i;
		cout << ": parent = " << tree[i].parent;
		cout << ", sibling = " << tree[i].sib;
		cout << ", degree = ";
		if (tree[i].left < 0 || tree[i].right < 0) {
			if (tree[i].left < 0 && tree[i].right < 0) {
				cout << 0;
			}
			else {
				cout << 1;
			}
		}
		else {
			cout << 2;
		}
		cout << ", depth = " << tree[i].depth;
		cout << ", height = " << tree[i].dmax-tree[i].depth;
		if (tree[i].parent < 0) {
			cout << ", root" << endl;
		}
		else {
			if (tree[i].left < 0 && tree[i].right < 0) {
				cout << ", leaf" << endl;
			}
			else {
				cout << ", internal node" << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3164
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	c := sc.ReadString()

	counter := 0
	leftPos := 0
	rightPos := n
	for ; leftPos < rightPos; leftPos++ {
		if c[leftPos] == 'W' {
			for {
				rightPos--
				if rightPos <= leftPos {
					break
				}

				if c[rightPos] == 'R' {
					counter++
					break
				}
			}
		}
	}

	fmt.Println(counter)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    map<int,int> mp;
    for (int i = 0; i < n; i += 2) {
        mp[v[i]]++;
    }
    vector<pair<int,int>> even;
    for (auto p: mp) {
        even.push_back(p);
    }
    even.push_back({0,0});
    sort(even.begin(),even.end(),[](auto a, auto b) {
            return a.second > b.second;
            });

    map<int,int> mp2;
    for (int i = 1; i < n; i += 2) {
        mp2[v[i]]++;
    }
    vector<pair<int,int>> odd;
    for (auto p: mp2) {
        odd.push_back(p);
    }
    odd.push_back({-1,0});
    sort(odd.begin(),odd.end(),[](auto a, auto b) {
            return a.second > b.second;
            });
    if (even[0].first != odd[0].first) {
        int ans = (n/2-even[0].second) + (n/2-odd[0].second);
        cout << ans << '\n';
    }
    else {
        int a1 = (n/2-even[1].second) + (n/2-odd[0].second);
        int a2 = (n/2-even[0].second) + (n/2-odd[1].second);
        cout << min(a1,a2) << '\n';
    }
}



Measured memory_bytes: 6520
#include <iostream>
#include <vector>
#include <complex>
#include <iomanip>
#include <cmath>

using namespace std;

typedef complex<double> P;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double eps = 1e-8, inf = 1e8;

template<typename T> T sqr(T x){return x*x;}

double cross(const P &a, const P &b){
    return imag(conj(a) * b);
}

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

int ccw(P a, P b, P c){
    b -= a; c -= a;
    if(cross(b, c) > eps)return 1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)return 2;
    if(norm(b) < norm(c))return -2;
    return 0;
}

struct L:vector<P>{
    L(const P &a, const P &b){
        push_back(a); push_back(b);
    }
};

bool interSS(const L &s, const L &t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

bool interSP(const L &s, const P &p){
    return abs(s[0]-p) + abs(s[1]-p) - abs(s[1]-s[0]) < eps;
}

P xptSS(const L &s, const L &t){
    double d = cross(s[1] - s[0], t[1] - t[0]);
    if(abs(d) < eps){
        if(interSP(t, s[0]))return s[0];
        if(interSP(t, s[1]))return s[1];
        if(interSP(s, t[0]))return t[0];
        return t[1];
    }
    return t[0] + (t[1] - t[0]) * cross(s[1] - s[0], s[1] - t[0]) * (1. / d);
}

struct C:P{
    double r;
    C(const P &a, double r):P(a), r(r){}
};

int overlap(const C &c1, const C &c2){
    if(sqr(c1.r + c2.r) < norm(c1 - c2))return 0;
    if(abs(c1 - c2) + c1.r < c2.r + eps)return -1;
    if(c2.r < c1.r && abs(c1 - c2) + c2.r < c1.r + eps)return 1;
    if(abs(abs(c1 - c2) - c1.r - c2.r) < eps)return -2;
    return 2;
}

vector<P> xptCC(const C &c1, const C &c2){
    vector<P> res;
    double d = abs(c1 - c2);
    if(d < eps || abs(overlap(c1, c2)) != 2)return res;
    double rc = (sqr(d) + sqr(c1.r) - sqr(c2.r)) / (2. * d);
    double rs = sqrt(sqr(c1.r) - sqr(rc));
    P diff = (c2 - c1) / d;
    res.push_back(c1 + diff * P(rc, rs));
    res.push_back(c1 + diff * P(rc, -rs));
    return res;
}

double solve(vector<C> stake){
    vector<P> fixpt(all(stake));
    vector<L> locus;
    rep(i, (int)stake.size())rep(j, i){
        vector<P> xpt = xptCC(stake[i], stake[j]);
        if(xpt.empty())continue;
        fixpt.push_back((xpt[0] + xpt[1]) / 2.);
        locus.emplace_back(xpt[0], xpt[1]);
    }
    rep(i, (int)locus.size())rep(j, i){
        if(!interSS(locus[i], locus[j]))continue;
        fixpt.push_back(xptSS(locus[i], locus[j]));
    }
    double res = 0.;
    for(auto p: fixpt){
        double h = inf;
        for(auto c: stake)h = min(h, sqr(c.r) - norm(c - p));
        res = max(res, h);
    }
    return res;
}

int main(){
    for(int n; cin >> n, n;){
        vector<C> stake;
        rep(i, n){
            int x, y, l;
            cin >> x >> y >> l;
            stake.emplace_back(P(x, y), l);
        }
        cout << fixed << setprecision(7) << sqrt(solve(stake)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
  double x,h,s;
  
  cin >> x >> h;
  while(x!=0&&h!=0){
    s=x*x+sqrt(h*h+x*x/4)*x*2;
    printf("%.6f\n",s);
    cin >> x >> h;
  }
  return 0;
}

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

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

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

    return 0;
}

Measured memory_bytes: 256
a, b, c, k = map(int, input().split())

suma = 0


if k > a:
    if k > a + b:
        if k == a + b + c:
            print(a - c)
        else:
            k = k - (a + b)
            print(a-k)
    else:
        print(a)
else:
    print(k)

Measured memory_bytes: 9188
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp.to!(char[]);
    auto K = S.length;
    int w;
    foreach (s; S) {
        if (s == 'o') ++w;
    }
    writeln(w+(15-K) >= 8 ? "YES" : "NO");
}

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

class union_find {
public:
    int par[200000];
    int rank[200000];

    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    int N, K, L;
    cin >> N >> K >> L;
    vector<int> P(K), Q(K);
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        P[i] = p, Q[i] = q;
    }
    vector<int> R(L), S(L);
    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        R[i] = r, S[i] = s;
    }

    union_find uf1, uf2;
    uf1.init(N), uf2.init(N);

    for (int i = 0; i < K; i++) uf1.unite(P[i], Q[i]);
    for (int i = 0; i < L; i++) uf2.unite(R[i], S[i]);


    map<pair<int, int>, int> count;
    for (int i = 0; i < N; i++) {
        count[pair<int, int>(uf1.find(i), uf2.find(i))]++;
    }
    for (int i = 0; i < N; i++) {
        cout << count[pair<int, int>(uf1.find(i), uf2.find(i))] << " ";
    }
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <queue>
#define LIM 2000001 
using namespace std;

struct node {
	int left;
	int right;
	int key;
};

int main(void) {
	int noq,num;
	cin >> noq;
	string ope;
	vector<node> dll(LIM);
	dll[0] = {0,0,-1};
	for (int q = 1; q < noq+1; ++q) {
		cin >> ope;
		if (ope == "insert") {
			cin >> num;
			dll[q] = {0,dll[0].right,num};
			dll[dll[0].right].left = q;
			dll[0].right = q;
		}
		else if (ope == "delete") {
			cin >> num;
			bool end = false;
			bool find = false;
			int next = dll[0].right;
			while (!find && !end) {
				if (dll[next].key == num) {
					int temp;
					dll[dll[next].left].right = dll[next].right;
					dll[dll[next].right].left = dll[next].left;
					find = true;
				}
				else if (dll[next].key == -1) {
					end = true;
				}
				else {
					next = dll[next].right;
				}
			}
		}
		else if (ope == "deleteFirst") {
			dll[0].right = dll[dll[0].right].right; 
			dll[dll[0].right].left = 0;
		}
		else if (ope == "deleteLast") {
			dll[0].left = dll[dll[0].left].left;
			dll[dll[0].left].right = 0;
		}
		int next = dll[0].right;
	}

	bool first = true;
	bool end = false;
	int next = dll[0].right;
	while (!end) {
		if (dll[next].key == -1) {
			end = true;
		}
		else {
			if (!first) {
				cout << " ";
			}
			first = false;
			cout << dll[next].key;
			next = dll[next].right;
		}
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 26348
char x[101][1001];
main(m,a,h,p,q){
  for(;scanf("%d%d%d",&m,&m,&a),a;printf("%d\n",a)){
    for(memset(x,0,sizeof(x));m;m--)
      scanf("%d%d%d",&h,&p,&q),x[p][h]=q,x[q][h]=p;
    for(h=1000;h;h--)a=x[a][h]?x[a][h]:a;
  }
  return 0;
}

Measured memory_bytes: 704
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
     dis=min(abs(i-j),abs(x-i)+1+abs(y-j))-1
     ans[dis]+=1
for i in ans:
    print(i)


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

using namespace std;

const int MX = 100;
const long double pi = acos(-1), R = 1e15;

int x[MX], y[MX];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d %d", x + i, y + i);
	
	for (int i = 0; i < n; i++) {
		vector<pair<long double, int>> events;
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			
			long double xc = (x[i] + x[j]) / 2.0;
			long double yc = (y[i] + y[j]) / 2.0;
			
			long double vx = y[j] - y[i];
			long double vy = x[i] - x[j];
			
			long double a = vx * vx + vy * vy;
			long double b = 2 * (xc * vx + yc * vy);
			long double c = xc * xc + yc * yc - R * R;
			
			long double D = b * b - 4 * a * c;
			long double t1 = (-b - sqrt(D)) / (2 * a);
			long double t2 = (-b + sqrt(D)) / (2 * a);
			
			long double x1 = xc + t1 * vx, y1 = yc + t1 * vy;
			long double x2 = xc + t2 * vx, y2 = yc + t2 * vy;
			
			long double alpha = atan2(y1 / R, x1 / R);
			long double beta =  atan2(y2 / R, x2 / R);
			
			if (alpha < 0) alpha += 2 * pi;
			if (beta < 0) beta += 2 * pi;
			
			// swap(alpha, beta); ????
			
			events.emplace_back(alpha, +1);
			events.emplace_back(beta, -1);
			if (alpha > beta) {
				events.emplace_back(0, +1);
				events.emplace_back(2 * pi, -1);
			}
		}
		
		sort(events.begin(), events.end());
		
		int s = 0;
		long double last = 0, sum = 0;
		for (auto& e : events) {
			if (s == n - 1) sum += e.first - last;
			s += e.second;
			last = e.first;
		}
		
		printf("%.15Lf\n", sum / (2 * pi));
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    int p=min(a,b),q;
    if((a+b)<n){
        q=0;
    }else{
        q=(a+b)-n;
    }
    cout<<p<<" "<<q<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

# 再帰で実装する
# 正か負かで分岐

def calc_4geo_series(k)
  return (4**(k + 1) - 1) / 3
end

# 配列を返す s[i]
def calc_expr(n)
  if n == 0
    return [0]
  end

  if n > 0
    k = 0
    loop do
      if n <= calc_4geo_series(k)
        break
      end
      k += 1
    end

    s = calc_expr(n - 4**k)
    s.fill(0, (s.length)..(2 * k - 1))
    s[2 * k] = 1
  else
    k = 0
    loop do
      if -n <= 2 * calc_4geo_series(k)
        break
      end
      k += 1
    end

    s = calc_expr(n + 2**(2 * k + 1))
    s.fill(0, (s.length)..(2 * k))
    s[2 * k + 1] = 1
  end

  return s
end

puts calc_expr(n).join.reverse


Measured memory_bytes: 1788
import numpy as np
H,W,K=map(int, input().split())

C=[]
for h in range(H):
    c=list(input())
    C.append(c)
#print(C)
ans=0
for i in range(2**H):
    for j in range(2**W):
        now=np.array(C.copy())
        for h in range(H):
            if i>>h&1==1:
                now[h,:]="."
        for w in range(W):
            if j>>w&1==1:
                now[:,w]="."
        sub=(now=="#").sum()
        #print(sub, now)
        if sub==K:
            ans+=1

print(ans)

Measured memory_bytes: 27088
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,m;
  cin>>n>>m;
  constexpr int INF = 1'000'000'000;
  vector<vecint> mat(n,vecint(n, INF));
  for (int i:irange(0,m)) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    mat[a][b] = 1;
  }
  for(int k:irange(0,n))
    for(int i:irange(0,n))
      for(int j:irange(0,n))
        mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
  int mn = INF;
  int mni = 0;
  for (int i:irange(0,n)) {
    if (mat[i][i] < mn) {
      mn = mat[i][i];
      mni = i;
    }
  }
  if (mn >= INF) {
    cout<<-1<<endl;
    return 0;
  }
  int j=0;
  for (int k:irange(0,n)) {
    if (mat[mni][k] == 1 && mat[mni][k] + mat[k][mni] == mat[mni][mni]) {
      j = k;
    }
  }
  vecint v(1, mni);
  v.push_back(j);
  while (mat[j][mni] > 1) {
    int nj = 0;
    for (int k:irange(0,n)) {
      if (mat[j][k] == 1 && mat[j][k] + mat[k][mni] == mat[j][mni]) {
        nj = k;
      }
    }
    j = nj;
    v.push_back(j);
  }
  cout<<v.size()<<endl;
  for(auto& node:v) {
    cout<<node+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 4224
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        var N = long.Parse(Console.ReadLine());
        //var inf = new long[N+1][];
        var inf = new Dictionary<long,long>[N+1];
        
        for(int i = 1; i <= N ;i++){
          inf[i] = new Dictionary<long,long>();
          var K = long.Parse(Console.ReadLine());
          for(int j = 1; j <= K ;j++){
            var XY = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            inf[i].Add(XY[0],XY[1]);
          }
        }
        
        var ans = 0;
        
        for(int i = 0; i < (int)Math.Pow(2,N);i++){
          
          var flag = true;
          var count = 0;
          for(int j = 0; j< N;j++){
            //j+1人目が正直者かどうか
            if(((int)Math.Pow(2,j) & i) != 0){
             // Console.WriteLine("j:"+j+" i:"+i);
              count++;
              //証言が矛盾していないか
              foreach(KeyValuePair<long,long> item in inf[j+1]){
                if(i == 1){
                 // Console.WriteLine("Key:"+item.Key+" Value:"+item.Value);
                }
                if( (item.Value == 1) && (((int)Math.Pow(2,item.Key-1) & i) !=0)){
                }else if( (item.Value == 0) && (((int)Math.Pow(2,item.Key-1) & i) ==0)){
                  
                }else{
                  flag = false;
                  break;
                }
              }
            }
            if(!flag){
              break;
            }
          }
          if(flag && count > ans){
            ans = count;
          }
        }
        
        Console.WriteLine(ans);
        
    }
}


Measured memory_bytes: 13408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s;
	cin >> s;
	int hour, minute, second;
	hour = s / 3600;
	s -= (hour * 3600);
	minute = s / 60;
	s -= (minute * 60);
	second = s;
	cout << hour << ":" << minute << ":" << second << endl;
	return 0;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var N = input[0];
            var K = input[1];
            var Q = input[2];

            var array = new int[N];
            foreach (var A in Enumerable.Range(0, Q).Select(_ => int.Parse(Console.ReadLine())))
            {
                array[A - 1] += 1;
            }

            foreach (var a in array)
            {
                Console.WriteLine(a > Q - K ? "Yes" : "No");
            }
        }
    }
}


Measured memory_bytes: 15840
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<min(c,b/a)<<endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>

using namespace std;

int a[200000];
long long sum[200001];

int main() {
    int n, x, i, j;
    long long ans = 1e18;
    
    scanf("%d %d", &n, &x);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
    
    for (i = 1; i <= n; i++) {
        int c = n;
        long long t = (long long)(n + i) * x;
        
        for (j = 1; c > 0; j++) {
            int nc = max(c - i, 0);
            
            if (c == n) {
                t += (sum[c] - sum[nc]) * 5;
            } else {
                t += (sum[c] - sum[nc]) * (j * 2 + 1);
            }
            
            c = nc;
            
            if (t > ans) break;
        }
        
        ans = min(ans, t);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  
  int now = 0, cnt = 0;
  for(int i = 0; i < N; i++){
    if(A[i] != now){
      now = A[i];
    }else {
      cnt++;
    }
  }
  // cout << "cnt: " << cnt << endl;
  if(cnt % 2 == 0)cout << N - cnt << endl;
  else cout << N - (cnt + 1) << endl;

  // for(auto i : A)cout << i << " ";
  // cout << endl;
}


Measured memory_bytes: 640
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


COST = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6
}


# inputs
N, M = 0, 0
A = [0]


def hoge():
    d = dict()
    def labeler(label, iter):
        enumerate()


def set_inputs():
    global N, M, A
    N, M = get_int_list()
    A = get_int_list()


@lru_cache(maxsize=None)
def dp(i):
    if i < 0:
        return -inf
    elif i == 0:
        return 0
    return max(dp(i - COST[a]) + 1 for a in A)


def main():
    setrecursionlimit(100000)
    set_inputs()

    candidates = sorted(A, reverse=True)
    ret = []
    n = N
    for i in range(dp(N)):
        for a in candidates:
            cond = True
            if i == dp(N) - 1:
                cond = COST[a] == n
            if dp(n - COST[a]) == dp(n) - 1 and cond:
                ret.append(a)
                n -= COST[a]
                break
    print(''.join(str(r) for r in ret))


if __name__ == '__main__':
    main()


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

int main(void){
 
  int A,B,C;
 
  scanf("%d %d %d\n",&A,&B,&C);
  
  if((A==B&&A!=C)||(B==C&&B!=A)||(C==A&&C!=B)){
  	printf("Yes\n");
  }else{
  	printf("No\n");
  }
  
  return 0;
  
}

Measured memory_bytes: 128
'use strict'
const Main=input=>{
    input=input.split("\n");
    for(let i=0;i<input.length;i++){
        input[i]=input[i].split(" ");
    }
    
    let answer=-1;
    for(let i=0;i<1000;i++){
        const si=""+i;
        if(si.length!=input[0][0])continue;
        let flag=true;
        for(let j=0;j<input[0][1];j++){
            if(si[input[j+1][0]-1]!=input[j+1][1])flag=false;
        }
        if(flag){
            answer=si;
            break;
        }
    }
    
    console.log(answer);
}

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

Measured memory_bytes: 21448