akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)

const ll INF = (1LL << 62) - 1;

void solve() {
	int N, R;
	cin >> N >> R;
	cout << (N >= 10 ? R : R + 100 * (10 - N)) << endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	solve();

}

Measured memory_bytes: 256
n, m = map(int, input().split())
sss = []
for i in range(m):
    _, *ss = list(map(int, input().split()))
    sss.append(ss)
ps = list(map(int, input().split()))

ret = 0
for i in range(2 ** n):
    lst = [(i & (2 ** j) == 0) for j in range(n)]

    f = True
    for idx, ss in enumerate(sss):
        cnt = 0
        for s in ss:
            cnt += lst[s - 1]
        if cnt % 2 != ps[idx]:
            f = False
            break

    if f:
        ret += 1
print(ret)


Measured memory_bytes: 3064
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, X;
    cin >> N >> X;
    int m[N];
    rep(i, N) cin >> m[i];
    sort(m, m+N);
    rep(i, N){
        X -= m[i];
    }
    cout << N + X/m[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int l[100000], r[100000];

int main() {
    cin >> n;
    rep(i,n) cin >> l[i] >> r[i];
    sort(l, l+n, greater<int>()); sort(r, r+n);

    ll ans1 = 0;
    ll pre = 0;
    rep(i,n) {
        if (l[i] < pre) break;
        ans1 += l[i] - pre;
        pre = l[i];
        if (pre < r[i]) break;
        ans1 += pre - r[i];
        pre = r[i];
    }
    ans1 += abs(pre);
    ll ans2 = 0;
    pre = 0;
    rep(i,n) {
        if (r[i] > pre) break;
        ans2 += pre - r[i];
        pre = r[i];
        if (pre > l[i]) break;
        ans2 += l[i] - pre;
        pre = l[i];
    }
    ans2 += abs(pre);
    cout << max(ans1, ans2) << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N,K; cin >> N >> K;
    int l[100];

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

    sort(l,l+N); reverse(l,l+N);

    int ans = 0;
    for (int i = 0;i < K;i++){
        ans += l[i];
    }

    cout << ans << endl;

    return 0;

}

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

int main(int argc, char *argv[]) {
  int N, M, X, Y;
  int x[100], y[100];
  int max_x, min_y;
  // read input
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  for (int i = 0; i < N; i++)
    scanf("%d", &x[i]);
  for (int i = 0; i < M; i++)
    scanf("%d", &y[i]);
  // find max_x and min_y
  max_x = -100;
  for (int i = 0; i < N; i++)
    if (x[i] > max_x)
      max_x = x[i];
  min_y = 100;
  for (int i = 0; i < M; i++)
    if (y[i] < min_y)
      min_y = y[i];
  // decide
  if (max_x < min_y && max_x < Y && min_y > X)
    printf("No War\n");
  else
    printf("War\n");
  return 0;
}


Measured memory_bytes: 128
#
import sys
import math
import numpy as np
import itertools



# いくつか入力
s, t = input().split()
# いくつか入力
a, b = (int(i) for i in input().split())  
u = input()

if s==u:
    print(a-1,b)
else:
    print(a,b-1)




Measured memory_bytes: 21488
from collections import Counter
n=int(input())
a=[]
for i in range(n):
    a.append(input())
m=int(input())
b=[]
for i in range(m):
    b.append(input())
ans=0
a_counter=Counter(a)
b_counter=Counter(b)

for i in a_counter:
    d=a_counter[i]
    if i in b_counter:
        d-=b_counter[i]
    else:
        d=d
    ans=max(ans,d)
    d=0
print(ans)

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

using namespace std;

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S;
  T = "";
  if(S.size() <= N){
    cout << S << endl;
  }
  else{
    for(int i = 0; i < N; i++){
    T = T + S.at(i);
    }
    cout << T + "..." << endl;
  }
}

Measured memory_bytes: 3628
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;

const int N = 1e5 + 5;

int a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 0; i + 1 < n; i++) {
        if (-a[i] - a[i + 1] > a[i] + a[i + 1]) {
            a[i] = -a[i];
            a[i + 1] = -a[i + 1];
        }
    }
    for (int i = 0; i < n; i++) {
        ans += a[i];
    }
    cout << ans;
    return 0;
}

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

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

int main(){
   int n, a[3];
   cin>>n>>a[0]>>a[1]>>a[2];
   string s[100000];
   rep(i, n) cin>>s[i];

   int ans[100000];
   rep(i, n){
      int e, f;
      e=s[i][0]-'A';
      f=s[i][1]-'A';
      if(a[e]==0 && a[f]==0){
         cout<<"No"<<endl;
         return 0;
      }
      else if(a[e]==0){
         ans[i]=e; a[e]++; a[f]--;
      }
      else if(a[f]==0){
         ans[i]=f; a[f]++; a[e]--;
      }
      else if(a[e]==1 && a[f]==1 && i!=n-1){
         int g, h;
         g=s[i+1][0]-'A';
         h=s[i+1][1]-'A';
         if(e==g || e==h){
            ans[i]=e; a[e]++; a[f]--;
         }
         else{
            ans[i]=f; a[f]++; a[e]--;
         }
      }
      else{
         if(a[e]<a[f]){
            ans[i]=e; a[e]++; a[f]--;
         }
         else{
            ans[i]=f; a[f]++; a[e]--;
         }
      }
   }

   cout << "Yes" << endl;
   rep(i, n) cout << (char)('A'+ans[i]) << endl;
   return 0;
}


Measured memory_bytes: 7128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


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);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



int main() {


	int n;
	cin >> n;
	vector<int> a(n), b(n);
	int maxi = -1;
	int sec_maxi = -1;
	map<int, int> mp;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		maxi = max(maxi, a[i]);
		mp[a[i]]++;
	}

	for (int i = 0; i < n; i++)
	{
		if (sec_maxi < a[i]) {
			if (a[i] != maxi) {
				sec_maxi = a[i];
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (a[i] != maxi) {
			cout << maxi << endl;
		}
		else
		{
			if (mp[maxi] > 1) {
				cout << maxi << endl;
			}
			else
			{
				cout << sec_maxi << endl;
			}
		}
	}
	









	

	return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';


signed main(){
    ll a[2], b[2];
    cin>>a[0]>>a[1]>>b[0]>>b[1];
    ll ans = -1e18;
    for(int i = 0; i < 2; ++i) for(int j = 0; j < 2; ++j) ans = max(ans, a[i]*b[j]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long


double calc(int a,int b){
    return abs(a - b) * abs(a - b);
}
int main(){
    int ans = 0;
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N;i++)
    {
        for (int j = 0; j < D;j++)
        {
            cin >> X[i][j];
        }
    }
    for (int i = 0; i < N;i++)
    {
        for (int j = i + 1; j < N;j++)
        {
            double calced = 0;
            for (int k = 0; k < D; k++)
            {
                calced = calced +(double)calc(X[i][k], X[j][k]);
            }
            calced = sqrt(calced);
            if (floor(calced) == calced)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  REP(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }

  usll S;
  ll now_i = 0;
  ll count = 0;
  for (;;) {
    if (now_i == 1) {
      cout << count << endl;
      return 0;
    }

    if (S.find(A[now_i] - 1) != S.end()) {
      cout << -1 << endl;
      return 0;
    }

    count++;
    now_i = A[now_i] - 1;
    S.emplace(now_i);
  }

  return 0;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    int m;
    cin >> n >> m;
    string s;
    cin >> s;
    int cnt = 0;
    REP(i,n-1){
        if(s[i] != s[i+1]){
            cnt++;
        }
    }
    cnt++;
    int t = n;
    t -= cnt;
    t += m*2;

    print(min(n-1,t));
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}





Measured memory_bytes: 512
import numpy as np
N,M=map(int,input().split(' '))
LR=[list(map(int,input().split(' '))) for i in range(M)]
LR=np.array(LR)

if min(LR[:,1])-max(LR[:,0])+1>0:
  print(min(LR[:,1])-max(LR[:,0])+1)
else:
  print(0)

Measured memory_bytes: 37884
//  .:::.   .:::.
// :::::::.:::::::
// :::::::::::::::
// ':::::::::::::'
//   ':::::::::'
//     ':::::'
//       ':'
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
using namespace std;
ll a[100001][3], dp[100001][3];
int main()
{
    FIO;
    ll t, q, maxx, n, m, k, i, j, k1, k2, k3, x, flag, ans, sum, cnt, prev;
    string ss1, ss2;
    cin>>ss1>>ss2;
    n = sz(ss1);
    m = sz(ss2);
    ll dp[n+1][m+1];
    // char prev[n+1][m+1];
    memset(dp,0,sizeof(dp));
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            if( ss1[i] == ss2[j])
            {
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
        }

    }
    maxx = 0;
    k1 = k2 = 0;
    rep(i,0,n+1)
    {
        rep(j,0,m+1)
        {
            if( dp[i][j] > maxx)
            {
                k1 = i;
                k2 = j;
                maxx = dp[i][j];
            }
        }
    }
    vector<char> v;
    i = k1;
    j = k2;
    // if( i != -1)
    // {
    //     flag = 1;
    // }
    while( i != 0 or j!= 0 and flag)
    {
        if( dp[i-1][j-1] + 1 == dp[i][j] and (ss1[i-1] == ss2[j-1]))
        {
            v.pb(ss1[i-1]);
            i--;
            j--;
        }
        else if( dp[i-1][j] == dp[i][j])
        {
            i--;
        }
        else if( dp[i][j-1] == dp[i][j])
        {
            j--;
        }
        else
        {
            break;
        }
    }
    // cout<<dp[n][m]<<endl;
    reverse(all(v));
    for(i = 0; i < sz(v);++i)
    {
        cout<<v[i];
    }
    if( sz(v) == 0)
    {
        cout<<"";
    }
    cout<<endl;

    return 0;    
}
/*
axyb
abyxb
*/

Measured memory_bytes: 70656
#include <stdio.h>

int main()
{
     char s1[11], s2[11], s3[11];
     scanf("%s %s %s", s1, s2, s3);

     char a1 = s1[0] - 32;
     char a2 = s2[0] - 32;
     char a3 = s3[0] - 32;

     printf("%c%c%c\n", a1, a2, a3);

     return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String[] kyoku = new String[N];
        int[] kyoku_num = new int[N];
        for(int i=0;i<N;i++){
            kyoku[i]=scan.next();
            kyoku_num[i]=scan.nextInt();
        }
        String a = scan.next();
        int ans = 0;
        boolean flg = false;
        for(int i=0;i<N;i++){
            if(flg){
                ans+=kyoku_num[i];
            }
            if(a.equals(kyoku[i])){
                flg=true;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> p_i;

int main()
{
    string s;
    cin >> s;
    int dnm = 0;
    for (int i = 0; i < s.size(); i++)
    {
        dnm += s[i] - '0';
    }
    int n = atoi(s.c_str());
    if (n % dnm == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * File              : B - Contests.cpp
 * Author            : horcrux2301 <khajuriaharsh729@gmail.com>
 * Date              : 12.01.2019 17:38:53
 * Last Modified Date: 12.01.2019 17:39:19
 */
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
    out << '(' << p.ff << ", " << p.ss << ')';
    return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
    int l = v.size();
    for (int i = 0; i < l - 1; i++)
        out << v[i] << ' ';
    if (l > 0)
        out << v[l - 1];
    return out;
}

template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    trace(comma + 1, args...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    clock_t tStart = clock();
    int test;
    test = 1;
    // cin >> test;
    while (test--) {
        ll n;
        cin >> n;
        ll a, b;
        cin >> a >> b;
        vector<ll> v(n);
        for (ll i = 0; i < n; i++)
            cin >> v[i];

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

        ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
        for (ll i = 0; i < n; i++) {
            if (v[i] <= a)
                cnt1++;
            else if (v[i] > a && v[i] <= b)
                cnt2++;
            else
                cnt3++;
        }

        ll ans = min(cnt1, min(cnt2, cnt3));

        cout << ans << endl;
    }
#ifdef LOCAL_DEFINE
    printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
    return 0;
}


Measured memory_bytes: 256
/**
 *      ABC 84 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-02 04:40:15
**/

bool isNumber(char c){
    if (c == '0'){
        return true;
    }
    else if (c == '1'){
        return true;
    }
    else if (c == '2'){
        return true;        
    }
    else if (c == '3'){
        return true;        
    }
    else if (c == '4'){
        return true;        
    }
    else if (c == '5'){
        return true;        
    }
    else if (c == '6'){
        return true;        
    }
    else if (c == '7'){
        return true;        
    }
    else if (c == '8'){
        return true;        
    }
    else if (c == '9'){
        return true;        
    }
    else {
        return false;
    }
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B; cin >> A >> B;
    string S; cin >> S;
    int count = 0;
    if (S[A] == '-'){
        for (int i = 0; i < A; ++i) {
            if (isNumber(S[i])){
                ++count;
            }            
        }
        for (int i = A + 1; i < A + B + 1; ++i){
            if (isNumber(S[i])){
                ++count;
            }
        }
        count == A + B ? cout << "Yes" : cout << "No";
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define INF 100000007
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<double> V(N);
	rep(i,0,N) cin >> V[i];
	double min = INF;
	int tmp;
	while(V.size() != 1){
		min = INF;
		double ans;
		sort(all(V));
/*
		rep(j,0,V.size()-1){
			if(min > V[j+1] - V[j]){
				min = V[j+1] - V[j];
				ans = V[j+1]+V[j];
				tmp = j;
			}
		}
		*/
		ans = V[0]+V[1];
		V.erase(V.begin());
		V.erase(V.begin());
		V.push_back(ans/2.0);
	}
	cout << V[0] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ab = sc.nextInt();
        int bc = sc.nextInt();
        int ca = sc.nextInt();


        System.out.println(ab*bc/2);
        sc.close();
    }

}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define int ll
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 1e5+100;
const int mod = 1e9+7;
const int inf = 1e9 + 100;
const int sigma = 30;
int n, m, k, t = 1;
string a, b;
int lim;

int ele[ms];

bool dp[ms][2];
int seen[ms][2];

bool sol(int qt, int p){
  if(qt<0) return 1;
  if(qt==0) return 0;

  if(seen[qt][p]) return dp[qt][p];
  seen[qt][p] = 1;
  bool ans = 0;
  
  for(int j=0; j<n; j++){
    if(!sol(qt-ele[j],  p==0? 1: 0)) ans = 1;
  }
  return dp[qt][p] = ans;
}

void solve(){
  cin>>n>>m;
  memset(seen, 0, sizeof seen);
  for(int i=0; i<n; i++){
    cin>>ele[i];
  }
  if(sol(m, 0)){
    cout<<"First"<<endl;
  }else{
    cout<<"Second"<<endl;
  }
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

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



int main() {
    int n;
    cin >> n;
    int dummy = n;
    bool flag = false;
    if(n%2==0) flag = true;
    for(int i=3;i*i<=n;i+=2){
        if(flag) break;
        if(n%i==0)flag=true;
    }
    vector<int> l;

    if(flag){
        for(int i=2;i*i<=n;i++){
            if(n%i==0) {
                l.push_back(i);
                n /= i;
                i=1;
            }
        }
        if(n > 1) l.push_back(n);
    }
    if(!flag) l.push_back(n);

    cout<<dummy<<":";
    rep(i,l.size())cout<<" "<<l[i];
    cout << endl;
}


Measured memory_bytes: 3152
# ABC150C

import itertools

N=int(input())
Ps=tuple(map(int,input().split()))
Qs=tuple(map(int,input().split()))

l=[i+1 for i in range(N)]
cnt=0
Pno=0
Qno=0
for i in itertools.permutations(l):
    if i==Ps:
        Pno=cnt
    if i==Qs:
        Qno=cnt
    cnt+=1
    
print(abs(Qno-Pno))

Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k;
	string s1, s2;
	cin >> n >> s1 >> s2;
	for (i = 0; i < n; i++) cout << s1[i] << s2[i];
	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int heaps[500010], h;

void max_heapify(int a[], int i) {
  int largest, b;
  int l = i * 2;
  int r = i * 2 + 1;

  if (l <= h && a[l] > a[i])
    largest = l;
  else
    largest = i;
  if (r <= h && a[r] > a[largest])
    largest = r;

  if (largest != i) {
    b = a[i];
    a[i] = a[largest];
    a[largest] = b;
    max_heapify(a, largest);
  }
}

void build_maxheap(int a[]) {
  for (int i = h / 2; i >= 1; i--) {
    max_heapify(a, i);
  }
}

int main(void) {

  scanf("%d", &h);
  for (int i = 1; i <= h; i++)
    scanf("%d", &heaps[i]);

  build_maxheap(heaps);

  for (int i = 1; i <= h; i++)
    printf(" %d", heaps[i]);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define dubug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

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

  vector<ll> p(n + 1, 0);

  rep(i, n) cin >> p[i];

  for_each(p.begin(), p.end(), [](auto & v) { v--;});

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	char a[N];
	cin >> a;
	int K;
	cin >> K;
	for (int i = 0; i < N; i++) {
		if (a[i] != a[K-1]) {
			a[i] = '*';
		}
	}
	cout << a << endl;
}

Measured memory_bytes: 256
N=int(input())

AB = [list(map(int,input().split())) for _ in range(N)]

AB=sorted(AB, key=lambda x: x[1])

time=0
flag=0
for i,j in AB:
    time+=i
    if time>j:
        flag=1
        break
if flag==1:
    print("No")
else:
    print("Yes")
    

Measured memory_bytes: 55264
#また長さが1の時を考慮していない
#出来るだけループの外で計算する
n=int(input())
a=[int(input()) for i in range(n)]
m1=max(a)
m2=sorted(a,reverse=True)[1]
for i in range(n):
    if m1==a[i]:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 13340
#include "bits/stdc++.h"

using namespace std;


template <int p>
struct Modint
{
	int value;

	Modint() : value(0) {}
	Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}

	inline Modint &operator+=(const Modint &b)
	{
		if ((this->value += b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator-=(const Modint &b)
	{
		if ((this->value += p - b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator*=(const Modint &b)
	{
		this->value = (int)((1LL * this->value * b.value) % p);
		return (*this);
	}
	inline Modint &operator/=(const Modint &b)
	{
		(*this) *= b.inverse();
		return (*this);
	}

	Modint operator+(const Modint &b) const { return Modint(*this) += b; }
	Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
	Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
	Modint operator/(const Modint &b) const { return Modint(*this) /= b; }

	inline Modint &operator++(int) { return (*this) += 1; }
	inline Modint &operator--(int) { return (*this) -= 1; }

	inline bool operator==(const Modint &b) const { return this->value == b.value; }
	inline bool operator!=(const Modint &b) const { return this->value != b.value; }
	inline bool operator<(const Modint &b) const { return this->value < b.value; }
	inline bool operator<=(const Modint &b) const { return this->value <= b.value; }
	inline bool operator>(const Modint &b) const { return this->value > b.value; }
	inline bool operator>=(const Modint &b) const { return this->value >= b.value; }

	//requires that "this->value and p are co-prime"
	// a_i * v + a_(i+1) * p = r_i
	// r_i = r_(i+1) * q_(i+1) * r_(i+2)
	// q == 1 (i > 1)
	// reference: https://atcoder.jp/contests/agc026/submissions/2845729 (line:93)
	inline Modint inverse() const
	{
		assert(this->value != 0);
		int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
		while (r1)
		{
			int q = r0 / r1;
			r0 -= q * r1;
			swap(r0, r1);
			a0 -= q * a1;
			swap(a0, a1);
		}
		return Modint(a0);
	}

	friend istream &operator>>(istream &is, Modint<p> &a)
	{
		long t;
		is >> t;
		a = Modint<p>(t);
		return is;
	}
	friend ostream &operator<<(ostream &os, const Modint<p> &a)
	{
		return os << a.value;
	}
};

const int MOD = 1e9 + 7;

using Int = Modint<MOD>;

Int pow(Int e, int64_t x)
{
	if (x == 0)
		return 1;
	Int res = (x & 1 ? e : 1), tmp = pow(e, x >> 1);
	res *= tmp * tmp;
	return res;
}

void solve(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> s(n), t(m);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> t[i];
	}
	vector<vector<Int>> dp(n+1, vector<Int>(m+1)), dp2(dp);
	dp[0][0] = 1;
	for (int i = 0; i <= n; i++)
	{
		dp2[i][0] = 1;
	}
	for (int i = 0; i <= m; i++)
	{
		dp2[0][i] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (s[i-1] == t[j-1])
			{
				dp[i][j] = dp2[i-1][j-1];
			}
			dp2[i][j] = dp[i][j] - dp2[i-1][j-1] + dp2[i-1][j] + dp2[i][j-1];
		}
	}
	cout << dp2[n][m] << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
constexpr int MAX = 1e5 + 1;
// const int MAX = 10;
int card[MAX];          // カードに関する連結成分番号を保存.
int connection[MAX];    // 各連結成分 の カード数 を保存.
vector<int> graph[MAX]; // カードの番号を, グラフの頂点に見立てる.

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param s: グラフの探索開始頂点.
// @param l: 連結成分番号(※1以上).
// @return: 特に無し.
void bfs(int s, int l){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    // ※スタート地点に, 連結成分番号を指定.
    card[s] = l;
    connection[l]++;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){

        // 4. キューから取り出す.
        int u = q.front();
        q.pop();

        // 5. 取り出した要素を処理.
        for(auto &e : graph[u]){
            // 6. 訪問済であれば, 処理をスキップ.
            if(card[e] > 0)            continue;
            if(card[e] == 0 && e != s) card[e] = card[u], connection[l]++, q.push(e);
        }
    }
    return;
}

int main() {

    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);

    // 2. グラフ作成.
    for(int i = 0; i < M; i++){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        x--, y--;
        // x -> y
        graph[x].push_back(y);
        // y -> x
        graph[y].push_back(x);
    }
    
    // 3. 連結成分に分解.
    int c = 0;
    for(int i = 0; i < N; i++) if(graph[i].size() > 0 && card[i] == 0) c++, bfs(i, c);
    
    // グラフ連結情報確認.
    // for(int i = 0; i <= N; i++){
    //     printf("card[%d] = %d\n", i, card[i]);
    //     printf("connection[%d] = %d\n", i, connection[i]);
    // }
    
    // 4. 後処理.
    // -> 各連結成分 ごとに, 魔法 を 1回使用する必要があることと, 
    // 連結成分に含まれないカードは, それぞれ魔法を使用する必要があると見る.
    int ans = N;
    for(int i = 1; i < N; i++){
        if(connection[i] > 0) ans -= connection[i], ans++;
        else                  break;
    }
    printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 6904
x,y = map(int,input().split())
L = [list(input()) for _ in range(x)]
F = [['#']*(y+2) for _ in range(x+2)]
for i in range(x):
  for j in range(y):
    F[i+1][j+1] = L[i][j]
for f in F:
  print(''.join(f))

Measured memory_bytes: 9156
from itertools import combinations

N = int(input())
S = [input() for i in range(N)]
march = {"M":0, "A":0, "R":0, "C":0, "H":0}

for i in S:
    if i[0] in march:
        march[i[0]] += 1

ans = 0
for first, second, third in combinations(march.values(), 3):
    ans += first * second * third

print(ans)

Measured memory_bytes: 9772
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
    
def nCk(n,k):
    res = 1
    a=n-k
    b=k
    for i in range(1,a+b+1):
        res = res*i%mod
    for i in range(1,a+1):
        res = res*mod_inv(i,mod)%mod
    for i in range(1,b+1):                                 
        res = res*mod_inv(i,mod)%mod
    return res
def nHr(n,r):
    return nCk(n+r-1,r)

def div3(x): #素因数分解配列 dict格納型
    div=defaultdict(int)
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div[check]+=1
            x/=check
        check+=1
    if x != 1:
      div[x] += 1
    return div

def main():
    n,m = inpm()
    div = div3(m)
    ans = 1
    for e in div:
        ans = (ans * nHr(n,div[e])) % mod
    print(ans)
    
if __name__ == "__main__":
    main()

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int k, x;
  cin >> k >> x;
  int cnt = 0;
  for (int i = x - k + 1; i < x + k; ++i) {
    if (cnt != 0) cout << " ";
    cout << i;
    cnt++;
  }
  cout << "\n";
  return 0;
}

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

int main(){
    long long a,b;
    long long tmp,x,r;
    cin >>a >>b;

    x = a*b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    cout << x/b <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a;
    string b;
    cin>>a>>b;
    b.erase(b.begin()+1);
    int c=stoi(b);
    cout<<a*c/100<<endl;
    return 0;
}


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

long long N, W, w[105], v[105], dp[105][100005];

int main() {
    scanf("%lld%lld", &N, &W);

    for(int i = 1; i <= N; i++) {
        scanf("%lld%lld", &w[i], &v[i]);
    }

    for (int i = 1; i <= N+1; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = dp[i-1][j];
            if (w[i] <= j) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    printf("%lld\n", dp[N][W]);
}

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



class Program
{
 
    public static void Main( )
    {
        var employers = new int[ int.Parse( Console.ReadLine( ))+1 ];
        Console.ReadLine( ).Split( ).Select( int.Parse ).ToList( ).ForEach( x => employers[ x ] += 1 );
        employers.Skip(1).ToList( ).ForEach( x => Console.WriteLine(x) );

    }
}




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

const int MAXN = 1e5+5;
const long long INF = 1e18+7;
#define mp make_pair
#define pb push_back
int val[MAXN],weight[MAXN];
long long dp[MAXN];
// dp[i] ==> The maximum we can get using [1...n-1] and using i capacity( No need to use it all)
int main()
{
    int n,cap;cin >> n >> cap;
    for(int i=0;i<n;++i){
        cin >> val[i] >> weight[i];
    }
    for(int i=0;i<n;++i){
        for(int wei = cap;wei>=0;--wei){
            if(wei >= val[i]) dp[wei] = max(dp[wei],dp[wei-val[i]] + weight[i]);
        }
    }
    cout << dp[cap];
}


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

int main(){
    int A,B;
    cin >> A >> B;
    int plus = A + B;
    int minus = A - B;
    int multi = A * B;
    int max = plus;
    if(minus > max) max = minus;
    if(multi > max) max= multi;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD2 1000000007
#define MOD 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int a, b, c, d;

Int dp[3300][3300];
Int dpsum[3300][3300];
Int invpw[3300][3300];
Int inv[3300];
Int pwc[3300];
Int ans;

int main()
{
    cin >> a >> b >> c >> d;
    pwc[0] = 1;
    for (int i = 1; i < 3300; i++)
        pwc[i] = pwc[i - 1] * c % MOD;

    dp[a][b] = 1;
    for (int i = a + 1; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            dp[i][j] = dp[i - 1][j];
            dp[i][j] += dp[i][j - 1] * (i - 1) % MOD;
            dp[i][j] %= MOD;
        }
        for (int j = b; j <= d; j++) {
            dp[i][j] += dp[i - 1][j] * (j - 1) % MOD;
            dp[i][j] %= MOD;
            if (i == c) {
                ans += dp[i][j] * pwc[d - j] % MOD;
                //                cout << dp[i][j] << " " << d - j << " " <<
                //                pwc[d - j] << endl;
                ans %= MOD;
            }
        }
    }
    if (c == a)
        ans = pwc[d - b];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80460
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 2e5 + 7;

int32_t main() {
    speed;
    string a;
    cin >> a;

    int q, cnt_r = 0, cnt = 0;
    cin >> q;

    vector < int > qr(q);
    vector < pair < int, char > > vc(q);

    for ( int i = 0; i < q; i++ ) {
        int t;
        cin >> t;

        qr[i] = t;

        if ( t == 1 ) {
            cnt_r++;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            
            vc[i] = { f - 1, c };
        } 
    }
    for ( int i = q - 1; i >= 0; i-- ) {

        if ( qr[i] == 1 ) {
            cnt++;
        }
        else {

            if ( cnt & 1 ) {
                vc[i].first = 1 - vc[i].first;
            }
        }
    }
    if ( cnt_r & 1 ) {
        reverse( a.begin(), a.end() );
    } 
    for ( int i = q - 1; i >= 0; i-- ) {

        if ( qr[i] == 1 ) {
            continue;
        }
        else {

            if ( !vc[i].first ) {
                cout << vc[i].second;
            }
        }
    }
    for ( int i = 0; i < q; i++ ) {

        if ( qr[i] == 1 ) {
            continue;
        } 
        else {
            
            if ( vc[i].first ) {
                a += vc[i].second;
            }
        }
    }
    cout << a;  
}   
  

Measured memory_bytes: 5584
#include <iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#define pb push_back
#define ll long long
#define ld long double
#define f first
#define s second

using namespace std;
const int N = 1e5 + 5;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a[6];
    for(int i = 0; i < 5; i++)cin >> a[i];
    for(int i = 0; i < 5; i++)
    {
        if(a[i] == 0)
        {
            cout << i + 1;
            return 0;
        }
    }
    return 0;
}




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

using namespace std;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector <int> r(N + 1);
  r[0] = 0;
  for (int i = 0; i < s.size(); ++i) {
    r[i + 1] = s[i] == 'R' ? 1 : 0;
    r[i + 1] += r[i];
  }
  
  int ans = 200000;
  for (int i = 0; i <= N; ++i) {
    int left = i - r[i];
    int right = r[N] - r[i];
    if (left > right) {
      ans = min(ans, left);
    } else if (left == right) {
      ans = min(ans, right);
    } else {
      ans = min(ans, right);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define printA(arr) for(int i = 0; i < SZ(arr); i++){cout << arr[i];if (i==SZ(arr)-1){cout<<endl;}else{cout << " ";}}
typedef long long ll;

int main()
{
  int a;
  int b;
  int c;
  ll k;
  cin >> a >> b >> c >> k;
  int t;
  t = k%2 ? -1 : 1;

  cout << (a-b)*t << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
hs = gets.split.map{|n| n.to_i }

hs = [0] + hs

result = true

(hs.size-1).downto(1){|i|
  if hs[i] < hs[i-1]
    hs[i-1] -=1 
  end
  if hs[i] < hs[i-1]
    result = false
  end
}

if result
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9348
#include <stdio.h>
void cnt_alphabet(char ch, int cnt[])
{
    int ch_code = ch; //strの文字コード
    for (int i = 0; i < 26; i++)
    {
        if (ch_code == 'A' + i || ch_code == 'a' + i)
        {
            cnt[i]++;
        }
    }
}
int main(void)
{
    char ch;
    int cnt[26] = {0};

    while (scanf("%c", &ch) != EOF) //EOFまで入力を続ける
    {
        cnt_alphabet(ch, cnt);
    }

    for (int j = 0; j < 26; j++)
    {
        printf("%c : %d\n", 'a' + j, cnt[j]);
    }

    return 0;
}


Measured memory_bytes: 2680
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int N = 1e5+50;

int32_t main(){
	//ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("atcoder.txt", "r", stdin);
	int tc = 1;
	for(int T=1; T<=tc; T++){
		int a, b; cin>>a>>b;
		int res = -1;
		for(int i=2; i<=N; i++){
			int x = i*0.08;
			int y = i*0.1;
			if(x == a and y == b){
				res = i;
				break;
			}
		}
		cout<<res<<"\n";
	}
	return 0;
}

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

int main() {
	long long q, h, s, d;
	long long n;
	cin>>q>>h>>s>>d;
	cin>>n;
	vector <pair <int, double> > v;
	v.push_back(make_pair(q*8, 0.25));
	v.push_back(make_pair(h*4, 0.5));
	v.push_back(make_pair(s*2, 1));
	v.push_back(make_pair(d, 2));
	sort(v.begin(), v.end());

	long long ans = 0;
	int i = 0;
	while (i < v.size() && n != 0)
	{
		// cout<<v[i].first<<" ";

		if (n < v[i].second)
			i++;
		else {
			if (v[i].second == 2) {
				ans += v[i].first;
				n -= 2;
			}
			else {
				ans += (n*(v[i].first/2));
				n = 0;
			}
			i = 0;
		}
	}

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

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {set_intersection(ALL(a),ALL(b),inserter(c,c.end()));}
template<class T> void getor(const T &a,const T &b,T &c) {set_union(ALL(a),ALL(b),inserter(c,c.end()));}

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

const int MOD=1e9+7;


int main() {
  // できうる暗証番号の種類
  // そもそも3桁なので、1000通りしかない
  // なので、それぞれができるかを計算する
  int N;cin>>N;
  string S;cin>>S;

  ll ans = 0;
  REP(i,10)REP(j,10)REP(k,10) {
    char c1='0'+i,c2='0'+j,c3='0'+k;
    bool check1=false,check2=false;
    REP(i,S.size()) {
      char c=S[i];
      if (c==c1 && !check1) check1=true;
      else if (c==c2 && check1 && !check2) check2=true;
      else if (c==c3 && check1 && check2) {
        ans++;
        break;
      }
    }
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 256