akhauriyash/Code-Regression huggingface dataset:
W, H, N = map(int, input().split())
p = [map(int, input().split()) for _ in range(N)]
w_left = 0
w_right = W
h_bottom = 0
h_top = H

for x, y, a in p:
    if a == 1:
        w_left = max(w_left, x)
    elif a == 2:
        w_right = min(w_right, x)
    elif a == 3:
        h_bottom = max(h_bottom, y)
    else:
        h_top = min(h_top, y)

ans = max(0, w_right - w_left) * max(0, h_top - h_bottom)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(unsigned int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define DUMPL(ar) for(unsigned int i=0; i<ar.size(); i++) { cout << ar[i]; if(i<ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示"
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// goto ANSWER; で最後へ飛ぶ
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int merge(vector<int> &a){
    static int count = 0;
    int left = a.size() / 2;
    vector<int> a_left;
    vector<int> a_right;
    // 分割
    for(int i=0; i<(int)a.size(); i++){
        if(i < left){
            a_left.push_back(a.at(i));
        }else{
            a_right.push_back(a.at(i));
        }
    }
    // ソート
    if(a.size() > 2){
        merge(a_left);
        merge(a_right);
    }
    if(a.size() == 1){ // 3つの配列を分割した際起こり得る
        if(a_left.size() == 1) a = a_left;
        else a = a_right;
        return 0;
    }
    // 結合
    int lc = 0, rc = 0;
    // cout << "[left.size: " << a_left.size() << " right.size: " << a_right.size() << "]" << endl;
    for(int i=0; i<(int)a.size(); i++){
        // cout << '\t' << "lc: " << lc << " rc: " << rc << endl;
        count++;
        if(lc >= left) { a.at(i) = a_right.at(rc++); continue; }
        if(rc >= (int)a_right.size()) { a.at(i) = a_left.at(lc++); continue; }

        if(a_left.at(lc) <= a_right.at(rc)){
            a.at(i) = a_left.at(lc++);
        }else{
            a.at(i) = a_right.at(rc++);
        }
    }
    return count;
}

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

    /*
    6 3 5 1 8 2 4 7
    6 3 5 1  -  8 2 4 7
    6 3  -  5 1  -  8 2  -  4 7
    3 6  -  1 5  -  2 8  -  4 7
    1 3 5 6  -  2 4 7 8
    1 2 3 4 5 6 7 8
    */

    int n;
    cin >> n;
    vector<int> s(n);
    FOR(i, n) cin >> s[i];
    // s = {6, 3, 5, 1, 8, 2, 4, 7};

    int ans = merge(s);

    DUMPL(s);
    COUT(ans);

ANSWER:
    return 0;
}


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

int main(){
    int n;
    string taro, hanako;
    int t_score = 0;
    int h_score = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> taro >> hanako;
        if(taro > hanako){
            t_score += 3;
        } else if(taro == hanako){
            t_score += 1;
            h_score += 1;
        } else {
            h_score += 3;
        }
    }
    
    cout << t_score << " " << h_score << endl;
    return 0;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define		CH		ch=(getchar())
#define		N		10005

inline		int		IN(){
	int x=0,f=1;char ch;
	for (CH;ch>'9'||ch<'0';CH) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';CH) (x*=10)+=ch-'0';
	return x*f;
}

int i,j,k,l,n,m;
long long xx,ans,a[N];

int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	ans=a[1];
	for (i=2;i<=n;i++){
		xx=__gcd(ans,a[i]);
		ans*=a[i]/xx;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define rep1(i,N) for(int i=1;i<=(int)N;i++)
#define pb push_back
#define all(c) c.begin(),c.end()
#define show(x) cout<<#x<<" "<<x<<endl
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> P;
typedef bitset<300> BS;

int D;		//doc num
int ms[1000];
vector<P> docs[1000];
BS can[300];
bool positive[1000];
int N;

bool add_edge(int s,int t){
	if(can[s][t]) return 1;
	if(can[t][s]) return 0;
	can[s][t]=1;
	rep(x,N) if(can[x][s]){
		can[x][t]=1;
		can[x]|=can[t];
	}
	rep(y,N) if(can[t][y]) can[s][y]=1;
	// rep(i,N){
	// 	rep(j,N) cout<<can[i][j];
	// 	puts("");
	// }
	// puts("");
	return 1;
}
bool add(int d){
	vector<P>& doc=docs[d];
	int M=ms[d];
	rep(i,M) if(!add_edge(doc[i].fs,doc[i].sc)) return 0;
	rep(i,N) if(can[i][i]) return 0;
	return 1;
}

vector<string> sts;
string instrs[100000][2];
int main(){
	string stsx,stsy;
	cin>>stsx>>stsy;
	sts.pb(stsx);sts.pb(stsy);
	cin>>D;
	int M=0;
	rep(i,D){
		int n;
		cin>>n;
		ms[i]=n;
		rep(j,n){
			rep(k,2) cin>>instrs[M][k],sts.pb(instrs[M][k]);
			M++;
		}
	}
	sort(all(sts));
	sts.erase(unique(all(sts)),sts.end());
	N=sts.size();

	int sx=lower_bound(all(sts),stsx)-sts.begin();
	int sy=lower_bound(all(sts),stsy)-sts.begin();
	can[sx][sy]=1;

	int it=0;
	rep(i,D){
		rep(j,ms[i]){
			int x=lower_bound(all(sts),instrs[it][0])-sts.begin();
			int y=lower_bound(all(sts),instrs[it][1])-sts.begin();
			docs[i].pb(P(x,y));
			it++;
		}
	}
	while(true){
		bool update=0;
		rep(i,D) if(!positive[i]){
			rep(j,ms[i]){
				P p=docs[i][j];
//				cout<<p.fs<<","<<p.sc<<endl;
				if(can[p.fs][p.sc]){
					if(!add(i)){
						puts("No");
						return 0;
					}
					positive[i]=1;
					update=1;
					goto done;
				}
			}
		}
		done:
		if(!update) break;
	}
	puts("Yes");
}

Measured memory_bytes: 16540
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstddef>
#include <cinttypes>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <array>
#include <valarray>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <tuple>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

const double EPS = 1e-10;
const int64_t INF = 1e9;

int main()
{
	int n;
	scanf("%d", &n);
	printf("%d\n", 1-n);

	return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <stdint.h>
#include <vector>
 
using namespace std;
static vector<uint32_t> Ts;
int32_t main()
{
  uint32_t N;
  cin >> N;
 
  for(uint32_t i = 0; i < N ; i++){
    int32_t t;
    cin >> t;
    Ts.push_back(t);
  }
 
  uint32_t M;
  cin >> M;
  for(uint32_t i = 0; i < M; i++){
    uint32_t p, m;
    cin >> p >> m;
    p--;
    uint32_t count = 0;
    for(uint32_t i = 0; i < Ts.size();i++){
      if(i == p){
        count += m;
      } else{
        count += Ts[i];
      }
    }
    cout << count << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define forn(i, n) for(int i = 0; i < int__(n); i++) 
#define sz(a) int__(a.size())
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 2e5 + 7;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}

int cmax=0;
map<pi,int> mp;
vvi a(MAX);

void dfs(int x,int p){
	int last=1;
	int c=mp[{min(x,p),max(x,p)}];
	for(int y:a[x]){
		if(y==p) continue;
		if(last == c) last++;
		mp[{min(y,x),max(y,x)}]=last; cmax=max(last,cmax);
		dfs(y,x);
		last++;
	}
}

int__ main()
{	
	fast;
	int n; cin >> n; vpi edges;
	for(int i=0;i<n-1;i++){
		int u,v; cin >> u >> v;
		a[u].pb(v); a[v].pb(u);
		edges.pb({min(u,v),max(u,v)});
	}

	dfs(1,1);
	cout << cmax << endl;
	for(pi x:edges) cout << mp[x] << endl;

}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if ((a+b+c) == max(a, max(b, c)) * 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 


int32_t main()
{
	IOS
	string s1,s2;cin>>s1>>s2;
	int n1=s1.length(),n2=s2.length();
	s1='$'+s1;
	s2='$'+s2;
	//Note 3000 * 3000 dp possible 
	vector<vector<int>>dp(n1+1,vector<int>(n2+1));
	pair<int,int> par[n1+1][n2+1];
	
	//Note dp[0][0] = 0 && dp[1...n1][0]=0  && dp[0][1...n2]=0 , base cases
	par[1][1]={-1,-1};
	for(int i=1;i<=n1;i++)
	{
		for(int j=1;j<=n2;j++)
		{
			if(s1[i]==s2[j])
			{
				dp[i][j]=dp[i-1][j-1] + 1 ;
				par[i][j]={i-1,j-1};
			}
			else
			{
				if( dp[i-1][j] > dp[i][j-1])
				{
					 dp[i][j]=dp[i-1][j];
					 par[i][j]={i-1,j};
				}
				else
				{
					dp[i][j]=dp[i][j-1];
					par[i][j]={i,j-1};
				}
			}
		}
	}
	string ans;
	pair<int,int>crnt={n1,n2};
	while( crnt.first != 0 && crnt.second != 0 )
	{
		if( par[crnt.first ][ crnt.second ].first == crnt.first -1 && par[crnt.first ][ crnt.second ].second== crnt.second -1  ) ans+=s1[crnt.first];
		crnt=par[ crnt.first ][ crnt.second ];
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}
		


Measured memory_bytes: 211456
#include<bits/stdc++.h>
using namespace std;
int main(){
  double N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  double sum = 0;
  for(int j=0; j<N; j++){
    sum += vec.at(j);
  }
  double D = 0;
  D = sum / N;
  int d = 0;
  if(D >= 0){
  d = D + 0.49999999;
  }
  else{
  d = D - 0.49999999;
  }
  
  int ans = 0;
  for(int k=0; k<N; k++){
    ans += (vec.at(k) - d) * (vec.at(k) - d);
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n;cin>>n;
    vector<int>a(n);

    rep(i,n){
        cin>>a[i];
    }

    int ans=0;

    rep(i,n-1){
        rep2(j,i+1,n){
            ans=max(ans,abs(a[i]-a[j]));
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define maxe              *max_element
#define mine              *min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x;
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl;
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    unordered_map<ll,ll>mp;
    map<ll,ll>keep;
    ll n; cin>>n; vector<ll>inp(n); get(inp);
    for(ll i=0;i<n;i++) keep[inp[i]]++;
    if(n==1)
    {
        cout<<"1"; return 0;
    }
    vector<ll>v;
    for(auto i:keep)
    {
        if(i.S==1) v.pb(i.F);
        else mp[i.F]++;
    }
    if(v.sz==0)
    {
        cout<<"0"; return 0;
    }
    ll c=0;
    vector<ll>vec(10000000);
    for(ll i=0;i<v.sz;i++)
    {
        ll k=v[i];
        for(ll j=1;j*j<=k;j++)
        {
            if(k%j==0)
            {
                ll x=k/j;
                ll y=j;
                if(vec[x]==1 || vec[y]==1 || mp[x]>=1 || mp[y]>=1) G;
            }
        }
        c++;
        done : 1;
        vec[k]=1;
    }
    cout<<c;
}
















Measured memory_bytes: 125416
Y,X=map(int,input().split())
info=[]
come=[[0]*X for i in range(Y)]
num=[[0]*X for i in range(Y)]
bl=0 # #の数
come[0][0]=1
for i in range(Y):
    a=list(input())
    info.append(a)
    for j in range(X):
        if a[j]=="#":
            bl+=1
def bfs(y,x,nanpo):
    if not(0<=y<=(Y-1) and 0<=x<=(X-1)):
        return
    if info[y][x]=="#":
        return
    if come[y][x]==1:
        return
    come[y][x]=1
    num[y][x]=nanpo
    next_.append([y,x])
    
next_=[[0,0]]
l=1
nanpo=1
while l>0:
    for i in range(l):
        #print(i)
        #print(next_)
        bfs(next_[0][0]+1,next_[0][1],nanpo)
        bfs(next_[0][0]-1,next_[0][1],nanpo)
        bfs(next_[0][0],next_[0][1]+1,nanpo)
        bfs(next_[0][0],next_[0][1]-1,nanpo)
        del next_[0]
    nanpo+=1
    l=len(next_)
#print(num)
if come[Y-1][X-1]==0:
    print(-1)
else:
    print(X*Y-bl-(num[Y-1][X-1]+1))
#print(bl)

Measured memory_bytes: 3188
import math
A, B = map(int, input().split())
max_price = math.ceil((A+0.99999)/0.08)
min_price = math.floor((B/0.1))
found = 0
for price in range(min_price, max_price+1):
  if math.floor(price*0.08) == A and math.floor(price*0.1) == B:
    print(price)
    found = 1
    break
if found == 0:
  print(-1)

Measured memory_bytes: 3060
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n, k; cin >> n >> k;
  double ans = 0.0;
  for(int i = 1; i <= n; i++) {
    int cnt = 0;
    int t = i;
    while(t < k) {
      cnt++;
      t <<= 1;
    }
    ans += pow(0.5, cnt);
  }
  ans = ans / double(n);
  cout << fixed << setprecision(10) << ans << "\n";
}

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

using namespace std;

int main() {
    int K; cin >> K;
    int ans = 0;
    for(int i=1; i<K; i++) {
        for(int j=i+1; j <= K; j++) {
            if(i%2 == 0 && j%2 == 1) ans++;
            if(i%2 == 1 && j%2 == 0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    stack<int> st;
    string s;
    while(cin >> s){
        if(s=="+"){
            int a=st.top(); st.pop();
            int b=st.top(); st.pop();
            st.push(b+a);
        }else if(s=="-"){
            int a=st.top(); st.pop();
            int b=st.top(); st.pop();
            st.push(b-a);
        }else if(s=="*"){
            int a=st.top(); st.pop();
            int b=st.top(); st.pop();
            st.push(b*a);
        }else{
            st.push(stoi(s));
        }
    }
    cout << st.top() <<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  bool ok = abs(c-a)<=d || (abs(b-a)<=d && abs(c-b)<=d);
  puts(ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double q;
  while(cin >>q,q!=-1){
    double ans = q/2;
    for(;;){
      ans = ans-((ans*ans*ans)-q)/(3*ans*ans);
      if(ans*ans*ans-q<q*0.00001 && -q*0.00001<ans*ans*ans-q) break;
    }
    printf("%.6lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1232
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: chars,
    }
    let mut c = 0;
    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - 1 - i] { c += 1; }
    }
    puts!("{}\n", c);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 2e5+9;
vector<int> g[N][2];
int d[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int k; cin >> k;
    for(int i = 1; i < k; i++) {
        g[i][1].push_back((i+1)%k);
        g[i][0].push_back(i*10ll%k);
    }
    deque<int> dq({1});
    memset(d, 0x3f, sizeof d);
    d[1] = 1;
    while(!dq.empty()) {
        int u = dq.front(); dq.pop_front();
        for(int v: g[u][0]) {
            if(d[v] > d[u]) {
                d[v] = d[u];
                dq.push_front(v);
            }
        }
        for(int v: g[u][1]) {
            if(d[v] > d[u] + 1) {
                d[v] = d[u] + 1;
                dq.push_back(v);
            }
        }
    }
    cout << d[0] << endl;








    return 0;
    
}

Measured memory_bytes: 16896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    boolean possible = false;
    for (int i = a; i <= b; i++) {
      if (i % k == 0) {
        possible = true;
        break;
      }
    }
    System.out.println(possible ? "OK" : "NG");
  }
}

Measured memory_bytes: 25388
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N,K;

    cin >> N >> K;

    int result = 1;
    int i = 0;
    while(i<N){
        if(result<K){
            result *= 2;
        }else{
            result += K;
        }
        i++;
    }
    cout << result << endl;
}

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

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

const int N = 111111;
const int LOG = 20;

int a[N];
int nxt[N][20];

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n, L;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &L);
  for (int i = 0; i < n; ++i) {
    nxt[i][0] = upper_bound(a.begin(), a.end(), a[i] + L) - a.begin() - 1;
  }
  for (int j = 1; j < LOG; ++j) {
    for (int i = 0; i < n; ++i) {
      nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }
  }
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x; --y;
    if (x > y) {
      swap(x, y);
    }
    int step = 0;
    for (int i = LOG - 1; i >= 0; --i) {
      if (nxt[x][i] < y) {
        x = nxt[x][i];
        step += (1 << i);
      }
    }
    step += (x < y);
    printf("%d\n", step);
  }
  return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define ll long long
#define re register
#define cs const

using std::cerr;
using std::cout;
using pii=std::pair<int,int>;
#define x first
#define y second

cs int N=1e2+7;

int n,m;

char s[N][N];
int d[N][N];

void Main(){
	scanf("%d%d",&n,&m);
	for(int re i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	memset(d,0x3f,sizeof d);d[1][1]=0;
	for(int re i=1;i<=n;++i)
		for(int re j=1;j<=m;++j){
			if(i>1)d[i][j]=std::min(d[i][j],d[i-1][j]+(s[i][j]!=s[i-1][j]));
			if(j>1)d[i][j]=std::min(d[i][j],d[i][j-1]+(s[i][j]!=s[i][j-1]));
		}
	cout<<(d[n][m]+(s[1][1]=='#')+(s[n][m]=='#'))/2<<"\n";
}

inline void file(){
#ifdef zxyoi
	freopen("A.in","r",stdin);
#endif
}signed main(){file();Main();}

Measured memory_bytes: 256
n = int(input())
L = []
anslist = []
for i in range(n):
  s = input()
  L.append(s)
L.sort()
L.append('zzzzzzzzzzzzz')
cntmax = 1
cur = L[0]
temp = 1
for i in range(1,n+1):
  if L[i] == cur:
    temp += 1
  else:
    cur = L[i]
    cntmax = max(cntmax,temp)
    temp = 1
cur = L[0]
temp = 1
for i in range(1,n+1):
  if L[i] == cur:
    temp += 1
  else:
    cur = L[i]
    if temp == cntmax:
      anslist.append(L[i-1])
    temp = 1
anslist.sort()
for i in range(len(anslist)):
  if anslist[i] != 'zzzzzzzzzzzzz':
    print(anslist[i])

Measured memory_bytes: 20680
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;
const int mod=1e9+7;

int n,m,x[N],y[N];

int main() {
	n=read(),m=read();
	for (int i=1;i<=n;++i) x[i]=read();
	for (int i=1;i<=m;++i) y[i]=read();
	int sx=0,sy=0;
	for (int i=1;i<n;++i) sx=(sx+1ll*i*(n-i)%mod*(x[i+1]-x[i]))%mod;
	for (int i=1;i<m;++i) sy=(sy+1ll*i*(m-i)%mod*(y[i+1]-y[i]))%mod;
	printf("%d\n",1ll*sx*sy%mod);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 100000


using namespace std;

using ll =long long;
using P = pair<int,int>;

string replaceAll(string &replacedStr, string from, string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int gettt(long long int num){
    int digit=0;
if(num<10){
digit=0;
}else{
    while(num>1){
        num /= 10;
        digit++;
    }
}
    return digit;
}

int main() {

ios::sync_with_stdio(false);
cin.tie(0);
int a;
int c=-1;
for(int i=0;i<5;i++){
cin>>a;
if(a==0)c=i;
}

cout<<(c+1)<<endl;
}
//double res=10.11;
//printf("%.10f",ans);
//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;


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

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

using namespace std;

const int INF = 10000;

int repe1(int i)
{
	if (i % 10 == 3 || i < 30) {
		return i % 10;
	}
	return repe1(i / 10);
}



int main()
{
	
	int N;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		
		//末尾に3があるか、途中に3があるか
		if (i % 3 == 0 ||  i % 10 == 3 || repe1(i) == 3) {
			cout << " " << i;
		}
	}
	cout << endl;

	return 0;
}



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

using namespace std;

int main(){
	int n; scanf("%d", &n);
	//int a; scanf("%d", &a);
	int arr[n];
	for(int i=0;i<n-1;i++)
		scanf("%d", &arr[i]);
	int s=arr[0];
	for(int i=1;i<n-1;i++)
		s+=(min(arr[i],arr[i-1]));
	s+=arr[n-2];
	printf("%d\n", s);
}

Measured memory_bytes: 256
n=int(input())
abc=[]
for i in range(n):
    x=tuple(map(int,input().split()))
    abc.append(x)
dp=[[0]*n for _ in range(3)]
for i in range(3):
    dp[i][0]=abc[0][i]

for i in range(1,n):
    x=abc[i]
    for j in range(3):
        dp[j][i]=max(dp[j][i],dp[(j+1)%3][i-1]+x[j],dp[(j+2)%3][i-1]+x[j])

ans=0
for i in range(3):
    ans=max(ans,dp[i][-1])
print(ans)

Measured memory_bytes: 64600
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int n,s=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    while(a%2==0){
      s++;
      a/=2;
    }
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
s = input()[:-1]

length = len(s)

for a in range(length, 1, -1):
  temp = s[:a]
  if len(temp) %2 == 0:
    half = len(temp)//2
    if temp[:half] == temp[half:]:
      ans = len(temp)
      break #ここでbreakするために，forを大きいところから回してる
    
print(ans)


Measured memory_bytes: 2940
#pragma GCC optimize("O2,unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
int maxn = 531441, B, C;
int n, p[531441], f[531441];
int rev(int a) {
	int r = 0, c = 1;
	while(c < maxn) {
		if(a%3) r +=(3 - (a%3))*c;
		c*=3,a/=3;
	}
	return r;
}
 
int s = 0;
vector<int> small[729];
int id[531441], lup[531441], u = 0;
 
void add() {
	s = (s + B - 1)%B;
	for(auto i : small[s]) {
		if(lup[i] != u) {
			if((lup[i]^u)&1) id[i] = f[id[i]];
			lup[i] = u;
		}
		id[i] = (id[i] + 1)%C;
	}
}
 
void flip() {
	u++;
	for(int i = 0; i < B; i++) {
		if(f[i] <= i) {
			swap(small[(s+i)%B], small[(s+f[i])%B]);
		}
	}
}
 
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string t;
	cin >> n >> t;
	maxn = B = 1;
	for(int i = 0; i < n; i++) maxn *= 3;
	for(int i = 0; i < n/2; i++) B *= 3;
	C = maxn/B;
	for(int i = 0; i < maxn; i++) {
		f[i] = rev(i);
		small[i%B].push_back(i);
		id[i] = i/B;
	}
	
	for(auto i : t) {
		if(i == 'R') add();
		else flip();
	}
	for(int i = 0; i < B; i++)
		for(auto j : small[i]) p[j] += (B+i-s)%B;
	for(int i = 0; i < maxn; i++) {
		if(lup[i] != u) {
			if((lup[i]^u)&1) id[i] = f[id[i]];
			lup[i] = u;
		}
		p[i] += B*id[i];
	}
	for(int i = 0; i < maxn; i++) cout << p[i] << " ";
}


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

int main() {
	int n, m, s, a, mod = 100000;
	while(cin >> n >> m){
		int sum[100010] = {0};
		for(int i = 1; i < n; ++i){
			scanf("%d", &s);
			sum[i + 1] = sum[i] + s;
		}
		int now = 1, ans = 0;
		for(int i = 0; i < m; ++i){
			scanf("%d", &a);
			if(a >= 0)
				ans += sum[now + a] - sum[now];
			else
				ans += sum[now] - sum[now + a];
			ans %= mod;
			now += a;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1636
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    string s;
    cin >> s;

    bool ok = true;
    if (s.size() != A + B + 1)
        ok = false;
    else if (s[A] != '-')
        ok = false;
    else
        for (int i = 0; i < s.size(); i++)
            if (i != A && !isdigit(s[i]))
                ok = false;

    cout << (ok ? "Yes" : "No") << endl;
}


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

typedef long long ll;
const int mod = 1e9 + 7;
string S;
ll H, W;
vector<string> v;

int main() {
    cin >> H >> W;
    v.resize(H);
    rep(i, H) cin >> v[i];

    // 横方向, 縦方向
    // ll c1[H][W], c2[H][W];
    ll ans[H][W];
    memset(ans, 0, sizeof(ans));
    rep(i, H) {
        vector<ll> done(W);
        rep(j, W) {
            // printf("i: %lld j: %lld ans: %lld\n", i, j, ans[i][j]);
            if (v[i][j] == '#') continue;
            if (done[j]) continue;

            ll l = 0;
            while (j + l < W) {
                if (v[i][j + l] == '#') break;
                l++;
            }

            rep(k, l) {
                ans[i][j + k] += l;
                done[j + k] = 1;
            }
        }
    }

    rep(i, W) {
        vector<ll> done(H);
        rep(j, H) {
            if (v[j][i] == '#') continue;
            if (done[j]) continue;

            ll l = 0;
            while (j + l < H) {
                if (v[j + l][i] == '#') break;
                l++;
            }

            rep(k, l) {
                ans[j + k][i] += l;
                done[j + k] = 1;
            }
        }
    }

    ll max_v = 0;
    rep(i, H)rep(j, W) {
        max_v = max(max_v, ans[i][j] - 1);
    }

    cout << max_v << endl;
}

Measured memory_bytes: 35584
#include "stdio.h"

struct Card{
  char suit;
  int value;
};

void merge(Card matrix[], int left, int mid, int right){
  int n1,n2;
  n1 = mid - left;
  n2 = right - mid;

  Card* Left = new Card [n1+1];
  Card* Right = new Card [n2+1];

  for(int i=0;i<n1;i++){
    Left[i] = matrix[left+i];
  } 
  for(int a=0;a<n2;a++){
    Right[a] = matrix[mid+a];
  }

  Card max;
  max.suit = 'M';
  max.value = 2000000000;
  Left[n1] = max;
  Right[n2] = max;

  int i=0;
  int j=0;

  for(int k=left;k<right;k++){
    if(Left[i].value <= Right[j].value){
      matrix[k] = Left[i];
      i++;
    }else{
      matrix[k] = Right[j];
      j++;
    }
  }
  
  delete [] Left;
  delete [] Right;

}

void mergeSort(Card matrix[], int left, int right){
  if( left + 1 >= right){
    return;
  }
  
  int mid;
  mid = (int)( (left+right)/2.0 );

  mergeSort(matrix, left, mid);
  mergeSort(matrix, mid, right);
  merge(matrix, left, mid, right);
}

int partition(Card matrix[], int p, int r){
  int i;
  int j;
  i = p-1;

  Card standard = matrix[r];

  Card temp;
  for(j=p;j<r;j++){
    if(matrix[j].value <= standard.value){
      i = i + 1;
      temp = matrix[i];
      matrix[i] = matrix[j];
      matrix[j] = temp; 
    }     
  }  
  
  temp = matrix[i + 1];
  matrix[i+1] = matrix[r];
  matrix[r] = temp;

  return i+1;
}

void quickSort(Card matrix[], int p, int r){
  if(p < r){
    int q = partition(matrix, p, r);
    quickSort(matrix, p, q-1);
    quickSort(matrix, q+1, r);
  }
}

bool isSameMatrix(Card matrix1[], Card matrix2[], int N){
  for(int i=0;i<N;i++){
    if(matrix1[i].suit != matrix2[i].suit ){
      return false;
    }
  }
  return true;
} 

void outputMatrix(Card matrix[], int N){
  for(int i=0;i<N;i++){
    printf("%s %d\n", &(matrix[i].suit), matrix[i].value);
  }
}


int main(void){

  int N;
  scanf("%d", &N);

  Card* matrix1 = new Card [N];
  Card* matrix2 = new Card [N];

  for(int i=0;i<N;i++){
    scanf("%s %d", &(matrix1[i].suit), &(matrix1[i].value));
    matrix2[i] = matrix1[i];
  }

  mergeSort(matrix1, 0, N);
  quickSort(matrix2, 0, N-1);

  if(isSameMatrix(matrix1, matrix2, N)){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  outputMatrix(matrix2, N);

  delete [] matrix1;
  delete [] matrix2;

  return 0;
}


Measured memory_bytes: 4652
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        for(int m = 0; m < 20; m++) {
            int numA = sc.nextInt();
            if(numA!=0) {
                int foo[] = new int[numA];
                int av[] = new int[numA-2];
                for(int i = 0; i < numA ; i++) {
                    foo[i] = sc.nextInt();
                }
                int max = foo[0];
                int min = foo[0];

                for(int i = 0; i < numA ; i++) {
                    if(max < foo[i]) {
                        max = foo[i];
                    }
                    if(min > foo[i])
                        min = foo[i];
                }

                int count = 0;
                int countMax = 0;
                int countMin = 0;
                for(int i = 0; i < numA; i++) {
                    if(foo[i] == max) {
                        if(countMax == 0) {
                            countMax++;
                        }else {
                            av[count] = foo[i];
                            count++;
                        }
                    }else if(foo[i] == min){
                        if(countMin == 0) {
                            countMin++;
                        }else {
                            av[count] = foo[i];
                            count++;
                        }
                    }else {
                        av[count] = foo[i];
                        count++;
                    }
                }

                int sum = 0;
                for(int i = 0; i< av.length; i++) {
                    sum += av[i];
                }
                System.out.println(sum/av.length);
            }
            else {
                break;
            }
        }
    }


}


Measured memory_bytes: 29352
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;


bool used[N];
vector<int> g[N];


bool ok[N];

void dfs(int v, int depth = 0) {
    if (depth > 2) {
        return;
    }
    ok[v] = true;
    used[v] = true;
    for (auto to : g[v]) {
        if (!used[to]) dfs(to, depth + 1);
    }
    used[v] = false;
}

void solve() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0);
    if (ok[n - 1]) {
        printf("POSSIBLE");
    } else {
        printf("IMPOSSIBLE");
    }
}

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

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

int main()
{
    int A,B,C,X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    int counter = 0;
    for(int i = 0; i <= A; i++){
        for(int k = 0; k <= B; k++){
            for(int n = 0; n <= C; n++){
                if(500*i+100*k+50*n==X) counter++;
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int  s=100000;

	int n;
	scanf("%d",&n);


	for(;n--;){
		if(int(s*1.05)%1000==0){
			s=int(s*1.05);
		}else{
			s= int(s*1.05) + (1000- int(s*1.05) % 1000);
		}
	}
	printf("%d\n",s);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  int sum=0;
  vector<int> point(n,0);
  rep(i,n){
    cin>>point[i];
    sum+=point[i];
  }
  sort(point.begin(),point.end());
  
  int i=0;
  while(i<n && sum%10==0){
    if(point[i]%10!=0)
      sum-=point[i];
    i++;
  }
  if(sum%10==0) sum=0;
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        List<Order> orders = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            Order order = new Order(i, sc.nextInt());
            orders.add(order);
        }

        List<Order> sorted = orders.stream()
            .sorted(Comparator.comparing(Order::getNumber))
            .collect(Collectors.toList());

        for (int i = 0; i < n; i++) {
            System.out.print(sorted.get(i).getOrder() + " ");
        }
    }

    static class Order {
        Integer order;
        Integer number;
        
        public Order(Integer order, Integer number) {
            this.order = order;
            this.number = number;
        }

        public Integer getOrder() {
            return order;
        }

        public Integer getNumber() {
            return number;
        }
    }
}

Measured memory_bytes: 71080
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
 
int main(){
  LL n, a;
  cin >> n >> a;
  
  cout << pow(n,2) - a << endl;
 
  return 0;
}

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

#define ll long long int
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

int main() {_
    ll n;
    cin >> n;
    ll dp[n][3] = {};
    for(int i = 0; i<n; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        if(i == 0) {
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }
        else {
            dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
            dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int K=in();
    string S=in<string>();
    int senaka=0;
    int mukiau=0;
    int ans=0;
    REP(i,N-1){
        if(S[i]=='L'&&S[i+1]=='R'){
            senaka++;
        }else if(S[i]=='R'&&S[i+1]=='L'){
            mukiau++;
        }
        if(S[i]==S[i+1]){
            ans++;
        }
    }
    
    ans+=min(K*2,2*min(senaka,mukiau));
    if(senaka!=mukiau){
        if(K>min(senaka,mukiau)){
            ans++;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h> 
using namespace std;
string s[100005];
int n;
map<string,int> ss;
long long  cmd(int m){
	long long x=0;
	for(int i=m-1;i>0;i--) x += i;
	return x;
}
int main()
{
	long long ans=0;
	cin >>n;
	getchar();
	for(int i=0;i<n;i++){
		getline(cin,s[i]);
		sort(s[i].begin(),s[i].end());
		ss[s[i]]++;
	}
	map<string ,int>::iterator it;
	for(it=ss.begin();it != ss.end();it++){
			ans =ans+cmd(it -> second);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    long long N,K;
    cin >> N >> K;
    
    long long H[N];
    long long sum = 0;
    rep(i,N){
        cin >> H[i];
    }
    
    sort(H,H + N);
    
    if(N <= K){
        cout << 0 << endl;
    }
    else{
        rep(i,N - K){
            sum += H[i];
        }
        cout << sum << endl;
    }
    
}


Measured memory_bytes: 1792
N = int(input())
A = []
B = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
    print(B[N//2] - A[N//2] + 1)
else:
    a0 = A[N//2 - 1]
    b0 = B[N//2 - 1]
    a1 = A[N//2]
    b1 = B[N//2]

    print((b1 + b0) - (a1 + a0) + 1)


Measured memory_bytes: 25444
function main()
  
  (A,B,C) = map(x -> parse(Int,x), split(readline()))
  
  K = parse(Int,readline())
  
  for i in 1:K
    
    if max(A,B,C) == A
      A *= 2
    elseif max(A,B,C) == B
      B *= 2
    else
      C *= 2
    end
    
  end
  
  println(A+B+C)
  
end

main()

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

int main()
{
  int64_t a;
  string b;
  cin >> a >> b;
  int bl = b.length();
  int64_t c = 0;

  for (int i = 0; i < bl; i++) {
    if (b[i] == '.') continue;
    c = c * 10 + b[i] - '0';
  }

  cout << a * c / 100 << endl;
}


Measured memory_bytes: 3624