akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

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

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

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
int n ;
vector<string> lis ;

void dfs_list(int c,string s,int premax){
    if(c==0){
        lis.push_back(s) ;
        return ;
    }
    else{
        for(int i=1;i<=premax+1;i++){
            dfs_list(c-1,s+(char)('a'+i-1),max(premax,i)) ;
        }
    }
}
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n ;
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    dfs_list(n-1,"a",1) ;
    REP(i,SZ(lis)){
        cout << lis[i] <<endl;
    }



    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 7796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Objects;

//import org.junit.Test;

public class Main {
//	@Test
//	public void testName() throws Exception {
//		main(null);
//	}

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(
				System.in))) {

			new Main().solution(br);
		}
	}

	private void solution(BufferedReader br) throws IOException {
		for (String line = br.readLine(); Objects.nonNull(line); line = br
				.readLine()) {
			String[] strList = line.split(" ", 0);

			int num1 = Integer.parseInt(strList[0]);
			int num2 = Integer.parseInt(strList[1]);

			// char char1 = str.charAt(1);
			// char char2 = str.charAt(3);
			// int num1 = Integer.parseInt("" + char1);
			// int num2 = Integer.parseInt("" + char2);

			if (num1 == 0 && num2 == 0) {
				break;
			} else if (num1 > num2) {
				System.out.println(num2 + " " + num1);
			} else {
				System.out.println(num1 + " " + num2);
			}

		}
	}

}

Measured memory_bytes: 27008
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> l(q),r(q);
	rep(i, q) {
		cin >> l[i] >> r[i];
		l[i]--;
		r[i]--;
	}
	vector<int> a(n);
	FOR(i, 1, n) {
		if (s[i - 1] == 'A' && s[i] == 'C') {
			a[i] = a[i - 1] + 1;
		}
		else {
			a[i] = a[i - 1];
		}
	}
	rep(i, q) {
		cout << a[r[i]] - a[l[i]] << endl;
	}
	return 0;
}



Measured memory_bytes: 2176
i , t = gets.chomp.split(" ").map(&:to_i)
ans = 100000
i.times do |n|
     c, th = gets.chomp.split(" ").map(&:to_i)
     if t >= th
         if ans > c
             ans = c
         end
     end
 end
 if ans == 100000
     puts "TLE"
 else
     puts ans
 end
 

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

int main() {
  int n, i, j;
  int x = 0;
  int l, r;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> l >> r;
    x += r-l+1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

def cf(x1, x2):
    cf = [i for i in range(1, min(x1, x2)+1)
          if x1 % i == 0 and x2 % i == 0]
    return cf

ans = cf(A, B)
ans.sort(reverse=True)

print(ans[K-1])


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  VI cnt(26, 1e9);
  REP(i,N){
	VI c(26);
	string s; cin >> s;
	REP(i,SZ(s))
	  c[s[i]-'a']++;
	REP(i,26)
	  mini(cnt[i], c[i]);
  }
  REP(i,26)
	cout << string(cnt[i], 'a'+i);
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;

void main(){
	// input
	int[] input;
	for(auto i = 0; i < 3; i++){
		input ~= to!int(readln().chomp());
	}
	

	immutable int start_money = input[0];
	immutable int a_price = input[1];
	immutable int b_price = input[2];

	immutable int answer = (start_money - a_price) % b_price;

	writeln(answer);

}


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

int main()
{
  int h;
  int w;
  while(1){
    cin>>h>>w;
    if(h==0 && w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;  
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
bool check(int a){
    int ns[5];
    for (int i = 0; i < 5; i++) {
        /* code */
        ns[i] = a % 10;
        a/=10;
    }
    if(ns[0] == ns[4] && ns[1] == ns[3]){
        return true;
    }else{
        return false;
    }
}

int main() {
    int a,b;
    cin>>a>>b;
    int cou =0;
    for (int i = a; i < b+1; i++) {
        if(check(i)){
            cou++;
        }
    }
    std::cout << cou << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    ll n;
    cin >> n;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    reverse(all(h));
    int maxv = h[0];
    rep(i,n){
        if(h[i] > maxv) {
            h[i]--;
            if(h[i] > maxv) {
                cout << "No" << endl;
                return 0;
            }
            maxv = h[i];
        }else {
            maxv = h[i];
        }
    }
    cout << "Yes" << endl;
    cout << endl;
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    string s = "";
    cin >> s;
    int ct = 0;
    map<char, int> chk;
    if (s[0] != 'A')
    {
        COUT("WA");
        return 0;
    }

    string slice = s.substr(2, s.length() - 3);
    REP(i, slice.length())
    {
        if (slice[i] != 'C' && isupper(slice[i]))
        {
            COUT("WA");
            return 0;
        }

        chk[slice[i]]++;
    }
    if (isupper(s[1]) || isupper(s[s.length() - 1]))
    {
        COUT("WA");
        return 0;
    }

    if (chk['C'] != 1)
    {
        COUT("WA");
        return 0;
    }

    COUT("AC");
    return 0;
}

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

signed main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a>=b&&a>=c)cout<<a*10+b+c<<endl;
  else if(b>=a&&b>=c)cout<<b*10+a+c<<endl;
  else cout<<c*10+a+b<<endl;
}

Measured memory_bytes: 256
/*  
    tanuj_johal :: gla_clg_sync_with_CSE(true);
    bonding.tie(true);
    hardwork.tie(true);
    
    ::::::::--------------------::::::::
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;


const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
bool imp = false;

void solve()
{
    unordered_map<ll,ll> mp;        set<ll> st;
    multiset<ll> ms;
    
    ll a,b,n;cin>>a>>b>>n;
    ll s = 0;
    ll e = n;
    ll ans = 0;
    while(s <= e)
    {
        ll mid = (s+e)/2;
        ll find = floor(((double)a*mid)/b) - a*floor(mid/b);
        if(find>=0)
        {
            ans = max(ans,find);
            s = mid+1;
        }
        else{
            e = mid-1;
        }
    }
    ll mid = min(b-1,n);
    ans = max(ans, (ll)(floor(((double)a*mid)/b) - a*floor(mid/b)));
    
    cout<<ans<<endl;
}

int main()
{
    fio
    int t=1;
    if(imp) cin>>t;
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        solve();
        // tc++;
    }
    
}


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

int main() {

  char a,b;
  cin >> a >> b;
  
  if((a=='H')&&(b=='H'))
    cout << 'H';
  if((a=='H')&&(b=='D'))
    cout << 'D';
  if((a=='D')&&(b=='H'))
    cout << 'D';
  if((a=='D')&&(b=='D'))
    cout << 'H';
  
  
}


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

int main(){
    int N,T;
    cin >> N >> T;
    vector<int> A(N);
    vector<int> B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    vector<vector<int> > dp1(N + 1, vector<int> (T));
    rep(i,N + 1){
        rep(j,T){
            dp1[i][j] = 0;
        }
    }
    rep(i,N){
        rep(j,T){
            dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
            if (j + A[i] < T){
                dp1[i + 1][j + A[i]] = max(dp1[i + 1][j + A[i]], dp1[i][j] + B[i]);
            }
        }
    }
    vector<vector<int> > dp2(N + 1, vector<int> (T));
    rep(i,N + 1){
        rep(j,T){
            dp2[i][j] = 0;
        }
    }
    for (int i = N - 1; i >= 0; i--){
        rep(j,T){
            dp2[i][j] = max(dp2[i][j] , dp2[i + 1][j]);
            if (j + A[i] < T){
                dp2[i][j + A[i]] = max(dp2[i][j + A[i]], dp2[i + 1][j] + B[i]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++){
        rep(j,T){
            ans = max(ans, dp1[i][j] + B[i] + dp2[i + 1][T - 1 - j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 74008
#include <stdio.h>
int main()
{
	int a, S, h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	a = S % 3600;
	m = a / 60;
	s = a % 60;
	printf("%d:%d:%d\n", h,m,s);
	return 0;
}

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

int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    printf("%.9f ", (double)W * H / 2);
    if (W % 2 == 0 && H % 2 == 0 && x == W / 2 && y == H / 2)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int a = int.Parse(str.Split(' ')[0]);
            int b = int.Parse(str.Split(' ')[1]);

            string astr = "";
            string bstr = "";

            for (int i = 0; i < a; i++)
            {
                astr += b.ToString();
            }

            for (int i = 0; i < b; i++)
            {
                bstr += a.ToString();
            }

            if (astr.CompareTo(bstr) < 0)
            {
                Console.WriteLine(astr);
            }
            else
            {
                Console.WriteLine(bstr);
            }
        }
    }
}


Measured memory_bytes: 27496
n = int(input())
# a = n + 1
a = list(map(int, input().split()))
#b = n
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if a[i] > b[i]:
        ans += b[i]

    else:
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] < b[i]:
            ans += a[i + 1]
            a[i + 1] = 0
        else:
            ans += b[i]
            a[i + 1] -= b[i]

print(ans)


Measured memory_bytes: 82020
#include <cstdio>
#include <cmath>
using namespace std;
void minc(double x[], double y[], int n, int p) {
    double sum = 0.0;
    for(int i = 0; i < n; i++) {
        sum += pow(abs(x[i]-y[i]), p);
    }
    printf("%f\n", pow(sum, 1.0/p));
}
void mincInf(double x[], double y[], int n) {
    double max = 0.0;
    for(int i = 0; i < n; i++) {
        double tmp = abs(x[i]-y[i]);
        if(max < tmp) max = tmp;
    }
    printf("%f\n", max);
}
int main() {
    int n;
    scanf("%d", &n);
    double x[n], y[n];
    for(int i = 0; i < n; i++) scanf("%lf", &x[i]);
    for(int i = 0; i < n; i++) scanf("%lf", &y[i]);
    minc(x, y, n, 1);
    minc(x, y, n, 2);
    minc(x, y, n, 3);
    mincInf(x, y, n);
}


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

const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    vector<unsigned int> a(N);
    unsigned int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        sum ^= a[i];
    }
    for (int i = 0; i < N; ++i) {
        cout << (sum ^ a[i]) << endl;
    }
}


Measured memory_bytes: 4052
#include <iostream>
using namespace std;
long long gcd(long long n, long long m){
	if(n%m==0){
		return m;
	}else{
		return gcd(m, n%m);
	}
}
int main() {
	long long n, k, x, ans = 0;
	cin >> n >> k;
	cin >> x;
	ans = abs(x-k);
	for (int i=0; i<n-1; i++) {
		cin >> x;
		long long temp = abs(x-k);
		ans = gcd(ans, temp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=0;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;



string s;

int main() {
	cin>>s;

	if(s.substr(0,4)=="YAKI"){
		p("Yes");
	}else{
		p("No");
	}
	return 0;
}


Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize
    }
    println!("{}", (((n+1)/2) as f64) / (n as f64));
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
import sys

p=10**9+7

x,y=map(int,input().split())

if (x+y)%3!=0 or x>2*y or y>2*x:
    print(0)
    sys.exit()

a=(-x+2*y)//3
b=(2*x-y)//3

A=1
for i in range(1,a+1):
    A=A*i
    A=A%p
B=1
for i in range(1,b+1):
    B=B*i
    B=B%p

AB=1
for i in range(1,a+b+1):
    AB=AB*i
    AB=AB%p

C=(AB*pow(A,p-2,p)*pow(B,p-2,p))%p

print(C)

Measured memory_bytes: 3064
#include<stdio.h>

#define N 10000
#define Q 10000

int main() {
  int S[N];
  int T[Q];
  int i,j,x,y,count = 0;

  scanf("%d",&x);

  for(i = 0; i < x; i++) {
    scanf("%d",&S[i]);
  }

  scanf("%d",&y);

  for(i = 0; i < y; i++) {
    scanf("%d",&T[i]);
  }

  for(i = 0; i < y; i++) {
    for(j = 0; j < x; j++) {
      if(S[j] == T[i]) {
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, A, B, col, rem;
  cin >> N >> A >> B;
  col = N / (A + B);
  
    if(N % (A + B) >= A){
    rem = A;
    }
    else{
    rem = N % (A + B);
    }
  
  cout << col * A + rem << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
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
#define INF 1000000000000000000

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

    int A, B;
    cin >> A >> B;
    string s;
    cin >> s;
    if (count(all(s), '-') == 1 && s[A] == '-' && s.size() == A + B + 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
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;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;cin >> n;
    vector<int> a(n),b(1000010);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,1000010) b[i] = i;
    for(int i=0;i<n;i++){
	if(b[a[i]] == 0) b[a[i]] = -1;
	if(b[a[i]] == -1) continue;
	b[a[i]] = 0;
	for(int j=2*a[i];j<=1000000;j+=a[i]){
	    b[j] = -1;
	}
    }
    int ans = 0;
    for(int i=0;i<n;i++){
	if(b[a[i]] != -1) ans++; 
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
const int maxn = 3005, mod = 1e9 + 7;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n, m, f[maxn][maxn][2], fac[maxn << 1], ifac[maxn << 1];

int add(int a, int b) {return a + b >= mod ? a + b - mod : a + b;}

int C(int n, int m)
{
	return (ll)fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main()
{
	n = gi(); m = gi();

	fac[0] = ifac[0] = ifac[1] = 1;
	for (int i = 1; i <= n + m; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
	for (int i = 2; i <= n + m; ++i) ifac[i] = (ll)(mod - mod / i) * ifac[mod % i] % mod;
	for (int i = 1; i <= n + m; ++i) ifac[i] = (ll)ifac[i - 1] * ifac[i] % mod;
	
	for (int i = 0; i <= n; ++i) f[0][i][i == 0] = 1;

	for (int i = 0; i < m; ++i)
		for (int j = 0; j <= n; ++j)
			for (int k = 0; k < 2; ++k) {
				if (!f[i][j]) continue;
				if (j) f[i + 1][j - 1][k | (j == 1)] = add(f[i + 1][j - 1][k | (j == 1)], f[i][j][k]);
				if (j < n) f[i + 1][j + 1][k] = add(f[i + 1][j + 1][k], f[i][j][k]);
				if (j) f[i + 1][j][k | (j == 1)] = add(f[i + 1][j][k | (j == 1)], f[i][j][k]);
				if (j < n) f[i + 1][j][k] = add(f[i + 1][j][k], f[i][j][k]);
			}
	int ans = 0;
	for (int i = 0; i <= n; ++i) ans = add(ans, f[m][i][1]);
	printf("%d\n", ans);
	
	return 0;
}



Measured memory_bytes: 70784
#include <iostream>
#include <vector>
using namespace std;
int dx[8] = {1, 1, 1, 0, 0,-1,-1,-1};
int dy[8] = {1, 0,-1, 1,-1, 1, 0,-1};

int put(int turn, int x, int y, vector<vector<char> >& field, bool ischange){
    char c[2] = {'o', 'x'};
    field[x][y] = c[1-turn];
    int count=0;
    for(int i=0; i<8; i++){
        int tmpx=x+dx[i], tmpy=y+dy[i];
        int precount=0;
        while(field[tmpx][tmpy] == c[1-turn]){
            precount++;
            tmpx += dx[i];
            tmpy += dy[i];
        }
        if(field[tmpx][tmpy] == c[turn]){
            count+=precount;
            if(ischange){
                for(int j=0; j<precount; j++){
                    tmpx -= dx[i];
                    tmpy -= dy[i];
                    field[tmpx][tmpy] = c[turn];
                }
            }
        }
    }
    if(!ischange){
        field[x][y] = '.';
    }else{
        field[x][y] = c[turn];
    }
    return count;
}    

int main(){
    vector<vector<char> > field(10, vector<char>(10, 'E'));
    for(int i=1; i<=8; i++){
        for(int j=1; j<=8; j++){
            cin >> field[i][j];
        }
    }
    
    int turn = 0;
    for(int s=0; s<64; s++){
        int best=0;
        int x=0, y=0;
        for(int i=1; i<=8; i++){
            for(int j=1; j<=8; j++){
                if(field[i][j]!='.') continue;
                int eval = put(turn, i, j, field, false);
                if(eval +turn > best){
                    best = eval;
                    x = i;
                    y = j;
                }
            }
        }
        if(best!=0){
            put(turn, x, y, field, true);
        }
        turn = 1-turn;
    }

    for(int i=1; i<=8; i++){
        for(int j=1; j<=8; j++){
            cout << field[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

int bisect(int L, int R, int t, int a, int T, int A) {
  int mid = (L + R) / 2;
  if ((T * mid >= t && A * mid >= a) && !(T * (mid - 1) >= t && A * (mid - 1) >= a)) {
    return mid;
  } else if (T * (mid - 1) >= t && A * (mid - 1) >= a) {
    return bisect(L, mid, t, a, T, A);
  } else {
    return bisect(mid, R, t, a, T, A);
  }
}

signed main() {
  int N = in();
  vector<int> T(N);
  vector<int> A(N);
  rep(i, N) {
    cin >> T[i];
    cin >> A[i];
  }
  int t = T[0];
  int a = A[0];
  FOR(i, 1, N) {
    int mid = bisect(0, ((int)1e18) / max(A[i], T[i]), t, a, T[i], A[i]);
    t       = T[i] * mid;
    a       = A[i] * mid;
  }
  cout << a + t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1]=='1'){
        cout << "-1" << endl;
        return 0;
    }
    if(s[0]=='0'){
        cout << "-1" << endl;
        return 0;
    }
    rep(i,n/2){
        if(s[i]!=s[n-2-i]){
            cout << "-1" << endl;
            return 0;
        }
    }

    int now = 1;
    srep(i,1,n){
        cout << now << ' ' << i+1 << endl;
        if(n%2==0){
            if(n/2<=i){
                if(s[n-1-i]=='1'){
                    now = i+1;
                }
            }
        }else{
            if((n+1)/2<=i){
                if(s[n-1-i]=='1'){
                    now = i+1;
                }
            }
        }
    }

    return 0;
}
 
 


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
  int a,b ,c;
  cin >> a >> b >> c;
  if(a == b && b != c)
    cout << "Yes" << endl;
  else if(c == b && b != a)
    cout << "Yes" << endl;
  else if(a == c && c != b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
bool compar(const pair<string,ll> &a, const pair<string,ll> &b) 
{ 
    if(a.first==b.first)
    return (a.second < b.second);
    else
    return (a.first < b.first);
}

void comp()
{
	ll i,j,k,m,n,p,w,d,x,y;
	string s;
	cin>>s;
	n=s.length();
	string t="",u="";
	fl(i,n/2)
	{
		t+=s[i];
	}
	fli(i,n/2+1,n)
	{
		u+=s[i];
	}
	j=0;
	k=n/2-1;
	while(j<=k)
	{
		if(t[j]==t[k])
		{
			j++;
			k--;
		}
		else
		{
			break;
		}
	}
	if(j>k)
	{
		if(t==u)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
	else
	{
		cout<<"No\n";
	}

}

int main()
{
    speedup;
    ll i=0,t;
    ll n;
    //cin>>t;
    t=1;
	while(t--)
    {
    	i++;
    	//cout<<"Case #"<<i<<": ";
        comp();
    }
    return 0;
}


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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

int main(void) {
    int N;
    
    cin >> N;

    vector<int> div(N + 1, 1);
    long long ans = 1;

    for (int i = 2; i <= N; i++) {
        for (int j = i; j <= N; j += i) {
            div[j] += 1;
        }
        ans += div[i] * (long long) i;
    }

    cout << ans << "\n";

    return 0;
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m, t;
  cin >> n >> m >> t;
  vector<int> cnt_r(n + 1), cnt_c(m + 1);
  vector<pair<int, int>> input(t);
  for(int i = 0; i < t; ++i) {
    int x, y;
    cin >> x >> y;
    cnt_r[x] += 1;
    cnt_c[y] += 1;
    input[i] = {x, y};
  }
  int mx_r = *max_element(cnt_r.begin(), cnt_r.end());
  int mx_c = *max_element(cnt_c.begin(), cnt_c.end());
  set<int> best_r, best_c;
  for(int i = 1; i <= n; ++i) {
    if(cnt_r[i] == mx_r) best_r.insert(i);
  }
  for(int j = 1; j <= m; ++j) {
    if(cnt_c[j] == mx_c) best_c.insert(j);
  }
  int ans = mx_r + mx_c;
  int cnt = 0;
  for(auto [x, y] : input) {
    if(best_r.count(x) && best_c.count(y)) {
      cnt += 1;
    }
  }
  if(cnt == 1ll * best_r.size() * best_c.size()) {
    ans -= 1;
  }
  cout << ans << '\n';
}

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

int main() {
  string N;
  int K;
  cin >> N >> K;

  int Ndigits= N.size();
  vector<vector<int>> dp0(Ndigits+1, vector<int>(K+1)); // dp0.at(j).at(k)= #(上j桁がN未満である,0以外の数字がちょうどk個使われている整数)
  vector<vector<int>> dp1(Ndigits+1, vector<int>(K+1)); // dp1.at(j).at(k)= #(上j桁がNと一致する,0以外の数字がちょうどk個使われている整数)

  for(int i=1; i<Ndigits; i++){ dp0.at(i).at(0)= 1; }
  dp0.at(1).at(1)= N.at(0)- '1';
  dp1.at(1).at(1)= 1;
  for(int k=1; k<= K; k++){
    for(int i=2; i<= Ndigits; i++){
      if(N.at(i-1)=='0'){
        dp0.at(i).at(k)= 9* dp0.at(i-1).at(k-1)+ dp0.at(i-1).at(k);
        dp1.at(i).at(k)= dp1.at(i-1).at(k);
      }
      else{
        dp0.at(i).at(k)= 9* dp0.at(i-1).at(k-1)+ dp0.at(i-1).at(k)+ (N.at(i-1)-'1')* dp1.at(i-1).at(k-1)+ dp1.at(i-1).at(k);
        dp1.at(i).at(k)= dp1.at(i-1).at(k-1);
      }
    }
  }

  cout << dp0.at(Ndigits).at(K)+ dp1.at(Ndigits).at(K) << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double t = sc.nextDouble();
        double a = sc.nextDouble();
        double height[] = new double[n];
        double min = 1000;
        int index = 0;
        for(int i=0; i<n; i++){
            height[i] = sc.nextDouble();
            double temp = t - height[i]*0.006;
            if(Math.abs(a - temp) < min){
                min = Math.abs(a - temp);
                index = i+1;
            }
        }
        System.out.println(index);
    }
}

Measured memory_bytes: 28916
N, K = map(int, input().split())
P = [int(p) - 1 for p in input().split()]
C = list(map(int, input().split()))

max_score = -10 ** 9
for i in range(N):
    memo = set()
    score = 0
    cur = i
    move = 0

    while move < K and P[cur] not in memo:
        cur = P[cur]
        memo.add(cur)
        score += C[cur]
        move += 1
        max_score = max(score, max_score)

    if move < K and score > 0:
        score = max(K // move - 1, 1) * score
        move *= max(K // move - 1, 1)
        max_score = max(score, max_score)

        cur = i
        while move < K:
            cur = P[cur]
            score += C[cur]
            move += 1
            max_score = max(score, max_score)

print(max_score)

Measured memory_bytes: 116744
require 'set'

class Graph
	def initialize
		@nodes = Set.new
		@edges = Set.new
	end

	def add_node(label = nil)
		Node.new(label)
	end

	def add_edge(u, v)
		e = Edge.new(u, v)
		u.outgoings << e
		v.incomings << e
		e
	end
	
	def del_edge(e)
		u, v = e.from, e.to
		u.outgoings.delete(e)
		v.incomings.delete(e)
		e
	end

	class Node
		def initialize(label)
			@label = label
			@outgoings = Set.new
			@incomings = Set.new
		end
		
		def to_s
			@label
		end
		attr_accessor :incomings, :outgoings, :label
	end

	class Edge
		def initialize(u, v)
			@from = u	
			@to = v
		end
		attr_reader :from, :to
	end

	def get_path_dfs(s, t, reached = Set.new)
		reached << s	
		s.outgoings.each{|e|
			v = e.to
			next if reached.include?(v)
			return [e] if v == t
			
			path = get_path_dfs(v, t, reached) 
			return [e] + path if path
		}
		nil
	end
end

def get_ints
	gets.split.map(&:to_i)
end

loop {
	w, h = get_ints
	break if w == 0
	xs, ys = get_ints
	xg, yg = get_ints
	n = gets.to_i
	
	g = Graph.new 
	nodes = (0..h+1).map{ (0..w+1).map{ g.add_node(0) } }

	n.times {
		c, d, x, y = get_ints
		for i in y..y+(d==0 ? 2 : 4)
			for j in x..x+(d==0 ? 4 : 2)
				nodes[i][j].label = c
			end
		end
	}

	for y in 1..h
		for x in 1..w
			u = nodes[y][x]
			[[1,0], [-1,0], [0,1], [0,-1]].each{|dx, dy|
				v = nodes[y+dy][x+dx]
				g.add_edge(u, v) if u.label == v.label
			}
		end
	end

	s = nodes[ys][xs]
	if s.label > 0 && g.get_path_dfs(s, nodes[yg][xg])
		puts 'OK'
	else
		puts 'NG'
	end
}

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

void _140() {
    int n;
    cin >> n;

    int a[20];
    int b[20];
    int c[20];
    for (int i = 0; i < n; ++i) 
        cin >> a[i];
    for (int i = 0; i < n; ++i) 
        cin >> b[i];
    for (int i = 0; i < n - 1; ++i) 
        cin >> c[i];

    int score = 0;
    for (int i = 0; i < n - 1; ++i) {
        score += b[a[i] - 1];
        if (a[i + 1] == a[i] + 1) {
            score += c[a[i] - 1];
        }
        // cout << score << endl;
    }
    score += b[a[n - 1] - 1];

    cout << score << endl;
}

#include <string>
void _141() {
    string s;
    cin >> s;
    bool judge = true;
    for (int i = 0; i < s.size(); ++i) {
        if ((i + 1) % 2 == 0 && s[i] == 'R') {
            judge = false;
            break;
        } else if ((i + 1) % 2 == 1 && s[i] == 'L') {
            judge = false;
            break;
        }
    }

    if (judge) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    _141();
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
//#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<cassert>
/* 
struct Meirei{
    std::string mei;
    std::string str;
};


struct Node{
	Node(){
		umu=false;
		a=NULL;
		c=NULL;
		g=NULL;
		t=NULL;
	}
	~Node(){
		if(a)delete a;
		if(c)delete c;
		if(g)delete g;
		if(t)delete t;
//		std::cout << "a::" << a << ",g::" << g << ",c::" << c << ",t::" << t << std::endl;
	}
	bool umu;
	Node* a,*c,*g,*t;//?????°???????????°????????????????????????????????§?????????????????°????????????
};
class Tree
{
public:
	Tree(){
		m_root=new Node();
	}
	~Tree(){
		delete m_root;
	}
	void insert(std::string moji);
	bool find(std::string moji);
	
private:
	Node* m_root;
};

void Tree::insert(std::string moji)
{
//	m_root=new Node();
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL)	node->a = new Node();
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL)	node->c = new Node();
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL) node->g = new Node();
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL)	node->t = new Node();
			node = node->t;
		}else {
			assert(true);
		}
	}
	node->umu=true;
}
//---------------------------------
bool Tree::find(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL)	return false;
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL)	return false;
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL)	return false;
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL)	return false;
			node = node->t;
		}else {
			assert(true);
		}
	}
	if(node->umu)return true;
	return false;
}
*/
//typedef std::vector<MEIREI> VecMeirei;
//typedef std::vector<std::string> WORDS;
//typedef std::vector<bool> ARINASHI;
//void input();
//bool find(WORDS jisho, std::string str);
void output(bool result);
int a2i(std::string str);
//-------------------------------------------------------------------
int main()
{
    long n;
    std::cin >> n;
    //std::set<std::string> st;
	const int max_index = std::pow(5,12);
	std::vector<bool> vb(max_index,false); 
	for(int i=0; i<n; i++){
		std::string meirei;
	    std::cin >> meirei;
		std::string moji;
		std::cin >> moji;
		
		if(meirei=="insert"){
		    vb[a2i(moji)]=true;  //1??????insert???logn
	    }else if(meirei=="find"){
	     	output(vb[a2i(moji)]);
	    }
	}
    return 0;
}
//----------------------------------
int a2i(std::string str){
	int sum = 0;
	int num = 0;
	for(int i=0; i< str.size() ; i++){
		sum  *= 5;
		if(str[i]=='A'){ num = 1;}
		else if(str[i]=='C') {num = 2;}
		else if(str[i]=='G') {num = 3;}
		else if(str[i]=='T') {num = 4;}
		else {num = 0;}
		sum += num;
	}
	return sum;
}
//-------------------------------------------------------------------
void output(bool result)
{
    if(result){
        std::cout << "yes" << std::endl;
    }else{
        std::cout << "no" << std::endl;
    }
    return;
}
//-------------------------------------------------------------------

Measured memory_bytes: 32648
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLong()
    if (s == 1000000000000000000) {
        println("0 0 1000000000 0 0 1000000000")
    } else {
        val y = s / 1000000000 + 1
        val x = 1000000000 * y - s
        println("0 0 1000000000 1 $x $y")
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31260
sa=list(input())
sb=list(input())
sc=list(input())
t="a"
while True:
    if t=="a" and len(sa)==0:
        print("A")
        break
    elif t=="b" and len(sb)==0:
        print("B")
        break
    elif t=="c" and len(sc)==0:
        print("C")
        break
    elif t=="a":
        t=sa[0]
        del sa[0]
    elif t=="b":
        t=sb[0]
        del sb[0]
    elif t=="c":
        t=sc[0]
        del sc[0]        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
using namespace std;
int k,a[505][505],cs;
int main(){
	cin>>k;
	if(k<=500){
		printf("%d\n",k);
		fo(i,1,k){
			fo(j,1,k)printf("%d ",i);
			printf("\n");
		}
	}else{
		fo(i,1,500){
			if(i<=k-500){
				++cs;int g=0;
				fo(j,1,500-i+1)a[j][j+i-1]=(++g)&1?cs:cs+1;
				fo(j,1,i-1)a[501-i+j][j]=(++g)&1?cs:cs+1;
				++cs;
			}else{
				++cs;
				fo(j,1,500-i+1)a[j][j+i-1]=cs;
				fo(j,1,i-1)a[501-i+j][j]=cs;
			}
		}
		printf("500\n");
		fo(i,1,500){
			fo(j,1,500)printf("%d ",a[i][j]);
			printf("\n");
		}
	}
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] r = new int[n][2];
        int[][] b = new int[n][2];
        boolean[] buse = new boolean[n];
        for(int i=0; i<n; i++){
            r[i][0] = sc.nextInt();
            r[i][1] = sc.nextInt();            
        }
        for(int i=0; i<n; i++){
            b[i][0] = sc.nextInt();
            b[i][1] = sc.nextInt();       
            buse[i] = false;
        }
        sc.close();

        int ans = 0;

        MyComp comp = new MyComp();
        Arrays.sort(r, comp);

        for(int i=0; i<n; i++){
            int rx = r[n-i-1][0];
            int ry = r[n-i-1][1];
            int bymin = 1000;
            int byminpos = 0;
            for(int j=0; j<n; j++){
                if(b[j][0] > rx && b[j][1] > ry && b[j][1] < bymin && !buse[j]){
                    bymin = b[j][1];
                    byminpos = j;
                }
            }
            if(bymin != 1000){
                ans++;
                buse[byminpos] = true;
            }
        }

        System.out.println(ans);
    }
}

class MyComp implements Comparator{
    @Override
    public int compare(Object i1, Object i2){
        return ((int[])i1)[0] - ((int[])i2)[0];
    }
}


Measured memory_bytes: 24020
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 1001
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; }//1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; }//9,8,7,6
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; }//a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); }//aaa,aab
//temmie_のsnippet

int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	rep(t,101)rep(k,101)if(x==t+k&&y==2*t+k*4){printf("Yes");return 0;}
	printf("No");
}

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	int n, k;
	cin >> n >> k;
	int a[n];
	int foo;
	vi pos, neg;
	forn(i, 0, n) {
		cin >> foo;
		a[i] = foo;
		if(foo > 0) pos.pb(foo);
		else
			neg.pb(foo);
	}
	sort(all(pos));
	sort(all(neg));
	int nn = neg.size();
	if(pos.empty()) {
		ll ans = 1;

		for(int i = 0; i < k; ++i) {
			ll curr = 0;
			if(k & 1) { curr = neg[nn - 1 - i]; }
			else
				curr = neg[i];
			curr %= M;
			curr += M;
			ans = (ans * curr) % M;
		}
		cout << ans << endl;
		return 0;
	}
	int pA = n - 2;
	int pB = 0;
	sort(a, a + n);

	ll ans = 1;
	if(k & 1) {
		--k;
		ans *= a[n - 1];
		--pA;
	}
	k /= 2;

	while(k) {
		--k;
		ans %= M;
		ll A = (a[pB] * (ll)a[pB + 1]);
		ll B = (a[pA] * (ll)a[pA + 1]);
		if(A > B) {
			A %= M;
			ans = (ans * A) % M;
			pB += 2;
		}
		else {
			B %= M;
			ans = (ans * B) % M;
			pA -= 2;
		}
		ans %= M;
	}
	ans += M;
	ans %= M;
	cout << ans << '\n';

	return 0;
}

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

int main(){
    int N,M;
    while(cin >> N >> M, N!=0 && M!=0){
        vector<int> H;
        vector<int> W;
        int hSum = 0, wSum = 0;
        for(int i=0;i<N;i++){
            int h;
            cin >> h;
            hSum += h;
            H.emplace_back(hSum);
        }
        for(int i=0;i<M;i++){
            int w;
            cin >> w;
            wSum += w;
            W.emplace_back(wSum);
        }

        vector<int> h(1 << 23,0);
        reverse(W.begin(),W.end());
        reverse(H.begin(),H.end());
        W.emplace_back(0);
        H.emplace_back(0);
        for(int i=0;i<H.size();i++){
            for(int j=i+1;j<H.size();j++){
                h[H[i] - H[j]]++;
            }
        }

        int ans = 0;
        for(int i=0;i<W.size();i++){
            for(int j=i+1;j<W.size();j++){
                ans += h[W[i]-W[j]];
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 35732