akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
typedef pair<double, double> dop;
//------------------変数-----------------------//
ll n, m, a[100010], cnt = 0, grid[1001][1001] = {};
string str;
//-------------------関数----------------------//


int main() {
	ll k;
	cin >> n >> m>>k;
	REP(i, n+1) {
		REP(j, m+1) {
			ll hoge = i*m;
			hoge += (n - i)*j-i*j;
			if (hoge == k) { cout << "Yes" << endl; return 0; }
		}
	}
	cout << "No" << endl;
	return 0;
}




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

int	main() {
	long N, M;
	cin >>N >>M;
	if (1<abs(N-M)) {
	       cout <<0 <<endl;
	       return 0;
	}
	long S;
	if (N==M)
		S=2;
	else
		S=1;
	while (N>1) {
		S *=N;
		S %=1000000007;
		N--;
	}
	while (M>1) {
		S *=M;
		S %=1000000007;
		M--;
	}
	cout <<S <<endl;
	return 0;
};


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

#define mod 1e9+7

using namespace std;
using ll = long long; 

void add_self(int& a, int b){
    a +=b;
    a -= a>=mod ? mod : 0;
}

void sub_self(int& a, int b){
    a -=b;
    a += a<0 ? mod : 0;
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int>dp(k+1);
    
    dp[0] =1;
    
    while(n--){
        int up_to;
        scanf("%d" ,&up_to);
        vector<int>fake(k+1);
        
        for(int used = k; used >=0; used--){
            int l = used + 1;
            int r = used + min(up_to ,k - used);
            int tmp = dp[used];
            
            if(l <= r){
                add_self(fake[l], tmp);
                if(r + 1 <= k){sub_self(fake[r+1], tmp);}
            }
        }
        
        int prefixe_sum = 0;
        for(int i=0; i<=k; i++){
            add_self(prefixe_sum, fake[i]);
            add_self(dp[i], prefixe_sum);
        }
    
   
    }
    
    
    printf("%d\n", dp[k]);
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i,n){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a.begin(),a.end());
	rep(i,n){
		if(b[i] == a[n-1]) cout << a[n-2] << endl;
		else cout << a[n-1] << endl;
	}
	return 0;
}

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

int main(){
	int N; cin >> N;
	string S; cin >> S;
	int ans = 1;
	char ch = S[0];

	for (int i = 1; i < N; i++) {
		if (S[i] != ch) {
			ans += 1;
			ch = S[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  if (x[0] >= 0) {
    cout << x[k - 1] << endl;
    return 0;
  } else if (x[n - 1] <= 0) {
    cout << abs(x[n - k]) << endl;
    return 0;
  }

  int s = 0;
  for (; s < n - 1; ++s) {
    if (x[s] < 0 && x[s + 1] >= 0) {
      break;
    }
  }
  int ans = numeric_limits<int>::max();
  for (int i = 1; i <= k; ++i) {
    const int m = k - i;
    const int l = s + 1 - m;
    const int r = s + i;
    if (l < 0) continue;
    if (n <= r) continue;

    const int dist = abs(x[r] - x[l]);
    ans = min({ans, abs(x[l]) + dist, abs(x[r]) + dist});
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
from collections import Counter
import sys
input = sys.stdin.read
def main():
    n = int(sys.stdin.readline())
    A = input().split()
    C = Counter(A)
    for i in ["AC", "WA", "TLE", "RE"]:
        n = C[i]
        print("{} x {}".format(i, n))
if __name__ == '__main__':
    main()


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

int main() {
  string S;
  cin >> S;
  bool ok = true;
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 1){
    if (S.at(i) == 'R'){
      ok = false;
    }
    }else{
      if(S.at(i) == 'L'){
        ok = false;
      }
    }
  }
  if(ok == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

using namespace std;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;

ll mod = 1e9+7;

ll solve() {
    int x, n, a; cin >> x >> n;
    unordered_set<int> num_set;
    rep(i, n) {
        cin >> a;
        num_set.insert(a);
    }
    int left = x, right = x;
    while (num_set.count(left)) {
        left--;
    }
    while (num_set.count(right)) {
        right++;
    }

    return (x - left <= right - x) ? left : right;
}

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

	cout << solve() << endl;
}


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

using namespace std;

vector<pair<double, double>> coord;
vector<long double> results;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    coord.resize(n);
    for(int i=0;i<n;i++){
        long double a,b;
        cin>>a>>b;
        coord[i]={a,b};
    }
    double summ=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            results.push_back(sqrt((coord[i].first-coord[j].first)*(coord[i].first-coord[j].first)+(coord[i].second-coord[j].second)*(coord[i].second-coord[j].second)));
            summ+=results[results.size()-1];
        }
    }

    cout.precision(10);

    cout<<fixed<<(2.*summ/(double)n);


    return 0;
}

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

using namespace std;

#if 1
#define DEBUG(x) do{cerr << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
	int x,a;
	cin >> x >> a;

	if( x < a){
		cout << "0" << endl;
	}
	else{
		cout << "10" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  VVI X(3,VI(3));
  rep(i,3) rep(j,3) cin>>X[i][j];
  int N;
  cin>>N;
  VI B(N);
  rep(i,N) cin>>B[i];
  rep(i,N){
    rep(j,3) rep(k,3){
      if(X[j][k]==B[i]) X[j][k]=0;
    }
  }
  int ans=1;
  if(X[0][0]==0&&X[1][0]==0&&X[2][0]==0) ans=0;
  if(X[0][1]==0&&X[1][1]==0&&X[2][1]==0) ans=0;
  if(X[0][2]==0&&X[1][2]==0&&X[2][2]==0) ans=0;
  if(X[1][0]==0&&X[1][1]==0&&X[1][2]==0) ans=0;
  if(X[0][0]==0&&X[0][1]==0&&X[0][2]==0) ans=0;
  if(X[2][0]==0&&X[2][1]==0&&X[2][2]==0) ans=0;
  if(X[0][0]==0&&X[1][1]==0&&X[2][2]==0) ans=0;
  if(X[0][2]==0&&X[1][1]==0&&X[2][0]==0) ans=0;
  if(ans) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main() {
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  bool ans;
  if(abs(b-a)+t*w<=t*v){
    ans=1;
  }else{
    ans=0;
  }
  if(ans)
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
}

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

typedef long long ll;
#define MOD (1000000007LL)

int N;
string S[51];

ll dp[52][52][22][30];

ll solve(int up,int down,int id,int c){

  ll &ret = dp[up][down][id][c];
  if( ret != -1 ) return ret;
  if( up > down ) return ret = 1LL;
  if( c > 26 ) return ret = 0LL;
  if( id == (int)S[up].size() ) {
    if( up == down) return ret = 1LL;
    return ret = 0LL;
  }

  char ch = c + 'a' - 1;
  ret = solve(up,down,id,c+1);

  for(int i=up;i<=down;i++){
    if( S[i][id] != ch && S[i][id] != '?' ) break;
    if( S[i][id] == '?' && c == 0 ) break;
    ret += ( solve(i+1,down,id,c + 1) * solve(up,i,id+1,0) ) % MOD;
    ret %= MOD;    
  }

  //  cout << up << " " << down << " " << id << " "<< c << " ( " << ch << " ) "  << S[up][id] << endl;  
  //    cout << ret << endl;
  return ret;
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> N;
  int lenmax = 0;
  for(int i=0;i<N;i++){
    cin >> S[i];
    lenmax = max( lenmax, (int)S[i].size() );
  }
  for(int i=0;i<N;i++){
    while( (int)S[i].size() < lenmax ){    
      char c = 'a' - 1;
      S[i] += c;
    }
    // cout << S[i] << endl;
  }
  cout << solve(0,N-1,0,0) << endl;
}

Measured memory_bytes: 15240
#include <stdio.h>

int main(void){
    long HP,n,i,sum=0;
    long AT[10000000];
    
    scanf("%ld %ld",&HP,&n);
    
    for (i=0;i<n;i++){
        scanf("%ld",&AT[i]);
        sum = sum + AT[i];
    }
    
    if (sum >= HP){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 2560
N = int(input())
W = list(input() for _ in range(N))
for i in range(1,N):
    n = len(W[i-1])
    for j in range(0,i):
        if W[i] == W[j]:
            print("No")
            exit()
    if W[i-1][n-1] != W[i][0]:
        print("No")
        exit()
    else:
        continue
print("Yes")


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n, q;
    cin >> n >> q;
    vector<priority_queue<ll> > vs(n);
    rep(i,q){
        ll com, t; 
        cin >> com >> t;
        ll x;
        if(com == 0){
            cin >> x;
            vs[t].push(x);
        }else if(com == 1 && vs[t].size() > 0)cout << vs[t].top() << endl;
        else if(vs[t].size() > 0)vs[t].pop();
    }
    return 0;
} 


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  scanf ("%d",&n);
  for (int x = 3,count = 0; count < n; x+=10) {
    bool prime = true;
    for (int y = 2; y * y <= x; y++) if (x%y==0) prime=false;
    if (prime) {
      count++;
      printf ("%d%c",x,count==n?'\n':' ');
    }
}
  return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N;
  cin>>N;
  //VEC2(v,N,1024);
  VEC2(F,N,10);
  VEC2(P,N,11);

  FOR(i,0,N) FOR(j,0,10) cin>>F[i][j];
  FOR(i,0,N) FOR(j,0,11) cin>>P[i][j];

  ll inst=0;
  ll res=-1e15;
  ll sum=0;
  FOR(i,1,1024){
    vector<ll> key(N,0);
    ll po=i;
    FOR(j,0,N){
      po=i;
      inst=0;
      FOR(k,0,10){
        if(po%2==1)inst+=F[j][k];
        po/=2;
      }
      key[j]=P[j][inst];
    }
    sum=0;
    FOR(j,0,N)sum+=key[j];
    res=max(res,sum);
  }

  cout<<res<<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()
using namespace std;
typedef long long ll;

vector<ll> lay(50+1), paty(50+1);

ll solve(ll n, ll x) {
	ll ans = 0;
	if(n == 1) {
		if(x == 1) ans  = 0;
		if(x == 2) ans  = 1;
		if(x == 3) ans  = 2;
		if(x == 4) ans  = 3;
		if(x == 5) ans  = 3;
	}
	else if(x == 1) ans += 0;
	else if(x > 1 && x < lay[n-1]+2) ans += solve(n-1, x-1);
	else if(x == lay[n-1]+2) ans += 1LL + solve(n-1, lay[n-1]);
	else if(x > lay[n-1]+2 &&x < lay[n]) ans += solve(n-1, x-lay[n-1]-2) + 1LL + solve(n-1, lay[n-1]);
	else if(x == lay[n]) ans += paty[n];
	return ans;
}

int main() {
	ll n, x;
	cin >> n >> x;
	
	lay[0] = 1;
	paty[0] = 1;
	rep(i, n) {
		lay[i+1] = 2 * lay[i] + 3;
		// cout << lay[i+1] << endl;
	}
	rep(i, n) {
		paty[i+1] = 2 * paty[i] + 1;
		// cout << paty[i+1] << endl;
	}
	cout << solve(n, x) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int n ;
   cin >> n ;
   int d = n/500;
   ll ans = d*1000 ;
   n = n-d*500;
  // cout << n << " " ;
   d = n/5 ;
   ans += d*5 ;
   cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int n, m, k;
typedef pair<long long int, int> P;
vector<P> x[100010], y[100010];
vector<P> g[400010];
long long int INF = 1e18;
bool f;
long long int d[400010];
priority_queue<P, vector<P>, greater<P> > q;

int main(){
	scanf("%d %d %d", &m, &n, &k);
	for(int i=0; i<k; ++i){
		long long int a, b;
		scanf("%lld %lld", &a, &b);
		if((a + b != n + m) || (a + b != 2)){
			x[a].push_back(P(b, i+1));
			y[b].push_back(P(a, i+1));
		}else if(a + b == 2) f = true;
	}
	x[1].push_back(P(1, k+1));
	y[1].push_back(P(1, k+1));
	x[m].push_back(P(n, k+2));
	y[n].push_back(P(m, k+2));
/*
	printf("\n");
	for(int i=1; i<=m; ++i)
		for(int j=0; j<x[i].size(); ++j)
			printf("x=%d %dth y=%d %dth\n", i, j, x[i][j].first, x[i][j].second);
	printf("\n");
	for(int i=1; i<=n; ++i)
		for(int j=0; j<y[i].size(); ++j)
			printf("%d %d %d %d\n", i, j, y[i][j].first, y[i][j].second);
	printf("\n");
*/

	for(int i=1; i<=m; ++i){
		sort(x[i].begin(), x[i].end());
		for(int j=0; j+1<x[i].size(); ++j){
			g[x[i][j].second].push_back(P(x[i][j+1].first-x[i][j].first, x[i][j+1].second));
			g[x[i][j+1].second].push_back(P(x[i][j+1].first-x[i][j].first, x[i][j].second));
		}
	}

	for(int i=1; i<=n; ++i){
		sort(y[i].begin(), y[i].end());
		for(int j=0; j+1<y[i].size(); ++j){
			g[y[i][j].second+k+2].push_back(P(y[i][j+1].first-y[i][j].first, y[i][j+1].second+k+2));
			g[y[i][j+1].second+k+2].push_back(P(y[i][j+1].first-y[i][j].first, y[i][j].second+k+2));
		}
	}

	for(int i=1; i<=k; ++i){
		g[i].push_back(P(1, i+k+2));
		g[i+k+2].push_back(P(1, i));
	}
	if(f){
		g[k+1].push_back(P(1, 2*k+3));
		g[2*k+3].push_back(P(1, k+1));
	}
	g[k+2].push_back(P(1, 2*k+4));
	g[2*k+4].push_back(P(1, k+2));
/*
	for(int i=1; i<=2*k+4; ++i){
		
		for(int j=0; j<g[i].size(); ++j){
			printf("cost=%d to=%d\n", g[i][j].first, g[i][j].second);
		}
	}
*/
	fill(d+1, d+2*k+5, INF);
	d[k+1] = 0;
	if(f) d[2*k+3] = 1;
	q.push(P(0, k+1));
	while(!q.empty()){
		P p = q.top(); q.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0; i<g[v].size(); ++i){
			if(d[g[v][i].second] > d[v] + g[v][i].first){
				d[g[v][i].second] = d[v] + g[v][i].first;
				q.push(P(d[g[v][i].second], g[v][i].second));
			}
		}
	}
/*	printf("\n");
	for(int i=1; i<=2*k+4; ++i) printf("%d\n", d[i]);
	printf("\n");
*/	long long int ans = min(d[k+2], d[2*k+4]);
	if(ans == INF) printf("-1\n");
	else printf("%lld\n", ans);
}

Measured memory_bytes: 64468
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type loom struct {
	index int
	To []int
	count int
}
func main() {
	scan_init()
	n := scanInt()
	m := scanInt()
	a := make([]int, m)
	b := make([]int, m)
	sizes = make([]int, n)
	for i:= 0; i<n; i++ {
		sizes[i] = n+1
	}
	sizes[0] = 0
	looms = make([]loom, n)
	for i:= 0; i<n; i++ {
		looms[i].index = i
		looms[i].To = []int{}
	}
	for i:= 0 ; i<m; i++ {
		a[i] = scanInt()-1
		b[i] = scanInt()-1
		looms[a[i]].To = append(looms[a[i]].To, b[i])
		looms[b[i]].To = append(looms[b[i]].To, a[i])
	}
	// 幅優先探索
	output = make([]int, n) // n= 0 は飛ばす
	for i:= 0; i<n; i++ {
		output[i] = n+1
	}
	output[0] = 0
	flags = make([]bool, n)
	flags[0] = true
	// BFS(0, 0, n)
	que := []box{}
	for i:= 0; i<len(looms[0].To); i++ {
		var set box
		set.target = looms[0].To[i]
		set.pre = 0
		que = append(que, set)
	}
	for i:= 0; i<len(looms[0].To); i++ {
		output[looms[0].To[i]] = 1
	}
	// pre := 0
	for len(que) > 0 {
		var value box
		value,que = shift(que)
		take := looms[value.target].To
		// fmt.Println(take, "take", output, value)
		for i:= 0; i<len(take); i++ {
			if output[take[i]] == n+1{
				output[take[i]] = value.target+1
				var set box
				set.pre = value.target
				set.target = take[i]
				que = append(que, set)
			} else {
				continue
			}
		}
		// pre = value
	}
	// fmt.Println(looms, output)
	check := true
	for i:= 0; i<n; i++ {
		if output[i] == n+1 {
			check = false
		}
	}
	// fmt.Println(looms, output)
	if check {
		fmt.Println("Yes")
		for i:= 1; i<n; i++ {
			fmt.Println(output[i])
		}
	} else {
		fmt.Println("No")
	}
}
var output []int
var sizes []int
var flags []bool
var looms []loom
func BFS (index int, size int, n int) {
	take := looms[index].To
	size++
	fmt.Println("回数", size, index+1, take, output, flags)
	for i:= 0; i<len(take); i++ {
		if output[take[i]] > n {
			output[take[i]] = index+1
		} else {
			continue
		}
	}
	for i:= 0; i<len(take); i++ {
		if !flags[take[i]] {
			flags[take[i]] = true
			BFS(take[i], size, n)
		} else {
			continue
		}
	}
}

type box struct {
	target int
	pre int
}
var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}
func shift(slice []box) (box, []box){
	n := len(slice)
	value := slice[0]
	popSlice := slice[1:n]
	return value, popSlice
}


Measured memory_bytes: 29656
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (h, w) = get!(i32, i32);
    let (a, b) = get!(i32, i32);
    println!("{}", h * w - (a * w + b * h) + a * b);
}


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

int main() {

  ll n,m,d;
  cin >> n >> m >> d;

  /* 各数字の差が１かどうかだけなら
   * a_kが１またはｎなら１通り
   * a_kが1<a_k<nなら2通り
   *
   * d = 0
   * d = 1 (a_k == 1 or n, a_k-1 or a_k+1 でd=1, 1<a_k<n でd=1)
   * d = 2 (k != 0 && k != m-1 && 両側で
   *
   * 数字は常に左側を基準として、右側が+1or-1とする。
   *
   * a_k = 1 -> 
   * 1) k == 0 || m-1 -> n^(m-2)
   * 2) else -> n^(m-2)
   * sum = n^(m-2) + (m-2)*n^(m-2) = (m-1)*n^(m-2)
   *
   * a_k = n -> = a_k = 1
   *
   * 1 < a_K < n
   * 1) -> n^(m-2)
   * 2) -> 2*n^(m-2)
   * sum = 2*n^(m-2) + (m-2)*2*n^(m-2) = (2m-2)*n^(m-2)
   *
   * 2*(m-1)*n^(m-2) + (n-2)*(2m-2)*n^(m-2) = (2n-2)*(m-1)*n^(m-2)
   *
   * 1~(m-2) 番目の数がターゲットになっている時に0~(m-3)番目とのペアも+-1になっているケース
   *
   * a_k = 1 || n -> n^(m-3)
   * sum = (m-2)*n^(m-3)
   *
   * 1 < a_k < n
   * 2) -> 2*n^(m-3)
   * sum = (m-2)*2*n^(m-3)
   *
   * 2*(m-2)*n^(m-3) + (n-2)*2*(m-2)*n^(m-3) = (n-1)*2*(m-2)*(n^(m-3))
   * */

  /*
   *
   * m=2 のとき
   * 差がdのもの、n - (1+d) + 1 = n-d (n-d)*2 通り
   * m=3 のとき
   * (n-d)*2*n + (n-d)*2*n 
   * m=4 のとき
   * 3*(n-d)*2*n^2
   *
   * (m-1)*(n-d)*2*(n^(m-2))
   **/
  long double ave;

  if(d!=0) 
    ave = (m-1)*(n-d)*2.0/(n*n);
  else 
    ave = (m-1)*(n-d)*1.0/(n*n);


  //cout << fixed;
  cout << setprecision(7) << ave << endl;
  return 0;
}




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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long X, Y; cin >> X >> Y;
	int len = 1;
	long long lst = X;
	while(true) {
		if (lst <= Y / 2) lst *= 2; else break;
		++len;
	}
	cout << len << endl;
}

Measured memory_bytes: 256
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut pre_gcd: Vec<u64> = vec![0; n];
    let mut post_gcd: Vec<u64> = vec![0; n];
    pre_gcd[0] = a[0];
    for i in 1..n {
        pre_gcd[i] = gcd(pre_gcd[i - 1], a[i]);
    }
    post_gcd[n - 1] = a[n - 1];
    for i in (0..n - 1).rev() {
        post_gcd[i] = gcd(post_gcd[i + 1], a[i]);
    }
    let mut result = 1;
    assert_eq!(pre_gcd[n - 1], post_gcd[0]);
    result = std::cmp::max(result, pre_gcd[n - 2]);
    result = std::cmp::max(result, pre_gcd[n - 1]);
    result = std::cmp::max(result, post_gcd[0]);
    result = std::cmp::max(result, post_gcd[1]);
    for i in 1..n-1 {
        result = std::cmp::max(result, gcd(pre_gcd[i - 1], post_gcd[i + 1]));
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_121
{
    class Program
    {

        static void Main(string[] args)
        {
            long[] dataArr = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            
            long start = dataArr[0];
            long end = dataArr[1];

            long data1 = 0;
            //開始が奇数の場合
            if (0 < start % 2)
            {
                data1 = start;
                start++;
            }

            long data2 = 0;
            //終了が偶数の場合
            if (0 == end % 2)
            {
                data2 = end;
                end--;
            }

            long data3 = 0;
            if(((end - start + 1) / 2)  % 2 == 0)
            {
                data3 = 0;
            }
            else
            {
                data3 = 1;            
            }
            Console.WriteLine(data1 ^ data2 ^ data3);

        }
    }
}



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

int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  
  int Q = K-1;
  
  if(S[Q] == 'A')
    S[Q] = 'a';
    
  if(S[Q] == 'B')
    S[Q] = 'b';
    
  if(S[Q] == 'C')
    S[Q] = 'c';
    
  cout << S << endl;
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,l,r,ans;

main() {
    cin >> n;
    rep(i,n) {
        cin >> l >> r;
        ans += r-l+1;
    }
    ct(ans)
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int n,m,a,b;
  cin >> n >> m;
  vector<priority_queue<int>> w(1e5 + 1);
  set<pair<int,int>> mw;
  rep(i,n){
    cin >> a >> b;
    w.at(a).push(b);
  }
  ll ans = 0;
  for(int i= 1;i<=m;i++){
    if(w.at(i).size()){ 
      mw.insert(make_pair(w.at(i).top(),i));
      w.at(i).pop();
    }
    if(mw.size()){ 
      pair<int,int> p = *rbegin(mw);
      mw.erase(p);
      b = p.first;
      a = p.second;
      ans += (ll) b;
      if(w.at(a).size()){ 
        mw.insert(make_pair(w.at(a).top(),a));
        w.at(a).pop();
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
import java.util.*;

public class Main {
    static int[] a;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(a);
        int ans;
        int index = binary_search(a[N-1]/2);
        if (index==0) {
            ans = 0;
        } else {
            ans = Math.abs(a[index]-(double)a[N-1]/2) < Math.abs(a[index-1]-(double)a[N-1]/2) ? index : index-1;
        }
        System.out.println(a[N-1] + " " + a[ans]);
    }
    public static boolean isOK(int index, int key) {
        if (a[index] >= key) return true;
        else return false;
    }

    public static int binary_search(int key) {
        int left = -1;
        int right = a.length;

        while (right - left > 1) {
            int mid = left + (right - left) / 2;

            if (isOK(mid, key)) right = mid;
            else left = mid;
        }
        return right;
    }
}

Measured memory_bytes: 48456
N, M = map(int, input().split())

AC_count = 0
WA_count = 0
WA_count_dict = {}
is_not_AC = {}

for m in range(M):
    p, S = input().split()
    p = int(p)
    
    if p not in is_not_AC.keys():
        is_not_AC[p] = True
        WA_count_dict[p] = 0
        
    if is_not_AC[p]:
        if S=="WA":
            WA_count_dict[p] += 1
        else:
            AC_count += 1
            is_not_AC[p] = False
            
for k in is_not_AC.keys():
    if is_not_AC[k] == False:
        WA_count += WA_count_dict[k]

print(AC_count, WA_count)

Measured memory_bytes: 24644
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)
    for{
      in <- inputs
      val Array(h, w, _*) = in.split(" ").map(_.toInt)
      }{
        if(h != 0 && w != 0) println(List.tabulate(h, w) { (i, j) =>
          val simbol = if ((i % 2 == 0 && j % 2 == 0) ||
            (i % 2 != 0 && j % 2 != 0)) "#"
          else "."
          val EOS = if(j == w - 1) "\n" else ""
          simbol + EOS
        }.flatten.mkString)
      }
  }
}

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

using namespace std;

int main(){
  int a,b,n;
  cin >> n >> a >> b;
  for(int i = a;i<=b;i++){
    if(i%n == 0){
      cout << "OK" << "\n";
      return 0;
    }
  }
  cout << "NG" << "\n";
}

Measured memory_bytes: 3624
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
local str2tbl = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local N = read.nl()
local S = str2tbl(read.l())
local depth = 0
local after = {}
for i=N,1,-1 do
    if S[i] == '(' then
        depth = depth - 1
    else
        depth = depth + 1
    end
    if depth < 0 then
        table.insert(after, ')')
        depth = depth + 1
    end
end
local before = {}
for i=1,depth do
    table.insert(before, '(')
end
local function t2s(t) return table.concat(t,"") end
print(t2s(before) .. t2s(S) .. t2s(after))


Measured memory_bytes: 508
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int x,y,z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a>b){
        cout << "a > b"<<endl;
    }
    else{
        if(a == b){
            cout << "a == b" << endl;
        }
        else{
            cout << "a < b" << endl;
        }
    }
}



Measured memory_bytes: 3096
function comp(a, b) {
  return a - b;
}

function Main(input) {
  a = input.split(' ');
  for (var i = 0; i < a.length; i++) {
    a[i] = parseInt(a[i]);
  }
  a.sort(comp);
  console.log(a.join(' '));
}
/*
function debug() {
  var input = document.getElementById('id1').value;
  Main(input);
}
*/

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15112
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

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

  int n; cin >> n;
  string s; cin >> s;
  string t; cin >> t;

  for(int i=n; i>=0; i--) {
    bool flag = true;
    for(int j=0; j<i; j++) {
      //debug(j); debugln(j+n-i);
      if (t.at(j) != s.at(j+(n-i))) {
        flag = false;
      }
    }
    if (flag) {
      cout << n+n-i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int a[1001], b[1001], c[1001], d[1001], test[1001];
signed main() {
    int n, p, q, r, s, P, Q, R, C;
    for (int z = 0; z < 100; z++) {
        int x = 0;
        cin >> n; if (n == 0) { return 0; }
        for (int h = 0; h < n; h++) {
            cin >> s >> p >> q >> r;
            a[h] = s; b[h] = p; c[h] = q; d[h] = r;
            test[h] = 4 * p + 9 * q + 4 * r;
        }
        cin >> P >> Q >> R >> C;
        for (int h = 0; h < n; h++) {
            if (b[h] <= P && c[h] <= Q && d[h] <= R && test[h] <= C) {
                cout << a[h] << endl; x++;
            }
        }
        if (x == 0) { cout << "NA" << endl; }
    }
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int cnt = 0;
    rep(i, N - 2) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,K = map(int,input().split(' '))
u = 10**9+7

M = (N+1)*N//2

LIMIT = 0
ANS = 0

#i個の要素を使って成立させられる数値が幾つあるのか考える
#LINITは, i個で作れる最大の数
for i in range(K,N+2):
    m_LIMIT = (0+(i-1))*i//2
    M_LIMIT = (N+(N-(i-1)))*i//2
    ANS += (M_LIMIT-m_LIMIT)+1
    ANS %= u
print(ANS)

Measured memory_bytes: 63936
N=int(input())
list_A=[int(A) for A in input().split()]
list_A.insert(0,0)
list_A.insert(N+1,0)
money=0
for i in range(N+1):
  money+=abs(list_A[i+1]-list_A[i])
for i in range(1,N+1):
  Money=money-abs(list_A[i]-list_A[i-1])-abs(list_A[i+1]-list_A[i])+abs(list_A[i+1]-list_A[i-1])
  print(Money)
    


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

using ll = long long;


int main(){

  int N;
  cin >> N;

  map<int,int> mp;
  int a;
  for(int i=0;i<N;i++){
    cin >> a;
    mp[a]++;
  }

  int Q;
  cin >> Q;

  ll ans=0;
  for(auto u:mp){
    ans+=u.first*u.second;
  }

  ll b,c;
  ll num;
  ll distance;
  for(int j=0;j<Q;j++){
    cin >> b >> c;
    num=mp[b];
    distance=(c-b)*mp[b];
    mp.erase(b);
    mp[c]+=num;
    ans+=distance;
    cout << ans << endl;
  }
}

Measured memory_bytes: 6556
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], m = h[1];
		var s = Console.ReadLine();

		var safe = new int[n + 1];
		var t = 0;
		for (int i = 1; i <= n; i++) safe[i] = s[i] == '0' ? t = i : t;

		var dp = new int[n + 1];
		for (int i = n - 1; i >= 0; i--)
		{
			if (s[i] == '1') { dp[i] = -1; continue; }
			var j = Math.Min(n, i + m);
			if (safe[j] == i) { Console.WriteLine(-1); return; }
			dp[i] = dp[safe[j]] + 1;
		}

		var l = new List<int>();
		var u = dp[0];
		for (int i = 0; i <= n; i++)
		{
			if (dp[i] == u)
			{
				l.Add(i);
				u--;
			}
		}
		Console.WriteLine(string.Join(" ", Enumerable.Range(0, l.Count - 1).Select(i => l[i + 1] - l[i])));
	}
}


Measured memory_bytes: 16736
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int out1[n],out2[n];
	out1[0]=arr[0];
	out2[n-1] = arr[n-1];
	for(int i=1;i<n;i++){
		out1[i] = (arr[i]^out1[i-1]);
		out2[n-i-1] = (out2[n-i]^arr[n-i-1]); 
	}
	cout<<out2[1]<<" ";
	for(int i=1;i<n-1;i++){
		cout<<(out1[i]^out2[i])<<" ";
	}
	cout<<out1[n-2]<<"\n";
}

Measured memory_bytes: 5928
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        if(a.equals("H")){
            System.out.println(b);
            
        }
        if(a.equals("D") && b.equals("D")){
            System.out.println("H");
        }
        if(a.equals("D") && b.equals("H")){
            System.out.println("D");
        }
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);

//dp[i][j][k]:i番目までのカードからj枚とったときの和がkとなる取り方の総数;
ll dp[55][55][3000];
int main(){
    ll n,a;
    cin>>n>>a;
    ll sum = 0;
    vector<ll> x(n);
    for(ll i=0;i<n;i++){
        cin>>x[i];
        sum+=x[i];
    }

    dp[0][0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=n;j++){
            for(ll k=0;k<=sum;k++){
                //i番目のカードをとる場合と、とらない場合
                dp[i+1][j][k]+=dp[i][j][k];
                if(j-1>=0&&k-x[i]>=0){
                    dp[i+1][j][k]+=dp[i][j-1][k-x[i]];
                }
            }
        }
    }
    ll res = 0;
    for(ll j=1;j<=n;j++){
        res += dp[n][j][j*a];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 66560
#include <stdio.h>
#include <limits.h>

int n,k;
int h[100000];
int dp[100000];

int abs(int x){return x>0?x:-x;}
int min(int a,int b){return a>b?b:a;}

int main()
{
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&h[i]);

    for(int i=1;i<n;i++) dp[i]=INT_MAX;
    dp[0]=0;

    for(int i=0;i<n-1;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    printf("%d\n",dp[n-1]);
}

Measured memory_bytes: 896
#include <stdio.h>
int main()
{
	int n,x,min,max;
	double sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		if(i==0)
		{
			max=x;
			min=x;
		} 
		if(x>max) max = x;
		if(x<min) min = x;
		sum = sum + x;
	}
	printf("%d %d %.0lf\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2108
N = input()

n = int(N[-1])
if((n == 2)or(n == 4)or(n == 5)or(n == 7)or(n == 9)):
  print('hon')
elif((n == 0)or(n == 1)or(n == 6)or(n == 8)):
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;

ll N;
vector<ll> a;


int main(){
  ll inp;
  ll num=1;
  ll result=0;
  
  cin >> N;
  int checked[100000]={0};
  
  for(int i = 0;i<N;i++){
    cin >> inp;
    a.push_back(inp);
  }
  
  do{
    result++;
    if(a[num-1]==2){
      cout << result << endl;
      return 0;
    }
    else{
      checked[num-1]=1;
      num=a[num-1];
    }
  }while(!checked[num-1]);

  cout << "-1" << endl;
  return 0;
  
}


Measured memory_bytes: 1784
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,C,D = MI()

t = A
a = C

for i in range(100):
    a -= B
    if a <= 0:
        print("Yes")
        exit()
    
    t -= D
    if t <= 0:
        print("No")
        exit()


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

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

#define tmax(a, b, c) max(a, max(b, c))
#define tmin(a, b, c) min(a, min(b, c))

int main()
{
	int N;
	set<int> s;
	map<int, int> mp;
	bool ans;

	cin >> N;
	rep(i, N) {
		int a;
		cin >> a;
		s.insert(a);
		if (mp.count(a) == 0) mp[a] = 1;
		else mp[a]++;
	}

	if (s.size() == 1) {
		if (mp[0] == N) ans = true;
		else ans = false;
	}
	else if (s.size() == 2) {
		if (N % 3 == 0 && mp[0] == N / 3) ans = true;
		else ans = false;
	}
	else if (s.size() == 3) {
		set<int>::iterator it = s.begin();
		int x = *it; it++;
		int y = *it; it++;
		int z = *it;

		if ((x ^ y) == z && mp[x] == mp[y] && mp[y] == mp[z]) ans = true;
		else ans = false;
	}
	else ans = false;

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

	return 0;
}


Measured memory_bytes: 7552
tramp = set()
tramp_given = set()

for i in range(1, 14):
    for elem in ["H ", "S ", "C ", "D "]:
        tramp.add(elem+str(i))

n = int(input())
for i in range(n):
    tramp_given.add(input())

res = sorted(tramp-tramp_given)
res = sorted(res, key=len)
for elem in res:
    if elem[0]=="S":
        print(elem)

for elem in res:
    if elem[0]=="H":
        print(elem)

for elem in res:
    if elem[0]=="C":
        print(elem)

for elem in res:
    if elem[0]=="D":
        print(elem)






Measured memory_bytes: 5600
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vi x(n), y(n);
    vc d(n);
    rep(i, n) cin >> x[i] >> y[i] >> d[i];
    auto f = [&](double t) {
        double Mx = -inf, mx = inf;
        double My = -inf, my = inf;
        rep(i, n) {
            double nx = x[i], ny = y[i];
            if (d[i] == 'R') nx += t;
            else if (d[i] == 'L') nx -= t;
            else if (d[i] == 'U') ny += t;
            else ny -= t;
            chmax(Mx, nx);
            chmin(mx, nx);
            chmax(My, ny);
            chmin(my, ny);
        }
        return (Mx - mx) * (My - my);
    };
    double l = 0, r = inf;
    rep(_, 100) {
        double m1 = (l * 2 + r) / 3;
        double m2 = (l + r * 2) / 3;
        if (f(m1) < f(m2)) r = m2;
        else l = m1;
    }
    cout << fixed << setprecision(20) << f(l) << endl;
}


Measured memory_bytes: 4512