akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<pair<long long , long long>> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i].second >> p[i].first;
  }
  sort(p.begin(), p.end());
  for(int i=0; i<N; i++){
    //cout << p[i].first << ' ' << p[i].second << endl;
  }
  vector<long long> wa(N);
  wa[0] = p[0].second;
  for(int i=1; i<N; i++){
    wa[i] = wa[i-1] + p[i].second;
  }
  bool ok=true;
  for(int i=0;i<N;i++){
    if(wa[i] > p[i].first){
      ok = false;
      break;
    }
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;
    int cnt=0;
    for(int i=0; i<N; i++){
        int h;
        cin >> h;
        if (h>=K){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int a;
	cin >> a;
	string b = "No";
	
	for(int i = 1; i < 10; ++i){
	    if(a%i == 0 && a/i < 10){
	         b = "Yes";
	    }
	}
	
	cout << b << endl;
}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();

		System.out.println( ( a + b ) * h / 2 ) ;
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e9
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(!isdigit(c))	{if(c=='-')	f=-1;c=getchar();}
	while(isdigit(c))	t=t*10+c-'0',c=getchar();
	return t*f;
}
inline void write(ll x){if(x<0)	{putchar('-');write(-x);return;}if(x>=10)	write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
int f[201][201],n,x[2001],y[2001],use[2001],vis[2001];
inline bool dfs(int x)
{
	For(i,1,n)
	{
		if(f[x][i]&&!use[i])
		{
			use[i]=1;
			if(!vis[i]|| dfs(vis[i]))
			{
				vis[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	n=read();
	For(i,1,n)	x[i]=read(),y[i]=read();
	For(i,1,n)	x[i+n]=read(),y[i+n]=read();
	For(i,1,n)	
		For(j,n+1,n+n)
		{
			if(x[i]<x[j]&&y[i]<y[j])	f[i][j-n]=1;
		}
	int ans=0;
	For(i,1,n)
	{
		memset(use,0,sizeof use);
		if(dfs(i))	ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,c;cin>>n>>c;
    int t;cin>>t;
    int s=t,en=t+c;
    ll ans=0;
    for(int i=0;i<n-1;++i)
    {
        cin>>t;
        if(t>en)
        {
            ans+=en-s;
            s=t;en=s+c;
        }
        else
        {
            en=t+c;
        }
    }
    cout<<ans+en-s<<'\n';
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: uedahiroki
 *
 * Created on 2019/06/22, 21:29
 */

#include <cstdlib>
#include<iostream>
using namespace std;


int main(void) {

    int N,L;
    cin>>N>>L;
    
    int i;
    int sum=0;
    int count=0;
    for(i=0;i<N;i++)
    {
        sum+=i+L;
        count++;
    }
    int j;
    if(N==0)
    {
        cout<<0<<endl;
    }
    if(L==0)
    {
        cout<<sum<<endl;
    }
    else if(L>0)
    {
        cout<<sum-L<<endl;
    }
    else if(L<0&&(count+L)>0)
    {
        cout<<sum<<endl;
    }
    else
    {
        cout<<sum-(N+L-1)<<endl;
    }
    
    
    
    return 0;
}



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

using namespace std;

int main() {

    int num = 0;
    int max_num = 0;
    int N;
    int A[100000];
    int M[100000] = {};

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

    max_num = *max_element(A, A + N);

    for (int i = 0; i < N; ++i) {
        ++M[A[i]];
    }

    for (int i = 0; i <= max_num; ++i) {
        int tmp = M[i];
        if (i - 1 >= 0) tmp += M[i - 1];
        if (i + 1 <= max_num) tmp += M[i + 1];
        num = max(num, tmp);
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

// aとbの最大公約数を求める関数
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

// 素因数分解を行う関数
map<ll, ll> PrimeFactor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    ll gcd_num = gcd(a, b);
    map<ll, ll> factor = PrimeFactor(gcd_num);
    ll ans = factor.size() + 1;  // 素因数の種類の数 + 1
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())

if 400<=N<=599:
  print(8)
elif 600<=N<=799:
  print(7)
elif 800<=N<=999:
  print(6)
elif 1000<=N<=1199:
  print(5)
elif 1200<=N<=1399:
  print(4)
elif 1400<=N<=1599:
  print(3)
elif 1600<=N<=1799:
  print(2)
elif 1800<=N<=1999:
  print(1)

Measured memory_bytes: 9188
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define f(i,j,n) for(int i=j;i<=n;i++)
using namespace std;
int main()
{
	char a[1002][1002];
	int x,b;
	cin>>x>>b;
	for(int i=1;i<=x;i++)
		for(int j=1;j<=b;j++)
			cin>>a[i][j];
	for(int i=1;i<=x;i++)
	{
		for(int j=1;j<=b;j++)
		{
			if(a[i][j]=='#')cout<<a[i][j];
			else
			{
				int ans=0;
				if(a[i-1][j-1]=='#')ans++;
				if(a[i-1][j]=='#')ans++;
				if(a[i-1][j+1]=='#')ans++;
				if(a[i][j-1]=='#')ans++;
				if(a[i][j+1]=='#')ans++;
				if(a[i+1][j-1]=='#')ans++;
				if(a[i+1][j]=='#')ans++;
				if(a[i+1][j+1]=='#')ans++;
				cout<<ans;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DIM 300007
#define INF 1000000007
using namespace std;

long long n,p[DIM],res=INF;

int main()
{
    cin>>n;
    for(int i = 1; i <= n; ++i)
    {
        char c;
        cin>>c;
        if(c=='E')
            p[i] = p[i-1]+1;
        else p[i] = p[i-1];
    }

    for(int i = 1; i <= n; ++i)
    {
        long long curr = 0;
        curr+= i - 1 - p[i-1];
        curr+= p[n] - p[i];
        res = min(res,curr);
    }

    cout<<res;

    return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll m=s.size()+k-1;
    V<ll> c(m+3);
    ll n=s.size();
    c[n-1]=1;
    //c[m]=1;
    for(ll i=n;i<=m+2;i++){
        c[i]=(c[i-1]*i)%mod;
        c[i]=(c[i]*mod_pow(i-n+1,mod-2,mod))%mod;
    }
    V<ll> c26(k+1),c25(k+1);
    c25[0]=1;
    c26[0]=1;
    for(ll i=1;i<=k;i++){
        c25[i]=c25[i-1]*25LL%mod;
        c26[i]=c26[i-1]*26LL%mod;
    }
    ll ans=0;
    for(ll i=0;i<=k;i++){
        ans=(ans+((c[m-i]*c25[k-i])%mod)*c26[i]%mod)%mod;
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 35576
#include<stdio.h>

int main(void){
    int n,k;

    scanf("%d",&n);
    scanf("%d",&k);

    int p[n];

    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }

    int min,tmp;

    for(int i=0; i<n-1; i++){
        min=p[i];
        tmp=i;
        for(int j=i+1; j<n; j++){
            if(min>p[j]){
                min=p[j];
                tmp=j;
            }
        }
        p[tmp]=p[i];
        p[i]=min;
    }

    int sum=0;

    for(int i=0; i<k; i++){
        sum+=p[i];
    }

    printf("%d",sum);

    return 0;
}

Measured memory_bytes: 1728
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sum=0l;
for(int i=0;i<n;i++){
sum+=sc.nextLong();
}
if(sum%2l==0)System.out.println("YES"); else System.out.println("NO");
}
}

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

int main() {
	int N;
	cin >> N;
	int tmp = N;
	int sum = 0;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)

	for i := 0; i < 1<<uint(3); i++ {
		now := string(n[0])
		for j := 0; j < 3; j++ {
			if i>>uint(j)&1 == 1 {
				now += "+"
			} else {
				now += "-"
			}
			now += string(n[j+1])
		}
		// fmt.Println(now)

		ans, _ := strconv.Atoi(string(now[0]))
		for j := 0; j < 3; j++ {
			n1, _ := strconv.Atoi(string(now[j*2+2]))
			if string(now[j*2+1]) == "+" {
				ans += n1
			} else {
				ans -= n1
			}
		}

		if ans == 7 {
			fmt.Printf("%s=7\n", now)
			return
		}
	}

}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		//int n = sc.nextInt();
		//String s = sc.next();
		//long n = sc.nextLong();
		//double n = sc.nextDouble();
		int ans = 0;
		for(int i = 0; i < 5 ; i++) {
			int n = sc.nextInt();
			if(n == 0) {
				ans = i+1;
			}
		}

	
		System.out.println(ans);
		//System.out.println("No");
		

	}
}


Measured memory_bytes: 35708
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n,m,l;cin>>n>>m>>l;
	vector<ll> a(m),b(m),c(m);
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;b[i]--;
	}
	int q;cin>>q;
	vector<int> s(q),t(q);
	for(int i=0;i<q;i++){
		cin>>s[i]>>t[i];
		s[i]--;t[i]--;
	}
	vector<vector<int>> f(n);
	ll def=1;
	for(int i=0;i<18;i++)def*=10;
	vector<vector<ll>> d(n,vector<ll>(n,def));
	for(int i=0;i<m;i++){
		d[a[i]][b[i]]=c[i];
		d[b[i]][a[i]]=c[i];
	}
//	for(int i=0;i<n;i++){
//					for(int j=0;j<n;j++){
//						cout<<d[i][j]<<' ';
//					}cout<<endl;
//				}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
//		for(int i=0;i<n;i++){
//				for(int j=0;j<n;j++){
//					cout<<d[i][j]<<' ';
//				}cout<<endl;
//			}
	}
//	for(int i=0;i<n;i++){
//		for(int j=0;j<n;j++){
//			cout<<d[i][j]<<' ';
//		}cout<<endl;
//	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(d[i][j]<=l){
				f[i].push_back(j);
			}
		}
	}
	vector<vector<int>> used(n,vector<int>(n,0));
	for(int i=0;i<n;i++){
		used[i][i]=1;
	}
	vector<vector<vector<int>>> ans(n,vector<vector<int>>(n));
	for(int i=0;i<n;i++){
		ans[i][0]=f[i];
		for(int j=0;j<f[i].size();j++){
			used[i][f[i][j]]=1;
		}
		for(int j=1;j<n;j++){
			vector<int> exns=ans[i][j-1];
			for(int k=0;k<exns.size();k++){
				vector<int> next=f[exns[k]];
				for(int o=0;o<next.size();o++){
					if(used[i][next[o]]==0){
						used[i][next[o]]=1;
						ans[i][j].push_back(next[o]);
					}
				}
			}
		}
	}
	for(int i=0;i<q;i++){
		for(int j=0;j<n;j++){
			vector<int> canans=ans[s[i]][j];
			int flag=0;
			for(int k=0;k<canans.size();k++){
				if(t[i]==canans[k])flag=1;
			}
			if(flag){
				cout<<j<<endl;
				break;
			}else{
				if(j==n-1){
					cout<<-1<<endl;
				}
			}
		}
	}







	return 0;
}


Measured memory_bytes: 8192
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


ans = []
loop {
  n = gif
  break if n == 0
  st = []
  en = []
  rep n do
    s,e = gs
    stt = s.split(':').map(&:to_i)
    enn = e.split(':').map(&:to_i)
    st << stt[0]*60*60 + stt[1]*60 + stt[2]
    en << enn[0]*60*60 + enn[1]*60 + enn[2]
  end
  max = 0
  st.sort!
  en.sort!
  rep n do |i|
    tmp = 0
    repl i, n-1 do |j|
      if en[i] > st[j] && en[i] <= en[j]
        tmp += 1
        max = tmp if tmp > max
      end
    end
  end
  ans << max
}

puts ans

Measured memory_bytes: 9516
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
map<ll,ll> mp;
ll h(ll x){
    ll tot=1;
    for(int i=0;i<x;i++)tot*=10;
    return tot;
}
void f(ll x,ll y,ll z){
    if(z==7&&x<=n){ans++;}
    if(x>n)return ;
    f(x+h(y)*3,y+1,z|1);
    f(x+h(y)*5,y+1,z|2);
    f(x+h(y)*7,y+1,z|4);
}
int main(void){
    cin>>n;
    f(0,0,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		double x1,y1,x2,y2,x,y;
		double r;
		x1 = sc.nextDouble();
		y1 = sc.nextDouble();
		x2 = sc.nextDouble();
		y2 = sc.nextDouble();
		x = Math.abs(x1 - x2);
		y = Math.abs(y1 - y2);
		x = x * x;
		y = y * y;
		r = Math.sqrt(x + y);
		System.out.println(r);
	}
}

Measured memory_bytes: 27796
N=int(input())
S=input()
count=0
r=S.count("R")
g=S.count("G")
b=S.count("B")

count+=r*g*b
#print(r,g,b)
for i in range(0,N-1):
	for j in range(i+1,N):
		k=2*j-i
		if k>=N:break
		if S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]:
			count-=1
print(count)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
ll const mod=1e9+7;
template <class T> bool is_prime(T IN) { if (IN <= 1) return false; for (long long i = 2; i * i <= IN; i++) { if (IN % i == 0) { return false; } } return true; } template <class T> vector<pair<long long, long long>> primefact(T x) { vector<pair<long long, long long>> ret; ll cpyx=x; for (long long i = 1; i * i <= x; i++) { if (x % i == 0) { vector<long long> alt = {i, x / i}; if (alt[0] == alt[1]) alt[1] = 1; for (long long j = 0; j < alt.size(); j++) { if (is_prime(alt[j])) { pair<long long, long long> t = make_pair(alt[j], 0); while (cpyx % alt[j] == 0) { cpyx /= alt[j]; t.second++; } ret.push_back(t); } } } } return ret; }
//最初に設定する.
const int MAX = 510000; const int MOD = 1000000007;
 bool is_modcinit=false;
long long fac[MAX], finv[MAX], inv[MAX];  void modcinit() { is_modcinit=true; fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long modc(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; if(!is_modcinit)modcinit(); return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; }
int main( ){
    ll n,m;
    cin>>n>>m;
    vpllll res=primefact(m);
    ll ans=1;
    for(pllll e:res){
        ans*=modc(e.second+n-1,n-1);
        ans=(ans%mod+mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 15584
N=int(input())

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N+1):
	num_6_max=num_6(i)
	num_9_max=num_9(N-i)
	a6_num=[]
	a9_num=[]
	A=i
	B=N-(i)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))


Measured memory_bytes: 3992
INFTY=1000000000

n=int(input())
A=list(map(int,input().split()))

def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L=[A[left+i] for i in range(n1)]
    R=[A[mid+i] for i in range(n2)]
    L.append(INFTY)
    R.append(INFTY)
    ans=0
    i=0
    j=0
    for k in range(left,right):
        if L[i]<=R[j]:
            A[k]=L[i]
            i+=1
        else:
            A[k]=R[j]
            j+=1
            ans+=max(n1-i,0)
    return ans

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        cnt1=mergeSort(A,left,mid)
        cnt2=mergeSort(A,mid,right)
        return merge(A,left,mid,right)+cnt1+cnt2
    return 0

cnt=mergeSort(A,0,n)
print(cnt)



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

int main(){
    int n,a[100],x=0;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=2;i<=n;i++){
        if(a[i-1]==a[i]){
            a[i]=a[i-1]+a[i+1];
            x++;
        }


    }
    cout<<x<<endl;
    return 0;
}

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

using namespace std;

int main() {
	double a,b,c,d,e,f;
	double x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x = (double)(c*e - b*f)/(a*e - b*d);
		y = (double)(c*d - a*f)/(b*d - a*e);
		cout << setprecision(3) << setiosflags(ios::fixed);
		cout << x+0.0000000001 << ' ' << y+0.0000001 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var TA = Sarray();
            var T = TA[0];
            var A = TA[1];
            var Hi = Sarray();
            var ans = 0;
            var min = (double)Mod;
            for (var i = 0; i < N; ++i)
            {
                var delta = Abs(A - (T - Hi[i] * 0.006));
                if(delta<min)
                {
                    min = delta;
                    ans = i;
                }
            }
            WriteLine(ans + 1);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13328
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	map<ll,ll> s;
	REP(i,n) s[a[i]]++;
	auto ite=s.begin();
	ll ans=0;
	while(ite!=s.end()) {
		P p=*ite;
		if(p.second>p.first) ans+=p.second-p.first;
		if(p.second<p.first) ans+=p.second;
		ite++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 7168
from collections import defaultdict, deque
 
 
def bfs(start):
    q = deque([start])
    dist = [-1] * N
    dist[start] = 0
    while q:
        v = q.popleft()
        for nv, nw in g[v]:
            if dist[nv] >= 0:
                continue
            dist[nv] = (dist[v] + nw) % 2
            q.append(nv)
    return dist
 
 
N, *UVW = map(int, open(0).read().split())
g = defaultdict(set)
 
ans = [0] * N
for u, v, w in zip(*[iter(UVW)] * 3):
    u -= 1
    v -= 1
    g[u].add((v, w))
    g[v].add((u, w))
print("\n".join(map(str, bfs(0))))

Measured memory_bytes: 78604
# include<iostream>
# include<algorithm>
# include<cmath>
using namespace std;

bool isprime(int x){
    if(x == 2){
        return true;
    }
    if(x < 2 || x % 2 == 0 ){
        return false;
    }

    int i = 3;
    while(i <= sqrt(x)){
        if(x % i == 0){
            return false;
        };
        i = i + 2 ;
    }
    return true;
}

int main(){
    int n,x,ans;
    cin >> n;
    ans = 0;
    for(int i=0;i<n;i++){
        cin >> x;
        if(isprime(x)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int n, ans, sum;
    while (1)
    {
        cin>>n;
        if (n==0) break;
        ans=0; sum=0;
        for (int i=1; ; i++)
        {
            sum+=i;
            if (sum>=n) break;
            if ((n-sum)%(i+1)==0)  ans++;
        }
        cout<<ans<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ab,x,y,ans[3];
	cin >> a >> b >> ab >> x >> y;
	
	ans[0] = a*x + b*y;
	if(x >= y)
		ans[1] = y*2*ab + (x-y)*a;
	
	else
		ans[1] = x*2*ab + (y-x)*b;
		
	ans[2] = max(x,y)*2*ab;
		
	cout << min(ans[0],min(ans[2],ans[1])) << endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);


int N,M,Q;
vector<vector<int>> A(0);




int main() 
{
  cin>>N>>M>>Q;
  stack<pair<int,vector<int>>> stk;
  rep(i,M)
  {
    stk.push({1,{i+1}});
  }
  while(!stk.empty())
  {
    auto p=stk.top();
    stk.pop();
    int n=p.first;
    auto vec=p.second;
    if(n==N) {A.push_back(vec); continue;}
    int l=vec.at(n-1);
    for(int i=l;i<=M;i++)
    {
      auto vec2=vec;
      vec2.push_back(i);
      stk.push({n+1,vec2});
    }
  }  
  /*
  for(auto a:A)
  {
    rep(i,a.size())
    {
      if(i!=0) cout<<" ";
      cout<<a.at(i);
    }
    cout<<endl;
  } 
  */
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  rep(i,Q)
  {
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  
  int ans=0;
  for(auto hoge:A)
  {
    int sum=0;
    rep(i,Q)
    {
      if(hoge.at(b.at(i))-hoge.at(a.at(i))==c.at(i))
      {
        sum+=d.at(i);
      }
    }
    ans=max(sum,ans);
  }
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 13560
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>v(5, 0);

int main() {
	string s;
	cin >> s;
	REP(i, 0, s.size()) {
		if (s[i] == 'a') {
			v[0]++;
		}
		else if (s[i] == 'b') {
			v[1]++;
		}
		else {
			v[2]++;
		}
	}
	if (abs(v[1] - v[0]) < 2 && abs(v[2] - v[1]) < 2 && abs(v[0] - v[2]) < 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    if S == T[:-1]:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> db, de;
vector<vector<ll>> G;
/*
void dfsb(ll id, ll now) {
    db[id] = now;
    for(int i=0;i<G[id].size();i++) {
        if(now+1<db[G[id][i]]) {
            dfsb(G[id][i], now+1);
        }
    }
}

void dfse(ll id, ll now) {
    de[id] = now;
    for(int i=0;i<G[id].size();i++) {
        if(now+1<de[G[id][i]]) {
            dfse(G[id][i], now+1);
        }
    }
}
*/
void dfs(ll id, ll now, vector<ll>& d) {
    d[id] = now;
    for(int i=0;i<G[id].size();i++) {
        if(now+1<d[G[id][i]]) {
            dfs(G[id][i], now+1, d);
        }
    }
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    db.resize(N, INF);
    de.resize(N, INF);
    /*
    dfsb(0, 0);
    dfse(N-1, 0);
    */
    dfs(0, 0, db);
    dfs(N-1, 0, de);
    for(int i=0;i<N;i++) {
        if(db[i]>de[i]) tmp++;
    }
    //cout << N-tmp << " " << tmp << endl;
    if(N-tmp>tmp) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 14756
#include<stdio.h>
#include<string.h>

int main(void)
{
	int i;
	char str[1001];
	
	fgets(str, 1001, stdin);
	for(i = 0;i < strlen(str);i++){
		if(str[i] <= 'z' && str[i] >= 'a'){
			str[i] -= 0x20;
		}
	}
	printf("%s", str);
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, k;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    while (n != 0) {
        int a[n + 1] = {};
        rep(i, n) cin >> a[i];
        rep(i, n) a[i + 1] += a[i];
        int ans = -1e12;
        rep(i, n - k) ans = max(ans, a[i + k] - a[i]);
        ans = max(ans, a[k - 1]);
        cout << ans << endl;
        cin >> n >> k;
    }

}

Measured memory_bytes: 3884
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#include <numeric>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

bool check(vector<int> in1, vector<int> in2) {
    int size = in1.size();
    bool flag = true;
    for (int i = 0; i < size; i++) {
        if (in1[i] != in2[i]) flag = false;
    }
    return flag;
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];

    int res = 0, a = 0, b = 0;

    int c = 1;
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);
    do {
        if (check(v, P)) a = c;
        if (check(v, Q)) b = c;
        c++;
    } while( next_permutation(v.begin(), v.end()) );

    res = abs(a - b);
    cout << res << endl;
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    while (true) {
        Int n;
        cin >> n;
        if (n == 0) break;
        vector<Int> v(n);
        for (Int i = 0; i < n; i++) {
            cin >> v[i];
        }
        sort(all(v));
        Int sum = 0;
        for (Int i = 1; i < n - 1; i++) {
            sum += v[i];
        }
        dump(sum / (n - 2));
    }
    return 0;
}



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

const int N = 200005;

int n, m;
bool vis1[N], vis2[N];

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int a, b;
		cin >> a >> b;
		if (a == 1)
			vis1[b] = true;
		else if (b == n)
			vis2[a] = true;
	}
	for (int i = 1; i <= n; ++i)
		if (vis1[i] && vis2[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;


const int N = 200005, MOD = 1e9 + 7;

ll POWER (ll x, ll y){
    ll ans = 1;
    while (y){
        if ((y & 1) > 0)
            ans = ans * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return ans;
}

int n;

int S[N], F[N], inv[N];

vector < int > g[N];

int A[N], B[N];
int dp[N];
int ans;

void dfs (int k, int p){
    A[k] = 1;
    for (int to : g[k]){
        if (to == p)
            continue;
        dfs (to, k);
        S[k] += S[to];
        A[k] = A[k] * inv[S[to]] % MOD * A[to] % MOD;
    }
    A[k] = A[k] * F[S[k]] % MOD;
    S[k]++;
}

void go (int k, int p){
    B[k] = B[k] * inv[n - S[k]] % MOD;
    for (int to : g[k]){
        if (to == p)
            continue;
        B[k] = B[k] * A[to] % MOD;
        B[k] = B[k] * inv[S[to]] % MOD;
    }
    //dp[k] = A[k];
    //if (k > 1)
    dp[k] = B[k] * F[n - 1] % MOD;
    for (int to : g[k]){
        if (to == p)
            continue;
        B[to] = B[k] * F[n - S[to] - 1] % MOD * F[S[to]] % MOD * POWER (A[to], MOD - 2) % MOD;
        go (to, k);
    }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    F[0] = 1;
    inv[0] = 1;
    for (int i = 1; i <= n; i++){
        F[i] = F[i - 1] * i % MOD;
        inv[i] = POWER (F[i], MOD - 2);
    }
    for (int u, v, i = 1; i < n; i++){
        cin >> u >> v;
        g[u].pb (v);
        g[v].pb (u);
    }
    dfs (1, 0);
    B[1] = 1;
    go (1, 0);
    for (int i = 1; i <= n; i++)
        cout << dp[i] << endl;
    return 0;
}


Measured memory_bytes: 24048
while True:
    n, m = map(int, input().split())
    
    if n==0 and m==0:
        break
    
    a = [int(a) for a in input().split()]
    SUM = []
    for i in range(len(a)-1):
        a0 = a[0]
        for j in range(len(a)-1):
            sum = a0+a[j+1]
            if sum<=m:
                SUM.append(sum)
            if m<sum:
                SUM.append(0)
        a.pop(0)
    if max(SUM)==0:
        print('NONE')
    else:
        print(max(SUM))


Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline int read()
{
	int x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(int x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

#pragma GCC optimize ("O3")
int main()
{
	int h = read(), w = read();
	int columnAccum[2000] = {};
	int rowMax[2000] = {};
	int max = 0;
	for (int i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (int j = 0; j < w; j++)
		{
			var c = getchar_unlocked() & 1;
			if (c)
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				for (int k = j - currentChain; k < j; k++)
					rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		getchar_unlocked();
		for (int j = w - currentChain; j < w; j++)
			rowMax[j] = Max(rowMax[j], currentChain);
	}
	for (int i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;

    int a = 0, b = 0;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

void solve() {
    ll X,K,D; cin >> X >> K >> D;
    ll k = abs(X)/D;
    if(k == K) cout << abs(abs(X)-D*K) << endl;
    else if(k < K) {
        ll ret1 = abs(X)-D*k;
        ll ret2 = abs(abs(X)-D*(k+1));
        if(ret1 == ret2) cout << abs(ret1) << endl;
        else if((K-k)%2 == 0) cout << abs(ret1) << endl;
        else cout << abs(ret2) << endl;
    } else {
        cout << abs(abs(X)-D*K) << endl;
    }
}

int main() {
    int T;
    T = 1;
    while(T--) {
        solve();
    }
}

Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


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

int W, H;
int b[105][105];
bool visited[105][105] = {};
int solve(int x, int y) {
	if (x < 0 || W + 1 < x || y < 0 || H + 1 < y) return 0;
	if (b[x][y]) return 1;
	if (visited[x][y]) return 0;
	visited[x][y] = true;
	int ret = 0;
	rep(i, 6) {
		ret += solve(x + dx[y % 2][i], y + dy[y % 2][i]);
	}
	return ret;
}
int main() {
	cin >> W >> H;
	rep(i, H)rep(j, W) cin >> b[j+1][i+1];
	cout << solve(0, 0) << endl;

	return 0;
}


Measured memory_bytes: 3432
#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;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	rep(i,n) cin >> x[i] >> u[i];
	double res=0;
	rep(i,n){
		if(u[i] == "JPY"){
			res += x[i];
		}else{
			res += x[i]*380000;
		}
	}
	cout << res << 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) begin(v),end(v)
using ll = long long;

int main() {
  int a,b,k;cin>>a>>b>>k;
  int cnt=0;
  for(int i=120;i>=1;i--){
    if(a%i==0&&b%i==0)cnt++;
    if(cnt==k){
      cout<<i<<endl;
      return 0;
    }
  }
}

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

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;




void main() {
    long x;
    scan(x);
    for (long i = 1; ; i++) {
        if (i * (i + 1) / 2 >= x) {
            writeln(i);
            return;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

  



/************************************************/
const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}
 
vector<int64_t> fact, seq_inv, fact_inv;
 
void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}
 
void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}
 
void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}
 
void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}
 
int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}
 
int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}
 
int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}
 
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}
 
int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}
 
int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}
/************************************************/

vector<ll> a(mx);

int main(){
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
 
  ll ans=0;
  ll sum=0;
  ll r=0;
  rep(i,n){
    while(r<n && sum+a[r]==(sum^a[r])){      
      sum += a[r];
      r++;
    }
    ans += r-i;
    sum -= a[i];
  }
  cout << ans << endl;
  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {

    li n;
    cin >> n;
    li h, w;
    cin >> h >> w;
    cout << (n - h + 1)*(n - w + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m,res=0;
vi s;
vvi g;

int dfs(int v,int p){
	vi a,b;
	for(auto u:g[v]) if(u!=p){
		a.push_back(dfs(u,v));
		b.push_back((s[u]>=m?1:0));
		s[v]+=s[u];
	}
	if(a.empty()) return 0;
	int sum=0,N=b.size(),tmp=0;
	for(auto i:b) sum+=i;
//	cout<<a[0]<<' '<<b[0]<<endl;
	for(int i=0;i<N;i++) tmp=max(tmp,sum-b[i]+a[i]);
//	cout<<tmp<<endl;
	res=max(res,tmp+(n-s[v]>=m?1:0));
	vi c(N);
	for(int i=0;i<N;i++) c[i]=a[i]-b[i];
	if(N>=2){
		sort(c.rbegin(),c.rend());
		res=max(res,sum+c[0]+c[1]+(n-s[v]>=m?1:0));
	}
//	cout<<v+1<<' '<<tmp<<endl;
	return max(tmp,sum);
}

int main(){
	cin>>n>>m;
	g=vvi(n);
	s=vi(n,1);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--,v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	cout<<res<<endl;
}


Measured memory_bytes: 20032