akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

#pragma endregion

int _same(char a, char b, char c);
int _same(char a, char b, char c) {
	if (a == b && b == c) return 0;
	if ((a == b && b != c) || (a == c && a != b) ||
		(b == c && a != c)) return 1;
	return 2;
}

int main(void) {
	int N;
	char a[3][101];
	int i, cnt = 0;

	i_cin(N);
	for (i = 0; i < 3; i++) {
		s_cin(a[i]);
	}
	for (i = 0; i < N; i++) {
		
		cnt += _same(a[0][i], a[1][i], a[2][i]);
	}

	i_cout(cnt);

	return 0;
}

	/*int A, B, C, X;
	int a, b, r, tmp, cnt = 0;

	i_cin4(A, B, C, X);

	r = (X % 100) / 50;
	if (r && !C) {i_cout(0); return 0;}

	tmp= X / 500;
	a = (tmp > A) ? A : tmp;
	tmp = X / 100;
	b =  (tmp > B) ? B : tmp;
	if (a && b) cnt = a * b / 2;
	else cnt = _max(a, b);
	cnt++;
	i_cout(cnt);*/





Measured memory_bytes: 128
/*
Author : Vidish Joshi
*/

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

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define ll long long int
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define FOR1(i, m, n) for(i=m; i<n; i++)
#define FOR2(i, n, m) for(i=n-1; i>=m; i--)
#define v(v) ll v; cin>>v
#define mod 1000000007
#define mod2 998244353
#define mp make_pair
#define pb push_back
#define fill(a) memset(a, 0, sizeof(a))
#define start ll t; cin>>t; while(t--)

void re() {}
template <typename T, typename... args>
void re(T &x, args &... tail)
{
    cin >> x;
    re(tail...);
}
void pr() {}
template <typename T>
void pr(const T &x)
{
    cout << x;
}
template <typename T, typename... args>
void pr(const T &x, const args &... tail)
{
    cout << x << " ";
    pr(tail...);
}
template <typename... args>
void prln(const args &... tail)
{
    pr(tail...);
    cout << "\n";
}


int main(){
	FIO;
	ll n; cin>>n;
	ll a[n];
	ll ans = 0, minn = LLONG_MAX;
	for(ll i=0; i<n; i++){
		cin>>a[i];
		if(a[i]<minn){
			ans++;
			minn=a[i];
		}
	}
	
	cout<<ans<<"\n";


	return 0;
}


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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long double> S(n);
  rep(i,n) {
    double p;
    cin >> p;
    S[i] = (p+1)/2;
    if (i > 0) S[i] += S[i-1];
  }
  long double ans = 0;
  for (int i = k-1; i < n; ++i) {
    long double res = S[i];
    if (i >= k) res -= S[i-k];
    ans = max(ans, res);
  }
  cout << std::fixed;
  cout << std::setprecision(9) << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int match_index[9] = {2,5,5,4,5,6,3,7,6};
int dp[10020];

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

    int nums[m];
    int matchs[m];
    rep(i, 0, m)
    {
        int a;
        cin >> a;
        nums[i] = a;
        // cout << i << ' ' << a << endl;
    }
    sort(nums, nums + m);
    rep(i, 0, m)
        matchs[i] = match_index[nums[i] - 1];
    // rep(i, 0, m)
    //     cout << matchs[i] << endl;
    // return 0;

    rep(j, 0, n + 1)
        dp[j] = -1;
    dp[0] = 0;

    rep(j, 1, n + 1)
    rep(i, 0, m)
    if (j - matchs[i] >= 0)
    if (dp[j - matchs[i]] != -1)
        dp[j] = max(dp[j], dp[j - matchs[i]] + 1);

    string ans = "";
    while (n > 0)
    {
        rrep(i, m, 0)
        {
            // cout << matchs[i] << endl;
            if (n - matchs[i] >= 0)
            if (dp[n - matchs[i]] + 1 == dp[n])
            {
                ans += char('0' + nums[i]);
                n -= matchs[i];
                break;
            }
        }
        // cout << n << ' ' << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
const int N = 1e5 + 1;
typedef long long ll;
const int M = 1e9;

ll n, dp[N], h[N], k;

int main (){
cin >> n>> k;
for (int i = 1;i <= n;++i){
    cin >> h[i];
}
dp[1] = 0;
dp[2] = abs (h[2]- h[1]);
for (ll i = 3;i <= n;++i){
    dp[i] = M;
    for (ll j = i - 1;j >= max (i - k, ll(1));--j){
        dp[i] = min (abs (h[i] - h[j]) + dp[j], dp[i]);
    }
}
cout << dp[n];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define t1 first
#define t2 second
#define ll long long
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d=a+b;
	if(d>=c)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}


void solve()
{
	char a,b;
	cin >> a >> b;
	int temp = b - '0';
	string temp1 = "";
	while(temp--)
		temp1 += a;
	string temp2 = "";
	temp = a - '0';
	while(temp--)
		temp2 += b;
	if(temp1 < temp2)
		cout << temp1 << ln;
	else
		cout << temp2 << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	clock_t start,stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for(int tc = 1;tc < t + 1;tc++) solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

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


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  ll res=1;
  rep(i,n)
  {
    ll t;
    cin>>t;
    res=lcm(res,t);
    //cout<<t<<endl;
    //cout<<res<<endl;
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
package main

import "fmt"

//配列の中に特定の文字列が含まれるかを返す
func arrayContains(arr []string, str string) bool{
  for _, v := range arr{
    if v == str{
      return true
    }
  }
  return false
}

func main() {
  var S string
  fmt.Scan(&S)
  
  var result []string
  for _,s := range(S) {
    if arrayContains(result, string(s)){
      continue
    }else{
      result = append(result, string(s))
    }
  }
  if len(result) == 2 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define S second
#define F first
const int  MOD = 1e9 + 7;
const ll  MAX = 1e14;
const int  N = 405;
ll a[N];
ll dp[N][N] , last[N][N];

//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);  cin.tie(0);
    int n; cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
    for(int j = 0 ; j < n ; j++){
        for(int i = 0 ; i <= n ; i++){
            dp[i][j] = MAX;
        }
    }
    for(int j = 0 ; j < n ; j++){
        for(int i = j ; i >= 0 ; i--){
            if(i == j){
                dp[i][j] = 0;
                last[i][j] = a[i];
                continue;
            }
            for(int k = i; k <= j; k++){
                ll pos = dp[i][k] + dp[k+1][j] + last[i][k] + last[k+1][j];
                if(pos < dp[i][j]){
                    dp[i][j] = pos;
                    last[i][j] = last[i][k] + last[k+1][j];
                }
            }

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


    return 0;
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

struct Fact_combination {
private:
	vector< long long >FACT;
	vector< long long >IFACT;
	int N;
public:
	long long extgcd(long long a, long long b, long long &x, long long &y) {
		long long g = a;
		x = 1;
		y = 0;
		if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
		return g;
	}
	long long invMod(long long a, long long m) {
		long long x, y;
		if (extgcd(a, m, x, y) == 1) return (x + m) % m;
		else                         return 0;
	}
	long long mod_pow(long long x, long long n) {
		long long res = 1;
		while (n > 0) {
			if (n & 1) res = res * x%MOD;
			x = x * x%MOD;
			n >>= 1;
		}
		return res;
	}
	void inverse(int n) {
		N = n;
		FACT.resize(N + 1);
		IFACT.resize(N + 1);
		FACT[0] = 1;
		IFACT[0] = 1;
		for (int i = 1;i <= N;i++) {
			FACT[i] = FACT[i - 1] * i % MOD;
			IFACT[i] = invMod(FACT[i], MOD);
		}
	}
	long long combi(int n, int r) {
		if (n < 0 || r < 0 || r > n)return 0;
		if (r > n / 2)r = n - r;
		return FACT[n] * IFACT[n - r] % MOD*IFACT[r] % MOD;
	}
};

ll n, m, ans = 1;

int main() {
	cin >> n >> m;
	ll M = m;
	Fact_combination f;
	f.inverse(100050);
	for (int i = 2;i*i <= m;i++) {
		int cnt = 0;
		while (true) {
			if (M%i != 0)break;
			M /= i;
			cnt++;
		}
		if (!cnt)continue;
		ans *= f.combi(n + cnt - 1, cnt);
		ans %= MOD;
	}
	if (M != 1)ans *= n;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
n,m = map(int,input().split())
num = [0] * (m+1)
setn = []
sum = 0
for i in range(n):
    setn = list(map(int,input().split()))

    for j in range(setn[0]):
        box = setn[j+1]
        num[box] = num[box] + 1

for x in range(len(num)):
    if num[x] == n:
        sum += 1

        
print(sum,end="")

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

double inf = 1e100;
int n, k;
double x[60];
double y[60];
double c[60];
double dist(double ax, double ay, double bx, double by) {
  double dx = bx - ax;
  double dy = by - ay;
  return hypot(dx, dy);
}

bool ok(double cx, double cy, double t) {
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    double d = dist(cx, cy, x[i], y[i]);
    if (t >= c[i] * d - 1e-10) ++cnt;
  }
  return cnt >= k;
}

pair<double, double> inter(
  double ax, double ay, double a,
  double bx, double by, double b) {
  double d = dist(ax, ay, bx, by);
  if (d >= a + b) return make_pair(-inf, -inf);
  if (d <= abs(b - a)) return make_pair(-inf, -inf);
  double t = (a + b + d) / 2;
  double s = sqrt(t * (t - a) * (t - b) * (t - d));
  double h = 2 * s / d;
  double x = sqrt(a * a - h * h);
  double y = sqrt(b * b - h * h);
  double k = y > d && y > x ? -x : x;
  
  double dx = bx - ax;
  double dy = by - ay;
  double ux = dx / d;
  double uy = dy / d;
  double mx = ax + k / d * dx;
  double my = ay + k / d * dy;
  return make_pair(mx - h * uy, my + h * ux);
}

bool sub(double t) {
  for (int i = 0; i < n; ++i) {
    if (ok(x[i], y[i], t)) return true;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      auto p = inter(x[i], y[i], t / c[i], x[j], y[j], t / c[j]);
      if (p.first == inf) continue;
      if (ok(p.first, p.second, t)) return true;
    }
  }
  return false;
}

int main() {
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> c[i];
  }
  
  double lo = 0;
  double hi = 1e10;
  for (int z = 0; z < 100; ++z) {
    double mid = (lo + hi) / 2;
    if (sub(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << setprecision(16) << fixed << lo << endl;
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 12 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    ivv(a);
    ivv(b);
    ivv(c);
    cout<<min(a*b , c)<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong
    }

    val even = as.count(v => v % 2 == 0 && v % 4 != 0)
    val mOf4 = as.count(_ % 4 == 0)

    if (even == 0 && mOf4 + 1 >= n - even - mOf4) {
      println("Yes")
    } else if (even != 0 && mOf4 >= n - even - mOf4) {
      println("Yes")
    } else {
      println("No")
    }
  }
}


Measured memory_bytes: 57872
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

map<vector<int>, int> tree_hash;
int AHU_hash(int v, int parent, vector<vector<int>> &adj){
    vector<int> res;
    for(int next: adj[v]){
        if(next == parent) continue;
        res.emplace_back(AHU_hash(next, v, adj));
    }
    sort(res.begin(), res.end());
    if(tree_hash.count(res) == 0){
        tree_hash[res] = tree_hash.size();
    }
    return tree_hash[res];
}

void dfs(int y, int x, char bw, int c, vector<vector<char>> &g, vector<vector<int>> &color){
    int h = g.size();
    int w = g[0].size();
    if(!(0<=y and y<h and 0<=x and x<w)) return;
    if(color[y][x] != -1 or bw != g[y][x]) return;
    color[y][x] = c;
    for(int d=0; d<(bw=='.'? 4: 8); d++){
        dfs(y+dy[d], x+dx[d], bw, c, g, color);
    }
}
vector<vector<int>> make_rooted_tree(vector<vector<char>> &g){
    int h = g.size();
    int w = g[0].size();
    vector<vector<int>> color(h, vector<int>(w, -1));
    int coloridx = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(color[i][j] == -1){
                dfs(i, j, g[i][j], coloridx, g, color);
                coloridx++;
            }
        }
    }
    vector<vector<int>> adj(coloridx);
    for(int i=0; i<h-1; i++){
        for(int j=0; j<w-1; j++){
            for(int d=0; d<2; d++){
                int c1 = color[i][j];
                int c2 = color[i+dy[d]][j+dx[d]];
                if(c1 != c2){
                    adj[c1].push_back(c2);
                    adj[c2].push_back(c1);
                }
            }
        }
    }
    for(auto &v: adj){
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
    }
    return adj;
}

int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h == 0) break;

        vector<int> hv(2);    
        for(int d=0; d<2; d++){
            if(d == 1){
                cin >> h >> w;
            }
            vector<vector<char>> grid(h+2, vector<char>(w+2, '.'));
            for(int i=1; i<=h; i++){
                for(int j=1; j<=w; j++){
                    cin >> grid[i][j];
                }
            }
            auto tree = make_rooted_tree(grid);
            hv[d] = AHU_hash(0, -1, tree);
        }
        if(hv[0] == hv[1]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3492
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a));
  int s = 0;
  for (int i = 0; i < k; i++) {
    s += a[i];
  }
  cout << s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

vector< pair<ll,ll> > input;
vector< vector<ll> > v;

string num_to_ID(ll x)
{
  string s = to_string(x);
  while(s.length()<6)
  {
    s = '0' + s;
  }
  return s;
}

string ID(ll city, ll num)
{
  string cityID, numID;
  cityID = num_to_ID(city);
  numID = num_to_ID(num);
  return cityID + numID;
}

ll comp_num(pair<ll,ll> p)
{
  ll city = p.first-1;
  ll min = 0;
  ll max = (ll)v[city].size()-1;
  
  if((v[city])[0]==p.second)
  {
    return 1;
  }

  while(min+1!=max)
  {
    ll mid = (min+max)/2;
    if((v[city])[mid]<p.second) min = mid;
    else max = mid;
  }
  return max+1;
}

int main()
{
  ll n,m;
  cin >> n >> m;
  vector<ll> tmp;
  rep(n)
  {
    v.push_back(tmp);
  }
  rep(m)
  {
    ll p,y;
    cin >> p >> y;
    input.push_back(make_pair(p,y));
    v[p-1].push_back(y);
  }

  rep(n) sort(v[i].begin(),v[i].end());

  for(auto p:input)
  {
    ll num = comp_num(p);
    string s = ID(p.first,num);
    cout << s << endl;
  }
  return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s;
    while (true) {
        cin >> s;
        if (s == "#") break;

        int y, m, d;
        cin >> y >> m >> d;

        if ((y == 31 and m >= 5) or (y >= 32)) {
            cout << "? " << y-31+1 << " " << m << " " << d << endl;
        }
        else {
            cout << s << " " << y << " " << m << " " << d << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3140
s, c = map(int, input().split())

ans = 0
#手持ちのSで作れる分だけSccを作る
if c <= 2*s:
  ans += c // 2
  c = c%2
  s = 0
else:
  ans += s
  c = c - 2*s
  s = 0
  


#print(s)
#print(c)
#print(ans)
#まだcが余ってたらSccを作る
if c >= 4:
  ans += c // 4
  
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,a,b,c=1,g,counter=0,u,v,d,e,p,x,y,flag=0;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> x >> y >> a >> b >> c;
     ll ans = 0;
    priority_queue<ll> R,G,C;
    priority_queue<ll,vector<ll> ,greater<ll> > A;
    for(i=0;i<a;i++)    {cin >> u; R.push(u);}
    for(i=0;i<b;i++)    {cin >> u; G.push(u);}
    for(i=0;i<c;i++)    {cin >> u; C.push(u);}

    for(i=0;i<x;i++)
    {
        A.push(R.top());  ans += R.top(); R.pop();
    }

     for(i=0;i<y;i++)
    {
        A.push(G.top()); ans += G.top();  G.pop();
    }
    while(!C.empty() and A.top()<C.top())
    {
        ans -= A.top(); A.pop(); ans += C.top() ; A.push(C.top()); C.pop();
    }
    cout << ans;

}
    return 0;
}

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

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 4852
s = input()
l = len(s)
h = l // 2
ans = 0

pre = s[:h]
#print(pre)
if l % 2 == 0:
  rear = s[h:]
else:
  rear = s[h+1:]
#print(rear)
rear_rev = ''.join(list(reversed(rear)))
#print(rear_rev)

for i in range(len(pre)):
  if pre[i] != rear_rev[i]:
    ans += 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
 
int main(void)
{
    int n,ans=0,max=0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)
        cin >> a[i];

    sort(a.begin(),a.end());

    map<int,int> mp;
    for(int i = 0;i < n;i++)
        mp[a[i]]++;

    for(int i = a[0];i<= a[n-1];i++){
        int b=0;
        b= mp[i] + mp[i+1] + mp[i+2];
        if(max<b)
            max=b;
    }

    cout << max << endl;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();

		char[] str = s.toCharArray();



		for(int i=0; i<str.length;i++) {
			int num = str[i] + N;
			char c  = (char)(num);
			if( c > 'Z')
				c = (char)(c - 26);
			System.out.print(c);
		}


		sc.close();

	}

}

Measured memory_bytes: 26436
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int D;
	cin >> D;
	vector<int> c(26);
	for (auto& x : c) {
		cin >> x;
	}
	vector<vector<int>> s(D, vector<int>(26));
	for (auto& v : s) {
		for (auto& x : v) {
			cin >> x;
		}
	}
	vector<int> t(D);
	for (auto& x : t) {
		cin >> x;
		--x;
	}

	vector<int> last(26, 0);

	int v = 0;
	for (int d = 0; d < D; ++d) {
		v += s[d][t[d]];
		last[t[d]] = d + 1;
		for (int i = 0; i < 26; ++i) {
			v -= c[i] * (d + 1 - last[i]);
		}
		cout << v << endl;
	}
}


Measured memory_bytes: 3652
from collections import deque
import sys
input = sys.stdin.readline

N, Q = [int(i) for i in input().split()]

E = [[] for _ in range(N)]
for a, b in (map(int, input().split()) for _ in range(N - 1)):
    E[a - 1].append(b - 1)
    E[b - 1].append(a - 1)

ans = [0] * N
for p, x in (map(int, input().split()) for _ in range(Q)):
    ans[p - 1] += x

visited = [False] * N
Q = deque([0])
while Q:
    a = Q.popleft()
    visited[a] = True
    for e in E[a]:
        if visited[e]:
            continue
        ans[e] += ans[a]
        Q.append(e)

print(*ans)


Measured memory_bytes: 93972
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
  
int main() {
        string l;
        while((l = readln(), l.length)){
                int s = to!int(chomp(l));
                int a, b, c, d;
                int ans = 0;
                for(a = 0; a <= 9; a++) for(b = 0; b <= 9; b++) for(c = 0; c <= 9; c++) for(d = 0; d <= 9; d++){
                        if(a + b + c + d == s) ans++;
                        }
                writeln(ans);
                }
        return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int n;
    cin >> n;
    ll A[n];
    int ans = 0;
    Rep(i,n){
        cin >> A[i];
        if(A[i] < A[ans]){
            ans = i;
        }
    }
    cout << ans+1 << endl;
    //cin >> n;
}


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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

int H, W, N;
vector< pair< int, int > > g[200000];
bool v[200000];
int64 cost[200000];
int64 L, R;

void chmin(int64& a, int64 b)
{
  a = min(a, b);
}

bool dfs(int idx)
{
  chmin(idx < H ? L : R, cost[idx]);
  for(auto& e : g[idx]) {
    if(v[e.first]++) {
      if(cost[idx] + cost[e.first] != e.second) return (false);
    } else {
      cost[e.first] = e.second - cost[idx];
      if(!dfs(e.first)) return (false);
    }
  }
  return (true);
}

int main()
{
  scanf("%d %d", &H, &W);
  scanf("%d", &N);
  while(N--) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    --x, --y;
    g[x].emplace_back(H + y, z);
    g[H + y].emplace_back(x, z);
  }

  for(int i = 0; i < H + W; i++) {
    if(v[i]++) continue;
    L = INF, R = INF;
    if(!dfs(i) || L + R < 0) {
      puts("No");
      return (0);
    }
  }

  puts("Yes");
}


Measured memory_bytes: 14592
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main()
{
    int n;
    int ans = 0;
    int a[100005];
    int v[100005] = {};

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int now = 1;
    
    while (now != 2 && v[now] == 0) {
        v[now] = 1;
        now = a[now];
        ans++;
    }

    if (now != 2) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# 本スクリプトを通じて以下の意味で用いる
# dist: 直接結ぶエッジの長さ
# shortest path (sp): 他のノードを経由しうる最短経路

from heapq import heappush, heappop

HUGE = 10 ** 15

def main():
    n, m = map(int, input().split())
    dist_sets = [{} for i in range(n)]
    for i in range(m):
        a1, b1, c = map(int, input().split())
        dist_sets[a1 - 1][b1 - 1] = c
        dist_sets[b1 - 1][a1 - 1] = c
    shortest_path_mat = [get_shortest_path_dijkstra(i, dist_sets) for i in range(n)]
    res = 0
    for i in range(n):
        for j in dist_sets[i].keys():
            if i > j:
                continue
            if shortest_path_mat[i][j] < dist_sets[i][j]:
                res += 1
    print(res)

def get_shortest_path_dijkstra(root, dist_sets):
    n = len(dist_sets)
    known_sp = [HUGE for i in range(n)]
    known_sp[root] = 0
    determined = [(i == root) for i in range(n)]
    pq = [(known_sp[root], root)]  # 第一要素はキュー追加時の shortest path 候補
    while len(pq) > 0:
        sp_cand, i = heappop(pq)
        determined[i] = True
        if known_sp[i] < sp_cand:
            continue
        for j, dist_ij in dist_sets[i].items():
            if determined[j]:
                continue
            if known_sp[i] + dist_ij < known_sp[j]:
                known_sp[j] = known_sp[i] + dist_ij
                heappush(pq, (known_sp[j], j))
    return known_sp

main()


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int (i) = (a);(i) < (b);(i)++)
#define Rep(i,n) For(i,0,n)
#define All(a) (a).begin(),(a).end()
#define sp " "
#define Rev(s,a,b) reverse((s).begin()+(a),(s).begin()+(b)+1)//s[a]....s[b] rev

vector<char> boin = {'a','i','u','e','o'};
typedef long long ll;

int main(){
    int x,y;
    int ans = 0;
    cin >> x >> y;
    if(x == 1){
        ans += 300000;
    }else if(x == 2){
        ans += 200000;
    }else if(x == 3){
        ans += 100000;
    }
    if(y == 1){
        ans += 300000;
    }else if(y == 2){
        ans += 200000;
    }else if(y == 3){
        ans += 100000;
    }
    if(x == 1 && y == 1)ans += 400000;
    cout << ans << endl;
    //cin >> x;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>  
#include<string.h>
using namespace std;
queue<int> q;
int vis[2000000];
int n,m;
bool check(int x)
{
if(x>=0&&x<=2000000&&vis[x]==-1)
    return 1;
    return 0;
}
int bfs(int n)
{   
	q.push(0);
	
	while(!q.empty())
	{int x=q.front(); 	
      	if(n==x)
      	return 1;
      	if(n<x)
      	return 0;
		if(check(x+100))
		{
			q.push(x+100);
			vis[x+100]=1;
		}
		if(check(x+101))
		{
			q.push(x+101);
			vis[x+101]=1;
		}
		if(check(x+102))
		{
			q.push(x+102);
			vis[x+102]=1;
		}
		if(check(x+103))
		{
			q.push(x+103);
			vis[x+103]=1;
		}
		if(check(x+104))
		{
			q.push(x+104);
			vis[x+104]=1;
		}
		if(check(x+105))
		{
			q.push(x+105);
			vis[x+105]=1;
		}
		q.pop();
	}
}
int main()
{
	while(~scanf("%d",&n))
	{     	while(!q.empty())
	{
		q.pop();
	}
	    memset(vis,-1,sizeof(vis));
  		printf("%d\n",bfs(n));
		
	}
}


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

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var a = ReadText();
            var up = a.ToUpper();
            return a == up ? "A" : "a";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main(){
    int i = 0;
    int j = 0;

    for(i=1;i<10;i++){
    for(j=1;j<10;j++){
    
    cout << i << "x" << j << "=" << i*j << endl;

    }
    }

    return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
int n;
const int N = 1e5 + 10;
int a[N];
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a; 
}
bool check() {
	int s = n&1;
	rep(i,1,n) s ^= a[i]&1;
	if (s) return true;
	int cnt = 0, t = 0;
	rep(i,1,n) if ((a[i]&1) && a[i] > 1) cnt++, t = i;
	if (cnt == 1) {
		a[t]--; int g = a[1];
		rep(i,2,n) g = gcd(g, a[i]);
		rep(i,1,n) a[i] /= g;
		return !check();
	}
	return false;
}
int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	printf(check() ? "First\n" : "Second\n");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(x % y, y);
}
int main() {
	int N, K;
	long double ans, tmp = 0, bo = 1, si = 1, k = 1,sip=1,a=1,l=0,r=0;
	cin >> N >> K;
	for (int i = 1; i < N+1; i++)
	{
		tmp = i;
		while (tmp<K)
		{
			tmp *= 2;
			k*=2;
		}
		k *= N;
		//tmpは一個前のボ
		if (i != 1)tmp = bo;
		else tmp = k*bo / gcd(k, bo);
		bo = k*bo/gcd(k, bo);
		sip = bo / k;
		si = si * bo / tmp;
		if (i == 1)si = 0;
		//if(si!=0)sip += bo / k;
		//si += bo/k;
		si += sip;
		k = 1;
	}
	ans = si / bo;
	cout.precision(15);
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll x;cin>>x;
    x-=400;
    ll a=x/200;
    cout<<8-a<<endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int div1[10000001];

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

	for(i=1;i<=n;i++){
		for(j=i;j<=n;j+=i){
			div1[j]++;
		}
	}
	uint64 ans = 0;
	for(i=1;i<=n;i++){
		ans += (uint64)i*(uint64)div1[i];
	}
	cout<<ans<<endl;
	return 0;
};

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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<ll> parent;

    UnionFind(ll N){
        parent = vector<ll>(N,-1);
    }

    ll root(ll A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    ll size(ll A){
        return -parent[root(A)];
    }

    bool unite(ll A, ll B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(ll A, ll B){
        return root(A)==root(B);
    } 
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,m,q;
    cin>>n>>m>>q;
    UnionFind uni(n);
    vector<array<ll,2>> v;
    for(ll i=0;i<q;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        if(c==0) uni.unite(a,b);
        else {
            if(m==n-1){
                cout << "No\n";
                return 0;
            }
            v.push_back({a,b});
        }
    }
    ll cnt = 0;
    for(ll i=0;i<n;i++){
        if(i==uni.root(i)){
            m -= uni.size(i)-1;
            cnt++;
        }
    }
    ll t = 0;
    bool tree = true;
    for(auto i:v){
        tree=false;
        if(uni.same(i[0],i[1])){
            cout << "No\n";
            return 0;
        }
    }
    if(cnt*(cnt-1)/(2LL) < m || m<cnt-(int)tree){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;

}


Measured memory_bytes: 3188
dbflag=""

def debug(*args):
  if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
  if ""!=dbflag:return _INDATA.readline()
  else: return input()


result = -1

X = int(readline())
A = int(readline())
B = int(readline())

print((X-A) %B)


Measured memory_bytes: 2940
nums = list(map(int,input().split()))
N = nums[0]
M = nums[1]
numss = list(map(int,input().split()))
cnt = M
summ = sum(numss)
for num in numss:
  if num >= summ/(M*4):
    cnt -= 1
if cnt > 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9060
#include<bits/stdc++.h>                          
using namespace std;    
int n,c[105],t[105],T,ans=1005; 
int main(){	
	cin>>n>>T;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i]>>t[i];
		if(t[i]<=T) ans=min(ans,c[i]);
	}
	if(ans!=1005) cout<<ans;
	else cout<<"TLE";
	return 0;
}

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

int main()
{
    int x;
    cin >> x;
    string sw;

    if (x < 30)
    {
        sw = "No";
    }
    else
    {
        sw = "Yes";
    }

    cout << sw << endl;
    return 0;
}

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

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

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
  string N;
  cin >> N ;
  int out = 0;
  for( int i=0;i<N.length();i++ )
    {
      if( N[i]=='2' )
	out += 1;
    }
  cout << out << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include<complex>
typedef complex<double> Point;
double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
  b -= a;
  c -= a;
  if(cross(b, c) > EPS) return +1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}
// テァツつケテ」ツ?古、ツクツ嘉ィツァツ津・ツスツ「abcテ」ツ?ョテ」ツ?ゥテ」ツ?禿」ツ?ォテ」ツ?づ」ツつ凝」ツ?ョテ」ツ?凝・ツ按、テ・ツョツ堙」ツ?凖」ツつ?
enum { OUT, ON, IN };
int contains(Point a, Point b, Point c, Point p){
  int A = ccw(a, b, p);
  int B = ccw(b, c, p);
  int C = ccw(c, a, p);
  if(A == B && B == C && abs(A) == 1) return IN;
  if(!A || !B || !C) return ON;
  return OUT;
}

int main(){
  Point a, b, c, d;
  while(cin >> a.real() >> a.imag() >> b.real() >> b.imag() >> c.real() >> c.imag() >> d.real() >> d.imag()){
    int C = contains(a, b, c, d);
    if(C == IN){
      cout << "YES" << endl;
    }else if(C == OUT){
      cout << "NO" << endl;
    }else if(C == ON){
      cout << "ON!" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    
    vector<set<int>> fl(N);
    UnionFind uf(N);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        fl[a].insert(b);
        fl[b].insert(a);
        uf.unite(a, b);
    }
    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        if (!uf.same(c, d)) continue;
        fl[c].insert(d);
        fl[d].insert(c);
    }

    for (int i = 0; i < N; i++) {
        int mem = uf.size(i) - 1;
        mem -= fl[i].size();
        cout << mem << " ";
    }

    cout << endl;
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int count=0;
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      long int t = i*j;
      if(n > t) {
        count++;
      } else {
        break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int K, N, res = 0;
cin >> N >> K;
int L[N];
for (int i = 0; i < N; ++i) cin >> L[i];
sort(L, L + N, greater<int>());
for (int i = 0; i < K; ++i) {
        res += L[i];
}
cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 301
using namespace std;
int w[N],mem[N][N],used[N][N];

int dfs(int l,int r){
  if(l==r) return 0;
  if(r-l==1) return 2*(abs(w[l]-w[r])<=1);
  if(used[l][r]++) return mem[l][r];
  
  int res=0;
  
  if((r-l)%1==0&&abs(w[l]-w[r])<=1&&
     dfs(l+1,r-1)==r-l-1) res=2+dfs(l+1,r-1);
  
  for(int i=l;i<r;i++)
    res=max(res,dfs(l,i)+dfs(i+1,r));
  
  return mem[l][r]=res;
}

int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<n;i++)cin>>w[i];
    memset(used,0,sizeof(used));
    cout<<dfs(0,n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3768