akhauriyash/Code-Regression huggingface dataset:
import math

A,B,H,M = map(int, input().split())

omega_A = 6
omega_B = 30

degree_A = omega_A * M
degree_B = omega_B * H + ((omega_B / 60) * M)
degree_AB = abs(degree_A - degree_B)

if degree_AB > 180:
  degree_AB = 360 - degree_AB
  
C = (A**2 + B**2 - 2*A*B*math.cos(math.radians(degree_AB)))**0.5  

print(C)

Measured memory_bytes: 9460
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
map<ll,ll> dividers[10010];
map<ll,ll> mp;
ll extgcd(ll a, ll b, ll& x, ll& y) {//ax+by=1
  if (b == 0) {
    x = 1, y = 0; return a;
  }
  ll q = a/b, g = extgcd(b, a - q*b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}

ll invmod (ll a, ll m) { // a^-1 mod m
  ll x, y;
  extgcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
ll A[10010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        ll a=A[i];
        for(ll j=2;j*j<=a;j++){
            if(a%j!=0)continue;
            while(a%j==0){
                a/=j;
                dividers[i][j]++;
            }
            mp[j]=max(mp[j],dividers[i][j]);
        }
        if(a!=1){
            dividers[i][a]=1;
            mp[a]=max(mp[a],1ll);
        }
    }
    ll lcm=1;
    for(auto o:mp){
        lcm=lcm*(ll)pow(o.first,o.second)%MOD;
    }
    ll ans=0;
    for(ll i=0;i<N;i++){
        ll B_i=lcm*invmod(A[i],MOD)%MOD;
        /*for(auto o:dividers[i]){
            B_i=B_i*invmod(pow(o.first,o.second),MOD)%MOD;
            //B_i=B_i*(ll)pow(divider,mp[divider]-o.second)%MOD;
        }*/
        ans=(ans+B_i)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long k;
    cin >> n >> k;
    k--;
    long long ans = -1e18;
    vector<long long>v(n + 3);
    vector<int>p(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    for(int i = 1; i <= n; i++){
        vector<long long>pref;
        vector<int>vis(n + 3, 0);
        int x = i;
        long long sum = 0;
        while(1 == 1){
            if(vis[p[x]] == 1){
                break;
            }
            vis[p[x]] = 1;
            sum = sum + v[p[x]];
            pref.push_back(sum);
            x = p[x];
        }
        long long r = (long long)pref.size();
        vector<long long>mx(r + 3);
        mx[0] = pref[0];
        for(long long j = 1; j < r; j++){
            mx[j] = max(mx[j - 1], pref[j]);
        }
        long long cur = max(mx[min(k, r - 1)], (k/r) * pref[r - 1] + mx[k % r]);
        ans = max(ans, cur);
    }
    cout << ans;
    return 0;
}

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

int main(){
    string s; cin>>s;
 
    bool check1=false;
    bool check2=false;
    bool check3=false;
  
  if(s[0]=='A') check1=true;
  
  string t=s.substr(2,s.size()-3);
   int count1=0;
  int count2=0;
  for(int i=0;i<t.size();i++){
    if(t[i]=='C')count1++;
  }
    for(int i=0;i<s.size();i++){
      if(s[i]>='A'&&s[i]<='Z')count2++;
    }
  
      
  if(count1==1)check2=true;
  if(count2==2)check3=true;
  
 
   if(check1&&check2&&check3)cout<<"AC"<<endl;
   else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());
        int k = Integer.parseInt(scanner.next());

        System.out.print(k * (int) (Math.pow(k -1, n -1)));


    }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

long long int gcd(long long int m, long long int n) {
	int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main() {
  long long int A, B;
  long long int C, D;

  cin >> A >> B >> C >> D;

  long long int E = C/gcd(C, D)*D;
  long long int A_=A-1;

  cout << (B-A_)-((B/C-A_/C) + (B/D-A_/D) - (B/E-A_/E)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <iostream>
#include <set>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
using namespace std;
int main() {
	string S;
	cin >> S;
	int suwako = 0;
	for (int i = 0; i < S.size(); i++) {
		suwako = suwako + ((S.at(i)) - '0');
	}
	if (suwako % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using namespace std;

long long calc(int x)
{
    long long i, c = 0;
    long long res = 0;
    for (i = 1; i * 10 <= x; i *= 10){
        res += 9 * (++c) * i;
    }
    return ((x - i + 1) * (++c) + res);
}

int main()
{
    int n, k;
    
    while (scanf("%d %d", &n, &k) && n){
        int l = 0, r = 1000000000;
        
        while (l != r){
            int mid = (l + r + 1) >> 1;
            
            if (calc(mid) >= n) r = mid - 1;
            else l = mid;
        }
        int sum = calc(l);
        for (int i = l + 1; ; i++){
            char s[128];
            sprintf(s, "%d", i);
            for (int j = 0; s[j]; j++){
                ++sum;
                if (n <= sum && sum <= n + k - 1) printf("%c", s[j]);
            }
            if (sum > n + k - 1) break;
        }
        printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 1196
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;

	auto cnt = new long[](N);
	foreach (x; 1..N+1)
	{
		auto x2 = x^^2;
		if (x2 > N) break;
		foreach (y; 1..N+1)
		{
			auto y2 = y^^2;
			if (x2 + y2 + x*y > N) break;
			foreach (z; 1..N)
			{
				auto z2 = z^^2;
				auto a = x2 + y2 + z2 + x*y + y*z + z*x;
				if (a > N) break;
				++cnt[a-1];
			}
		}
	}

	foreach (i; 0..N)
	{
		writeln(cnt[i]);
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define INF 1234567891
#define MAXS 107

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INP freopen("input.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

bool funct(pair<int, pair<string, int> >a, pair <int, pair<string, int> >b){
  if(a.second.first == b.second.first){
    return a.second.second > b.second.second;
  }
  else return a.second.first < b.second.first;
}


pair <int, pair<string, int> > lista[MAXS];


int main(){
  int n;cin >> n;
  int b; string a;
  for(int i = 1 ; i <= n; ++i){
    cin >> a >> b;
    lista[i] = mp(i, mp(a, b));
  }
  sort(lista+1, lista+n+1, funct);
  for(int i = 1; i <= n; ++i){
    cout << lista[i].first << "\n";
  }
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	vi s(n), f(n);
	rep(i, 0, n) {
		cin >> s[i] >> f[i];
	}
	rep(i, 0, n) {
		if (a == s[i] || b == f[i]) {
			cout << 1 << endl;
			return 0;
		}
		else if ((s[i] < a&&a < f[i]) || (s[i] < b&&b < f[i])) {
			cout << 1 << endl;
			return 0;
		}
		else if ((a < s[i] && f[i] < b) || (a < s[i] && f[i] < b)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}



Measured memory_bytes: 3100
/* ex 5_4
   kanon */

#include <stdio.h>
#include <string.h>
#define SIZE 80

int main(void)
{
    //与えられる値を入れる数を宣言
    char str[SIZE], *ptr;
    int longest_len = 0, temp_len = 0;

    //変数に値を入力する
    scanf("%s", str);

    //文字列内で探索
    ptr = &str[0];

    while (*ptr != '\0')
    {
        //ATCGならtemp_lenを更新していく
        if (*ptr == 'A' || *ptr == 'T' || *ptr == 'C' || *ptr == 'G')
        {
            temp_len++;
        }
        /*ATCGでないなら更新をやめてtemp_len=0とする。
        このときもし、temp_lenの長さが今までの最長ATCG列longest_lenより
        長いならlongest_lenを更新する*/
        else
        {
            if (temp_len > longest_len)
                longest_len = temp_len;

            temp_len = 0;
        }
        //ポインタを次の文字にずらしていく
        ptr++;
    }

    if (temp_len > longest_len)
        longest_len = temp_len;

    //答えを出力
    printf("%d\n", longest_len);
    return 0;
}

Measured memory_bytes: 1736
a = int(input())
alist = [int(b) for b in input().split()]

totalsum = sum(alist)
leftsum = 0
fans = 100000000

for i in range(a):
    leftsum += alist[i]
    rightsum = totalsum - leftsum
    ans = abs(leftsum - rightsum)

    if fans > ans:
        fans = ans


print(fans)

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

int main(){
  int n, score_t=0, score_h=0;
  cin >> n;
  for(int i=0; i<n; i++){
    string t, h;
    cin >> t >> h;
    if(t == h){
      score_t++;
      score_h++;
    }else if(t > h)
      score_t+=3;
    else
      score_h+=3;
  }
  cout << score_t << " " << score_h << endl;
  return 0;
}



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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int flag[1000005];
bool check[1000005];

int main()
{
    int n;
    cin >> n;
    int arr[n];
    REP(i,n) cin >> arr[i];
    sort(arr,arr+n);
    REP(i,n) flag[arr[i]]++;
    int ans = 0;
    REP(i,n){
        if(!check[arr[i]]) {
            for(int j=arr[i];j<=1e6;j+=arr[i]) check[j]=true;
            if(flag[arr[i]]==1) ans++;
        }
    }
    cout << ans;
}


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

using namespace std;

int x[1000];
int temp[1000];
void MargeSort(int x[],int left,int right){
    int i,j,mid,k;
    if(left>=right)return;
    mid=(left+right)/2;
    MargeSort(x,left,mid);
    MargeSort(x,mid+1,right);
    for(i=left;i<=mid;i++){
        temp[i]=x[i];
    }
    for(i=mid+1,j=right;i<=right;i++,j--){
        temp[i]=x[j];
    }
    i=left; j=right;
    for(k=left;k<=right;k++){
        if(temp[i]>=temp[j])x[k]=temp[i++];
        else x[k]=temp[j--];
    }
}

int main(){
    int num=10;
    for(int i=0;i<num;i++){
        cin>>x[i];
    }
    MargeSort(x,0,num-1);
    for(int i=0;i<3;i++){
        cout<<x[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int n,k;
char s[200005];
int nxt[26];
void gonext(int i){
    while(nxt[i]<n&&s[nxt[i]]!='a'+i)nxt[i]++;
}
int bit[200005];
void add(int i,int x){
    i++;
    while(i<=n){
        bit[i]+=x;
        i+=i&(-i);
    }
}
int sum(int i){
    i++;
    int res=0;
    while(i>0){
        res+=bit[i];
        i-=i&(-i);
    }
    return res;
}
int main(void){
    cin>>s>>k;
    n=strlen(s);
    for(int i=0;i<26;i++){
        gonext(i);
    }
    for(int i=0;i<n;i++)add(i,1);
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            if(nxt[j]==n)continue;
            if(sum(nxt[j]-1)<=k){
                k-=sum(nxt[j]-1);
                cout<<s[nxt[j]];
                add(nxt[j],-1);
                nxt[j]++;
                gonext(j);
                break;
            }
        }
    }
    cout<<endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  int n,weight;
  cin>>n>>weight;
  vll v(n),w(n);
  rep(i,n)cin>>v.at(i)>>w.at(i);
  vvll dp(n+1,vll(weight+1));
  
  rep(i,weight+1)dp.at(0).at(i)=0;
  rep(i,n){
      rep(j,weight+1){
      if(j-w.at(i)>=0){
          dp.at(i+1).at(j)=max(dp.at(i).at(j),dp.at(i+1).at(j-w.at(i))+v.at(i));
      }else{
          dp.at(i+1).at(j)=dp.at(i).at(j);
      }//cout<<i<<" "<<j<<" "<<dp.at(i).at(j)<<endl;
  }
  }
  cout<<dp.at(n).at(weight)<<endl;
}
  

   
    

   



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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

int main(void){
	int N;
	cin >> N;
	int A[200];
	rep(i, N) cin >> A[i];

	int ans = 0;
	while(1){
		rep(i, N){
			if(A[i] % 2 == 1){
				printf("%d\n", ans);
				return 0;
			}
			A[i] /= 2;
		}
		ans++;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	int res = 0;
	int a[10]; cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];

	for (int i = 1; i <= 5; i++) if (a[i] % 10 == 0) res += a[i] ; else res +=( (a[i] / 10) * 10 + 10);

	int p = 0; for (int i = 1; i <= 5; i++) if (a[i] % 10 != 0) p = 1;
	if (p == 1) {
        
        for(int i= 1; i<= 5; i++) if(a[i] % 10 == 0) a[i] = 9;
      
        p = 10 - min(a[1] % 10, min(a[2] % 10, min(a[3] % 10, min(a[4] % 10, a[5] % 10))));
    }
    res -= p;
	cout << res << endl;
}

Measured memory_bytes: 256
#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;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

const int MAXN = 1e5 + 5;

vector< vector< int > > a(MAXN);

int block[MAXN];

int vis[MAXN];

int tot;

vector< int > seq;

void dfs(int u,int ref) {
	vis[u] = 1;
	tot++;
	block[u] = ref;
	seq.pb(u);
	for(auto v : a[u]) {
		if(!vis[v]) {
			dfs(v , ref);
		}
	}
}

void solve()
{
	int n , m , k;
	
	cin >> n >> m >> k;
	
	int ref = 0;
	
	int u , v;
	
	vector< vector< int >> b(MAXN);
	
	for(int i = 0; i < m; ++i) {
		cin >> u >> v;
		a[v].pb(u);
		a[u].pb(v);
		b[v].pb(u);
		b[u].pb(v);
	}
	
	for(int i = 0; i < k; ++i) {
		cin >> u >> v;
		
		b[v].pb(u);
		b[u].pb(v);
	}
	
	int ans[n+1] {};
	
	for(int i = 1; i <= n; ++i) {
		if(!vis[i]) {
			tot = 0;
			dfs(i , ref);
		
			for(auto j : seq) {
				ans[j] = tot-1;
			}
			
			for(auto j : seq) {
				for(auto z : b[j]) {
					if(block[z] == ref) {
						ans[z]--;
					}
				}
			}
			
			ref++;
			
			seq.clear();
		}
	}
	
	for(int i = 1; i <= n; ++i) {
		cout << ans[i] << " ";
	}
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 23016
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int mod = 2019;
int main() {
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    map<int,int>mp;
    mp[0] = 1;
    int cur = 1;
    ll ans = 0;
    int x = 0;
    rep(i,s.size()) {
        x += (s[i]-'0')*cur;
        x %= mod;
        ans += mp[x];
        mp[x]++;
        cur *= 10;
        cur %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, d;
   cin >> n >> d;
   vector<vector<int>> X(n, vector<int>(d));
   rep(i, 0, n) {
      rep(j, 0, d) { cin >> X[i][j]; }
   }
   hr();
   int ans = 0;
   rep(i, 0, n) {
      rep(j, 0, i) {
         int norm2 = 0;
         rep(k, 0, d) { norm2 += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]); }
         int norm = sqrt(norm2) + 0.3;
         if (norm * norm == norm2) ans++;
      }
   }
   cout << ans << endl;
   return 0;
}

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

int main(void)
{
    bool student[30] = { false };
    
    int tmp;
    for (int i = 0; i < 28; i++){
        scanf("%d", &tmp);
        student[tmp - 1] = true;
    }
    
    for (int i = 0; i < 30; i++){
        if (!student[i]){
            printf("%d\n", i + 1);
        }
    }
    return (0);
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public class Node
	{
		public Dictionary<int, long> Connections{get;set;}
		public int Index {get;set;}
		public long Offset {get;set;}
		public bool Visited {get;set;}
	}
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var nodes = new Node[n];
		for(int i = 0; i < n; i++)
		{
			nodes[i] = new Node() {Index = i, Connections = new Dictionary<int, long>()};
		}
		//var edges = new Edge[n-1];
		for(int i = 0; i < n-1; i++)
		{
			var p = Input();
			var a = p[0].ToInt()-1;
			var b = p[1].ToInt()-1;
			var d = p[2].ToLong();
			//edges[i] = new Edge(){Distance = p[2].ToLong(), Connections = new List<int>()};
			//edges[i].Connections.Add(p[0].ToInt()-1);
			//edges[i].Connections.Add(p[1].ToInt()-1);
			nodes[a].Connections.Add(b, d);
			nodes[b].Connections.Add(a, d);
		}
		var qk = Input().ToInt();
		var q = qk[0];
		var k = qk[1];
		CalcOffset(nodes, k-1, 0);
		
		for(int i = 0; i < q; i++)
		{
			var xy = Input().ToInt();
			var x = xy[0] - 1;
			var y = xy[1] - 1;
			Console.WriteLine(nodes[x].Offset + nodes[y].Offset);
		}
	}
	
	private static void CalcOffset(Node[] nodes, int index, long deep)
	{
		if(nodes[index].Visited)
			return;
		nodes[index].Offset = deep;
		nodes[index].Visited = true;
		foreach(var key in nodes[index].Connections.Keys)
		{
			if(key != index)
				CalcOffset(nodes, key, nodes[index].Connections[key] + deep);
		}
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 65376
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    int64_t ans=0, cnt;

    for(int i = 1; i < N; i++){
        cnt = 0;
        for(int j = 1; j <= (int)sqrt(i); j++){
            if(i % j == 0) cnt++;
        }
        cnt *= 2;
        if(i == (int)sqrt(i) * (int)sqrt(i)) cnt--;
        ans += cnt;
    }

    cout << ans << endl;
}


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

using ll=long long;



void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    vector<int> A(3);
    A[0]=abs(a-b);
    A[1]=abs(b-c);
    A[2]=abs(c-a);
    sort(A.begin(), A.end());
    cout<<A[0]+A[1]<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A=sorted(A,reverse=True)
ans=0
for i in range(1,N):
    ans+=A[i//2]
print(ans)






        




    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B&&B!=C){
    cout<<"Yes"<<endl;
  }
  else if(A==C&&A!=B){
    cout<<"Yes"<<endl;
  }
  else if(C==B&&B!=A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll k;
  cin>>k;
  ll n=max((ll)2,(k+9999999999999999)/10000000000000000);
  cout<<n<<endl;
  ll b=k/n;
  ll c=k%n;
  rep(i,0,n-c){
    cout<<n-1+b*n-(k-b)<<' ';
  }
  rep(j,0,c){
    cout<<n-1+(b+1)*n-(k-b-1);
    if(j==c-1) cout<<endl;
    else cout<<' ';
  }
}

Measured memory_bytes: 256
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift() * 1
l = inp.shift().split(' ')
sum = 0
a = []
for (i=0; i<N; i++) {
    sum += l[i] * 1
    a[i] = sum
}
min = Infinity
for (i=0; i<N-1; i++) {
    d = Math.abs(a[i] - (sum - a[i]))
    if (min > d) {
        min = d
    } 
}
console.log(min)

Measured memory_bytes: 35908
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n,date;
  int sta[2];
  cin >> n;
  while(n--){
    bool f = true;
    sta[0] = 0;
    sta[1] = 0;
    for(int i = 0;i < 10 ; i++){
      cin >> date;
      if(date > sta[0])sta[0] = date;
      else if(date > sta[1])sta[1] = date;
      else f = false;
    }
    if(f)puts("YES");
    else puts("NO");
  }
  return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int N;
  int K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i < N; i++)
    cin >> l[i];

  sort(l.begin(), l.end());
  int sum = 0;
  for(int i = N-K; i < N; i++){
    sum += l[i];
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table


t,_ = sieve(100005)
m = [0]
cnt = 0
for i in range(100005):
    #分かりにくいけど奇数時のiは偶数です
    if i%2==0 and t[i] and t[(1+i)//2]:
        cnt+=1
    m.append(cnt)


Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(m[r] - m[l-1])


Measured memory_bytes: 5396
import sys

[num, values] = sys.stdin.readlines()
values = [int(x) for x in values.split()]

min_value = 999999999999
max_value = -999999999999
total_value = 0

for value in values:
    if value < min_value:
        min_value = value
    if max_value < value:
        max_value = value

    total_value += value

print("{0} {1} {2}".format(min_value, max_value, total_value))

Measured memory_bytes: 7088
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>

using namespace std;

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

ll pow_5(ll num)
{
  ll ret = 1;
  for (int i = 0; i < 5; i++)
  {
    ret *= num;
  }
  return ret;
}

int main()
{
  ll x;
  cin >> x;
  // vector<vector<ll>> fig(2001, 2001);
  for (int i = -1000; i <= 1000; i++)
  {
    for (int j = -1000; j <= 1000; j++)
    {
      // fig[i+1000][j+1000] = pow_5(i) - pow_5(j);
      ll k = pow_5(i) - pow_5(j);
      if (k == x)
      {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string s; cin >> s;
	bool c = false;
	bool f = false;

	REP(i, s.length()){
		if(s[i] == 'C' and c == false) c = true;
		else if(s[i] == 'F' and c == true) f = true;
	}

	if(c == true and f == true) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;

}


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

const long long INF = 10000000000000007;
const int MAX_A = 51;
const int MAX_N = 51;

struct edge{ 
    int to; int a; long long b; 
    edge(int _to, int _a, long long _b): to(_to), a(_a), b(_b) {} 
};



typedef pair<int,int> P;

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<edge>> G(N);
    vector<long long> C(N), D(N);
    long long SumA = 0;
    for(int i = 0; i < M; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G[u].push_back(edge(v, a, b));
        G[v].push_back(edge(u, a, b));
        SumA += a;
    }
    for(int i = 0; i < N; ++i) {
        cin >> C[i] >> D[i];
    }

    // 各町ごとに、銀貨の枚数が0 ~ Amax×(N-1)
    vector<vector<long long>> State(N, vector<long long>(SumA + 1, INF));
    priority_queue<P, vector<P>, greater<P> > que;

    // que.second = K -> i = K/(Amax*(N-1) + 1), j = K%(Amax*(N-1) + 1)
    int Row_size = SumA + 1;
    S = min((long long)S, SumA); // 銀貨をAmax*(N-1)枚になるまで捨てる
    State[0][S] = 0;
    que.push(P(0, Row_size*0 + S));
    while(!que.empty()){
        P q = que.top(); que.pop();
        int City = q.second/Row_size; 
        long long Money = q.second - City*Row_size;
        if(State[City][Money] < q.first) continue;
        for(int i = 0; i < G[City].size(); ++i) {
            edge e = G[City][i];
            // 購入するときの遷移 (多分ここでTLEになってそう)
            for(int j = 1; ; ++j) { 
                // j := 交換する金貨
                // 消費する時間は j*D[City]
                // 得られる銀貨は j*C[City]
                long long nM = min(SumA, Money + C[City]*j);
                if(State[City][nM] > State[City][Money] + D[City]*j) {
                    State[City][nM] = State[City][Money] + D[City]*j;
                    que.push(P(State[City][nM], City*Row_size + nM));
                }
                else { break; } // 基本的に、同じ頂点に対して、お金を増やす遷移をして、ある程度お金を増やしたら効果はなくなると考えられる
                if(nM >= SumA) break;
            }
            // 移動するときの遷移
            long long nM = Money - e.a;
            if(nM < 0) continue;
            if(State[e.to][nM] > State[City][Money] + e.b) {
                State[e.to][nM] = State[City][Money] + e.b;
                que.push(P(State[e.to][nM], e.to*Row_size + nM));
            }
        }
    }
    for(int i = 1; i < N; ++i) {
        auto &p = State[i];
        cout << *min_element(p.begin(), p.end()) << endl;
    }
    return 0;
}

Measured memory_bytes: 20632
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);

    vector<int> rank(9,0);

    for (int i = 0; i < N; i++) {
        int rate;
        cin >> rate;
        if (rate>=3200) rate=3200;
        rank[rate/400]++;
    }

    int low = 0;

    for (int i = 0; i < 8; i++) {
        if( rank[i] > 0 ) {
            low++;
        }
    }

    cout << max(low,1) << " " << max(low+rank[8],1) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;


void solve(){

    string s,t;
    cin >> s >> t;
    ll n = s.size();
    bool b=true;
    rep(i,n){
        if(s[i]!=t[i]) b=false;
    }
    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;
    

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
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 main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, A, B; cin >> N >> A >> B;
  
  //main
  ll ans = 0; ll Q = N/(A+B); ll R = N%(A+B);
  ans += A*Q;
  if(R<A){
    ans += R; 
  }else{
    ans += A; 
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def f(n, a_list):
    a_list = list(zip(range(n), a_list))
    a_list.sort(key=lambda x: x[1])
    # a_list[j][0]: (j + 1)番目に小さい活発度をもつ幼児の座標
    # a_list[j][1]: ↑の活発度
    dp = [0]
    # dp[x]: x 人を左, (k - x) 人を右に置く場合
    for k in range(1, n + 1):
        dp_ = []
        i, a = a_list.pop()  # i: 座標, a: 活発度
        dp_.append(dp[0] + a * (n - k - i))
        for x in range(1, k):
            dp_.append(max(dp[x - 1] + a * (i - x + 1),
                           dp[x] + a * (n - k + x - i)))
        dp_.append(dp[k - 1] + a * (i - k + 1))
        dp = dp_
    return max(dp)


if __name__ == '__main__':
    n = int(input())
    a_list = list(map(int, input().split()))
    print(f(n, a_list))


Measured memory_bytes: 9380
import bisect

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0

A,B,C = sorted(A),sorted(B),sorted(C)

for b in B:
  a = bisect.bisect_left(A,b)
  c = bisect.bisect_right(C,b)
  ans += a*(N-c)
  
print(ans)

Measured memory_bytes: 29512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    ll N,K;
    cin >> N >> K;
    vector<int> h(N);
    vector<ll> cost(N,INF);
    cost[0] = 0;
    rep(i,N) cin >> h[i];

    rep(i,N){
        rep(j,K){
            if(i + j + 1 >= N) break;
            cost[i + j + 1] = min(cost[i + j + 1],abs(h[i + j + 1] - h[i])+cost[i]);
        }
    }
    cout << cost[N - 1] << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    char s[111];
    unsigned long long int k;
    scanf("%s", s);
    scanf("%lld", &k);
    unsigned long long int i;
    for (i = 0; i < k; i++)
    {
        if (s[i] != '1')
        {
            printf("%c\n", s[i]);
            return 0;
        }
    }
    printf("1\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl p(n);
    ll sum = 0;
    rep(i, n) {
        cin >> p[i];
        sum += p[i];
    }
    sort(rall(p));

    out(sum - p[0]/2);
    re0;
}

Measured memory_bytes: 256
package main
import "fmt"
import "sort"
var (
    index int
)
func main() {
fmt.Scanf("%d", &index)
index *= 2
        p := make([]int, index)
for i := 0; i < index; i++ {
        fmt.Scanf("%d", &p[i])
}
sort.Sort(sort.Reverse(sort.IntSlice(p)))
sum := 0
for i := 1; i < index; i+=2 {
sum += p[i]
}
fmt.Println(sum)
}

Measured memory_bytes: 640
N, M = map(int, input().split())
students = [list(map(int,input().split())) for _ in range(N)]
checkpoints = [list(map(int,input().split())) for _ in range(M)]

for x, y in students:
    distance = float('inf')

    for i in range(M):
        gx, gy = checkpoints[i][0], checkpoints[i][1]
        tmp_dis = abs(x - gx) + abs(y - gy)
        if tmp_dis < distance:
            distance = tmp_dis
            ans = i + 1
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]) pr("Yes");
  else pr("No");

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
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.regex : regex;
import std.container;
import std.bigint;


void main()
{
  (48-readln.chomp.to!int).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

struct node{
    vector<ll> child;
    ll counter = 0;
};

vector<node> tree(200020);

void dfs(ll crnt_node, ll parent){
    tree[crnt_node].counter += tree[parent].counter;

    rep(i, tree[crnt_node].child.size()){
        ll next_node = tree[crnt_node].child[i];
        if(next_node == parent)continue;
        dfs(next_node, crnt_node);
    }
}

int main(){
    ll n, q;
    cin >> n >> q;

    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;

        tree[a].child.push_back(b);
        tree[b].child.push_back(a);
    }

    rep(i, q){
        ll p, x;
        cin >> p >> x;
        p--;

        tree[p].counter += x;
    }

    rep(i, tree[0].child.size()){
        ll next_node = tree[0].child[i];
        dfs(next_node, 0);
    }

    rep(i, n)cout << tree[i].counter << " ";
}

Measured memory_bytes: 24320
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    double d,t,s;
    cin>>d>>t>>s;
    double ans=d/s;
    if(ans<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int N = 50007;
const int M = 500;
const int B = 207;

int main()
{
	int a,b;cin>>a>>b;
	if(a <= 9 && b <= 9) cout<<a*b<<endl;
	else cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B, C; std::cin >> A >> B >> C;
  if ( C >= A && C <= B ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
a=[]
for i in range(h):
  a.append(list("."+(input())+"."))
a.insert(0,["."]*(w+2))
a.append(["."]*(w+2))
flg = True
for i in range(h+2):
  for j in range(w+2):
    if a[i][j] == "#":
      for (k,l) in ((i,j+1),(i,j-1),(i+1,j),(i-1,j)):
        if a[k][l] != "#":
          cnt+=1
          if cnt == 4:
            flg = False
    cnt=0
if flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: usize,
      hs: [usize; n],
    }

    let mut ans = 0;
    for h in hs {
        if h >= k {
            ans += 1;
        }
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    string n,t;
    bool ans=false;
    cin >> n >> t;
    rep(i,n.size()){
        if(n==t)
            ans=true;
        n =n.back()+n.substr(0,n.size()-1);
    }
    if(ans)
        cout << "Yes" << endl;
    else
            cout << "No" << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<string,int> s;
  vector<string> b(n);
  rep(i,n){
   string a;
    cin >> a;
    b[i] = a;
    s[a]++;
  }
  //cout << b[1] << endl;
  //cout << s << endl;
  int maxim =0;
  for (auto p : s) {
  auto k = p.first;
  auto v = p.second;
    if(maxim < v) maxim = v;
  //cout << k << " => " << v << endl;
}
  for (auto p : s) {
  auto k = p.first;
  auto v = p.second;
    if(v == maxim) cout << k << endl;
}
}


Measured memory_bytes: 25092
w = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
ans = [0] * 26
word = 'Yes'
for i in w:
  ans[alpha.index(i)] += 1

for i in ans:
  if i % 2 == 0:
    pass
  else:
    word = 'No'
    break

print(word)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n, a, b, sum = 0, ovsum = 0;
    string s;
    cin >> n >> a >> b >> s;
    rep(i, s.size()){
        if(sum < a + b && s[i] == 'a'){
            cout << "Yes" << endl;
            sum++;
        }else if(s[i] == 'b' && sum < a + b && ovsum < b){
            cout << "Yes" << endl;
            sum++; ovsum++;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896