akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>A>>B;
    cout<<6 - A - B<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////
int n, m, q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

long long calc(vector<int> x) {
  // for(int i=0; i<n; i++) cerr << x[i] << " ";
  // cerr << endl;
  long long sum = 0;
  for(int i=0; i<q; i++) {
    if (x[b[i]-1] - x[a[i]-1] == c[i]) sum += d[i];
  }
  return sum;
}

void solve() {
  long long ans = 0;
  vector<int> x(n, 1);
  for(int i=0; i<n; i++) {
    for(int j=1; j<=m; j++) {
      x[n-1-i] = j;
      ans = max(ans, calc(x));
    }
  }
  cout << ans << endl;
}
long long xxx = 0;
void solve2(vector<int> x, int p) {
  if (p == 0) {
    xxx = max(xxx, calc(x));
  }
  if (p < 1) return;
  for(int i=1; i<=x[p+1]; i++) {
    x[p] = i;
    solve2(x, p-1);
    xxx = max(xxx, calc(x));
    // for(int j=0; j<n; j++) cerr << x[j] << " ";
    // cerr << endl;
  }
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  for(int i=0; i<q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];

  // solve();

  vector<int> x(n, 1);
  for(int i=1; i<=m; i++) {
    x[n-1] = i;
    solve2(x, n-2);
  }
  cout << xxx << endl;


  return 0;
}

// EOF


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, T a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return min(a, b);
	}
	
	T get(int k){return dat[k+n-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

struct UF
{
	vector<int> par; // 親のインデックスを記憶する配列
	vector<int> sz; // サイズを記憶する。
	vector<int> rank;
	// 初期化
	UF(int n):par(n),sz(n),rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
};

int main(){
	
	ll n,d;cin >> n >> d;
	vector<ll> a(n);
	vector<P> v(n);
	REP(i,n){
		cin >> a[i];
		v[i] = MP(a[i],i);
	}
	
	segtree<P> L(n,MP(LLINF,LLINF));
	segtree<P> R(n,MP(LLINF,LLINF));
	
	sort(ALL(v));
	vector<pair<ll,P>> g;
	
	REP(i,n){
		ll val = v[i].FI;
		ll id = v[i].SE;
		auto tmp = L.que(0,id);
		if(tmp.FI != LLINF){
			g.PB(MP(tmp.FI - (n-1-id) * d + a[id],MP(id,tmp.SE)));
		}
		tmp = R.que(id+1,n);
		if(tmp.FI != LLINF){
			g.PB(MP(tmp.FI - id * d + a[id],MP(id,tmp.SE)));
		}
		L.update(id,MP((n-1-id)*d + a[id],id));
		R.update(id,MP(id*d + a[id],id));
	}
	
	sort(ALL(g));
	
	UF uf(n);
	ll ans = 0;
	REP(i,g.size()){
		if(!uf.same(g[i].SE.FI,g[i].SE.SE)){
			uf.unite(g[i].SE.FI,g[i].SE.SE);
			ans += g[i].FI;
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 35820
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
 
const int N = 110;
 
int dp[N][N];
bool mat[N][N];
 
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m;cin >> n >> m;
    for(int i=0 ; i<n ; i++){
        string s;cin >> s;
        for(int j=0 ; j<m ; j++){
            dp[i][j] = 1e9;
            mat[i][j] = (s[j] == '#');
        }
    }
    dp[0][0] = mat[0][0];
    for(int i=0 ; i<n ; i++)
        for(int j=0 ; j<m ; j++){
            if(i)
                dp[i][j] = dp[i-1][j] + (mat[i][j] && !mat[i-1][j]);
            if(j)
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (mat[i][j] && !mat[i][j-1]));
        }
    cout << dp[n-1][m-1] << "\n";
}


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

int main(){

  int L;
  int a,b,c,d;
  cin>>L>>a>>b>>c>>d;

  a=(a-1)/c+1;
  b=(b-1)/d+1;
  L-=max(a,b);
  cout <<L<<endl;  

  return 0;
}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    string t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++) if(s[i] == t[i]) cnt++;
    cout << cnt;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt(),w = scanner.nextInt();
		char[][] cstr = new char[h][w];
		for(int i=0;i<h;i++){
			String s = scanner.next();
			cstr[i] = s.toCharArray();
		}
		char[][] board = new char[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(cstr[i][j] == '#'){
					System.out.print("#");
					continue;
				}
				int count = 0;
				for(int k=-1;k<=1;k++){
					if(i+k < 0 || h - 1 < i+k){
						continue;
					}
					for(int l=-1;l<=1;l++){
						if(j+l < 0 || w - 1 < j+l){
							continue;
						}
						if(cstr[i+k][j+l] == '#'){
							count++;
						}
					}
				}
				System.out.print(count);
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 21204
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    d = {}
    for a in A:
        if a in d:
            d[a] += 1
        else:
            d[a] = 1

    num = []
    for key in d:
        num.append(d[key])

    if len(num) <= K:
        ans = 0
    else:
        num = sorted(num, key=lambda x: -x)
        ans = sum(num[K:])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33780
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;
    cin >> C;
    if(A+B+C>=22) cout << "bust" << endl;
    else cout << "win" << endl;

}

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

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

  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int ans = 0;
  for (int t = 1; t <= 100; t++) {
    bool on = false;
    rep(i, N) {
      if (h[i] >= t)
        on = true;
      if (h[i] < t && on)
        on = false, ans++;
    }
    if (on)
      ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[2000005],g,o(2000005,0),f(2000005,0),ans(2000005,0);
vector <vector<lli>> a(2000005,vector<lli>(26,0));
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n,k;cin>>n>>k;
    vector <lli> a,b;
    lli x;
    for(lli i=0;i<n;i++)
    {
        cin>>x;
        if(x>=0)a.pb(x);
        else b.pb(abs(x));
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    lli j=0,i=min(k,(lli)a.size());
    if(k>a.size())
    {
        j=k-a.size();
        if(j%2==1 && j+1<=b.size() && j+1<=k)
            j+=1;
        i=k-j;
    }
    i--;lli f=0;
    if(j%2==0)
    {
    while( i>=1 && j<(lli)b.size()-1 && b[j]*b[j+1]>a[i]*a[i-1])
    {
        j+=2;i-=2;f=1;
    }
    }
    if(j%2==1)
    {
        reverse(b.begin(),b.end());
    }
    lli ans=1;
    //cout<<i<<" "<<j<<endl;
    for(lli c=0;c<j;c++)
    {
        ans*=(-b[c]);
        ans=abs(ans)%mod;
        ans=mod-ans;
    }
    for(lli c=i;c>=0;c--)
    {
        (ans*=(a[c]))%=mod;
    }
    cout<<ans<<endl;
}



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

int factorial(int n) {
    if (n == 1) return 1;
    return factorial(n-1) * n;
}

int main() {
    int n;
    cin >> n;
    vector<int> xs(n);
    vector<int> ys(n);
    for (int i = 0; i < n; i++) {
        cin >> xs[i] >> ys[i];
    }

    const int all = factorial(n);

    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);

    vector<int> ord_orig = ord;

    double mean = 0;
    do {
        for (int i = 0; i < n-1; i++) {
            mean += hypot(xs[ord[i]]-xs[ord[i+1]],ys[ord[i]]-ys[ord[i+1]])/all;
        }
        next_permutation(ord.begin(),ord.end());
    }while(!equal(ord.cbegin(), ord.cend(), ord_orig.cbegin()));

    cout << setprecision(10) << mean << endl;
}


Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  string s;
  cin >>s;

  s[5] = ' ';
  s[13] = ' ';

  cout << s << endl;

  return 0;
}


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

int main()
{
  int n, a;
  cin >> n;
  cin >> a;
  if (a - (n % 500) >= 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int64_t x; cin >> x;

    int t = 0;
    while (t * (t + 1) / 2 < x) t++;
    cout << t << endl;
}


Measured memory_bytes: 888
fn main() {
    let nk: Vec<usize> = read_vec();
    let (n, k) = (nk[0], nk[1]);
    let v: Vec<u32> = read_vec();

    let mut ans = 0;

    for i in 0..n {
        if v[i] >= k as u32 {
            ans += 1;
        }
    }
    println!("{}", ans);

}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub 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()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
<?php
fscanf(STDIN, '%s', $str);
$word = 'keyence';
$start = substr($str, 0, 3);
$end = substr($str, -4, 4);
if (substr($str, 0, 7) === $word || substr($str, -7, 7) === $word) {
    echo 'YES';
} else {
    for ($i=1; $i < 7; $i++) { 
        $key = substr($str, 0, $i);
    }

    for ($i=1; $i < 7; $i++) { 
        $key  = substr($word, 0, $i);
        $ence = substr($word, $i-7);
        if (substr($str, 0, $i) === $key && substr($str, $i-7) === $ence) {
            echo "YES"."\n";
            exit;
        }
    }
    echo "NO";
}
echo "\n";

Measured memory_bytes: 4732
while True:
    m = int(input())
    if m == 0:break
    n = 1000 - m
    a = n // 500
    n%=500
    b = n // 100
    n%=100
    c = n // 50
    n%=50
    d = n // 10
    n%=10
    e = n // 5
    n%=5
    print(a + b + c + d + e + n)

Measured memory_bytes: 7540
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>

using namespace std;

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);

    for (int i = 0; i < A.size(); i++) {
        cin >> A[i];
    }

    int maxDistance = 0;
    for (int i = 0; i < N; i++) {
        if (i == N - 1){
            int distance = A[N - 1] - A[0];
            if (distance > K / 2)distance = K - distance;
            if (maxDistance < distance)maxDistance = distance;
        }
        else {
            int distance = A[i+1] - A[i];
            if (distance > K / 2)distance = K - distance;
            if (maxDistance < distance)maxDistance = distance;
        }
    }
    std::cout << K - maxDistance << endl;

    return 0;
}

Measured memory_bytes: 1024
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k1,l,sum=0,ans=0,k,var,a[100005]={0},x,y,z,k2;
string s,t;
set<string> st;
bool check(int i)
{
    for(int j=0;j<t.size();j++)
    {
        if(s[j+i]==t[j]||s[j+i]=='?') continue;
        else return false;
    }
    return true;
}
int main()
{
    ios
    cin>>s>>t;
    for(i=0;i<=(ll)s.size()-(ll)t.size();i++)
    {
        if(check(i))
        {
            string p="";
            for(int j=0;j<i;j++)
            {
                if(s[j]=='?') p+='a';
                else p+=s[j];
            }
            p+=t;
            for(j=i+t.size();j<s.size();j++)
            {
                 if(s[j]=='?') p+='a';
                else p+=s[j];
            }
            st.insert(p);
        }
    }
    if(!st.size())
    {
        cout<<"UNRESTORABLE\n";
        return 0;
    }
    cout<<*st.begin();
 	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  bool all = true;
  int sum = 0;
  int min = 101;
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    sum += a;
    if (a % 10 != 0)
    {
      if (min > a) min = a;
      all = false;
    }
  }
  printf("%d\n", sum % 10 != 0 ? sum : all ? 0 : sum - min);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
        int n = sc.nextInt();
        String ans = "";
        for(int i = 0; i * n < s.length(); i++){
        	System.out.print(s.charAt(i * n));
        }
    }
}

Measured memory_bytes: 36160
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int d; cin >> d;
	cout << "Christmas";
	rep(i, 25 - d) cout << " Eve";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 892
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys


def solve(X: int):
    m = 100
    ans = 0

    while m < X:
        ans += 1
        m = int(m * 1.01)

    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63484
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	const int MOD = 1000000007;

	public void Solve(){
		int N = ri();
		long[] As = rla();

		BigInteger sum = 0;
		for (int i = 0; i < N; i++)
		{
			sum += As[i];
		}

		BigInteger ans = 0;
		for (int i = 0; i < N - 1; i++)
		{
			sum -= As[i];
			ans = (ans + As[i] * sum) % MOD;
		}

		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
	static BigInteger[] rba(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>BigInteger.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


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

int main(){
int n,m,a,b;
int sum[100];
int big[100];
while(cin>>n>>m){
for(int i=0;i<100;i++){
sum[i]=0;}
b=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>a;
sum[j]+=a;}}
for(int i=1000;i>-1;i--){
for(int j=0;j<m;j++){
if(i==sum[j]){
if(b!=m-1){
cout<<j+1<<" ";}
if(b==m-1){
cout<<j+1<<endl;}
b++;}}
}}}

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


int main(){
    int n, m;
    cin >> n >> m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  map<string,int> m;
  string str;
  for(int i=0;i<n;i++){
    cin>>str; m[str]++;
  }
  cout<<"AC x "<<m["AC"]<<"\n";
  cout<<"WA x "<<m["WA"]<<"\n";
  cout<<"TLE x "<<m["TLE"]<<"\n";
  cout<<"RE x "<<m["RE"];
  return 0;
}

Measured memory_bytes: 3636
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.stage[i + 1][j * 2 - 1] + self.stage[i + 1][j * 2]
    end
  end
end
SegTree.create = function(self, n)
  self.emptyvalue = 0
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = 0 end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage, mul = 1, 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  -- while right - left + 1 < mul do
  --   start_stage = start_stage + 1
  --   mul = mul * 2
  -- end
  local ret = self.emptyvalue
  local tasks = {{start_stage, left, right}}
  while 0 < #tasks do
    local task = tasks[#tasks]
    table.remove(tasks)
    local stage, l, r = task[1], task[2], task[3]
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mce((l - 1) / sz) * sz
      table.insert(tasks, {stage + 1, l, mmi(r, newr)})
      l = newr + 1
    end
    if sz <= r + 1 - l then
      local pos = mce(l / sz)
      ret = ret + self.stage[stage][pos]
      l = l + sz
    end
    if l <= r then
      table.insert(tasks, {stage + 1, l, r})
    end
  end
  return ret
end
SegTree.decValue = function(self, idx)
  self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1
  for i = self.stagenum - 1, 1, -1 do
    local dst = mce(idx / 2)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.stage[i + 1][idx] + self.stage[i + 1][rem]
    idx = dst
  end
end
SegTree.inc = function(self, idx)
  self.stage[self.stagenum][idx] = 1 + self.stage[self.stagenum][idx]
end
SegTree.new = function(n)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  -- obj.updateAll = SegTree.updateAll
  -- obj.create = SegTree.create
  -- obj.getRange = SegTree.getRange
  -- obj.inc = SegTree.inc
  -- obj.decValue = SegTree.decValue
  obj:create(n)
  return obj
end

local n, k = io.read("*n", "*n")
local sum, tmp, conv = {}, {}, {}
sum[1] = io.read("*n") - k
for i = 2, n do
  sum[i] = sum[i - 1] + io.read("*n") - k
end
sum[n + 1] = 0
for i = 1, n + 1 do tmp[i] = sum[i] end
table.sort(tmp)
local sumTypeCount = 1
local sumTypeList = {}
conv[tmp[1]] = 1
sumTypeList[1] = tmp[1]
for i = 2, n + 1 do
  if tmp[i] ~= sumTypeList[sumTypeCount] then
    sumTypeCount = sumTypeCount + 1
    conv[tmp[i]] = sumTypeCount
    sumTypeList[sumTypeCount] = tmp[i]
  end
end
local segtree = SegTree.new(sumTypeCount)
for i = 1, n do
  segtree:inc(conv[sum[i]])
end
segtree:updateAll()
local bias = 0
local cnt = 0
for i = 1, n do
  cnt = cnt + segtree:getRange(conv[bias], sumTypeCount)
  segtree:decValue(conv[sum[i]])
  bias = sum[i]
end
print(cnt)


Measured memory_bytes: 35372
from collections import Counter
from itertools import combinations
N = int(input())
S = [input()[0] for i in range(N)]
C = dict(Counter(S))

A = ["M", "A", "R", "C", "H"]
Z = []
for moji, num in C.items():
    if moji in A:
        Z.append(num)

ans = 0
if len(Z) < 3:
    print(0)
else:
    comb = list(combinations(Z, 3))
    for c in comb:
        ans += c[0] * c[1] * c[2]
    print(ans)



Measured memory_bytes: 4224
using System;

namespace Repetitive_Processing
{
    class Print_Test_Cases
    {
        static void Main(string[] args)
        {
            int c = 1;
            while (true)
            {
                var line = Console.ReadLine();
                if (line == "0") break;
                Console.WriteLine("Case "+c+": "+line);
                c++;
            }
        }
    }
}

Measured memory_bytes: 9256
#include <bits/stdc++.h>
#define N 100003
#define endl "\n"

#define trace1(x)             	 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;


using namespace std;

int main() {
	// for fast input output using cin cout
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	// size of array
	// input
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a + b;
	int r = c + d;

	if (l > r)
		cout << "Left\n";
	else if (l < r)
		cout << "Right\n";
	else
		cout << "Balanced\n";
	return 0;
}

Measured memory_bytes: 256
import collections

num = int(input())
a_i = list(map(int, input().split()))
q = int(input())
c = collections.Counter(a_i)
ans = sum(a_i)

for x in range(q):
    a, b = map(int, input().split())
    val = b - a
    cnt = c[a]
    c[a] -= cnt
    c[b] += cnt
    ans += val * cnt
    print(ans)

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >> n;
   vector<int> v;
   for(int i =0; i < n; i++)
   {
      int k; cin >> k;
      v.push_back(k);
   }
   sort(all(v));
   cout << v[n-1] - v[0] << nl;

}


Measured memory_bytes: 3584
n,m = map(int, input().split())

a = [[] for i in range(n)]

for i in range(m):
    x,y,z = map(int, input().split())
    x-=1
    y-=1
    a[x].append(y)
    a[y].append(x)
b = [0 for i in range(n)]
ans = 0

for j in range(n):
    if b[j]==1:
        continue
    else:
        b[j]=1
        ans += 1
        stack = [j]
    while stack:
        p = stack.pop()
        for i in range(len(a[p])):
            if b[a[p][i]]==0:
                b[a[p][i]]=1
                stack.append(a[p][i])
print(ans)


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
import sys

l, r = list(map(int, input().split()))

ans = 2018

for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    if ((i * j) % 2019) < ans:
      ans = (i * j) % 2019
    if ans == 0:
      print(ans)
      sys.exit()

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  int ans = H*W - h*W - (H-h)*w;
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int w, n, wn[30];

	cin >> w >> n;
	for (int i = 0; i < w; ++i)
	{
		wn[i] = i + 1;
	}
	for (int i = 0; i < n; ++i)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(wn[a - 1], wn[b - 1]);
	}
	for (int i = 0; i < w; ++i)
	{
		cout << wn[i] << endl;
	}
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int cnt = 0;
  for (int i = A; i <= B; i++) {
    if ((i % 10 == i / 10000) && (i / 10 % 10 == i / 1000 % 10)) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


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

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    A.sort();

    long x = A[N/2-1];
    long y = A[N/2];
    if (x == y) {
        writeln(0);
    } else {
        writeln(y - x);
    }
}


Measured memory_bytes: 4420
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	
   int n;
   cin >> n;
   vector<long double> v(n);

   for(int i=0;i<n;i++){
      cin >> v[i]; 
   }
   
   sort(v.begin(), v.end());
   
   long double ans = v[0];
   for(int i=1;i<n;i++){
    ans = (ans +v[i]) / 2; 
   } 

  cout << ans << endl;
}



Measured memory_bytes: 256
from collections import namedtuple
from queue import Queue
from copy import deepcopy

def bfs(start, stage):
    if stage[start.y][start.x] == "#":
        return -1
    ans = 0
    q = Queue()
    q.put(start)
    stage[start.y][start.x] = 0
    while not q.empty():
        current = q.get()
        for move in moves:
            nxt = point(current.y + move.y, current.x + move.x)
            can_move = 0 <= nxt.y < h and 0 <= nxt.x < w and stage[nxt.y][nxt.x] == "."
            if can_move:
                q.put(nxt)
                stage[nxt.y][nxt.x] = stage[current.y][current.x] + 1
                ans = stage[current.y][current.x] + 1
    return ans


point = namedtuple("point", "y, x")
moves = [point(-1, 0), point(0, 1), point(1, 0), point(0, -1)]
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = -1
for y in range(h):
    for x in range(w):
        steps = bfs(point(y, x), deepcopy(S))
        ans = max(ans, steps)
print(ans)


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

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

ll pref_sum(vi &f, int r){ // range query [0..r]
    ll ret = 0;
    for(; r >= 0; r = (r&(r + 1)) - 1){
        ret += f[r];
    }

    return ret;
}

ll get_sum(vi &f, int l, int r){ // arbitary range query [l..r]
	return pref_sum(f, r) - pref_sum(f, l - 1);
}

void update(vi &f, int idx, ll val){ // point update
    for(; idx < sz(f); idx |= (idx + 1)){
        f[idx] += val;
    }
}

int main() {
    ll tt = 1, n, m, l, r, c, i, j, k, w, x, y;
    boost;

    // cin >> tt;
    ll ans = 0;
    ll x1, y1, z1, x2, y2, z2;
    for(int _ = 1; _ <= tt; _++) {
        cin >> n >> x >> r;
        cout << (ll)ceil(1.0*n/x)*r << nl;
    }
}

Measured memory_bytes: 3652
A, B, K = map(int, input().split())
a    = []
b    = []
same = []
for i in range(1, A+1):
    if A % i == 0:
        a.append(i)
for i in range(1, B+1):
    if B % i == 0:
        b.append(i)
for v_a in a:
    for v_b in b:
        if v_a == v_b:
            same.append(v_a)
            
same = sorted(same, reverse=True)
print(same[K-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;

void solve()
{
    ll n;cin>>n;vi v(n);
    fr(n)
    cin>>v[i];
    vi sol;ll cnt=0;
    for(int i=0;i<(n-1);i++)
    {
        if(v[i]>=v[i+1])
            cnt++;
        else
        {
            sol.pb(cnt);
            cnt=0;
        }

    }
    sol.pb(cnt);
    cnt=0;
    /*for(int i=(n-1);i>0;i--)
    {
        if(v[i]>=v[i-1])
            cnt++;
        else
        {
            sol.pb(cnt);
            cnt=0;
        }
    }
    sol.pb(cnt);*/
    sort(ALL(sol));
    reverse(ALL(sol));
    cout<<sol[0]<<endl;

    return ;

}
int main()
{
    ll t=1;
    //cin>>t;
    fr(t)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 2168
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////


//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);

  sin(S);
  ll s = 0;
  rep(i, S.size()){
    s += S[i] - '0';
  }

  if(s % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  //cout << s << endl;
}

Measured memory_bytes: 3724
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll h,w;
    std::cin >> h>>w;
    string a[1001];
    std::set<pair<ll,ll>> ne;
    std::set<pair<ll,ll>> nex;
    for (int i = 0; i < h; i++) {
        std::cin >> a[i];
        for (int j = 0; j < w; j++) {
            if(a[i][j] == '#'){
                ne.insert({i,j});
            }
        }
    }
    ll count = 0;
    while(true){
        // for (int i = 0; i < h; i++) {
        //     for (int j = 0; j < w; j++) {
        //         std::cout <<  a[i][j];
        //     }
        //     std::cout << std::endl;
        // }
        // std::cout << std::endl;
        
        for (auto e : ne) {
            ll ef = e.first;
            ll es = e.second;
            if(ef<h-1){
                if(a[ef+1][es] == '.'){
                    nex.insert({ef+1,es});
                    a[ef+1][es] = '#';
                }
            }
            if(es<w-1){
                if(a[ef][es+1] == '.'){
                    nex.insert({ef,es+1});
                    a[ef][es+1] = '#';
                }
            }
            if(ef>0){
                if(a[ef-1][es] == '.'){
                    nex.insert({ef-1,es});
                    a[ef-1][es] = '#';
                }
            }
            if(es>0){
                if(a[ef][es-1] == '.'){
                    nex.insert({ef,es-1});
                    a[ef][es-1] = '#';
                }
            }
        }
        ne.clear();
        for (auto e : nex) {
            ne.insert(e);
        }
        nex.clear();
        
        if(ne.size()!=0){
            count++;
        }else{
            break;
        }
    }
    std::cout << count << std::endl;
    
    
    
}


Measured memory_bytes: 65152
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

const INF = 1<<29;

class Graph {
    class Edge {
        int from, to, cap, cost;
        Edge rev;
    }
    int V;
    Edge[][] G;
    Edge[] prevEdge;
    this(int V) {
        this.V = V;
        this.G = new Edge[][V];
        this.prevEdge = new Edge[V];
    }
    void addEdge(int from, int to, int cap, int cost) {
        auto e = new Edge;
        auto r = new Edge;
        e.from = from; e.to = to; e.cap = cap; e.cost = cost; e.rev = r;
        r.from = to; r.to = from; r.cap = 0; r.cost = -cost; r.rev = e;
        G[from] ~= e;
        G[to] ~= r;
    }
    int minCostFlow(int s, int t, int flow) {
        auto potential = new int[V];
        auto D = new int[V];
        int ret = 0;
        alias P = Tuple!(int, "index", int, "dist");
        while (flow > 0) {
            BinaryHeap!(Array!P, "a.dist > b.dist") PQ;
            D[] = INF;
            D[s] = 0;
            PQ.insert(P(s, 0));
            while (! PQ.empty) {
                auto c = PQ.front; PQ.removeFront;
                int v = c.index;
                if (D[v] < c.dist) continue;
                foreach (e; G[c.index]) {
                    int ndist = D[v] + potential[v] - potential[e.to] + e.cost;
                    if (e.cap > 0 && D[e.to] > ndist) {
                        D[e.to] = ndist;
                        prevEdge[e.to] = e;
                        PQ.insert(P(e.to, D[v]));
                    }
                }
            }
            if (D[t] == INF) return -1;
            foreach (v; 0 .. V) potential[v] += D[v];
            int d = flow;
            for (int v = t; v != s; v = prevEdge[v].from) {
                d = min(d, prevEdge[v].cap);
            }
            flow -= d;
            ret += d * potential[t];
            for (int v = t; v != s; v = prevEdge[v].from) {
                auto e = prevEdge[v];
                e.cap -= d;
                e.rev.cap += d;
            }
        }
        return ret;
    }
}

void main() {
    int V, E, F; readf("%s %s %s\n", &V, &E, &F);
    auto G = new Graph(V);
    foreach (i; 0 .. E) {
        int u, v, c, d; readf("%s %s %s %s\n", &u, &v, &c, &d);
        G.addEdge(u, v, c, d);
    }
    writeln(G.minCostFlow(0, V - 1, F));
}

Measured memory_bytes: 2660
#include <iostream>

using namespace std;

int main()
{
    long long a,b,p=1,i,cb,ok=0;
    cin>>a>>b;
    cb=b;
    while(b)
    {
        b=b/10;
        p*=10;
    }
    while(a)
    {
        cb+=a%10*p;
        a/=10;
        p*=10;
    }
    for(i=0;i<=cb;i++)
    {
        if(i*i==cb)
            {
                ok=1;
                break;
            }
    }
    if(ok==1)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, q;
    scanf("%d%d", &n, &q);
    vector < ll > Q = {n};
    for (; q; q --)
    {
        ll a;
        scanf("%lld", &a);
        while (Q.size() && Q.back() >= a)
            Q.pop_back();
        Q.push_back(a);
    }
    map < ll , ll > M;
    M[Q.back()] ++;
    for (int i = (int)Q.size() - 2; ~ i; i--)
        while (M.rbegin()->first > Q[i])
        {
            ll a = M.rbegin()->first, b = M.rbegin()->second;
            M[Q[i]] += a / Q[i] * b;
            M[a % Q[i]] += b;
            M.erase(a);
        }
    for (int i = n; i; i--)
        M[i] += M[i + 1];
    for (int i = 1; i <= n; i++)
        printf("%lld\n", M[i]);
    return 0;
}

Measured memory_bytes: 8692