akhauriyash/Code-Regression huggingface dataset:
# AtCoder Regular Contest 065
# D - 連結 / Connectivity
# https://atcoder.jp/contests/arc065/tasks/arc065_b
import sys
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        # self.parent = [i for i in range(n)]
        self.parent = list(range(n))
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, *KL = map(int, input().split())
    uf = [UnionFind(N) for _ in range(2)]
    for i in range(2):
        for j in range(KL[i]):
            p, q = map(int, input().split())
            uf[i].union(p-1, q-1)

    d = defaultdict(int)
    for i in range(N):
        d[(uf[0].find(i), uf[1].find(i))] += 1

    # for i in range(N):
    #     print(d[(uf[0].find(i), uf[1].find(i))], end = " ")
    # print("")
    
    print(" ".join([str(d[(uf[0].find(i), uf[1].find(i))]) for i in range(N)]))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


Measured memory_bytes: 60508
#include<iostream>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a > b && a > c){
    cout << b*c/2 << endl;
  }else if(b > a && b > c){
    cout << a*c/2 << endl;
  }else{
    cout << a*b/2 << endl;
  }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ret = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int sum = 0;
            for (int k = 0; k < d; k++)
            {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int sq = sqrt(sum);
            if (sum == sq * sq)
                ret++;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int answer = 0;
if(N>=3*5*7){
  answer++;
}
if(N>=3*5*11){
  answer++;
}
if(N>=3*5*13){
  answer++;
}
if(N>=3*3*3*5){
  answer++;
}
if(N>=3*3*3*7){
  answer++;
}

System.out.println(answer);
}
}


Measured memory_bytes: 23252
import sys
from itertools import accumulate
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


MAX = 10**5


def eratosthenes(n):
    is_prime = [1] * n
    is_prime[0] = 0

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = 0
                j += i
    return is_prime


def main():
    q = int(input())
    is_prime = eratosthenes(MAX)

    a = [0] * (MAX+1)
    for i in range(MAX+1):
        if is_prime[i-1] and is_prime[(i+1)//2-1]:
            a[i] = 1

    s = [0] + a
    s = list(accumulate(s))

    for _ in range(q):
        l, r = map(int, input().split())
        print(s[r+1] - s[l])


if __name__ == '__main__':
    main()


Measured memory_bytes: 8508
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	char a[105];
	scanf("%s",a+1);
	int n=strlen(a+1);
	if(n==1) {printf("%c\n",a[1]);return 0;}
	bool flag=true;int cnt=0;
	for(int i=1;i<=n;++i) {if(a[i]!='9') flag=false;cnt+=a[i]-'0';}
	if(flag) {printf("%d\n",n*9);return 0;}
	int ans=0;
	ans+=a[1]-'1';
	ans+=(n-1)*9;
	printf("%d\n",max(ans,cnt));
	return 0;
}

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

namespace AtCoderBeginnerContest148
{
    class A_RoundOne
    {
        static void Main(string[] args)
        {
            var valA = int.Parse(Console.ReadLine());
            var valB = int.Parse(Console.ReadLine());
            var ans = Enumerable.Range(1, 3).Where(x => x != valA).Where(x => x != valB).First();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
// AOJ Volume2 0222

#include <stdio.h>
#include <string.h>

#define MAX (10000000)

char prime[10000001];

int main(void)
{
    int n;
    int i, j;

    
    for (i = 2; i <= MAX; i++){
        if (prime[i] == 0){
            for (j = i + i; j <= MAX; j += i){
                if (j <= MAX){
                    prime[j] = 1;
                }
            }
        }
    }

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        
        for (i = n; i >= 13; i--){
            if (prime[i] == 0){
                if (prime[i - 2] + prime[i - 6] + prime[i - 8] == 0){
                    printf("%d\n", i);
                    break;
                }
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 10364
from itertools import product

A, B, C, D = list(map(int, input()))

for pattern in product('+-', '+-', '+-'):
    f = '{}{}{}{}{}{}{}'.format(A, pattern[0], B, pattern[1], C, pattern[2], D)

    if eval(f) == 7:
        print(f+'=7')
        break

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
   int x,y,i,j;
   for(;;){
      scanf("%d %d",&y,&x);
      if(x+y==0) break;
      for(i=0;i<y;i++){
         for(j=0;j<x;j++)
            if(i*j==0 || i+1==y || j+1==x)
               printf("#");
            else
               printf(".");
         printf("\n");
      }
   printf("\n");
   }
   return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
using namespace std;
long long a[101];
int main()
{
	long long b=9999999999999,c=-1,d,e,f,n;//b is min;c is max.
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=b)
			b=a[i];
		if(a[i]>=c)
			c=a[i];
	}
	cout<<c-b;
	
} 

Measured memory_bytes: 256
import numpy as np
n = int(input())
S = [list(input()) for _ in range(n)]

ss = [s + s for s in S]
ss = np.array(ss + ss)

ans = 0
for i in range(n):
    a = ss[i:i + n, :n]
    if np.array_equal(a, a.T):
      ans += 1
print(ans * n)


Measured memory_bytes: 30236
#include<bits/stdc++.h>
using namespace std;
 
 int main() {
 
    long a,b,k;
    cin>>a>>b>>k;

    vector<long>v;
    long j;

    for(int i=a;i<=b;i++){

        if( i < a+k || i > b-k ){
            cout<<i<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int a, b, c, d, e;
	scanf("%d", &a);
	b = a / 3600;
	c = a % 3600;
	d = c / 60;
	e = c % 60;
	printf("%d:%d:%d\n", b, d, e);
	return 0;

}

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

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

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    map<ll,vector<ll>> m;
    vector<ll> p(N);
    rep(i,N) {
        p[i] = m[v[i]].size();
        m[v[i]].push_back(i);
    }
    vector<P> n(N);
    rep(i,N){
        if(p[i]!=(ll)(m[v[i]].size()-1)){
            n[i].first = m[v[i]][p[i]+1] - m[v[i]][p[i]] +1;
            n[i].second = (m[v[i]][p[i]+1]+1)%N;
        }
        else {
            n[i].first = N+m[v[i]][0]-m[v[i]][p[i]] +1;
            n[i].second = (m[v[i]][0] + 1)%N;
        }
    }
    ll L = 0;
    ll t = 0;
    do{
        L+=n[t].first;
        t = n[t].second;
    } while(t!=0);
    ll R = K*N % L;
    while(R>=n[t].first){
        R -= n[t].first;
        t = n[t].second;
    }
    vector<ll> ans;
    ll U = R;
    rep(i,R){
        ll s = (t+i)%N;
        if(n[s].first>U) {
            ans.push_back(v[s]);
            U--;
        }
        else {
            U-=n[s].first;
            i+=n[s].first-1;
        }
    }
    for(auto x:ans) cout<<x<<" ";
    cout<<endl;
}

Measured memory_bytes: 33488
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,t;
  cin >> a >> b >> c;
  if(a>b){
    t = a;
    a = b;
    b = t;
  }
  if(b>c){
    t = b;
    b = c;
    c = t;
  }
  if(a==5 && b==5 && c==7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int a[105],n,ans;
int main()
{
	cin>>n;
	for(RI i=1;i<=n+n;++i) cin>>a[i];
	sort(a+1,a+1+n+n);
	for(RI i=1;i<=n+n;i+=2) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int n,i,a[1000],sum;
    double d,ave;
    d=0.0;
    while(1){
        cin >> n;
        if(n==0)break;
        
        for(i=0;i<n; i++)cin >> a[i];
        sum=0.0;
        for(i=0;i<n; i++)sum=sum+a[i];
        ave=1.0*sum/n;
        d=0.0;
        for(i=0; i<n; i++){
            d=d+(ave-a[i])*(ave-a[i]);
        }
        printf ("%lf\n",sqrt(d/n));
    }
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  int a[100];
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  long long tri = 1;
  rep(i, n) {
    tri *= 3;
  }
  int count = 0;
  rep(i, n) {
    if (a[i] % 2 == 0){
      count += 1;
    }
  }
  long long bi = 1;
  rep(i, count) {
    bi *= 2;
  }
  cout << tri - bi << endl;
  return 0;
}


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

int main() {
  int K;
  cin >> K;
  int a=0;
  int ans=-1;
  for (int i=0; i<K; i++){
    a=a*10+7;
    a=a%K;
    if (a==0) {
      ans=i+1;
      break;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(void) {
  long n;
  cin >> n;
  long a[n];
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  long tmp1=0, tmp2=0;
  long ans1=0, ans2=0;

  for(int i=1;i<=n;++i){
    tmp1 += a[i-1];
    tmp2 += a[i-1];
    if(i%2){
      if(tmp1 <= 0){
        ans1 += 1 - tmp1;
        tmp1 = 1;
      }
      if(tmp2 >= 0){
        ans2 += 1 + tmp2;
        tmp2 = -1;
      }
    }
    else{
      if(tmp1 >= 0){
        ans1 += 1 + tmp1;
        tmp1 = -1;
      }
      if(tmp2 <= 0){
        ans2 += 1 - tmp2;
        tmp2 = 1;
      }
    }
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 1024
n, m = [int(i) for i in input().split()]
if n >= 3 and m >= 3:
    ans = (n - 2) * (m - 2)
elif n == 1 and m == 1:
    ans = 1
elif n == 1 and m >= 2:
    ans = m - 2
elif n >= 2 and m == 1:
    ans = n - 2
elif n == 2 or m == 2:
    ans = 0

print(ans)


Measured memory_bytes: 61812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long N, L;
cin >> N >> L;
vector<string> s(N);
rep(i, N) cin >> s.at(i);
sort(s.begin(), s.end());
rep(i, N) cout << s.at(i);
cout << endl;


// cout << ans1 << ans2 << endl;
  return 0;
 
}



Measured memory_bytes: 256
#include <stdio.h>
 
int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];
 
int main()
{
    int q, i, t, f;
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    scanf("%d", &q);
    while (q--) {
        scanf("%d%d", &t, &f);
        for (i = 1; i <= 6; i++) {
            if (assign[i] == t) t = i;
            if (assign[i] == f) f = i;
        }
        printf("%d\n", assign[face[t][f][3]]);
    }
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  vector<string> d;
  rep(i,s.size()){
    for(int j=i;j<min(i+5,(int)s.size());j++){
      d.pb(s.substr(i,j-i+1));
    }
  }
  sort(d.begin(),d.end());
  int p=1;
  int now=0;
  while(p<k){
    if(d[now+1]!=d[now]) p++;
    now++;
  }
  cout<<d[now]<<endl;
}

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

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> A(x), B(y), C(z);
  rep(i, x) cin >> A[i];
  rep(i, y) cin >> B[i];
  rep(i, z) cin >> C[i];
  int n = x * y;
  vector<ll> D(n);
  rep(i, x) rep(j, y) D[i+j*x] = A[i] + B[j];
  sort(D.begin(), D.end());

  auto f = [&](ll c) {
    int res = D.end() - lower_bound(D.begin(), D.end(), c);
    return res;
  };

  auto g = [&](ll c) {
    int res = 0;
    rep(i, z) {
      res += f(c - C[i]);
    }
    return res;
  };

  ll l = 0, r = 10000000000 * 3 + 1;
  while (l+1 < r) {
    ll m = (l+r) / 2;
    if (k > g(m)) r = m;
    else l = m;
  }

  vector<ll> ans;
  rep(i, z) {
    rep(j, n) {
      if (C[i] + D[n-1-j] < r) break;
      ans.push_back(C[i] + D[n-1-j]);
    }
  }
  sort(ans.rbegin(), ans.rend());
  for (ll a : ans) cout << a << endl;
  rep(i, k-ans.size()) cout << l << endl;
  
  return 0;
}


Measured memory_bytes: 11304
import itertools
N, K = [int(_) for _ in input().split()]
P = [int(_) - 1 for _ in input().split()]
C = [int(_) for _ in input().split()]


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_right(self, p, v):  # apply operator from the right side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(dat[p], v)
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_left(self, p, v):  # apply operator from the left side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(v, dat[p])
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        vl = vr = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                vl = f(vl, dat[l])
                l += 1
            if r & 1:
                r -= 1
                vr = f(dat[r], vr)
            l >>= 1
            r >>= 1
        return f(vl, vr)


ans = -10**20
se = set()
for start in range(N):
    if start in se:
        continue
    now = start
    scores = []
    while True:
        if now in se:
            break
        se.add(now)
        scores += [C[now]]
        now = P[now]
    cyclelen = len(scores)
    cum = list(itertools.accumulate(scores * 2))
    st = SegmentTree(cum, max, -10**20)
    cycle, residue = divmod(K, cyclelen)
    ans = max([ans] + [
        st.query(start2 + 1, start2 + 1 + min(cyclelen, K)) - cum[start2]
        for start2 in range(cyclelen)
    ])
    if cum[-1] > 0 and cycle > 0:
        v1 = cum[-1] * (cycle - 1) // 2 + max(
            st.query(start2, start2 + cyclelen + 1) - cum[start2]
            for start2 in range(cyclelen))
        v2 = cum[-1] * cycle // 2 + max(
            st.query(start2, start2 + residue + 1) - cum[start2]
            for start2 in range(cyclelen))
        ans = max([ans, v1, v2])
print(ans)


Measured memory_bytes: 11276
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int l; cin>>l; string str; cin>>str; int ans=0;
  for(int i=0;i<l-2;i++)
    if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C') ans++;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N;
    ll goukei = 0;
    cin >> N;
    vector<ll> B(N);

    for(int i = 0;i < N;i++){
        if(i < N -1)
            cin >> B.at(i);
        else if(i == N -1)
            B.at(i) = B.at(i -1);
    }
    
    for(int i = 0;i < N ;i++){
        if(i == 0)
            goukei += B.at(i);
        else if(i == N -1)
            goukei += B.at(i);
        else{
            if(B.at(i) <= B.at(i-1))
                goukei += B.at(i);
            else
            {
                goukei += B.at(i-1);
            }
            
        }
    }

    cout << goukei << endl;

}

Measured memory_bytes: 256
T_HP, T_A, A_HP, A_A = map(int, input().split())

while (True):
    A_HP -= T_A
    if (A_HP <= 0):
        print('Yes')
        exit()
    else:
        T_HP -= A_A
    
    if (T_HP <= 0):
        print('No')
        exit()

Measured memory_bytes: 9172
import java.util.Scanner;

/**
 * 2019/06/15
 * AtCoder Beginner Contest 130
 * 
 * A - Rounding
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int A = sc.nextInt();

		int result;
		if(X < A) {
			result = 0;
		} else {
			result = 10;
		}
		
		System.out.println(result);
	}
	
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

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


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

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
vector<long long> factor_array(long long n){
    vector<long long> res ;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i) ;
            if(i*i!=n){
                res.push_back(n/i) ;
            }
        }
    }
    sort(res.begin(),res.end()) ;
    return res ;
}

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

vector<pair<long long, long long>> prime_factorization(long long n){
    vector<pair<long long, long long>> res ;
    vector<long long> tmp = factor_array(n) ;
    for(long long i = 0; i<(long long)tmp.size(); i++){
        if(is_prime(tmp[i])){
            long long m = n ;
            long long cnt = 0 ;
            while(m%tmp[i]==0){
                m /= tmp[i] ;
                cnt++ ;
            }
            res.push_back(make_pair(tmp[i],cnt)) ;
        }
    }
    return res ;
}

vector<bool> prime_table(int n){
    vector<bool> res(n+1,true) ;

    res[0] = false ;
    res[1] = false ;

    for(int i=2;i*i<=n;i++){
        if(res[i]){
            int j = i+i ;
            while(j<=n){
                res[j] = false ;
                j += i ;
            }
        }
    }
    return res ;
}
//-----------------------------------------

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

  ll n;
  cin >> n;
  vpll ans = prime_factorization(n);
  cout << n << ":";

  for(int i=0;i<SZ(ans);i++){
    ll m = ans[i].second;
    ll k = ans[i].first;
    for(int j = 0;j<m;j++){
      cout << " " << k ;
    }
  }
  cout <<endl;



  return 0;
}



Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int A[101][100];//データを入れる配列
int d[101];
int f[101];
int t = 1;//time

int Depth(int n){
    if((f[n] != 0)){//既に探索が終了していたら、その節点は飛ばす
        return 0;
    }
    if(d[n] == 0){//はじめて通る節点だったら、dに時間を記録
        d[n] = t;
        t++;
    }
    if((A[n][0] != 0)){//隣接点が1つ以上ある場合は以下のループに入る
        for(int i=1; i<=A[n][0]; i++){
            //if(A[n][i] == n){//自分自身に返ってくるノードだったら、
            //    f[A[n][i]] = t;
            //    t++;
            //    return 0;
            //}
            if((A[n][i] != n) && (d[A[n][i]] == 0)){
                Depth(A[n][i]);
            }
        }
    }
    f[n] = t;
    t++;
}

int main(){
    int n, num;
    cin >> n;
    for(int k=1; k<=n; k++){
        d[k] = 0;
        f[k] = 0;
    }
    for(int i=1; i<=n; i++){
        cin >> num;
        cin >> A[i][0];
        for(int j=1; j<=A[i][0]; j++){
            cin >> A[i][j];
        }
    }

    for(int l=1; l<=n; l++){
        Depth(l);
        //cout << l << " " << d[l] << " " << f[l] << " " << endl;
    }
    for(int i=1; i<=n; i++){
        cout << i << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;
    
int main()
{
    int A[3][3];
    int N;
    int b[10];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    cin >> N;
    for (int i = 0; i < N; i++) cin >> b[i];

    bool flag[3][3] = { false };
    for (int h = 0; h < N; h++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (b[h] == A[i][j]) flag[i][j] = true;
            }
        }
    }

    bool bingo = false;
    for (int i = 0; i < 3; i++) {
        if (flag[i][0] && flag[i][1] && flag[i][2]) bingo = true;
    }
    for (int j = 0; j < 3; j++) {
        if (flag[0][j] && flag[1][j] && flag[2][j]) bingo = true;
    }
    if (flag[0][0] && flag[1][1] && flag[2][2]) bingo = true;
    if (flag[0][2] && flag[1][1] && flag[2][0]) bingo = true;
    if (bingo) cout << "Yes" << endl;
    if (!bingo) cout << "No" << endl;
}


Measured memory_bytes: 256
console.log((args=>{
  const [[N],a] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  let count = 0;
  for ( let i = 0; i < N; i+=2 ) {
    if ( a[i]&1 ) count++;
  }
  return `${count}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29672
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	ll=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
	a = int(input())
	print(ll[a-1])
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main() {
  
  int n;
  cin >> n;
  
  bool flags[] = {0, 0, 0, 0};
  for(int i = 0; i < n; i++) {
    char c;
    cin >> c;
    switch(c) {
      case 'P': 
        flags[0] = true;
        break;
      case 'W': 
        flags[1] = true;
        break;
      case 'G': 
        flags[2] = true;
        break;
      case 'Y': 
        flags[3] = true;
        break;
    }
  }
  
  if((flags[0] + flags[1] + flags[2] + flags[3]) == 3) {
    cout << "Three" << endl;
  }
  else if((flags[0] + flags[1] + flags[2] + flags[3]) == 4) {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define INF 1000000000
int p[101],m[101][101];
int x,y;
void matrixChainOrder(int);

int main(){
  int n,i,j;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    

    scanf("%d%d",&p[i-1],&p[i]);
     
    
  }
   
  matrixChainOrder(n);

  printf("%d\n",m[1][n]);

  return 0;
}

void matrixChainOrder(int num){
  int n,i,k,j,l,q=INF,*data,t;
  n=num;
  

  for(i=1;i<=n;i++){
    m[i][i]=0;
    
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i,t=0;k<=j-1;k++){
	//	printf("%d,%d\n",m[x][y],m[i][k]+m[k+1][j]+(p[i-1][0])*(p[k][0])*(p[j][0]));

	m[i][j]=fmin(m[i][j],m[i][k]+m[k+1][j]+(p[i-1])*(p[k])*(p[j])); 
	 
      }
   

    }

  }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define pii pair<int,int>
#define se second
using namespace std;
void solve()
{
    int n;
    cin>>n;
    int tle=0,ac=0,wa=0,re=0;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        if(s[i]=="AC"){
            ac++;
        }else if(s[i]=="WA"){
            wa++;
        }else if(s[i]=="TLE"){
            tle++;
        }else{
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re;
}
int32_t main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
    }
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    ll a , b ;
    cin >> a >> b ;

    ll rem = a % b ;
    ll ans = a / b ;

    if ( rem ) ans ++ ;

    cout << ans ;
    line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define INF 1700000
using namespace std;

vector<vector<int> >a;
int n;

int lo(int,int);
int main(){
  while(1){

    cin >>n;
    if(n==0)break;
    a=vector<vector <int> >(n,vector<int>(n+1,0));
    for(int i=0;i<n;i++){
      for(int j=0;j<n+1;j++){
        cin >> a[i][j];
      }
    }
    vector<vector<int> >ma(1<<n,vector<int>(n+1,INF));
    vector<int>mi(1<<n,INF);
    //data input                                                                
    mi[0]=0;
    for(int i=0;i<1<<n;i++){
      for(int j=0;j<n;j++){
        if((i&(1<<j))!=0)continue;
        mi[i|(1<<j)]=min(mi[i|(1<<j)],mi[i]+lo(j,i));
      }
    }
    /* for(int i=0;i<mi.size();i++){
      cout << mi[i]<<endl;
      }*/
	

    cout << mi[mi.size()-1]<<endl;   
  }
  return 0;
}
int lo(int r,int ha){
  int mi = a[r][0];
  for(int i=0;i<n;i++){
    if((ha&(1<<i))==0)continue;
    mi=min(mi,a[r][i+1]);
  }
  return mi;
}

Measured memory_bytes: 9632
n,m = map(int,input().split())
pairs = []
for i in range(m):
    a,b = map(int,input().split())
    pairs.append([a-1,b-1])

ans = [0]*m
P = [-1]*n

def find(a):
    if(P[a] < 0):
        return a
    P[a] = find(P[a])
    return P[a]

def same(a, b):
    return find(a) == find(b)

def size(a):
    return -P[find(a)]

def unite(a,b):
    a = find(a)
    b = find(b)
    if(a == b):
        return false
    if(P[a] > P[b]):
        a,b = b,a
    P[a] += P[b]
    P[b] = a

t = n*(n-1)/2

for i in range(m):
    ans[m-1-i] = int(t)
    u,v = pairs[m-1-i][0],pairs[m-1-i][1]
    if(same(u,v)):
        continue
    else:
        t-= size(u)*size(v)
        unite(u,v)

print(*ans,sep = "\n")


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

int main() {
  int n,m;
  std::cin >> n>>m;
  std::vector<int> ans(n+1);
  for (int i = 0; i < n+1; i++) {
    ans[i]=0;
  }

  int num;
  string po;
  int conum=0;
  int misnum=0;
  for (int i = 0; i < m; i++) {
    std::cin >> num >>po;
    if(ans[num]!=-1){
      if(po=="AC"){
        misnum+=ans[num];
        ans[num]=-1;
        conum++;
      }
      else{
        ans[num]++;
      }
    }
  }
  std::cout << conum << '\n';
  std::cout << misnum << '\n';
  return 0;
}


Measured memory_bytes: 640
n, a, b = map(int, input().split(" "))
MOD = 10 ** 9 + 7

def comb(total, count):
  x, y = 1, 1
  for i in range(count):
    x = x * (total - i) % MOD
    y = y * (count - i) % MOD
  return x * pow(y, MOD - 2, MOD) % MOD

s = (pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)) % MOD
print(s)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] cnt = new int[100000];
		for (int i = 0; i < n; i++) {
			cnt[sc.nextInt()]++;
		}
		sc.close();

		int ans = 0;
		for (int i = 1; i < 99999; i++) {
			int sum = cnt[i - 1] + cnt[i] + cnt[i + 1];
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 51860
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space*/
int main(){
  unsigned  x,y; cin >> x >> y;
  unsigned  ans = 0;
  ans = min(y-x,min(y+x+1,min(-y-x+1,-y+x+2)));
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    one=set()
    two=set()
    three=set()
    n=int(input())
    s=input()
    for c in s:
        for s2 in two:
            three.add(s2+c)
        for s1 in one:
            two.add(s1+c)
        one.add(c)
    print(len(three))

main()

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
	char s[100005];
	int i, n, k;
	int a, b ,c;
	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &k);
	int xi = 1;
	for(i = 1 ; i <= k ; i++)
	{
		xi = xi * 2;
	}
	int ans1,ans2,ans3;
	ans1 = a * xi + b +c;
	ans2 = a + b * xi + c;
	ans3 = a + b + c * xi;
	printf("%d\n", max(max(ans1, ans2),ans3));
	return 0;
}

Measured memory_bytes: 128
n, a, b = map(int, input().split())

mod = 10 ** 9 + 7
f = [1]
for i in range(1,2*(10 ** 5)+1):
    f.append((f[-1] * i) % mod)
def comb(n,r):
    z = 1
    for i in range(n-r+1, n+1):
        z *= i
        z %= mod
    return (z * pow(f[r], mod-2, mod)) % mod

ans = (pow(2, n, mod) - 1 - comb(n, a) - comb(n, b)) % mod

print(ans)

Measured memory_bytes: 11028
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXM = 60;
const int MAXN = 20;

struct Edge {
    int x, y, z;
}edge[MAXM + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, l;
    ios::sync_with_stdio(false);
    cin >> l;
    l--;
    if(l == 1) {
        cout << 2 << " " << 2 << "\n";
        cout << "1 2 0\n";
        cout << "1 2 1\n";
        return 0;
    }
    int bit;
    for(i = 0; (1 << i) <= l; i++) {
        if(l & (1 << i)) {
            bit = i;
        }
    }
    n = bit + 1;
    int m = 0;
    for(i = 1; i < n; i++) {
        edge[++m] = {i, i + 1, 0};
    }
    for(i = 1; i < n; i++) {
        edge[++m] = {i, i + 1, 1 << (bit - i)};
    }
    int cst = (1 << bit);
    for(i = bit - 1; i >= 0; i--) {
        if(l & (1 << i)) {
            edge[++m] = {1, n - i, cst};
            cst += (1 << i);
        }
    }
    edge[++m] = {1, n, l};
    cout << n << " " << m << "\n";
    for(i = 1; i <= m; i++) {
        cout << edge[i].x << " " << edge[i].y << " " << edge[i].z << "\n";
    }
    //cin.close();
    //cout.close();
    return 0;
}


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

int main() {
  int A;
  cin >> A;
  int B = 0;
  while(A > floor(B * 1.08)) {
    B = B + 1;
  }
  if(A == floor(B * 1.08)){
    cout << B << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N  1000
int max(int a,int b){
  if(a>b) return a;
  return b;
}
 
int lcs(char *X,char *Y){
  int c[N+1][N+1];
  int m = strlen(X);
  int n = strlen(Y);
  int maxl=0;
  int i,j;
  for(i=m;i>=0;i--){
    X[i+1]=X[i];
  }
   for(i=n;i>=0;i--){
    Y[i+1]=Y[i];
  }
  X[0]=' ';
  Y[0]=' ';
  for(i=1;i<=m;i++)c[i][0]=0;
  for(j=1;j<=n;j++)c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i]==Y[j]){
    c[i][j]=c[i-1][j-1]+1;
      }else{
    c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }
  return maxl;
}
     
 
int main(){
  char s1[N+1],s2[N+1];
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",s1,s2);
    printf("%d\n",lcs(s1,s2));
  }
  return 0;
}

Measured memory_bytes: 4524
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var X = sc.nextInt();
        var Y = sc.nextInt();
        WriteLine(X + (Y / 2));
    }
}

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 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 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[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int n = scan.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] a = new int[n];


		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
			y[i]=scan.nextInt();
			a[i]=scan.nextInt();
		}

		int maxX=0;
		int minX=w;
		int maxY=0;
		int minY=h;

		for(int i=0;i<n;i++) {

			if(a[i]==1) { //x<xiをぬる
				if(maxX<=x[i]) {
					maxX=x[i];
				}

			}else if(a[i]==2) {
				if(minX==w) {
					minX=x[i];
				}else if(minX!=0 && minX>x[i]) {
					minX=x[i];
				}

			}else if(a[i]==3) {
				if(maxY<=y[i]) {
					maxY=y[i];
				}

			}else if(a[i]==4) {
				if(minY==h) {
					minY=y[i];
				}else if(minY!=0 && minY>y[i]){
					minY = y[i];
				}
			}
		}
		int kuro =0;
		/*
		System.out.println(maxX);//maxXより小さいところを塗る
		System.out.println(minX);//minXより大きいところを塗る
		System.out.println(maxY);//maxYより小さいところを塗る
		System.out.println(minY);//minYより大きいところを塗る
		*/
		if(maxX>=minX && minX!=0) {
			kuro = w*h;
		}else if(maxY>=minY && minY!=0) {
			kuro = w*h;
		}else {
			//if(maxX==0&&minX==w){
			//kuro=w*maxY+w*(h-minY);
			//}else if(maxY==0 && minY==h) {
				//kuro=h*maxX + h*(w-minX);
			//}else {
				kuro=h*(maxX)+h*(w-minX)+w*maxY+w*(h-minY);
				//System.out.println(kuro);
				//多すぎるので引く
				kuro=kuro-( (maxX*maxY)+(maxX*(h-minY))+((w-minX)*maxY)+((w-minX)*(h-minY)));
//System.out.println(kuro);
				if(minX==w) {

					kuro= maxX*h+maxY*w+w*(h-minY);
					kuro = kuro - ( (maxX*maxY)+(maxX*(h-minY))+((w-minX)*maxY)+((w-minX)*(h-minY)));


				}
				if(minY==h) {
					kuro= maxY*w+maxX*h+h*(w-minX);
					kuro = kuro - ( (maxX*maxY)+(maxX*(h-minY))+((w-minX)*maxY)+((w-minX)*(h-minY)));

				}




				if(maxX==0&&minX==w){
					kuro=w*maxY+w*(h-minY);
					}else if(maxY==0 && minY==h) {
						kuro=h*maxX + h*(w-minX);
				}

		}
		//System.out.println(kuro);
		System.out.println(w*h-kuro);


		}


}


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int A,B,ans=-1;
  cin>>A>>B;
  if(A>9 || B>9){
    cout<<ans<<endl;
  }else{
    ans=(A*B);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define read(x) scanf("%d",&x)
typedef long long ll;
typedef double dl;
using namespace std;

const int N=2e5+7;
const int M=1e9+7;
const int INF=0x3f3f3f3f;

int n,m;

vector<int> G[N];
int h[N];

bool check(int x){
	for(auto i:G[x]){
		if (h[i]>=h[x]) return 0;
	}
	return 1;
}

int u,v;

void solve(){
	cin>>n>>m;
	fo(i,1,n) cin>>h[i];
	fo(i,1,m){
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int ans=0;
	fo(i,1,n){
		ans+=check(i);
	}
	cout<<ans;
}

int main(){
//	ios::sync_with_stdio(0);
//  cin.tie(0),cout.tie(0);
//	int T;read(T);
//	for(int i=1;i<=T;i++)
		solve();
}


Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

ll f (ll n, ll b) {
        if (b == 1) return -1;
        ll s = 0;
        while (n) s += n%b, n /= b;
        return s;
}

ll N, S, ans = 1e18;

int main () {
        cin >> N >> S;
        if (N == S) ans = N+1;
        for (ll i = 1; i*i <= N; i++) if (f(N, i) == S) ans = min(ans, i);
        for (ll i = 1; i*i <= N-S; i++) if ((N-S)%i == 0) {
                ll x = (N-S)/i;
                if (f(N, i+1) == S) ans = min(ans, i+1);
                if (f(N, x+1) == S) ans = min(ans, x+1);
        }
        printf("%lld\n", ans == 1e18 ? -1 : ans);
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;

int n;

int vis[MAX], prime[MAX], num;
ll phi[MAX];
void makePhi(int siz) {
    phi[1] = 1;
    for (int i = 2; i <= siz; i++) {
        if (!vis[i]) prime[++num] = i, phi[i] = i - 1;
        for (int j = 1; j <= num && i * prime[j] <= siz; j++) {
            vis[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                phi[i * prime[j]] = phi[i] * prime[j];
                break;
            }
            else phi[i * prime[j]] = phi[i] * phi[prime[j]];
        }
    }
    for (int i = 1; i <= siz; i++) phi[i] += phi[i - 1];
}

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d", &n);
    makePhi(n);
    ll ans = 0;
    for (int l = 1, r = 0; l <= n; l = r + 1) {
        r = n / (n / l);
        ans += 1ll * (phi[r] - phi[l - 1]) * (n / l) * (n / l) * (n / l);
    }
    printf("%lld\n", ans);


    return 0;
}

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

const int INF = 0x3f3f3f3f;
const int MAX = 1e5+20;
int n,k,arr[MAX],dp[MAX];

int solve(int cur) {
    if(cur==n-1) return 0;
    if(cur>n) return INF;

    if(~dp[cur]) return dp[cur];

    int ans=INF;

    for(int i=1;i+cur<n&&i<=k;i++){
        ans=min(ans, abs(arr[cur]-arr[cur+i])+solve(cur+i));
    }

    return dp[cur]=ans;

}

int main() {

    memset(dp,-1,sizeof(dp));

    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&arr[i]);

    solve(0);
    printf("%d\n",dp[0]);

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 1000000; ++i) {
		if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
			dunk(i);
			return 0;
		}
	}
	dunk(-1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()
    e = [[] for _ in range(n)]
    for _ in range(m):
        a, b = ns()
        e[a - 1].append(b - 1)

    res = [-1 for _ in range(n)]

    def dfs(ti):
        tmp = 0
        for vi in e[ti]:
            if res[vi] != -1:
                tmp = max(tmp, res[vi] + 1)
            else:
                tmp = max(tmp, dfs(vi) + 1)
        res[ti] = tmp
        return tmp

    ans = 0
    for i in range(n):
        if res[i] == -1:
            ans = max(ans, dfs(i))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76040