akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int bfs(vector< vector<int> > &adj,int s,int cnt)
{
	int max=-1;
	queue<int> q;
	vector<bool> used(cnt);
	vector<int> d(cnt), p(cnt);
	
	q.push(s);
	used[s]=true;
	p[s]=-1;
	d[s]=0;
	
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int u: adj[v])
		{
			if(!used[u])
			{
			used[u]=true;
			q.push(u);
			d[u]=d[v]+1;
			p[u]=v;
			
			if(d[u]>max)
				max=d[u];
			}
				
		}
	}
	return max;
}

int main()
{
	int n,i,j,k,h,w,cnt=1;;
	cin>>h>>w;
	char arr[h][w];	
	int nadj[h][w];
	memset(nadj,-1,sizeof(nadj));

for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cin>>arr[i][j];
			if(arr[i][j]=='.')
			{
				nadj[i][j]=cnt;
					++cnt;	
			}
		}
	}
	vector< vector<int> > adj(cnt);
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(nadj[i][j]!=-1)
			{
				if(nadj[i-1][j]!=-1 && i!=0)
				{
					adj[nadj[i][j]].push_back(nadj[i-1][j]);
					
				}
				if(nadj[i+1][j]!=-1 && i<h-1)
				{
					adj[nadj[i][j]].push_back(nadj[i+1][j]);
					
				}
				if(nadj[i][j-1]!=-1 && j!=0)
				{
					adj[nadj[i][j]].push_back(nadj[i][j-1]);
					
				}
				if(nadj[i][j+1]!=-1 && j<w-1)
				{
					adj[nadj[i][j]].push_back(nadj[i][j+1]);
					
				}	
			}
		}
	}
	/*for(i=0;i<adj.size();i++)
	{
		cout<<i<<" ";
		for(j=0;j<adj[i].size();j++)
			cout<<adj[i][j]<<" ";
		cout<<endl;
	}*/
	int ans=0;
	
	for(i=1;i<cnt;i++)
		ans=max(ans,bfs(adj,i,cnt));
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
n = gets.to_i

edges = []
g = Array.new(n){ [] }
(n-1).times do |i|
  e = gets.split.map(&:to_i).map{|k|k-=1}
  e[1], e[0] = e[0], e[1] if e[0] > e[1] # 辺は頂点 i < j の形で入れる。
  g[e[0]] << e[1] # 隣接リストに
  g[e[1]] << e[0] # 反対向きにも隣接リストに.無向グラフなので
  edges << e # 辺リストにいれる。辺が識別されてて、最後に辺リストから辺を回して色をとりだす。
end

colors = Hash.new() # Esge => color # 辺についてO(1)で使った色を見れる。O(1)はホントに?
colors_used = Array.new(n){Hash.new} # 頂点と色についてO(1)で使ったか確かめられる。
used = Array.new(n){false} # 頂点について探索済みかどうかO(1)でわかる。
que = [0] # 頂点0から見ていくので0が入っている # 探索待ちの未探索の頂点リスト

k = 0 # 答えとなる色の数
while !que.empty? do
  v = que.shift # queにある頂点を取り出す. 破壊的メソッドなので先頭は削除される。
  cur = 1 # 使ってない色がわからないので、とりあず色1から見ていく。
  g[v].each do |w| # vの隣接頂点wを見ていく。
    next if used[w] == true # 探索済みの頂点なら見ない。
    k = g[v].size if k < g[v].size  # 隣接する頂点数より色数が小さければ色数を更新
    v<w ? (i,j = v,w) : (i,j = w,v) # i < jの並びで頂点を捉える。
    # next if colors[[i,j]] != nil # nilでなければi-jの辺に色がついてて頂点jは探索済みで,次に。
    cur += 1 while colors_used[v][cur] == true # v周りの頂点で色をつかっていれば次の色に更新していく。塗る前に使ってない色にする。
    colors_used[v][cur] = true # vに色を使ったので記録する。
    colors_used[w][cur] = true # wに色を使ったので記録する。
    colors[[i,j]] = cur # 辺に使った色をいれる。
    que.push(w) #探索待ちの未探索頂点リストに頂点wを入れる。
  end
  used[v] = true # 頂点vを探索済みにする。
end

puts k
edges.each{ |e| puts colors[e] }

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

using namespace std;

const int MaxN = 501;

long long a[MaxN][MaxN];

vector <int> p1;
vector <int> p2;

long long lcm(long long a, long long b)
{
    return a / __gcd(a, b) * b;
}

bool isPrime(int x)
{
    if(x == 1)
        return false;
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return false;
    return true;
}

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};

void build(int x, int y)
{
    for(int i = 0; i < 4; ++i)
    {
        int xx = x + dx[i];
        int yy = y + dy[i];

        if(xx >= 0 && xx < MaxN && yy >= 0 && yy < MaxN)
            a[x][y] = lcm(a[x][y], a[xx][yy]);
    }

    ++a[x][y];

    assert(a[x][y] <= 1e15 && a[x][y] > 0);
}

void check()
{
    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
        {
            for(int d = 0; d < 4; ++d)
            {
                int x = i + dx[d];
                int y = j + dy[d];

                if(x >= 0 && x < MaxN && y >= 0 && y < MaxN)
                {
                    long long k1 = min(a[i][j], a[x][y]);
                    long long k2 = max(a[i][j], a[x][y]);

                    assert(k2 % k1 == 1);
                }
            }
        }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    mt19937 rnd(clock());

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            a[i][j] = 1;

    for(int i = 2; i <= 20000; ++i)
        if(isPrime(i))
        {
            if(p1.size() <= MaxN)
                p1.push_back(i);
            else
                p2.push_back(i);
        }

//    shuffle(p1.begin(), p1.end(), rnd);
//    shuffle(p2.begin(), p2.end(), rnd);

    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j + i < MaxN; ++j)
            a[i + j][j] *= p1[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; i + j < MaxN; ++i)
            a[i][j + i] *= p1[j - 1];


    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j < MaxN && i - j >= 0; ++j)
            a[i - j][j] *= p2[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; j + i < MaxN; ++i)
            a[MaxN - 1 - i][j + i] *= p2[j - 1];

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            if((i + j) & 1)
                build(i, j);

    check();

    int n;
    cin >> n;

    assert(n <= MaxN);

    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
            cout << a[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}



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

bool intersect(int x1, int y1, int r1, int x2, int y2, int r2){
  return pow(r1+r2, 2) > pow(x1-x2, 2)+pow(y1-y2, 2);
}

int main() {
  int n;
  while(cin >> n){
    if(n==0) return 0;

    vector<int> x(n), y(n), r(n), c(n), on(n, 0);

    rep(i, n){
      int xt, yt, rt, ct;
      cin >> xt >> yt >> rt >> ct;
      x[i]=xt, y[i]=yt, r[i]=rt, c[i]=ct;
      rep(j, i) if(intersect(xt, yt, rt, x[j], y[j], r[j])) on[i] |= (1<<j);
    }

    vector<int> dp(1<<n, -1);
    dp[0] = 0;
    int ans = 0;

    rep(i, 1<<n){
      if(dp[i]==-1) continue;
      ans = max(ans, dp[i]);

      rep(j, n-1){
        if((i&(1<<j))!=0 || (i&on[j])!=on[j]) continue;
        REP(k, j+1, n){
          if((i&(1<<k))!=0 || (i&on[k])!=on[k] || c[j]!=c[k]) continue;
          int next = (i|(1<<j))|(1<<k);
          dp[next] = max(dp[next], dp[i]+2);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 68440
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios_base::sync_with_stdio(0),cin.tie(0)
int32_t main()
{int n,W,w,v,i,j;
 fast();
 cin>>n>>W;
 int N=n*1e3;
 vector<int> dp(N+1,1e9+5);
 dp[0]=0;
 for(i=0;i<n;++i)
 {cin>>w>>v;
  for(j=N;j>=v;--j)
  dp[j]=min(dp[j],dp[j-v]+w);
 }
 for(i=N;i>=0;--i)
 {if(dp[i]<=W)
  {cout<<i;
   break;
  }
 }
 return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace AGC017
{
    class A
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = input[0];
            long P = input[1];
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long eCount = 0;
            long oCount = 0;

            for (int i = 0; i < N; i++)
            {
                if (A[i] % 2 == 0) eCount++;
                else oCount++;
            }
            if (P == 1 && oCount == 0) { Console.WriteLine(0); return; }

            double res = 0;
            //res += Math.Pow(2, eCount); // 何も選ばないも含んでいる
            long[,] c = new long[oCount + 5, oCount + 5];
            c[0, 0] = 1;
            for (int i = 1; i <= oCount; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    if (j == 0) c[i, j] = c[i - 1, j];
                    else c[i, j] = c[i - 1, j] + c[i - 1, j - 1];
                }
            }

            for (int i = 0; i <= oCount; i++)
            {
                if (i % 2 == P) res += Math.Pow(2, eCount) * c[oCount, i];
            }
            Console.WriteLine(res);
        }
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n,k;
    cin>>n>>k;

    vi am,ap;
    rep(i,n){
        int num;
        cin>>num;
        if(num<0)am.push_back(-num);
        else ap.push_back(num);
    }

    sort(all(ap));
    sort(all(am));

    ll ans=1;

    if(n==k){
        int l=ap.size();
        rep(i,l)ans=(ans*ap[i])%MOD;
        l=am.size();
        rep(i,l)ans=(ans*am[i])%MOD;
        if(l%2)ans=(-ans+MOD)%MOD;

        cout<<ans<<"\n";
        return 0;
    }

    if((0==ap.size()) && k%2){
        rep(i,k)ans=(ans*am[i])%MOD;
        ans=(-ans+MOD)%MOD;

        cout<<ans<<"\n";
        return 0;
    }

    int ip=ap.size()-1,im=am.size()-1;

    rep(i,k){
        if((k-1-i)%2==0 || im<1){
            cerr<<"a\n";
            ans=(ans*ap[ip])%MOD;
            ip--;
        }else if(ip<1){
            cerr<<"b\n";
            ans=(ans*am[im])%MOD;
            ans=(ans*am[im-1])%MOD;
            im-=2;
            i++;
        }else{
            if(((ll)ap[ip])*ap[ip-1] > ((ll)am[im])*am[im-1]){
                cerr<<"c\n";
                ans=(ans*ap[ip])%MOD;
                ans=(ans*ap[ip-1])%MOD;
                ip-=2;
                i++;
            }else{
                cerr<<"d\n";
                ans=(ans*am[im])%MOD;
                ans=(ans*am[im-1])%MOD;
                im-=2;
                i++;
            }
        }
        cerr<<"i="<<i<<",ans="<<ans<<"\n";
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 4296
#include <iostream>
 #include <stdio.h>
using namespace std;
int main(void) {
    long a , b , c , d , main;
    cin >> a >> b >> c;
    d = a / (b+c);
		main = d * b ;
		if(a % (b+c) > b ){
       printf("%ld\n", main + b );
		}else{
      printf("%ld\n", main + a % (b+c));
		}
    return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c, min;

    cin >> a >> b >> c;

    min = a+b;

    if(min > a+c){
        min = a+c;
    }

    if(min > b+c){
        min = b+c;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
<?php 
  	$line = trim(fgets(STDIN));
	$flag1 = FALSE;
	$a = substr($line, 0, (strlen($line)-1)/2);
	$b = substr($line, ((strlen($line)+3)/2)-1, strlen($line));
	if ($line == strrev($line)) {
    	$flag1 = TRUE;
    }
	
	$flag2 = FALSE;
	if ($a == strrev($a)) {
    	$flag2 = TRUE;
    }

	$flag3 = FALSE;
	if ($b == strrev($b)) {
    	$flag3 = TRUE;
    }

	if ($flag1 && $flag2 && $flag3) {
    	echo "Yes\n";
    } else {
      	echo "No\n";
    }
	

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

int main(){
    int N,K;
    cin >> N >> K;
    int d;
  	int tmp;
    int l[N];
    for(int i=0;i<N;i++) l[i]=0;
    for(int i=0;i<K;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> tmp;
            l[tmp-1] = 1;
        }
    } 
    int ans=0;
    for(int i=0;i<N;i++){
        if(l[i]==0){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    for (int i = 0; i < M; i++)
    {
        cin >> y[i];
    }
    sort(y.begin(), y.end());
    bool flag = false;
    for (int i = X + 1; i <= Y; i++)
    {
        if ((x.back() < i) && (y.front() >= i))
        {
            flag = true;
            break;
        }
    }
    if (flag)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    long long H;
    cin >> H;
    long long ans = 0;
    long long count = 1;

    while (H > 1) {
        ans += count;
        count *= 2;
        H /= 2;
    }
    ans += count;
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N, ans = 0, cnt = 0;
  string s;
  cin >> N >> s;
  
  for(int i = 0; i < N; i++){
    if(s.at(i) == 'I'){
      cnt++;
      ans = max(ans, cnt);
    }
    else{
      cnt--;
    }
  }
  
  cout << ans << endl;
}

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

int main (){
    int a, b;
    cin >> a >> b;
    if(a+b >= a-b && a+b >= a*b){
        cout << a+b;
    }else if(a-b>= a+b && a-b >= a*b){
        cout << a-b;
    }else if(a*b >= a+b && a*b >= a-b){
        cout << a*b;
    }
}


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

int main(){
    int N;
    cin >> N;
    int hotels[N];
    for(int i = 0;i < N;i++){
        cin >> hotels[i];
    }
    int cnt = 1;
    int MAX = hotels[0];
    for(int i = 1;i < N;i++){
        if(MAX <= hotels[i]){
            cnt++;
            MAX = hotels[i];
        }
    }
    cout << cnt << endl;

    return 0;
}


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

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

const int INF = 1e9 + 7;

using namespace std;

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

    vector<int> v(n);
    vector<int> c(n);
    rep (i, 0, n)
	cin >> v[i];
    rep (i, 0, n)
	cin >> c[i];

    int res = 0;
    for (int i = 0; i < 1 << n; i++) {
	int tmp = 0;
	for (int j = 0; j < n; j++) {
	    if (i & 1 << j) {
		tmp += (v[j] - c[j]);
	    }
	}
	res = max(res, tmp);
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;
///if(///////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}


///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n; cin>>n;
vv<bool> isprime(n+1, true);
ll ans=1;
for(int i=2;i<=n;++i){
	// normal seive
	if(!isprime[i]) continue;
	for(int j=i*i;j<=n;j+=i) isprime[j]=false; 
	// Count power of i in n.
	int ct=0, temp=n; 
	while(temp){temp/=i; ct+=temp;}
	// add to answer;
	ans=(ans*(ct+1))%MOD;
}
cout<<ans<<el;



return 0;
}


Measured memory_bytes: 256
# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
divs = make_divisors(N)
# print(sorted(divs))
divs2 = make_divisors(N-1)
ans = len(sorted(divs2))-1
for div in divs[1:]:
    tmp = N
    while tmp%div == 0:
        tmp //= div
    if tmp%div == 1:
        ans += 1
print(ans)

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

import sys
import os

N = int(input())
for i in range(N):
    lst = list(map(int, input().split()))
    mx = max(lst)
    lst.remove(mx)

    if mx * mx == lst[0] * lst[0] + lst[1] * lst[1]:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int isKaibun(string &s){
	int ret = 1;
	for(int i=0; i<s.size(); i++){
		if(s[i] != s[s.size()-1-i]){
			ret = 0;
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;

	int ans = 0;
	for(int i=A; i<=B; i++){
		string s = to_string(i);
		if(isKaibun(s)){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3716
using System;
class Pg{
  static void Main(string[] args){
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    int c = int.Parse(Console.ReadLine());
    int d = int.Parse(Console.ReadLine());
    int e = int.Parse(Console.ReadLine());
    int k = int.Parse(Console.ReadLine());
    string f = e - a <= k ? "Yay!" : ":(";
    Console.WriteLine(f);
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


bool chill[100];
typedef pair<Edge, int> P;
// ¹öª¢çÈ¢ê
Weight dijkstra2(const Graph &g, int s, int m, int t) {
  int n = g.size();
  Weight dist[n][m+1];
  REP(i,n)REP(j,m+1)dist[i][j] = INF;
  dist[s][m] = 0;
  priority_queue<P> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(P(Edge(-2, s, 0),m)); !Q.empty(); ) {
    Edge e = Q.top().first;
    int nm = Q.top().second;
    Q.pop();
//    printf("(%d->%d)%d nm=%d\n",e.src,e.dst, e.weight, nm);
    if (dist[e.dst][nm] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (nm < f->weight) continue;
      if (chill[f->dst]) {      // âpÅ«é
        for (int i=nm-f->weight; i<=m; ++i) {
          if (dist[f->dst][i] > e.weight+f->weight+(i-(nm-f->weight))){
            dist[f->dst][i] = e.weight+f->weight+(i-(nm-f->weight));
            Q.push(P(Edge(f->src, f->dst, e.weight+f->weight+(i-(nm-f->weight))), i));
          }
        }
      } else {
        if (dist[f->dst][nm-f->weight] > e.weight+f->weight ) {
          dist[f->dst][nm-f->weight] = e.weight+f->weight;
          Q.push(P(Edge(f->src, f->dst, e.weight+f->weight), nm-f->weight));
        }
      }
    }
  }
  int res = INF;
  REP(i,m+1) {
    res = min(res,dist[t][i]);
  }
  return res;
}

int main() {
  int n, m, l, k, a, h;
  while(cin>>n>>m>>l>>k>>a>>h,n) {
    REP(i,n)
      chill[i] = 0;
    REP(i,l) {
      int b;
      cin >> b;
      chill[b] = 1;
    }
    Graph g(n);
    REP(i,k) {
      int x,y,t;
      cin >> x>>y>>t;
      g[x].push_back(Edge(x,y,t));
      g[y].push_back(Edge(y,x,t));
    }
    int dist = dijkstra2(g, a, m, h);
    if (dist!=INF)
      cout << dist << endl;
    else
      cout << "Help!" << endl;
  }
}

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

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

const long long INF = 1LL << 60;
long long dp[100100];

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


    return 0;
}

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

int main ( )  {
	long long Q, H, S, D, N ;
	scanf ( "%lld%lld%lld%lld%lld", & Q, & H, & S, & D, & N ) ;
	Q *= 4, H *= 4, S *= 4, D *= 4, N *= 4 ;
	double q = Q / 1, h = H / 2, s = S / 4, d = D / 8 ;
	std :: vector < std :: pair < double, std :: pair < long long, int > > > price ;
	price.push_back ( std :: make_pair ( q, std :: make_pair ( Q, 1 ) ) ) ;
	price.push_back ( std :: make_pair ( h, std :: make_pair ( H, 2 ) ) ) ;
	price.push_back ( std :: make_pair ( s, std :: make_pair ( S, 4 ) ) ) ;
	price.push_back ( std :: make_pair ( d, std :: make_pair ( D, 8 ) ) ) ;

	std :: sort ( price.begin ( ), price.end ( ) ) ;

	long long ans ( 0 ) ;

	for ( int i = 0 ; i < 4 ; ++ i )  {
		ans += 1LL * ( N / price.at ( i ).second.second ) * price.at ( i ).second.first ;
		if ( ( N %= price.at ( i ).second.second ) == 0 )  break ;
	}

	return ! printf ( "%lld\n", ans >> 2 ) ;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;
    vector<string> S(H), ans_b(H), ans_r(H);
    rep(i, H) {
        cin >> S[i];
        ans_b[i] = ans_r[i] = S[i];
    }

    rep(i, W) ans_r[0][i] = '#';
    rep(i, W) ans_b[H-1][i] = '#';

    rep(x, W) {
        if (x % 2 == 0) {
            for (int y=1; y<H-1; y++) {
                ans_r[y][x] = '#';
            }
        } else {
            for (int y=1; y<H-1; y++) {
                ans_b[y][x] = '#';
            }
        }
    }

    rep(y, H) {
        rep(x, W) cout << ans_r[y][x];
        cout << endl;
    }
    cout << endl;
    rep(y, H) {
        rep(x, W) cout << ans_b[y][x];
        cout << endl;
    }
}



Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int a[4],i;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);
if(a[0]>a[1])
    a[0]=a[1];
if(a[2]>a[3])
    a[2]=a[3];
            printf("%d",a[0]+a[2]);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<set>
#define MAXN 1000000000

using namespace std;

int main()
{
    char ch1[101],ch2[101];
    scanf("%s %s",ch1,ch2);
    printf("%s%s",ch2,ch1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

struct vertex {
	int id;
	int x;
	int y;
};

bool xComp(const vertex& s1, const vertex& s2) {
	return s1.x != s2.x ? s1.x < s2.x : s1.y < s2.y;
}
bool yComp(const vertex& s1, const vertex& s2) {
	return s1.y != s2.y ? s1.y < s2.y : s1.x < s2.x;
}

struct node {
	int innum;
	node* left;
	node* right;
};

vector<vertex> V(500005);
node* NIL = (node*)malloc(sizeof(node));
node* root;

void makeT(int a, int b, node** focus, int turn) {
	if (a >= b) return;
	if (turn % 2 == 0) sort(V.begin() + a, V.begin() + b, xComp);
	else sort(V.begin() + a, V.begin() + b, yComp);
	int mid = (a + b) / 2;
	node* buf = (node*)malloc(sizeof(node));
	buf->innum = mid;
	buf->left = NIL;
	buf->right = NIL;
	*focus = buf;
	makeT(a, mid, &((*focus)->left), turn + 1);
	makeT(mid + 1, b, &((*focus)->right), turn + 1);
}

vi ret;

void findT(int sx, int tx, int sy, int ty, node* focus, bool t) {
	if (focus == NIL) return;
	int xx = V[focus->innum].x, yy = V[focus->innum].y;
	if (sx <= xx && xx <= tx && sy <= yy && yy <= ty){
		ret.push_back(V[focus->innum].id);
	}
	if (t == 0) {
		if (sx <= xx) findT(sx, tx, sy, ty, focus->left, 1);
		if (xx <= tx) findT(sx, tx, sy, ty, focus->right, 1);
	}
	else {
		if (sy <= yy) findT(sx, tx, sy, ty, focus->left, 0);
		if (yy <= ty) findT(sx, tx, sy, ty, focus->right, 0);
	}
}

int main() {
	root = NIL;
	int n;
	scanf("%d", &n);
	Loop(i, n) {
		int x, y;
		scanf("%d %d", &x, &y);
		V[i] = { i, x, y };
	}
	makeT(0, n, &root, 0);
	int q;
	scanf("%d", &q);
	Loop(i, q) {
		int sx, tx, sy, ty;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ret.clear();
		findT(sx, tx, sy, ty, root, 0);
		sort(ret.begin(), ret.end());
		Loop(j, ret.size()) printf("%d\n", ret[j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 23996
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,n) for(ll i = 0; i < ((ll)(n)); i++)   // 0-indexed昇順

map<ll,ll> memo;
ll MOD = 1000000007;

ll fib(ll a) {
    if (memo.count(a) > 0) return memo[a];
    memo[a] = (fib(a-1) + fib(a-2)) % MOD;
    return memo[a];
}

int main() {
    memo[0] = 0;
    memo[1] = 1;

    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    rep(i,M) {
        cin >> A.at(i);
    }

    ll res = 1;
    ll cur = 0;
    for (ll a : A) {
        res *= fib(a - cur);
        res %= MOD;
        cur = a + 1;
    }
    res *= fib(N - cur + 1);

    cout << res % MOD << endl;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n;
void solve() {
    cin >> n;
    list<pair<string, char>> ans;
    ans.emplace_back("", 'a');
    rep(_, n) {
        itrep(i, ans) {
            auto tmp = i->first;
            loop(j, 'a', i->second) {
                ans.insert(i, make_pair(tmp + (char)j, i->second));
            }
            i->first += i->second;
            if (i->second != 'z') ++i->second;
        }
    }

    for (auto& m : ans) cout << m.first << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 12544
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
  if(v<=w){cout<<"NO";return 0;}
  if(b<a)swap(a,b);
  rep(i,t){
    a+=v;
    b+=w;
    if(a>=b){cout<<"YES";return 0;}
  }
  cout<<"NO";
}

Measured memory_bytes: 3592
a,b,c,x = open(0)
d=0
x = int(x)
 
for i in range(int(a)+1):
  for j in range(int(b)+1):
    for k in range(int(c)+1):
      if  500*i + 100*j + 50*k == x:
        d += 1
     
      
print(d)

Measured memory_bytes: 2940
n,K = map(int,input().split())
M = 10**9+7

c = 0
for k in range(K,n+2):
    c += n*(n+1)//2 - (n-k)*(n-k+1)//2 - k*(k-1)//2 + 1
# print("k=",k,"c=",c)
print(c%M)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string s;cin>>s;
	int cnt=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1]) cnt++;
	}
	cout<<cnt<<"\n";
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;


void prime_factorization(ll n,vector<ll> &vec){
    ll temp = n;

    for(ll i = 2;i*i <= n;i++){
        if(temp == 1) break;
        while(temp % i == 0){
            vec.push_back(i);
            temp /= i;
        }
    }
    if(temp != 1) vec.push_back(temp);
    return;
}


int main(){
    ll n; cin >> n;
    vector<ll> vec;
    prime_factorization(n, vec);
    
    cout << n << ":";
    rep(i,0,vec.size()){
        cout << " " << vec[i];
    }
    cout << endl;
    return 0;
}



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

int main(){
  int N,M;
  cin>>N>>M;
  priority_queue<int> L;
  priority_queue<int,vector<int>,greater<int>>R;
  for(int i=0;i<M;i++){
    int l,r;
    cin>>l>>r;
    L.push(l);
    R.push(r);
  }
  if(L.top()<=R.top())
    cout<<R.top()-L.top()+1<<endl;
  else
    cout<<0<<endl;
}

Measured memory_bytes: 1276
import java.util.Scanner;

/**
 * @ClassName BBQEasy
 * @Description TODO
 * @Author NebulaPort
 * @Date 2019/9/13 23:16
 */
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        in.nextLine();
        int[] value=new int[n*2];
        for (int i = 0; i <2*n ; i++) {
            value[i]=in.nextInt();

        }
        for (int i = 0; i <value.length; i++) {
            for (int j = 1; j <value.length-i ; j++) {
                if (value[j-1]>value[j]){
                    int tmp=value[j-1];
                    value[j-1]=value[j];
                    value[j]=tmp;
                }
            }
        }
        int sum=0;
        for (int i = 0; i <2*n ; i+=2) {
            sum+=value[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int s;
  	
  	cin>>s;
  	if(s%2==1){
    cout<<fixed<<setprecision(6);
    cout<<((double)s+1)/2/s<<endl;
    }
  	else{
    cout<<fixed<<setprecision(6);
    cout<<(double)s/2/s<<endl;
    }
}

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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, x, t;
	cin >> n >> x >> t;
	int times=(n+x-1)/x;
	int ans=times*t;
	cout << ans << "\n";
}


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

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;

    int ac[100500] = {}, lr[100500] = {};
    for(size_t i = 1, count = 0; i < n; i++) {
        if(s[i-1] == 'A' && s[i] == 'C') count++;
        ac[i] = count;
    }

    for(size_t i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        lr[i] = ac[r-1] - ac[l-1];
    }

    for(size_t i = 0; i < q; i++) {
        cout << lr[i] << endl;
    }
}

Measured memory_bytes: 1792
#include <stdio.h>

int main( void ) {
	int i, j, data[ 10 ], max, tmp;

	for ( i = 0; i < 10; i++ )
		scanf( "%d", data + i );

	for ( i = 0; i < 3; i++ ) {
		max = i;
		for ( j = i + 1; j < 10; j++ )
			if ( data[ max ] < data[ j ] )
				max = j;

		tmp = data[ i ];
		data[ i ] = data[ max ];
		data[ max ] = tmp;
	}

	for ( i = 0; i < 3; i++ )
		printf( "%d\n", data[ i ] );

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <iomanip>

using namespace std;

double dp[310][310][310];
int N;

double calcdp(int i, int j, int k){
    double res;
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    res = N;
    if (i > 0) res += calcdp(i - 1, j, k) * i;
    if (j > 0) res += calcdp(i + 1, j - 1, k) * j;
    if (k > 0) res += calcdp(i, j + 1, k - 1) * k;
    res /= (i + j + k);
    dp[i][j][k] = res;
    return res;
}

int main() {
    int d;
    int dd[3] = {0, 0, 0};

    cin >> N;
    for (int x = 0; x < N; x++){
        cin >> d;
        if (d != 0) {
            dd[d - 1] += 1;
        }
    }

    // テーブルの初期化
    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(10) << calcdp(dd[0], dd[1], dd[2]) << endl;

    return 0;
}

Measured memory_bytes: 233088
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair


using namespace std;

int main(){

    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    vector<int> water;
    vector<int> sugar;

    map<int,int> wm;
    map<int,int> sm;

    queue<int> tmpq;

    tmpq.push(0);

    while(!tmpq.empty()){
        int tmp = tmpq.front();

        if(wm[tmp] == 0 && tmp <= f){
            wm[tmp] = 1;
            water.pback(tmp);
            tmpq.push(tmp + a * 100);
            tmpq.push(tmp + b * 100);
        }

        tmpq.pop();
    }

    tmpq.push(0);

    
    while(!tmpq.empty()){
        int tmp = tmpq.front();

        if(sm[tmp] == 0 && tmp <= f){
            sm[tmp] = 1;
            sugar.pback(tmp);
            tmpq.push(tmp + c);
            tmpq.push(tmp + d);
        }

        tmpq.pop();
    }

    float p = 0;
    int bestw = 0;
    int bests = 0;;

    rep(i,water.size()){
        rep(j,sugar.size()){
            int tmpw = water[i];
            int tmps = sugar[j];

            if(tmpw == 0 || tmpw + tmps > f || 100.0 * tmps / tmpw > 1.0 * e) continue;

            if(p < 100.0 * tmps / (tmpw + tmps)){
                bestw = tmpw;
                bests = tmps;
                p = 100.0 * tmps / (tmpw + tmps);
            }
        }
    }

    if(bestw == 0){
        bestw = water[1];
    }

    cout << bestw + bests << " " << bests << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
char str[100000][11] = {0};
int main(){
	long long int i, n, j, Count = 0;
	map<string, int> m;
	cin >> n;
	rer(i,0,n){
		cin >> str[i];
		sort(str[i],str[i]+strlen(str[i]));
		Count += m[str[i]]++;
	}
//	map<string,int>::iterator mi;
//	for(mi=m.begin(); mi!=m.end();mi++){
//		if(mi->second!=1){
//			Count+=mi->second;
//		}
//	}
	cout << Count << endl;
	return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	int n;
	cin>>n;
	bool a[1005];
	for(int i=0;i<n+1;i++){
		a[i]=true;
	}
	vector<int> pri;
	for(int i=2;i<n+1;i++){
		if(a[i]){
			pri.push_back(i);
			int p=i;
			while(p<=n){
				a[p]=false;
				p+=i;
			}
		}
	}
	int cnt[pri.size()];
	for(int i=0;i<pri.size();i++){
		cnt[i]=0;
		int ad=n;
		while(ad!=0){
			ad/=pri[i];
			cnt[i]+=ad;	
		}
	}
	ll ans=1;
	for(int i=0;i<pri.size();i++){
		ans=ans*(cnt[i]+1)%inf;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>

using namespace std;
int main() {
    int ans=0;
    string  s,t;
    cin>>s>>t;
    if(s[0]==t[0])ans++;
    if(s[1]==t[1])ans++;
    if(s[2]==t[2])ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,W;
int g_w[2002][2002];
int g_h[2002][2002];
int main() {
  cin >> H >> W;
  int cnt_w = 0;
  int cnt_h = 0;
  // 横連続
  for (int i=0;i<H;i++ ) {
    string s;
    cin >> s;
    for ( int j=0;j<W;++j) {
      if (s[j] == '.') {
        ++cnt_w;
      } else {
        if (cnt_w>0) {
          for (int k=j-cnt_w;k<j;++k) {
            g_w[i][k] = cnt_w;
          }
        }
        cnt_w = 0;
      }
    }
    if( cnt_w>0) {
      for (int k=W-cnt_w;k<W;++k) {
        g_w[i][k] = cnt_w;
      }
      cnt_w = 0;
    }
  }
  // 縦連続
  for (int j=0;j<W;++j ) {
    for ( int i=0;i<H;++i) {
      if (g_w[i][j] != 0) {
        ++cnt_h;
      } else {
        if (cnt_h>0) {
          for (int k=i-cnt_h;k<i;++k) {
            g_h[k][j] = cnt_h;
          }
        }
        cnt_h = 0;
      }
    }
    if( cnt_h>0) {
      for (int k=H-cnt_h;k<H;++k) {
        g_h[k][j] = cnt_h;
      }
      cnt_h = 0;
    }
  }
/*  
  for (int i=0;i<H;++i) {
    for (int j=0;j<W;++j) {
      cout << g_w[i][j];
    }
    cout << endl;
  }
  cout << endl;
  for (int i=0;i<H;++i) {
    for (int j=0;j<W;++j) {
      cout << g_h[i][j];
    }
    cout << endl;
  }
  */
  int mv = 0;
  for (int i=0;i<H;++i) {
    for (int j=0;j<W;++j) {
//      g_w[i][j] += g_h[i][j] - 1;
      mv = max(mv, g_w[i][j]+ g_h[i][j] - 1);
    }
  }
  cout << mv << endl;
}
  


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0;
    cin>>n;
    long long a[3*n];
    f(i,0,3*n){
        cin>>a[i];
    }
    sort(a,a+3*n);
    for(int i=n;i<3*n;i+=2){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void)
{
    string S;
    ll K;
    cin >> S >> K;

    ll n = S.size();


    ll leftSeq = 0;
    ll rightSeq = 0;

    
    for (int i = 0; i < n; i++)
    {
        if (S[i] == S[0])
            leftSeq++;
        else
            break;
    }

    if(leftSeq == n){
        cout << n * K / 2 << endl;
        return 0;
    }

    for (int i = n-1; i >= 0; i--)
    {
        if (S[i] == S[n - 1])
            rightSeq++;
        else
            break;
    }

    ll singleCnt = 0;
    char val = S[0];
    int seq = 1;
    for(int i = 1; i <= n; i++){
        if(val == S[i]) {
            seq++;
        } else {
            singleCnt += seq/2;
            val = S[i];
            seq = 1;
        }
    }

    if(rightSeq%2 == 1 && leftSeq %2 == 1 && K%2 == 0){
        cout << ((singleCnt + 1 ) * K) - 1 << endl;
    } else {
        cout << singleCnt * K << endl;
    }

    return 0;
}


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

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

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

	while(true){
		int m,n; cin >> m;
		if(m == 0) break;
		vector<P> a(m);
		for (int i = 0;i < m;i++){
			cin >> a[i].first >> a[i].second;
		}
		sort(a.begin(),a.end());
		int x = a[0].first, y = a[0].second;
		for (int i = 0;i < m;i++){
			a[i] = P(a[i].first-x, a[i].second-y);
		}
		map<P,bool> mp;
		cin >> n;
		for (int i = 0;i < n;i++){
			int x,y; cin >> x >> y;
			mp[P(x,y)] = true;
		}

		bool f = false;
		
		for(auto&& i : mp){
			int idx = 0;
			int fx = i.first.first, fy = i.first.second;
			while(mp[P(a[idx].first+fx,a[idx].second+fy)]){
				if(idx == m-1){
					cout << fx - x << " " << fy - y << endl;
					f = true;
					break;
				}
				idx++;
			}
			if(f) break;
		}

	}

	return 0;

}



Measured memory_bytes: 3152
// atcoder/abc173/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename T, typename U> inline pair<T, U> swap(pair<T, U>& p) { swap(p.first, p.second); return p; }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  lli n;
  while (cin >> n) {
    vec<pair<int, int>> v(n - 1);
    cin >> v;
    each (i, v) --i.first, --i.second;

    // 木の場合:
    // 連結成分の数 = 頂点数 - 辺数

    lli x = 0;
    for (int i = 0; i < n; ++i) {
      x += (i + 1) * (n - i);
    }
    each (e, v) {
      unless (e.first < e.second) swap(e);
      x -= (e.first + 1) * (n - e.second);
    }
    cout << x << endl;
  }

  return 0;
}


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

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(q);
  vector<int> b(q);
  vector<int> c(q);
  vector<int> d(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

  vector<vector<int>> vecAs;
  for (int i1 = 1; i1 <= m; i1++) {
    for (int i2 = i1; i2 <= m; i2++) {
      if (n == 2) vecAs.push_back({i1, i2});
      for (int i3 = i2; i3 <= m; i3++) {
        if (n == 3) vecAs.push_back({i1, i2, i3});
        for (int i4 = i3; i4 <= m; i4++) {
          if (n == 4) vecAs.push_back({i1, i2, i3, i4});
          for (int i5 = i4; i5 <= m; i5++) {
            if (n == 5) vecAs.push_back({i1, i2, i3, i4, i5});
            for (int i6 = i5; i6 <= m; i6++) {
              if (n == 6) vecAs.push_back({i1, i2, i3, i4, i5, i6});
              for (int i7 = i6; i7 <= m; i7++) {
                if (n == 7) vecAs.push_back({i1, i2, i3, i4, i5, i6, i7});
                for (int i8 = i7; i8 <= m; i8++) {
                  if (n == 8) vecAs.push_back({i1, i2, i3, i4, i5, i6, i7, i8});
                  for (int i9 = i8; i9 <= m; i9++) {
                    if (n == 9)
                      vecAs.push_back({i1, i2, i3, i4, i5, i6, i7, i8, i9});
                    for (int i10 = i9; i10 <= m; i10++) {
                      if (n == 10)
                        vecAs.push_back(
                            {i1, i2, i3, i4, i5, i6, i7, i8, i9, i10});
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  int ans = 0;
  for (vector<int> vecA : vecAs) {
    int point = 0;
    rep(i, q) {
      if (vecA[b[i] - 1] - vecA[a[i] - 1] == c[i]) point += d[i];
    }
    ans = max(ans, point);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  int res = 0;
  map<string, int> m;
  rep(i, n) {
    res = max(res, ++m[s[i]]);
  }
  vector<string> ans;
  rep(i, n) {
    if (m[s[i]] == res) {
      ans.push_back(s[i]);
      m[s[i]] = 0;
    }
  }
  sort(ans.begin(), ans.end());
  rep(i, ans.size()) cout << ans[i] << endl;


  
  return 0;
}

Measured memory_bytes: 28404
import java.util.*;

public class Main{
//public class abc164_a{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int s = scan.nextInt();
		int w = scan.nextInt();

		
		if(s > w){
			System.out.println("safe");
		}else{
			System.out.println("unsafe");
		}
	}

}

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

int main(){
	long long int n,k,l,sum=0;
	std::cin>>n>>k;

	std::vector<int> v(n);
	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(), v.end());

	l = v.size() - k;

	for (int i = 0; i < l; i++) {
		sum += v[i];
	}



	std::cout<<sum<<std::endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    long long x, y;

    while(scanf("%lld %lld", &x, &y)==2)
    {
        int count = 0;
        while(x<=y)
        {
            count++;
            x*=2;
        }

        printf("%d\n", count);
    }

    return 0;
}

Measured memory_bytes: 128