akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  vector<ll> p;
  rep(i, N){
    cin >> Q;
    p.push_back(Q);
  }
  sort(ALL(p));
  rep(i, p.size()-1){
    ans += p[i];
  }
  ans += p[N-1]/2;
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,n,q,a[N],b[N],c[N],freq[N];

void solve()
{
    cin>>n;
    int ans=0;
    for(i=1;i<=n;++i)
    {
        cin>>a[i];
        freq[a[i]]++;
        ans+=a[i];
    }
    cin>>q;
    while(q--)
    {
        cin>>b[i]>>c[i];
        ans-=freq[b[i]]*b[i];
        ans+=freq[b[i]]*c[i];
        freq[c[i]]+=freq[b[i]];
        freq[b[i]]=0;
        cout<<ans<<endl;
    }
}

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

Measured memory_bytes: 5184
//copyright sumitraj387
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back//_____standard_template____
#define bsdk ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //___________program booster_________
#define pop pop_back
#define str string
#define endl "\n"
#define vec vector
#define m_p make_pair
#define mod 1000000007
#define modi 998244353
int i,j;
main()
{
    bsdk
   int n,m;
   float sum=0;
   cin>>n>>m;
   int arr[n];
   vector<int>v;
   for(i=0;i<n;i++)
   {
        cin>>arr[i];
        sum+=arr[i];
   }
   float m1=m;
   float x=x=((sum)/((4.0)*m1));
   for(i=0;i<n;i++)
   {
       float y=arr[i];
       if(y>=x)
         v.pb(arr[i]);
   }
   if(v.size()>=m)
    cout<<"Yes";
   else
    cout<<"No";

}


Measured memory_bytes: 256
n = gets.to_i
arr = n.times.map{gets.chomp}

list = {}
count = 0

for s in arr
  k = s.split('').sort.join
  if list.has_key?(k)
    list[k] += 1
  else
    list[k] = 1
  end
end

list.each do |_, v|
  if v > 1
    count += v * (v - 1) / 2
  end
end
puts count

Measured memory_bytes: 26748
#include<stdio.h>
#include<string.h>
int N,c=0;
int ch(int n)
{
	int l,r;
	char S[5];
	sprintf(S,"%d",n);
	for(l=0,r=strlen(S)-1;l<r;l++,r--)
		if(S[l]!=S[r])
			return 0;
	return 1;
}
int main()
{
	scanf("%d",&N);
	for(;;c++)
	{
		if(ch(N-c)){N-=c;break;};
		if(ch(N+c)){N+=c;break;};
	}
	printf("%d\n",N);
	return 0;
}

Measured memory_bytes: 608
n = int(input())
if n <= 6:
    print(1)
elif 6<=n<=11:
    print(2)
else:
    if n % 11 == 0:
        print((n//11)*2)
    elif 0 < n%11 <=6:
        print((n//11)*2+1)
    else:
        print((n//11)*2+2)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long double ll;

#define  kak 1000000000000;


int main(){
    ll score;
    ll p;
    ll N;
    ll K;
    cin >> N;
    cin >> K;
    double ans = 0;

    for (int i = 1; i <=N ; ++i) {
        score = i;
        p = (ll) 1.0 / (ll)N ;
        for (int j = i; score < K ; ++j) {
            score = score * 2;
            p = (ll) p / 2;
        }

        ans += (ll) p;
    }

    cout << setprecision(12) << ans << endl;

    return 0;
}




Measured memory_bytes: 256
n=int(input())
numbers = [int(n) for n in input().split()]
cost = []
for i in range(0,n):
    cost.append(0)
#cost[0]=0
cost[1]=abs(numbers[1]-numbers[0])
for i in range(2,n):
    cost[i]=min((cost[i-2]+abs(numbers[i]-numbers[i-2])),(cost[i-1]+abs(numbers[i]-numbers[i-1])))
    
#print(cost)
print(cost[n-1])

Measured memory_bytes: 13928
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder
{
    public static class Program
    {
        static void Main()
        {
            var nd = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var obCount = (nd[1] * 2 + 1);
            var a = nd[0] / obCount;
            if (nd[0] % obCount > 0) ++a;
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 11348
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

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

Measured memory_bytes: 3632
#include <stdio.h>
typedef long long ll;

ll n;
ll a[100005];
ll l;

ll last;

int main()
{
    scanf("%lld %lld", &n, &l);
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", a + i);
    }

    for (ll i = 1; i < n; i++) {
        if (a[i] + a[i + 1] >= l) {
            last = i;
        }
    }

    if (last == 0) {
        puts("Impossible");
        return 0;
    }
    else {
        puts("Possible");
    }

    for (ll i = 1; i < last; i++) {
        printf("%lld\n", i);
    }

    for (ll i = n - 1; i > last; i--) {
        printf("%lld\n", i);
    }

    printf("%lld\n", last);

    return 0;
}


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

int main(){
	int h, w; cin >> h >> w;
	bool t[h][w];
	rep(i, h)rep(j, w) {
		bool b; cin >> b;
		t[i][j] = b;
	}

	int ans = -1;
	int dp[h][w];
	memset(dp, 0, sizeof(dp));
	rep(i, h)rep(j, w){
		if(t[i][j]) dp[i][j] = 0;
		else if(!i || !j) dp[i][j] = 1;
		else {
			int m = INT_MAX;
			m = min(m, dp[i-1][j-1]);
			m = min(m, dp[i-1][j]);
			m = min(m, dp[i][j-1]);
			dp[i][j] = m + 1;
		}
		ans = max(ans, dp[i][j]);
	}

	cout << ans*ans << endl;

	return 0;
}



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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> stones(n), dp(n+1, INT_MAX/2);
    for (int i = 0; i < n; ++i) cin >> stones[i];
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
    	for (int j = 1; j <= k; ++j) {
    		if (i >= n-j) continue;
    		dp[i+j] = min(dp[i+j], dp[i] + abs(stones[i+j] - stones[i]));
    	}
    }
    cout << dp[n-1] << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>H(N);
  for(int i=0;i<N;i++){cin>>H.at(i);}
  sort(H.begin(),H.end());
  int64_t sum=0;
  if(N>K){
    for(int i=0;i<(N-K);i++){
      sum+=H.at(i);}
      }
  cout<<sum<<endl;
  return 0;}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
int main() {
	int n = 0, x = 0,d = 0;
	int ans = 0;
	int date[1000] = {};
	int date_copy[1000] = {};
	std::cin >> n >> d >> x;
	for (int i = 0; i < n; i++) { std::cin >> date[i]; }
	for (int i = 0; i < n; i++) { date_copy[i] = 1; }

	for (int i = 0; i < n; i++) {
		while (date_copy[i] <= d) {
			date_copy[i] += date[i];
			ans++;
		}
	}
	ans += x;
	std::cout << ans << std::endl;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = (int)1e6 + 3;

int powr(int n, int k){
  if(k == 0) return 1;
  int p = powr(n, k/2);
  p = (p * 1ll * p) % MOD;
  if(k % 2 == 1) p = (p * 1ll * n) % MOD;
  return p;
}

int fac[MOD];

void solve(){
  int x, d, n;
  cin >> x >> d >> n;
  if(d == 0){
    cout << powr(x, n) << "\n";
    return;
  }
  x = (x * 1ll * powr(d, MOD - 2)) % MOD;
  if(x == 0){
    cout << 0 << "\n";
    return;
  }
  if(x + n - 1 >= MOD){
    cout << 0 << "\n";
    return;
  }
  int ans = (fac[x + n - 1] * 1ll * powr(fac[x - 1],MOD-2))%MOD;
  ans = (ans * 1ll * powr(d, n)) % MOD;
  cout << ans << "\n";
}

int main(){
  fastIO;
  fac[0]=1;
  for(int i = 1; i < MOD; i ++ )
    fac[i]=(fac[i-1]*1ll*i)%MOD;
  int q;
  cin >> q;
  for(int t = 0 ;t < q; t ++ ) solve();
  return 0;
}

Measured memory_bytes: 4864
#include<cstdio>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
        char a[1000]={0};
        int ch,cnt=0,mns=0;
        cin>>a;
        ch=(strlen(a)-1)/2;
        if(strlen(a)%2!=0&&a[ch]!='w'&&a[ch]!='i')cnt++;
        for(int i=0;i<ch+1;i++)
        {
                if(a[i]=='('&&a[strlen(a)-mns-1]==')');
                else if(a[i]=='i'&&a[strlen(a)-mns-1]=='i');
                else if(a[i]=='w'&&a[strlen(a)-mns-1]=='w');
                else if(a[i]==')'&&a[strlen(a)-mns-1]=='(');
                else if(i==strlen(a)-mns-1);
                else cnt++;
                mns++;
        }
        cout<<cnt<<endl;
        return 0;
}

Measured memory_bytes: 1144
import numpy as np
import sys
from numba import njit, i8

mod = 10 ** 9 + 7
@njit((i8, i8, i8[:]), cache=True)
def main(n, k, a):
	fac = np.full(n + 3, 1, dtype = np.int64)
	for i in range(1, n + 1):
		fac[i] = fac[i - 1] * i % mod
	
	def inv(x):
		res = 1
		e = mod - 2
		while e > 0:
			if e & 1:
				res = res * x % mod
			x = x * x % mod
			e >>= 1
		return res
	def c(n, k):
		return fac[n] * inv(fac[n - k] * fac[k] % mod) % mod

	ans = 0
	for i in range(n - k + 1):
		ans += (a[n - 1 - i] - a[i]) * c(n - 1 - i, k - 1)
		ans %= mod
	print(ans)


if __name__ == '__main__':
	stdin = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
	n, k = stdin[:2]
	a = np.sort(stdin[2:])
	main(n, k, a)


Measured memory_bytes: 108252
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// 約数列挙：nの約数を昇順に返す
vector<long long> enumDivisors(long long n){
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            ret.push_back(i);
            if(n/i != i) ret.push_back(n/i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

// 桁数を返す
ll retDigit(ll n){
    if(n == 0) return 1;
    ll ret = 0;
    while(n > 0){
        ret++;
        n /= 10;
    }
    return ret;
}

int main(){
    Init();
    ll n, ans = INFLL; cin >> n;
    auto eDiv = enumDivisors(n);
    for(auto p: eDiv){
        ll tb = n/p;
        chmin(ans, retDigit(max(p, tb)));
    }
    cout << ans <<endl;
}

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

using namespace std;

long long solve (long long h) {
    if (h == 1)
        return 1;
    return 1 + solve(h / 2) * 2;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    long long h;
    cin >> h;
    cout << solve(h);
}


Measured memory_bytes: 3604
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();
    int m = in.nextInt();

    int[] x = new int[m];

    for (int i = 0; i < m; i++)
      x[i] = in.nextInt();

    x = mergeSort(x);

    int res = x[m - 1] - x[0];

    int[] diffs = new int[m - 1];

    for (int i = 0; i < m - 1; i++)
      diffs[i] = x[i + 1] - x[i];

    diffs = mergeSort(diffs);

    int i = m - 2;
    while (n-- > 1 && i >= 0) {
      res -= diffs[i];
      i--;
    }

    out.println(res);

    out.close();
  }

  static class InputReader {

    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }

  static void print(int[] arr) {
    Arrays.stream(arr).forEach(i -> System.out.print(i + " "));
    System.out.println();
  }

  public static int[] mergeSort(int[] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[] left = new int[mid];
    int[] right = new int[a.length - mid];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static int[] merge(int[] l, int[] r) {
    int[] merged = new int[l.length + r.length];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i] <= r[j])
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }
}

Measured memory_bytes: 46836
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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 / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> x(n);
    vector<ll> y(n);
    for(ll i=0;i<n;++i){
        cin>>x[i];
        y[i] = x[i];
    }

    sort(y.begin(), y.end());
    ll a = y[n/2];
    ll b = y[n/2-1];

    for(ll i=0;i<n;++i){
        ll ans = a;
        if(x[i] > b){
            ans = b;
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#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 K, N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  int l = A[0] + K - A[N-1];
  for (int i = 1; i < N; i++) {
    l = max(A[i] - A[i-1], l);
  }
  cout << K - l << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

vector<int> G[100000];
int match[100000];
bool used[100000];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v] = true;
	for(int i = 0;i < G[v].size();i++){
		int u = G[v][i],w = match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bi_match(int V){
	int res = 0;
	memset(match,-1,sizeof(match));
	for(int v = 0;v < V;v++){
		if(match[v] < 0){
			memset(used,0,sizeof(used));
			if(dfs(v)) res++;
		}
	}
	return res;
}

signed main(){
	int n,a[100],b[100],c[100],d[100];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i] >> b[i];
	for(int i = 0;i < n;i++) cin >> c[i] >> d[i];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(a[i] < c[j] && b[i] < d[j]){
				add_edge(i,n + j);
			}
		}
	}
	cout << bi_match(n * 2) << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    map<string,int>mp;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }   

    int m;
    cin>>m;
    while(m--)
    {   
        cin >> s;
        mp[s]--;
    }   
    int ans=0;
    for(auto x:mp)
    {   
        ans=max(ans,x.second);
    }   
    cout<<ans<<endl;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn = 1e5+10;
const int mod = 1e9+7;

int n,k=0;
vi g[maxn];
int c[maxn];
map<ii,int> mp;

ii dale(ii x){
	return ii(max(x.ff,x.ss),min(x.ff,x.ss));
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	vii e(n);
	for(int i=1;i<n;++i){
		cin>>e[i].ff>>e[i].ss;
		e[i]=dale(e[i]);
		mp[e[i]]=i;
		g[e[i].ff].pb(e[i].ss);
		g[e[i].ss].pb(e[i].ff);
	}
	queue<int> q;
	q.push(1);
	vector<bool> vis(n+1);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		set<int> st;
		vis[x]=true;
		for(auto &w:g[x]){
			if(!vis[w]){
				q.push(w);
			}
			int pos=mp[dale(ii(x,w))];
			//cout<<"x="<<x<<" w="<<w<<" pos="<<pos<<" c[pos]="<<c[pos]<<endl;
			if(c[pos]!=0)
				st.insert(c[pos]);
		}
		int color=1;
		for(auto &w:g[x]){
			ii aux=ii(x,w);
			int pos=mp[dale(aux)];
			if(c[pos])continue;
			while(st.count(color)) ++color;
			c[pos]=color;
			st.insert(color);
		}
		k=max(k,color);
	}
	cout<<k<<endl;
	for(int i=1;i<n;++i){
		cout<<c[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    for(int i=0;i<S.size();i++) cout<<'x';
    cout<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vc;

const int INF = 0x3fffffff;

class Flow{
	public:
		int N;
		vector<vc> F, C, edge;

		// ????????????????????? n:????????°
		Flow(int n): F(n,vc(n)), C(n,vc(n)), N(n), edge(n) {}

		// ??????????????????
		void addEdge(int f, int t, int c){
			F[f][t] = C[f][t] = c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		int flow(int n, int c, int T, vector<bool> &bf){
			if( n == T ) return c;
			bf[n] = true;
			for(int i: edge[n]) if( F[n][i] > 0 && !bf[i] ){
				int f = flow(i, min(c, F[n][i]), T, bf);
				F[n][i] -= f;
				F[i][n] += f;
				if( f > 0 ) return f;
			}
			return 0;
		}
		// ?????§???????±???????
		int maxFlow(int S, int T){
			int ret = 0;
			vector<bool> bf(N);
			for(int add; add = flow(0, INF, T, bf); bf.assign(N,0)) ret += add;
			return ret;
		}

		// ??°???????????????????????????
		void clear(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	int V, E;
	cin >> V >> E;
	Flow fl(V);
	rep(i, E){
		int u, v, c;
		cin >> u >> v >> c;
		fl.addEdge( u, v, c );
	}

	cout << fl.maxFlow(0, V-1) << endl;

	return 0;
}

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

using namespace std;

const long long inf = (long long) 1e18;

long long n, s;

bool ok(long long b) {
  if (b <= 1) return false;
  long long tmp = n;
  long long ret = 0;
  while (tmp) {
    long long d = tmp % b;
    ret += d;
    tmp /= b;
  }
  return ret == s;
}

int main() {
  scanf("%lld %lld", &n, &s);
  if (n == s) {
    printf("%lld\n", n + 1);
    return 0;
  }
  for (int i = 1; (long long) i * i <= n; i++) {
    if (ok(i)) {
      printf("%d\n", i);
      return 0;
    }
  }
  long long ans = inf;
  for (int i = 1; (long long) i * i <= n; i++) {
    if (n >= s && (n - s) % i == 0) {
      if (ok((n - s) / i + 1)) ans = min(ans, (n - s) / i + 1);
    }
  }
  if (ans == inf) ans = -1;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

struct UnionFind{
  vi d;
  UnionFind(ll n=0): d(n,-1) {}
  ll find(ll x){
    if(d[x]<0) return x;
    return d[x]=find(d[x]);
  }
  bool unite(ll x,ll y){
    x=find(x); y=find(y);
    if(x==y) return false;
    if(d[x]>d[y]) swap(x,y);
    d[x]+=d[y];
    d[y]=x;
    return true;
  }
  bool same(ll x,ll y){return find(x)==find(y);}
  ll size(ll x){return -d[find(x)];}
};

void solve() {
  ll n,m;
  cin>>n>>m;
  UnionFind uf(n);
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    uf.unite(a,b);
  }
  ll ans=0;
  rep(i,n) chmax(ans,uf.size(i));
  out(ans);
}

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


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

int main(){
    int n; cin >> n;
    int a[n]; rep(i,n) cin >> a[i];
    int mean = 0;
    rep(i,n) mean += a[i];
    mean /= n;
    int ans1 = 0, ans2 = 0;
    rep(i,n) ans1 += (a[i]-mean)*(a[i]-mean);
    mean++;
    rep(i,n) ans2 += (a[i]-mean)*(a[i]-mean);
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
      int max = Math.max(a*b,c*d);

		System.out.print(max);
       
       
      
    }
}

Measured memory_bytes: 21716
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::i64;
use std::io::{stdin, Read};
use std::usize;

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, d: i64, a: i64);
    let div = |x, y| {
        let ret = x / y;
        let r = x % y;
        if r == 0 {
            ret
        } else {
            ret + 1
        }
    };
    let mut xh = vec![];
    for _ in 0..n {
        parse!(it, x: i64, h: i64);
        xh.push((x, h));
    }
    xh.sort();
    let mut ret = 0;
    let mut dq = VecDeque::new();
    let mut ds = 0;
    for (x, mut h) in xh {
        while let Some(&(dd, xd)) = dq.front() {
            if x > xd {
                ds += dd;
                dq.pop_front();
            } else {
                break;
            }
        }
        assert!(ds <= 0);
        h += ds;
        if h <= 0 {
            continue;
        }
        let y = div(h, a);
        ret += y;
        let dd = y * a;
        ds -= dd;
        let r = x + 2 * d;
        dq.push_back((dd, r));
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c = stoi(to_string(a) + to_string(b));
    int q = sqrt(c);
    if (q * q == c) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100

int n,m;
bool map[MAX_A][MAX_A];

int dfs(int now,int n,bool* visited){


    bool all_visited = true;

    for(int i = 0;i < n;i++){
        if(visited[i] == false){
            all_visited = false;
        }
    }

    if(all_visited){
        return 1;
    }

    int r = 0;

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

        if(map[now][i]==false){
            continue;
        }
        if(visited[i]){
            continue;
        }

        visited[i]=true;
        r+=dfs(i,n,visited);
        visited[i] = false;

    }

    return r;
}



int main(){

    cin >> n >> m;
    for(int i = 0;i < m;i++){
        int a,b;
        cin >> a >> b;
        map[a-1][b-1] = true;
        map[b-1][a-1] = true;
    }

    bool visited[MAX_A];

    REP(n){
        visited[i]=false;
    }

    visited[0] = true;

    cout << dfs(0,n,visited) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip> // for /* << std::fixed << std::setprecision(k) << */
using namespace std;

//defines

#define forn(n) for(int i = 0; i < n; i++)
#define pb push_back
#define int long long

int32_t main() {
	int h, n, sum, a;
	
	cin >> h >> n;
	
	sum = 0;
	
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += a;
	}
	
	if (sum < h)
		cout << "No";
	else
		cout << "Yes";
}



Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int ac[100500], wa[100500];
	int n, m, sumAC = 0, sumWA = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ac[i] = 0;
		wa[i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p >> s;
		if (s == "AC") {
			if (ac[p - 1] == 0) {
				ac[p - 1] = 1;
			}
		}
		else {
			if (ac[p - 1] == 0) {
				wa[p - 1]++;
			}
		}
		
	}
	for (int i = 0; i < n; i++) {
		if (ac[i] == 1) {
			sumAC += ac[i];
			sumWA += wa[i];
		}
		
	}
	cout << sumAC <<" "<< sumWA << endl;
	return 0;
}

Measured memory_bytes: 1024
n, k = map(int,input().split())
ans = 0
q, r = divmod(n, k)
for a in range(1, n+1):
    b = k - a%k
    c = k - b%k
    if (c + a)%k == 0:
        now = 1
        if 1 <= b%k <= r: now *= q+1
        else: now *= q
        if 1 <= c%k <= r: now *= q+1
        else: now *= q
        ans += now
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    long long p = 1;
    long long ans;

    for (int i = 1; i <= n; i++) {
        p *= i;
        p = p % 1000000007;
    }

    cout << p << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  if(n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}

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

int main()
{
	int a,b;

	cin >> a >> b;

	if(a < b){
		cout << "a < b" << endl;
	}
	else if(a > b){
		cout << "a > b" << endl;
	}
	else{
		cout << "a == b" << endl;
	}

	return 0;
}

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

int main(){
  int64_t N, D;

  while(std::cin >> N >> D){
    int ans = 0;

    for(int i = 0; i < N; ++i){
      int64_t X, Y; std::cin >> X >> Y;

      if(X * X + Y * Y <= D * D){
        ++ans;
      }
    }



    std::cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int N;
  long long K;
  cin >> N >> K;
  long long prev = 0;
  long long now = 0;
  long long sum = 0;
  for(int i = 0; i < N; ++i) {
    prev = now;
    cin >> now;
    sum += min(now - prev, K);
  }
  cout << sum + K << endl;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",(b-a)*(b-a-1)/2-a)
}


Measured memory_bytes: 4352
//2019/12/8
//Bit.
//One of my favorite.
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;

int main(){
	llong n;
	cin>>n;
	
	vector<llong> a(n);
	REP(i,n) cin>>a[i];
	
	llong ans=0;
	REP(i,60){
		llong hoge=(1LL<<i);//point!!!!!
		
		llong cnt=0;
		REP(j,n){
			if(a[j]&hoge) cnt++;
		}
		
		ans+=(hoge%MOD)*(cnt*(n-cnt)%MOD)%MOD;//point.
		ans%=MOD;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <cstdio>
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int first= a*b;
    int second=c*d;
    if(first>=second){
        printf("%d",first);
    }
    else{
        printf("%d",second);
    }
}


Measured memory_bytes: 1716
n, m = map(int, input().split())
xy = []
for _ in range(m):
    x, y, _ = map(int, input().split())
    xy.append((x - 1, y - 1))


class UF:
    def __init__(self, n):
        self.n = n
        self.g = list(range(n))
        self.vertices = list(range(n))

    def union(self, i0, i1):
        g0, g1 = self.find(i0), self.find(i1)
        g0, g1 = min(g0, g1), max(g0, g1)
        self.g[g1] = g0

    def find(self, i):
        path = []
        while self.g[i] != i:
            path.append(i)
            i = self.g[i]

        for j in path:
            self.g[j] = i

        return i

uf = UF(n)

for x, y in xy:
    uf.union(x, y)

g = set()
for x in range(n):
    g.add(uf.find(x))

answer = len(g)
print(answer)


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

using namespace std;

#define ll long long
#define up(i,j,n)	for(ll i=j;i<=n;i++)
#define down(i,j,n)	for(ll i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)

const ll MAXN=1e5+5;

ll a[MAXN],N,pre[MAXN],add[MAXN],ans=0,mx=0,M;

namespace solution{
	void mark(ll l,ll r,ll a,ll b){
		pre[l]+=a;
		add[l]+=b;
		add[r+1]-=b;
		pre[r+1]-=a+(r-l+1)*b;
	}
	void Prepare(){
		scanf("%lld%lld",&N,&M);
		up(i,1,N)scanf("%lld",&a[i]);
	}
	void Solve(){
		up(i,1,N-1){
			ll now=a[i],nxt=a[i+1];
			if(now<nxt){
				mark(now+1,nxt,-1,1);
				ans+=(nxt-now);
			}else{
				if(now+1<=M)mark(now+1,M,-1,1);
				mark(1,nxt,M-now-1,1);
				ans+=(nxt+M-now);
			}
		}
//		up(i,1,M)printf("%lld ",pre[i]);puts("");
//		up(i,1,M)printf("%lld ",add[i]);puts("");
		up(i,1,M){
			add[i]+=add[i-1];
			pre[i]+=pre[i-1]+add[i];
		}
//		up(i,1,M)printf("%lld ",pre[i]);puts("");
		up(i,1,M)cmax(mx,pre[i]);
//		printf("%lld %lld\n",ans,mx);
		printf("%lld\n",ans-mx);
	}
}

int main(){
//	freopen("input.in","r",stdin);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}


Measured memory_bytes: 2560
use std::io;


fn main() {
    let mut x = read_one::<usize>();
    loop {
        if is_prime(x) {
            println!("{}", x);
            return;
        }
        x += 1;
    }
}

fn is_prime(n: usize) -> bool {
    if n == 2 { return true; }
    for i in 2..(n as f64).sqrt().ceil() as usize + 1 {
        if n % i == 0 { return false; }
    }
    true
}


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

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

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

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

Measured memory_bytes: 4352
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

# --------------------------------------------

dp = None

def main():
    N = input()
    fx = 0

    for n in N:
        fx += int(n)

    if int(N) % fx == 0:
        print("Yes")
    else:
        print("No")

main()


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

int main() {
  string s;
  cin >> s;
  int c0 = 0,c1 = 0;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == '0') c0++;
    else c1++;
  }
  cout << 2*min(c0,c1) << endl; 
}


Measured memory_bytes: 512
$<.map{|s|
    a=[];
    s.split.map{|t|
        if t=="+"
            a.push(a.pop+a.pop);
        elsif t=="-"
            a.push(-a.pop+a.pop);
        elsif t=="*"
            a.push(a.pop*a.pop);
        elsif t=="/"
            a.push(1.0/a.pop*a.pop);
        else
            a.push(t.to_i);
        end
    }
    p a.pop
}


Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    int n,m;
    cin>>n>>m;
    int k;
    int p[m];
    vector<vector<int>> v(n);

    for(int i=0;i<m;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            int s;
            cin>>s;
            s--;
            v[s].push_back(i);
        }
    }
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    long long ans=0;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (long long bit = 0; bit < (1LL<<n); ++bit){
        int cnt[m]={};
        for(int i=0;i<n;i++){
            if((bit>>i&1LL)){
                for(int j=0;j<v[i].size();j++){
                    cnt[v[i][j]]++;
                }
            }
        }
        bool ok=true;
        for(int j=0;j<m;j++){
            if(cnt[j]%2!=p[j]) ok=false;
        }
        if(ok ) ans++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[100];
	int N;
	int c = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		if ((i+1)%2==1&&a[i]%2==1)
		{
			c++;
		}
	}
	cout << c;
}

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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        if(s[i]==s[i+1]){
          cout<<"Bad"<<endl;
          return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const [N, K] = input[0].split(" ").map(el => parseInt(el));
    let As = input[1].split(" ").map(el => parseInt(el))

    for(let ki=0; ki<K; ki++){
        let imos = new Array(N+1).fill(0)
        for(let i = 0; i<N;i++){
            let l = Math.max(0, i - As[i])
            let r = Math.min(i+As[i]+1, N)
            imos[l]++
            imos[r]--
        }
        for(let i = 0; i<N; i++){
            imos[i+1] += imos[i]
        }
        let isDone = true
        for(let i = 0; i<N; i++){
            if(imos[i] !== N){
                isDone = false
                break
            }
        }
        imos.pop()
        As = imos
        if(isDone) break
    }
    console.log(As.join(" "))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


Measured memory_bytes: 71488
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  double l;
  cin >> l;
  double ans = pow(l, 3) / 27;
  printf("%.9f\n", ans);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

typedef pair<long long,int> P;

int main(){
  int n;
  long long h;
  cin>>n>>h;
  long long a[n],b[n];
  long long ma=0;
  REP(i,n){
    cin>>a[i]>>b[i];
    if(ma<a[i]){
      ma = a[i];
      //mai = i;
    }
  }
  
  vector<P> nb;
  REP(i,n){
    if(b[i]>=ma){
      nb.push_back(P(b[i],i));
    }
  }
  sort(nb.begin(),nb.end(),greater<P>());
  int cntb=nb.size();
  
  long long sumb[cntb];
  REP(i,cntb){
    if(i==0){
      sumb[i]=nb[i].first;
    }else{
      sumb[i]=sumb[i-1]+nb[i].first;
    }
  }
  int l=1;int r=1000000010;
  int m,temp,cnt;
  bool flag;//whileの処理を最後までやるか否か
  while(r-l>1){
    m=(l+r)/2;
    if(m<=cntb){
      if(sumb[m-1]>=h){
        r = m+1;
        if(r-l==2){
          if(sumb[l-1]>=h){
            break;
          }else{
            l = m;
          }
        }
      }else{
        l = m+1;
      }
    }else{
      if(((h-sumb[cntb-1])+ma-1)/ma<=(m-cntb)){
        r = m+1;
        if(r-l==2){
          if(((h-sumb[cntb-1])+ma-1)/ma<=(l-cntb)){
            break;
          }else{
            l = m;
          }
        }
      }else{
        l = m+1;
      }
    }
  }
  
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 4336
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int n=S.size();
	int flag=1;
	rep1(i,n-1){
		if(S[i]!='9') flag=0;
	}
	int ans;
	if(flag) ans=(n-1)*9+(S[0]-'0');
	else ans=(n-1)*9+(S[0]-'0')-1;
	prin(ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  ll S = 0;
  string s;
  map<map<char, int>, ll> v;
  REP(i, N) {
    cin >> s;
    map<char, int> a;
    REP(j, 10) a[s[j]]++;
    v[a]++;
  }
  for(auto it = v.begin();it != v.end();it++) {
    S += (it->second) * (it->second - 1) / 2;
  }
  cout << S << endl;
}

Measured memory_bytes: 52348