akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
#define INF (1e18)+1
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i; 
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}

int arr[200001];

 
int32_t main() {
 
   int N,K ;
   
   cin >> N >> K;
   
   for(int i=0; i<N; i++){
   		
   		cin >> arr[i];
   	
   	
   }
   
   sort(arr, arr+N);
   
   reverse(arr,arr+N);
   
   int cnt = 0 ;
   for(int i=0+K; i<N; i++){
   	
   		cnt+= arr[i];
   	
   }
   
   
   cout << cnt << endl;
   
}

Measured memory_bytes: 4712
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int r;
    cin >> r;
    cout << ( r * r ) * 3 << endl;
    return 0;
}


Measured memory_bytes: 256
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int t[13];
   t[0]=1; for(int i=1; i<13; i++) t[i]=t[i-1]*26;

   int N; cin>>N;
   int l=1,s=26;
   while(s<N){
      l++;
      s+=t[l];
   }
   N-=s-t[l]+1;
   //cout << N << endl;

   str res;

   for(int p=l-1; p>=0; p--){
      int idx=0;
      while(idx*t[p]<=N) idx++; idx--;
      res+=char('a'+idx);
      N-=t[p]*idx;
   }
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
	int i,a[3],sum=0,x,y;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	x=sum/60;
	y=sum%60;
	printf("%d\n%d\n",x,y);
	return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<string>
using namespace std;
int main(){
    int priceadder=0;
    string add;
    cin >> add;
    for(int i = 0;i < 4;i++){
        if(add[i] =='o'){
            priceadder += 100;
        }
    }
    cout << 700+priceadder << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = set(il())
    Q = ii()
    T = set(il())

    ret = 0
    for t in T:
        if t in S:
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()



Measured memory_bytes: 16284
import java.util.Scanner;

public class Main {

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

		    String s = sc.nextLine();
		    String n = s.substring(1, 2);
		    int si = Integer.parseInt(s);
		    int ni = Integer.parseInt(n);
		    
		    if((si - ni * 10) % 101 == 0) {
		    	System.out.println("Yes");
		    }
		    else {
		    	System.out.println("No");
		    }
		    
		    sc.close(); }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>

using namespace std;

int main(void){
	while(1){
		int n; cin >> n;
		if(!n) break;

		vector<pair<int, int> > v(n);
		for(int i=0; i<n; i++){
			cin >> v[i].second >> v[i].first;
		}

		int m; cin >> m;
		vector<pair<char, int> > move(m);
		for(int i=0; i<m; i++){
			cin >> move[i].first >> move[i].second;
		}

		pair <int, int> pos;
		pos.first = pos.second = 10;
		for(int i=0; i<m; i++){
			char d = move[i].first;
			for(int j=0; j<move[i].second; j++){
				if(d == 'N') pos.first++;
				else if(d == 'E') pos.second++;
				else if(d == 'S') pos.first--;
				else pos.second--;

				for(int k=0; k<v.size(); k++){
					if(pos == v[k]){
						v.erase(v.begin()+k);
						break;
					}
				}
			}
		}

		if(v.size() == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 3092
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e5+5,M=4e5+5,mo=1e9+7;
ll tr[M],a[N],b[N],s[N],n,K,i,j,k,L[N],R[N],v[M],m,f[N],ans;
void change(ll x,ll l,ll r,ll i,ll j,ll v)
{
	if (i>j) return ;
	if (l==i&&j==r)
	{
		tr[x]=v;
		return ;
	}
	if (tr[x]) tr[x*2]=tr[x*2+1]=tr[x],tr[x]=0;
	ll m=(l+r)/2;
	if (m>=j) change(x*2,l,m,i,j,v);
	else if (m<i) change(x*2+1,m+1,r,i,j,v);
	else change(x*2,l,m,i,m,v),change(x*2+1,m+1,r,m+1,j,v);
}
ll get(ll x,ll l,ll r,ll p)
{
	if (l==r) return tr[x];
	if (tr[x]) tr[x*2]=tr[x*2+1]=tr[x],tr[x]=0;
	ll m=(l+r)/2;
	if (m>=p) return get(x*2,l,m,p);else return get(x*2+1,m+1,r,p);
}
ll calc(ll x)
{
	ll y=get(1,1,m,x);
	if (!y) return 0;
	return f[y]+(v[L[y]]-v[x]+K)%K;
}
int main()
{
	scanf("%lld %lld\n",&n,&K);
	fo(i,1,n)
	{
		scanf("%lld %lld",a+i,b+i);
		s[i]=s[i-1]+a[i];
		if (b[i]==1&&2*a[i]>K)
		{
			printf("-1\n");
			return 0;
		}
	}
	fo(i,1,n)
		if (b[i]==1)
		{
			L[i]=((-2*s[i])%K+K)%K;
			R[i]=((-2*s[i-1])%K+K)%K;
			swap(L[i],R[i]);
		}else L[i]=0,R[i]=K-1;
	fo(i,1,n) v[++m]=L[i],v[++m]=R[i];
	sort(v+1,v+m+1);
	m=unique(v+1,v+m+1)-v-1;
	fd(i,n,1)
	{
		L[i]=lower_bound(v+1,v+m+1,L[i])-v;
		R[i]=lower_bound(v+1,v+m+1,R[i])-v;
		f[i]=calc(L[i]);
		if (L[i]>R[i]) 
			change(1,1,m,R[i]+1,L[i]-1,i);
		else change(1,1,m,1,L[i]-1,i),change(1,1,m,R[i]+1,m,i);
	}
	ans=f[1];
	fo(i,1,m) 
		ans=min(ans,calc(i));
	printf("%lld\n",s[n]*2+ans);
}

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

const int maxn = 200005;
int n,temp;
int a[maxn];
int b[maxn];

int main()
{
    int x = 0;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i = n; i >= 1; i--)
    {
        temp = 0;
        for(int j = i; j <= n; j+=i)
            temp += b[j];
        if(temp%2 != a[i])
        {
            b[i] = 1;
            x++;
        }
    }
    printf("%d\n",x);
    if(x)
    {
        for(int i = 1; i <= n; i++)
        {
            if(b[i])
                printf("%d ",i);
        }
    }
    return 0;
}


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


int main(){
    string s,t;
    cin>>s>>t;
    int res=0;
    for(int i=0; i<s.size(); ++i){
        if(s[i]!=t[i]) res++;
    }
    cout<<res;
//    map<char,int> mp1,mp2;
//    for(int i=0; i<s.size(); ++i){
//        if(mp1.find(s[i])!=mp1.end()) mp1[s[i]]++;
//        else mp1.insert({s[i],1});
//        if(mp2.find(t[i])!=mp2.end()) mp2[t[i]]++;
//        else mp2.insert({t[i],1});
//    }
//    map<char,int>::iterator it;
//    int res=0;
//    for(it=mp1.begin(); it!=mp1.end(); ++it){
//        char c = it->first;
//        int co = it->second;
//        if(mp2.find(c)==mp2.end()) res+= co;
//        else{
//            if(mp2[c]<co) res+= co-mp2[c];
//        }
//    }

}


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

int main() {
	int n; cin >> n;
	vector<int>A(n), b(n); for (auto&& x : A)cin >> x;
	for (int i = 0; i < n; i++) {
		b[i] = A[i] - i + 1;
	}
	sort(b.begin(), b.end());
	int bmed = b.size() % 2 == 0 ? (b[b.size() / 2 - 1] + b[b.size() / 2]) / 2 : b[b.size() / 2];
	long long ans = 0; for (auto&& x : b)ans += abs(x - bmed);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n,m,q=map(int,input().split())
x=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
    for j in range(2):
        x[i][j]-=1
a=[]
def dfs(v):
    if len(v)>n:
        return
    if len(v)==n:
        a.append(v)
    for i in range(int(v[-1]),m+1):
        dfs(v+[i])
for i in range(1,m+1):
    dfs([i])
ans=0
for i in a:
    now=0
    for k in range(q):
        if i[x[k][1]]-i[x[k][0]]==x[k][2]:
            now+=x[k][3]
    ans=max(now,ans)
print(ans)

Measured memory_bytes: 22960
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int f=lcm(c,d);
	cout<<(b-a+1)-(b/c-(a-1)/c+b/d-(a-1)/d-(b/f-(a-1)/f))<<endl;
}





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

namespace ConsoleApp11
{
    class Class33
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var L = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (L.Max() < L.Sum() - L.Max())
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }
}


Measured memory_bytes: 13396
import math
def readInt():
    return list(map(int, input().split()))
a,b,h,m = readInt()
# print(a)
arg_h = 30*h + 30*(m/60)
arg_m = 6*m
if abs(arg_h-arg_m) < 180:
    arg = math.radians(abs(arg_h-arg_m))
    ans = (a**2+b**2-2*a*b*math.cos(arg))**(1/2)
elif abs(arg_h-arg_m) == 180:
    ans = a+b
else:
    arg = math.radians(360-abs(arg_h-arg_m)) 
    ans = (a**2+b**2-2*a*b*math.cos(arg))**(1/2)
# print(arg_h, arg_m, arg)
# print(math.cos(arg))

print('{:.20f}'.format(ans))

Measured memory_bytes: 9540
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define bug cout<<"AIkahne aise"<<endl
ll A[5000001];
vector<ll>v;
vector<pair<ll,ll> >v2;
/*void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}*/
int main()
{
  ll a,b,t,cnt=0;
  cin>>a>>b>>t;
  for(int i=1;i<=t;i++)
  {
      if(i%a==0)
        cnt++;
  }
  cout<<cnt*b<<endl;
return 0;
}


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

int main() {
  int n;cin>>n;
  map<string,int> mp;
  int cnt=0;
  rep(i,n){
    string s;cin>>s;
    mp[s]++;
    cnt=max(cnt,mp[s]);
  }
  for(auto x:mp){
    if(cnt==x.second)cout<<x.first<<endl;
  }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
	
	cout << s[0] << (s.size() - 2) << s[s.size() - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

N, A = map(int, input().split())
X = list(map(int, input().split()))

X2 = [0]*N

for i in range(N):
    X2[i] = X[i] - A

C = Counter([0, X2[0]])

for x in X2[1:]:
    C2 = Counter()
    for s, c in C.items():
        C2[s+x] += c
    C += C2

print(C[0]-1)


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

int main(){
  int h,n; cin >> h >> n;
  vector<int> dp(h+1,INF);
  dp[0]=0;
  rep(i,n){
      int a,mp; cin >> a >> mp;
      int tmp;
      //for(int j=a; j<=h; j++){
    rep(j,h){
          dp[min(h,j+a)]=min(dp[min(h,j+a)],dp[j]+mp);
      }
  }
  cout << dp[h] << endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int  tr['T'+1];
char f[33554432];
 
int main()
{
    int n, k, c;
 
    tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
    n = in();
    while (n--) {
        if (gc() == 'i') {
            k = 7; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            f[k] = 1;
        } else {
            k = 5; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            if (f[k]) pc('y'), pc('e'), pc('s');
            else      pc('n'), pc('o');
            pc('\n');
        }
    }
    return 0;
}


Measured memory_bytes: 2992
w = input()

num = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

for i in range(len(w)):
    if w[i] == 'a':
        num[0] += 1

    elif w[i] == 'b':
        num[1] += 1

    elif w[i] == 'c':
        num[2] += 1

    elif w[i] == 'd':
        num[3] += 1

    elif w[i] == 'e':
        num[4] += 1

    elif w[i] == 'f':
        num[5] += 1

    elif w[i] == 'g':
        num[6] += 1

    elif w[i] == 'h':
        num[7] += 1

    elif w[i] == 'i':
        num[8] += 1

    elif w[i] == 'j':
        num[9] += 1

    elif w[i] == 'k':
        num[10] += 1

    elif w[i] == 'l':
        num[11] += 1

    elif w[i] == 'm':
        num[12] += 1

    elif w[i] == 'n':
        num[13] += 1

    elif w[i] == 'o':
        num[14] += 1

    elif w[i] == 'p':
        num[15] += 1

    elif w[i] == 'q':
        num[16] += 1

    elif w[i] == 'r':
        num[17] += 1

    elif w[i] == 's':
        num[18] += 1

    elif w[i] == 't':
        num[19] += 1

    elif w[i] == 'u':
        num[20] += 1

    elif w[i] == 'v':
        num[21] += 1

    elif w[i] == 'w':
        num[22] += 1

    elif w[i] == 'x':
        num[23] += 1

    elif w[i] == 'y':
        num[24] += 1

    elif w[i] == 'z':
        num[25] += 1

ans = "Yes"

for i in range(len(num)):
    if num[i] % 2 == 1:
        ans = "No"
        break

print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

template <class T>
struct RangeSum {
  vector<T> vec;
  RangeSum() {}
  RangeSum(vector<T> elems) : vec(elems) {
    for (int i = 1; i < vec.size(); i++) { vec[i] += vec[i - 1]; }
  }
  T sum(int l, int r) {
    if (l > r) return T(0);
    if (l == 0)
      return vec[r];
    else
      return vec[r] - vec[l - 1];
  }
};

void solve() {
  vector<vector<int>> f = vect(3, vect(3, 0));
  cin >> f;
  for (int i = -200; i <= 200; i++) {
    for (int j = -200; j <= 200; j++) {
      vector<int> a(3), b(3);
      a[0] = i, b[0] = j;
      for (int k = 1; k < 3; k++) {
        a[k] = f[k][0] - f[0][0] + a[0];
        b[k] = f[0][k] - f[0][0] + b[0];
      }
      bool judge = true;
      for (int p = 0; p < 3; p++) {
        for (int q = 0; q < 3; q++) {
          if (a[p] + b[q] != f[p][q]) judge = false;
        }
      }
      if (judge) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


Measured memory_bytes: 256
def s():
 def b(M,x,y,n=1):
  M[x][y]=0;a=n
  if M[x-1][y]:
   t=b(M,x-1,y,n+1)
   if a<t:a=t
  if M[x][y-1]:
   t=b(M,x,y-1,n+1)
   if a<t:a=t
  if M[x+1][y]:
   t=b(M,x+1,y,n+1)
   if a<t:a=t
  if M[x][y+1]:
   t=b(M,x,y+1,n+1)
   if a<t:a=t
  M[x][y]=1
  return a
 for e in iter(input,'0'):
  n,m=int(e),int(input())
  P=[[0]*(n+2)for _ in[0]*(m+2)]
  for i in range(m):P[i+1][1:-1]=map(int,input().split())
  a=0
  for i in range(1,m+1):
   for j in range(1,n+1):
    if P[i][j]:
     t=b(P,i,j)
     if a<t:a=t
  print(a)
if'__main__'==__name__:s()


Measured memory_bytes: 5720
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

i64 A, B, C; cin >> A >> B >> C;
if (A == B && A != C) cout << "Yes\n";
else if (A == C && B != A) cout << "Yes\n";
else if (B == C && A != C) cout << "Yes\n";
else cout << "No\n";


return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if((max(a, b) - min(a, b)) % 2 == 0){
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int N,M;
cin >> N >> M;

 const int nmmax=50;
 char A[nmmax][nmmax],B[nmmax][nmmax];


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

 for(int y=0;y<M;y++){
 for(int x=0;x<M;x++){
 cin >> B[y][x];
 }
 }

 bool exist=false;



 for(int ly=0;ly<N;ly++){
 for(int lx=0;lx<N;lx++){

 if(ly+M-1>=N or lx+M-1>=N) continue;

 bool match=true;
 for(int y=0;y<M;y++){
 for(int x=0;x<M;x++){
 if(A[ly+y][lx+x]!=B[y][x]) match=false;
 }
 }
 if(match) exist=true;
 }
 }

 if(exist)
 cout << "Yes" << endl;
 else
 cout << "No" << endl;
    return 0;
}

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

int counts[100005];

int main()
{
	int N;
	scanf("%d", &N);
	
	long long initialSum = 0;
	for(int i = 0; i < N; i++)
	{
		int Ai;
		scanf("%d", &Ai);
		counts[Ai]++;
		initialSum += Ai;
	}
	
	int Q;
	scanf("%d", &Q);
	
	for(int i = 0; i < Q; i++)
	{
		int Bi, Ci;
		scanf("%d%d", &Bi, &Ci);
		
		initialSum -= (long long)(Bi) * (long long)(counts[Bi]);
		initialSum += (long long)(Ci) * (long long)(counts[Bi]);
		
		counts[Ci] += counts[Bi];
		counts[Bi] = 0;
		
		//initialSum += (long long)(Ci) * (long long)(counts[Ci]);
		
		printf("%lld\n", initialSum);
	}
}

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

using namespace std;

map<string, int> cnt;

int main()
{
	int n, maxv, x, i;
	string s;
	cin>>n;
	maxv = 0;
	for (i=0; i<n; i++)
	{
		cin>>s;
		if (cnt.count(s) == 0) cnt[s] = 1; else cnt[s] ++;
		maxv = max(maxv, cnt[s]);
	}
	for (map<string, int>::iterator itr=cnt.begin(); itr!=cnt.end(); itr++)
		if (itr->second == maxv) cout<<itr->first<<endl;
	return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;

int main() {
    long long H,N,A;
    cin >> H >> N;
    for (auto i = 0; i < N && H > 0; ++i) {
        cin >> A;
        H -= A;
    }
    if (H <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 300010;
int K,N;
int ans[MC];

int main(){
	cin >> K >> N;
	if(K%2==0){
		cout << K/2;
		repp(i,1,N) cout << ' ' << K;
		cout << endl;
	} else {
		fill(ans,ans+N,(K+1)/2);
		int z = N-1;
		repp(i,0,N/2){
			if(ans[z] > 0){
				--ans[z];
			} else {
				--ans[z-1];
				ans[z] = K;
				if(ans[z-1]==0) --z;
				else z = N-1;
			}
		}
		repp(i,0,N){
			cout << ans[i] << (ans[i+1]==0?'\n':' ');
			if(ans[i+1]==0) break;
		}
	}
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int A, B;

int main(){
	cin >> A >> B;
	if (A % 2 != B % 2){
		cout << "IMPOSSIBLE" << endl;
	}
	else{
		cout << (A + B) / 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
typedef long long ll;

ll parent[100005];
ll diff_weight[100005];    

void init(ll nmemb);
ll root(ll x);
ll weight(ll x);
ll diff(ll x, ll y);
bool isSameGroup(ll x, ll y);
void unite(ll x, ll y, ll w);
ll groubSize(ll x);

void init(ll nmemb) {
    for (ll i = 0; i < nmemb; i++) {
        parent[i] = -1;
        diff_weight[i] = 0;
    }
}

ll root(ll x) {
    if (parent[x] < 0) {
        return x;
    }
    
    // 累積和的に重みを再計算
    ll r = root(parent[x]);
    diff_weight[x] += diff_weight[parent[x]];
    parent[x] = r;

    return parent[x];
}

ll weight(ll x) {
    root(x);
    return diff_weight[x];
}

ll diff(ll x, ll y) {
    return weight(y) - weight(x);
}
    
bool isSameGroup(ll x, ll y) {
    return root(x) == root(y);
}

    /**
     * x->yの重みをwとして併合.
     * 即ち, weight(y) = weight(x) + w が成り立つ
     * x, yが既に同じグループのときは何もしない
     */
void unite(ll x, ll y, ll w) {
    if (isSameGroup(x, y)) {
        return;
    }

    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    
    parent[y] = x;
    diff_weight[y] = w;
}

ll groubSize(ll x) {
    return -parent[root(x)];
}

ll n;
ll u, v, w;

int main()
{
    scanf("%lld", &n);
    init(n);

    for (int i = 0; i < n - 1; i++) {
        scanf("%lld %lld %lld", &u, &v, &w);

        unite(u, v, w);
    }

    printf("0\n");
    for (int i = 2; i <= n; i++) {
        if (diff(1, i) & 1) {
            printf("1\n");
        }
        else {
            printf("0\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;

	string befS;
	cin >> befS;
	map<string , bool > mp{};
	mp[befS] = 1;

	rep(i,1,n){
		string nowS;
		cin >> nowS;

		if( mp[nowS] || befS[befS.size()-1] != nowS[0] ){ No; ret 0;}

		befS = nowS;
		mp[nowS] = 1;
	}

	Yes;
	
	ret 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

vector<ll> calc_devisors(ll a){
    vector<ll> ret;
    for(int i=1; i*i<=a; i++){
        if(a%i!=0) continue;
        ret.push_back(i);
        ll another = a/i;
        if(i!=another) ret.push_back(another);
    }
    return ret;
}

const int N_MAX = 200010;
ll C[N_MAX];

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N+1);
    FOR(i, 1, N+1){
        cin >> A.at(i);
    }

    vector<ll> Ans(N+1);

    for(int i=N; i>=1; i--){
        // 今まで何個入っているか
        ll c = C[i];

        ll a = A[i];
        if((a==1 && c==0) || (a==0 && c==1)){
            Ans[i]=1;
            // いれる
            auto V = calc_devisors(i);
            for(ll v : V){
                C[v]++;
                C[v] %= 2;
            }

        }else{
            // いれない
        }

    }

    ll count=0;
    FOR(i, 1, N+1){
        ll a = Ans[i];
        if(a==1) count++;
    }
    p(count);
    FOR(i, 1, N+1){
        if(Ans[i]==1){
            p(i);
        }
    }
    
    return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int a,b,c,p,m;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	p=b-a;
	m=c-b;
	if(p==m)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

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; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////


int main()
{
  int n,q;
  scanf("%d %d", &n, &q);

  dsu d(n);
  vector<int> ans;
  for (int i=0; i<q; i++){
    int t,u,v; scanf("%d %d %d", &t, &u, &v);
    if (t==0) d.merge(u, v);
    else ans.push_back(d.same(u, v));
  }
  for (auto v:ans) cout << v << endl;

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    set<long long int> A;
    for(int i = 0; i < N; i++) {
        long long int a;
        cin >> a;
        A.insert(a);
    }
    string messages = "NO";
    if(A.size() == N) {
        messages = "YES";
    }
    cout << messages << endl;
    return 0;
}

Measured memory_bytes: 11648
#input
#N = list(map(int,input().split()))
#H = list(map(int,input().split()))
S = str(input())
ans = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "1":
            ans += 1
    else:
        if S[i] == "0":
            ans+= 1
print(min(ans,len(S)-ans))

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> sunuke(N, false);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      sunuke.at(A-1) = true;
    }
  }
  int ans = 0;
  for (bool count : sunuke) {
    if (!(count)) ans++;
  }
  cout << ans << endl;
}

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

int main(){
	int h,w;
	cin>>h>>w;
	vector<string> s(h);
	for(int i=0;i<h;i++)cin>>s[i];
	
	int x[9]={-1,0,1,-1,0,1,-1,0,1};
	int y[9]={-1,-1,-1,0,0,0,1,1,1};
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				cout<<"#";
			}else{
				int ans=0;
				for(int k=0;k<9;k++){
					if((i+y[k]>=0&&j+x[k]>=0)&&(i+y[k]<h&&j+x[k]<w)&&s[i+y[k]][j+x[k]]=='#')ans++;
				}
				cout<<ans;
			}
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    s = input()
    print(s.rfind("Z") - s.find("A") + 1)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const ll INF=1e18;
const int MAX_V=114514;

struct edge{
	int to;
	ll cost;
};

int V;
vector<edge> g[MAX_V];
// 頂点sからの最短距離
ll d[MAX_V];

void add_edge(int u, int v, ll cost){
	g[u].push_back({v, cost});
	g[v].push_back({u, cost});
	return;
}

void dijkstra(int s){
	// piiのfirstは最短距離、secondは頂点の番号
	priority_queue<pll, vector<pll>, greater<pll>> que;
	fill(d, d+V, INF);
	d[s]=0;
	que.push(pii(0, s));
	while(!que.empty()){
		pll p=que.top();
		que.pop();
		ll v=p.second;
		if(d[v]<p.first){
			continue;
		}
		REP(i, g[v].size()){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b, c, q, k, x, y;
	cin>>n;
	V=n;
	REP(i, n-1){
		cin>>a>>b>>c;
		--a;
		--b;
		add_edge(a, b, c);
	}
	cin>>q>>k;
	--k;
	dijkstra(k);
	REP(i, q){
		cin>>x>>y;
		--x;
		--y;
		cout<<d[x]+d[y]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 11504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int a,b;
  cin >> a >> b;
  
  for(int i=1;i<=1000;i++){
    int x=i,y=i;
    x *= 8;
    y *= 10;
    x /= 100;
    y /= 100;
    if(x==a&&y==b) {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for(int i = 0; i < n; ++i) {
		map<char, pair<int, int>> a;
		for(int j = 0; j < i; ++j) {
			a[s[j]].first = 1;
		}
		for(int j = i; j < n; ++j) {
			a[s[j]].second = 1;
		}
		int cou = 0;
		for(auto i : a) {
			if(i.second.first + i.second.second == 2)
				++cou;
		}
		ans = max(ans, cou);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3656
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

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

using namespace std;

int main() {
	ll w, h, n; cin >> w >> h >> n;
	vector<vector<ll>> v(h, vector<ll>(w,1));
	rep(_, n) {
		ll x, y, a; cin >> x >> y >> a;
		ll i_min = 0;
		ll i_max = h;
		ll j_min = 0;
		ll j_max = w;
		switch (a)
		{
		case 1: j_max = x;
			break;
		case 2: j_min = x;
			break;
		case 3: i_max = y;
			break;
		case 4: i_min = y;
			break;
		default:
			break;
		}
		for (ll i = i_min; i < i_max; i++)
			for (ll j = j_min; j < j_max; j++)
				v[i][j] = 0;
	}
	ll ans = 0;
	rep(i, h)
		rep(j, w)
		ans += v[i][j];
	cout << ans << endl;
}

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

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

	int a, b, c;
	cin >> a >> b >> c;

	if( a > b ) {
		if( a > c ) {
			cout << (b+c == a ? "Yes" : "No");
		}
		else {
			cout << (a+b == c ? "Yes" : "No");
		}
	}
	else {
		if( b > c ) {
			cout << (a+c == b ? "Yes" : "No");
		}
		else {
			cout << (a+b == c ? "Yes" : "No");
		}
	}

	cout << endl;
}


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

using namespace std;
const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 5e18+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef   long long ll;
typedef   unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);


int N;
int v[100005][3];
int mem[100005][3];


int dp(int pos,int last){
    if(pos==N) return 0;
    int ans = 0;
    if(last != -1 && mem[pos][last] != -1) return mem[pos][last];
    lp(i,0,3)if(i!=last){
        ans = max(ans,v[pos][i]+dp(pos+1,i));
    }
    return mem[pos][max(0,last)] = ans;
}





int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
//#ifndef ONLINE_JUDGE
//   freopen( "output.txt" , "w" , stdout ) ;
//   freopen( "input.txt" , "r" , stdin ) ;
//#endif

    cin >> N ;
    lp(i,0,N)lp(j,0,3) cin >> v[i][j];
    memset(mem,-1,sizeof mem);
    cout << dp(0,-1);


    return 0;
}


Measured memory_bytes: 15320
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n, m = LI()
    print((n-1)*(m-1))
    return

#B
def B():
    s = S()
    print(s[0]+str(len(s)-2)+s[-1])
    return

#C
def C():
    II()
    a = LI()
    a1 = 0
    a2 = 0
    a3 = 0
    for ai in a:
        if not ai % 4:
            a3 += 1
            continue
        if not ai % 2:
            a2 += 1
            continue
        a1 += 1
    if a2:
        print(["No", "Yes"][a3 >= a1])
        return
    print(["No", "Yes"][a3 >= a1 - 1])
    return
"""
    n, m = LI()
    x = -1
    y = -1
    z = -1
    for i in range(n + 1):
        a = m - 9000 * i - 1000 * n
        if a % 4000 == 0 and a >= 0 and n - i - a / 4000 >= 0:
            y = a / 4000
            z = n - i - y
            x = i
            break
    print(int(x),int(y),int(z))
"""

#D
def D():
    move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    h, w = LI()
    II()
    a = LI()
    ans = [[None] * w for i in range(h)]
    x = 0
    y = 0
    diarect = 0
    for num, ai in enumerate(a, start=1):
        for _ in range(ai):
            ans[y][x] = num
            x += move[diarect][0]
            y += move[diarect][1]
            if 0 <= x < w and 0 <= y < h:
                if ans[y][x]:
                    x -= move[diarect][0]
                    y -= move[diarect][1]
                    diarect += 1
                    diarect %= 4
                    x += move[diarect][0]
                    y += move[diarect][1]
                continue
            x -= move[diarect][0]
            y -= move[diarect][1]
            diarect += 1
            diarect %= 4
            x += move[diarect][0]
            y += move[diarect][1]
            
    for a in ans:
        print(" ".join(map(str, a)))
    return

#Solve
if __name__ == '__main__':
    A()


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

def solve():
    N = int(input())
    S = input()

    """
    3桁の数字がijkだとして、それを作れるかを全探索で数えていく
    平均計算量は、(3750*10)*(7500*10)*(15000*10) = O(10**4 * 10**4 * 10**5) = O(10**13)
    """

    ans = 0
    for i in range(0, 10):
        idx = S.find(str(i))  # 平均計算量15000
        if idx == -1:
            continue
        for j in range(0, 10):
            jdx = S[idx+1:].find(str(j))  # 平均計算量7500
            if jdx == -1:
                continue
            for k in range(0, 10):
                if str(k) in S[idx+1+jdx+1:]:  # 平均計算量3750
                    ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
using namespace std;

typedef long long ll;


#define  kak 1000000000000;





int main(){
        int Q;
        cin >> Q;
        priority_queue<int, vector<int>,  greater<>> que2;
        priority_queue<int, vector<int>> que;
        long sum = 0;
        long sum2 = 0;
        long sumb = 0;
        int count = 0;
        for(int i = 0; i < Q; i++){
            int q;
            cin >> q;
            if(q == 1){
                ll a;
                ll b;

                cin >> a;
                cin >> b;
                sumb += b;

                count++;

                if(count <= 2) {
                    que.push(a);
                    sum += a;
                }
                else{
                    ll temp = que.top();
                    ll t2 = que2.top();
                    if(t2 < a) {
                        que2.push(a);
                        sum2 += a;
                    }else{
                        que.push(a);
                        sum += a;
                    }
                }
                if(que.size() > (count+1)/2){
                    ll top = que.top();
                    que.pop();
                    que2.push(top);
                    sum -= top;
                    sum2 += top;
                }
                if(que2.size() > count/2){
                    ll top = que2.top();
                    que2.pop();
                    que.push(top);
                    sum2 -= top;
                    sum += top;
                }

            }else{
                ll m = que.top();
                ll ans = 0;
                ans = -(sum-que.size()*m)+(sum2-que2.size()*m)+sumb;
                cout << m << ' ' << ans << endl;
            }
        }

        return 0;
}




Measured memory_bytes: 3452