akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

int main() {
	map<char, char>a, b;
	string s, t;
	int i, j, k;

	cin >> s >> t;

	for (i = 0; i < s.length(); i++) {
		if (a.find(t[i]) == a.end()) {
			a.insert(make_pair(t[i], s[i]));
		}
		else {
			if (a.at(t[i]) != s[i]) {
				cout << "No";
				return 0;
			}
		}
		if (b.find(s[i]) == b.end()) {
			b.insert(make_pair(s[i], t[i]));
		}
		else {
			if (b.at(s[i]) != t[i]) {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 776
import collections,copy,sys
def LI(): return list(map(int,sys.stdin.readline().split()))
N,Q = LI()
ans = [0]*(N+1)
graph = [collections.deque() for _ in range(N+1)] #1_index
for _ in range(N-1):
    a,b = LI()
    graph[a].append(b)
    graph[b].append(a)
for _ in range(Q):
    p,x = LI()
    ans[p] += x
seen = [-1]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]!=-1:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])


Measured memory_bytes: 157216
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

double sunuke(long long m){
  char ch[32];
  int ii,len;
  int sum = 0;
  double sumd;
  sprintf(ch,"%ld",m);
  //printf("%s",ch);
  len = strlen(ch);
  for(ii=0;ii<len;ii++){
	//cout << sum << endl;
	sum += ch[ii] - '0';
  }
  sumd = sum;
  return m/sumd;
}
bool isSunuke(long long m,long long pls){
  double sunu;
  long long ii;
  sunu = sunuke(m);
  for(ii=pls;ii<=pls*100;ii=ii+pls){
	if(sunu > sunuke(m+ii)){
	  return false;
	}
  }
  return true;
}

int main(){
  long long k,cnt=0;
  long long first = 1,plus=1,pn,nextLen,firstLen,next,cur;
  char curstr[30],nextstr[30];
  cin >> k;
  
//  while(cnt<=k){
//	cout << first << endl;
//	
//	next = first + plus;
//
//	sprintf(curstr,"%s",first);
//	sprintf(nextstr,"%s",next);
//
//	curLen  = s
//	nextLen = strLen(nextstr);
//	
//  }
//  for(cnt=1;cnt<=1000;cnt++){
//	if(isSunuke(cnt)){
//	  cout << cnt << endl;
//	}
//  }

  cur = 1;
  pn = 0;
  while(cnt < k && cur <= pow(10,15)){
	if(isSunuke(cur,plus)){
	  cout << cur << endl;
	  cnt++;

	}
	if(!isSunuke(cur+plus,plus)){
	  pn++;
	  plus = pow(10,pn);
	}
	//cout << cur << endl;
	cur += plus;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char[]s = sc.nextLine().toCharArray();
        int x = s[s.length-1]-'0';
        if (x==3){
            pw.println("bon");
        }
        else if (x==0||x==1||x==6||x==8){
            pw.println("pon");
        }
        else pw.println("hon");
        pw.flush();
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 32728
import random
 
def calc1(D, s, t):
  last = [0 for _ in range(26)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value
 
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

t = [0 for _ in range(D)]
 
for i in range(D):
  for j in range(26):
    day = i + 1
    calc[j] = c[j] * (day - last[j])
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  t[i] = min_idx + 1

val = calc1(D, s, t)
for _ in range(45000):
  d_rand = random.randint(1,D)
  q_rand = random.randint(1,26)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  new_val = calc1(D, s, t)
  if val > new_val:
    t[d_rand-1] = old
  else:
    val = new_val
for i in range(D):
  print(t[i])

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool success = true;
    if (s.size() % 2 == 0)
    {
        for (int i = 0; i < s.size(); i++)
        {
            if (i % 2 == 0)
            {
                if (s[i] != 'h')
                {
                    success = false;
                }
            }
            else
            {
                if (s[i] != 'i')
                {
                    success = false;
                }
            }
        }
    }
    else
    {
        success = false;
    }
    cout << (success ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define INF 100000

int main() {
  int N, X;  //個数、気温、目標気温
  cin >> N >> X;
  int min = INF;
  int sum = 0;
  vector<int> m(N);
  for (int i = 0; i < N; i++) {
    cin >> m[i];
    if (min > m[i]) min = m[i];
    sum += m[i];
  }

  cout << N + (X - sum) / min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define io std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int mo=998244353; const int mod=1000000007;

const int manx=100000+5;



int main(){
    io;
    ll a,b; cin>>a>>b;
    if(a<=b) puts("unsafe");
    else puts("safe");
    return 0;
}


Measured memory_bytes: 3560
#include<cstdio>
const int N=100005;
int n,v[N],he[N],to[N*2],nx[N*2],d[N],fa[N];
inline void wk(int w,int x,int y)
{to[w]=y,nx[w]=he[x],he[x]=w;}
inline int imx(int x,int y){return x>y?x:y;}
int dfs(int x)
{
	int a=0,b=0,c=0;
	for(int i=he[x],y;i;i=nx[i])if((y=to[i])!=fa[x])
	{c=1,fa[y]=x;if(!dfs(y))return 0;a+=v[y],b=imx(b,v[y]);}
	if(!c)return 1;
	if(v[x]>a||v[x]<a-v[x]||a-v[x]>a-b)return 0;//
	v[x]-=a-v[x];return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&v[i]);
	for(int i=1,x,y;i<n;++i)
		scanf("%d%d",&x,&y),++d[x],++d[y],
		wk(i*2,x,y),wk(i*2+1,y,x);
	if(n==2){v[1]==v[2]?printf("YES"):printf("NO");return 0;}
	for(int i=1;i<=n;++i)if(d[i]==1)
	{dfs(i)?printf("YES"):printf("NO");return 0;}
	return 0;
}

Measured memory_bytes: 12664
#include<bits/stdc++.h>
using namespace std;
int n,a[105];
void pr()
{
	int i;
	for(i=1;i<=n;i++)
	{
		if(i>1)printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
}
void sor()
{
	int i,j,k;
	for(i=2;i<=n;i++)
	{
		k=a[i];
		j=i-1;
		while(j>=1&&a[j]>k)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=k;
		pr();
	}
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	pr();
	sor();
	return 0;
}


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double pi = 3.141592653589;
	double r; cin >> r;
	cout << fixed;
	cout << setprecision(6) << r * r * pi<<" ";
	cout << setprecision(6) << (double)(2) * r * pi << endl;
}


Measured memory_bytes: 3268
if __name__ == '__main__':
    odds, evens = (input() for _ in range(2))

    answer = []
    for odd, even in zip(odds, evens): answer.extend((odd, even))

    if len(odds) != len(evens):
        remains = odds if len(odds) > len(evens) else evens
        answer.append(remains[-1])

    print(''.join(answer))


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

typedef long long ll;
const int MAX_M = 100000;

int main() {
	int N, M, X[MAX_M], dist[MAX_M - 1];

	std::cin >> N >> M;

	for(int i = 0; i < M; ++i) {
		std::cin >> X[i];
	}
	std::sort(X, X + M);
	
	for(int i = 0; i < M - 1; ++i) {
		dist[i] = std::abs(X[i + 1] - X[i]);
	}
	std::sort(dist, dist + M - 1);

	ll ans = 0;
	for(int i = 0; i < (M - 1) - (N - 1); ++i) {
		ans += dist[i];
	}

	std::cout << ans << std::endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<bitset>
#include<cmath>
using namespace std;
bitset<10000>a[10];
int main()
{
	int H,W,count,sum;
	while(cin>>H>>W,H)
	{
		int temp;
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				cin>>temp;
				if(temp)a[i].set(j);
				else a[i].reset(j);
			}
		}
		sum=0;
		for(int cur=0;cur<(1<<H);cur++)
		{
			count=0;
			for(int i=0;i<H;i++)
			{
				if((cur>>i)&1)a[i].flip();
			}
			for(int j=0;j<W;j++)
			{
				temp=0;
				for(int i=0;i<H;i++)
				{
					if(a[i].test(j))temp++;
				}
				count+=max(temp,H-temp);
			}
			sum=max(count,sum);
			for(int i=0;i<H;i++)
			{
				if((cur>>i)&1)a[i].flip();
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        while(true){
            int one = input.nextInt();
            int two = input.nextInt();
            if(one == 0 && two == 0)break;
            if (one > two) {
                int temp = one;
                one = two;
                two = temp;

            }
            System.out.println(one + " " + two);
        }

    }}


Measured memory_bytes: 36580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;
            String X;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            C = int.Parse(word[2]);
            if(C>=A&&C<=B)
            {  X= "Yes"; }
            else
            { X = "No"; }
            Console.WriteLine(X);
            Console.ReadKey();

        }
    }
}


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

int main(){
    int tmp[5];
    char com;
    while(cin >>tmp[0]>>com>>tmp[1]>>com>>tmp[2]>>com>>tmp[3]>>com>>tmp[4]){
    int hand[14]={};

    for(int i=0; i<5; ++i){
      if(tmp[i]==1)++hand[13];
      ++hand[tmp[i]-1];
    }

    int pair=0,three=0,str=0,four=0;
    for(int i=0; i<14; ++i){
      if(hand[i]==4){++four;}
      if(hand[i]==1)++str;
      if(hand[i]==2)++pair;
      if(hand[i]==3)++three;
      if(str!=5 && hand[i]==0)str=0;
    }
    if(hand[0]==hand[13] && hand[0]==2)--pair;
    if(four)cout << "four card" << endl;
    else if(three && pair)cout << "full house" << endl;
    else if(str >= 5)cout << "straight" << endl;
    else if(three)cout << "three card" << endl;
    else if(pair == 2)cout << "two pair" << endl;
    else if(pair == 1)cout << "one pair" << endl;
    else cout << "null" << endl;
  }   
}



Measured memory_bytes: 3076
#!/usr/bin/env python

def main():
    k = int(input())
    flg = [False for _ in range(k)]
    r = 7
    cnt = 0

    while True:
        r = r % k
        cnt += 1
        if r == 0:
            break
        if flg[r]:
            cnt = -1
            break
        flg[r] = True
        r = r*10 + 7

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17012
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int A, B, C, D;
	int length = 0;

	cin >> A >> B >> C >> D;

	if (B >= C)
	{ 
		length = min(B, D) - max(A, C);
	}

	if (length < 0) {
		length = 0;
	}

	cout << length << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
H.reverse()
for i in range(1, N):
    if H[i-1] < H[i] - 1:
        print("No")
        break
    elif H[i-1] == H[i] - 1:
        H[i] -= 1
else:
    print("Yes")

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
        cout << s << ln;
    else
        cout << "red" << ln;
    return 0;
}


Measured memory_bytes: 3656
base_chars = set("ACGT")

max_len = 0
tmp_len = 0
for c in input().strip():
  if c in base_chars:
    tmp_len += 1
  else:
    max_len = max(max_len, tmp_len)
    tmp_len = 0
max_len = max(max_len, tmp_len)
print(max_len)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  char a='a';
  for(int i=0;i<26;i++){
    if(!count(s.begin(),s.end(),a)){
      cout<<a;
      return 0;
    }
    a++;
  }
  cout<<"None";
}

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

int main() {
	string s;
	cin >> s;
	int x, y;
	for (int i = 0;i < s.size();++i) {
		if (s[i] == 'A') {
			x = i;
			break;
		}
	}
	for (int i = s.size() - 1;i >= 0;--i) {
		if (s[i] == 'Z') {
			y = i;
			break;
		}
	}
	cout << y - x + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            Console.WriteLine((a+b)%24);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    rep(x, 1000) {
        int nx = x / 10;
        vector<int> d(1, x % 10);
        while (nx) {
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (d.size() != n) continue;
        reverse(d.begin(), d.end());
        bool ok = true;
        rep(i, m) {
            if (d[p[i].first - 1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS 
#include<stdio.h>
main() {
	int i, n;
	for (i = 1;; i++) {
		scanf("%d", &n);
		if (n == 0)break;
		printf("Case %d: %d\n", i, n);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int X,Y;
    cin >> X >> Y;
    cout << X+Y/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#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,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k, a, b; cin >> k >> a >> b;
  cout << max(k+1, a+(b-a)*((k-a+1)/2)+((k-a+1)%2)) << endk;
  return 0;
}


Measured memory_bytes: 3648
/***************************************** START OF TEMPLATE *********************************************/
#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, k, cnt[N], ans = 0;


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/
ll fast_pow(ll x, ll y, ll MOD=MOD){
    ll res=1;
    while(y){
        if(y&1)res=(res*x)%MOD;
        y>>=1;x=(x*x)%MOD;
    }
    return res;
}

/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    cin>>n>>k;
    frr(i,k,1){
        cnt[i] = fast_pow(k/i, n);
        for(ll j = 2*i; j <= k; j += i){
            cnt[i] = (cnt[i] - cnt[j] + MOD)%MOD;
        }
        ans = (ans + i*cnt[i]%MOD)%MOD;
    }

    cout<<ans;
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

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


// ヒープソート(昇順) *****************

int A[100001], B[100001], tmp; // Bでソート(Aは従属) 必要に応じて要素数と型を変える
int length;                    // 要素数:sort()を呼び出す前に設定する


void swap(int i, int j) {
    int tmp;
    tmp  = A[i];
    A[i] = A[j];
    A[j] = tmp;
    tmp  = B[i];
    B[i] = B[j];
    B[j] = tmp;
}

void downheap(int k, int r) {
    int j, v, w;
    v = B[k];
    w = A[k];
    while (1) {
        j = 2 * k + 1;
        if (j > r) break;
        if (j != r) {
            if (B[j + 1] > B[j]) {
                j = j + 1;
            }
        }
        if (v >= B[j]) break;
        B[k] = B[j];
        A[k] = A[j];
        k = j;
    }
    B[k] = v;
    A[k] = w;
}

void sort() {
    int i;
    for (i = (length - 2) / 2; i >= 0; i--) {
        downheap(i, length - 1);
    }
    for (i = length - 1; i > 0; i--) {
        swap(0, i);
        downheap(0, i - 1);
    }
}

// ***************** ヒープソート(昇順) 



int main() {
  int N, result;
  int i;
  scanf ("%d", &N);
  length = N;
  
  for (i=0;i<N;i++) {
      scanf("%d", &B[i]);
  }
  
  sort();
  
  printf ("%d\n", B[N/2]-B[N/2-1]);
  
  return 0;
}




Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<ll> X(N),X2(N);
    ll s = 0;
    rep(i,N){
        cin >> X[i];
        X2[i] = X[i];
    }
    sort(X.begin(),X.end());
    ll mid = X[N/2];
    rep(i,N){
        if(X2[i]<mid){
            cout << mid << endl;
        }else{
            cout << X[N/2-1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
package main

import (
    "fmt"
)

var as []int
var m map[int]bool

func main() {
    m = make(map[int]bool)

    var n, k int
    fmt.Scan(&n, &k)

    as = make([]int, n)
    for i := range as {
        var a int
        fmt.Scan(&a)
        as[i] = a
    }

    b := check(k)
    if b {
        fmt.Println("First")
    } else {
        fmt.Println("Second")
    }
}

// check returns whether first is winner or not
func check(k int) bool {
    if b, ok := m[k]; ok {
        return b
    }
    for i := range as {
        if as[i] > k {
            continue
        }
        b := check(k - as[i])
        if !b {
            m[k] = true
            return true
        }
    }
    m[k] = false
    return false
}


Measured memory_bytes: 17280
#include <iostream>
#include <fstream>

int main()
{
	int H, W;
	std::cin >> H >> W;
	int costs[10][10];
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			std::cin >> costs[i][j];
		}
	}
	// min cost matrix
	// j is start node, k is end node
	// i is intermediate node
	for (int i = 0; i < 10; i++)
		// for every digit
	{
		for (int j = 0; j < 10; j++)
			// for every different digit
		{
			if (i == j)
				continue;
			// see if digit i can update digit j
			for (int k = 0; k < 10; k++)
			{
				if (k == j || k == i)
					continue;
				if (costs[j][k] > costs[j][i]
					+ costs[i][k])
				{
					costs[j][k] = costs[j][i]
						+ costs[i][k];
				}
			}
		}
	}

	/*std::cout << std::endl;
	std::cout << std::endl;
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			std::cout << costs[i][j] << " ";
		}
		std::cout << std::endl;
	}*/

	int digit;
	int result = 0;
	for (int i = 0; i < H * W; i++)
	{
		std::cin >> digit;
		if (digit != -1)
			result += costs[digit][1];
	}
	std::cout << result;
}

Measured memory_bytes: 256
while(1):
    a = list(map(int,input().split()))
    if a[0]==0:
        break
    else:
        for i in range(a[0]):
            if i ==0 or i == a[0]-1:
                for j in range(a[1]):
                    print("#",end="")
            else:
                for j in range(a[1]):
                    if j == 0 or j ==a[1]-1:
                        print("#",end="")
                    else:
                        print(".",end="")
            print("")
        print("")


Measured memory_bytes: 7012
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl kai(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,桁数回の演算だからだいたいO(logN)くらい?



signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    rep(i,n)cin >> a[i];
    sort(a,a + n,greater<>());
    intl ans = 0;
    intl hlen = (alength(a) + 1) / 2;
    rep(i, hlen)ans += a[i];
    repi(i,hlen,n - 1) ans += a[i - hlen + 1];
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,M;
  int a,b;
  cin >> N >> M;
  
  vector<int> cities(N);
  
  //道路をカウント
  for (int i=0;i<M;i++) {
    cin >> a >> b;
    cities.at(a-1) += 1;
    cities.at(b-1) += 1;
  }
  
  //結果出力
  for (int i=0;i<N;i++) {
    cout << cities.at(i) << endl;
  }
}


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

int main(){
    ll n; cin >> n;
    ll n1 = n/3;
    ll n2 = n/5;
    ll n3 = n/15;
    ll ans;
    ans = (n+1)*n/2-3*(1+n1)*n1/2-5*(1+n2)*n2/2+15*(1+n3)*n3/2;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
int n; string s[55];
ll dp[55][55][25]; bool u[55][55][25];
int nm[55][55][25];
ll rec(int L,int R,int num){
	if(u[L][R][num]) return dp[L][R][num];
	u[L][R][num] = 1;
	if(L==R){
	      dp[L][R][num] = 1;
	      for(int j=num-1;j<s[L].size();j++) if(s[L][j]=='?') dp[L][R][num] = (dp[L][R][num]*26LL)%mod;
	      return dp[L][R][num];
	}
	int cnt = 0;
	for(int i=L;i<=R;i++){
		if(s[i].size() < num){
			if(i != L || cnt) return dp[L][R][num] = 0;
			cnt++;
		}
	}
	if(cnt){
		if(cnt == R-L+1){
			return dp[L][R][num] = 1;
		}
		else return dp[L][R][num] = rec(L+cnt,R,num);
	}
	ll t[55][30] = {};
	t[L-1][0] = 1;
	for(int i=L;i<=R;i++){
		for(int j=L-1;j<i;j++){
			if(nm[j+1][i][num] > 0){
				//dp[j+1][i][num+1] wo kentou
				int k = nm[j+1][i][num];
				{
					{
                        ll R = rec(j+1,i,num+1);
						for(int l=0;l<k;l++) t[i][k] = (t[i][k] + t[j][l]*R%mod)%mod;
					}
				}
			}
			else if(nm[j+1][i][num] == 0){
				ll R = rec(j+1,i,num+1);
				ll T = 0;
				for(int k=1;k<=26;k++){
					T = (T+t[j][k-1])%mod;
					t[i][k] = (t[i][k]+T*R%mod)%mod;
				}
			}
		}
	}
	for(int i=1;i<=26;i++) dp[L][R][num] = (dp[L][R][num]+t[R][i])%mod;
	return dp[L][R][num];
}
int main(){
	cin >> n;
	for(int i=1;i<=n;i++) cin >> s[i];
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			for(int k=1;k<=20;k++){
				for(int x=i;x<=j;x++){
					if(s[x].size()>=k){
						if(s[x][k-1] != '?'){
							if(nm[i][j][k] == 0) nm[i][j][k] = 1 + (s[x][k-1]-'a');
							else if(nm[i][j][k] != 1 + (s[x][k-1]-'a')) nm[i][j][k] = -1;
						}
					}
				}
			}
		}
	}
	cout << rec(1,n,1) << endl;
}

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

typedef long double ld;

int main(){
  int k,x;
  cin >> k >> x;
  for(int i=-(k-1);i<k;i++){
    cout << (x+i) << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int r, g, b;
    std::cin >> r >> g >> b;

    int sum = (r * 100) + (g * 10) + b;

    if(sum % 4 == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

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

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

    ll n;
    cin >> n;
    vector<ll> a;
    a.push_back(0);
    rep(i, n){
        ll a_;
        cin >> a_;
        a.push_back(a_);
    }

    sort(a.begin(), a.end());
    vector<ll> sm(n+1, 0);
    sm[1] = a[1];
    int res = 1;
    for(int i = 2; i < n+1; ++i){
        if(sm[i-1]*2 >= a[i]) ++res;
        else res = 1;

        sm[i] = sm[i-1] + a[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4944
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int S[30];
    rep(i, n) cin >> S[i];
    int cnt = 0;
    REP(i, 1, n - 2) {
        if (min({S[i - 1], S[i], S[i + 1]}) < S[i] && S[i] < max({S[i - 1], S[i], S[i + 1]})) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N;
  cin >> N;
  vector<int> A(3 * N);
  for (int i = 0; i < 3 * N; i++)
  {
    cin >> A.at(i);
  }
  
  vector<int> P(1, 0);
  priority_queue<int, vector<int>, greater<int>> que0;
  for (int i = 0; i < N; i++)
  {
    P.at(0) += A.at(i);
    que0.push(A.at(i));
  }
  for (int i = N; i < 2 * N; i++)
  {
    int m = que0.top();
    if (m < A.at(i))
    {
      P.push_back(P.back() - m + A.at(i));
      que0.pop();
      que0.push(A.at(i));
    }
    else P.push_back(P.back());
  }
  
  vector<int> Q(1, 0);
  priority_queue<int> que1;
  for (int i = 3 * N - 1; i >= 2 * N; i--)
  {
    Q.at(0) += A.at(i);
    que1.push(A.at(i));
  }
  for (int i = 2 * N - 1; i >= N; i--)
  {
    int M = que1.top();
    if (M > A.at(i))
    {
      Q.push_back(Q.back() - M + A.at(i));
      que1.pop();
      que1.push(A.at(i));
    }
    else Q.push_back(Q.back());
  }
  reverse(Q.begin(), Q.end());
  
  int ans = -INF;
  for (int i = 0; i < N + 1; i++)
  {
    chmax(ans, P.at(i) - Q.at(i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6516
import itertools

N = int(input())
A = list(map(int, input().split()))
ans = list()
for i in itertools.combinations(A, 2):
  div = 0
  #print(i[0])
  if i[0] > i[1]:
    div = i[0] - i[1]
  else:
    div = i[1] - i[0]
  ans.append(div)

print(max(ans))

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  vector<int> l(n);
  for (int i = 0; i < n; i ++)
    cin >> l.at(i);
  
  sort(l.begin(), l.end());

  int sum = 0;
  for (int i = 0; i < n - 1; i ++)
    sum += l.at(i);

  if (l.at(n - 1) < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,P; cin >> N >> P;
    string S; cin >> S;
    reverse(all(S));
    int ans=0;
    if(P==2 || P==5){
        rep(i,SZ(S)){
            if((S[i]-'0')%P==0){
                ans+=N-i;
            }
        }
    } else {
        map<int,int> m;
        m[0]=1;
        int num;
        rep(i,SZ(S)){
            if(!i) num=S[i]-'0';
            else{
                num+=(power(10,i,P)*(S[i]-'0'))%P;
            }
            num%=P;
            ans+=m[num];
            m[num]++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1044
import sys
n = int(input())
s = input()
d = int(n/2)
if(len(s)%2 == 1):
    print("No")
    sys.exit()
else:
    for i in range(d):
        if(s[i] != s[i + d]):
            print("No")
            sys.exit()

print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define IN(a) scanf("%d",&a);
#define OUT(a) printf(a);
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
	int a[5];
	REP(i,5){
		IN(a[i])
	}

	if (a[2]-a[4] >= 0 && a[3]-a[4] >= 0 && a[2]+a[4] <= a[0] && a[3]+a[4] <= a[1] ){
		OUT("Yes\n")
	}
	else{
		OUT("No\n")
	}

	return 0;
 }

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

int main() {
 string a;
  cin>>a;
  int p=a.size();
  int q,r;
  
  for(int i=0;i<p;i++){
    if(a.at(i)=='A'){
      q=i+1;
      break;
    }
  }
  
  for(int i=0;i<p;i++){
    if(a.at(p-1-i)=='Z'){
      r=p-i;
      break;
    }
  }
  
  cout<<r-q+1<<endl;
  
}

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

int main() {
  int H1,H2,M1,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  M1+=H1*60;
  M2+=H2*60;
  cout<<max(M2-M1-K,0)<<endl;
}

Measured memory_bytes: 3652
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    x, k, d = [int(x) for x in input().rstrip().split(" ")]

    if abs(k * d) < abs(x):
        if x > 0:
            print(abs(x - k*d))
            return
        else:
            print(abs(x + k*d))
            return

    # 0直前まで
    step = x//(d)
    x -= d*step
    k -= step

    if k % 2 == 0:
        print(abs(x))
    else:
        if x > 0:
            print(abs(x - d))
        else:
            print(abs(x + d))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61772
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  string S, a, b, c, d;
  int N, cnt;
  cin >> S;
  N = S.size();
  if (N == 3) {
    if (S.at(0) == S.at(2)) {
      cout << "Yes";
    }
    else {
      cout << "No";
    }
  }
  else {
  	a = S.substr(0, N/2);
  	b = S.substr(N/2 + 1, N/2);
    
    if (a != b) {
      cout << "No";
    }
    else {
      for(int i = 0; i < (int)a.size(); i++){
    	if (a[i] != a[(int)a.size()-1-i]) {
          cout << "No" << endl << i;
          break;
        }
        cnt++;
        if (cnt == (int)a.size()) {
          cout << "Yes";
        }
      }
        
    }
  }
 
}

    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

vector<vector<ll>>g(100000);
ll dp[100000];

ll dfs(ll x){
  if(dp[x]!=-1) return dp[x];
  ll temp=0;
  for(auto v:g[x]){
    temp=max(temp,dfs(v)+1);
  }
  dp[x]=temp;
  return dp[x];
}

int main() {
  ll n,m;
  cin>>n>>m;
  ll x,y;
  for(int i=0;i<n;i++) dp[i]=-1;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    g[x-1].push_back(y-1);
  }
 /* for(int i=0;i<n;i++){
    for(int j=0;j<g[i].size();j++){
      cout<<g[i][j]<<" ";
    }
    cout<<"\n";
  }*/
  ll res=0;
  for(int i=0;i<n;i++){
    x=dfs(i);
    res=max(res,x);
   // cout<<x<<" ";
  }
  cout<<res<<"\n";
}

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

from operator import mul
from functools import reduce

def bb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
if m==1 and n==1:
    print(0)
    exit()

if m>1 and n>1:
    print(bb(n,2)+bb(m,2))
elif m>1:
    print(bb(m,2))
else:
    print(bb(n,2))



Measured memory_bytes: 3572
a, b, c, x, y = [int(i) for i in input().split()]

if (a + b) <= c * 2:
  cost_over = 10 ** 100
  cost = a * x + b * y 
else: 
  if x <= y:
    cost_over = c * 2 * y
    cost = c * 2 * x + b * (y - x)
  else: 
    cost_over = c * 2 * x
    cost = c * 2 * y + a * (x - y)

min = min(cost, cost_over)
print(min)

  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e5 + 1010;
const int P = 3000;

map <LL, int> kwa;
map <pair<LL, LL>, int> m;
map <pair<LL, LL>, int> done;

int n;
LL a;
vector <int> p;
bool sito[N];



int main() {	
	scanf ("%d", &n);
	rep(i, 2, N - 1) {
		if (!sito[i]) {
			if (i <= P) p.pb(i);
			kwa[(LL) i * i] = i;
			for (int j = i; j < N; j += i)
				sito[j] = 1;
		}
	}
	rep(i, 1, n) {
		scanf ("%lld", &a);
		LL x = 1, y = 1;
		for (auto it : p) {
			if (a % it == 0) {
				int cnt = 0;
				while (a % it == 0) {
					cnt++;
					a /= it;
				}
				if (cnt % 3 == 1) x *= it;
				if (cnt % 3 == 2) y *= it;
			}
		}
		if (a > 1 && kwa.count(a) > 0)
			y *= kwa[a];
		else if (a > 1)
			x *= a;
		m[{x, y}] += 1;
		//printf ("%lld %lld\n", x, y);
	}
		
	int opt = 0;
	for (auto it : m) {
		if (done.count(it.fi)) continue;
		LL x = it.fi.fi;
		LL y = it.fi.se;
		done[{x, y}] = done[{y, x}] = 1;
		if (x == 1 && y == 1) {
			opt++;
			continue;
		}
		opt += max(m[{x, y}], m[{y, x}]);
	}
	printf ("%d\n", opt);
		
	
	
	return 0;
}


Measured memory_bytes: 25984
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}


int main() {
    int n;cin>>n;
    int seat[100002]={0};
    for(auto i = 0;i<n;i++){
        int l,r;cin>>l>>r;
        seat[l]++;
        seat[r+1]--;
    }
    int count = 0;
    for(auto i=1;i<100002;i++){
        seat[i] += seat[i-1];
        if(seat[i] == 1) count++;
    }
    
    cout << count << endl;
    return 0;
}







Measured memory_bytes: 640
H,W=map(int,input().split())
a=[]

for i in range(H):
    a.extend(list(input()))

b=[0]*26
abc="abcdefghijklmnopqrstuvwxyz"

for i in a:
    b[abc.index(i)]+=1

if max(b)==H*W:
    print("Yes")
    exit()


num_odd=0
num_4=0
num_2=0

for i in range(26):
    if b[i]%4!=0:
        if b[i]%2==1:
            if num_odd!=0:
                print("No")
                exit()
            else:
                num_odd=b[i]
        else:
            num_4+=4*(b[i]//4)
            num_2+=b[i]%4
    else:
        num_4+=b[i]

if H%2==0 and W%2==0:
    if num_odd!=0 or num_2!=0:
        print("No")
    else:
        print("Yes")
elif H%2==1 and W%2==0:
    if num_4-(H-1)*W>=0 and num_4-(H-1)*W+num_2==W:
        print("Yes")
    else:
        print("No")
elif H%2==0 and W%2==1:
    if num_4-(W-1)*H>=0 and num_4-(W-1)*H+num_2==H:
        print("Yes")
    else:
        print("No")
elif H%2==1 and W%2==1:
    if num_4+4*(num_odd//4)>=(H-1)*(W-1):
        print("Yes")
    else:print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define 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,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P[i];
  vector<ll> A(N), B(N);
  rep(i, N) A[i] = B[N-1-i] = 1 + i * 40000L;
  rep(i, N) A[P[i]-1] += i;
  rep(i, N) cout << A[i] << ' '; cout << endl;
  rep(i, N) cout << B[i] << ' '; cout << endl;
  return 0;
}


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

typedef long long ll;
const ll INF = 1LL << 60;

ll N, K;
int main() {
    cin >> N >> K;

    ll ans = 0;
    while (N != 0) {
        N /= K;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256