akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

class mint{
public:
  ll x;
  mint(ll x=0) : x(x%mod){}
  mint& operator+=(const mint rhs){
    x += rhs.x;
    while(x >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint rhs){
    x -= rhs.x;
    while(x < 0) x += mod;
    return *this;
  }
  mint & operator*=(const mint rhs){
    (x *= rhs.x) %= mod;
    return *this;
  }
  mint operator+(const mint rhs) const {
    mint res(*this);
    return res += rhs;
  }
  mint operator-(const mint rhs) const {
    mint res(*this);
    return res -= rhs;
  }
  mint operator*(const mint rhs) const {
    mint res(*this);
    return res *= rhs;
  }
  friend ostream& operator<<(ostream& os,const mint rhs){
    os << rhs.x;
    return os;
  }
};

#define rep(index,num) for(int index=0;index<num;++index)
int N;
typedef struct{
  int A;
  int B;
} Work;
Work w[200000];
int main(){
  std::cin >> N;
  ll sum = 0;
  rep(i,N){
    cin >> w[i].A >> w[i].B;
    sum += w[i].A;
  }
  sort(w,w+N,[](Work a,Work b){return a.B < b.B;});
  if(w[N-1].B < sum){
    cout << "No" << endl;
    return 0;
  }
  sum = 0;
  bool ans = true;
  rep(i,N){
    sum += w[i].A;
    if(sum > w[i].B){
      ans = false;
      break;
    }
  }
  if(ans) cout << "Yes"<< endl;
  else    cout << "No" << endl;
  return 0;
}


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

int main(){
    string s,t;
    cin>>s>>t;
    t.erase(t.size()-1);
    if(s==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3600
import sys
import math
N=int(input())
P=list(map(int,input().split()))
temp=[0]*N
cp=[i for i in range(1,N+1)]
Q=list(map(int,input().split()))
for i in range(N):
    temp[i]=cp.index(P[i])
    cp.remove(P[i])

rank=0
for i in range(N):
    rank+=temp[i]*math.factorial(N-i-1)
Pr=rank
cp=[i for i in range(1,N+1)]
for i in range(N):
    temp[i]=cp.index(Q[i])
    cp.remove(Q[i])
rank=0
for i in range(N):
    rank+=temp[i]*math.factorial(N-i-1)
Qr=rank
print(abs(Pr-Qr))

Measured memory_bytes: 3064
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i=0;i<N;i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		list.add(X);
		Collections.sort(list);

		int[] diff = new int[N];
		for (int i=0;i<N;i++) {
			diff[i] = list.get(i+1)-list.get(i);
		}
		Arrays.sort(diff);
		int min = diff[0];
		ArrayList<Integer> divisor_min = divisor(min);
		Collections.sort(divisor_min, Collections.reverseOrder());
		for (Integer element : divisor_min) {
			int flag = 0;
			for (int element_diff : diff) {
				if (element_diff%element!=0) {
					flag = 1;
					break;
				}
			}
			if (flag==0) {
				System.out.println(element);
				break;
			}
		}
	}

	static ArrayList<Integer> divisor(int n) {
	    ArrayList<Integer> list = new ArrayList<Integer>();
	    for (int i=1;i<=Math.sqrt(n);i++) {
	        if (n%i==0) {
	            list.add(i);
	            if (i*i!=n) {
	                list.add(n/i);
	            }
	        }
	    }
	    Collections.sort(list);
	    return list;
	}
}

Measured memory_bytes: 46792
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0335?year=2016

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;

    cout << n * 32 << endl;
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    long long dpi[n+1];
    long long dpn[n+1];
    if(n != 2){
        dpi[0] = 0;
        dpi[1] = abs(a[1]);
        for(int i = 2; i <= n; i++){
            dpi[i] = dpi[i-1] + abs(a[i-1] - a[i]);
        }
        dpn[n] = abs(a[n]);
        for(int i = n-1; i >= 0; i--){
            dpn[i] = dpn[i+1] + abs(a[i] - a[i+1]);
        }
        cout << abs(a[2]) + dpn[2] << endl;
        for(int i = 2; i <= n-1; i++){
            cout << dpi[i-1] + abs(a[i-1] - a[i+1]) + dpn[i+1] << endl;
        }
        cout << dpi[n-1] + abs(a[n-1]) << endl;
    } else {
        cout << 2*abs(a[2]) << endl;
        cout << 2*abs(a[1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
bool dp[5001][5001];
int tar = 0;
int N, K;
int a[5001];
void solve(int depth, int cost){
	if(depth == N + 1)return;
	if(dp[depth][cost])return;

	dp[depth][cost] = true;
	solve(depth+1, cost);
	if((cost+a[depth] < K) && (tar != depth)){
		solve(depth+1, cost+a[depth]);
	}
}

int main(void){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	//dp[j枚目まで][総和をxにできるか]
	sort(a, a+N);
	int r = N;
	int l = -1;
	while(r - l > 1){
		tar = (r+l) / 2;
		if(a[tar]>=K){
			r=tar;continue;
		}
		fill_n(*dp, 5001*5001, false);
		// solve(0, 0);
		bool flag = false;
		dp[0][0] = true;
		rep(i,N)rep(j,K+1){
			if(tar == i){
				dp[i+1][j] = dp[i][j];
			}else{
				dp[i+1][j] = dp[i][j];
				if(j-a[i] >= 0){
					dp[i+1][j] = (dp[i][j-a[i]]||dp[i][j]);
				}
			}
		}
		// cout << tar << ", " << a[tar] << endl;
		// rep(i,K){
		// 	cout << dp[N][i] << " ";
		// }cout << endl;
		REP(i,K-a[tar], K){
			flag |= dp[N][i];
		}//cout << (flag?"YES":"NO")<<endl;
		if(!flag){
			l = tar;
		}else{
			r = tar;
		}
	}
	cout << l+1 << endl;
}
/*
20
19 10 9 1
*/


Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  deque<char> d;
  int n;
  cin>>n;
  int cnt=0;
  string s;
  cin>>s;
  rep(i,n){
    d.push_back(s[i]);
    if(s[i]=='(') cnt++;
    else cnt--;
    if(cnt==-1){
      d.push_front('(');
      cnt++;
    }
  }
  while(cnt){
    cnt--;
    d.push_back(')');
  }
  rep(i,d.size() ){
    cout<<d[i];
  }
  cout<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int k[m];
  vector<vector<int>> a(m);
  for(int i=0;i<m;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      int l;
      cin>>l;
      a[i].push_back(l);
    }
  }
  int p[m],ans=0;
  for(int i=0;i<m;i++) cin>>p[i];

  for(int bit=0;bit<(1<<n);bit++){
    int light=0;
    for(int i=0;i<m;i++){
      int cnt=0;
      for(int j=0;j<k[i];j++){
        if(bit&(1<<a[i][j]-1)) cnt++;
      }
      if(p[i]==0&&cnt%2==0) light++;
      if(p[i]==1&&cnt%2==1) light++;
    }
    if(light==m) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	ll ans = 0 ;
	//solve
	for(int i = 0 ; i * r <= n ; i++){//iは、rの箱の数
		for(int j = 0 ; i * r + j * g <= n; j ++){
			int lastB = n - (i * r) - (j * g);
			if(lastB % b == 0 || lastB == 0){
				ans ++ ;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
		return a<x.a;
	}
};
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const ll p=1000000007ll,inf=1000000000000000000ll;
const int N=200005;

int main(){
	int n;
	scanf("%d",&n);
	printf("%lld",( ((ll)n) * (n-1) )>>1);
	return 0;
}

Measured memory_bytes: 256
#!python3.4.3

n = int(input())
s_list = []
s_dict = {}
for _ in range(n):
    s = input()
    s_list.append(s)
    if s in s_dict.keys():
        s_dict[s] += 1
    else:
        s_dict[s] = 1

max_ = max(s_dict.values())
result = [key for key in s_dict if s_dict[key] == max_]
result = sorted(result)

for i in result:
    print(i)


    
    
    

Measured memory_bytes: 34564
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long


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

  ll a,b; cin >> a >> b;
  if (a > 12) cout << b << endl;
  else if (a<=12 && a>=6) cout << b/2 << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 764
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
long long n,a[10000],ans=1;
int main()
{
	cin>>n;
	for (long long i=0;i<n;i++) a[i]=i+1;
	for (long long i=2;i<=n;i++){
		long long x=0;
		for (long long j=0;j<n;j++) while (a[j]%i==0) a[j]/=i,x++;
		ans=(ans*(x+1))%1000000007;
	}
	cout<<ans<<endl;
	return 0;
} 

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

using namespace std;

const int limit = 100010;
vector<vector<int>> xy(limit);
vector<bool> visited(limit);

void dfs(int v){
    visited[v] = true;
    for (auto &e : xy[v]){
        if (! visited[e])
        {
            dfs(e);
        }
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        z = z%2;
        xy[x].push_back(y);
        xy[y].push_back(x);
    }
    int ans;
    ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            ans++;
            dfs(i);
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 11872
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
   int a, b, c; cin >> a >> b >> c;
   if(a%b==0){
       if(c==0)cout << "YES" << ln;
       else cout << "NO" << ln;
   }else{
       int gcd = __gcd(a, b);
       if(c%gcd==0)cout << "YES" << ln;
       else cout << "NO" << ln;
   }
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()
def n():
    return int(input())

S = s()
K = n()

n=0
for s in S:
    n += 1
    if s != '1':
        s_first = s
        break

if n <= K:
    print(s)
else:
    print(1)


Measured memory_bytes: 5672
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics.Contracts;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var XY = ReadInts();
            var X = XY[0];
            var Y = XY[1];
            var ans = "No";
            if (Y % 2 == 0)
            {
                if (X * 2 <= Y && Y <= X * 4)
                {
                    ans = "Yes";
                }
            }
            WriteLine(ans);
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27480
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    lint x[3100][3100];
    lint dp[3100][3100][4];
  int main(){
    lint r,c,k;
    cin>>r>>c>>k;
    rep(i,k){
        lint a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        x[a][b]=c;
    }
    rep(i,3100){
        rep(j,3100){
            rep(k,4){
                if(k==0)dp[i][j][k]=0;
                else dp[i][j][k]=-INF;
            }
        }
    }
    rep(i,r){
        rep(j,c){
            if(x[i][j]!=0){
              rep(k,3){
                  dp[i][j][3-k]=max(dp[i][j][3-k],dp[i][j][2-k]+x[i][j]);
              }
              rep(k,4){
                    dp[i][j+1][k]=max(dp[i][j+1][k], dp[i][j][k]);
              }
              if(i!=(r-1))dp[i+1][j][0]=max({dp[i][j][0],dp[i][j][1],dp[i][j][2],dp[i][j][3]});
            }else{
                rep(k,4){
                    dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
                    dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
                }
            }
        }
    }
    lint ans=max({dp[r-1][c-1][0],dp[r-1][c-1][1],dp[r-1][c-1][2],dp[r-1][c-1][3]});
    cout<<ans<<endl;
    }
      
    
  

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

#define MAX_N 1e6

lli n, s;
vector<lli> ary;
vector<lli> b(MAX_N);

int main(void){
    cin >> n;
    rep(i, n){
        lli a;
        cin >> a;
        ary.push_back(a);
        b[a]++;
    }
    s = 0;
    rep(i, b.size()){
        s += (b[i]*(b[i]-1))/2;
    }

    rep(i, n){
        cout << s-(b[ary[i]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 12528
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  double table[51];
  table[0] = 1;
  double hoge = 0.5;
  REP(i,50) {
    table[i+1] = table[i] * hoge;
    hoge *= 0.5;
  }
  int N = 100001;
  vector<double> dp(N);
  vector<double> ans(N);
  REP(i,N-1) {
    dp[i+1] += 1.0-dp[i];
    for (int j=1; j<=50&&i+j+1<N; ++j)  {
      dp[i+1+j] += (1.0-dp[i]) * table[j];
//      printf("%d,%d dp[i+j] = %f\n",i,j,dp[i+1+j]);
    }
    ans[i+1] = ans[i] + dp[i+1];
    // cout << i+1 << " " << dp[i+1] << endl;
    // cout << i+1 << " " << ans[i+1] << endl;
  }
  int n;
  while(cin>>n,n)
    printf("%.5f\n",ans[n]);
}

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

#define MAX 100000

int Parent(int i) {
    return i / 2;
}
int Left(int i) {
    return 2 * i;
}
int Right(int i) {
    return 2*i + 1;
}

int main() {
    int h, A[MAX+1];
    cin >> h;
    for ( int i = 1; i <= h; i++ ) cin >> A[i];
    
    for ( int i = 1; i <= h; i++ ) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if ( Parent(i) >= 1 ) {
            cout << "parent key = " << A[Parent(i)] << ", ";
        }
        if ( Left(i) <= h ) {
            cout << "left key = " << A[Left(i)] << ", ";
        }
        if ( Right(i) <= h ) {
            cout << "right key = " << A[Right(i)] << ", ";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3076
def resolve():
    n, k = map(int, input().split())
    hp = list(map(int, input().split()))
    hp.sort()
    if n > k:
        for i in range(k):
            hp.pop()
    else:
        for i in range(n):
            hp.pop()
    print(sum(hp))




if __name__ == "__main__":
    resolve()

Measured memory_bytes: 26180
N, M, C = gets.chomp.split(' ').map(&:to_i)

BS = gets.chomp.split(' ').map(&:to_i)


@res = 0
(1..N).each do |n|
  as = gets.chomp.split(' ').map(&:to_i)
  sum = C
  as.map.each_with_index do |a, i|
    sum = sum + a*BS[i]
  end
  if sum > 0
    @res += 1
  end
end

puts @res


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int d ,t, s,f,r;
  cin>>d>>t>>s;
  r=d%s;
  if(r==0)
  {
  
  f=d/s;
  if(f<=t)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  }
  else
  {
  
  f=d/s;
  f++;
  if(f<=t)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  }
  
  return 0;
  
  
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;cin >> a >> b;
	if(a<=1){
		if(b%4==1) b=1;
		else if(b%4==2) b++;
		else if(b%4==3) b=0;
		cout << b << endl;
	}
	else{
		if(b%4==1) b=1;
		else if(b%4==2) b++;
		else if(b%4==3) b=0;
		a--;
		if(a%4==1) a=1;
		else if(a%4==2) a++;
		else if(a%4==3) a=0;
		cout << (a^b) << endl;
	}
}


Measured memory_bytes: 256
//16
#include<iostream>
#include<queue>

using namespace std;

struct S{
  int c,p,s;
  double t;
  bool operator<(S a)const{
    return t>a.t;
  }
};

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    int s,g;
    cin>>s>>g;
    int d[31][31]={{}};
    int cs[31][31]={{}};
    while(m--){
      int x,y,di,ci;
      cin>>x>>y>>di>>ci;
      d[x][y]=d[y][x]=di;
      cs[x][y]=cs[y][x]=ci;
    }
    bool p[31][31][31]={{{}}};
    priority_queue<S> que;
    S is={s,-1,0,0};
    que.push(is);
    while(!que.empty()){
      S c=que.top();
      if(c.c==g&&c.s==1)break;
      que.pop();
      if(p[c.c][c.p][c.s]++)continue;
      for(int i=1;i<=n;i++){
	if(d[c.c][i]&&i!=c.p){
	  for(int a=-1;a<=1;a++){
	    S n;
	    n.c=i;
	    n.p=c.c;
	    n.s=c.s+a;
	    if(n.s>0&&n.s<=cs[c.c][i]){
	      n.t=c.t+d[c.c][i]*1./n.s;
	      que.push(n);
	    }
	  }
	}
      }
    }
    if(que.empty()){
      cout<<"unreachable"<<endl;
    }else{
      cout<<fixed<<que.top().t<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 20840
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n, p;
	cin>>n>>p;
	int o = 0;
	rep(i, n){
		int t;
		cin>>t;
		if(t%2) o = 1;
	}
	if(p==0){
		cout<<(o?1LL<<(n-1):1LL<<n)<<endl;
	} else {
		cout<<(o?1LL<<(n-1):0)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main (void) {
    string S;

    cin >> S;

    if (S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    int alphabet[26] = {0};
    for (int i = 0, len = S.length(); i < len; i++) {
        alphabet[S[i] - 'a']++;
    }

    if (S.length() != 26) {
        cout << S;
        for (int i = 0; i < 26; i++) {
            if (alphabet[i] == 0) {
                char c = i + 'a';
                cout << c << endl;
                return 0;
            }
        }
    } else {
        string s = S;
        next_permutation(s.begin(), s.end());
        for (int i = 0, len = S.length(); i < len; i++) {
            cout << s[i];
            if (s[i] != S[i]) {
                cout << endl;
                return 0;
            }
        }
    }
}


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

int main() {
	char s[101], t[101], i, len, flg;
	if (scanf("%s%s", s, t) == 0) return 1;
	len = strlen(s);

	int add(int a, int b) {
		int c = a + b;
		return (c >= len) ? c - len : c;
	}

	int cmp() {
		int j;
		for (j = 0; j < len; j++) if (s[add(i, j)] != t[j]) return 0;
		return 1;
	}

	flg = 0;
	for (i = 0; i < len; i++) {
		if (cmp()) {
			flg = 1;
			break;
		}
	}
	printf(flg ? "Yes" : "No");
	return 0;
}


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

int main(){
	
	int a,h;
	int c ,m=0;
	//cout<<"Enter the health of Monster: ";
	cin>>a;
	//cout<<"Enter the Value: ";
	cin>>h;
	
	while(1){
		c = a - h;
		if(c > 0){
		m++;
		}
		else
		break;
		a = c;
	}
	cout<<m+1;
return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n'

using namespace std;

long long a, b, c;
 
int main(){
    cin >> a >> b >> c;

    if((a+b) == c){
        cout << b+c;
    } else if((a+b) < c){
        cout << (a+b) + b + 1;
    } else if((a+b) > c){
        cout << b+c;
    }
 
 
 
 
}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#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(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int d[1010];
int l[1010];
int n,x;

signed main() {
  INIT;
  cin>>n>>x;
  REP(i,n){
    cin>>l[i];
  }

  int i=0;
  while (i<=n && d[i]<=x){
    d[i+1] = d[i] + l[i];
    ++i;
  }

  cout<<min(n+1,i)<<endl;

  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a,b,m;
  cin>>a>>b;
  m=a+b;
  if(a-b>m){
    m=a-b;
  }
  if(a*b>m){
    m=a*b;
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    
    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        

        // ----- 変数 ----- //
        String str;
        boolean flag = false; // デバッグ用。提出時はfalse。
        boolean first = true;
        int n = 0;
        int total = 0;
        int[] dice = new int[6];
        
        try {
            while(flag || reader.ready()){

                // ----- データ処理 ----- //
                // 文字列の取得
                str = reader.readLine();

                // 初回のみ別処理
                if(first) {
                    first = false;
                    // 移動回数取得
                    n = Integer.parseInt(str);
                    // 合計値の初期化
                    total = 1;
                    // サイコロ初期配置
                    dice = new int[] {1, 6, 5, 3, 2, 4};

                    if (n == 0) {break;}
                    else {continue;}
                } 

                // サイコロの移動処理
                switch(str) {
                    case "North" : North(dice); break;
                    case "South" : North(dice); North(dice); North(dice); break;
                    case "East"  : East(dice); break;
                    case "West"  : East(dice); East(dice); East(dice); break;
                    case "Right" : Right(dice); break;
                    case "Left"  : Right(dice); Right(dice); Right(dice); break;
                }

                total += dice[0];

                
                if(--n == 0) {
                    System.out.println(total);
                    first = true;
                }
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    // ----- 自作関数 ----- //

    //上  下  北  東  南  西
    //---------------------
    //０  １　２　３   ４　５
    //０  ５  ４  ２  １  ３
    // dice = new int[] {1, 6, 5, 3, 2, 4};

    private static void North(int[] dice){
        int temp = dice[0];
        dice[0] = dice[4];
        dice[4] = dice[1];
        dice[1] = dice[2];
        dice[2] = temp;
    }

    private static void East(int[] dice){
        int temp = dice[0];
        dice[0] = dice[5];
        dice[5] = dice[1];
        dice[1] = dice[3];
        dice[3] = temp;
    }

    private static void Right(int[] dice){
        int temp = dice[2];
        dice[2] = dice[5];
        dice[5] = dice[4];
        dice[4] = dice[3];
        dice[3] = temp;
    }
}


Measured memory_bytes: 25540
use std::io;


/// https://beta.atcoder.jp/contests/abc085/tasks/abc085_b
fn main() {
    let n = read_one::<usize>();
    let mut dn = Vec::new();
    for _ in 0..n {
        dn.push(read_one::<usize>());
    }
    dn.sort();
    dn.dedup();
    println!("{}", dn.len());
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
  int num;
  cin >> num;

  for(int i=1; i<=num; i++){
    if(i%3==0) cout << " " << i;
    else{
      int x = i;
      while(1){
        if(x==0) break;
        if(x%10==3){
          cout << " " << i;
          break;
        }else{
          x /= 10;
        }
      }
    }
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int n, an;
vector<int> vec;
map<int, int> cnt;
set<tuple<int, int, int>> s;

void check(vector<int> v1, vector<int> v2)
{
    for (int i = 0; i < (int) v1.size(); ++i) if (cnt[v1[i]] < v2[i])
        return;
    if (v1.size() == 3) {
        if (v1[1] > v1[2]) swap(v1[1], v1[2]);
        s.insert(make_tuple(v1[0], v1[1], v1[2]));
    } else {
        ++an;
    }
}

void calc()
{
    for (auto x: vec) {
        check({x}, {74});
        for (auto y: vec) if (x != y) {
            check({x, y}, {2, 24});
            check({x, y}, {4, 14});
            for (auto z: vec) if (x != z && y != z) {
                check({x, y, z}, {2, 4, 4});
            }
        }
    }
}

void factor(int n)
{
    for (int i = 2; i <= n; ++i) {
        int v = 0;
        while (n % i == 0) {
            ++v;
            n /= i;
        }
        if (v) cnt[i] += v;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        factor(i);
    }
    for (auto &kv: cnt) if (kv.second > 1) {
        vec.push_back(kv.first);
    }
    calc();
    cout << an + s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[300005];

ll ans;

int n;

void solve() {                   
	scanf("%d", &n);
	n *= 3;

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);
    }

    sort(arr + 1, arr + n + 1);

    for (int l = 1, r = n; l <= r; ++l) {
    	ans += arr[r - 1];
    	r -= 2;
    }

    printf("%lld\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1408
import numpy as np
from numba import njit

n = int(input())
a = list(map(int, input().split()))
MAX = 10 ** 6

nums = np.zeros(MAX + 1, np.int64)
for e in a:
    nums[e] += 1


@njit
def solve(nums):
    mx = 0
    for i in range(2, MAX + 1):
        cnt = nums[i::i].sum()
        mx = max(mx, cnt)

    return mx


mx = solve(nums)

if nums[1] == n:
    ans = "pairwise coprime"
elif mx == n:
    ans = "not coprime"
elif mx == 1:
    ans = "pairwise coprime"
else:
    ans = "setwise coprime"

print(ans)


Measured memory_bytes: 207160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;

long double L;

int32_t main()
{
    cin >> L;
    cout << fixed << setprecision(30) << pow(L/3.0, 3.0);
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

inline LL getLL()
{
	char ch;LL res;bool f;
	while (!isdigit(ch=getchar()) && ch!='-') {}
	if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
	while (isdigit(ch=getchar())) res=res*10+ch-'0';
	return res;
}

LL dp[100048][5];

struct node
{
	int sign;
	int num;
}a[100048];

int n;

int main ()
{
	int i,j;n=getint();string s;
	for (i=1;i<=n;i++)
	{
		if (i==1) {a[i].sign=1,a[i].num=getint();continue;}
		cin>>s;a[i].sign=(s[0]=='+'?1:-1);
		a[i].num=getint();
	}
	for (i=1;i<=n;i++)
		for (j=0;j<=4;j++)
			dp[i][j]=-LINF;
	dp[1][0]=a[1].num;
	for (i=2;i<=n;i++)
		for (j=0;j<=4;j++)
		{
			//no sign
			dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i].num*a[i].sign*(j%2?-1:1));
			//)
			if (j!=4) dp[i][j]=max(dp[i][j],dp[i-1][j+1]+a[i].num*a[i].sign*((j+1)%2?-1:1));
			//(
			if (j && a[i].sign==-1) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+a[i].num*(j%2?-1:1));
		}
	printf("%lld\n",dp[n][0]);
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,K;
  cin>>N>>K;
  VI D(K);
  VVI A(K);
  rep(i,K){
    cin>>D[i];
    int tmp;
    rep(j,D[i]){
      cin>>tmp;
      A[i].pb(tmp);
    }
  }
  VI ans(100);
  rep(i,K) rep(j,A[i].size()){
    ans[A[i][j]-1]++;
  }
  int ans2=0;
  rep(i,N) if(ans[i]==0) ans2++;
  cout<<ans2<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int a[110][2],memo[110][10010];

int func(int i,int w){
    if(i==0||w==0) return memo[i][w]=0;
    if(memo[i][w]!=-1) return memo[i][w];
    
    if(w>=a[i-1][1]) return memo[i][w]=max(a[i-1][0]+func(i-1,w-a[i-1][1]),func(i-1,w));
    else           return memo[i][w]=func(i-1,w);
}


int main(){
    int N,W;
    cin>>N>>W;
    for(int i=0;i<110;++i){
        cin>>a[i][0]>>a[i][1];
        for(int w=0;w<10010;++w)
            memo[i][w]=-1;
    }

    cout<<func(N,W)<<endl;
    return 0;
}


Measured memory_bytes: 7420
#include <iostream>
#define llint long long

using namespace std;

llint N, K;

int main(void)
{
	cin >> N >> K;
	
	llint ans = K;
	for(int i = 0; i < N-1; i++) ans *= K-1;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 200 * 1000 + 5;
long long n, a[MAX_N], dp[MAX_N][5];

void read_input() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
}

void solve() {
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= 3; j++) {
			int x = a[i] - 1 - j % 2;
			if (x < 0)
				x += a[i];
			else
				x = a[i] - x % 2;
			dp[i][j] = max(dp[i][j - 1], dp[i - 1][j] + x);	
		}
}

void print_output() {
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans = min(ans, -dp[i][3]);
	for (int i = 1; i <= n; i++)
		ans += a[i];
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 9600
def resolve():
    X, K, D = map(int, input().split())
    count = min(abs(X//D), K)
    if X > 0:
        X -= D*count
    else:
        X += D*count
    K -= count
    if K > 0:
        if K%2 == 0:
            print(abs(X))
        else:
            print(D-abs(X))
    else:
        print(abs(X))
resolve()

Measured memory_bytes: 9184
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int s;
	ll ans = 0;
	cin >> s;
	rep(i, 1, s) {
		int x = s - 3 * i;
		if (x < 0)break;
		ans += mc(x + i - 1, i - 1);
		ans %= mod;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	void merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion

int main()
{
	long long n, m; cin >> n >> m;
	vector<long long> res(m);
	vector<int> a(m), b(m);
	rep(i, 0, m - 1)
	{
		cin >> a[i] >> b[i];
		--a[i], --b[i];
	}

	UnionFind uf(n);

	long long cur = n * (n - 1) / 2;
	res[0] = cur;
	rep(i, 0, m - 2)
	{
		if (uf.issame(a[m - 1 - i], b[m - 1 - i]))
		{
			res[i + 1] = cur;
		}
		else
		{
			long long sa = uf.size(a[m - 1 - i]), sb = uf.size(b[m - 1 - i]);
			cur -= sa * sb;
			res[i + 1] = cur;
			uf.merge(a[m - 1 - i], b[m - 1 - i]);
		}
	}

	reverse(all(res));
	rep(i, 0, m - 1)cout << res[i] << endl;
}

Measured memory_bytes: 3328
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let mut graph = vec![Vec::new(); n];
    for i in 0..n {
        let line: Vec<bool> = read_line().trim().chars().map(|c| c == '1').collect();
        for j in 0..n {
            if line[j] {
                graph[i].push(j);
            }
        }
    }

    let mut ans = -1;
    for i in 0..n {
        let mut visited = vec![false; n];
        let mut prev = HashSet::new();
        let mut current = HashSet::new();
        let mut k = 0;
        current.insert(i);

        loop {
            if current.is_empty() {
                break;
            }
            let mut next = HashSet::new();
            let mut valid = true;
            for v in current.iter() {
                visited[*v] = true;
            }
            for v in current.iter() {
                for w in graph[*v].iter() {
                    if prev.contains(w) {
                        continue;
                    }
                    if visited[*w] {
                        valid = false;
                        break;
                    }
                    next.insert(*w);
                }
            }
            if valid {
                k += 1;
                prev = current.clone();
                current = next.clone();
            } else {
                k = -1;
                break;
            }
        }
        let valid = visited.iter().find(|b| !**b).is_none();
        if valid {
            ans = cmp::max(ans, k);
        }
    }
    println!("{}", ans);
}


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

namespace AtCoderB
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            for (int i=0; i<101; i++)
            {
                if (s == t)
                {
                    Console.WriteLine("Yes");
                    // Console.ReadKey();
                    return;
                }

                s = s.Substring(1, s.Length - 1) + s[0];
            }

            Console.WriteLine("No");
            // Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 21
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

ll a[MAX][MAX];
ll dp[MAX][(1<<21)];
ll f(ll index,ll n,bitset<32>& w){
	if(index==n) return 1;
	ll x = w.to_ullong();
	if(dp[index][x]!=-1) return dp[index][x];
	ll ans=0;
	For(j,0,n){
		if(a[index][j] && !w[j]){
			w[j]=1;
			ll temp = f(index+1,n,w);
			w[j]=0;
			ans = (ans+temp)%Mod;
		}
	}
	dp[index][x]=ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	ll n;cin>>n;
	For(i,0,n) For(j,0,n) cin>>a[i][j];
	bitset<32> w(0);
	cout<<f(0,n,w)<<endl;
}


Measured memory_bytes: 344320
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int A, B; std::cin >> A >> B;

  if ( A >= 13 ) std::cout << B << std::endl;
  else if ( A >= 6 ) std::cout << B/2 << std::endl;
  else std::cout << 0 << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if (x - r >= 0 && x+r <=  W && y - r >= 0 && y + r <= H)
    puts("Yes");
  else
    puts("No");
  return 0;
}
  

Measured memory_bytes: 584
import bisect
N,M=map(int,input().split())
A=[[0] for j in range(N)]
px=[]
for i in range(M):
    p,x=map(int,input().split())
    A[p-1].append(x)
    px.append([p,x])
for m in range(N):
    A[m].sort()
for k in range(M):
    q=bisect.bisect_left(A[px[k][0]-1],px[k][1])
    print("0"*(6-len(str(px[k][0])))+str(px[k][0])+"0"*(6-len(str(q)))+str(q))

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

using ll = long long;

const int MAXN = 2e5;
int N;
ll A, B;
ll X[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	ll ans = 0;
	for (int i = 0; i+1 < N; i++) {
		ans += min(B, A * (X[i+1] - X[i]));
	}
	cout << ans << '\n';

	return 0;
}


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

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(){
    int n, k; cin >> n >> k;
    if(n < 10) cout << k + 100 * (10 - n) << endl;
    else cout << k << endl;
}

Measured memory_bytes: 256