akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
	char p[10001];
	while(cin>>p)
	{
		int l=strlen(p),flag1=1;
		for(int i=0;i<l;i++)
		{
		   if(p[i]!=p[i+1])
		   {
			   switch(p[i])
			   {
			   case '1':if(flag1%5==1)cout<<"'";
				         if(flag1%5==2)cout<<",";
						 if(flag1%5==3)cout<<".";
						 if(flag1%5==4)cout<<"!";
						 if(flag1%5==0)cout<<"?";break;
			   case '2':if(flag1%6==1)cout<<"a";
				         if(flag1%6==2)cout<<"b";
						 if(flag1%6==3)cout<<"c";
						 if(flag1%6==4)cout<<"A";
						 if(flag1%6==5)cout<<"B";
						 if(flag1%6==0)cout<<"C";
						 break;
			   case '3':if(flag1%6==1)cout<<"d";
				         if(flag1%6==2)cout<<"e";
						 if(flag1%6==3)cout<<"f";
						 if(flag1%6==4)cout<<"D";
						 if(flag1%6==5)cout<<"E";
						 if(flag1%6==0)cout<<"F";
						 break;
			   case '4':if(flag1%6==1)cout<<"g";
				         if(flag1%6==2)cout<<"h";
						 if(flag1%6==3)cout<<"i";
						 if(flag1%6==4)cout<<"G";
						 if(flag1%6==5)cout<<"H";
						 if(flag1%6==0)cout<<"I";
						 break;
			   case '5':if(flag1%6==1)cout<<"j";
				         if(flag1%6==2)cout<<"k";
						 if(flag1%6==3)cout<<"l";
						 if(flag1%6==4)cout<<"J";
						 if(flag1%6==5)cout<<"K";
						 if(flag1%6==0)cout<<"I";
						 break;
			   case '6':if(flag1%6==1)cout<<"m";
				         if(flag1%6==2)cout<<"n";
						 if(flag1%6==3)cout<<"o";
						 if(flag1%6==4)cout<<"M";
						 if(flag1%6==5)cout<<"N";
						 if(flag1%6==0)cout<<"O";
						 break;
			   case '7':if(flag1%8==1)cout<<"p";
				         if(flag1%8==2)cout<<"q";
						 if(flag1%8==3)cout<<"r";
						 if(flag1%8==4)cout<<"s";
						 if(flag1%8==5)cout<<"P";
						 if(flag1%8==6)cout<<"Q";
						 if(flag1%8==7)cout<<"R";
						 if(flag1%8==0)cout<<"S";
						 break;
			   case '8':if(flag1%6==1)cout<<"t";
				         if(flag1%6==2)cout<<"u";
						 if(flag1%6==3)cout<<"v";
						 if(flag1%6==4)cout<<"T";
						 if(flag1%6==5)cout<<"U";
						 if(flag1%6==0)cout<<"V";
						 break;
			   case '9':if(flag1%8==1)cout<<"w";
				         if(flag1%8==2)cout<<"x";
						 if(flag1%8==3)cout<<"y";
						 if(flag1%8==4)cout<<"z";
						 if(flag1%8==5)cout<<"W";
						 if(flag1%8==6)cout<<"X";
						 if(flag1%8==7)cout<<"Y";
						 if(flag1%8==0)cout<<"Z";
						 break;
			   case '0':
				   for(int i=0;i<flag1-1;i++)
							cout<<" ";break;
			   }
			   flag1=1;
		   }
		   else
		   {
           flag1++;
		   }
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
	using namespace std;
	#define       M                        1000000007
	#define       ll                       long long
	#define	      FIO		               ios_base::sync_with_stdio(false);cin.tie(NULL)
	#define       ifor(st,lim)             for(int i=st;i<lim;i++)
	#define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
	#define       eifor(st,lim)            for(int i=st;i<=lim;i++)
	#define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
	#define       blank		                 cout<<'\n';
	int n,k;

	unordered_set<int> us[200001];
	bool visited[200001];

	int dfs( int u) {
		visited[u] = true;
		int sz = 1;

		for(auto it : us[u]) {
			if(!visited[it]) {
				sz+=dfs(it);
			}
		}
		return sz;
	}
	void solve()
	{	
		int n,m; cin>>n>>m;
		int a[m][2];
		bool visted = {false};

		ifor(0,m) {
			int a,b; cin>>a>>b;
			us[a].insert(b);
			us[b].insert(a);
		}
		int ans = 0;
		for(int i=1;i<=n;i++) {
			if(!visited[i]) {
				int size = dfs(i);
				ans = max(ans,size);
			}
		}
		cout<<ans;
	}


	int main()
	{
	#ifndef ONLINE_JUDGE
	  freopen("input.txt","r",stdin);
	  freopen("output.txt","w",stdout);
	#endif
	int t=1;
	  while(t--){
	    solve();
	   } 
	}



Measured memory_bytes: 39612
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
A=get_i
kind=A.tally
if kind.size<=K
    puts 0
    exit
end
puts kind.sort{|x,y| x[1]<=>y[1]}[..max(0,kind.size-K)-1].inject(0){|res,x| res+=x[1]}

Measured memory_bytes: 48512
#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	
	int a[n] ;
	int i;
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}	
	
	//使用暴力枚举 
	int result = 0;
	int j,k;
	
	for(i = 0;i < n;i++){
		for(j = i+1;j < n;j++){
			if(a[i] == a[j])
				continue;
			for(k = j+1;k < n;k++){
				if(a[i] == a[k] || a[j] == a[k])
					continue;
				
				if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i])
					result++;
			}
		}
	} 
	
	printf("%d",result);
	 
	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,tmp1,tmp2,tmp3;
    long long ans = 0;
    cin >> a >> b >> c;
    if(a == b && b == c && a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        cout << -1 << endl;
        return 0;
    }
    while(1){
        if(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
            tmp1 = a;
            tmp2 = b;
            a = (b+c)/2;
            b = (tmp1+c)/2;
            c = (tmp1+tmp2)/2;
            ans++;
        }else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int y = sc.nextInt();
        int x = sc.nextInt();
        char[][] array = new char[y][x];
        int[] dy = {-1,-1,-1,0,0,1,1,1};
        int[] dx = {-1,0,1,-1,1,-1,0,1};
        for(int i = 0; i<y; i++) {
            String s = sc.next();
            for(int j=0; j<x; j++) {
                array[i][j] = s.charAt(j);
            }
        }
        for(int i = 0; i<y; i++) {
            for(int j=0; j<x; j++) {
                if(array[i][j]=='#') continue;
                int count = 0;
                for(int k=0; k<8; k++) {
                    int ni = i + dy[k];
                    int nj = j + dx[k];
                    if(ni <0 || y<=ni) continue;
                    if(nj <0 || x<=nj) continue;
                    if(array[ni][nj]=='#') count++;
                }
                array[i][j] = (char) (count + '0');
            }
        }
        for(int i = 0; i<y; i++) {
            for(int j=0; j<x; j++) {
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 23636
N, T = gets.split.map(&:to_i)
t_list = gets.split.map(&:to_i)

max = N * T
ans = max
prev_t = 0
t_list[1..-1].each do |t|
  if t - prev_t < T
    ans -= (T - (t - prev_t))
  end
  prev_t = t
end
puts ans


Measured memory_bytes: 15876
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
string s;int cnt;
int n,m,k,a[N],b[N];
int main()
{
	cin>>n>>m>>k>>s;
	int last=-1e8;cnt=0;
	for(int i=0;i<n;i++)
	{
		if(i-last-1>=k&&s[i]=='o')
		{
			cnt++;
			a[cnt]=i;
			last=i;
		}
		if(cnt==m)break;
	}
	last=1e8;cnt=m;
	for(int i=n-1;i>=0;i--)
	{
		if(last-i-1>=k&&s[i]=='o')
		{
			b[cnt--]=i;
			last=i;
		}
		if(!cnt)break;
	}
	for(int i=1;i<=m;i++)
	{
		if(a[i]==b[i])
		{
			cout<<a[i]+1<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5100000;
const int MOD = 1000000007;

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;
}
int main(){
  int x, y;
  cin >> x >> y;
  long long int m,n;
  COMinit();
  
  
  if((2*x-y)>=0 && (2*x-y)%3==0 && (-x+2*y)>=0 && (-x+2*y)%3==0){
    m = (2*x-y)/3;
    n = (-x+2*y)/3;
    if(m<n){
      long long int t = m;
      m = n;
      n = t;
    }
    cout << COM(m+n,n) << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 119808
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
 ll n,m;
  while(cin>>n>>m,n+m){
    vector<ll> tl(n+m);
    rep(i,n+m){
      cin>>tl[i];
    }
    sort(tl.begin(),tl.end());
    ll maxx = tl[0];
    rep(i,n+m-1){
      maxx = max(maxx,tl[i+1] - tl[i]);
    }
    cout<<maxx<<endl;
  }
  

}

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

using namespace std;

int main() {
    double h, minh = 1e6, maxh = 0;
    while (cin >> h) {
        minh = min(minh, h);
        maxh = max(maxh, h);
    }
    cout << maxh - minh << endl;

    return 0;
}

Measured memory_bytes: 1276
# 入力
N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted(A)

# (中央値、最小値, 最大値, 2番目の最小値, 2番目の最大値, ...) の順で差をとる場合と、
# (中央、最大値, 最小値, 2番目の最大値, 2番目の最小値, ...) の順で差をとる場合を比較し、
# 大きい方を解とする
ans = (
    2 * sum(
        B[-(i + 1)] - B[i]
        for i in range(N // 2)
    ) - min(
        B[N // 2] - B[N // 2 - 1],
        B[N // 2 + 1] - B[N // 2] if N % 2 == 1 else 10**18
    )
)
# 出力
print(ans)


Measured memory_bytes: 8284
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int H, W;

	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		rep(i, H) {
			if (i == 0) rep(j, W) cout << '#';
			else if (i == H - 1) rep(j, W) cout << '#';
			else {
				cout << '#';
				rep(j, W - 2) cout << '.';
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}




	return 0;
}



Measured memory_bytes: 3088
use proconio::marker::*;
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        k: usize,
        p: [Usize1; n],
        c: [i64; n],
    };
    let mut ans = i64::min_value();

    for i in 0..n {
        let start = i;
        let mut now = start;
        let mut cycle = Vec::new();
        let mut cycle_score = 0;
        loop {
            cycle_score += c[now];
            now = p[now];
            cycle.push(c[now]);
            if now == start {
                break;
            }
        }

        let mut tot = 0;
        let length = cycle.len() as i64;
        let cycle_num = k as i64 / length;
        let mut j = if cycle_num > 0 {
            ((cycle_num - 1) * length) as usize
        } else {
            0
        };
        if cycle_score > 0 && cycle_num > 0 {
            tot += (cycle_num - 1) * cycle_score;
        }

        while j < k {
            tot += c[now];
            now = p[now];
            j += 1;
            ans = max(ans, tot);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2392
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    
    System.out.println(H * W - ( H * w + W * h - h * w ));
  }
}

Measured memory_bytes: 24020
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[502020];
int imos[502020];
bool f[502020];
int main()
{
	int num, mod;
	scanf("%d%d", &num, &mod);
	num *= 2;
	for (int i = 0; i < num; i++)scanf("%d", &d[i]);
	sort(d, d + num);
	for (int i = 0; i < num; i++)d[i + num] = d[i];
	int mini = mod;
	int c = 0;
	for (;;)
	{
	l01:;
		//printf("%d\n", c);
		if (c == num / 2)break;
		int r = rand() % num;
		if (f[r] || r % 2 == 0)goto l01;
		int maxi = 0;
		for (int i = 0; i < num; i++)maxi = max(maxi, (d[i] + d[r + num - i]) % mod);
		mini = min(mini, maxi);
		for (int i = 0; i <= num + num; i++)imos[i] = 0;
		for (int i = 0; i < num; i++)
		{
			int u1 = upper_bound(d, d + num + num, (mini - 1 + mod - d[i]) % mod) - d + i;
			int l1 = lower_bound(d, d + num + num, (mod - d[i]) % mod) - d + i;
			u1 %= num, l1 %= num;
			if (u1 == l1)
			{
				if ((d[i] + d[0]) % mod >= mini)imos[0]++;
			}
			else if (u1 < l1)imos[u1]++, imos[l1]--;
			else imos[u1]++, imos[l1 + num]--;
		}
		for (int i = 0; i < num + num; i++)imos[i + 1] += imos[i];

		//printf("%d %d\n", r, mini);
		//for (int i = 0; i < num + num; i++)printf("%d ", imos[i]); printf("\n");

		for (int i = 0; i < num; i++)if (i % 2 != 0 && (imos[i] + imos[i + num]) != 0 && !f[i])f[i] = true, c++;
	}
	printf("%d\n", mini);
}

Measured memory_bytes: 3968
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    n=n%k;
    while(n > abs(n-k)) n = abs(n-k);
    cout<<n<<endl;
}

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

using namespace std;

int main(){
	int A,B;
  	cin>>A>>B;
  	int cnt = 0;
  	for(int i=A;i<=B;i++){
    	int x=i;
      	cin>>x;
      	int s = x%10;
      	int t = x/10%10;
      	int u = x/1000%10;
      	int v = x/10000%10;
      	if(s==v && t==u)
          cnt++;
    }
  	cout << cnt << endl;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)

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

	int n;
	cin >> n;
	
	vector<int> price(n);
	FOR(i,0,n) cin >> price[i];
	sort(price.begin(), price.end(), greater<int>());
	
	//cout << "price:" << endl;
	//FOR(i, 0, n) cout << price[i] << endl;
	//cout << endl;
	
	int cost = int(price[0]/2);
	FOR(i,1,n) cost += price[i];
	
	cout << cost << endl;
	
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()] 
C = 0
S = 0
X = H[0]
for i in range(N-1):
	if X >= H[i+1]:
		C+=1
	else:
		if S < C:
			S = C
		C = 0
	X = H[i+1]
	if (i+2) >= N:
		if S < C:
			S = C
print(S)

Measured memory_bytes: 14224
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 505
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	char a[2], b[2];
	scanf("%s %s", a, b);
	int dif = a[0] - b[0];
	if (dif < 0)
		putchar('<');
	else if (dif > 0)
		putchar('>');
	else
		putchar('=');
}

Measured memory_bytes: 256
max_n = 10**18

n = int(input())
  
if n % 2 == 1:
  print(0)
else:  
  ans = d = i = 0
  while n >= d:
    d = 2 * 5**(i+1)
    ans += n // d  
    i+=1
  print(ans)  

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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    for (int i = 1; i <= n; i+=2){
        for (int j = 1; j <= i; j++){
            if(i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
        cnt = 0;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;

    if (s[s.size() - 1] == 's') {
        s += 'e';
        s += 's';
    } else {
        s += 's';
    }

    cout << s;

    return 0;
}

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

int N, M;
vector<int> V[100005];
bool vis[100005];
deque<int> nodes;
bool disabled;

void dfs(int x) {
	if (vis[x]) return;
	else vis[x] = 1;
	if (disabled) return;
	nodes.push_back(x);
	for (int i = 0; i < V[x].size(); i++) dfs(V[x][i]);
	disabled = 1;
}
/*
void dfs2(int x, int p) {
	if (vis[x]) return;
	else vis[x] = 1;
	if (disabled) return;
	if (!disabled) nodes.push_back(x);
	for (int i = 0; i < V[x].size(); i++) if (V[x][i] == 0 && p != 0) disabled = 1;
	for (int i = 0; i < V[x].size(); i++) dfs2(V[x][i], x);
	if (!disabled) nodes.pop_back();
}
*/
void dfs3(int x) {
	if (vis[x]) return;
	else vis[x] = 1;
	if (disabled) return;
	if (x != 0) nodes.push_front(x);
	for (int i = 0; i < V[x].size(); i++) dfs3(V[x][i]);
	disabled = 1;
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	dfs(0);
	memset(vis, 0, sizeof(vis));
	for (int i = 1; i < nodes.size(); i++) vis[nodes[i]] = 1;
	disabled = 0;
	dfs3(0);
	printf("%d\n", nodes.size());
			for (int j = 0; j < nodes.size(); j++) {
				if (j) printf(" ");
				printf("%d", nodes[j]+1);
			}
			printf("\n");
	/*bool used = 0;
	for (int i = 0; i < N; i++) {
		if (V[i].size() == 1) {
			dfs(i);
			used = 1;
			printf("%d\n", nodes.size());
			for (int j = 0; j < nodes.size(); j++) {
				if (j) printf(" ");
				printf("%d", nodes[j]+1);
			}
			printf("\n");
			break;
		}
	}
	if (used) return 0;
	dfs2(0, -1);
	memset(vis, 0, sizeof(vis));
	for (int i = 1; i < nodes.size(); i++) vis[nodes[i]] = 1;
	dfs3(0, -1);*/
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%lld", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 300;
const double eps = 1e-9;
using namespace std;
int dp[MAXN][MAXN][MAXN];

int _min(int a, int b, int c, int d, int e, int f)
{
    return min(min(a, min(b, c)), min(d, min(e, f)));
}

int dfs(int a, int b, int c)
{
    int x = min(a, min(b, c));
    int z = max(a, max(b, c));
    int y = a + b + c - x - z;
    a = x, b = y, c = z;
    if (c >= MAXN)
        return INF;
    if (dp[a][b][c] != -1)
        return dp[a][b][c];
    if (a == b && b == c)
        return 0;
    return dp[a][b][c] = _min(dfs(a + 1, b + 1, c), dfs(a + 1, b, c + 1), dfs(a, b + 1, c + 1), dfs(a + 2, b, c), dfs(a, b + 2, c), dfs(a, b, c + 2)) + 1;
}

int main()
{
    for (int i = 0; i < MAXN; i++)
        for (int j = 0; j < MAXN; j++)
            for (int k = 0; k < MAXN; k++)
                dp[i][j][k] = -1;
    int a, b, c;
    ni(a), ni(b), ni(c);
    int ans = dfs(a, b, c);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 105728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    int ans;
  	ll n=s.size();
    if(k<=n){
        for(int i=0;i<k;i++){
            if(s[i]!='1'){
                ans=s[i]-'0';
                break;
            }
            if(s[k-1]=='1'){
                ans=1;
            }
        }
    }
    else {
        for(int i=0;i<s.size();i++){
            if(s[i]!='1'){
                ans=s[i]-'0';
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3552
#include<cstdio>
int num,ans=0;
int main()
{
    scanf("%d",&num);
    ans=ans*10+num;
    scanf("%d",&num);
    ans=ans*10+num;
    scanf("%d",&num);
    ans=ans*10+num;
    ans%4?printf("NO"):printf("YES");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N; cin >>N;
  vector<int> vec(N);
  for(int& n : vec) { cin >>n; }
  int cnt = 0;
  vector<int> tmpv(3);
  for(int i = 1; i < N - 1; i++){
    tmpv[0] = vec[i - 1];
    tmpv[1] = vec[i];
    tmpv[2] = vec[i + 1];
    sort(tmpv.begin(), tmpv.end());
    if(tmpv[1] == vec[i]) cnt++;
  }
  cout <<cnt <<endl;
  return 0;
}


Measured memory_bytes: 256
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
import math
ans = 0

for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        tmp = math.sqrt(tmp)
        if float.is_integer(tmp):
            ans += 1
            
print(ans)
            


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char c1[10];
    char c2[1000];
    int c=0,a;
     
    scanf("%s",c1);
    //printf("%s",c1);
     
    while(1){
    scanf("%s",c2);
        if(strcmp(c2,"END_OF_TEXT")==0){
        break;
        }
    for(a=0;a<1000;a++){
        if(c2[a]=='A'){
        c2[a]='a';
        }
        if(c2[a]=='B'){
        c2[a]='b';
        }
        if(c2[a]=='C'){
        c2[a]='c';
        }
        if(c2[a]=='D'){
        c2[a]='d';
        }
        if(c2[a]=='E'){
        c2[a]='e';
        }
        if(c2[a]=='F'){
        c2[a]='f';
        }
        if(c2[a]=='G'){
        c2[a]='g';
        }
        if(c2[a]=='H'){
        c2[a]='h';
        }
        if(c2[a]=='I'){
        c2[a]='i';
        }
        if(c2[a]=='J'){
        c2[a]='j';
        }
        if(c2[a]=='K'){
        c2[a]='k';
        }
        if(c2[a]=='L'){
        c2[a]='l';
        }
        if(c2[a]=='M'){
        c2[a]='m';
        }
        if(c2[a]=='N'){
        c2[a]='n';
        }
        if(c2[a]=='O'){
        c2[a]='o';
        }
        if(c2[a]=='P'){
        c2[a]='p';
        }
        if(c2[a]=='Q'){
        c2[a]='q';
        }
        if(c2[a]=='R'){
        c2[a]='r';
        }
        if(c2[a]=='S'){
        c2[a]='s';
        }
        if(c2[a]=='T'){
        c2[a]='t';
        }
        if(c2[a]=='U'){
        c2[a]='u';
        }
        if(c2[a]=='X'){
        c2[a]='x';
        }
        if(c2[a]=='Y'){
        c2[a]='y';
        }
        if(c2[a]=='Z'){
        c2[a]='z';
        }
    }
 
        if(strcmp(c2,c1)==0){
        c++;
        }
    }
printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <cmath>
#define inf 1000000000

using namespace std;

int N, M;
int a[55], b[55], c[55], d[55];

int main(void)
{
	cin >> N >> M;
	for(int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for(int i = 0; i < M; i++) cin >> c[i] >> d[i];
	
	int dist, min_d, min_j;
	for(int i = 0; i < N; i++){
		min_d = inf;
		for(int j = 0; j < M; j++){
			dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if(min_d > dist){
				min_d = dist;
				min_j = j;
			}
		}
		cout << min_j + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2001;

int n, m, d[N][N][4];
vector <string> g;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    for(auto &i : g) cin >> i;
    for(int i = 0 ; i < n ; i++){
        int las = -1;
        for(int j = 0 ; j < m ; j++){
            if(g[i][j] == '#'){
                las = j;
                continue;
            }
            d[i][j][0] = j - las;
        }
        las = m;
        for(int j = m - 1 ; j >= 0 ; j--){
            if(g[i][j] == '#'){
                las = j;
                continue;
            }
            d[i][j][1] = las - j;
        }
    }
    for(int j = 0 ; j < m ; j++){
        int las = -1;
        for(int i = 0 ; i < n ; i++){
            if(g[i][j] == '#'){
                las = i;
                continue;
            }
            d[i][j][2] = i - las;
        }
        las = n;
        for(int i = n - 1 ; i >= 0 ; i--){
            if(g[i][j] == '#'){
                las = i;
                continue;
            }
            d[i][j][3] = las - i;
        }
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            int cur = 0;
            for(int k = 0 ; k < 4 ; k++){
                cur += d[i][j][k];
            }
            ans = max(ans, cur);
        }
    }
    cout << ans - 3 << endl;
}


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

int Q ;
long long int L , R , DP[65][2] , A[65][2];
void pre(){
    DP[0][0] = DP[0][1] = 1 ;
    for(int i=1;i<=64;i++){
        DP[i][0] = (DP[i-1][0]+DP[i-1][1]) ;
        DP[i][1] = (DP[i-1][0]+DP[i-1][1]) ;
    }
}

void solve(){
    long long sum = 0 ;
    for(int i=63;i>=0;i--){
        A[i][0] += sum ;
        if(L & (1LL << i)){
            A[i][0] += (L - DP[i][0]) ;
            sum += (DP[i][0]/2) ;
            L -= DP[i][0] ;
        }
    }
    R ++ ;
    sum = 0 ;
    for(int i=63;i>=0;i--){
        A[i][1] += sum ;
        if(R & (1LL << i)){
            A[i][1] += (R - DP[i][1]) ;
            sum += (DP[i][1]/2) ;
            R -= DP[i][1] ;
        }
    }
    sum = 0 ;
    for(int i=63;i>=0;i--){
        A[i][1] -= A[i][0] ;
        A[i][1] %= 2 ;
        if(A[i][1])
            sum += (1LL << i) ;
    }
    cout << sum << endl ;
}
int main(){
    pre() ;
        cin >> L >>  R ;
        solve() ;
    return 0 ;
}


Measured memory_bytes: 256
#include<cstdio>
const int N=1e5+5;
int n,i,et,he[N];
struct edge{int l,to;}e[2*N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int dfs(int x,int fa){
	int sum=1;
	for (int i=he[x];i;i=e[i].l)
		if (e[i].to!=fa) sum+=dfs(e[i].to,x);
	if (sum==2) sum=0;return sum;
}
int main(){
	n=read();if (n&1){puts("First");return 0;}
	for (i=1;i<n;i++){
		int x=read(),y=read();
		e[++et].l=he[x];he[x]=et;e[et].to=y;
		e[++et].l=he[y];he[y]=et;e[et].to=x;
	}
	puts(dfs(1,0)?"First":"Second");
}

Measured memory_bytes: 2176
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N, M; cin >> N >> M;
	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

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

using namespace std;

typedef long long ll;

#ifdef WIN32
inline int getchar_unlocked()
{
    return _getchar_nolock();
}
inline void putchar_unlocked(char c)
{
    _putchar_nolock(c);
}
#endif

inline int raw_char()
{
    return getchar_unlocked();
}

inline int read_char()
{
    char c;
    do
    {
        c=getchar_unlocked();
    } while(c<33);
    return c;
}

inline void print_char(char c)
{
    putchar_unlocked(c);
}

template<typename T=ll>
inline T read_int()
{
    T temp=0;
    bool neg=0;
    char c=read_char();
    if(c=='-')
    {
        neg=1;
        c=raw_char();
    }
    while(c>='0'&&c<='9')
    {
        temp=temp*10+c-'0';
        c=raw_char();
    }
    return neg?-temp:temp;
}

template<typename T=ll>
inline void print_int(T x)
{
    if(x==0)
    {
        print_char('0');
        return;
    }
    char buff[24];
    int idx=0;
    if(x<0)
    {
        print_char('-');
        x=-x;
    }
    while(x)
    {
        buff[idx++]=x%10+'0';
        x/=10;
    }
    while(idx)
        print_char(buff[--idx]);
}

const int m=1e9+7;

int main()
{
    vector<vector<bool>> b;
    vector<vector<ll>> dp;
    int y=read_int(),x=read_int();
    b.assign(y,vector<bool>(x,1));
    dp.assign(y,vector<ll>(x,0));
    for(int i=0;i<y;++i)
        for(int j=0;j<x;++j)
        {
            char c=read_char();
            if(c=='#')
                b[i][j]=0;
        }
    for(int i=0;i<y;++i)
    {
        if(!b[i][0])
            break;
        dp[i][0]=1;
    }
    for(int i=0;i<x;++i)
    {
        if(!b[0][i])
            break;
        dp[0][i]=1;
    }
    for(int i=1;i<y;++i)
        for(int j=1;j<x;++j)
            if(b[i][j])
                dp[i][j]=(dp[i-1][j]%m+dp[i][j-1]%m)%m;
    print_int(dp[y-1][x-1]);
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[100000];
int dist[1000000];
int ans = 0;
int main() {
    int n ; cin>>n;
    for(int i = 0 ; i < n - 1; ++i){
        int x , y ;cin>>x>>y;
        x--; y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    vector<int>dist(n) , nad(n , -1);
    queue<int>q;
    q.push(0);
    int k = 0 ;
    for(int& i : dist)cin>>i;
    sort(dist.begin() , dist.end() , greater<int>());
    nad[0] = dist[k++];
    while(!q.empty()){
        int x = q.front(); q.pop();
        for(int& i : adj[x]){
            if(nad[i] != -1)continue;
            nad[i] = dist[k++];
            ans += nad[i];
            q.push(i);
        }
    }
    cout<<ans<<endl;
    for(int& i : nad)cout<<i<<" ";
    
}


Measured memory_bytes: 4992
N, M = map(int, input().split())
A = [0] * (N + 5)
MOD = 10 ** 9 + 7
dp = [0] * (N + 5)
for i in range(M):
    a = int(input())
    A[a] = 1


dp[0] = 1
for i in range(N):
    if A[i + 1] != 1:
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
    if A[i + 2] != 1:
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD

print(dp[N])

Measured memory_bytes: 47320
// https://atcoder.jp/contests/abc171/tasks/abc171_e

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 

const int maxn = 200500;

int a[maxn];
signed main() {
    ios::sync_with_stdio(0);
    cin.sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    int t = 0;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        t ^= a[i];
    }

    for(int i = 1; i <= N; i++) {
        cout << (t^a[i]) << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4428
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>

using namespace std;

class Dice
{
public:
	int top;	// ?????¢
	int south;	// ?????¢
	int east;	// ??±??¢
	int west;	// ?\???¢
	int north;	// ?????¢
	int bottom;	// ?????¢
	int tmp;	// ?????¢????????????????????¨
	void rotation(char ope);
};

void Dice::rotation(char ope)
{
	switch(ope)
	{
		case 'E':
			tmp = top;
			top = west;
			west = bottom;
			bottom = east;
			east = tmp;			
			break;
		case 'W':
			tmp = top;
			top = east;
			east = bottom;
			bottom = west;
			west = tmp;
			break;
		case 'S':
			tmp = top;
			top = north;
			north = bottom;
			bottom = south;
			south = tmp;
			break;
		case 'N':
			tmp = top;
			top = south;
			south = bottom;
			bottom = north;
			north = tmp;
			break;
	}
}

int main()
{
	Dice dice1;
	string ope;
	cin >> dice1.top >> dice1.south >> dice1.east >> dice1.west >> dice1.north >> dice1.bottom;
	
	//???????????¢??????????????\???
	cin >> ope;
	
	for(int i = 0; i < ope.length(); i++)
	{
		dice1.rotation(ope[i]);
	}
	
	cout << dice1.top << endl;
}

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

int main(){
    int N;
    cin >> N;
    int p;
    if (N%2==0) p = N/2;
    else p = N/2 + 1;
    cout << p << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
    char ptnA[50][50];
    char ptnB[50][50];
    char tmp[51];
    int n,m,flg;
    
    scanf("%d %d", &n, &m);
    for (int i=0; i<n; i++){
        scanf("%s", tmp);
        for (int j=0; j<n;j++){
            ptnA[j][i] = tmp[j];
        }
    }
    for (int i=0; i<m; i++){
        scanf("%s", tmp);
        for (int j=0; j<m;j++){
            ptnB[j][i] = tmp[j];
        }
    }
    
    flg = 0;
    for (int x=0; x <= n-m; x++){
        for (int y=0; y <= n-m; y++){
            int matched = 1;
            for (int w=0; w<m; w++){
                for (int h=0; h<m; h++){
                    if (ptnA[x+w][y+h] != ptnB[w][h]){
                        matched = 0;
                        break;
                    }
                }
                if (!matched) break;
            }
            if (matched){
                flg = 1;
                break;
            }
        }
        if (flg) break;
    }
    
    puts(flg?"Yes":"No");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
n0 = -1
c = 0
T = False
for i in range(N):
    n = int(input())
    if n > n0+1:
        T = True
    elif n == n0+1 and i != 0:
        c += 1
    else:
        c += n
    n0 = n
if T:
    print(-1)
else:
    print(c)

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

void solve(string s, string t, int size){
	int ans = 0;
	for(int i = 0; i < size; i++){
		if(s[i] != t[i]){
			ans++;
		}
	}
	cout << ans << endl;
}

int main(){
	string s , t;
	cin >> s >> t;
	int sSize = s.size();
	
	solve(s , t , sSize);
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
    T.pop_back();
    if (S == T) cout << YES << endl;
    else cout << NO << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

int main()
{
	string s;
	int ans = 0;
	cin >> s;
	int l = s.length();
	for (int i = 0; i < (l / 2 + l % 2); i++) {
		if (s[i] != s[l - 1 - i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){

    int N[3];
    cin >> N[0] >> N[1] >> N[2];

    sort(N, N + 3);

    int min = N[0], mid = N[1], max = N[2];

    if((mid - min) % 2 == 0) cout << ((mid - min) / 2) + (max - mid) << endl; 
    else cout << ((max - mid) + 1) + (((mid - min) / 2) + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{
    int x,y;
    cin>>x>>y;
    if((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) &&(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12))
        cout<<"Yes";
    else if((x==4 || x==6 || x==9 || x==11) && (y==4 || y==6 || y==9 || y==11))
        cout<<"Yes";
    else if(x==2 && y==2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  int n = ri();
  int nn = ri();
  wi(n*nn-n-nn+1);
  
  return 0;
}


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

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    
    ll d = b/x;
    
    if(a == 0) cout << d + 1;
    else cout << d - (a - 1)/x;
}

Measured memory_bytes: 256
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

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

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

string S;
// Main program
void solve(){
    int N;
    cin >> N ;
    int change_to_white[300010];
    int change_to_black[300010];
    cin >> S;
    change_to_black[N+1]=0;
    change_to_white[0]=0;
        REP(i,N){
        if(S[i]=='#'){
            change_to_white[i+1] = change_to_white[i]+1;
        }
        else{
            change_to_white[i+1] = change_to_white[i] ;
        }
    }
    REP(i,N){
        int n = N - i -1;
        if(S[n]=='.'){
            change_to_black[n] = change_to_black[n+1] + 1;
        }
        else{
            change_to_black[n] = change_to_black[n+1];
        }
        DPRINT(change_to_black[n]);
    }

    int ans = 3000010;
    REP(i,N+1){
        chmin(ans, change_to_black[i]+ change_to_white[i]);
        DPRINT(ans);
    }
    cout << ans << endl;

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 2820
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N int
	fmt.Scan(&N)
	var o int
	if N%1000 != 0 {
		o = 1000*(N/1000+1) - N
	} else {
		o = 1000*(N/1000) - N
	}

	fmt.Fprintln(wtr, o)
	_ = wtr.Flush()
}


Measured memory_bytes: 1840
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <deque>

using namespace std;
#define int long long

const int mod = 998244353;

int32_t main() {
    int n, x, m;
    cin >> n >> x >> m;
    deque<int> a;
    a.push_back(x);
    a.push_back((x * x) % m);
    set<int> s;
    s.insert(x);
    while(!s.count(a.back())) {
        s.insert(a.back());
        a.push_back((a.back() * a.back()) % m);
    }
    int ans = 0;
    int all = 0;
    while(n && a.front() != a.back()) {
        ans += a.front();
        --n;
        a.pop_front();
    }
    if (n == 0) {
        cout << ans;
        return 0;
    }
    a.pop_back();
    for(int i = 0; i < a.size(); ++i) {
        all += a[i];
    }
    int cnt = n / a.size();
    ans += cnt * all;
    int last = cnt * a.size();
    for(int i = last; i < n; ++i) {
        ans += a[i % a.size()];
    }
    cout << ans;
}


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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

int main() {
  int a, b;
  std::cin >> a >> b;
  int ret = std::max(a + b, a - b);
  ret = std::max(ret, a * b);
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

ll ans,tmp;
ll a[30],b[30];
int main(){
  IOS();
  ll n;
  string s;
  cin>>n>>s;
  REP1(i,n-1){
    tmp=0;
    RST(a,0);
    RST(b,0);
    REP(j,n){
      if(j+1<=i) a[s[j]-'a']++;
      else b[s[j]-'a']++;
    }
    REP(j,26)if(a[j] && b[j]) tmp++;
    chkmax(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
#ans=a*A+b*B+ab*C
#a+ab//2>=X
#b+ab//2>=Y
ans=float('inf')
M=max(X,Y)
for ab in range(0,(M+1)*2,2):
    #print(X-ab//2,Y-ab//2,ab)
    ans=min(ans,A*max(0,X-ab//2)+B*max(0,Y-ab//2)+C*ab)
    #print(ans)
print(ans)

Measured memory_bytes: 9104
# -*- coding: utf-8 -*-
import itertools
N, M, X = map(int, input().split())
C_list = []
A_list_list = []
for i in range(N):
    A_list = list(map(int, input().split()))
    C_list.append(A_list[0])
    A_list_list.append(A_list[1:])

N_list = [i for i in range(N)]
ans = 10 ** 10
for i in range(1, N + 1):
    for comb in itertools.combinations(N_list, i):
        temp_ans = 0
        for j in comb:
            temp_ans += C_list[j]
        if temp_ans >= ans:
            continue
        
        X_list = [0 for _ in range(M)]
        for j in comb:
            temp_A_list = A_list_list[j]
            for k in range(M):
                X_list[k] += temp_A_list[k]
        if len([X_list[i] for i in range(len(X_list)) if X_list[i] < X]) == 0:
            ans = min(ans, temp_ans)

print(ans if ans != 10 ** 10 else -1)

Measured memory_bytes: 9256