akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{   
    string s ;
    cin >> s ;
    ll a[4] ;
    for(ll i = 0 ; i < 4 ; i++){
        a[i] = s[i] - '0' ;
    }

    ll ans = 0 ;

    
        for(ll k = 0 ; k < 2 ; k++){
            for(ll l = 0 ; l < 2 ; l++){
                for(ll m = 0 ; m < 2 ;m++){
                    ans += a[0] ;
                    if(k == 0){
                        ans += a[1] ;
                    }else{
                        ans -= a[1] ;
                    }
                    if(l == 0){
                        ans += a[2] ;
                    }else{
                        ans -= a[2] ;
                    }
                    if(m == 0){
                        ans += a[3] ;
                    }else{
                        ans -= a[3] ;
                    }

                    if(ans == 7){
                        cout << a[0] ;
                        if(k==0){
                            cout << "+" ;
                        }else{
                            cout << "-" ;
                        }
                        cout << a[1] ;
                        if(l==0){
                            cout << "+" ;
                        }else{
                            cout << "-" ;
                        }
                        cout << a[2] ;
                        if(m==0){
                            cout << "+" ;
                        }else{
                            cout << "-" ;
                        }
                        cout << a[3] ;
                        cout << "=7" << endl;

                        return 0 ;
                    }
                    ans = 0 ;
                }
            }
        }
    

    
    

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		TreeMap<Integer, Integer>map = new TreeMap<>();
		
		int tmp = 0;
		
		for (int i=0;i<n;i++) {
			int x = sc.nextInt();
			if (!map.containsKey(x)) {
				map.put(x, 0);
			}
			tmp = map.get(x);
			map.put(x, tmp+1);
		}
		int count = 0;
		while(!map.isEmpty()) {
			int a = map.lastKey();
			int b =Integer.highestOneBit(a)*2-a;
			if (map.containsKey(b) && a!=b) {
				count++;
				
				tmp = map.get(a);
				if (tmp>1) {
					map.put(a, tmp-1);
				} else {
					map.remove(a);
				}
				
				tmp = map.get(b);
				if (tmp>1) {
					map.put(b, tmp-1);
				} else {
					map.remove(b);
				}
			} else if (map.containsKey(b) && a==b) {
				tmp = map.get(a);
				if (tmp>=2) {
					count++;
				}
				
				if (tmp>2) {
					map.put(a, tmp-2);
				} else {
					map.remove(a);
				}
				
			} else {
				map.remove(a);
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 101216
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ; 
    int k ; 
    cin >> k ; 
    cout << v[k - 1] << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int abc;
    set<int> s;
    rep(i,3) {
        cin >> abc;
        s.insert(abc);
    }
    if (s.size()==2) cout << "Yes";
    else             cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a, b[2], i;

  scanf("%d", &a);

  b[0] = a % 10;
  a /= 10;
  b[1] = a/10;

  if(b[0] == b[1]){
    printf("Yes\n");
  }

  else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll ksm(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=2e5+10;
string a;
int n;
map<string,int>m;
int main(){
	scanf("%d",&n);
	int ans=0;
	while(n--){
		cin>>a;
		if(!m[a]){
			m[a]=1;
			ans++;
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 19308
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
    int a[N+1],b[N+1],c[M+1],d[M+1];
    int i,j,ans;
    int distance;
    int min;
    for(i=0;i<N;i++){
        scanf("%d %d",&a[i],&b[i]);
    }
    for(i=0;i<M;i++){
        scanf("%d %d",&c[i],&d[i]);
    }
    for(i=0;i<N;i++){
        min = INT_MAX;
        distance = 0;
        for(j=0;j<M;j++){
            distance = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(distance < min){
                min = distance;
                ans = j + 1;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int compare(const void *x, const void *y)
{
	return *(int*)y - *(int*)x;
}


int main(void)
{
	int N, i;
	long a[300000], ans = 0;
	scanf("%d", &N);
	for (i = 0; i < N * 3; ++i) scanf("%ld", &a[i]);
	qsort(a, N * 3, sizeof(long), compare);
	for (i = 1; i < N * 2; i += 2) ans += a[i];
	printf("%ld", ans);
	return 0;
}

Measured memory_bytes: 4860
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int n, m, a, b, c, t;
	while (cin >> n >> m >> a >> b >> c >> t,n) {
		int out[52] = {};
		int ori[52] = {};
		rep1(i, n) {
			cin >> ori[i];
		}
		int tra[40][52][52] = {};
		rep1(i, n) {
			tra[0][i][i - 1] = c;
			tra[0][i][i] = b;
			tra[0][i][i + 1] = a;
		}
		rep(i, 32) {
			rep1(j, n) {
				rep1(k, n) {
					rep1(l, n) {
						tra[i + 1][j][l] += tra[i][j][k] * tra[i][k][l]%m;
					}
				}
			}
			rep1(j, n) {
				rep1(k, n) {
					tra[i + 1][j][k] %= m;
				}
			}
		}
		rep1(i, n) {
			out[i] = ori[i];
		}
		rep(i, 32) {
			if (t&(1 << i)) {
				int z[52] = {};
				rep1(j, n) {
					rep1(k, n) {
						z[k] += out[j]*tra[i][j][k] % m;
					}
				}
				rep1(j, n) {
					out[j] = z[j]%m;
				}
			}
		}
		rep1(i, n) {
			cout << out[i];
			if (i <= n - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3408
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	ll N, M; cin >> N >> M;
	N = (N > 1 ? N - 2 : N);
	M = (M > 1 ? M - 2 : M);
	cout << N * M << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int x, y, g[13];

int main() {
	cin >> x >> y;
	g[4] = g[6] = g[9] = g[11] = 1;
	g[2] = 2;
	if (g[x] == g[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void main()
{
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  
  if(a == b || b == c){
  	if(a != c)
      printf("Yes\n");
    else
      printf("No\n");
  }
  else if(a == c){
  	if(a != b)
      printf("Yes\n");
    else
      printf("No\n");
  }
  else 
    printf("No");
}

Measured memory_bytes: 1676
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char x[1000];
    int sum =0;
    while(1) {
        scanf("%s",x);
        if(strlen(x) == 1 && x[0] == '0') break;
        for(int i = 0; i < strlen(x);i++){
            sum += x[i] - '0';
        }
        cout << sum << endl;
        sum = 0;
        
    }
    
  
   
   
   
    return 0;
}

Measured memory_bytes: 1156
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s | b + c == a || a + c == b || a + b == c = "Yes"
        | otherwise                              = "No"
  where [a, b, c] = fmap read (words s) :: [Int]

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

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

int main(){
  int n;
  int b,f,r,v;
  int res[4][3][10];

  cin>>n;

  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        res[i][j][k]=0;
      }
    }
  }

  for(int i=0; i<n; i++){
    cin>>b>>f>>r>>v;
    res[b-1][f-1][r-1]=res[b-1][f-1][r-1]+v;
  }

  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        if(k==9){
          cout<<" "<<res[i][j][k]<<endl;
        }else{
          cout<<" "<<res[i][j][k];
        }
      }
      if(j==2 && i!=3){
        cout<<"####################"<<endl;
      }
    }
  }
  return 0;
}

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

int main(){
  string s,S,T;
  cin>>s;
  int ans=1;
  S+=s[0];
  bool flag=false;
  for(int i=1;i<s.size();i++){
    if(flag) {T=s[i]; flag=false;}
    else T+=s[i];
    if(S==T) continue;
    else{
      ans++;
      S=T;
      flag=true;
    }
  }
  cout<<ans<<endl;
}
  

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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int q;
  cin >> q;;
  vector<int> a;

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int x; cin >> x;
      a.push_back(x);
    } else if (command == 1) {
      int p; cin >> p;
      ans.push_back(a[p]);
    } else {
      a.pop_back();
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define rep(p,a,b)    for(ll p=a;p<b;p++)
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

ll nextPowerOf2(ll n)
{
    n--;
    n |= n >> 1ll;
    n |= n >> 2ll;
    n |= n >> 4ll;
    n |= n >> 8ll;
    n |= n >> 16ll;
    n++;
    return n;
}


int main()
{

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("o1.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,t,i,j,k,ans;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        ans = 1000ll - (n%1000ll);
        if(ans==1000)ans=0;
        cout<<ans;
    }
    return 0;
}




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

int main() {
  ll X;
  cin >> X;
  ll result = 100;
  ll cnt = 0;
  while (X > result) {
    result *= 1.01;
    ++cnt;
  }
  cout << cnt << endl;
  
  return 0;
}


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

#define int long long int


int32_t main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(-max(a,c)+min(b,d)<0?0:-max(a,c)+min(b,d))<<endl;
}

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

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

  if (A == B &&  B != C) {
    cout << "Yes" << endl;
  }
  else if (A == C &&  A != B) {
    cout << "Yes" << endl;
  }
  else if (C == B &&  B != A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++){
        a[i]=i+1;
    }
    for(int i=0; i<n-1; i++)
        cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
    while(next_permutation(a, a+n)){
        for(int i=0; i<n-1; i++)
            cout<<a[i]<<" ";
    
        cout<<a[n-1]<<endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (0 <= N && N <= 1) {
    cout << N << endl;
    return 0;
  }

  string S = "";
  int j = 0;
  while (N != 0) {
    if (N % 2 == 0) {
      S = "0" + S;
    } else {
      S = "1" + S;
      N -= 1;
    }
    N /= -2;
  }
  cout << S << endl;
}


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

int main() {
	int A[8];
	int n = 0;
	while (n < 8) {
		cin >> A[n];
		n++;
	}
	int M = A[0] + A[1] + A[2] + A[3];
	int N = A[4] + A[5] + A[6] + A[7];
	if (M > N) {
		cout << M << endl;
	}
	else {
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define mod2 10000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll n;
    cin>>n;
    n%=1000;
    if(n==0)
    cout<<"0";
    else
    cout<<1000-n;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
int main(){
    long long N, ans=0;
    cin >> N;
    rep(i, N+1){
        if (i%3!=0 && i%5 !=0) ans = ans + i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
<?php
fscanf(STDIN, "%d %d", $N, $X);
$x = explode(" ", trim(fgets(STDIN)));
$x[] = $X;
$x_min = min($x);
$x = array_map(function($a) use($x_min) {return $a - $x_min;}, $x);

for ($i = 1; $i <= $N; $i++) {
    if (!isset($ans)) {
        $ans = gcd($x[$i - 1], $x[$i]);
    } else {
        $ans = gcd($ans, $x[$i]);
    }
    if ($ans === 1) break;
}
echo $ans;

//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}


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

int main()
{
    int x, y;
    scanf("%d %d", &x, &y);
    if (x >= y)
    {
        for (int i = 0; i < x; i++)
        {
            printf("%d", y);
        }
    }
    else if (x < y)
    {
        for (int i = 0; i < y; i++)
        {
            printf("%d", x);
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String str = sc.next();
			int max = 0;
			int cnt = 0;
			for (int i = 0; i < str.length() - 1; i++) {
				if (str.charAt(i) == str.charAt(i + 1)) {
					cnt++;
				} else {
					max = Math.max(max, cnt);
					cnt = 0;
				}
			}
			max = Math.max(max, cnt);
			if (max > 1) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 26984
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K, N;
  cin >> N >> K;
  vector<double> p(N);
  for(int i=0;i<N;i++) cin >> p.at(i);
  vector<double> E(N);
  for(int i=0;i<N;i++){
    E.at(i) = 1.0/2.0 * (p.at(i) + 1.0);
    //cout << E.at(i) << endl;
  }
  double ma = 0;
  double E_sum = 0;
  for(int i=0;i<K;i++){
      E_sum += E.at(i);
      //cout << E_sum << endl;
    }
  //cout << E_sum << endl;
  ma = max(ma, E_sum);
  for(int i=0;i<N-K;i++){
    E_sum += E.at(K + i);
    E_sum -= E.at(i);
    //cout << E_sum << endl;
    ma = max(ma, E_sum);
  }
  printf("%.10lf\n",ma);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll h, w;
  cin >> h >> w;
  
  queue<pair<int, int>> Q1;

  vector<pair<ll, ll>> white(0), brack(0);
  char a[1000][1000];
  ll n = 0;
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cin >> a[i][j];
      if (a[i][j] == '#'){
        Q1.push(make_pair(i, j));
        n++;
      }
    }
  }

  int res = 0;
  while (n < h*w){
    queue<pair<int, int>> Q2;
    while(!Q1.empty()){
      pair<int, int> P = Q1.front();
      Q1.pop();

      int x = P.first, y = P.second;
      if (x != 0){
        if (a[x-1][y] == '.'){
          a[x-1][y] = '#';
          Q2.push(make_pair(x-1, y));
          n++;
        }
      }
      if (x != h - 1){
        if (a[x+1][y] == '.'){
          a[x+1][y] = '#';
          Q2.push(make_pair(x+1, y));
          n++;
        }
      }
      if (y != w - 1){
        if (a[x][y+1] == '.'){
          a[x][y+1] = '#';
          Q2.push(make_pair(x, y+1));
          n++;
        }
      }
      if (y != 0){
        if (a[x][y-1] == '.'){
          a[x][y-1] = '#';
          Q2.push(make_pair(x, y-1));
          n++;
        }
      }
    }
    Q1 = Q2;

    res++;
  }

  cout << res << endl;


  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int x; std::cin >> x;
  vl vec;
  vec.pb(0);
  ll a = 1;
  while (1) {
    ll tmp = 1;
    rep(i, 5) tmp *= a;
    if (tmp > 1e18) break;
    vec.pb(tmp);
    a++;
  }
  rep(a, vec.size()) rep(b, vec.size()) {
    if (vec[a] - vec[b] == x) {
      std::cout << a << " " << b << "\n";
      return 0;
    } else if (vec[a] + vec[b] == x) {
      std::cout << a << " " << -1*(b) << "\n";
      return 0;
    }
  }
}


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

int main(){
  int N,M,C; cin >> N >> M >> C;
  int B[M];
  
  for(int i=0; i<M; i++){
    cin >> B[i];
  }
  
  int count=0; int sum,input;
  for(int i=0; i<N; i++){
    sum = 0;
    for(int j=0; j<M; j++){
      cin >> input; sum = sum + B[j]*input;
    }
   	if(sum+C>0){count++;}
  }
  
  cout << count;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include <cmath>

using namespace std;

int main() {
	long double b;
	int n;
	cin >> n;
	if (n % 3 == 0) {
		long long int aa;
		aa = (n / 3) * (n / 3) * (n / 3);
		cout << aa << endl;
	}
	else {
		string s = "", ss = "";
		long long int bb = 0;
		bb = n * n * n / 27;
		s += to_string(bb);
		long double cc = (n * n * n) % 27;
		ss = to_string(cc / 27);
		reverse(ss.begin(), ss.end());
		ss.pop_back();
		reverse(ss.begin(), ss.end());
		s += ss;
		cout << s << endl;
	}
}







Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3636
#include<iostream>
#include<string>
int main() {
	int g[3];
	int temp=0,s=0;
	std::cin >> g[0]>>g[1]>>g[2];

	for (int j = 0; j < 3; j++) {
		for (int i = 1; i < 3; i++) {
			if (g[i] > g[i - 1]) {
				temp = g[i];
				g[i] = g[i - 1];
				g[i - 1] = temp;
			}
		}
	}

	
	
	
	s= abs(g[0] - g[1]);
	
	 s+= abs(g[1]-g[2]);

	std::cout << s << std::endl;
	
}

Measured memory_bytes: 256
import math

N = int(input())

NN = math.floor(N / 1.08)

NNN = math.floor(NN*1.08)

if N == NNN:
    print(NN)
else:
    if math.floor((NN+1)*1.08) == N:
        print(NN+1)
    else:
        print(':(')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num5=0, num7=0;
  for(int i = 0; i < 3; i++) {
    int a;
    cin >> a;
    if(a == 5) {
      num5++;
    }
    else if(a == 7) {
      num7++;
    }
  }
  if(num5 == 2 && num7 == 1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

using namespace std;

int main() {
  vector<pair<double, double>> seq;
  double x, y;
  while (scanf("%lf,%lf", &x, &y) != EOF)
    seq.push_back(make_pair(x, y));
  seq.push_back(make_pair(seq[0].first, seq[0].second));

  double xm = seq[0].first;
  double ym = seq[0].second;
  double sum = 0.;

  for (int i = 0; i < seq.size() - 1; ++i) {
    double x1 = seq[i].first;
    double y1 = seq[i].second;
    double x2 = seq[i+1].first;
    double y2 = seq[i+1].second;
    double a = sqrt(pow(x1 - x2, 2) + pow(y1 -y2, 2));
    double b = sqrt(pow(x1 - xm, 2) + pow(y1 -ym, 2));
    double c = sqrt(pow(xm - x2, 2) + pow(ym -y2, 2));
    double z = (a + b + c) / 2.;
    double s = sqrt(z * (z - a) * (z - b) * (z - c));
    sum += s;
  }
  printf("%.10lf\n", sum);
}


Measured memory_bytes: 3152
n = int(input())
a = list(map(int, input().split()))

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)


Measured memory_bytes: 24748
#include <stdio.h>
int main(void){
    int n,i,mmax,sum;
    int pi[10]={0};
    mmax=0;
        sum=0;
    scanf("%d", &n);
    for(i=0;i<10;i++){
        scanf("%d", &pi[i]);
        if(pi[mmax]<pi[i]){
            mmax=i;
        }
    }
    pi[mmax]=pi[mmax]/2;
    for(i=0;i<10;i++){
        sum=sum+pi[i];
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
import collections
N=int(input())
A=list(map(int,input().split()))
A=collections.Counter(A)
mod = 10**9 + 7
for i in range(1,N,2) if N%2==0 else range(2,N,2):
    if A[i]!=2:
        print(0)
        exit()
if N%2==1:
    if not 0 in A or A[0]!=1:
        print(0)
        exit()
print((2**((N-N%2)//2)) % mod)


Measured memory_bytes: 55532
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, D[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> D[i];
	sort(D, D + N);

	int A = D[N / 2 - 1];
	int B = D[N / 2];

	int ans = B - A;

	cout << ans << endl;
}







Measured memory_bytes: 640
#include<cstdio>
#include<string>
#include<queue>
using namespace std;

int main() {
  char com[20];
  // 標準ライブラリの priority_queue を使用
  priority_queue<int> PQ;

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      int key ; scanf("%d", &key);  // cin より高速な scanf を使用
      PQ.push(key);
    } else if ( com[1] == 'x' ) {
      printf("%d\n", PQ.top());
      PQ.pop();
    } else if ( com[0] == 'e' ) {
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 6464
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"sort"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func factor(n int) map[int]int {
	retval := make(map[int]int)
	for n > 1 {
		for i := 2; i <= n; i++ {
			if n % i == 0 {
				retval[i]++
				n /= i
				break
			}
		}
	}
	return retval
}

func pow(x, y, mod int) int {
	res := 1
	for y > 0 {
		if (y & 1) == 1 {
			res *= x
			res %= mod
		}
		y >>= 1
		x *= x
		x %= mod
	}
	return res
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	M := N * 3
	A := make([]int, M)
	for i := 0; i < M; i++ {
		A[i] = io.NextInt()
	}
	sort.Ints(A)
	ans := 0
	for i := 0; i < N; i++ {
		ans += A[M - (2*i+1) - 1]
	}
	io.PrintLn(ans)
}


Measured memory_bytes: 17408
n, m = map(int, input().split())
a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())

for i in range(n):
    min_dist, min_c = 10**9, -1
    for j in range(m):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dist < min_dist:
            min_dist = dist
            min_c = j
    print(min_c+1)

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

string ans;
string s1,s2;

void Calc(int up,int indx1,int indx2){


  if(indx1==-1){
    if(up!=0){ans.insert(ans.begin(),(char)(up+(int)'0'));}
    return;
  }


  if(indx2>=0){
    int work = s1[indx1]-'0' + s2[indx2]-'0' + up;

    up = work/10;
    work = work%10;

    ans.insert(ans.begin(),(char)((int)'0'+work));
  }

  else{
    int work = s1[indx1]-'0' + up;

    up = work/10;
    work = work%10;

    ans.insert(ans.begin(),(char)((int)'0'+work));
  }


  Calc(up,indx1-1,indx2-1);
}

int main(){

  char head1,head2;
  string tmp;
  int size;
  int n;


  cin >> n;

  for(int i=0; i<n; i++){
    ans="";
    cin >> s1;
    cin >> s2;
    if(s1.size()<s2.size()){ tmp=s1;s1=s2;s2=tmp; }

    if(s1.size()>=81 || s2.size()>=81)
      cout<<"overflow"<<endl;
    else if((s1.size()>=80 || s2.size()>=80) && s1[0]-'0'+s2[0]-'0'>=10)
      cout<<"overflow"<<endl;
    else{
      Calc(0,s1.size()-1,s2.size()-1);
      cout << ans << endl;
    }
  }

  return 0;
}

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

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

int main(){
  ll a,b;
  cin>>a>>b;
  
  ll ans;
  if(a==b){
    ans=a;
  }
  else if(a%2==1 && b%2==0){
    ans=a^b^((b-a-1)/2%2);
  }
  else if(a%2==1 && b%2==1){
    b++;
    ans=a^b^((b-a-1)/2%2);
    ans^=b;
  }
  else if(a%2==0 && b%2==0){
    a++;
    ans=a^b^((b-a-1)/2%2);
    ans^=a-1;
  }
  else if(a%2==0 && b%2==1){
    a++;
    b++;
    ans=a^b^((b-a-1)/2%2);
    ans=ans^(a-1)^b;
  }
 
  cout<<ans<<endl;
  return 0;
}

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

int n,cnt;
int a[100010];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) if(a[i]!=i) cnt++;
	if(cnt==0||cnt==2) puts("YES");
	else puts("NO"); 
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    if(n==3):
        print(2,5,63)
        return
    if(n==4):
        print(2,5,20,63)
        return

    q=n//8
    r=n%8
    ans=list(i for i in range(1,12*q+1) if(i%2==0 or i%3==0))
    x=12*q
    if(r==1):
        ans+=[x+6]
    elif(r==2):
        ans+=[x+2,x+4]
    elif(r==3):
        ans+=[x+2,x+4,x+6]
    elif(r==4):
        ans+=[x+2,x+4,x+6,x+12]
    elif(r==5):
        ans+=[x+2,x+3,x+4,x+6,x+9]
    elif(r==6):
        ans+=[x+2,x+3,x+4,x+6,x+9,x+12]
    elif(r==7):
        ans+=[x+2,x+3,x+4,x+6,x+8,x+9,x+10]
    print(*ans)
resolve()

Measured memory_bytes: 42224
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
		int N,B;
		cin >> N;
		vector <int>X(N),A(100);
		rep(i, N)
			cin >> X[i];
		rep(i,100 ) {
			rep(j, N) {
				A[i] += pow(X[j] - i, 2);
			}
		}
		B = *min_element(all(A));
		cout << B ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod=998244353;
const int N=3e5+5;
const int inf=1e9+7;
int da[N];
char s[N];
int judge(int ii,int jj){
    //for(int i=ii;i<=jj;i++)cout<<s[i];cout<<endl;
    for(int i=ii;i<=jj;i++){
        if(s[i]!=s[jj-(i-ii)])return 0;
    }
    return 1;
}
int main()
{
    /*
    int n,p,q,s,x;
    scanf("%d%d%d%d",&n,&p,&q,&s);
    for(int i=0; i<p; i++)
        scanf("%d",&da[i]);
        */
    scanf("%s",s+1);
    int n=strlen(s+1);
    if(judge(1,n)&&judge(1,(n-1)/2)&&judge((n+3)/2,n))
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int A,B,ans;
  scanf("%d %d",&A,&B);
  if(A>B){
  ans=A-B*2;
    if(ans>0){
    printf("%d",ans);
    }
    else{
    printf("0");
    }
  }
  else{
  printf("0");
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a = N%10;
  if(a==3){
    cout << "bon" << endl;
  }
  else if(a==0||a==1||a==6||a==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3572
n,m = map(int,input().split())
likes = [0]*(m+1)
for _ in range(n):
    ka = list(map(int,input().split()))
    a = ka[1:]
    for like_idx in a:
        likes[like_idx] += 1

ans = 0
for num in likes:
    if num >=n:
        ans += 1
print(ans)

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vll a(n); rep(i,n) cin >> a[i];
    int i = 0, cnt_odd = 0;
    rep(i,n){
        if(a[i]%2 == 1) cnt_odd++;
    }
    cout << ( cnt_odd %2 == 0  ? "YES" : "NO") << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------
vector<long long> factor_array(long long n){
    vector<long long> res ;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i) ;
            if(i*i!=n){
                res.push_back(n/i) ;
            }
        }
    }
    sort(res.begin(),res.end()) ;
    return res ;
}

bool is_prime(long long n){
    if(n==2){
        return true ;
    }
    else if(n<2 || n%2==0){
        return false ;
    }
    else{
        long long i = 3 ;
        while(i*i<=n){
            if(n%i==0){
                return false ;
            }
            i += 2 ;
        }
        return true ;
    }
}

map<long long, long long> prime_factorization(long long n){
    map<long long, long long> res ;
    vector<long long> tmp = factor_array(n) ;
    for(long long i = 0; i<(long long)tmp.size(); i++){
        if(is_prime(tmp[i])){
            long long m = n ;
            long long cnt = 0 ;
            while(m%tmp[i]==0){
                m /= tmp[i] ;
                cnt++ ;
            }
            res[tmp[i]] = cnt ;
        }
    }
    return res ;
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n ;
    cin >> n ;
    map<ll,ll> ans ;
    FOR(i,1,n+1){
        map<ll,ll> ma = prime_factorization(i) ;
        IREP(j,ma){
            ans[j->FI] += j->SE ;
        }
    }
    ll answer = 1 ;
    IREP(i,ans){
        answer *= (i->SE + 1) ;
        answer %= MOD ;
    }
    cout << answer <<endl;
    return 0;
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> count(n, 0);
    vector<int> higher(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    vector<int> a(m);
    vector<int> b(m);
    int tmp1, tmp2;
    for (int i = 0; i < m; i++)
    {
        cin >> tmp1 >> tmp2;
        a[i] = tmp1 - 1, b[i] = tmp2 - 1;
        count[a[i]]++, count[b[i]]++;
        if (h[a[i]] > h[b[i]])
            higher[a[i]]++;
        else if (h[a[i]] < h[b[i]])
            higher[b[i]]++;
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (count[i] == higher[i])
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5112
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
const int N=100010;
int l[N],r[N],num[N];
bool cmp(int i,int j){
	return r[i]<r[j];
}
int main(){
	n=read();
	int a,b;
	for (int i=1;i<=n;i++){
		a=read();
		b=read(); 
		l[i]=a-b;
		r[i]=a+b;
		num[i]=i;
	}
	sort(num+1,num+1+n,cmp);
//	for (int i=1;i<=n;i++){
//		cout<<l[num[i]]<<" "<<r[num[i]]<<endl;
//	}
	int ans=n;
	for (int i=1;i<n;i++){
		if (r[num[i]]<=l[num[i+1]])continue;
		ans--;
		r[num[i+1]]=r[num[i]];
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());

            long n = long.Parse(Console.ReadLine());

            
            long ans = 0;
            for(int a=1; a<= n; a++)
            {
                for(int b= a; b <= n; b++)
                {
                    for(int c = b; c <= n; c++)
                    {
                        long temp= Gcd(Gcd(a, b), c);
                        ans += temp;
                        if (a != b || b != c) ans += 2 * temp;
                        if (a!=b && b != c) ans += 3 * temp;

                    }
                }
            }

            Console.WriteLine(ans);

            //ここまで
        }


        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
    }

}


Measured memory_bytes: 40560
function Main(input){
  	var M = parseInt(input.trim().split(" ")[0],10);
  	var H = parseInt(input.trim().split(" ")[1],10);
  	var result = (M === 1 || H === 1)?1:Math.ceil(M*H/2);
  	console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
struct block{
	long long ab,wei,solid,val;
	bool operator <(block b){
		return ab < b.ab;
	}
};
 
long long n,ans,dp[1003][20003];
 
int main(){
	cin >> n;
	vector<block> vals;
	for(int i = 0 ; i < n ; i += 1){
		long long a,b,c;
		cin >> a >> b >> c;
		vals.push_back({a+b,a,b,c});
	}
	sort(vals.begin(),vals.end());
	for(int i = 0 ; i < n ; i += 1){
		for(int j = 0 ; j <= 20000 ; j += 1){
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(j <= vals[i].solid){
				dp[i+1][j+vals[i].wei] = max(dp[i+1][j+vals[i].wei],dp[i][j]+vals[i].val);
			}
		}
	}
	for(int i = 0 ; i < 1003 ; i += 1){
		for(int j = 0 ; j < 20003 ; j += 1){
			ans = max(ans,dp[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
int main() {
    ll N,X;
    scanf("%lld%lld", &N,&X);
    printf("%lld\n",3*(N-gcd(N,X)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

using Graph = vector<vector<int>>;
Graph G;
int n;
int vis1[100010];
//int depth=0;
int dfs1(int v,int p,int depth){
    vis1[v]=depth;
    for(auto np: G[v]){
        if(np==p ) continue;
      //  vis1[np]=depth;
        dfs1(np ,v,depth+1);
    }

}
int vis2[100010];
int dfs2(int v,int p,int depth){
    vis2[v]=depth;
    for(auto np: G[v]){
        if(np == p ) continue;
    //    vis2[np]=depth;
        dfs2(np ,v,depth+1);
    }

}


int main(){
    
    cin>>n;
    G.assign(n,vector<int>());
    for (int i = 0; i < n-1; i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int cnt1=0,cnt2=0;
    dfs1(0,-1,0);
    dfs2(n-1,-1,0);
  /*   for (int i = 0; i < n; i++)
    {
        cerr<<vis1[i]<<" "<<vis2[i]<<endl;
    }*/
    
   
   if(n==2){
       cout<<"Snuke"<<endl;
       return 0;
   }
    for (int i = 1; i < n-1; i++)
    {
        if(vis1[i]<=vis2[i]){
            cnt1++;
        }
        else{
            cnt2++;
        }
    }
    if(cnt1>cnt2){
        cout<<"Fennec"<<endl;
    }
    else{
        cout<<"Snuke"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String string = sc.next();
		int ans=0;
		for(int i=0;i<string.length();i++){
			ans=ans+Integer.parseInt(string.substring(i,i+1));
			if(ans>=9){ans=ans-9;}
		}
		if(ans==0){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}

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

int main()
{
  int n;
  scanf("%d",&n);
  int x[500];
  for(int i=0;i<n;i++){
    scanf("%d",x+i);
    x[i]--;
  }
  priority_queue<pair<int,int> > Q;
  for(int i=0;i<n;i++){
    for(int k=0;k<i;k++){
      Q.push(make_pair(-x[i],i));
    }
  }
  static int A[500000];
  for(int i=0;i<n*n;i++){
    A[i]=-1;
  }
  for(int i=0;i<n;i++){
    A[x[i]]=i;
  }
  int T[500];
  for(int i=0;i<n;i++){
    T[i]=i;
  }
  bool F=0;
  for(int i=0;i<n*n;i++){
    if(A[i]!=-1){
      int j=A[i];
      if(T[j]!=0){
	F=1;
	break;
      }
      for(int k=0;k<n-j-1;k++){
	Q.push(make_pair(-n*n-1,j));
      }
    }
    else{
      if(Q.empty()){
	F=1;
	break;
      }
      A[i]=Q.top().second;
      T[A[i]]--;
      Q.pop();
    }
  }
  if(F){
    puts("No");
  }
  else{
    puts("Yes");
    for(int i=0;i<n*n;i++){
      printf("%d ",A[i]+1);
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 3696