akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}//gcd
int main(){
    Int n,x;cin >> n >> x;
    vector<Int> sa(n);
    for(Int i=0;i<n;i++){
        Int data;cin >> data;
        sa[i] = abs(x-data);
    }
    Int ans = sa[0];
    rep(i,n-1){
        ans = gcd(ans,sa[i+1]);
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 1024
import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))
A=np.append(A,0)
A=np.insert(A,0,0)
S=sum(abs(np.diff(A[:])))

for i in range(1,len(A)-1):
  if A[i-1]==A[i]:
    print(S)
  elif (A[i-1]<A[i] and A[i]<A[i+1]) or (A[i-1]>A[i] and A[i]>A[i+1]):
    print(S)
  else:
    print(S-min(abs(A[i-1]-A[i]),abs(A[i]-A[i+1]))*2)
    

Measured memory_bytes: 38540
n = int(input())
x = [int(x) for x in input().split()]
nums = []

for i in range(n):
    nums.append([x[i], i])

nums.sort()

for i in range(n):
    nums[i].append(i)
right = nums[n // 2][0]
left = nums[n // 2 - 1][0]
nums.sort(key=lambda x: x[1])

for i in range(n):
    if nums[i][2] < n // 2:
        print(right)
    else:
        print(left)

Measured memory_bytes: 56260
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(ll N, ll K){
    COMinit();
    rep1(i,K){
        ll ans = COM(N-K+1,i) * COM(K-1,K-i);
        ans %= MOD;
        print(ans);
    }
}

int main(){
    ll N,K; cin >> N >> K;
    solve(N,K);
    return 0;
}

Measured memory_bytes: 12288
#include<iostream>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;

int main()
{
    int N,M,C;
    cin >> N >> M >> C;
    int B[M];
    rep(i,M) cin >> B[i];

    int A, sum=0, cnt=0;
    rep(n,N){
        rep(i,M){
           cin >> A;
           sum += A*B[i];
        }
        sum += C;
        if(sum>0){
            cnt++;
        }
        sum = 0;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a[1000];
    int i,sum;
    while(1)
    {
        scanf("%s",&a);
        if(a[0]=='0')
        {
            return 0;
        }
        sum = 0;
        for(i=0;a[i]!='\0';i++)
        {
            sum+=a[i]-'0';
        }
        printf("%d\n",sum);
}
return 0;
    }



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
    int n;
    cin >> n;
    string s[2];
    for(int i=0;i<2;i++){
        cin >> s[i];
    }
    int pre=-1,now=-1;//yoko 1,tate 2
    ll ans = 3;
    for(int i=0;i<n;i++){
        if(s[0][i]!=s[1][i]){
            i++;
            now = 1;
        }else{
            now = 2;
        }
        if(pre == 1 && now == 1){
            ans *= 3;
            ans %= 1000000007;
        }
        if((pre == 2 && now == 2)||(pre == 2 && now == 1)){
            ans *= 2;
            ans %= 1000000007;
        }
        if(pre == -1&&now == 1){
            ans *= 2;
            ans %= 1000000007;
        }
        pre = now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, node:int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        
    def find(self, x:int) -> int:
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x:int, y:int) -> bool:
        if self.isSame(x,y):
            #print("x and y has already united")
            return False
        
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = self.par[ry]
        else:
            self.par[ry] = self.par[rx]
            
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
                
        return True
                
    def isSame(self, x:int, y:int) -> bool:
        return self.find(x) == self.find(y)
    
from collections import defaultdict
import sys
sdin = sys.stdin.readline    

# 入力
n, k, l = map(int, sdin().split())

pq = []
for i in range(k):
    p, q = map(int, sdin().split())
    pq.append(tuple([p-1, q-1]))

rs = []
for i in range(l):
    r, s = map(int, sdin().split())
    rs.append(tuple([r-1, s-1]))

# 道路、鉄道についてそれぞれunion find
path = UnionFind(n)
for p, q in pq:
    path.unite(p, q)

rail = UnionFind(n)
for r, s in rs:
    rail.unite(r, s)

# (path.root, rail.root)の辞書作る
path_rail = defaultdict(int)
    
for i in range(n):
    path_rail[(path.find(i), rail.find(i))] += 1

# 表示する
ans = [path_rail[(path.find(i), rail.find(i))] for i in range(n)]
print(*ans)


Measured memory_bytes: 80460
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main(void){
	int n, m;
	cin >> n >> m;
	cout << n*n - m << endl;

	return 0;
}

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

int main(){
    int x, h, m, s;
	cin >> x;
    h = x/3600;
    m = (x-h*3600)/60;
    s = (x-h*3600)-(m*60);
	cout << h << ":"<< m << ":" << s << endl;
}


Measured memory_bytes: 3116
#!/usr/bin/env python3
n=int(input())
cnt=0
a_list=list(map(int,input().split()))
for i in range(n):
    while True:
        if a_list[i]%2==0:
            cnt+=1
            a_list[i]=a_list[i]/2
        else:
            break
    cnt=max(cnt,0)
print(cnt)

Measured memory_bytes: 10160
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define ri register int
#define rb register bool
#define rc register char
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)

const int N=5e5+10,inf=1e9;
int len,pre[N];
struct node{int to[26];node(){memset(to,0,sizeof(to));}}nod[N];
bool vis[N];
char str[N];
vector<int>V[26];

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}
void print(ri x){if(!x)return;print(pre[x]);printf("%c",str[x]);}
il int upp(ri x,ri y)
{
	ri l=0,r=V[x].size()-1;
	while(l<r){ri mid=(l+r)>>1;if(V[x][mid]>y)r=mid;else l=mid+1;}
	return l;
}

int main()
{
	//freopen("B.in","r",stdin);freopen("B.out","w",stdout);
	scanf("%s",str+1);len=strlen(str+1);
	rp(i,1,len)V[str[i]-'a'].push_back(i);rp(i,0,25)V[i].push_back(inf);
	rp(i,1,len)
	{
		rp(j,0,25){ri to=upp(j,i);if(V[j][to]!=inf)nod[i].to[j]=V[j][to];}
	}
	rp(i,0,25)if(V[i][0]!=inf)nod[0].to[i]=V[i][0];
	//QwQ
	//rp(i,1,len)rp(j,0,25)printf("nod[%d].to[%d]=%d\n",i,j,nod[i].to[j]);
	//QwQ
	queue<int>Q;
	rp(i,0,25)if(nod[0].to[i])Q.push(nod[0].to[i]),vis[nod[0].to[i]]=1;else return printf("%c",(char)('a'+i)),0;
	while(!Q.empty())
	{
		ri nw=Q.front();Q.pop();
		rp(i,0,25)
		{ri t=nod[nw].to[i];if(t){if(!vis[t])vis[t]=1,pre[t]=nw,Q.push(t);}else return print(nw),printf("%c",(char)('a'+i)),0;}
	}
	return 0;
}


Measured memory_bytes: 54016
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

class unko10 {
public:
	char C[1275725], C9[211470];
	constexpr unko10() : C(), C9() {
		char c[11] = {};
		int d = 0;
		int k[11] = {};
		int saidai[11] = {};
		int ma = 10;

		auto ci = C;
		while (d >= 0) {
			c[d] = k[d]++ + 'a';
			saidai[d + 1] = max(saidai[d], k[d]);
			d++;
			if (d == ma) {
				rep(i, ma)* ci++ = c[i];
				*ci++ = '\n';
				d--;
			}

			while (d >= 0 && (c[d] - 'a') == saidai[d]) {
				k[d] = 0;
				c[d] = 'z';
				d--;

			}
		}
		d = 0;
		ma = 9;
		ci = C9;
		while (d >= 0) {
			c[d] = k[d]++ + 'a';
			saidai[d + 1] = max(saidai[d], k[d]);
			d++;
			if (d == ma) {
				rep(i, ma)* ci++ = c[i];
				*ci++ = '\n';
				d--;
			}

			while (d >= 0 && (c[d] - 'a') == saidai[d]) {
				k[d] = 0;
				c[d] = 'z';
				d--;
			}
		}
	}
} f;


char dn[37260], *di = dn;
int N, k;
char c[10];
void keisan(int n, int saidai) {
	if (n == N) {
		rep(i, N) *di++ = c[i];
		*di++ = '\n';
	}
	else {
		rep1(i, saidai + 1) {
			c[k++] = 'a' + i - 1;
			keisan(n + 1, max(saidai, i));
			k--;
		}
	}
}

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


	scanf("%d", &N);

	if (N < 9) {
		keisan(0, 0);
		fwrite(dn, 1, di - dn, stdout);
	}
	else if (N == 9){
		fwrite(f.C9, 1, 211470, stdout);
	}
	else {
		fwrite(f.C, 1275725, 1, stdout);
	}

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra()
{
    int minv;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;

    while (1)
    {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++)
        {
            if (minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
            break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INFTY)
            {
                if (d[v] > d[u] + M[u][v])
                {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j] = INFTY;
        }
    }

    int k, c, u, v;
    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 3112
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
min_y = min(y)
s1 = set([i for i in range(X + 1, Y + 1)])
s2 = set([i for i in range(max_x + 1, min_y + 1)])
if s1 & s2:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3064
/*************************
author : coldbeer
2019-06-07 8:35:02 PM
*************************/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

const int inf = 1e9 + 5;
int n, k;
vector<int> h;
vector<int> cache;

int solve(int i)
{
    if (i == n)
        return 0;
    if (i > n)
        return inf;
    if(cache[i] != -1)
        return cache[i];
    int a = inf;
    for (int l = 1; l <= k; l++)
        if (i + l <= n)
            a = min(a, abs(h[i] - h[i + l]) + solve(i + l));
    cache[i] = a;
    return cache[i];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    h.assign(n + 1, 0);
    for (int i = 1; i < n + 1; i++)
        cin >> h[i];
    cache.assign(n + 1,-1);
    cout << solve(1) << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

bool has_key_using_find(map<ll, ll> &m, ll n){
    if (m.find(n) == m.end()){
        
        return false;
    }
    else{
        
        return true;
    }
}

int main()
{
    ll n,k;
    cin >> n >> k;
    
    ll mi=n;
    ll b,c;
    if(n>k){
        b=n;
        c=k;
    }
    else{ 
        b=k;
        c=n;
    }
    ll d = b-c;
    
    if(n < k){
        cout << (n<d ? n:d);
        return 0;
    }
    else if(n==k){ 
        cout << 0;
        return 0;
    }
    
    ll a = d % k;
    
    cout << (a < abs(k-a) ? a : abs(k-a));
    


    
    return 0;
}

Measured memory_bytes: 256
import math
import sys

a,b,h,m = map(int,input().split())

if b>a:
    a,b = b,a

longd = 30*h + m/2
shortd = 360*m/60
# print(longd,shortd)
if abs(longd-shortd) > 180:
    dist = 360-abs(longd-shortd)
elif longd-shortd==0:
    print(abs(a-b))
    sys.exit()
elif abs(longd-shortd) == 180:
    print(abs(a+b))
    sys.exit()
else:
    dist = abs(longd-shortd)

if dist < 90:
    print(math.sqrt((b*math.sin(math.radians(dist)))**2 + (a -b*math.cos(math.radians(dist)))**2))
elif dist == 90:
    print(math.sqrt(b**2 + a**2))
else:
    # print(dist,a,b)
    dist = 180 - dist
    print(math.sqrt((b*math.sin(math.radians(dist)))**2 + (a +b*math.cos(math.radians(dist)))**2))



Measured memory_bytes: 9504
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: i64 = input();
    let b: i64 = input();
    let mut v: Vec<i64> = (0..n).map(|_| input()).collect();
    v.sort_by_key(|v| -v);

    let mut i = 0;
    let mut u = vec![];
    while i < n {
        let cur = v[i];
        let mut cnt = 0;
        while i < n && v[i] == cur {
            cnt += 1;
            i += 1;
        }
        u.push((cur, cnt));
    }

    let mut sum = 0;
    let mut cnt = 0;
    let mut i = 0;
    while i < n && cnt < a {
        let (w, c) = u[i];
        if cnt + c < a {
            cnt += c;
            sum += w * c;
        } else {
            cnt = a - cnt;
            sum += w * cnt;
            break;
        }
        i += 1;
    }

    let avg = sum as f64 / a as f64;

    let mut comb = vec![vec![0i64; 51]; 51];
    for i in 0..51 {
        for j in 0..i + 1 {
            if j == 0 || j == i {
                comb[i][j] = 1;
            } else {
                comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
            }
        }
    }

    let mut p = 0;
    if i == 0 {
        for k in a..b + 1 {
            if k <= u[i].1 {
                p += comb[u[i].1 as usize][k as usize];
            }
        }
    } else {
        p += comb[u[i].1 as usize][cnt as usize];
    }

    println!("{}\n{}", avg, p);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int n;
  ll x;
  cin>>n;
  vector<ll> V;
  unordered_map<ll,ll> um;
  for(int i=0;i<n;i++)
  {
    cin>>x;
    V.pb(x);
    ll val=i+x;
    um[val]++;
  }
  ll cnt=0;
  for(ll i=0;i<n;i++)
  {
    ll val=i-V[i];
    cnt=cnt+um[val];
  }
  cout<<cnt<<endl;
}

int main()
{
  fastio
  solve();
}


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7  ;

int solve(int x , int y )
{
    if(x==y)
        return x ;
    if(x>y)
        swap(x,y);
    if(y>x){
        int k = y / x ;
        if(y%x==0)
            k -- ;
        return 2*k*x +solve (x,y-k*x) ;
    }

}

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int n , x ;
   cin >> n >> x;
   cout << n + solve(x,n-x);

}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
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;}
ll cnt(ll n,int c,int d){
ll ans=n;
ans-=n/c;
ans-=n/d;
ans+=n/lcm(c,d);
return ans;
}
int main(){
ll a,b;
int c,d;
cin>>a>>b>>c>>d;
cout<<cnt(b,c,d)-cnt(a-1,c,d)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
	long long int n,t,i,a,total=0,b=0;
	scanf("%lld%lld",&n,&t);

	for(i=0;i<n;i++){
		scanf("%lld",&a);
		a-b<t ? (total+=a-b):(total+=t);
		b=a;
	}
	printf("%lld\n",total+t);
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
import math


def solve(*args: str) -> str:
    n = int(args[0])

    ret = n-1
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            ret = min(ret, (int(n/i)-1) + (i-1))
    return str(ret)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(1)]))


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

int main(){
	ll n, m; scanf("%lld%lld", &n, &m);
	if (n > m) swap(n, m);
	if (n == 1) return 0 * printf("%lld\n", m == 1 ? 1 : (m - 2));
	ll ans = (n - 2) * (m - 2);
	printf("%lld\n", ans);
	return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    ll mn = INF;
    ll a, b;
    ll sum = 0;
    REP(i, n) {
        cin >> a >> b;
        sum += a;
        if (a <= b) continue;
        chmin(mn, b);
    }
    if (mn == INF) cout << 0 << EOL;
    else cout << sum - mn << EOL;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			int[] wk = new int[3];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			Arrays.sort(wk);
			int res = Math.abs(wk[0] - wk[1]) + Math.abs(wk[1] - wk[2]);

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		String s;
		String t;

		try {
			scanner = new Scanner(System.in);
			s = scanner.next();
			t = scanner.next();

			s = s + s;

			System.out.println(s.contains(t) ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22996
n = int(input())
arr = sorted(list(map(int,input().split())))
ans = 0
ok1 = False
ok2 = False
for i in arr:
    if i > 0:
        ok1 = True
    else:
        ok2 = True
if ok1 and ok2:
    for i in arr:
        ans += i if i > 0 else -i
    print(ans)
    ope1 = arr.pop()
    ope2 = arr.pop(0)
    for a in arr:
        if a > 0:
            print(ope2,a)
            ope2 -= a
        else:
            print(ope1,a)
            ope1 -= a
    print(ope1,ope2)
else:
    if ok1:
        ans = sum(arr) - 2*arr[0]
        print(ans)
        ope1 = arr.pop(0)
        for i in range(n-2):
            print(ope1,arr[i])
            ope1 -= arr[i]
        print(arr[-1],ope1)
    else:
        ans = -sum(arr) + 2*arr[-1]
        print(ans)
        ope2 = arr.pop(-1)
        for i in range(n-1):
            print(ope2,arr[i])
            ope2 -= arr[i]


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

int main() {
  char s[101], p[101], cmp[101];
  scanf("%s %s", s, p);
  for (int i = 0; s[i] != '\0';i++){
    int cmpi = 0;
    for (int j = i; cmpi < strlen(p);j++){
      if(s[j]=='\0'){
        j=0;
      }
      cmp[cmpi++] = s[j];
    }
    cmp[cmpi] = '\0';
    //printf("%s\n", cmp);
    if(strcmp(p,cmp)==0){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	if (n == 1) {
		if (a[0] == k) {
			cout << "POSSIBLE" << endl;
		}
		else {
			cout << "IMPOSSIBLE" << endl;
		}
		return 0;
	}

	int now = a[0];
	for (int i = 1; i < n; i++) {
		now = gcd(now, a[i]);
	}

	if (k % now == 0 && k <= *max_element(a, a + n)) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


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

public class  Main{
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[]a=new int[n+1];
        int[]b=new int[m+1];
        for(int i=1;i<=n;i++)a[i]=sc.nextInt();
        for(int i=1;i<=m;i++)b[i]=sc.nextInt();
        long[][]dp=new long[n+1][m+1];
        long MOD=(long)1e9+7;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
                dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] + MOD) % MOD;
                if (a[i] == b[j]) {
                    dp[i][j] = (dp[i][j] + 1 + dp[i - 1][j - 1]) % MOD;
                }
            }
        }
        pw.println((1+dp[n][m])%MOD);
        pw.flush();
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 79572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  int n;
  cin>>n;
  vi p(n),q(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  vi v;
  rep(i,n) v.eb(i+1);
  ll a,b,cnt=0;
  do {
    cnt++;
    if(p==v) a=cnt;
    if(q==v) b=cnt;
  } while(next_permutation(all(v)));
  out(abs(a-b));
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

int T[2019],ans;

int main(){
  string s;cin>>s;
  int n=s.size();
  T[0]++;
  for(int i=s.size()-1,keta=1,pre=0;~i;i--){
    ans+=T[(pre+=(s[i]-'0')*keta)%=2019]++;
    (keta*=10)%=2019;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a && c <= b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

for = flip map

main :: IO ()
main = do
  (n,m) <- listToTuple2 . map read . words <$> getLine :: IO (Int,Int)
  es <- replicateM m $ listToTuple3 . map readIntBS . BS.words <$> BS.getLine :: IO [(Int,Int,Int)]

  check <- newArray (1,n) False :: IO (IOUArray Int Bool)
  dist <- newArray (1,n) 0 :: IO (IOUArray Int Int)
  
  let graph = buildWeightedDirectedGraph (1,n) es

  a <- (forM [1..n] $ \i -> dfs graph i check dist)

  putStrLn $ if and a then "Yes" else "No"

  where
    dfs :: Array Node [(Node,Cost)] -> Int -> IOUArray Int Bool -> IOUArray Int Int -> IO Bool
    dfs graph cur check dist = do
      writeArray check cur True
      res <- forM (graph!cur) $ \(next,d) -> do
        isChecked <- readArray check next
        if (not isChecked) then do
          readArray dist cur >>= \x -> writeArray dist next (x+d)
          dfs graph next check dist
          else do
          readArray dist cur >>= \x -> readArray dist next >>= \y -> return $ y == x+d
      return $ if null res then True else and res
  


type Node = Int
type Cost = Int

buildWeightedDirectedGraph :: (Node,Node) -> [(Node,Node,Cost)] -> Array Node [(Node,Cost)]
buildWeightedDirectedGraph bound dat = runST $ do
  graph <- newArray bound [] :: ST s (STArray s Node [(Node,Cost)])
  forM_ dat $ \(s,e,c) -> do
    modifyArray graph s ((e,c):)
    modifyArray graph e ((s,-c):)
  freeze graph


Measured memory_bytes: 208252
#include <bits/stdc++.h>
using namespace std;
//Kodid in Dongo Ĝifun 4
//IP aĝres: 192.168.12.233

long long n,a,b,c,d;

long long what(int p,int q){
	int z1=p/q,z2=p%q;
	return z1*(q+1)+z2;
}

string qry(long long p,long long q,long long R,long long S){
	long long g=(p+q)/(min(p,q)+1);
	long long l=0,r=q+1,res=0,resid;
	while(r-l>1){
		int m=(l+r)>>1;
		long long f1=m*(g+1),f2=what(q-m,g);
		f2=p+q+1-f2;
		if(f1<f2){
			if(res<m){
				res=m;
				resid=f2;
			}
			l=m;
		}else{
			r=m;
		}
	}
	string s="";
	for(long long i=R;i<=S;i++){
		if(i<=res*(g+1)){
			if(i%(g+1)){
				s+='A';
			}else{
				s+='B';
			}
		}else{
			if(i<resid){
				s+='A';
			}else if((p+q+1-i)%(g+1)){
				s+='B';
			}else{
				s+='A';
			}
		}
	}
	return s;
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		bool rev=0;
		if(a<b){
			swap(a,b);
			c=a+b+1-c;
			d=a+b+1-d;
			swap(c,d);
			rev=1;
		}
		string s=qry(a,b,c,d);
		if(rev){
			reverse(s.begin(),s.end());
			for(int i=0;i<s.size();i++){
				s[i]^=3;
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
signed main(){
	string n;
	while(true){
		cin>>n;
		if(n=="0")break;
		int ans=0;
		for(int i=0;i<n.size();i++){
			ans+=n[i]-'0';
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3172
/// IN THE NAME OF GUITAR
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
 
ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
 
const ll MAXN = 5e3 + 10;
const ll MAXM = 210;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
stack<ll> st;
ll dp[MAXN][MAXN], B[MAXN][MAXM], L[MAXN][MAXM], R[MAXN][MAXM], A[MAXN], n, m;

int main() {
    scanf("%lld%lld", &n, &m);
    for (ll i = 2; i <= n; i++) {
        scanf("%lld", &A[i]);
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            scanf("%lld", &B[i][j]);
        }
    }
    partial_sum(A, A + MAXN, A);
    for (ll j = 1; j <= m; j++) {
        while (sz(st)) st.pop();
        st.push(0);
        B[0][j] = INF;
        for (ll i = 1; i <= n; i++) {
            while (sz(st) && B[i][j] > B[st.top()][j]) st.pop();
            L[i][j] = st.top() + 1;
            st.push(i);
        }
    }
    for (ll j = 1; j <= m; j++) {
        while (sz(st)) st.pop();
        st.push(n + 1);
        B[n + 1][j] = INF;
        for (ll i = n; i; i--) {
            while (sz(st) && B[i][j] > B[st.top()][j]) st.pop();
            R[i][j] = st.top() - 1;
            st.push(i);
        }
    }
    for (ll j = 1; j <= m; j++) {
        for (ll i = 1; i <= n; i++) {
            //~ cout << j << ' ' << i << ' ' << L[i][j] << ' ' << R[i][j] << endl;
            dp[L[i][j]][i] += B[i][j], dp[i + 1][R[i][j] + 1] += B[i][j];
            dp[i + 1][i] -= B[i][j], dp[L[i][j]][R[i][j] + 1] -= B[i][j];
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= n; j++) {
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
            if (j >= i) ans = max(dp[i][j] - A[j] + A[i], ans);
        }
    }
    printf("%lld\n", ans);
    return 0;
}
 

Measured memory_bytes: 224144
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;

class TaskE {
private:
	Debugger debugger;
public:
	void solveOne(int it){
		int n;
		cin >> n;
		vector<int> upper(n), lower(n);
		for(int i = 0; i < n; i++){
			cin >> lower[i] >> upper[i];
		}
		sort(lower.begin(), lower.end());
		sort(upper.begin(), upper.end());
		if(n&1){
			cout << upper[n/2] - lower[n/2] + 1 << endl;
		}else{
			cout << upper[n/2] + upper[n/2-1] - lower[n/2] - lower[n/2-1] + 1 << endl; 
		}


	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  ll n,ans=0;
  cin>>n;

    string s;
    cin>>s;

    

    

  for(int i=0;i<n;i++)
    {
      string te=s.substr(0,i+1);
      string mp=s.substr(i+1,n);
      sort(te.begin(),te.end());
      sort(mp.begin(),mp.end());

      
      map<char,int>tt,mpp;
      for(int j=0;j<te.length();j++)
        tt[te[j]]=1;
      for(int j=0;j<mp.length();j++)
         mpp[mp[j]]=1;
       ll com=0;
       for(int k=0;k<26;k++)
       {
        if(tt[char('a'+k)]&&mpp[char('a'+k)])
          com++;

       }
       ans=max(ans,com);

       

    }
    cout<<ans<<endl;
}
return 0;
}

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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
#define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  int A, B, K;
  cin >> A >> B >> K;
  int ans = 1;
  vector<int> v;
  int n = 1;
  while (ans <= A && ans <= B) {
    if (A % ans == 0 && B % ans == 0) {
      dump(ans);
      v.push_back(ans);
      n++;
    }
    ans++;
  }
  dumpv(v);
  cout << v[v.size() - K] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a - b >= 0)
			System.out.println("delicious");
		else if (Math.abs(a-b) <= x)
			System.out.println("safe");
		else
			System.out.println("dangerous");
		sc.close();
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include<string.h>
int main(){
  char s[1001];
  int n;
  int count[4]={0,0,0,0};
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<n;i++){
    if(s[i]=='S')count[0]++;
    if(s[i]=='N')count[1]++;
    if(s[i]=='W')count[2]++;
    if(s[i]=='E')count[3]++;
  }
  if((count[0]==0&&count[1]>0)||(count[1]==0&&count[0]>0))
    printf("No\n");
  else if((count[2]==0&&count[3]>0)||(count[3]==0&&count[2]>0))
    printf("No\n");
  else
    printf("Yes\n");
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void solve(int n, int x) {
		int ans = 0;
		for(int i=1;i<=n-2;i++) {
			for(int j=i+1;j<=n-1;j++) {
				for(int k=j+1;k<=n;k++) {
					if(i+j+k==x) ans++;
				}
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true) {
			int n, x;
			n = in.nextInt();
			x = in.nextInt();
			if(n == 0) break;

			solve(n, x);
		}
	}
}

Measured memory_bytes: 26400
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

const long long inf=1e15;

long long memo[402][402];
long long arr[402],kum[402];

long long rek(int a,int b){
	if(a==b) return 0;
	if(memo[a][b]!=-1) return memo[a][b];
	memo[a][b]=inf;
	for(int i=a;i<b;i++){
		if(rek(a,i)+rek(i+1,b)+kum[b]-kum[a-1]<memo[a][b]) memo[a][b]=rek(a,i)+rek(i+1,b)+kum[b]-kum[a-1];
	}
	return memo[a][b];
}

int main () {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		kum[i]=kum[i-1]+arr[i];
	}
	memset(memo,-1,sizeof memo);
	cout<<rek(1,n);



return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define LL long long 
using namespace std;

int main(){
	long double a,b,c;
	cin >> a >> b >> c;
	if((c-a-b)*(c-a-b) > 4*a*b && (c-a-b) > 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n, m;
	cin >> n >> m;
	vector<bool> a(n+1, false);
	for(int i = 0; i < m; ++i){
		int tmp;
		cin >> tmp;
		a[tmp] = true;
	}
	
	ll dp[n+10] = {};
	dp[0] = 1;
	for(int i = 0; i < n; ++i){
		if(!a[i+1]){
			dp[i+1] += dp[i] % MOD;
			dp[i+1] %= MOD;
		}
		if(!a[i+2]){
			dp[i+2] += dp[i] % MOD;
			dp[i+2] %= MOD;
		}
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 1024
H, W=list(map(int,input().split()))
a=[list(input()) for _ in range(H)]
b=[]
# print(a)
for i in range(len(a)):
    ct=0
    for j in range(len(a[0])):
        if a[i][j]=='#':
            ct+=1
    if ct!=0:
        b.append(a[i])
# print(b)
c=[[] for _ in range(len(b))]
# print(c)
for i in range(len(b[0])):
    ct=0
    for j in range(len(b)):
        if b[j][i]=='#':
            ct+=1
    if ct!=0:
        for k in range(len(b)):
            c[k].append(b[k][i])
            # print(c, k, i)
# print(c)

for i in range(len(c)):
    print(''.join(c[i]))

# print(a)
# for i in range(len(a[0]))):
#     ct=0
#     for j in range(max(len(a),0)):
#         if a[j][i]=='#':
#             ct+=1
#     if ct==0:
#         for k in range(max(len(a),0)):
#             a[k].pop(i)
#     print(a)
# print(a)
# for i in range(len(a)):
#     print(''.join(a[i]))


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    int A[200005] = {0},B[200005] = {0};
    rep1(i,N-1) cin >> A[i];

    rep(i,N)
        B[A[i]-1]++;
    
    
    rep(i,N) cout << B[i] << endl;
    //cout << endl;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  while(n > 0){
    if(n % 10 == 7){
      Yes(true);
      return 0;
    }
    n /= 10;
  }
  Yes(false);
  return 0;
}

Measured memory_bytes: 3608
let _ =
  let trk = Stack.create () in
  try
    while true do
      let t = Scanf.scanf "%d\n" (fun x -> x) in
      if t = 0 then
        Printf.printf "%d\n" (Stack.pop trk)
      else
        Stack.push t trk
    done
  with
    End_of_file -> ()

Measured memory_bytes: 2416
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

h,w = map(int,input().split())
for _ in range(h):
    temp = input()
    for __ in range(2):
        print(temp)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string w;
    cin >> w;
    ll ans = 0;
    while(1){
        string x;
        cin >> x;
        if(x == "END_OF_TEXT"){ break; }
        transform(x.begin(), x.end(), x.begin(), ::tolower);
        ans += (x == w);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

struct node 
{
	int c;//每本书的价格
	int a[15];//这本书能够提升Ta的第j个算法多少等级 
}book[15];//储存每一本书的信息 
int b[15];//统计每个子集能够提升第j个算法的总的等级数 

int main()
{ 
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>book[i].c;
		for(int j=0;j<m;j++) cin>>book[i].a[j];
	}
	int ans=2e9;
	for(int i=0;i<(1<<n);i++)
	{
		memset(b,0,sizeof b); 
		int sum=0;//统计每一个子集所有书的总价格 
		for(int j=0;j<n;j++)
			if(i>>j&1)
			{
				sum+=book[j].c;
				for(int k=0;k<m;k++) b[k]+=book[j].a[k]; 
			 } 
		bool flag=1;//判断m个算法是否都大于等于x，1为是，0为否
		for(int j=0;j<m;j++) if(b[j]<x) flag=0;
		if(flag) ans=min(ans,sum);//每次都选择更小价格 
	}
	if(ans==2e9) cout<<"-1";
	else cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3608