akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void) {
	int n = 0;
	vector<string> r;
	scanf("%d",&n);
	for(int i=0; i<n; i++)
	{
		int a[10];
		scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
		int ca=a[0],cb=0;
		for (int j=1; j<=9; j++)
		{
			if (ca >= cb){
				if (ca < a[j])
				{
					ca = a[j];
				} else if(cb < a[j]) {
					cb = a[j];
				} else {
					r.push_back("NO");
					break;
				}
			} else {
				if (cb < a[j])
				{
					cb = a[j];
				} else if(ca < a[j]) {
					ca = a[j];
				} else {
					r.push_back("NO");
					break;
				}
			}
			if (j==9){r.push_back("YES");break;}
		}
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
stones = input()
white = 0
black = 0
for i in range(N):
    if stones[i] == '.':
        white += 1
ans = white
for i in range(N):
    if stones[i] == '#':
        black += 1
    else:
        white -= 1
    if ans > black + white:
        ans = black + white
print(ans)


Measured memory_bytes: 3500
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

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

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

pub trait LexicalPermutation {
  /// Return `true` if the slice was permuted, `false` if it is already
  /// at the last ordered permutation.
  fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
  /// Original author in Rust: Thomas Backman <serenity@exscape.org>
  fn next_permutation(&mut self) -> bool {
    // These cases only have 1 permutation each, so we can't do anything.
    if self.len() < 2 { return false; }

    // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
    let mut i = self.len() - 1;
    while i > 0 && self[i-1] >= self[i] {
      i -= 1;
    }

    // If that is the entire vector, this is the last-ordered permutation.
    if i == 0 {
      return false;
    }

    // Step 2: Find the rightmost element larger than the pivot (i-1)
    let mut j = self.len() - 1;
    while j >= i && self[j] <= self[i-1]  {
      j -= 1;
    }

    // Step 3: Swap that element with the pivot
    self.swap(j, i-1);

    // Step 4: Reverse the (previously) weakly decreasing part
    self[i..].reverse();

    true
  }
}
fn main() {
  let l: f64 = read();
  let ans = (l/3.0) * (l/3.0) * (l/3.0);
  println!("{}", ans);
}

Measured memory_bytes: 4352
// Distance2.c
// ２つのデータがどれだけ似ているかを、それらの距離で測る手法は、
// クラスタリングや分類など、様々なところで使われています。
// ここでは、２つの n 次元ベクトル x={x1,x2,...,xn} と y={y1,y2,...,yn}
// の距離を計算してみましょう。
//
// このようなデータの距離を測る指標のひとつとして、次のミンコフスキー距離が知られています。 
//   Dxy=(∑i=1 to n |xi−yi|^p ) ^ (1/p)
//
// p=1 のとき 
//   Dxy= |x1−y1| + |x2−y2| + ... + |xn−yn|
//
// となり、これはマンハッタン距離とよばれます。 
//
// p=2 のとき 
//   Dxy=sqrt ( (|x1−y1|)^2 + (|x2−y2|)^2 + ... + (|xn−yn|)^2) 
//
// となり、これは一般的に使われるユークリッド距離になります。 
//
// p=∞ のとき 
//   Dxy=max i=1 to n (|xi−yi|)
//
// となり、これはチェビシェフ距離と呼ばれます。
//
// ２つの n 次元ベクトルが与えられるので、p がそれぞれ 1、2、3、∞ の
// ミンコフスキー距離を求めるプログラムを作成してください。
//
// 【入力】
// １行目に整数 n が与えられます。２行目にベクトル x の要素 {x1,x2,...xn}、
// ３行目にベクトル y の要素 {y1,y2,...yn} が空白区切りで与えられます。
// 入力はすべて整数値です。
// 【出力】
// p がそれぞれ 1、2、3、∞ の順番にそれぞれ１行に距離を出力してください。
// ただし、0.00001 以下の誤差があってもよいものとします。
// 【制約】
// ・1≤n≤100
// ・0≤xi,yi≤1000
// 【例】
// 入力：
// 3
// 1 2 3
// 2 0 4
// 出力：
// 4.000000
// 2.449490
// 2.154435
// 2.000000
#include<stdio.h>
#include<math.h>

int main( void) {
  int n;
  int x[100];
  int y[100];
  double Dxy, maxDxy;

  scanf( "%d", &n);

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

  // p = 1の時
  Dxy = 0;
  for ( int i = 0; i < n; i++) {
    Dxy += fabs( (double)(x[i] - y[i]));
  }
  printf( "%.6lf\n", Dxy);

  // p = 2の時
  Dxy = 0;
  for ( int i = 0; i < n; i++) {
    Dxy += pow( fabs( x[i] - y[i]), 2);
  }
  Dxy = sqrt( Dxy);
  printf( "%.6lf\n", Dxy);

  // p = 3の時
  Dxy = 0;
  for ( int i = 0; i < n; i++) {
    Dxy += pow( fabs( x[i] - y[i]), 3);
  }
  Dxy = pow( Dxy, (double)1/3);
  printf( "%.6lf\n", Dxy);
  
  // p = ∞の時
  maxDxy = 0;
  for ( int i = 0; i < n; i++) {
    Dxy = fabs( (double)(x[i] - y[i]));
    if ( Dxy > maxDxy) maxDxy = Dxy;
  }
  printf( "%.6lf\n", maxDxy);

  return 0;
}



Measured memory_bytes: 2048
t = x = y = 0
T = [0]
X = [0]
Y = [0]

N = int(input())
for i in range(N):
    t,x,y = map(int,input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

f = True
d = s = 0
for i in range(N):
    d = (T[i+1]-T[i]) - abs(X[i+1]-X[i]) - abs(Y[i+1]-Y[i])
    if f and d >= 0 and d%2 == 0:
        f = True
    else:
        f = False

if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11816
// Problem : C - Count Order
// Contest : AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_c
// Memory Limit : 1024,000000 MB
// Time Limit : 2000,000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <cmath>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>

using namespace std;

int n;

vector<int> p;
vector<int> q;

void input() {
  cin >> n;

  p = vector<int>(n);
  for (auto &&i : p)
    cin >> i;

  q = vector<int>(n);
  for (auto &&i : q)
    cin >> i;
}

void solve1() {
  int first = 0;

  auto tmp = p;
  iota(tmp.begin(), tmp.end(), 1);

  while (tmp != p) {
    ++first;

    next_permutation(tmp.begin(), tmp.end());
  }

  int second = 0;

  iota(tmp.begin(), tmp.end(), 1);

  while (tmp != q) {
    ++second;

    next_permutation(tmp.begin(), tmp.end());
  }

  cout << abs(first - second);
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;

  input();
  solve1();
}


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

#define pb push_back
#define ff first
#define ss second

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

int a, b, c;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	cout << min(min(a + b, b + c), c + a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pi 3.1415926536
#define loopj(n) for(int j=0;j<n;j++)
#define loopi(a,b,k) for(int i=a;i<b;i=i+k)
#define  deb(x) cout<<#x<<"  "<<x<<endl
int main()
{
	string n;
	cin>>n;
	ll sum=0;
	loopj(n.size())
	{
		sum+=(n[j]-'0');
	}
	if(sum%9==0)
	cout<<"Yes";
	else
	cout<<"No";
}

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

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

const int N = 2e6+10 , mod = 1e9+7;

int fac[N] , pw[N] , rev[N];

inline int p(int x , int y){
   int ret = 1;
   for( ; y ; y /= 2){
      if(y & 1)
         ret = 1ll * ret * x % mod;
      x = 1ll * x * x % mod;
   }
   return ret;
}

int c(int x , int y){
   return 1ll * fac[y] * rev[x] % mod * rev[y - x] % mod;
}

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   pw[0] = fac[0] = rev[0] = 1;
   for(int i = 1 ; i < N ; i++){
      fac[i] = 1ll * fac[i - 1] * i % mod;
      pw[i] = 1ll * pw[i - 1] * 25 % mod;
      rev[i] = p(fac[i] , mod - 2);
   }
   int k;
   string s;
   cin >> k >> s;
   int n = s.length();
   int ans = p(26 , n + k);
   for(int i = n - 1 ; i >= 0 ; i--){
      int val = 1ll * c(i , n + k) * pw[n + k - i] % mod;
      ans = (ans - val + mod) % mod;
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 27688
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 5000
#define X 1000000007
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
#define swap(x,y) (x^=y^=x^=y)
using namespace std;
int n,a,b,f[N+5][2],g[N+5],w[N+5][2];
I int QP(RI x,RI y) {RI t=1;W(y) y&1&&(t=1LL*t*x%X),x=1LL*x*x%X,y>>=1;return t;}
int main()
{
	RI i,j,t;if(scanf("%d%d%d",&n,&a,&b),t=QP(2,n),a>b&&swap(a,b),a==1) return printf("%d\n",t),0;
	for(f[0][0]=f[0][1]=i=1;i<=n;++i) for(j=1;j<=i;++j) j>=a&&Inc(f[i][0],f[i-j][1]),Inc(f[i][1],f[i-j][0]);
	for(g[0]=i=1;i<=n;++i) g[i]=(f[i][0]+f[i][1])%X;for(i=1;i^n;++i)
	{
		for(i<a&&(w[i][0]=1),j=1;j^min(i,a);++j) Inc(w[i][0],w[i-j][1]);
		for(i<b&&(w[i][1]=g[i-1]),j=1;j^min(i,b);++j) Inc(w[i][1],(j<=2?1LL:1LL*g[j-2])*w[i-j][0]%X);
		n-i<a&&Inc(t,X-w[i][1]),n-i<b&&Inc(t,X-1LL*w[i][0]*g[n-i-1]%X);
	}return printf("%d\n",t),0;
}

Measured memory_bytes: 3928
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

class FenwickTree
{
public:
	FenwickTree(int k)
	{
		data.resize(k);
	}

	i64 sum(int n)
	{
		i64 ans = 0;

		while (n > 0)
		{
			ans += data[n];
			n -= (n & -n);
		}

		return ans;
	}

	void add(int n, i64 num)
	{
		while (n < data.size())
		{
			data[n] += num;
			n += (n & -n);
		}
	}

	int search(i64 k)
	{
		int lo = 0, hi = data.size() - 1;
		int ans = 0;

		while (lo <= hi)
		{
			int mid = (lo + hi) / 2;

			i64 q = sum(mid);

			if (q >= k)
			{
				ans = mid;
				hi = mid - 1;
			}
			else
			{
				lo = mid + 1;
			}
		}

		return ans;
	}

private:
	vector<i64> data;
};

int main()
{
	i64 n;
	scanf("%lld", &n);

	vector<int> arr(n);

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

	vector<int> sorted = arr;

	sort(all(sorted));


	int lo = 0, hi = n - 1;

	i64 idx = n * (n + 1) / 4 + 1;
	int ans = 0;

	while (lo <= hi)
	{
		int mid = (lo + hi) / 2;

		//mid번째 보다 작은 값이 median인 구간의 개수를 센다
		vector<int> sum(n + 1);

		for (int i = 1; i <= n; i++)
		{
			if (arr[i - 1] >= sorted[mid])
				sum[i] = 1;
			else
				sum[i] = -1;
		}
		
		for (int i = 1; i <= n; i++)
			sum[i] += sum[i - 1];

		FenwickTree tree(2 * n + 1);

		i64 range = 0;

		// 임의의 l,r에 대해 sum[r] - sum[l-1] < 0 인 구간의 개수를 세야 함
		// sum[r] < sum[l-1]인 (l,r) 구간의 개수
		for (int i = 0; i <= n; i++)
		{
			tree.add(sum[i] + n, 1);
			auto c = tree.sum(sum[i] + n);

			//i+1개 중에서 c개는 내 이하 값
			range += i + 1 - c;
		}

		if (range > idx)
		{
			hi = mid - 1;
		}
		else
		{
			lo = mid + 1;
			ans = mid;
		}
	}

	printf("%d\n", sorted[ans]);

	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,m;
	cin >> n >> m;
	vector<ll> A(m), B(m), res(m);
	REP(i,m){
		cin >> A[i] >> B[i];
		A[i]--, B[i]--;
	}
	res[m-1] = (ll)n*(n-1)/2;
	UnionFind tree(n);
	for(int i=m-1; i>0; i--){
		if(!tree.issame(A[i], B[i])){
			res[i-1] = res[i] - tree.size(A[i]) * tree.size(B[i]);
		}else{
			res[i-1] = res[i];
		}		
		tree.merge(A[i], B[i]);
	}

	REP(i,m) cout << res[i] << '\n';
	return 0;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  int cnt[n+1] = {};
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    cnt[a]++;
  }
  sort(cnt,cnt+n+1,greater<int>());
  int ans = 0;
  for(int i = k; i < n+1; i++){
    ans += cnt[i];
  }
  cout << ans << endl;
}


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

int main(void){
  char S[100000];
  int mozisu;
  int min;
  int kazu = 0;
  int i;
  char kurosiro = '0';

  scanf("%s",S);

  for(i=0;S[i]!='\0';i++);
  mozisu = i;

  for(i=0;i<mozisu;i++){
    if(kurosiro !=S[i]){
      kazu++;
    }

    if(kurosiro == '1'){kurosiro = '0';
   }else{kurosiro = '1';}
  }



  min  = kazu;
  kurosiro = '1';
kazu = 0;

  for(i=0;i<mozisu;i++){
    if(kurosiro != S[i]){
      kazu++;
    }
    if(kurosiro == '1'){kurosiro = '0';
   }else{kurosiro = '1';}
  }

  if(kazu<min)min=kazu;

  printf("%d\n",min);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     ll i,j,n,cap;
     cin>>n>>cap;
     int wt[n+1],cost[n+1];

     for(i = 0; i < n; i++)
     {
          cin>>wt[i]>>cost[i];
     }

     ll dp[n+1][cap+1] = {};

     for(i = 1; i <= n; i++)
     {
          for(j = 1; j <= cap; j++)
          {
               if(wt[i-1] <= j)
               {
                    dp[i][j] = max(cost[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
               }
               else
                    dp[i][j] = dp[i-1][j];
          }
     }
     cout<<dp[n][cap]<<endl;
     /*for(i = 0; i <= n; i++)
     {
          for(j = 0; j <= cap; j++)
          {
               cout<<dp[i][j]<<" ";
          }
          cout<<endl;

     }*/


}



Measured memory_bytes: 79104
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int a, b, c;
	cin >> a >> b >> c;
	set <int> s;
	s.in (a);
	s.in (b);
	s.in (c);
	if (sz (s) == 2) {
		cout << "Yes" << endl;
	}
	else cout << "No";
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vi32> sums(n + 1, vi32(n + 1));
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    sums[l][r] += 1;
  }
  repc(i, n) rep(j, n) {
    sums[i][j + 1] += sums[i][j];
  }
  repc(j, n) rep(i, n) {
    sums[i + 1][j] += sums[i][j];
  }
  rep(i, q) {
    int p, q;
    cin >> p >> q;
    p -= 1;
    int ans = 0;
    ans = sums[q][q] - sums[p][q] - sums[q][p] + sums[p][p];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define lint __int128
#define vi vector<int>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E18 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    ll a ; cin >> a ; ld b ; cin >> b ;
    ld aa = a ;
    ll ans = (ll) aa * b ;
    cout << ans << endl ;
}


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

int main(){
  int64_t n,q;
  cin >> n >> q;
  vector<vector<int64_t>> tree(n,vector<int64_t>());
  rep(i,n-1){
    int64_t a,b;
    cin >> a >> b;
    tree.at(a-1).push_back(b-1);
    tree.at(b-1).push_back(a-1);
  }
  vector<pair<int64_t,int64_t>> query(q);
  vector<int64_t> pointtree(n); 
  vector<bool> ispassed(n);
  rep(i,q){
    int64_t I,P;
    cin >> I >> P;
    pointtree.at(I-1) += P;
  }
  /*rep(i,n){
    cout << pointtree.at(i) << ",";
    rep(j,tree.at(i).size()){
      cout << tree.at(i).at(j);
    }
    cout << endl;
  }
  cout << "#" << endl;*/
  queue<int64_t> dpsque;
  dpsque.push(0);
  ispassed.at(0) = true;
  while(!dpsque.empty()){
    int64_t HEAD = dpsque.front();
    //cout << HEAD << "##";
    rep(i,tree.at(HEAD).size()){
      int64_t hoge = tree.at(HEAD).at(i);
      //cout << hoge << ",";
      if(!ispassed.at(hoge)){
        ispassed.at(hoge) = true;
        pointtree.at(hoge) += pointtree.at(HEAD);
        dpsque.push(hoge);
      }
    }
    dpsque.pop();
  }
  rep(i,n){
    cout << pointtree.at(i) << endl;
  }
}
        
        
        
     

    
  

  


Measured memory_bytes: 21104
#include<stdio.h>
  
#define AMAX 20
 
int A[AMAX+1];
int n, q;

int solve( int p, int t, int res )
{
	return  ( p <= n ) ? solve( p+1, t-A[p],  !t ) || solve( p+1, t,  !t  ): res;
}

int main( void ) 
{
    int i;
    int num;
     
    scanf( "%d", &n );  
    for( i=0; i<n; i++ ) {
        scanf( "%d", &A[i] );
    }   
    scanf( "%d", &q );
    for( i=0; i<q; i++ ) {
        scanf( "%d", &num );
        if( solve( 0, num, 0 ) ) {
            printf( "yes\n" );      
        } else {
            printf( "no\n" );
        }
    }
    return 0;
}

Measured memory_bytes: 580
def count_divisor(num):
    result = 2
    for i in range(2, num):
        if num % i == 0:
            result += 1

    return result


n = int(input())
ans = 0
for i in range(9, n + 1, 2):
    if count_divisor(i) == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string S;
  cin >> S;
  int red = count(S.cbegin(), S.cend(), '0');
  int blue = count(S.cbegin(), S.cend(), '1');
  cout << min(red*2, blue*2) << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

long n;
long ans = 0;

void check(long m){
    if(m > 1 && n / m == n % m){
        ans += m;
    }
}

int main(){
    scanf("%ld", &n);
    for(long i = 1; i*i <= n; ++i){
        if(n % i == 0){
            check(n/i-1);
        }
    }
    printf("%ld\n", ans);
    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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int k, a, b; cin >> k >> a >> b;

  for(int i = 1; i*k <= b; ++i) {
    if(i*k >= a) {
      if(i*k <= b) {
	cout << "OK";
	return 0;
      }
    }
  }
  cout << "NG";
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	double a = n / (1.08);
	for (int i = int(a - 1); i <= int(a + 1); ++i) {
		if (int(i * 1.08) == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k, x;
  cin >> k >> x;
  if (500 * k >= x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int gcd(int a,int b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j++)
		{
			for(int k=j;k<=n;k++)
			{
				int x;
				if(i==j&&j==k)x=1;
				else if(i==j||j==k)x=3;
				else x=6;
				ans+=x*gcd(k,gcd(j,i));
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
public class Main {
	static long[] mmax=new long[812345];
	static long[] lazy=new long[812345];
	static void pushup(int x) {
		mmax[x]=Math.max(mmax[x<<1],mmax[x<<1|1]);
	}
	static void pushdown(int x) {
		long lz=lazy[x];
		if (lz!=0) {
			lazy[x]=0;
			mmax[x<<1]+=lz;
			mmax[x<<1|1]+=lz;
			lazy[x<<1]+=lz;
			lazy[x<<1|1]+=lz;
		}
	}
	static long query(int x,int L,int R,int l,int r) {
		if (l<=L&&r>=R) return mmax[x];
		pushdown(x);
		int m=(L+R)>>1;
		long ret=0;
		if (m>=l) ret=Math.max(ret,query(x<<1,L,m,l,r));
		if (m<r) ret=Math.max(ret,query(x<<1|1,m+1,R,l,r));
		pushup(x);
		return ret;
	}
	static void update(int x,int L,int R,int l,int r,long v) {
		if (l<=L&&r>=R) {
			mmax[x]+=v;
			lazy[x]+=v;
			return;
		}
		pushdown(x);
		int m=(L+R)>>1;
		if (m>=l) update(x<<1,L,m,l,r,v);
		if (m<r) update(x<<1|1,m+1,R,l,r,v);
		pushup(x);
	}
	public static void main(String[] args) throws IOException {
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		StringTokenizer sa=new StringTokenizer(in.readLine());
		int n=Integer.parseInt(sa.nextToken());
		int m=Integer.parseInt(sa.nextToken());
		ArrayList<Long>[] G=new ArrayList[n+1];
		for (int i=1;i<=n;++i) G[i]=new ArrayList<Long>();
		for (int i=0;i<m;++i) {
			sa=new StringTokenizer(in.readLine());
			int l=Integer.parseInt(sa.nextToken());
			int r=Integer.parseInt(sa.nextToken());
			int a=Integer.parseInt(sa.nextToken());
			if (a>=0) G[r].add(a*300000L+l);
			else G[r].add(a*300000L-l);
		}
		for (int i=1;i<=n;++i) {
			long tmp=query(1,1,n,1,i);
			update(1,1,n,i,i,tmp);
			for (int j=0;j<G[i].size();++j) {
				int l=(int)(G[i].get(j)%300000);
				long v=G[i].get(j)/300000;
				if (l<0) l=-l;
				update(1,1,n,l,i,v);
			}
		}
		out.println(Math.max(0L,mmax[1]));
		out.close();
	}
}

Measured memory_bytes: 108604
#include <iostream>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int a = X;
    int b = Y;
    int min = A * a + B * b;
    while (a > 0 || b > 0) {
        int tmp = min + C * 2 - (a > 0 ? A : 0) - (b > 0 ? B : 0);
        if (min < tmp) break;
        min = tmp;
        --a; --b;
    }
    cout << min << '\n';
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
  }
  return 0;
}




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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n+1, 0), dp(n+1, INT_MAX);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &v[i]);
    }
    dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        for(int j = 1; i-j >= 1 && j <= k; j++) {
            dp[i] = min(dp[i-j] + abs(v[i] - v[i-j]), dp[i]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    ll n, l;
    cin >> n >> l;
    ll taste_all = n * (l - 1) + n * (n + 1) / 2;

    ll min_abs = 1000;
    ll ans = 0;
    for(ll i = 1; i <= n; ++i){
        ll taste_apple = l + i - 1;
        if(abs(taste_apple) < min_abs){
            ans = taste_all - taste_apple;
            min_abs = abs(taste_apple);
        }
    }
    cout << ans << endl;
    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 repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
    ll n,m;cin >> n >>m;
    UnionFind uf(n);
    rep(i,m){
        ll x,y,z;cin >> x >> y >>z;x--;y--;
        if(!uf.same(x,y))uf.merge(x,y);
    }
    set<ll> s;
    rep(i,n){
        s.ins(uf.root(i));
    }
    cout <<s.size() <<endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using L = long long;
#define F first
#define S second
#define I XH[i]
using V= pair<L,L>;

L N,D,A,now=0,res=0,t;
V XH[200005];
queue<V>P;
int main() {cin>>N>>D>>A;for(L i=0;i<N;i++){cin>>I.F>>I.S;}sort(XH,XH+N);for(L i=0;i<N;i++){while(!P.empty()&&P.front().F<I.F){now-=P.front().S;P.pop();}I.S-=now;if(I.S>0){t=(I.S+A-1)/A;res+=t;P.push({I.F+2*D,t*A});now+=t*A;}}cout<<res;} 


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

int main()
{
    char s[3];
    cin >> s;

    int res = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            res++;
        }
    }

    cout << res << endl;
}

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

int main(void){
    int A,B,C,D,bus,train;
    cin>>A>>B>>C>>D;
    if(A>B)
        train=B;
    else
        train=A;

    if(C>D)
        bus=D;
    else
        bus=C;

    cout<<train+bus<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long[] a = in.nextLongArray(n);

            long[] tmp = new long[n + 1];
            for (int i = 0; i < n; i++) {
                tmp[i + 1] = tmp[i] + a[i];
            }

            TreeSet<Long> set = new TreeSet<>();
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    set.add(tmp[j] - tmp[i]);
                }
            }

            long ans = 0;
            for (int i = 60; i >= 0; i--) {
                int cnt = 0;
                for (long x : set) {
                    cnt += x >> i & 1;
                }
                if (cnt >= k) {
                    ans |= 1L << i;
                    TreeSet<Long> next = new TreeSet<>();
                    for (long x : set) {
                        if ((x >> i & 1) == 1) {
                            next.add(x);
                        }
                    }
                    set = next;
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextLong();
            }
            return res;
        }

    }
}



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

int main() {
	// your code goes here
	long long n, k;
	cin>>n>>k;
	if(n>k) n=n%k;
	if(n< abs(n-k))
		cout<<n;
	else
		cout<<abs(n-k);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int N;
	static int M;
	static int X[100010];
	scanf("%d",&N);
	scanf("%d",&M);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d",&X[i]);
	}
	
	static int cnt[100010] = {};
	for(int i = 1 ; i <= N ; i ++){
		cnt[X[i]] ++;
	}
	
	static int cnt_M[100010][2] = {};
	for(int i = 1 ; i <= 100000 ; i ++){
		cnt_M[i%M][0] += cnt[i]%2;
		cnt_M[i%M][1] += cnt[i]/2;
	}
	
	static int ret = 0;
	ret += cnt_M[0][0]/2;
	ret += cnt_M[0][1];
	if(M%2 == 0){
		ret += cnt_M[M/2][0]/2;
		ret += cnt_M[M/2][1];
	}
	for(int i = 1 ; i < M-i ; i ++){
		int a = min ( cnt_M[i][0] , cnt_M[M-i][0] );
		ret += a;
		cnt_M[i][0] -= a;
		cnt_M[M-i][0] -= a;
		while(cnt_M[i][0] >= 2 && cnt_M[M-i][1] >= 1){
			ret += 2;
			cnt_M[i][0] -= 2;
			cnt_M[M-i][1] -= 1;
		}
		while(cnt_M[M-i][0] >= 2 && cnt_M[i][1] >= 1){
			ret += 2;
			cnt_M[M-i][0] -= 2;
			cnt_M[i][1] -= 1;
		}
		ret += cnt_M[i][1];
		ret += cnt_M[M-i][1];
	}
	cout << ret << endl;
}



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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' ' << endl; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n;
	m = (ll)(n / 1.08);
	for (int i = m-2; i < m+3; ++i) {
    	if ((ll)(i*1.08)==n) {
        	dbg(i);
        	return 0;
        }
    }
    cout << ":(" << endl;
}


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

int main(){
    int k;
    cin >> k;
    rep(i, k) cout << "ACL";
    cout << endl;
}


Measured memory_bytes: 3660
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e18;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const double pi=acos(-1);


int main(){
    TB
    ll n,m;
    cin>>n>>m;
    ll ans=n*(n-1)/2;
    ans+=(m*(m-1)/2);
    cout<<ans<<'\n';
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    for(ll i=1; i<3501; i++)for(ll j=1; j<3501; j++){
        ll Nbc = N*i*j, bc = 4*i*j - N*(i+j);
        if(0 < bc && Nbc%bc == 0){
            cout << Nbc/bc << " " << i << " " << j << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=200005;
int a[N],cnt,n;
long long ans,s[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	std::sort(s+1,s+n+2);
	s[0]=s[1],s[n+2]=s[n+1]+1;
	for (int i=1;i<=n+2;i++){
		if (s[i]==s[i-1]) ++cnt;
		else ans=ans+1ll*cnt*(cnt-1)/2,cnt=1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
#include <vector>
    #include <list>
    #include <map>
    #include <set>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <bitset>
    #include <algorithm>
    #include <functional>
    #include <numeric>
    #include <utility>
    #include <sstream>
    #include <iostream>
    #include <iomanip>
    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    #include <ctime>
    #include <string>
    #include <climits>
    #include <tuple>
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> P;
    typedef tuple<int,int,int,int> T;
     
     
     
     
    int bit[100003],n;
    int sum(int i){
        int s=-1;
        while(i>0){
            s=max(bit[i],s);
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]=max(bit[i],x);
            i+=i&-i;
        }
    }
    int main(){
        int n;
        int a[101];
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=0;
        for(int i=0;i<n;i++){
            if(a[i]==a[i+1]){
                ans++;
                a[i+1]=-1;
            }
        
        }
        cout<<ans<<endl;

        return 0;
    }


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < n; ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long next_subset(unsigned long long subset){
	unsigned long long tem = subset + (subset & -subset);
	unsigned long long btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

inline void solve(){
	int n; cin>>n;
	if(n%10==n/100) cout<<"Yes";
	else cout<<"No";
	return;
}

inline void input(){
	return;
}

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





Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

void solution() {
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 1e6; i++) {
        int t1 = (i * 8) / 100;
        int t2 = (i * 10) / 100;
        if (t1 == a && t2 == b) {
            cout << i << endl;
            return;
        }
    }
    cout << "-1" << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

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

int main() {
  string S, T;
  cin >> S >> T;
  string ans = "No";
  // Sの長さ
  int s_length = S.length();
  // TからSの長さ分だけ取り出す
  string T_s = T.substr(0, s_length);
  int t_length = T.length();
  if (t_length == (s_length+1)) {
    if (S == T_s){
      ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;
	
	const ll mod = 1e9 + 7;
	ll dp[101][100001] = {};
	dp[0][0] = 1;

	rep(i, N) {
		int a;
		cin >> a;

		ll kari = 0;
		rep(j, a + 1) {
			kari = (kari + dp[i][j]) % mod;
			dp[i + 1][j] = kari;
		}
		for (int j = a + 1; j <= K; j++) {
			kari = (kari + dp[i][j] - dp[i][j - a - 1] + mod) % mod;
			dp[i + 1][j] = kari;
		}
	}

	co(dp[N][K]);


	Would you please return 0;
}

Measured memory_bytes: 79232
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    const N = tmp[0], M = tmp[1];
    iota(1,M/N+1).retro.filter!(x => M % x == 0).front.writeln;
}



Measured memory_bytes: 256