akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}


int main() {

  long a,b,c;

  cin >>a >>b >>c;


  // bool ans = true;


  // for(int i=0;i<4;i++){
  //   if (count[i]>=3)ans=false;
  // }


  if ( b>= a*c){
    cout << c;
  }else{
    cout << b/a;
  }





  // if (ans){
  //   cout << "YES" <<endl;
  // }else{
  //   cout << "NO" <<endl;
  // }


}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
  int n;
  vector<int> c(500),s(500),f(500);
  cin >> n;
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
  for(int i=0;i<n;i++){
      int t=0;
      for(int j=i;j<n-1;j++){
          if(t<s[j]) t=s[j];
          else if(t%f[j] == 0);
          else t=t+f[j]-t%f[j];
          t+=c[j];
      }
      cout << t << endl;
  } 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==B){
        printf("%d",C);

    }
    else if (A==C){
            printf("%d",B);
    }
    else if(B==C){
        printf("%d",A);
    }
    return 0;
}


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

char mas[20][20];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int sx,sy;
int w,h,cnt;

void dfs(int x,int y);

int main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>mas[i][j];
	if(mas[i][j]=='@'){
	  sx=j;
	  sy=i;
	}
      }
    }
    cnt=0;
    dfs(sx,sy);
    cout<<cnt<<endl;
  }
}

void dfs(int x,int y){
  mas[y][x]='#';
  cnt++;
  for(int i=0;i<4;i++){
    int nextx=x+dx[i];
    int nexty=y+dy[i];
    if(0<=nextx && nextx<w && 0<=nexty && nexty<h && mas[nexty][nextx]=='.'){
      dfs(nextx,nexty);
    }
  }
  return;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double f80;
 
// #define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ef emplace_front
#ifndef LOCAL
#define endl '\n'
#endif

typedef long long ll;
const int mod = 1e9 + 7;
const int mod1 = 1e6;

ll pwr(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int N = 2e5 + 5;
int dp[N][705];
 
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    int n = sz(s);
    s = '0' + s;
    fr(i, 0, n - 1) {
        fr(j, 0, 702) {
            int val = s[i + 1] - 'a' + 1;
            if(val != j) {
                dp[i + 1][val] = max(dp[i + 1][val], dp[i][j] + 1);
            }
            if(i < n - 2) {
                val = (s[i + 1] - 'a' + 1) + 26 * (s[i + 2] - 'a' + 1);
                dp[i + 2][val] = max(dp[i + 2][val], dp[i][j] + 1);
            }
        }
    }
    int ans = 0;
    fr(i, 0, 702) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 551376
n = int(input())
list = input().split()

for t in range(len(list)):
    list[t] = int(list[t])

cnt = 0

for idx in range(n):
    for t in range(101):
        if 0 != list[idx]:
            t_cnt = min(list[idx:n])
            idx2 = n
            if t_cnt == 0:
                idx2 = list[idx:n].index(0) + idx
                t_cnt = min(list[idx:idx2])
            for idx3 in range(idx,idx2):
                list[idx3] = list[idx3] - t_cnt
            cnt += t_cnt
        else:
            break
        
print(cnt)


Measured memory_bytes: 3064
import math
A,B,H,M=map(int,input().split())
#H時M分
#分の場所
theta_min=(360/60)*M
theta_hour=(360/12)*(H+M/60)
theta=abs(theta_min-theta_hour)
print( math.sqrt(A**2+B**2 - 2*A*B*math.cos(math.radians(min(theta,360-theta)))) )

Measured memory_bytes: 9448
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    for(int i=0; i<m ; ++i){
        cin >> l[i] >> r[i];
    }
    auto maxl = *max_element(l.begin(),l.end());
    auto minr = *min_element(r.begin(),r.end());
    cout << max(minr - maxl + 1, 0) << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		if ((C >= A && C <= B) || (C >= B && C <= A)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		scanner.close();
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int a[N];
int main(){
	int n,k;
//	for(int i=1;i<N;i++) a[i]=i;
	while(cin >> n){
		for(int i=1;i<=n;i++){
			cin >> k;
			a[k]=i;
		}
		printf("%d",a[1]);
		for(int i=2;i<=n;i++) printf(" %d",a[i]);
		cout << endl;
	}
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//
//ナップサック問題Ｄ
//
namespace EDPCD
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int W = int.Parse(input[1]);
            int[] w = new int[N + 1];
            long[] v = new long[N + 1];
            long[,] DP = new long[N + 1,W+1];
            List<long> ans = new List<long>();
            //DPの準備
            for (int i = 0; i <= W; i++)
            {
                DP[0, i] = 0;
            }
            //重さと価値の読み込み
            for (int i = 1; i <= N; i++)
            {
                string[] inputWV = Console.ReadLine().Split(' ');
                w[i] = int.Parse(inputWV[0]);//重さ
                v[i] = long.Parse(inputWV[1]);//価値
                for (int j = 0; j <= W; j++)
                {
                    if (j < w[i])
                    {
                        DP[i, j] = DP[i - 1, j];
                    }
                    else
                    {
                        DP[i, j] =Math.Max(DP[i-1,j-w[i]]+v[i],DP[i-1,j]);
                    }
                    //Console.Write(DP[i,j]+" ");
                    ans.Add(DP[i, j]);
                }
            }
                    Console.WriteLine(ans.Max());
        }
    }
}


Measured memory_bytes: 235524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  string s; cin>>s;
  rep(i,5) cout<<s.at(i);
  cout<<" ";
  rep(j,7) cout<<s.at(j+6);
  cout<<" ";
  rep(k,5) cout<<s.at(k+14);
  cout<<endl;
}

Measured memory_bytes: 256
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int main(){
    ll N,K; scanf(" %lld %lld",&N,&K);
  if(N*500 >= K ) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){

    int l, n, i, j, count = 0;
    double x;

    scanf("%d", &l); 

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

        scanf("%d", &n); 

        x = sqrt(n);

        if (n ==2 || n == 3){
            count++;
        }

        for (j = 2; j <= x+1; j++) {
            if (n%j == 0 || n%2 == 0 || n%5 == 0) {
                break;
            }
            else if (j >= x){
                count++;
                break;
            }
        }
    }

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

    return 0;
}


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

int main(){

int x,a,b,s,t;
cin>>x;
cin>>a;
cin>>b;

s=abs(x-a);
t=abs(x-b);

if(s>t){
    cout<<"B";
}
else{
    cout<<"A";
}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;


 
signed main()
{
    haha
   int n,a,b;
   cin>>n>>a>>b;
   int x=a+b;
   int y=n%x;
   int z=n/x;
   int ans=z*a;
   if(y<a)
   ans+=y;
   else
   ans+=a;
   cout<<ans;
  
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

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

    int cnt=0;
    for(int i=0;i<n;i++){
        while(a[i]%2==0){
            cnt++;
            a[i]/=2;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int H, W, i, j = 0;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if((i + j) % 2 == 1){
					printf(".");
				} else {
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}
	
	


Measured memory_bytes: 2064
N=int(input())
A=list(map(int,input().split()))
A=[0]+A+[0]
C=0
p=0
for i in range(1,N+2):
    C+=abs(A[i]-p)
    p=A[i]

for i in range(1,N+1):
    print(C-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))


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

int main(){
    int L,R,d;
    cin >> L >> R >> d;

    int ans = 0;
    int x = L/d;
    int y = R/d;

    ans = y - x;

    if(L%d == 0) ans++;

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

Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
  int n;double sum;
  double x[10],y[10];
  vector<int> v;
signed main(){
  cin>>n;
  rep(i,n)cin>>x[i]>>y[i];
  rep(i,n)v.push_back(i);
  double cnt = 0;
  do{
    rep(i,n-1){
      sum += sqrt((x[v[i+1]]-x[v[i]])*(x[v[i+1]]-x[v[i]]) + (y[v[i+1]]-y[v[i]])*(y[v[i+1]]-y[v[i]]));
    }
    cnt += 1.0;
  }while(next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(10) << sum/cnt << endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  string ans = "NO";
  
  for (int i = 1; i < 1000; i++){
  if ( (a * i) % b == c ){
    ans = "YES";
    break;
  }
    else{
      continue;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct e{
    int nxt,to,sum;
}edge[100005];
int head[10005];
int tot=0;
void add_edge(int u,int v,int w){
    tot++;
    edge[tot].nxt=head[u];
    edge[tot].to=v;
    edge[tot].sum=w;
    head[u]=tot;
    return ;
};
struct node{
    int v,w;
};
int dis[10005];
struct cmp{
    bool operator () (node a,node b){
        return a.w>b.w;
    }
};
int vis[10005];
void dij(int from){
    priority_queue<node,vector<node>,cmp> q;
    for(int i=1;i<=10005;i++){
        dis[i]=999999999;
        vis[i]=0;
    }
    node now,nxt;
    now.v=from;
    now.w=0;
    dis[now.v]=0;
    q.push(now);
    while(!q.empty()){
        now=q.top();
        q.pop();
        if(vis[now.v])continue;
        vis[now.v]=1;
        for(int i=head[now.v];i;i=edge[i].nxt){
            nxt.v=edge[i].to;
            if(dis[nxt.v]>dis[now.v]+edge[i].sum){
                dis[nxt.v]=dis[now.v]+edge[i].sum;
                nxt.w=dis[nxt.v];
                q.push(nxt);
            }
        }
    }
    return ;
}
int cnt[10005];
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
        add_edge(i,i+1,1);
        add_edge(i+1,i,1);
    }
    add_edge(x,y,1);
    add_edge(y,x,1);
    for(int i=1;i<=n;i++){
        dij(i);
        for(int j=i+1;j<=n;j++){
//            cout<<"from "<<i<<" to "<<j<<"="<<dis[j]<<endl;
            cnt[dis[j]]++;
        }
    }
    for(int i=1;i<=n-1;i++){
        cout<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <assert.h>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template <typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++)
        s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    if (B < A) swap(A, B);

    for (ll x = 0; x <= N - 1; x++) { // あげる回数
        ll y = N - 1 - x;
        ll lb = A + C * x - D * y, ub = A + D * x - C * y;
        if (lb <= B && B <= ub) {
            // cerr << "x: " << x << endl;
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
# input
N, X, Y = map(int, input().split())

# process
ans = [0]*(N-1)
for i in range(N-1):
    for j in range(i+1, N):
        d1 = j-i - 1
        d2 = abs(Y-1-j) + abs(X-1-i)
        ans[min(d1, d2, N-2)] += 1

# output
for a in ans:
    print(a)


Measured memory_bytes: 3444
#include<cctype>
#include<cstdio>

int main(void){
  char ch;

  while(1){
    scanf("%c",&ch);
    if(isalpha(ch)){
      if(islower(ch))printf("%c",toupper(ch));
      else printf("%c",tolower(ch));
    }else printf("%c",ch);

    if(ch=='\n')break;
  }
}



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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repc(i, a, b, c) for (int i = a; i < b; i += c)
#define mp make_pair
#define vec(type, name) vector< type > name
#define vecp(type1, type2, name) vector< pair < type1, type2 > >name
#define pb push_back
#define all(name) (name.begin(), name.end())
#define itt(name_con, name_it) auto name_it = name_con.begin()
#define repit(name_con, name_it)for(itt(name_con, name_it); name_it != name_con.end(); name_it++)

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		ll a, b, c, d, ans = 0;
		cin >> a >> b >> c >> d;
		ans += b/c - (a-1)/c;
		ans += b/d - (a-1)/d;
		c = (c*d)/__gcd(c, d);
		ans -= b/c - (a-1)/c;
		cout << (b-a+1)-ans;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 100;
int dp[max_n][max_n];
ll n,h;
int main(){
  cin >> n >> h;
  ll b[n];
  ll ama = 0;
  for(int i=0 ; i<n ; i++){
    ll x;
    cin >> x >> b[i];
    ama = max(x, ama);
  }
  sort(b, b+n);
  reverse(b, b+n);
  ll cnt = 0;
  ll i = 0;
  while(ama <= b[i] && i<n){
    cnt++;
    h -= b[i++];
    if(h<=0){
      cout << cnt << endl;
      return 0;
    }
  }
  ll k = (h+ama-1)/ama;
  cnt += k;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, ans;
    ans = 1;
    cin >> a >> b;
    while(a * 2 <= b){
        a *= 2;
        ans ++;
    }
    cout << ans <<"\n";
    return 0;
}


Measured memory_bytes: 256
class DisjointSet:
    def __init__(self, size):
        self.p = [i for i in range(size)]
        self.rank = [0] * size

    def same(self, x, y):
        return self.find_set(x) == self.find_set(y)

    def unite(self, x, y):
        self.link(self.find_set(x), self.find_set(y))

    def link(self, x, y):
        if self.rank[y] < self.rank[x]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def find_set(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_set(self.p[x])
        return self.p[x]

n, q = map(int, input().split())
ds = DisjointSet(n)
for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        ds.unite(x, y)
    if com == 1:
        print(1 if ds.same(x, y) else 0)



Measured memory_bytes: 6036
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	char X, Y;
	std::cin >> X >> Y;
	if (X > Y) {
		std::cout << ">";
	}
	else if (X < Y) {
		std::cout << "<";
	}
	else {
		std::cout << "=";
	}
	std::cout << endl;

	return 0;
}


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

#define ll long long

ll five(ll a) {
  return a * a * a * a * a;
}

int main() {
  ll X;
  cin >> X;
  
  for (ll a = 0; a <= 1000; a++) {
    for (ll b = -100; b <= 1000; b++) {
      if (five(a) - five(b) == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  
}

Measured memory_bytes: 3584
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;
	char sa[200000+3], *s=sa+1;

	while(scanf("%d\n%[.#]\n", &n, s+1)==2)
	{
		vi wc(n+2), bc(n+2);

		for(int i=1;i<=n;i++)
		{
			bc[i]=bc[i-1];
			if(s[i]=='#') bc[i]++;
		}
		for(int i=n;i>0;i--)
		{
			wc[i]=wc[i+1];
			if(s[i]=='.') wc[i]++;
		}
		int ans=n;
		for(int i=1;i<=n;i++)
		{
			int t=bc[i]+wc[i]-1;
			if(ans>t) ans=t;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2048
N = int(input())
A = [int(input()) for i in range(N)]
A_copy = A[:]
A_copy.sort()
# print(A, A_sort)
A_max = A_copy[len(A_copy)-1]
A_second = A_copy[len(A_copy)-2]
for i in range(N):
    if A[i] != A_max:
        print(A_max)
    else:
        print(A_second)

Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, M;
    cin >> N >> M;

    int res = 0;
    res += min(N, M/2);
    M -= res*2;
    res += M/4;

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define my_all(v) v.begin(),v.end()
#define my_un(v) v.erase(unique(ALL(v)),v.end())
#define my_each(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,m,k,sx,sy,ans=INT_MAX;
bool vis[805][805],b[805][805];
int dist[805][805];
char t;
void swap_int(int &a,int &b)
{
	a^=b;
	b^=a;
	a^=b;
}
bool inrange(int x,int y)
{
	return x>0&&x<=n&&y>0&&y<=m;
}
queue<pii> q,ostep;
int main()
{
	memset(dist,-1,sizeof(dist));
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			t=getchar();
			while(t!='#'&&t!='S'&&t!='.')
			{
				t=getchar();
			}
			b[i][j]=(t=='#');
			if(t=='S')
			{
				sx=i,sy=j;
			}
		}
	}
	q.push(pii(sx,sy));
	dist[sx][sy]=0;
	while(!q.empty())
	{
		pii fr=q.front();
		q.pop();
		int x=fr.first,y=fr.second;
		if(dist[x][y]<=k)
		{
			ostep.push(fr);
		}
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir],ny=y+dy[dir];
			if(inrange(nx,ny))
			{
				if(dist[nx][ny]==-1&&!b[nx][ny])
				{
					dist[nx][ny]=dist[x][y]+1;
					q.push(pii(nx,ny));
				}
			}
		}
	}
	memset(dist,-1,sizeof(dist));
	while(!ostep.empty())
	{
		pii p=ostep.front();
		ostep.pop();
		q.push(p);
		dist[p.first][p.second]=0;
	}
	while(!q.empty())
	{
		pii fr=q.front();
		q.pop();
		int x=fr.first,y=fr.second;
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir],ny=y+dy[dir];
			if(inrange(nx,ny))
			{
				if(dist[nx][ny]==-1)
				{
					dist[nx][ny]=dist[x][y]+1;
					q.push(pii(nx,ny));
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(i==n||j==m||i==1||j==1)
			{
				ans=min(ans,dist[i][j]);
			}
		}
	}
	ans=(ans+k-1)/k+1;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 8704
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int x,y,s;
	while(cin>>x>>y>>s,x+y+s!=0){
		int ans=0;
		for(int i=1;i<=s;i++){
			for(int j=1;j<=s;j++){
				int a=i*(100+x)/100,b=j*(100+x)/100;
				if(a+b==s){
					ans=max(ans,i*(100+y)/100+j*(100+y)/100);
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <cmath>
#include<iomanip>

//関数の宣言
int scoreSum(int n, int* pt);
double scoreApostasis(int n,double average, int* pt);

int main(){

	int n;
	int* pt;
	int sum;
	double average;
	double apostasis;
	double standardDeviation;


	while (true){
		std::cin >> n;

		if (n == 0){
			break;
		}

		pt = new int[n];

		for (int i = 0; i < n; ++i){
			std::cin >> pt[i];
		}

		sum = scoreSum(n, pt);
		average = (double)sum / (double)n;
		apostasis = scoreApostasis(n, average, pt);
		standardDeviation = std::sqrt(apostasis);

		std::cout <<std::fixed<<std::setprecision(10)<< standardDeviation << std::endl;

		delete[]pt;
	}
	
	return 0;
}

//関数の定義

int scoreSum(int n, int* pt){

	int scoreSum=0;

	for (int i = 0; i < n; ++i){
		scoreSum += pt[i];
	}
	return scoreSum;
}

double scoreApostasis(int n,double average, int* pt){

	double scoreApostasis=0;

	for (int i = 0; i < n; ++i){
		scoreApostasis += (pt[i] - average)*(pt[i] - average);
	}
	return scoreApostasis/n;
}


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

using namespace std;

int main(void) {
  string t, p;
  cin >> t >> p;

  int tz = t.size(), pz = p.size();
  vector<bool> f(tz);
  for (int i = 0; i < tz; i++) {
    bool flag = true;
    for (int j = 0; j < pz; j++) {
      flag &= t[i + j] == p[j];
    }
    f[i] = flag;
  }

  for (int i = 0; i < tz; i++) {
    if (!f[i]) continue;
    cout << i << endl;
  }

  return 0;
}


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

int64_t pw2(int k){
    return 1LL<<k;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int64_t ans = 0;
    int now = 0;
    for(int a : A){
        int low = 0;
        while(pw2(low+1) <= a) low++;
        int high = low + (pw2(low) < a);
        if(high <= now){
            now = low;
        }else{
            ans += high - now;
            now = high;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>
#include<map>

using namespace std;

long long i,j,k,n,m,N,K,A[101]={0},ans;

int main()
{
  cin>>N>>K;
  for(i=0;i<K;i++)
  {
    cin>>j;
    for(n=0;n<j;n++)
    {
      cin>>m;
      m--;
      A[m]=1;
    }
  }
  
  ans=N;
  for(i=0;i<N;i++)
  {
    ans-=A[i];
  }
  cout<<ans;
  
}

Measured memory_bytes: 3632
#include<cstdio>
using namespace std;
int A[1000];
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=999;i++) A[i]=A[i-1]+i;
	printf("%d\n",A[b-a]-b);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 1000000

int p[ N ] = { 1, 1, 0 };

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( j = 2; j < N; ++j )
  {
    if ( p[ j ] ) continue ;

    for ( i = j * 2; i < N; i += j )
    {
      p[ i ] = 1;
    }
  }

  for ( ; ; )
  {
    int a, d, n;

    scanf ( "%d%d%d", &a, &d, &n );
    if ( !( a | d | n ) ) break ;

    for ( ; n; a += d )
    {
      n -= !p[ a ];
    }

    printf ( "%d\n", a - d );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	char s[16];
	int a,b;
	scanf("%d",&a);
	while(scanf("%s",s) , s[0] != '='){
		scanf("%d",&b);
		if(s[0] == '+'){
			a+=b;
		}
		if(s[0] == '-'){
			a-=b;
		}
		if(s[0] == '*'){
			a*=b;
		}
		if(s[0] == '/'){
			a/=b;
		}
	}
	printf("%d\n",a);
	return 0;
}

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

int main(){
    int N,M; cin>>N>>M;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    int sum=0;
    rep(i,N) sum+=A[i];
    sort(A.begin(),A.end(), greater<int>());
    if (A[M-1]*4*M>=sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
} 

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    return fact[n]*inv[n-k]%mod;
}

int dp[17][1<<16];

int N,M;
int A[22];

signed main(){
    cin>>N>>M;
    rep(i,M)cin>>A[i];
    reverse(A,A+M);

    dp[0][0]=1;

    rep(i,M){
        rep(j,1<<N){
            add(dp[i+1][j],dp[i][j]);
            int w=(1<<N)-A[i];
            rep(k,N)if(j>>k&1)w-=1<<k;
            rep(k,N)if(!(j>>k&1)&&(1<<k)<=w+1)add(dp[i+1][j|(1<<k)],dp[i][j]*nCk(w,(1<<k)-1)%mod);
        }
    }

    int ans=0;
    rep(i,1<<N){
        int w=(1<<N)-1;
        rep(j,N)if(i>>j&1)w-=1<<j;

        int tmp=dp[M][i];
        rep(j,N)if(!(i>>j&1)){
            tmp=tmp*nCk(w,1<<j)%mod;
            w-=1<<j;
        }

        if(__builtin_popcount(i)&1)ans=(ans-tmp+mod)%mod;
        else ans=(ans+tmp)%mod;
    }


    rep(i,N)ans=ans*fact[1<<i]%mod;
    ans=ans*(1<<N)%mod;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define long long long

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    
    if (a + b + c <= 21) {
        cout << "win";
    } else {
        cout << "bust";
    }

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans = [0]*n


rside=0
lside=0

rpoint=0
lpoint=0

radd = 0
ladd = 0

left = 0
right=0
while right<n:
    if right == n-1:
        ladd = (rpoint - left + 1 ) // 2 +1
        radd = rpoint - left + 1 - ladd

        radd +=  (right - lpoint + 1) // 2 + 1
        ladd +=  (right - lpoint + 1) - ((right - lpoint + 1) // 2 + 1)

        ans[rpoint] += radd
        ans[lpoint] += ladd


    elif s[right] =='R' and s[right+1] == 'L':
        rpoint = right
        lpoint = right+1
    elif s[right] =='L' and s[right+1] == 'R' :
        ladd = (rpoint - left + 1 ) // 2 + 1
        radd = rpoint - left + 1 - ladd

        radd +=  (right - lpoint + 1) // 2 + 1
        ladd +=  (right - lpoint + 1) - ((right - lpoint + 1) // 2 + 1)

        ans[rpoint] += radd
        ans[lpoint] += ladd

        left = right+1
        
    right += 1

print(*ans)

Measured memory_bytes: 6512
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

char s[114514];
char t[114514];

int mofu[26];
int* nyan[26];

int main(void) {
	int i;
	int slen;
	int zyun = 0, seek = 0;
	if (scanf("%114513s", s) != 1) return 1;
	if (scanf("%114513s", t) != 1) return 1;
	for (i = 0; s[i] != '\0'; i++) {
		int idx = s[i] - 'a';
		if (0 <= idx && idx < 26) {
			nyan[idx] = realloc(nyan[idx], sizeof(*nyan[idx]) * (mofu[idx] + 1));
			if (nyan[idx] == NULL) return 2;
			nyan[idx][mofu[idx]++] = i;
		}
	}
	slen = i;
	for (i = 0; t[i] != '\0'; i++) {
		int idx = t[i] - 'a';
		if (0 <= idx && idx < 26) {
			if (mofu[idx] <= 0) {
				puts("-1");
				return 0;
			}
			if (nyan[idx][mofu[idx] - 1] < seek) {
				zyun++;
				seek = nyan[idx][0] + 1;
			} else if (seek <= nyan[idx][0]) {
				seek = nyan[idx][0] + 1;
			} else {
				int less = 0, ge = mofu[idx] - 1;
				while (less + 1 < ge) {
					int mid = less + (ge - less) / 2;
					if (seek <= nyan[idx][mid]) ge = mid; else less = mid;
				}
				seek = nyan[idx][ge] + 1;
			}
			if (seek >= slen) {
				zyun++;
				seek = 0;
			}
		} else {
			puts("-1");
			return 0;
		}
	}
	printf("%" PRId64 "\n", (int64_t)zyun * slen + seek);
	return 0;
}

/*

abab
aa

abab
aba

abab
ba

abab
bb

*/


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

#define repeat1_plc(i,n) for (i = 1; i < (n); ++i)

#ifdef DEBUG
#include <cassert>
#define debug(a) a
#else
#define debug(a)
#endif

#define MAX_H 100
#define MAX_W 100

struct rect { int h, w; };
int sq(int a) { return a * a; }
int sqhypot(int a, int b) { return sq(a) + sq(b); }
int sqhypot(const rect & p) { return sqhypot(p.w, p.h); }
bool operator < (const rect & a, const rect & b) {
    int ar = sqhypot(a), br = sqhypot(b);
    return ar != br ? ar < br : a.h < b.h;
}

int main() {
    while (true) {
        rect r; cin >> r.h >> r.w;
        if (not r.h or not r.w) break;
        debug(assert(r.h < r.w));
        rect acc = { MAX_H * MAX_W, MAX_H * MAX_W };
        {
            int diag = ceil(sqrt(sqhypot(r)));
            rect s;
            repeat1_plc (s.w, diag+1) repeat1_plc (s.h, s.w) {
                if (r < s and s < acc) {
                    acc = s;
                    break;
                }
            }
        }
        cout << acc.h << ' ' << acc.w << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
import sys

a = 'abcdefghijklmnopqrstuvwxyz'
for i in sys.stdin.readlines():
    s = i.strip()
    for j in range(1, 27):
        t = s.translate(str.maketrans(a, a[j:] + a[:j]))
        if 'the' in t or 'this' in t or 'that' in t:
            print(t)

Measured memory_bytes: 7260
#include <stdio.h>

int main(){
  int a,b,c,d,e,f,g,h;
  scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h);
  printf("%d\n",a+b+c+d>e+f+g+h?a+b+c+d:e+f+g+h);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int N, M;
    cin >> N >> M;
    int l[101000], r[101000];
    for(int i = 0; i < M; i++){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    int x = 0, y = N-1;
    for(int i = 0; i < M; i++){
        x = max(x, l[i]);
        y = min(y, r[i]);
    }

    if(y < x){
        cout << 0 << endl;
    }
    else {
        cout << y - x + 1 << endl;
    }


    return 0;
}


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

using namespace std;
using ll = long long;

ll solve(ll t) {
    ll lt = 0;
    ll s = 1;
    ll step = 0;
    while(true) {
        ll nt = lt + 4 * s;
        if(nt>t) break;
        lt = nt;
        s *= 3;
        step += 2;
    }
    // s is max_speed
    // lt is min_t with max_speed=s
    ll r = t - lt;
    while(r>0) {
        ll p = r / s;
        step += p;
        r -= p * s;
        s /= 3;
    }
    return step;
}

int main() {
    ll t;
    cin >> t;
    cout << solve(t) << endl;
}



Measured memory_bytes: 3128
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> b>>c;
    cout << b*c-b-c+1<< "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int> ;
#define pal pair < ll, ll> ;
#define vi vector <int> ;
#define vl vector < ll > ;
#define vpai vector < pii > ;

const int mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 3005;

ll dp[sze][sze];

void solve() {
    mem(dp);
    int n;
    cin>>n;
    ll arr[n];
    ll sum=0;
    rep(i,n) {
        cin>>arr[i];
        sum+=arr[i];
    }
    rep(i,n) dp[i][i]=arr[i];
    rep(i,n-1){
        dp[i][i+1]=max(arr[i],arr[i+1]);
    }

    // rep(i,n){
    //     rep(j,n){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    repn(len,3,n){
        for(int i=0;i<=n-len;i++){
            int j=i+len-1;
            ll x=dp[i+2][j];
            ll y=dp[i+1][j-1]; 
            ll z=dp[i][j-2];
            dp[i][j]=max(arr[i]+min(x,y),arr[j]+min(y,z));
            // cout<<i<<" "<<j<<" "<<x<<" "<<y<<" "<<len<<endl;
        }
    }

    cout<<-sum+2*dp[0][n-1]<<endl;
}


int main() {
    IOS;

    int t = 1;
    //cin >> t;
    while (t--) {
       solve();
    }

  return 0;
}

Measured memory_bytes: 74240
def isMM(s):
  n = int(s)
  if 0 < n <13:
    return True
  return False

s = raw_input()
s1 = s[:2]
s2 = s[2:]
ans = "NA"
if isMM(s2):
  if isMM(s1):
    ans = "AMBIGUOUS"
  else:
    ans = "YYMM"
else:
  if isMM(s1):
    ans = "MMYY"
    
print ans

Measured memory_bytes: 2568
#include <stdio.h>

int main(void) {
	int n;
	int i;
	int debt = 100000;
	

	scanf("%d", &n);

	for(i = 0; i < n; i++) {
		debt *= 105;
		debt /= 100;
		if(debt%1000) {
			debt /= 1000;
			debt ++;
			debt *= 1000;
		}
	}
	printf("%d\n", debt);

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double answer = 0;

		for (int i = 1; i <= N; i++) {
			int sum = i;
			int count = 0;
			while (sum <= K - 1) {
				sum *= 2;
				count++;
			}

			answer += (double)1/N * Math.pow((double)1/2, count);

		}

		System.out.println(answer);

	}
}


Measured memory_bytes: 22996
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int[] p = {a+b, a-b, a*b};
    Arrays.sort(p);
    System.out.println(p[2]);
  }
}

Measured memory_bytes: 35668
//_Krenil_Bhikadiya_

#include<bits/stdc++.h>
#define MAX_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define max(a,b) (a<b?b:a) 
#define min(a,b) (a>b?b:a) 
#define ll long long
#define ld long double
#define llu unsigned long long int
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define umap unordered_map
#define uset unordered_set
#define rep(i,a,n) for(int i=(int)a;i<(int)n;i++)
#define rev(i,n,a) for(int i=(int)n;i>=(int)a;i--)
#define pb push_back
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
const int INF  = 1e9;
const llu INFM = 1e18;
const int mod  = INF+7;
using namespace std;


int gcd(int A,int B)
{
	if(A==0) return B;

	return gcd(B%A,A);
}

int lcm(int A,int B)
{
	return ( A*B / gcd(A,B) );
}

ll mod_pwr(ll A,ll B,ll P)
{
	ll RES = 1; A %= P;

	while(B>0)
	{
		if(B&1) RES = RES * A % P;
		A = A * A % P;
		B >>= 1;
	}

	return RES;
}

llu pwr(llu A,llu B)
{
	llu RES=1;

	while(B>0)
	{
		if(B&1) RES*=A;
		A=A*A;
		B>>=1;
	}

	return RES;
}

ll modInv(ll A,ll M)
{
	return mod_pwr(A,M-2,M);
}

bool isPrime(int N)
{
	if(N==1) return false;

	for(int i=2;i*i<=N;i++)
	{
		if(N%i==0) return false;
	}

	return true;
}

ll dp[101][100001];

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	MAX_SPEED
	
	int test=1; //cin>>test;
	while(test--)
	{
		int N,W; cin>>N>>W;

		vi wt(N+1),val(N+1);

		rep(i,0,N) cin>>wt[i]>>val[i];

		rep(i,1,N+1)
		{
			rep(j,1,W+1)
			{
				if(wt[i-1]<=j)
				{
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
				}
				else dp[i][j]=dp[i-1][j];
			}
		}
		cout<<dp[N][W]<<endl;
	}
}

Measured memory_bytes: 81728
import static java.lang.System.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double c = (double)a / (double)b;
		out.println(a / b + " " + a % b + " " + String.format("%.5f",c));
	}
}


Measured memory_bytes: 26556
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100000

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

int main(void) {
  int N;
  scanf("%d", &N);
  int d[MAX_N];
  for(int i = 0; i < N; i++) {
    scanf("%d", &d[i]);
  }
  qsort(d, N, sizeof(int), int_sort);

  int lp = (N-1) / 2;
  int rp = lp + 1;
  int num = d[rp] - d[lp];
  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  vector<string> s(n);
  string mins = "";
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  string ans = "";

  sort(s[0].begin(), s[0].end());

  for (int i = 0; i < s[0].size(); i++) {
    if (i != 0 && s[0][i] == s[0][i - 1]) continue;  // 同じ文字はスキップ

    string base = s[0];
    char target = base[i];
    int minx = count(base.begin(), base.end(), target);

    for (int j = 1; j < n; j++) {
      string str = s[j];

      int sum = count(str.begin(), str.end(), target);
      minx = min(minx, sum);
    }

    for (int k = 0; k < minx; k++) {
      ans += target;
    }
  }

  sort(ans.begin(), ans.end());

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int i,j,k,l;
    int t,n;
    int s,f;
    int sum;
    
    while(true){
        sum=0;
        cin>>t;
        if(t==0)break;
        cin>>n;
        for(i=0;i<n;i++){
            cin>>s>>f;
            sum+=f-s;
        }
        if(sum>=t){
            cout<<"OK"<<endl;
        }else{
            cout<<t-sum<<endl;
        }
    }
    return(0);
}

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

using namespace std;

#define int int64_t

typedef int64_t ftype;
typedef complex<ftype> point;
#define x real
#define y imag

ftype dot(point a, point b)
{
	return (conj(a) * b).x();
}

ftype cross(point a, point b)
{
	return (conj(a) * b).y();
}

const int mod = 998244353;

void add_mod(int &a, int b)
{
	a += b;
	while(a >= mod)
		a -= mod;
	while(a < 0)
		a += mod;
}

signed main()
{
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	point r[n];
	for(int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		r[i] = {x, y};
	}
	int ans = 0;
	for(int s = 0; s < n; s++)
	{
		point o = r[s];
		vector<point> pts;
		for(int i = 0; i < n; i++)
			if(r[i].y() > o.y() || r[i].y() == o.y() && r[i].x() > o.x())
				pts.push_back(r[i]);
		sort(begin(pts), end(pts), [&](point a, point b)
			{return cross(a - o, b - o) < 0 || cross(a - o, b - o) == 0 && norm(a - o) < norm(b - o);});
		int m = pts.size();
		int dp[m][m];
		for(int i = 0; i < m; i++)
			for(int j = 0; j < m; j++)
				dp[i][j] = 0;
		for(int r = 0; r < m; r++)
			for(int l = 0; l < r; l++)
			{
				if(cross(pts[r] - o, pts[l] - o) == 0)
					continue;
				dp[l][r] = 1;
				for(int p = 0; p < l; p++)
					if(cross(pts[p] - o, pts[l] - o) == 0)
						add_mod(dp[l][r], dp[l][r]);
				for(int p = 0; p < l; p++)
					if(cross(pts[l] - pts[p], pts[r] - pts[p]) < 0)
						add_mod(dp[l][r], dp[p][l]);
				for(int p = l + 1; p < r; p++)
					if(cross(pts[r] - pts[l], pts[p] - pts[l]) <= 0)
						add_mod(dp[l][r], dp[l][r]);
				add_mod(ans, dp[l][r]);
			}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

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

    vector<pair<int, int>> task(n);

    for (int i = 0; i < n; ++i) {
        cin >> task.at(i).second >> task.at(i).first; // 締め切り/所要時間
    }

    sort(task.begin(), task.end()); // pairだとfirst要素にソートがかかる

    int sum = 0;
    bool isYes = true;
    for (auto v : task) {
        // 所要時間が締め切り時間をオーバーしなければよい
        sum += v.second;

        if (sum > v.first) {
            isYes = false;
            break;
        }
    }

    cout << (isYes ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 1792