akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var N, M, C int
	var B [20] int
	fmt.Scan(&N, &M, &C)
	for i := 0; i < M; i++ {
		fmt.Scan(&B[i])
	}
	var ans = 0
	for i := 0; i < N; i++ {
		var x = C
		for j := 0; j < M; j++ {
			var A int
			fmt.Scan(&A)
			x += A * B[j]
		}
		if x > 0 {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,result=1;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld",&n);
  rep(i,n) scanf("%d",&a[i]);
  for(i=n-2;i>=0;i--){
    if(a[i]<=a[i+1]) continue;
    else if(a[i]-a[i+1]==1){
      a[i]--;
    }else{
      result = 0;
      break;
    }
  }
  
  if(result==1) printf("Yes");
  else printf("No");
  return 0;
}



Measured memory_bytes: 2176
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <complex>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const double EPS=1e-10;

#define equals(a, b) (fabs((a)-(b))<EPS)
#define X real()
#define Y imag()

typedef complex<double> Point;
typedef complex<double> Vector;


struct Circle {
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0) :
        c(c),r(r){}
};

struct Segment {
    Point p1, p2;
};

bool include(Circle c,Point p) {
    return (norm(c.c-p) <= c.r*c.r+EPS);
}

int n;
double xs[301],ys[301];

Point getMidpoint(Point p1, Point p2, Point p3) {
    Point p=p1+p2+p3;
    p/=3;

    return p;
}

int f(Point p) {
    int ret=0;
    Circle c=Circle(p,1);
    rep(i,n) {
        if(include(c,Point{xs[i],ys[i]})) ret++;
    }

    return ret;
}

void solve() {
    rep(i,n) cin>>xs[i]>>ys[i];
    int ans=1;
    rep(i,n) rep(j,n) if(i<j) {
        Point p1=Point{xs[i],ys[i]};
        Point p2=Point{xs[j],ys[j]};
        Vector v=p1-p2;
        if(abs(v) > 2.0+EPS) continue;
        
        Vector t=(v/abs(v))*Vector(0,1);
        double h=sqrt(1-abs(v)*abs(v)/4.0);

        Point p = p2+v/2.0 + t*h;


        ans=max(ans,f(p));
        t*=-1.0;
        p = p2+v/2.0 + t*h;
        ans=max(ans,f(p));
    }

    cout<<ans<<endl;
}

int main() {
    while(cin>>n) {
        if(!n) break;
        solve();
    }
    return 0;
}

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

int main() {
    const int maxT = 1E+5 + 10;

    int N, C;
    cin >> N >> C;
    vector<vector<int>> record;
    record.assign(maxT, vector<int>(C+1, 0));

    int si, ti, ci, maxTi = 0;
    rep(i, N) {
        cin >> si >> ti >> ci;
        record[si][ci] = 2;
        record[ti][ci] = max(record[ti][ci], 1);
        maxTi = max(maxTi, ti);
    }

    for (int c=0; c<=C; c++) {
        bool recording = false;
        for (int t=0; t<=maxTi; t++) {
            if (record[t][c] == 2) recording = true;
            else if (record[t][c] == 1) recording = false;

            if (recording) record[t][c] = 2;
        }
    }


    int ans = 0;
    for (int t=0; t<=maxTi; t++) {
        int num_t = 0;
        for (int c=0; c<=C; c++) {
            // cout << record[t][c] << " ";
            if (record[t][c] > 0) num_t += 1;
        }
        // cout << endl;
        ans = max(ans, num_t);
    }

    cout << ans << endl;

    return 0;
}



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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define ar array
#define pb push_back
#define sz(X) ((int)(X).size())
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define  No cout<<"NO"<<endl;
#define  Yes cout<<"YES"<<endl;
#define  nl cout<<endl;

template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}
// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << ts(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }

#ifdef _DEBUG // compile with -DLOCAL
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
	#define dbg(...) 0
#endif

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }


const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll INF = 1e9 + 6;

ll add(ll a, ll b) {
    a += b;
    return a % mod;
}

ll mul(ll a, ll b) {
    a *= b;
    return a % mod;
}

inline ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MXN = 1e5 + 5;

ll dp[102][MXN];
void solve() {
int n,tot;
cin>>n>>tot;
int v[n+1],w[n+1];
int sum=0;
for(int i=1;i<=n;i++){
    cin>>w[i]>>v[i];
    sum+=v[i];
}
memset(dp,0x1f,sizeof(dp));
dp[0][0]=0;
for(int i=1;i<=n;i++){
    for(int j=sum;j>=0;j--){
        if(j>=v[i])
            dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
        else{
            dp[i][j]=dp[i-1][j];
        }
    }
}
int ans=0;
for(int i=0;i<=sum;i++){
    if(dp[n][i]<=tot){
        ckmax(ans,i);
    }
}
cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    #ifndef ONLINE_JUDGE
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
//    #endif
    int t = 1;
   // cin >> t;
    while (t--)solve();
    // cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}
//look if it requires ll


Measured memory_bytes: 83328
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
}


Measured memory_bytes: 3556
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = arg[0].split(" ").map(n=>~~n);
    
    console.log(~~N.sort((a,b)=>a-b).join("") === 1479 ? "YES" : "NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>x;i--)
typedef long long ll;
using namespace std;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll x=max(a,b);
    x=max(x,c);
    cout<< 9*x+a+b+c<<endl;
    
}



Measured memory_bytes: 256
///******* In the name of Allah *******///

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int m,n,i,j,k,l;
    string a;
    cin>>a;
    if(a=="SUN")
    {
        cout<<"7"<<endl;
    }
    else if(a=="MON")
    {
        cout<<"6"<<endl;
    }
    else if(a=="TUE")
    {
        cout<<"5"<<endl;
    }
    else if(a=="WED")
    {
        cout<<"4"<<endl;
    }
    else if(a=="THU")
    {
        cout<<"3"<<endl;
    }
    else if(a=="FRI")
    {
        cout<<"2"<<endl;
    }
    else if(a=="SAT")
    {
        cout<<"1"<<endl;
    }

    return 0;
}


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

int main(){
  int n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  sort(an.begin(),an.end());
  vector<ll> ep(n+1,0);
  for(int i=1; i<=n; ++i) ep[i] = ep[i-1] + an[i-1];
  
  int ans = p;
  int bord = an[n-p];
  for(int i=n-p-1; i>=0; --i){
    bool flag = (ep[n-p+1] - ep[i]) - (ll)(n-v)*m <= (ll)an[i]*(n-p-i+1);
    //cout << ep[n-p+1] - ep[i] << '-' << (n-v)*m << ':' << (ll)an[i]*(n-p-i+1) << endl;
    if(bord-an[i] <= m && flag){
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
 
void find3(int n);
  
int main(void) {
    int n;
      
    scanf("%d",&n);
    find3(n);
     
    printf("\n");
    return 0;
}
 
void find3(int n){
    int i;
     
    for(i=1;i<=n;i++){
        if(i % 3 == 0)
            printf(" %d",i);
        else if (i % 10 == 3)
            printf(" %d",i);
        else if (i / 10 == 3)
            printf(" %d",i);
        else if (i / 100 == 3)
            printf(" %d",i);
        else if (i / 1000 == 3)
            printf(" %d",i);
        else if (i % 1000 / 100 == 3)
            printf(" %d",i);
        else if (i % 100 / 10 == 3)
            printf(" %d",i);
        else{}
         
    }
}

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;
    int64_t ans = 0;
    int cnt = 0;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

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

    void unite(int x, int y, int c){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        cnt++;
        ans += c;
    }

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

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    map<int, vector<pair<int, int>>> qs;
    for(int i=0; i<Q; i++){
        int a, b, c;
        cin >> a >> b >> c;
        qs[c].emplace_back(a, b);
    }
    int mn = qs.begin()->first;

    UnionFind uf(N);
    vector<int> st[2];
    bool used[200000][2] = {0};
    for(int c=mn; uf.cnt < N-1;  c++){
        vector<int> nxt;
        for(int a : st[c%2]) if(!used[a][c%2]){
            used[a][c%2] = true;
            int b = (a+1) % N;
            uf.unite(a, b, c);
            nxt.push_back(b);
        }
        st[c%2] = nxt;
        if(qs.count(c)) for(auto& p : qs[c]){
            int a = p.first, b = p.second;
            uf.unite(a, b, c);
            st[c%2].push_back(b);
            st[(c+1)%2].push_back(a);
        }
    }
    cout << uf.ans << endl;
    return 0;
}


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

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

    if(N % 2 == 0) cout << fixed << setprecision(10) << 0.5000000000 << endl;
    else {
        cout << fixed << setprecision(10) << ((N+1.0)/(2.0*N)) << endl;
    }    
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;
const int MAX = 1e6;

class Point{
public: int x,y;

  Point(int x = 0,int y = 0): x(x),y(y){}
};

int main(){
  int n,q,a[MAX+1]={0};
  priority_queue<P> Q;
  Point x,y;

  cin >> n >> q;
  while(q--){
    cin >> x.x >> x.y;
    a[x.x] += x.y;
    Q.push(P(a[x.x],-x.x));
    while(true){
      y.x = -Q.top().second;
      y.y = Q.top().first;
      if(a[y.x] == y.y){
	cout << y.x << " " << y.y << endl;
	break;
      }
      Q.pop();
    }
  }

  return 0;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	int m=-1,mm=-1;
	REP(i,n){
		cin>>a[i];
		if(a[i]>m){
			mm=m;
			m=a[i];
		}else if(a[i]>mm){
			mm=a[i];
		}
	}
	
	REP(i,n){
		if(a[i]==m) cout<<mm<<endl;
		else cout<<m<<endl;
	}
}//解説参考.

Measured memory_bytes: 2432
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  sp <- replicateM n getLine
  let spWithNo = map snd $ sort $ zip (map ((\[a, b] ->  (a, 100 - (read :: String -> Int) b)) . words) sp) [1 .. n]
  putStrLn $ unlines $ map show spWithNo


Measured memory_bytes: 1020
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a;
int m[21][21];
ll dp[1<<21], mod = 1e9+7;

int main() {
    fast;
    memset(dp, 0, sizeof(dp));
    cin>>a;
    for(int q=0; q<a; q++){
        for(int w=0; w<a; w++){
            cin>>m[q][w];
        }
    }
    int all = (1<<a);
    for(int q=0; q<a; q++) dp[1<<q] = m[q][0];
    for(int msk=0; msk<all; msk++){
        if(!(msk&(msk-1))) continue;
        int bt = __builtin_popcount(msk);
        for(int q=0; q<a; q++){
            if(!(msk&(1<<q))) continue;
            dp[msk] += m[q][bt-1]*(dp[msk^(1<<q)]);
        }
        dp[msk]%=mod;
    }
    cout<<dp[all-1];
}

Measured memory_bytes: 16768
N = int(input())
S = [input() for i in range(N)]

n_dict = {}

for i in S:
    if i not in n_dict:
        n_dict[i] = 1
    else:
        n_dict[i] +=1
    
m = max(n_dict.values())
ans =[]
for k, v in n_dict.items():
    if v == m:
        ans.append(k)

ans.sort()

print(*ans, sep="\n")
    

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

const int Max = 5000005;
int H, A[Max];

void maxHeapify(int i)
{
    int l, r, largest;
    l = i*2;
    r = i*2+1;
    if(A[l]>A[i] && l<=H)
        largest = l;
    else largest = i;
    if(A[largest]<A[r] && r<=H)
        largest = r;
    if(largest!=i)
    {
        int temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
       // swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}
int main()
{
    cin >> H;
    for(int i=1; i<=H; i++)
        cin >> A[i];
    for(int i=H/2; i>=1; i--)//从不是叶子的结点开始
    {
        maxHeapify(i);
    }
    for(int i=1; i<=H; i++)
        cout << " " << A[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 4956
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	cout<<setprecision(20)<<fixed;
	double ans=0.;
	int N,M,D;
	cin>>N>>M>>D;
	if(D==0){
		cout<<1.*(M-1)*1./N<<endl;
		return 0;
	}
	int a,b,c;
	if(N<=D){
		double zero=0.;
		cout<<zero<<endl;
		return 0;
	}
	else if(N>=2*D){
		a=2*D;
		b=0;
		c=N-a;
	}
	else{
		b=2*D-N;
		a=N-b;
		c=0;
	}
	double A=a,B=b,C=c;
	cout<<1.*(M-1)*(A/N*1./N+C/N*2./N)<<endl;
	return 0;
}

Measured memory_bytes: 764
import sys

n_in = input()
result = input().split()
total = 0
n_in = int(n_in)
p_min = int(result[0])
for k0 in range(n_in):
    count = 0
    if int(result[k0]) <= p_min:
        total += 1
        p_min = int(result[k0])

print(total)


Measured memory_bytes: 17780
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ans float32
	for i := 0; i < n; i++ {
		var x float32
		var u string
		fmt.Scan(&x)
		fmt.Scan(&u)
		if u == "BTC" {
			x *= 380000
		}
		ans += x
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vector<pii> v;
	rep(i,n){
		int h,m;
		cin>>h>>m;
		v.PB(pii(h,m));
	}
	cin>>n;
	rep(i,n){
		int h,m;
		cin>>h>>m;
		v.PB(pii(h,m));
	}
	sort(ALL(v));
	v.erase(unique(ALL(v)),v.end());
	rep(i,v.size()){
		if(i) printf(" ");
		printf("%d:%02d",v[i].F,v[i].S);
	}
	puts("");
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3216
#include <iostream>
#define int long long
using namespace std;

int mod = 1000000007;
int n, k;

signed main() {
	cin >> n >> k;
	
	int ans = 0;
	for (int i = k; i <= n + 1; i++) {
		int low = (i - 1) * i / 2;	//[0, i)
		int high = n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2;	//(n - i, n]
		ans += high - low + 1;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,a,b;
signed main(){
	cin>>n>>a>>b;
	if(a%2==b%2){
		cout<<(max(a,b)-min(a,b))/2<<endl;
	}else{
		int ans=8e18;
		ans=min(ans,(a-1+b-1+1)/2);
		ans=min(ans,(n-a+n-b+1)/2);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pql priority_queue<ll>
#define fi first
#define se second
#define pb push_back
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mib map<int,bool>
#define mlb map<ll,bool>
#define f(i,k,n) for(ll i=k;i<n;i++)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll mod=1e9+7;
int main()
{
    IOS
    ld r;
    cin>>r;
    ld pii=3.141592653589793238;
    ld ans=2*pii*r;
    cout<<ans<<endl;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    int n;
    cin >> n;
    vi l(n);
    REP(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int count = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = i + 1; j < n ; j++){
            for(int k = j + 1 ; k < n ; k++){
                if( l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
                if( l[i] + l[j] > l[k]){
                    count++;
                }
            }
        }
    }
    cout << count << "\n";
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int N=1505;
const int mo=998244353;
int a[N][N],n,ans;
int deg[N],vis[N];
int S1,S2,S3,GG;
vector<int> e[N];
char s[N];
void dfs(int x){
	++S3;
	S1^=deg[x];
	S2+=e[x].size();
	vis[x]=1;
	For(i,0,e[x].size()-1)
		if (!vis[e[x][i]])
			dfs(e[x][i]);
}
int main(){
	scanf("%d",&n);
	For(i,0,n) For(j,0,n) a[i][j]=-1;
	For(i,1,n-1){
		scanf("%s",s+1);
		For(j,1,n-1){
			int c=-1;
			int v1=abs(i-j),v2=n-abs(n-i-j);
			if (v1>v2) swap(v1,v2);
			if (s[j]=='x') c=0;
			if (s[j]=='o') c=1;
			if (c!=-1&&a[v1][v2]!=-1&&c!=a[v1][v2]) GG=1;
			if (c!=-1) a[v1][v2]=c;
		}
	}
	if (GG)
		return puts("0"),0;
	For(i,1,n-1) For(j,1,n-1){
		int v1=i-j,v2=i+j;
		if (v1>=0&&v2<=n){
			//printf("%d %d\n",i,j);
			if (a[v1][v2]==-1){
				e[v1].PB(v2);
				e[v2].PB(v1);
				//printf("edge %d %d\n",v1,v2); 
			}
			else if (a[v1][v2]==1)
				deg[v1]^=1,deg[v2]^=1;
		}
	}
	int ans=1;
	For(i,0,n) if (!vis[i]){
		S1=S2=S3=0; dfs(i); S2/=2;
		int cnt=(i&1?(n+1)/2:n/2+1);
		if (cnt&1){
			if (S1) return puts("0"),0;
			S2-=S3-1;
		}
		For(j,1,S2)
			ans=2ll*ans%mo;
	}
	printf("%d",ans);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

//#define N 2000

template<size_t N>
const bitset<N> operator+(const bitset<N>& lhs, const bitset<N>& rhs)
{
    bitset<N> a(lhs), b(rhs), ret(lhs ^ rhs);

    for (b = (a & b) << 1, a = ret; b.any(); b = (a & b) << 1, a = ret) ret ^= b;

    return ret;
}

template<size_t N>
int edit_distance_bitset(const string& str1, const string& str2)
{
    char s1[N] = { ' ' };
    char s2[N] = { ' ' };
    char *p1, *p2;

    if (str1.size() >= str2.size()) { p1 = s1;  p2 = s2; }
    else { p1 = s2;  p2 = s1; }
    copy(str1.begin(), str1.end(), p1 + 1);
    copy(str2.begin(), str2.end(), p2 + 1);
    int m = strlen(s1);
    int n = strlen(s2);

    const bitset<N> ONE(1);
    bitset<N> Peq[256];
    bitset<N> Pv, Mv, Eq, Xv, Xh, Ph, Mh;
    int Score = m;

    for (int i = 0; i < m; i++) {
        Peq[s1[i]] |= ONE << i;
        Pv |= (ONE << i);
    }
    for (int j = 0; j < n; j++) {
        Eq = Peq[s2[j]];
        Xv = Eq | Mv;
        Xh = (((Eq & Pv) + Pv) ^ Pv) | Eq;
        Ph = Mv | ~(Xh | Pv);
        Mh = Pv & Xh;
        if ((Ph & (ONE << (m - 1))).any()) Score++;
        else if ((Mh & (ONE << (m - 1))).any()) Score--;
        Ph = Ph << 1 | ONE;
        Pv = (Mh << 1) | ~(Xv | Ph);
        Mv = Ph & Xv;
    }

    return Score;
}

int main(){
	string a,b;
  cin>>a>>b;
  cout<<edit_distance_bitset<1010>(a,b)<<endl;
  return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
#define MAX_M   100000

int tasu(int x){
    if(x <= 0)
        return 0;
    return x + tasu(x-1);
}

int P(int x){
    if(x == 1)
        return 1;
    return x * (P(x - 1));
}


void solve(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    REP(i,n)
        cin >> x[i] >> y[i];
    long double sum = 0;
    REP(i,n){
        for(int j = i; j < n; j++){
            sum += (n-1) * P(n) / tasu(n - 1) * sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        }
    }
    long double ans = sum;
    for(int i = 1; i <= n; i++)
        ans /= i;
    printf("%.10Lf\n", ans);
}

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

Measured memory_bytes: 256
table = []

for l in range(8):
    table.append(input())

print(90)
for i in range(8):
    for j in range(8):
        print(table[7-j][i], end="")
    print("")

print(180)
for i in range(8):
    for j in range(8):
        print(table[7-i][7-j], end="")
    print("")

print(270)
for i in range(8):
    for j in range(8):
        print(table[j][7-i], end="")
    print("")


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  int N, A, B, cnt = 0;
  cin >> N >> A >> B;
  rep(i, N + 1) {
    int sum = 0, n = i;
    while(n > 0) {
      sum += n % 10;
      n /= 10;
    }
    if(sum >= A && sum <= B)
      cnt += i;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 1000005
#define pb push_back
#define mp make_pair
#define vit vector<int>::iterator
typedef pair<int,int> pii;
vector<int> V[MAX];
vector<pii> E;
int dfs(int u,int p,int d,int dmax){
    int sum=1;
    if(d==dmax)
        return sum;
    for(auto v:V[u]){
        if(v!=p){
            sum+=dfs(v,u,d+1,dmax);
        }
    }
    return sum;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,d;
    cin>>n>>d;
    if(d%2){
        for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            V[u].pb(v);
            V[v].pb(u);
            E.pb(mp(u,v));
        }
        int mx=0;
        for(auto e:E){
            int vlu=dfs(e.first,e.second,1,d/2+1);
            vlu+=dfs(e.second,e.first,1,d/2+1);
            mx=max(mx,vlu);
        }
        cout<<n-mx;
    }
    else{
        for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
            V[u].pb(v);
            V[v].pb(u);
        }
        int mx=0;
        for(int i=1;i<=n;i++){
            int vlu=dfs(i,-1,0,d/2);
            mx=max(mx,vlu);
        }
        cout<<n-mx;
    }
}
/*
6 5
1 2
3 2
4 2
1 6
5 6
*/


Measured memory_bytes: 27156
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const double PI=3.14159265358979323846;
int main(){
  double a,b,x; cin >> a >> b >> x;
  double h = x/a/a;
  double ans = atan(2*(b-h)/a);
  if(h-a/2*tan(ans) < 0) ans = atan(b*b/2/a/h);
  ans = ans *180/PI;
  printf("%f\n",ans);
}


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

const int INF =1e9 + 5;

int main(){
	int n,k;
	cin>>n>>k;
	int h[n];

	for(int i=0;i<n;i++)
		cin>>h[i];

	vector<int> dp(n,INF);
	dp[0]=0;
	
	for(int i=0;i<n;i++){

		for( int j=i+1;j<=i+k;j++){
			if(j<n)
				dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
		}
	}

	cout<<dp[n-1];
	return 0;
}

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

using namespace std;

const int maxn = 300010;

int n,res,s1[3][maxn],s2[3][maxn];
string s;

int main() {
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    cin>>s;
    for (int i=0;i<n;i++) {
        int t = (s[i]=='W') ? 0 : 1;
        s1[t][i] = s1[t][i-1] + 1;
        s1[1-t][i] = s1[1-t][i-1];
    }
    for (int i=n-1;i>=0;i--) {
        int t = (s[i]=='W') ? 0 : 1;
        s2[t][i] = s2[t][i+1] + 1;
        s2[1-t][i] = s2[1-t][i+1];
    }
    res = 1e9;
    for (int i=0;i<n;i++) {
       // cout<<s1[0][i-1]<<" "<<s2[1][i+1]<<endl;
        res = min(res,s1[0][i-1]+s2[1][i+1]);
    }
    cout<<res<<endl;
}


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

using namespace std;

typedef long long ll;

int main() {
	ll n, sgn;
	cin >> n;
	sgn = n < 0;
	n = abs(n);
	ll ans = 0;
	for (ll i = 0, k = 1; n >= k; i++, k <<= 1) {
		if (n & k) {
			ans ^= k;
			if (i & 1 ^ sgn) {
				n += k;
			}
		}
	}
	string s = bitset<40>(ans).to_string();
	s = string(find(s.begin(), s.end(), '1'), s.end());
	cout << (s.size() == 0 ? "0" : s) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, k, n, ans = 0;
  scanf("%d", &n);
  char s[n + 10];
  scanf("%s", s);
  for(i = 1; i < n - 1; ++i) {
    int cnt = 0, flag1[26], flag2[26];
    for(j = 0; j < 26; ++j) flag1[j] = 0, flag2[j] = 0;
    for(j = 0; j < i; ++j) flag1[s[j] - 'a'] = 1;
    for(j = i; j < n; ++j) flag2[s[j] - 'a'] = 1;
    for(j = 0; j < 26; ++j) if(flag1[j] && flag2[j]) ++cnt;
    if(ans < cnt) ans = cnt;
  }
  printf("%d", ans);
  return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll n, m, mod = 1e9+7;
  cin >> n >> m;

  vector<ll> x(n+1), y(m+1);
  for (int i = 0; i < n; i++) cin >> x[i+1];
  for (int i = 0; i < m; i++) cin >> y[i+1];

  ll fac_x = 0, fac_y = 0;

  for (ll i = 1; i <= n; i++) {
    fac_x = (fac_x + ((i - 1) * x[i] - (n - i) * x[i])) % mod;
  }

  for (ll i = 1; i <= m; i++) {
    fac_y = (fac_y + ((i - 1) * y[i] - (m - i) * y[i])) % mod;
  }

  fac_x = fac_x % mod;
  fac_y = fac_y % mod;

  cout << (fac_x * fac_y) % mod << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	//freopen("in.txt","r",stdin);
	string str;
	while(cin>>str){
		int num[27]={0};
		ll ans=0;
		for(int i=0;i<str.size();i++){
			ans+=i-num[str[i]-'a'];
			num[str[i]-'a']++;
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 720
using System;
using System.Collections.Generic;

namespace volume
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] height = new int[10]; 
            for (int i = 0; i < 10; i++)
            {
                height[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(height);
            Array.Reverse(height);

            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(height[i]);
            }
        }
    }
}



Measured memory_bytes: 18028
n, a, b = map(int, input().split())

sum = 0
for i in range(n):
  x = (i + 1) // 10000 + (i + 1) % 10000 // 1000 + (i + 1) % 1000 // 100 + (i + 1) % 100 // 10 + (i + 1) % 10
  if a <= x <= b:
    sum += i + 1
print(sum)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, Q; 
  cin >> N >> Q;

  vector<vector<int>> graph(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }
  
  vector<int> ans(N, 0);
  REP(i, Q){
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  vector<bool> visited(N, false);

  queue<int> q;
  q.push(0);
  visited[0] = true;
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto v : graph[p]){
      if(visited[v]) continue;
      visited[v] = true;
      ans[v] += ans[p];
      q.push(v);
    }
  }

  REP(i, N){
    cout << ans[i]; SPBR(i, N);
  }

  return 0;
}

Measured memory_bytes: 17904
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int n;
	cin >> n;
	for (int i = n; i <= 999; i++) {
		int x = i / 100;
		int y = i % 100;
		y /= 10;
		int z = i % 10;
		if (x == y&&y == z) {
			cout << i << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
# 入力
N = int(input())

# sqrt(N) + 1 より大きい N の約数dについて、 d - 1 がお気に入りの数か
# 判定し、お気に入りの数であるものの和を解とする
ans = sum(
    N // d - 1
    for d in range(1, int(N**0.5) + 1)
    if N % d == 0 and N // d > 1 and (N // (N // d - 1)) == (N % (N // d - 1))
)

# 出力
print(ans)


Measured memory_bytes: 3060
A, B, C = map(int, input().split())
K = int(input())
ans = 'No'
for k in range(K+1):
  if A < B < C:
    ans ='Yes'
    break
  if A >= B:
    B *= 2
    continue
  if B >= C:
    C *= 2
    continue
print(ans)

Measured memory_bytes: 9144
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] ss = Console.ReadLine().Split(' ');
      long a = long.Parse(ss[0]);
      long b = long.Parse(ss[1]);
      long c = long.Parse(ss[2]);
      long d = long.Parse(ss[3]);
      Console.WriteLine(Math.Max(Math.Max(a * c, b * d), Math.Max(a * d, b * c)));
      Console.ReadLine();
    }

  }
}

Measured memory_bytes: 27528
#include <stdio.h>

int main() {

int n,i,j;
scanf("%d\n", &n);

char suit;
int rank;
int card[4][13];

for (i = 0; i<4 ; i++)
for (j = 0; j<13 ; j++)
card[i][j] = 0;

for (i = 0; i < n; i++){

scanf("%c %d\n", &suit, &rank);
if(suit == 'S') card[0][rank-1] = 1;
else if (suit == 'H') card[1][rank-1] = 1;
else if (suit == 'C') card[2][rank-1] = 1;
else if (suit == 'D') card[3][rank-1] = 1;

}

for (i = 0; i<4 ; i++)
for (j = 0; j<13 ; j++){
if(card[i][j] == 0){ 
if(i == 0) printf("S %d\n", j+1);
else if(i == 1) printf("H %d\n", j+1);
else if(i == 2) printf("C %d\n", j+1);
else if(i == 3) printf("D %d\n", j+1);
}
}

}



Measured memory_bytes: 2088
from itertools import product
s = input()
firstnum = s[0]
s = s[1:]
ans = 0
for c in product(range(2),repeat=(len(s))):
    formula = firstnum
    for i in range(len(s)):
        if c[i] == 1:
            formula += '+'
        formula += s[i]
    ans += eval(formula)

print(ans)


Measured memory_bytes: 3060
h, w = map(int, input().split())
#inputの両端に.を入れてリストに格納
ls = [[i for i in '.'+input()+'.'] for i in range(h)]
#上段を埋める
ls.insert(0, ['.' for i in range(w+2)])
#下段を埋める
ls.append(['.' for i in range(w+2)])

ans = 'Yes'
for i in range(1, h+1):
    for j in range(1, w+1):
        if ls[i][j] == '#' and '#' not in [ls[i][j-1], ls[i][j+1], ls[i-1][j], ls[i+1][j]]:
            ans = 'No'
            
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#define re register int
using namespace std;

int a,b,c,tmp,k,yu,t,arr[100001];

int main()
{
	std::cin>>a>>b>>c;
	
	while(1)
	{
		k++;
		tmp=a*k;
		yu=tmp%b;
		if(yu==c)
		{
			std::cout<<"YES";
			return 0;
		}
		arr[++t]=yu;
		if(yu==arr[1]&&t>1)
		{
			std::cout<<"NO";
			return 0;
		}
	}

	return 0;
}


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

using namespace std;

bool isPrime(int x) {
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	int i = 3;
	while (i <= sqrt(x)) {
		if (x % i == 0)
			return false;
		++i;
	}
	return true;
}

int main() {

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

	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (isPrime(x[i])) {
			++cnt;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3192
def solve(i, cost, sums):
    global x
    if min(sums) >= x:
        global min_cost
        min_cost = min(cost, min_cost)
        return
    if i == n:
        return
    solve(i + 1, cost, list(sums))
    for i_, a in enumerate(C[i][1]):
        sums[i_] += a
    cost += C[i][0]
    solve(i + 1, cost, list(sums))


n, m, x = map(int, input().split())
C = []
ans = 0
for _ in range(n):
    __ = [int(x) for x in input().split()]
    C.append([__[0], __[1:]])
min_cost = int(1e9)
solve(0, 0, [0] * m)
print(-1 if min_cost == int(1e9) else min_cost)


Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string N;
    int K;
    cin >> N >> K;
    int d = N.size();
    ll ans = 0;
    for(int i=0;i<d;i++){
        if(i!=d-1){
            if(K==1){
                ans+=9;
            }
            if(K==2){
                if(i<1) continue;
                ans+=9*9*(i);
            }
            if(K==3){
                if(i<2) continue;
                ans+=9*9*9*((i)*(i-1)/2);
            }
        }else{
            int num = N[0]-'0';
            if(K==1){
                ans += num;
            }
            if(K==2){
                ans += (num-1)*9*(d-1);
                if(d<2) continue;
                int j=1;
                for(;j<d;j++){
                    if(N[j]!='0'){
                        break;
                    }
                    if(j==d-1){
                        cout << ans << endl;
                        return 0;
                    }
                }
                ans+=9*(d-j-1) + (N[j]-'0');
            }
            if(K==3){
                ll tmp = 0;
                if(d<3) continue;
                tmp += (num-1)*9*9*(d-1)*(d-2)/2;
                int a=1;
                for(;a<d;a++){
                    if(N[a]!='0') break;
                    if(a==d-2){
                        cout << ans+tmp << endl;
                        return 0;
                    }
                }
                int num2 = N[a]-'0';
                tmp += (num2-1)*9*(d-a-1);
                tmp += 9*9*(d-a-1)*(d-a-2)/2;
                int b=a+1;
                for(;b<d;b++){
                    if(N[b]!='0') break;
                    if(b==d-1){
                        cout << ans+tmp << endl;
                        return 0;
                    }
                }
                tmp += 9*(d-b-1)+(N[b]-'0');
                ans += tmp;
            }
            
        }
        //cout << "i:" << i << " ans:" << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll A, B, N;
    cin >> A >> B >> N;

    if(B - 1 <= N){
        cout << (A * (B - 1)) / B << endl;
        return 0; 
    }else{
        cout << (A * N / B) - A * (N / B) << endl;
        return 0;
    }
}

Measured memory_bytes: 3632
import java.util.Map.Entry;
import java.lang.reflect.Method;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayList;

//import org.w3c.dom.css.Counter;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //String S = sc.next();
        long a = Integer.parseInt(sc.next());
        long b = Integer.parseInt(sc.next());
        long c = Integer.parseInt(sc.next());
        long d = Integer.parseInt(sc.next());
        long ans = a*c;
        if(ans <b*c){
           ans =b*c;
        }
        if(ans <b*d){
            ans =b*d;
         }
         if(ans <a*d){
            ans =a*d;
         }
         System.out.println(ans);

    }
}

Measured memory_bytes: 35608
import sys
input = sys.stdin.readline


def main(n, a, b, c):
    total = sum(b)

    for i in range(n-1):
        if a[i]+1 == a[i+1]:
            total += c[a[i]-1]

    return total


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    print(main(n, a, b, c))


Measured memory_bytes: 3060