akhauriyash/Code-Regression huggingface dataset:
program main
implicit none
character(len=100) :: s
integer :: i, j
logical :: status

read(*,*) s
status = .false.

do i = 1, len_trim(s)
if ( s(i:i) == 'C' ) then
j = i
exit
end if
end do

do i = j+1, len_trim(s)
if ( s(i:i) == 'F' ) then
status  = .true.
exit
end if
end do

if (status) then
write(*,'(a)') 'Yes'
else
write(*,'(a)') 'No'
end if

stop
end program main


Measured memory_bytes: 2884
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int v[N];
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int a[n + 1], suf[n + 10] = {};
	FOR (i, 0, n) cin >> a[i];
	
	FORD (i, n, 0) suf[i] = suf[i + 1] + a[i];
	v[0] = 1;
	
	int sum = 0;
	FOR (i, 0, n)
	{
	    sum += v[i];
	    if (v[i] < a[i]) {cout << -1; return 0;}
	    v[i] -= a[i];
	    
	    v[i + 1] = min(2*v[i], suf[i + 1]);
	}
	
	if (v[n]) {cout << -1; return 0;}
	print(sum);
}



















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

#define INF 1e9

int solve(int prev,int i,vector <vector <int> >& in,vector <vector<int> >& dp){
	int n = in.size();
	if(dp[prev][i]>=0) return dp[prev][i];
	if(i==n){ dp[prev][i]=0; return 0;}
	int m=-1;
	for(int j=0;j<=2;j++){
		if(j==prev) continue;
		m=max(m,in[i][j]+solve(j,i+1,in,dp));
		}
	dp[prev][i]=m;
	return m;
	}
int main(){
	int n;
	cin>>n;
	vector <vector <int> > in(n,vector <int> (3,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<=2;j++){
			cin>>in[i][j];
			}
		}
	int m=-1;
	vector <vector <int> > dp(3,vector <int> (n+1,-1));
	for(int i=0;i<=2;i++){
		m=max(m,solve(i,0,in,dp));
		}
	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 16248
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int f(string s)
{
	int ans = 0;
	ans+= (s[0]-'0')*100;
	ans += (s[2]-'0')*10;
	ans += (s[3]-'0')*1;
	return ans;
}

signed main()
{
	int a;
	string bs;
	cin >> a >> bs;
	int ans = a*f(bs)/100;
	printf("%lld\n",ans);
}




Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	Vec2 operator/(T s) const { return Vec2(x/s, y/s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }
	T sqlength() const { return x*x + y*y; }
	double length() const { return sqrt(sqlength()); }
	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

typedef Vec2<double> Vec;

pair<Vec, Vec> Tangent(const Vec& P, const Vec& C, double r)
{
	Vec D = P - C;
	double dc = D.length();
	D = D*(1.0 / dc);
	double t = acos(r / dc);
	Vec m = D*r*cos(t) + C;
	double h = dc * r * sin(t) / dc;
	Vec int1 = m + Vec(D.y, -D.x) * h;
	Vec int2 = m + Vec(-D.y, D.x) * h;
	return make_pair(int1, int2);
}

int main()
{
	typedef Vec2<long long> VecL;
	long long x1, y1, r1, x2, y2, r2;
	cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
	long long dsq = (VecL(x1, y1) - VecL(x2, y2)).sqlength();

	Vec C1(x1, y1), C2(x2, y2);
	Vec D = C2 - C1;
	Vec PO = D * r1 / (r1 - r2) + C1;
	Vec PI = D * r1 / (r1 + r2) + C1;
	auto TO = r1 != r2 ? Tangent(PO, C1, r1) :
		make_pair(Vec(D.y, -D.x) / D.length()*r1 + C1, Vec(-D.y, D.x) / D.length()*r1 + C1);

	vector<Vec> ans;
	if (dsq > (r1 + r2)*(r1 + r2)) {
		auto TI = Tangent(PI, C1, r1);
		ans.push_back(TO.first);
		ans.push_back(TO.second);
		ans.push_back(TI.first);
		ans.push_back(TI.second);
	}
	else if (dsq == (r1 + r2)*(r1 + r2)) {
		ans.push_back(TO.first);
		ans.push_back(TO.second);
		ans.push_back(PI);
	}
	else if (dsq > (r1 - r2)*(r1 - r2)) {
		ans.push_back(TO.first);
		ans.push_back(TO.second);
	}
	else if (dsq == (r1 - r2)*(r1 - r2)) {
		ans.push_back(PO);
	}

	sort(ans.begin(), ans.end());
	for (auto p : ans) {
		printf("%.10lf %.10lf\n", p.x, p.y);
	}
	return 0;
}


Measured memory_bytes: 3464
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int N;
vector<string> S;
vector<pair<string, int>> V;
bool ope1(pair<string, int>A, pair<string, int> B) {
	if (A.second != B.second) return A.second > B.second;
	else return A.first < B.first;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		S.push_back(s);
	}
	sort(S.begin(), S.end());
	string tmps = S[0];
	int tmpi = 1;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == S[i - 1]) tmpi++;
		else {
			auto p = make_pair(tmps, tmpi);
			V.push_back(p);
			tmps = S[i];
			tmpi = 1;
		}
	}
	auto p1 = make_pair(tmps, tmpi);
	V.push_back(p1);

	sort(V.begin(), V.end(), ope1);
	for (int i = 0; i < V.size(); i++) {
		if (V[i].second == V[0].second) cout << V[i].first << '\n';
	}

	return 0;
}

Measured memory_bytes: 18160
L,R = map(int,input().split())

res = []
for i in range(L,R):
    for j in range(i+1,R+1):
        res.append((i*j)%2019)
        if (i*j)%2019 == 0:
            break
    else:
        continue
    break

print(min(res))


Measured memory_bytes: 6888
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
const int N=1e5+5,MAX=3e7,MOD=1e9+7;
 
string a;
ll memo[N][14];
ll solve(int indx,int rem){
	if(indx==sz(a)){
		return (rem == 5);
	}

	ll &ret = memo[indx][rem];
	if(~ret)return ret;
	ret = 0;
	if(a[indx]=='?'){

		for(int i=0;i<=9;i++){
			if(indx==0)
				ret+=solve(indx+1,i);
			else
				ret+=solve(indx+1,(rem*10+i)%13);
			ret%=MOD;
		}
	}	
	else{
		if(indx==0)
			ret=solve(indx+1,(a[indx]-'0'));
		else
			ret = solve(indx+1,(rem*10+(a[indx]-'0'))%13);
		ret%=MOD;
	}

	return ret;
}
int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	cin>>a;
	//reverse(all(a));
	memset(memo,-1,sizeof(memo));
	cout<<solve(0,0)<<"\n";
}

Measured memory_bytes: 16080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001;
const ll INF=1LL<<60;

vector<pair<int,ll>> S[MAX];
ll dis[MAX];
int N;

void dijkstra(int u){
    priority_queue<pair<int,ll>> PQ;
    for(int i=0;i<N;i++){
        dis[i]=INF;
    }
    dis[u]=0;
    PQ.push(make_pair(u,0));

    while(!PQ.empty()){
        int a=PQ.top().first;
        ll b=PQ.top().second;
        PQ.pop();
        if(dis[a]<-b) continue;
        for(int i=0;i<S[a].size();i++){
            int c=S[a][i].first;
            ll d=S[a][i].second;
            if(dis[c]>dis[a]+d){
                dis[c]=dis[a]+d;
                PQ.push(make_pair(c,-dis[c]));
            }
        }
    }
}

int main(){
    
    int E,r;cin>>N>>E>>r;
    for(int i=0;i<E;i++){
        int a,b;
        ll c;cin>>a>>b>>c;
        S[a].push_back(make_pair(b,c));
    }

    dijkstra(r);

    for(int i=0;i<N;i++){
        if(dis[i]==INF) cout<<"INF"<<endl;
        else cout<<dis[i]<<endl;
    }
}



Measured memory_bytes: 33928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef unsigned long long ll;
ll MOD = 1000000007;
// 階乗
ll factorial[1000'000];
// 逆元
ll inverse[1000'000];


// 繰り返し2乗法
ll pow(ll x, ll n){
  ll ans = 1;
  while(n > 0){
    if((n & 1) == 1){
      ans = (ans * x) % MOD;
    }
    x = (x * x) % MOD;
    n >>= 1;
  }
  return ans;
}

// 階乗と逆元の計算
void f(int n){
  factorial[0] = 1;
  inverse[0] = 1;
  for(int i = 1; i <= n; i++){
    factorial[i] = i * factorial[i-1] % MOD;
    inverse[i] = pow(factorial[i], (MOD - 2)) % MOD;
  }
}

// フェルマーの小定理
ll combination(int n, int r){
  //return (factorial[n] * pow(factorial[r], MOD - 2)) % MOD * (pow(factorial[n-r], MOD - 2)%MOD) % MOD;
  return factorial[n] * inverse[r] % MOD * inverse[n-r] % MOD;
}

int main(){
  ll X, Y;
  cin >> X >> Y;
  ll m = 2 * Y - X;
  ll n = 2 * X - Y;
  if(m % 3 != 0 || n % 3 != 0){
    cout << 0 << endl;
    return 0;
  }

  ll a = m / 3;
  ll b = n / 3;
  f(a+b);
  ll answer = combination(a + b, a) % MOD;
  cout << answer << endl;  
  return 0;
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vll h(N), dp(N, INT_MAX); // dp[i] := 足場iに到着するまでに必要なコスト
    rep(i, N)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    rep(i, N - 2)
    {
        dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 1] - h[i + 2]));
    }
    cout << dp.back();
    return 0;
}

Measured memory_bytes: 1792
import sys

def solve(N, A):
  ret=1
  for a in A:
    if a == 0:
      return 0
  for a in A:
    ret*=a
    if ret > 10**18:
      return -1
  return ret
          
N=int(input())
A=list(map(int, input().split()))
print(solve(N,A))

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

int cnt(ll  n){
  int d = 0;
  while(n > 0){
    n /= 10;
    d++;
  }
  return d;
}

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

  int ans = cnt(n);

  for(ll a = 1LL; a*a <= n; a++){
    if(n%a != 0) continue;
    const ll b = n/a;

    const int cur = max(cnt(a), cnt(b));

    if(ans > cur){
      ans = cur;
    }
  }

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



 

Measured memory_bytes: 3628
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll pos[300010] = {};
    set<ll> rpos, gpos, bpos;
    rep(i,0,3*N){
        if(S[i] == 'R') rpos.insert(i);
        else if(S[i] == 'G') gpos.insert(i);
        else bpos.insert(i);
    }

    rrep(i,3*N-1,0){
        if(pos[i] == 0){
            pos[i] = 3;
            if(S[i] == 'R'){
                auto it1 = gpos.lower_bound(i);
                auto it2 = bpos.lower_bound(i);
                it1--; it2--;
                ll vg = *it1, vb = *it2;
                if(vg > vb){ // delete G
                    pos[vg] = 2;
                    pos[vb] = 1;
                }else{
                    pos[vb] = 2;
                    pos[vg] = 1;
                }
                gpos.erase(it1);
                bpos.erase(it2);

            }else if(S[i] == 'G'){
                auto it1 = rpos.lower_bound(i);
                auto it2 = bpos.lower_bound(i);
                it1--; it2--;
                ll vr = *it1, vb = *it2;
                if(vr > vb){ // delete G
                    pos[vr] = 2;
                    pos[vb] = 1;
                }else{
                    pos[vb] = 2;
                    pos[vr] = 1;
                }
                rpos.erase(it1);
                bpos.erase(it2);
            }else{
                auto it1 = rpos.lower_bound(i);
                auto it2 = gpos.lower_bound(i);
                it1--; it2--;
                ll vr = *it1, vg = *it2;
                if(vr > vg){ // delete G
                    pos[vr] = 2;
                    pos[vg] = 1;
                }else{
                    pos[vg] = 2;
                    pos[vr] = 1;
                }
                rpos.erase(it1);
                gpos.erase(it2);
            }
        }
    }
    // printa(pos, 3*N);
    ll ans = 1;
    map<ll, ll> mp;
    mp[0] = N;
    rep(i,0,3*N){
        ans *= mp[pos[i]-1];
        ans %= MOD;
        mp[pos[i]-1]--;
        mp[pos[i]]++;
    }
    print(ans);
    
}

Measured memory_bytes: 16916
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(r,g)=input.split("\n").map(_.toInt)
    (2*g-r).toString
  }
}


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

int main(){
    using psi=pair<string,int>;
    int n,q,t=0;
    cin >> n >> q;
    vector<psi> P(n);
    queue<psi> que;
    for(int i=0;i<n;i++){
        cin >> P.at(i).first >> P.at(i).second;
        que.push(P.at(i));
    }
    while(!que.empty()){
        if(que.front().second>q){
            t+=q;
            que.front().second-=q;
            psi p=que.front();
            que.pop();
            que.push(p);
        }
        else{
            t+=que.front().second;
            cout << que.front().first << " " << t << endl;
            que.pop();
        }
    }
}


Measured memory_bytes: 6752
n, a, b = map(int, input().split())
M = 10**9 + 7
total = pow(2, n, M)

def comb(n, k, p):
    if k > n-k:
        return comb(n, n-k, p)
    num, den = 1, 1
    for i in range(k):
        num = num * (n-i) % p
        den = den * (i+1) % p
    return num * pow(den, p-2, p) % p

print((total - 1 + (M - comb(n,a,M)) + (M - comb(n,b,M))) % M)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int minn=1000000000;
        long long sum=0;
        int ans=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            sum+=abs(a[i]);
            if(a[i]<0) ans++;
            if(abs(a[i])<minn) minn=abs(a[i]);
        }
//        cout<<sum<<endl;
        if(ans%2) sum-=2*minn;
        printf("%lld\n",sum);
    }
}


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

int n;
int c = 0;
int p[50];

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> p[i];
  }
  for(int i = 1; i <= n; ++i){
    if(i != p[i-1]){
      c += 1;
    }
  }
  if(c == 0 || c == 2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main () {
  string s;
  cin >> s ;
  if(
     !(s[0] == s[1] == s[2] == s[2])
     &&
     (((s[0] == s[1])
       &&(s[2] == s[3])
       && (s[1] != s[2]))
      || ((s[0] == s[3])
	  && (s[1] == s[2])
	  && (s[0] != s[2])))
     || ((s[0] == s[2] && (s[1] == s[3]) && s[1] != s[2]))) {
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }
}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	mp := map[int]int{}
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	m := getNextInt(scanner)
	for i := 0; i < m; i++ {
		b := getNextInt(scanner)
		mp[b] = 1
	}
	for i := 0; i < n; i++ {
		if mp[aa[i]] == 0 {
			fmt.Fprintln(writer, aa[i])
		}
	}
}



Measured memory_bytes: 16448
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))


(defparameter n (read))
(defparameter m (read))

(defun distance (a b)
  (+ (abs (- (car a) (car b))) (abs (- (cdr a) (cdr b)))))

(defun nearest (p l)
  (let ((res 0))
	(dotimes (i m)
	  (when (> (distance p (aref l res)) (distance p (aref l i)))
		(setf res i)))
	(1+ res)))

(let ((a (loop for i from 1 to n collect (cons (read) (read))))
	  (b (concatenate 'vector (loop for i from 1 to m collect (cons (read) (read))))))
  (mapc (lambda (target)
		  (princ (nearest target b))
		  (fresh-line))
		a))


Measured memory_bytes: 12860
#include <stdio.h>
#include <string.h>

char A[125];
char B[125];

int main(){

	scanf("%s",A);
	scanf("%s",B);

	int len_A=strlen(A);
	int len_B=strlen(B);

	if(len_A>len_B){
	printf("GREATER\n");
	}
	else if(len_A<len_B){
	printf("LESS\n");
	}
	else{
	int i;
	for(i=0;i<len_A;i++){
		if(A[i]-'0'>B[i]-'0'){
		printf("GREATER\n");
		return 0;
		}
		else if(A[i]-'0'<B[i]-'0'){
		printf("LESS\n");
		return 0;
		}
	}
	printf("EQUAL\n");
	}

	return 0;
}

Measured memory_bytes: 128
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    str t; cin>>t;
    int fl = 1;
    for(int q=0; q<t.size(); q++){
        if(q%2==0) fl&= t[q]!='L';
        else fl&=t[q]!='R';
    }
    if(fl) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
open System
open System.Linq;

let N = stdin.ReadLine()|> int
let A = stdin.ReadLine().Split()|>Array.map int
[<EntryPoint>]
let sf argv =
    let mutable B = [|for i in [0..N-1] -> 0|]
    for i in [0..N-1] do
        B.[A.[i] - 1] <- i+1
    for i in [0..N-1] do
        stdout.Write(B.[i])
        stdout.Write(" ")
    stdout.WriteLine()
    0 

Measured memory_bytes: 37320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int main() {
	string s;cin>>s;
	cout<<s[0]<<s[1]<<s[2];
	return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
  long long X, Y;
  cin >> X >> Y;

  long long ng = 1e18 + 1;
  long long ok = 1;
  while (abs(ok - ng) > 1) {
    long long m = (ok + ng)/2;

    if (m * X > Y) {
      ng = m;
    } else {
      ok = m;
    }
  }

  long long ans = 1;
  long long aa = X;

  while (ans <= ok) {
    aa *= 2;
    if (aa > Y) break;
    ans++;
  }

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


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

using namespace std;
int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int N,M;
	cin >> N >> M;
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 0,x; i < N; i++){
		cin >> x;
		q.push(x);
	}
	vector <pair<int,int>> query(M);
	for(int i = 0; i < M; i++){
		cin >> query[i].second >> query[i].first;
	}
	sort(query.rbegin(),query.rend());
	for(int i = 0; i < M; i++){
		for(int j = 0; j < query[i].second && q.top() < query[i].first; j++){
			q.pop();
			q.push(query[i].first);
		}
	}
	long long int ans = 0;
	while(!q.empty()){
		ans += q.top();
		q.pop();
	}
	cout << ans;
}

Measured memory_bytes: 1528
#include<stdio.h>

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> v(n+1);
    
    for(int i=1; i<=n; i++){
        cin>>v[i];
    }
    
    auto itmax=max_element(v.begin()+1,v.end());
    auto itmin=min_element(v.begin()+1,v.end());
    
    int pmax=itmax-v.begin(), pmin=itmin-v.begin();
    
    vector<pair<int,int>> ops;
    if(*itmax>=-(*itmin)){
        for(int i=1; i<=n; i++){
            if(v[i]<0){
                v[i]+=*itmax;
                ops.push_back({pmax,i});
            }
        }
        for(int i=2; i<=n; i++){
            if(v[i]<v[i-1]){
                v[i]+=v[i-1];
                ops.push_back({i-1,i});
            }
        }
    }
    else{
        for(int i=1; i<=n; i++){
            if(v[i]>0){
                v[i]+=*itmin;
                ops.push_back({pmin,i});
            }
        }
        for(int i=n-1; i>=1; i--){
            if(v[i]>v[i+1]){
                v[i]+=v[i+1];
                ops.push_back({i+1,i});
            }
        }
    }
    cout<<ops.size()<<endl;
    for(auto p:ops){
        cout<<p.first<<" "<<p.second<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int cnt[10][10];
int firstDig(int x){
        while(x){
                if(x<10) return x;
                x/=10;
        }
        return x;
}
int lastDig(int x){
        return x%10;
}
int main(){
        int n;
        while(~getI(n)){
                F(i,0,10) F(j,0,10) cnt[i][j]=0;
                FE(i,1,n) cnt[firstDig(i)][lastDig(i)]++;
                int ans=0;
                F(i,0,10) F(j,0,10) ans+=cnt[i][j]*cnt[j][i];
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
//using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    vector<vector<ll>>a(n,vector<ll>(3));
    rep(i,n){
        cin>>a[i][1]>>a[i][2]>>a[i][0];
    }
    ll H,cnt=0;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            rep(k,n){
                if(a[k][0]==0)continue;
                H=a[k][0]+abs(a[k][1]-i)+abs(a[k][2]-j);
                break;
            }
              cnt=0;
            rep(k,n){
                if((H-abs(a[k][1]-i)-abs(a[k][2]-j))<=0&&a[k][0]==0)cnt++;
                else if((H-abs(a[k][1]-i)-abs(a[k][2]-j))==a[k][0])cnt++;
            }
            if(cnt==n&&H>=1){
                cout<<i<<" "<<j<<" "<<H<<endl;
                return 0;
            }
        }
    }
}











Measured memory_bytes: 3616
# 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 _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
using pt = pair<int,int>; 
int n;
ll ans[N];
pt a[N];

int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i].F;
		a[i].S = i;
	}


	sort(a + 1, a + n + 1);
	int mn = 1e9;

	for (int i = n; i >= 1; --i) {
		mn = min(mn, a[i].S);
		ans[mn] += (a[i].F - a[i-1].F) * (ll)(n - i + 1);
	}

	for (int i = 1; i <= n; i ++)
		cout << ans[i] << '\n';

   	return Accepted;
}

// B...a

Measured memory_bytes: 3968
# -*- coding: utf-8 -*-


def main():
    a, b, c, d, e, f = map(int, input().split())
    concentration = 0
    water_set = set()
    sugar_set = set()

    # See:
    # https://www.youtube.com/watch?v=nCHz87GMdpo
    for i in range(f + 1):
        for j in range(f + 1):
            y = c * i + d * j

            if y <= f:
                sugar_set.add(y)

    for k in range(0, f + 1, 100):
        for l in range(0, f + 1, 100):
            x = a * k + b * l

            if 0 < x <= f:
                water_set.add(x)

    sugar_water_amount = min(water_set) + min(sugar_set)
    sugar_amount = min(sugar_set)

    for water in water_set:
        for sugar in sugar_set:
            if (water + sugar <= f) and (sugar <= e * (water // 100)):
                candidate = (100 * sugar) / (water + sugar)

                if candidate > concentration:
                    concentration = candidate
                    sugar_water_amount = water + sugar
                    sugar_amount = sugar

    print(sugar_water_amount, sugar_amount)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int A[100];
int main() {
	int N;
	cin >> N;
	rep(i, N) cin >> A[i];
	int ans = 1 << 30;
	REP(i, -100, 101) {
		int sum = 0;
		rep(j, N) sum += (A[j] - i)*(A[j] - i);
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 int cmp(const void * a,void * b)
 {
     return *(int *)b - *(int *)a;
 }
 int a[2][101];
 int main()
 {
     int q[101],N,i,j,k,sum;
     scanf("%d",&N);
     for(i=0;i<N;i++){
        scanf("%d",&a[0][i]);
     }
     for(i=0;i<N;i++){
        scanf("%d",&a[1][i]);
     }
     for(i=0;i<N;i++){
        sum = 0;
        for(j=0;j<=i;j++){
            sum += a[0][j];
        }
        for(k=i;k<N;k++){
            sum += a[1][k];
        }
        q[i] = sum;
     }
    // printf("%d\n",q[N-1]);
     qsort(q,N,sizeof(q[0]),cmp);
     printf("%d",q[0]);
     return 0;
 }


Measured memory_bytes: 128
S = input()
index = 0
while True:
    if S.find("eraser", index) == index:
        index += len("eraser")

    elif S.find("erase", index) == index:
        index += len("erase")

    elif S.find("dreamer", index) == index and S.find("ase", index + len("dreamer")) != index + len("dreamer"):
        index += len("dreamer")

    elif S.find("dream", index) == index:
        index += len("dream")

    elif index == len(S):
        print("YES")
        break
    else:
        print("NO")
        break


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int N;
	cin >> N;
	vector<int> nums(N);
	int i;
	int count=0;
	rep(i, N) {
		cin >> nums[i];
		if (i % 2 == 0) {
			if (nums[i] % 2 == 1)count = count + 1;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
  int a, i; 
  int Y[50];
  scanf("%d", &a);
  Y[0]=Y[1]=1;
  for ( i = 2; i <= a; i++ ){ Y[i]=Y[i-1]+Y[i-2];
  }
    printf("%d\n", Y[a]);
  return 0;
}



Measured memory_bytes: 2052
a, b, c, x, y = map(int, input().split())
count = 0

if x >= y:
	i = a * (x - y) + c * y * 2
	j = a * x + b * y
	k = c * x * 2
	if i >= j and k >= j:
		count = j
	elif i >= k and j >= k:
		count = k
	elif j >= i and k >= i:
		count = i
else:
	i = b * (y - x) + c * x * 2
	j = a * x + b * y
	k = c * y * 2
	if i >= j and k >= j:
		count = j
	elif i >= k and j >= k:
		count = k
	elif j >= i and k >= i:
		count = i

print(count)

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn range_year(n: usize) -> bool {
    ((12 < n) && (n <= 99)) || ((0 <= n) && (n <= 99))
}

fn range_both(n: usize) -> bool {
    (1 <= n) && (n <= 12)
}

fn range_month(n: usize) -> bool {
    range_both(n)
}

fn main(){
    let n: usize = read();
    let f = n / 100;
    let l = n % 100;
    if range_both(f) && range_both(l) {
        println!("AMBIGUOUS");
    }
    else if range_month(f) && range_year(l) {
        println!("MMYY");
    }
    else if range_year(f) && range_month(l) {
        println!("YYMM");
    }
    else if range_year(f) && range_year(l) {
        println!("NA");
    }
}



Measured memory_bytes: 4352
x,y,a,b,c=map(int,input().split())

p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r)

box=[]

ans=0


for i in range(x):
    box.append(p[i])

for j in range(y):
    box.append(q[j])

box = box + r

box=sorted(box,reverse=True)

for k in range(x+y):
    ans+=box[k]

print(ans)

Measured memory_bytes: 29672
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  cin>>s>>n;
  set<string> ss;
  for(int i=0;i<s.size();i++){
    for(int j=1;j<6;j++){
      if(i+j<=s.size()){
        ss.insert(s.substr(i,j));
      }
    }
  }
  int i=1;
  for(string sss:ss){
    if(i==n){
      cout<<sss;
      return 0;
    }
    i++;
  }
}

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

using namespace std;

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

	vector< int > vec( a );

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

	//	--------------------------------------------------

	bool manzoku = false;
	int manzokuCnt = 1;
	int cnt = 0;

	for( auto &it : vec )
	{
		if( it == manzokuCnt )
		{
			manzoku = true;
			manzokuCnt ++;
		}
		else
		{
			cnt ++;
		}
	}

	if( !manzoku ) cnt = -1;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	bool done[n+1]={0};
	int pen[n+1]={0};
	for(int i=0;i<m;i++){
		int x;
		string ver;
		cin>>x>>ver;
		if(ver=="WA" && !done[x]) pen[x]++;
		if(ver=="AC" && !done[x]) done[x]=1;
	}
	int sol=0,pena=0;
	for(int i=1;i<=n;i++){
		if(pen[i]>0 && done[i]) pena+=pen[i];
		if(done[i]) sol++;
	}
	cout<<sol<<" "<<pena;
	return 0;
}

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

#define ll long long

int main()
{
    ll n,i,j,k,l;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else
    {
        cin>>k>>l;
        cout<<k+l<<endl;
    }
}


Measured memory_bytes: 256
fun main() {
    val builder = StringBuilder()

    val mod = 998244353L

    val (n, s) = readInputLine().split(" ").map { it.toInt() }

    val aArr = readInputLine().split(" ").map { it.toInt() }

    val dp = Array(n + 1) { LongArray(s + 1) }

    dp[0][0] = 1L

    for ((i, a) in aArr.withIndex()) {
        for (j in 0..s) {
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 2L) % mod
            if (j + a <= s) {
                dp[i + 1][j + a] = (dp[i + 1][j + a] + dp[i][j]) % mod
            }
        }
    }

    builder.appendln(dp[n][s])

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 108040
package main

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

func scan(buf []int, s *bufio.Scanner) {
	for i := range buf {
		s.Scan()
		v, _ := strconv.Atoi(s.Text())
		buf[i] = v
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	aa := make([]int, n)
	bb := make([]int, n)
	cc := make([]int, n)

	scan(aa, s)
	scan(bb, s)
	scan(cc, s)

	sort.Ints(aa)
	sort.Ints(cc)

	sum := 0
	for _, b := range bb {
		i := sort.SearchInts(aa, b)
		j := sort.SearchInts(cc, b+1)
		sum += i * (n - j)
	}

	fmt.Println(sum)
}


Measured memory_bytes: 6016
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
vector<vector<ll>> vec;
ll N, M, Q;
ll res=0;
void dfs(string s){
    if(s.size()==N+1){
        ll tempres=0;
        rep(i,Q){
            if ((s[vec[i][1]]-'0')-(s[vec[i][0]]-'0')==vec[i][2]) {
                tempres += vec[i][3];
            }
        }
        chmax(res,tempres);
        return;
    }
    for(int i=s.back()-'0';i<=M;i++){
        dfs(s+(char)(i+'0'));
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin>>N>>M>>Q;
    vec.resize(Q,vector<ll>(4));
    rep(i,Q){
        rep(j,4){
            cin>>vec[i][j];
        }
    }
    dfs("1");
    cout<<res<<endl;
}


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

ll gcd(ll a, ll b) {
    if(a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = c * d / gcd(c, d);
    ll ans = b - a + 1 -
             (b / c - (a - 1) / c + b / d - (a - 1) / d - b / e + (a - 1) / e);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = 100100100100;
const int MOD = 1000000007;
const ld EPS = 1e-10;


ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(){
  int N, M; cin >> N >> M;
  vector<int> A(N);
  rep(i, N){
    cin >> A[i];
    A[i] /= 2;
  }

  vector<int> c(N);
  rep(i, N) {
    while (A[i] % 2 == 0) {
      A[i] /= 2;
      c[i]++;
    }
  }
  int min_c = *min_element(ALL(c));
  int max_c = *max_element(ALL(c));
  if (min_c != max_c) {
    cout << 0 << endl;
    return 0;
  }
  M /= 1<<min_c;

  ll l = 1;
  rep(i, N) {
    l = lcm(l, A[i]);
    if (l > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = (M / l + 2 - 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
#define int long long
using namespace std;
signed main(){
    int n; cin>>n;
    map<string,int> m;
    for(int i=0;i<n;++i){
        string s; cin>>s;
        m[s]++;
    }
    int maxv=0;
    for(const auto& x:m){
        if(x.second>maxv) maxv=x.second;
    }
    for(const auto& x:m){
        if(x.second==maxv) cout<<x.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int I;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    long long int n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    

    return 0;
} //カモンAC

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
using namespace std;
#define int long long
#define loop(i,a,b) for(i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define vct vector
#define stk stack
#define qu queue
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define br break
#define con continue
#define re return
#define tc(t) int t; cin>>t; while(t--)
#define q(q) int q; cin>>q; while(q--)
#define subs substr
#define er erase
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;
signed main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        /*int te;
        cin>>te;
        while(te--)*/{
                int s,max_sum=0,temp_sum=0,even=0,odd=0,color=1,oka=5,okb=0,inda=-1,indb=-1,n,maxf=INT_MAX,y,index=0,d,z,p=1,i,j,k,x=1,l,sum=0,ans=0,count=LONG_MAX,count2=0,count1=0,count3=0,ans1,ans2,berry=0,straw=0,berry1=0,straw1=0,berry2=0,straw2=0;
                cin>>n;
                vct<int> a(n+1),b(n+1),c(n+1);
                loop(i,1,n+1){
                        cin>>a[i]>>b[i]>>c[i];
                }
                int t[n+1][4]={0};
                t[1][1]=a[1];
                t[1][2]=b[1];
                t[1][3]=c[1];
                for(i=2;i<=n;i++){
                        t[i][1]=max(t[i-1][2]+a[i],t[i-1][3]+a[i]);
                        t[i][2]=max(t[i-1][1]+b[i],t[i-1][3]+b[i]);
                        t[i][3]=max(t[i-1][2]+c[i],t[i-1][1]+c[i]);
                }
                cout<<max(t[n][1],max(t[n][2],t[n][3]));
        }
        return 0;
}


Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main()
{
int K,N,p[1000],temp,sum=0;
cin>>N>>K;
for( int i=0;i<N;i++){
    cin>>p[i];
}
for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
        if(p[j]<p[i]){
            temp= p[i];
            p[i]=p[j];
            p[j]=temp;
        }
    }
}
for(int i=0;i<K;i++){
    sum=sum+p[i];
}
cout<<sum;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#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)) //最小値を求める
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string s;
    cin>>s;
    char a;
    REP(i,s.length()){
        a=s[i];
        a=(a+n-65)%26;
        a+=65;
        cout<<a;
    }
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int n;

int main(){
    int n,k;
    string str;
    cin>>n>>str>>k;
    char s=str[k-1];
    rep(i,n){
        if(str[i]!=s)str[i]='*';
    }
    cout<<str<<endl;
}

Measured memory_bytes: 256
import math
from bisect import bisect_right  # クエリより真に大きい値が初めて現れるインデックスを教えてくれる
# 初めて爆弾が届かない範囲を記録しながら前から順に倒していく
N, D, A = map(int, input().split())  # N体のモンスター, 爆弾の範囲D, 爆弾の威力A
XH = []
X = []
for _ in range(N):
    x, h = map(int, input().split())
    XH.append((x, math.ceil(h/A)))
    X.append(x)
# 座標で昇順ソート
XH.sort()
X.sort()
# 前から倒していく
now = 0
ans = 0
T = [0]*(N+1)  # 爆弾の範囲が切れる場所を記録しておく
for i in range(N):
    x, h = XH[i]  # 今見ているモンスターの座標, 体力
    now -= T[i]  # そのモンスターに届いていない爆弾があるなら引く
    if now >= h:  # 今残っている爆弾だけで倒せるならcontinue
        continue
    else:
        ans += h - now  # 足りない分(h-now個)の爆弾を使う
        T[bisect_right(X, x+2*D)] += h - now  # 爆弾の範囲が切れる場所を記録しておく
        now = h  # 今影響が残っている爆弾の威力
print(ans)


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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  int a,b; cin>>a>>b;
  int area;
  area = (a-1)*(b-1);
  printf("%d",area);
  return 0;
}

Measured memory_bytes: 256