akhauriyash/Code-Regression huggingface dataset:
from itertools import accumulate as acc
N, x, *A = map(int, open(0).read().split())
dp = []
for i in range(N):
  dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))

ans = 10**60
for i,a in enumerate(zip(*dp)):
  ans = min(ans,i*x+sum(a))
print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	ll N,K;
	cin>>N>>K;
	printf("%lld\n",K*(ll)pow(max(1LL,K-1),N-1));
	return 0; 
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
//#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e10,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {    
       int a,b,c;
       cin>>a>>b>>c;
       if(b*c>=a)
       cout<<"Yes";
       else
       cout<<"No";
    }
}
// 🍪 🍪 🍪

Measured memory_bytes: 3636
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    char map[ 128 ][ 128 ];
    int w, h;
    int x, y;

    scanf ( " %d %d", &h, &w );
    if ( !( w | h ) ) break ;

    for ( y = 0; y < h; ++y )
    for ( x = 0; x < w; ++x )
    {
      scanf ( " %c", &map[ x ][ y ] );
    }

    for ( x = y = 0; ; )
    {
      const char t = map[ x ][ y ];
      map[ x ][ y ] = 'Z';
      switch ( t )
      {
        case '.':
          printf ( "%d %d\n", x, y );
          goto CONTT;
        case '>': ++x; break ;
        case '<': --x; break ;
        case 'v': ++y; break ;
        case '^': --y; break ;
        default:
          puts ( "LOOP" );
          goto CONTT;
      }
    }
CONTT: ;
  }

  return ( 0 );
}

Measured memory_bytes: 0
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ff first
#define ss second
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,R,L) for(auto i=R;i>L;i--)
#define all(x) (x).begin(),(x).end()
#define show(x) cout<<(#x)<<" = "<<(x)<<"\n";
#define show2(x,y) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<"\n";
#define show3(x,y,z) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<" & "<<(#z)<<" = "<<(z)<<"\n";
#define endln "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007
#define INT_MAX 2147483647

using namespace std;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif // ONLINE_JUDGE
    fastio;
    int n;
    cin>>n;
    vector<char> arr(n);
    F(i,0,n) cin>>arr[i];
    int w = 0,r = 0;
    F(i,0,n)
    {
        if(arr[i] == 'R') r++;
        else w++;
    }
    int wleft = 0;
    int rleft=0,rright = 0;
    F(i,0,r)
    {
        if(arr[i]=='W') wleft++;
        else rleft++;
    }
    rright = r-rleft;

    cout<<max(wleft,rright);

}


Measured memory_bytes: 3660
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var bStart = 0
    var aEnd = 0
    var both = 0
    var cnt = 0

    val regex = "(AB)".toRegex()

    repeat(n) {
        val s = readLine()!!
        cnt += regex.findAll(s).count()
        if (s[0] == 'B' && s[s.length-1] == 'A') {
            both++
        } else if (s[0] == 'B') {
            bStart++
        } else if (s[s.length-1] == 'A') {
            aEnd++
        }
    }

    if (both == 0) {
        cnt += Math.min(bStart, aEnd)
    } else {
        if (bStart + aEnd > 0) {
            cnt += Math.min(bStart, aEnd) + both
        } else {
            cnt += Math.max(both - 1, 0)
        }
    }

    println(cnt)
}

Measured memory_bytes: 39884
S = gets.chomp
T = gets.chomp
s = S.split('')
t = T.split('')
l = S.length
u = Array.new
for i in 0..l-1
    u[i] = Array.new
    
    for j in 0..i
        u[i][j] = s[l-i+j-1]
    end

    if i < l-1

        for k in 0..l-i-2
            u[i][k+i+1] = s[k]
        end

    end

end
r = 0
for i in 0..l-1
    if u[i] == t
        r += 1
    end
end

if r == 0
    puts 'No'
else
    puts 'Yes'
end

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class UnionFind {
public:
  UnionFind(ll n) {
    r.resize(n, 0);
    p.resize(n, -1);
  }
  void unite(ll a, ll b) {
    a = find(a);
    b = find(b);
    if (a == b) return ;
    if (r[a] > r[b]) {
      p[a] += p[b];
      p[b] = a;
    } else {
      p[b] += p[a];
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  ll find(ll a) {
    return (p[a] < 0) ? a : p[a] = find(p[a]);
  }
  bool same(ll a, ll b) {
    return find(a) == find(b);
  }
  size_t size(ll n) {
    return -p[find(n)];
  }
private:
  vector<ll> r, p;
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  vector<ll> ans(n);
  UnionFind g(n);
  for (ll i = 0; i < m; ++i) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g.unite(a, b);
    ans[a]--;
    ans[b]--;
  }

  for (ll i = 0; i < k; ++i) {
    ll c, d;
    cin >> c >> d;
    c--; d--;
    if (g.find(c) == g.find(d)) {
      ans[c]--;
      ans[d]--;
    }
  }

  for (ll i = 0; i < n; ++i) {
    cout << ans[i]+g.size(i)-1 << " ";
  }
  cout << endl;
  
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    memset(S, 0, sizeof(S));
    REP(i, M)
    {
        ll l, r;
        cin >> l >> r;
        S[l - 1]++;
        S[r]--;
    }
    REP(i, N)
    {
        S[i + 1] += S[i];
    }
    ll ans = 0;
    REP(i, N)
    {
        if (S[i] >= M)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		String[] s=sc.readStringL("");
		String[] t=sc.readStringL("");
		
		int[] cs=new int[123];
		int[] ct=new int[123];
		for(String c: s){
			cs[c.getBytes("US-ASCII")[0]]+=1;
		}
		for(String c: t){
			ct[c.getBytes("US-ASCII")[0]]+=1;
		}
		Arrays.sort(cs);
		Arrays.sort(ct);
		
		
		boolean slv=true;
		for(int i=0; i<cs.length; i++){
			if(cs[i]!=ct[i]){
				slv=false;
			}
		}
		
		System.out.println((slv==true)? "Yes": "No");
	}
	
	static void solve(int cur, int nx, int en, int hld){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		BufferedReader read=null;
		StringTokenizer tok=null;
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


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


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int b;
    long long wynik[87];
    wynik[0]=2;
    wynik[1]=1;
    cin >>b;
    for(int i=2;i<=b;i++){
        wynik[i]=wynik[i-1]+wynik[i-2];
    }
    cout << wynik[b];
    return 0;
}


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

int main(){
   string s;
   cin >> s;
   char a = s.at(0);
   int sum = 0;
   for(int i = 1;i<s.size();i++){
      if(s.at(i-1) == s.at(i)){
        if(a == '1'){
          s.at(i) = '0';
        }else{
          s.at(i) = '1';
        }
        sum += 1;
      }
      a = s.at(i);
   }
   cout << sum << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair <LL,LL> p;

const int RLEN=1<<18|1;
inline char nc() {
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
    char ch=nc(); int i=0,f=1;
    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
    return i*f;
}

const int N=2e5+50;
vector <p> edge[N];
vector <p> f[N];
vector <p> tl, tr;
LL lim;
inline void inc(int x,const p &t) {
    if(f[x].size() && f[x].back()<=t) return;
    while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
    f[x].push_back(t);
}
inline bool dfs(int x,int fa) {
    f[x].clear();
    if(edge[x].size()==1) {f[x].push_back(p(0,0)); return true;} 
    LL lc,rc,disl,disr; int fir=0;
    for(int e=edge[x].size()-1;e>=0;e--) {
        int v=edge[x][e].first; if(v==fa) continue;
        if(!dfs(v,x)) return false;
        if(!fir) fir=1, lc=v, disl=edge[x][e].second;
        else rc=v, disr=edge[x][e].second;
    }
    tl.clear(), tr.clear(); LL lim2=lim-disl-disr;
    if(lim2<0) return false; 
    for(int p1=0,p2=0;p2<f[rc].size();p2++) {
        while(p1<f[lc].size() && f[lc][p1].first+f[rc][p2].second>lim2) ++p1;
        if(p1==f[lc].size()) break;
        tl.push_back(p(f[rc][p2].first+disr,f[lc][p1].second+disl));
    }
    for(int p1=0,p2=0;p1<f[lc].size();p1++) {
        while(p2<f[rc].size() && f[lc][p1].second+f[rc][p2].first>lim2) ++p2;
        if(p2==f[rc].size()) break;
        tr.push_back(p(f[lc][p1].first+disl,f[rc][p2].second+disr));
    }
    int pl=0, pr=0;
    while(pl<tl.size() && pr<tr.size()) {
        if(tl[pl].first>tr[pr].first) inc(x,tl[pl++]);
        else inc(x,tr[pr++]);
    }
    while(pl<tl.size()) inc(x,tl[pl++]);
    while(pr<tr.size()) inc(x,tr[pr++]);
    return f[x].size()>0;
}
inline bool check(LL v) { lim=v; return dfs(1,0);}
int main() {
    int n=rd();
    for(int i=2;i<=n;i++) {
        int x=rd(), w=rd();
        edge[x].push_back(p(i,w));
        edge[i].push_back(p(x,w));
    }
    LL l=0, r=1e12, ans=0;
    while(l<=r) {
        LL mid=(l+r)>>1;
        if(check(mid)) ans=mid, r=mid-1;
        else l=mid+1;
    } cout<<ans;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    if(N >= M){
        cout << 0 << endl;
        return 0;
    }
    vector<int> X(M);
    for(int i;i<M;i++){
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    vector<int> Y(M-1);
    for(int i=0;i<M-1;i++){
        Y[i] = X[i+1] - X[i];
    }
    sort(Y.begin(),Y.end());
    long long XX = X[X.size()-1] - X[0], sumY=0;
    for(int i=0;i<N-1;i++){
        sumY += Y[Y.size()-1-i];
    }
    cout << XX - sumY << endl;
}

Measured memory_bytes: 1024
def LI():return list(map(int,input().split()))
def yes():return print("Yes")
def no():return print("No")
from collections import deque, defaultdict, Counter
# from heapq import heappop, heappush
# import math
# from decimal import Decimal

# def divisors(x):
#     ret=[]
#     for i in range(1,int(x**.5)+1):
#         if x%i==0:
#             ret.append(i)
#             if x//i==i:continue
#             ret.append(x//i)
#     return sorted(ret)

# print(divisors(64),2**6)            

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

n=int(input())
pf=prime_factor(n)
pf=Counter(pf)
# print(pf)

def cng(x):
    le=2*x
    ret=-1
    mi=int(le**0.5)
    for i in range(mi-1,mi+10000):
        # print((i+1)*(i+2),le,i*(i+1))
        if (i+1)*(i+2)>le>=i*(i+1):
            ret=i
            # print((i+1)*(i+2),le,i*(i+1))
            break
        
    return ret

mp=[]   
for i in range(2*10**5):
    mp.append(cng(i))
# print(-1 in mp)

ans=0
for i in pf.values():
    ans+=mp[i]
    
print(ans)




Measured memory_bytes: 76720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Scanner parameter = new Scanner(System.in);

        String[] input1 = parameter.nextLine().split(" ");

        Integer limit = Integer.valueOf(input1[0]);

        Integer water1 = Integer.valueOf(input1[1]);

        Integer water2 = Integer.valueOf(input1[2]);

        System.out.println(water1 + water2 < limit ? 0 : water2 + water1 -limit);
    }
}


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

map<string, int> mapa;
set<string> mySet;

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

    int n;
    cin >> n;
    int maxi = 0;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mapa[s]++;
        maxi = max(maxi, mapa[s]);
        mySet.insert(s);
    }

    for(set<string>::iterator it = mySet.begin(); it != mySet.end(); it++)
        if(mapa[*it] == maxi) cout << *it << "\n";

    return 0;
}


Measured memory_bytes: 33280
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INF = 2147483647;
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP(i, 1, n+1)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

template<class T>
void printv(vector<T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}

ll N,M,Q;
vector<ll> a(51),b(51),c(51),d(51);
ll res = 0;

void rec(int depth, vector<ll> &v){
    if(depth == N+1){
        //計算する
        ll score = 0;
        rep2(i,Q){
            if (v[b[i]] - v[a[i]] == c[i]) score += d[i]; 
        }
        res = max(res, score);
        //printv(v);
        return;
    }
    // 次の要素の決定
    REP(i, v[depth-1], M+1){
        v.emplace_back(i);
        rec(depth+1, v);
        v.pop_back();
    }
}

int main() {
    cin>>N>>M>>Q;
    rep2(i,Q){ 
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    // idx:0の1はA_iには含まれないことに注意！！
    // dfsのための番兵的な使い方をしている
    vector<ll> v = {1};
    rec(1, v);
    cout << res;
    //printv(a);
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;

const int inf = 1e18;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    clock_t start = clock();

    int n,w; cin>>n>>w;
    vi weight(n+1), value(n+1);
    for(int i=1;i<=n;i++) cin >> weight[i] >> value[i];

    vector<vi> dp(n+1,vi(w+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            dp[i][j] = dp[i-1][j];
            if(j-weight[i] >= 0) dp[i][j] = max(dp[i][j],value[i]+dp[i-1][j-weight[i]]);
        }
    }

    int ans = 0;
    for(int j=0;j<=w;j++) ans=max(ans,dp[n][j]);
    cout << ans << endl;

    clock_t end = clock();
    cerr << "Time: " << (double)(end - start) / CLOCKS_PER_SEC << " seconds" << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cmath>

using namespace std;

int N;
int a[100000][3];

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    int x=0,y=0,t=0;
    for(int i=0;i<N;i++){
        int l = abs(x-a[i][1]) + abs(y-a[i][2]);
        if(l > a[i][0] - t){
            cout << "No" << endl;
            return 0;
        }
        if(l % 2 != (a[i][0]-t)%2){
            cout << "No" << endl;
            return 0;
        }
        x=a[i][1], y=a[i][2], t=a[i][0];
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n < m:
    x_distance = [x2 - x1 for x1, x2 in zip(x, x[1:])]
    x_distance.sort()
    print(sum(x_distance[:(m-n)]))
else:
    print(0)


Measured memory_bytes: 13968
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, Q = map(int, readline().split())
    AB = list(list(map(int, readline().split())) for _ in range(N-1))
    PX = list(list(map(int, readline().split())) for _ in range(Q))

    graph = [[] for _ in range(N)]
    for a, b in AB:
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)

    value = [0] * N
    for p, x in PX:
        value[p-1] += x

    que = deque([0])
    visited = [False]*N
    while que:
        x = que.popleft()
        visited[x] = True
        for y in graph[x]:
            if visited[y]:
                continue
            else:
                value[y] += value[x]
                que.append(y)
    print(' '.join(map(str, value)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 142260
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int a[n+1];
  	for(int i=0; i<n; i++){
    	cin >> a[i];
    }
  	long long ans=0;
  	for(int i=0; i<n; i++){
    	for(int j=i+1; j<n; j++){
        	ans += a[i]*a[j];
        }
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-1-i]:
            print("No")
            return
    s1 = s[:(n-1)//2]
    s2 = s[(n+3)//2-1:]
    n1 = len(s1)
    for i in range(n//4):
        if s1[i] != s[n1-1-i]:
            print("No")
            return
        if s2[i] != s[n1-1-i]:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9004
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :dp

  def initialize
    @n = gets.to_s.to_i
    @dp = Array.new(n+1, -1)
    @dp[0] = 0
  end

  def solve
    rec(n)
  end

  def rec(n)
    return @dp[n] if @dp[n] != -1
    ans = 1 + rec(n-1)
    1.upto(7) do |j|
      d = 6 ** j
      1.upto(5) do |k|
        next if n < d * k
        cnt = k + rec(n - d * k)
        ans = cnt if cnt < ans
      end
    end
   
    1.upto(6) do |j|
      d = 9 ** j
      1.upto(8) do |k|
        next if n < d * k
        cnt = k + rec(n - d * k)
        ans = cnt if cnt < ans
      end
    end

    @dp[n] = ans
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 25764
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	K, N := nextInt(), nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}
	maxL := K - (A[N-1] - A[0])
	for i := 1; i < N; i++ {
		maxL = max(maxL, A[i]-A[i-1])
	}
	fmt.Println(K - maxL)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  if (s[0] == 'S') {
    cout << "Cloudy" << endl;
  } else if (s[0] == 'C') {
    cout << "Rainy" << endl;
  } else if (s[0] == 'R') {
    cout << "Sunny" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    double sum= 0;
    REP(i,N){
        double j = i+1;
        while(j<K){
            j*=2;
        }
        sum += (i+1)/j;
    }
    cout << sum / N << "\n";
}

Measured memory_bytes: 256
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil

from sys import exit

from copy import deepcopy

def main():


    n = int(input())
    a = list(map(int,input().split()))
    aunique = list(set(a))

    if len(aunique) == 1:
        if a[0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(aunique) is 2:
        if n%3 or not 0 in aunique:
            print("No")
        else:
            l = []
            l.append(a.count(aunique[0]))
            l.append(a.count(aunique[1]))
            if aunique[0] == 0:
                if not l[0] == n//3:
                    print("No")
                else:
                    print("Yes")
            else:
                if not l[1] == n//3:
                    print("No")
                else:
                    print("Yes")
    elif len(aunique) is 3 and not n%3:
        l = []
        l.append(a.count(aunique[0]))
        l.append(a.count(aunique[1]))
        l.append(a.count(aunique[2]))

        if not l[0] == l[1] or not l[1] == l[2]:
            print("No")
        else:
            if (aunique[0] ^ aunique[1]) ^ aunique[2] ==0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")



main()


Measured memory_bytes: 16244
#include <stdio.h>
#define MAX 100005
#define NIL -1
typedef struct node{
    int p,l,r;
} node;

node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
    if(T[u].p == NIL)
        printf("root, ");
    else if(T[u].l == NIL)
        printf("leaf, ");
    else
        printf("internal node, ");
    printf("[");
    for(i=0,c=T[u].l;c != NIL;i++,c=T[c].r){
        if(i)
            printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}

int rec(int u,int p){
    D[u]=p;
    if(T[u].r != NIL)
        rec(T[u].r,p);
    if(T[u].l != NIL)
        rec(T[u].l,p+1);
}

int main(void){
    int i,o,d,v,c,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        T[i].p=T[i].l=T[i].r=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d",&v,&d);
        for(o=0;o<d;o++){
            scanf("%d",&c);
            if(!o)
                T[v].l=c;
            else
                T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++)
        if(T[i].p == NIL)
            r=i;
    rec(r,0);
    for(i=0;i<n;i++)
        print(i);
    return 0;
}

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

typedef long long ll;
#define MOD 1000000007

int main()
{
    string S;
    cin >> S;
    ll ans = 0;

    for (int i = 0; i < S.size() - 1; ++i)
    {

        if (S[i] != S[i + 1])
        {

            if (i + 1 > S.size())
            {
                break;
            }
            S.erase(i, 2);
            ++ans;
            ++ans;
            i = -1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
struct edge{
    int to;
    int cost;
};
signed main(void){
    int n,k;cin>>n>>k;
    vector<int>C(n),R(n);
    rep(i,n)cin>>C[i]>>R[i];
    vector<int>Road[n];
    int f,t;
    rep(i,k){
        cin>>f>>t;f--;t--;
        Road[f].push_back(t);
        Road[t].push_back(f);
    }
    
    vector<edge>Taxi[n];
    int Count[n];
    queue<int>Q;
    rep(i,n){
        rep(j,n)Count[j]=-1;
        Q.push(i);Count[i]=0;
        
        while(!Q.empty()){
            f=Q.front();Q.pop();
            for(auto x:Road[f]){
                if(Count[x]==-1){Count[x]=Count[f]+1;Q.push(x);}
            }
        }
        rep(j,n){
            if(Count[j]<=R[i]&&Count[j]>0)Taxi[i].push_back({j,C[i]});
        }
    }
//    rep(i,n){
  //      cout<<i<<';'<<' ';
    //    for(auto x:Taxi[i])cout<<x.to<<':'<<x.cost<<' ';
      //  cout<<endl;
 // }
    //Dijkstra
    int dist[n];fill(dist,dist+n,INF);
    priority_queue<P,vector<P>,greater<P>>que;
    dist[0]=0;
    que.push(P(0,0));
    while(!que.empty()){
        int d=que.top().F,f=que.top().S;que.pop();
        if(dist[f]<d)continue;
        rep(i,Taxi[f].size()){
            int t=Taxi[f][i].to;int c=Taxi[f][i].cost;
            if(dist[t]>c+d){
                dist[t]=c+d;
                que.push(P(c+d,t));
            }
        }
    }
    cout<<dist[n-1]<<endl;
}


Measured memory_bytes: 237432
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll all = 1; // 全ての集合
    ll not1or9 = 1; // 1(9)を一つも含まない集合
    ll not19 = 1; // 1,9を一つも含まない集合
    rep(i, N)
    {
        all *= 10;
        not1or9 *= 9;
        not19 *= 8;
        //
        all %= BIGP;
        not1or9 %= BIGP;
        not19 %= BIGP;
    }
    // 一つは1/9を含む
    ll in1or9 = (all + BIGP) - not1or9;
    // 一つは1か9を含む
    ll in19 = (all+ BIGP) - not19;
    // 1と9を含む
    ll all19 = ((in1or9 + BIGP)*2 - in19) % BIGP;
    //
    cout << all19;

    return 0;
}

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

int main() {
  int N, M;
  string s[200], t[200];

  cin >> N;
  rep(i, N) cin >> s[i];
  cin >> M;
  rep(i, M) cin >> t[i];

  int ans = -1111111111;

  rep(i, N) {
    string tmp = s[i];
    int cnt = 0;
    rep(j, N)  if (s[j] == tmp) cnt++;
    rep(j, M)  if (t[j] == tmp) cnt--;
    ans = max(ans, cnt);
  }
  rep(i, M) {
    string tmp = t[i];
    int cnt = 0;
    rep(j, N)  if (s[j] == tmp) cnt++;
    rep(j, M)  if (t[j] == tmp) cnt--;
    ans = max(ans, cnt);
  }

  cout << max(0, ans) << endl;

  return 0;

}

Measured memory_bytes: 256
/******* VIVEK PAl *******/
/*************************/
#include <bits/stdc++.h>
#define prime 1000000007
#define mod 100008
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
/****** END OF HEADER ******/
/***************************/
void fastIO(void);

bool cmp(pair<int,int>a, pair<int,int>b){
  if(a.first == b.first) return (a.second < b.second);
  return (a.first < b.first);
}
void solve()
{
    int N; cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
      cin>>A[i];
    bool flag=true;
    for(int i=0;i<N;i++){
      if(A[i]%2==0){
        if(A[i]%3!=0 && A[i]%5!=0){
          flag=false;
          break;
        }
      }
    }
    if(flag) printf("APPROVED\n");
    else printf("DENIED\n");
}
int main()
{
  fastIO();
  int T=1, t;
  //cin>>T;
  t = T;
  while(T--)
    {
        //printf("Case #%d: ", t-T);
        solve();
    }
}


void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100
#define INFTY 2097152

void enqueue(int);
int dequeue(void);
void bfs(int);

int M[N][N];
int d[N];
int queue[2*N];

int n,i,j;
int head = 1,tail=1;


int main(void)
{
  int k;
  int u,v;

  scanf("%d",&n);

  for(i = 0;i < n;i++)
  {
    for(j = 0;j < n;j++)
    {
      M[i][j] = 0;
    }
  }

  for(i = 0;i < n;i++)
  {
    scanf("%d %d",&u,&k);
    u--;

    for(j = 0;j < k;j++)
    {
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }


  bfs(0);

  return 0;
}




void enqueue(int q)
{
  queue[tail++] = q;
}


int dequeue()
{
  return queue[head++];
}


void bfs(int q)
{
  int u,v;

  enqueue(q);

  for(i = 0;i < n;i++)
  {
   d[i] = INFTY;
  }
  d[q] = 0;

 while(head != tail)
 {
   u = dequeue();
   for(v = 0;v < n;v++)
   {
     if(M[u][v] == 0)
     {
       continue;
     }
     if(d[v] != INFTY)
     {
       continue;
     }
     d[v] = d[u] + 1;
     enqueue(v);
   }
 }

 for(i = 0;i < n;i++)
 {
   printf("%d ",i+1);
   if(d[i] == INFTY)
   {
     puts("-1");
   }
   else
   {
     printf("%d\n",d[i]);
   }
 }
}



Measured memory_bytes: 2100
#include<iostream>
#define llt long long 
using namespace std;
	
void sum(llt n){


    llt divi[n+1]={0};
    llt cnt=0;

        for(llt i=1;i<=n;i++){
        for(llt j=i;j<=n;j=j+i){
           
            divi[j]++;
        }
    }


    
        
        llt ans=0;
        for(llt i=1;i<=n;i++){
            ans+=(llt)i*divi[i];
        }
            cout<<ans<<endl;

}	



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

	return 0;
}

Measured memory_bytes: 81716
//#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)


int main()
{
    int a;
    cin >> a;
    cout << (1000-(a % 1000)) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

ll DP[100005][3];
ll A[100005][3];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        for(int j=0; j<3; j++)
        cin>>A[i][j];

    for(int i=1; i<=n; i++)
        for(int j=0; j<3; j++)
            DP[i][j]=max(DP[i-1][(j+1)%3],DP[i-1][(j+2)%3])+A[i][j];

    cout<<max({DP[n][0],DP[n][1],DP[n][2]});
}


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

int main() {
  string n;

  cin >> n;

  if (n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) = {
    val n = readLine.split(" ")(0).toInt
    val c = readLine.split(" ").map(_.toInt)
    val minVal = (0 to n+1).toArray

    for( i <- 2 to n+1 ) {
      for( j <- c ) {
        if(j<=i && minVal(i-j) + 1 < minVal(i)) {
          minVal(i) = minVal(i-j)+1
        }
      }
    }
    println(minVal(n))
  }
}

Measured memory_bytes: 60692
#include <cstdio>
#include <string>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::string> S(N);
  for (size_t i=0; i<N; ++i) {
    char buf[384];
    scanf("%s", buf);
    S[i] = buf;
  }

  auto good=[&](size_t A)->bool {
    std::vector<std::string> T(N);
    for (size_t i=0; i<N; ++i)
      T[i] = S[i+A<N? i+A:i+A-N];

    for (size_t i=0; i<N; ++i)
      for (size_t j=i+1; j<N; ++j)
        if (T[i][j] != T[j][i])
          return false;

    return true;
  };

  int res=0;
  for (size_t i=0; i<N; ++i)
    if (good(i))
      res += N;

  printf("%d\n", res);
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long K, S;
	cin >> K >> S;
	long long ans = 0;
	for (long long i = 0; i <= K; i++) {
		for (long long j = 0; j <= K; j++) {
			int k = K - i - j;
			if (k < 0) continue;
			if (i * 1000 + j * 5000 + k * 10000 == S) {
				cout << k << ' ' << j << ' ' << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

#define SQ(x) ((x)*(x))

using namespace std;

int main(void)
{
	int n = 0;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		double x1 = 0.0, y1 = 0.0;
		double x2 = 0.0, y2 = 0.0;
		double x3 = 0.0, y3 = 0.0;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		
		double a = x1 - x2;
		double b = y1 - y2;
		double c = SQ(x2) + SQ(y2) - SQ(x1) - SQ(y1);
		double d = x2 - x3;
		double e = y2 - y3;
		double f = SQ(x3) + SQ(y3) - SQ(x2) - SQ(y2);
		
		double l = (c * e - b * f) / (a * e - b * d);
		double m = (a * f - c * d) / (a * e - b * d);
		double n = -1.0 * (SQ(x1) + SQ(y1) + l * x1 + m * y1);
		
		double centerX = l / -2.0;
		double centerY = m / -2.0;
		double radius = sqrt( SQ(l) / 4.0 + SQ(m) / 4.0 - n );
		
		cout.precision(3);
		cout << fixed << centerX << " " << centerY << " " << radius << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1288
#include <stdio.h>

int main(void){
	int num;
	double weight, height;
	
	while(scanf("%d,%lf,%lf", &num, &weight, &height) != EOF){
		if((weight / (height * height)) >= 25){
			printf("%d\n", num);
		}
	}
	
	return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, h; cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i, n){
        ll aa, bb; cin >> aa >> bb;
        a[i] = aa; b[i] = bb;
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    ll cnt = 0, remain = h;
    //cout << endl;
    rep(i, n){
        if(b[i] < a[0]) break;
        if(remain <= 0) break;
        remain -= b[i];
        cnt++;
        //cout << b[i] << endl;
    }
    if(remain > 0){
        cnt += remain / a[0];
        if(remain%a[0] != 0) cnt++;
        //printf("###\n%lld %lld %lld\n", a[0], remain / a[0], remain % a[0]);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pbds;
ll ans[55555];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	b--;
	c--;
	for(int i=0;i<a;i++)
	{
		for(int j=i+1;j<a;j++)
		{
			int num=abs(i-j);
			num=min(num,abs(i-b)+1+abs(c-j));
			num=min(num,abs(i-c)+1+abs(b-j));
			ans[num]++;
		}
	}
	for(int i=1;i<a;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
//	inp_out();
	int h1,m1,h2,m2,k;
	cin>>h1>>m1;
	cin>>h2>>m2;
	cin>>k;

	int v1=h1*60 + m1;
	int v2=h2*60 + m2;

	cout<<(v2-v1-k);

	return 0;
}

Measured memory_bytes: 3640
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

int s;

long number (string str) {
	auto l = s;
	s++;
	while (str[s] >= '0' && str[s] <= '9') s++;
	
	return str[l..s].to!long;
}

long factor (string str) {
	long res;

	if (str[s] == '(') {
		s++;
		res = expression(str);
		s++;
	} else {
		res = number(str);
	}

	return res;
}

long term (string str) {
	auto res = factor(str);
	
	while (1) {
		if (str[s] == '*') {
			s++;
			res *= factor(str);
		} else if (str[s] == '/') {
			s++;
			res /= factor(str);
		} else {
			break;
		}
	}

	return res;
}

long expression (string str) {
	auto res = term(str);

	while (1) {
		if (str[s] == '+') {
			s++;
			res += term(str);
		} else if (str[s] == '-') {
			s++;
			res -= term(str);
		} else {
			break;
		}
	}

	return res;
}

void main()
{
	auto n = readln.chomp.to!int;
	foreach (i; 0..n) {
		s = 0;
		auto eqn = readln.chomp.to!string;
		eqn.expression.writeln;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;


void solve(long long N, long long A, long long B){
    int ans = 0;

    for (int i = 1; i <= N; i++) {
        string num = to_string(i);
        int sum = 0;
        REP(j, num.size())
            sum += num[j] - '0';
        if (sum >= A && sum <= B)
            ans += i;
    }

    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)
 
#define INF 987654321
#define IINF 2987654321987654321
#define MOD 1000000007


int main() {
	ll h, n;
	scanf("%lld%lld", &h, &n);
	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		ll t; scanf("%lld", &t);
		sum += t;
	}

	if(sum >= h)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))
lst.sort()
k = lst[-1]+1
dp = [0 for i in range(k)]
ans = 0
for i in lst:
    if dp[i] == 0:
        ans += 1
        dp[i] = 2
        for j in range(i*2, k, i):
            dp[j] = 1
    elif dp[i] == 2:
        dp[i] = 1
        ans -= 1
print(ans)

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

int main() {
  int n, x, tmp;
  int total = 0;
  int m = 1000;

  cin >> n >> x;

  for (int i = 0; i < n; i++) {
    cin >> tmp;
    total = total + tmp;
    if (tmp < m) m = tmp;
  }
  cout << n + ((x - total) / m) << endl;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	char at[4] = { 'A', 'T', 'C', 'G'};
	string s;
	cin >> s;
	ll tmp = 0;
	vll ans;
	rep(i, s.size()) {
		if (s[i] == at[0] || s[i] == at[1] || s[i] == at[2] || s[i] == at[3]) ++tmp;
		else {
			ans.push_back(tmp);
			tmp = 0;
		}
	}
	ans.push_back(tmp);
	cout << *max_element(all(ans)) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC070C
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	j = gcd(ans,t[i])
	ans *= t[i]
	ans = ans//j

print(ans)


Measured memory_bytes: 3060
N = int(input())

s = 1
z = 1
n = 1
zn = 1
e = 10 ** 9 + 7

for i in range(N):
    s = s * 10 % e
    z = z * 9 % e
    n = n * 9 % e
    zn = zn * 8 % e

result = s - z - n + zn

while result < 0:
    result += e

print(result)

Measured memory_bytes: 63588
main :: IO ()
main = getLine >>= print . head . foldl calc [] . words

calc :: [Int] -> String -> [Int]
calc xs y
  | y == "+" = init2 ++ [last2 + last1]
  | y == "-" = init2 ++ [last2 - last1]
  | y == "*" = init2 ++ [last2 * last1]
  | otherwise = xs ++ [read y]
  where
    last1 = last xs
    last2 = last . init $ xs
    init2 = init . init $ xs



Measured memory_bytes: 4360
#include <iostream>

int main(void){
  int A, B, K;
  std::cin >> A >> B >> K;

  int a = (A < B)? A : B;
  int ans = 1;
  for(int i = a; i <= a; i--){
    if((A % i) == 0 && (B % i) == 0){
      ans = i;
      K--;
      if(K < 1)
	break;
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256