akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s;
    cin >> s;

    ll num = 0;
    rep(i, 0, s.size() - 1){
        if(s[i] != s[i + 1]) num++;
    }

    cout << num << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int w = Integer.parseInt(s.next()),
		    h = Integer.parseInt(s.next()),
		    x = Integer.parseInt(s.next()),
		    y = Integer.parseInt(s.next()),
		    r = Integer.parseInt(s.next());
		if( x-r>=0 && x+r<=w && y-r>=0 && y+r<=h)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 26176
// Gaurav Aggarwal
 
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;
    vll v;

    for(int i=0;i<n;++i) {

        ll a,b;
        cin>>a>>b;
        v.pb(mp(b,a));

    }
    ll start = 0;

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

    for(int i=0;i<n;++i) {

        start += v[i].second;
        if(start > v[i].first) {

            cout<<"No\n"; 
            return 0;
        }

    }
    cout<<"Yes\n";

    return 0;
}   

Measured memory_bytes: 6512
#include <stdio.h>

int main(){
  
  int i,n;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    printf("%d",a[n-i-1]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  return 0;
}
  

Measured memory_bytes: 1028
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := stdin(sc)
	ary := make([]int, n)
	for i := 0; i < n; i++ {
		v := stdin(sc)
		ary[i] = v
	}
	maxv := -math.MaxInt32
	minv := ary[0]
	for i := 1; i < n; i++ {
		maxv = max(maxv, ary[i]-minv)
		minv = min(minv, ary[i])
	}
	fmt.Println(maxv)
}

func stdin(sc *bufio.Scanner) int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}



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

int a[510][510], b[510][510];
int c[100010];
map<int, P> ma, mb;
int ya[510], xa[510], yb[510], xb[510];
int cra, crb, ccra, ccrb;
int counta, countb;

int main(){
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
            ma[a[i][j]] = {i, j};
        }
    }
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> b[i][j];
            mb[b[i][j]] = {i, j};
        }
    }
    rep(i, 0, m){
        cin >> c[i];
    }
    if(n == 1){
        rep(i, 0, m){
            if(ma.count(c[i])) counta++;
            if(mb.count(c[i])) countb++;
            if(counta == u && countb < v){
                cout << "USAGI" << endl; return 0;
            }
            if(counta < u && countb == v){
                cout << "NEKO" << endl; return 0;
            }
        }
        cout << "DRAW" << endl;
        return 0;
    }
    rep(i, 0, m){
        if(ma.count(c[i])){
            int y = ma[c[i]].first;
            int x = ma[c[i]].second;
            ya[y]++;
            xa[x]++;
            if(y == x) cra++;
            if(y + x == n - 1) ccra++;
            if(ya[y] == n) counta++;
            if(xa[x] == n) counta++;
            if(y == x && cra == n) counta++;
            if(y + x == n - 1 && ccra == n) counta++;
        }
        if(mb.count(c[i])){
            int y = mb[c[i]].first;
            int x = mb[c[i]].second;
            yb[y]++;
            xb[x]++;
            if(y == x) crb++;
            if(y + x == n - 1) ccrb++;
            if(yb[y] == n) countb++;
            if(xb[x] == n) countb++;
            if(y == x && crb == n) countb++;
            if(y + x == n - 1 && ccrb == n) countb++;
        }
        // cout << counta << ' ' << countb << endl;
        if(counta >= u && countb < v){
            cout << "USAGI" << endl;
            return 0;
        }
        if(counta < u && countb >= v){
            cout << "NEKO" << endl;
            return 0;
        }
    }
    cout << "DRAW" << endl;
}


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

int main(){
	int array [4] [13];
	for(int i=0; i<4; i++){
		for(int t=0; t<13; t++){
			array [i][t]=0;
		}
	}
	int num,no;
	char str;
	cin >> num;
	for(int i=0; i<num; i++){
		cin >> str >> no;
		if(str=='S'){
			array[0][no-1]=1;
		}
		if(str=='H'){
			array[1][no-1]=1;
		}
		if(str=='C'){
			array[2][no-1]=1;
		}
		if(str=='D'){
			array[3][no-1]=1;
		}
	}
	for(int i=0; i<4; i++){
		for(int t=0; t<13; t++){
			if(array[i][t]==0){
				if(i==0){
					cout << "S " << t+1 << endl;
				}
				if(i==1){
					cout << "H " << t+1 << endl;
				}
				if(i==2){
					cout << "C " << t+1 << endl;
				}
				if(i==3){
					cout << "D "<< t+1 << endl;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3096
#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 <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N, K;
    cin >> N >> K;

    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    vector<ll> sum_all;
    rep(i, N) {
        ll sum = 0;
        reps(j, i, N) {
            sum += a[j];
            sum_all.pb(sum);
        }
    }

    sort(ALL(sum_all), greater<ll>());

    // repv(sum_all) cout << *it << " ";
    // cout << endl;

    ll sum_max = (int)(log2(sum_all[0]));
    ll ans = 0;

    repr(i, sum_max) {
        ll bit = 1LL << i;
        vector<ll> cand;
        ll cnt = 0;

        rep(j, SZ(sum_all)) {
            if ((sum_all[j] & bit) > 0) {
                cand.pb(sum_all[j]);
                cnt++;
            }
        }

        if (cnt >= K) {
            sum_all = cand;
            ans |= bit;
        }

        // repv(sum_all) cout << *it << " ";
        // cout << endl;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  for(int i=0; i<n-1; i++)
    cin >> b.at(i);
  
  int answer = b.at(0) + b.at(n-2);
  
  for(int i=0; i<n-2; i++)
    answer += min(b.at(i), b.at(i+1));
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Type alias */
using ll = long long;
using ld = long double;

using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

using set_i = std::set<int>;
using set_ll = std::set<ll>;
using set_ld = std::set<ld>;

using uset_i = std::unordered_set<int>;
using uset_ll = std::unordered_set<ll>;
using uset_ld = std::unordered_set<ld>;

/* IO macros */
#define in(i)            int i; std::cin >> i
#define in2(i, j)        int i, j; std::cin >> i >> j
#define in3(i, j, k)     int i, j, k; std::cin >> i >> j >> k
#define in_(i)           std::cin >> i
#define in2_(i, j)       std::cin >> i >> j
#define in3_(i, j, k)    std::cin >> i >> j >> k
#define in_ll(i)         ll i; std::cin >> i
#define in2_ll(i, j)     ll i, j; std::cin >> i >> j
#define in3_ll(i, j, k)  ll i, j, k; std::cin >> i >> j >> k
#define in_ll_(i)        std::cin >> i
#define in2_ll_(i, j)    std::cin >> i >> j
#define in3_ll_(i, j, k) std::cin >> i >> j >> k
#define in_ld(i)         ld i; std::cin >> i
#define in2_ld(i, j)     ld i, j; std::cin >> i >> j
#define in3_ld(i, j, k)  ld i, j, k; std::cin >> i >> j >> k
#define in_ld_(i)        std::cin >> i
#define in2_ld_(i, j)    std::cin >> i >> j
#define in3_ld_(i, j, k) std::cin >> i >> j >> k
#define in_c(i)          char i; std::cin >> i
#define in2_c(i, j)      char i, j; std::cin >> i >> j
#define in3_c(i, j, k)   char i, j, k; std::cin >> i >> j >> k
#define in_c_(i)         std::cin >> i
#define in2_c_(i, j)     std::cin >> i >> j
#define in3_c_(i, j, k)  std::cin >> i >> j >> k
#define in_str(s)        std::string s; std::cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){std::cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){std::cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){std::cin>>x;}

#define print(x)   std::cout << x
#define println(x) std::cout << x << "\n"
#define print_fixed(x)   std::cout << std::fixed << x
#define println_fixed(x) std::cout << std::fixed << x << "\n"
#define print_vec(v) for (auto &x:v) { std::cout << x << " ";}
#define println_vec(v) for (auto &x:v) { std::cout << x << " ";} std::cout << "\n";
#define print_long_vec(v) for (auto &x:v) { std::cout << x << "\n";}
#define println_long_vec(v) for (auto &x:v) { std::cout << x << "\n";} std::cout << "\n";

/* Loops */
#define rep(i, n) for (auto i = 0; i < n; ++i)

/* Vector manipulation */
#define vec_sort(v) std::sort(v.begin(), v.end())

using namespace std;
/* Code Starts Here*/
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    in_ll(A);
    in_ld(B);
    ll C = round(B * 100);
    cout<<fixed<<setprecision(15);
    cout << A * C / 100 << endl;
    return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
int main(){
  int A,B,C,D,l,r;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  l=A+B;
  r=C+D;
  
  if(l<r){
    puts("Right");
  } else if (l==r){
    puts("Balanced");
  } else{
    puts("Left");
  }
  
  return 0;
}

Measured memory_bytes: 128
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
// const double long rf=14;
int i,j,k;
// vi a;
string s;
bool palindrome(int st,int n){
    for(i=st;i<=n;i++){
        if(s[i]!=s[n-i])return false;
    }
    return true;
}
void Anon_mouS(){
	// string s;
  	cin>>s;
    int n=s.length();
	if(palindrome((int)0,n-1) and palindrome((int)0,(n-1)/2-1) and palindrome((n+3)/2-1,n-1))cout<<"Yes";
    else cout<<"No";
}

int32_t main(){
	// func();
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    string tmp;
    cin >> n;
    vector<int> num;
    num.push_back(0);
    vector<string> str;
    unordered_multiset<string> s(n);
    rep(i, n)
    {
        cin >> tmp;
        str.emplace_back(tmp);
        s.emplace(tmp);
    }
    int m;
    cin >> m;
    unordered_multiset<string> t;
    rep(i, m)
    {
        cin >> tmp;
        t.emplace(tmp);
    }
    rep(i, n)
    {
        num.push_back(s.count(str[i]) - t.count(str[i]));
    }
    cout << *max_element(all(num)) << endl;
    return 0;
}

Measured memory_bytes: 384
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

mod = 10**9+7 #出力の制限
N = 10**5+1
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def p(n,r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
# a = cmb(n,r)

n = onem()
print(p(n,n))

Measured memory_bytes: 90008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 987654321
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

double r;
int main() {
	cin >> r;
	cout <<  3.141592 * 2 * r;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

struct edge { int to, cost; };
vector<vector<edge>> G;
vector<bool> used;

int mst() {
    int ret = 0;
    priority_queue<pair<int,int>> q;
    q.push(make_pair(0, 0));
    while ( ! q.empty()) {
        int dist = -q.top().first;
        int v = q.top().second;
        q.pop();
        if (used[v]) continue;
        used[v] = true;
        ret += dist;
        for (int i=0; i<(int)G[v].size(); ++i) {
            if ( ! used[G[v][i].to]) {
                q.push(make_pair(-G[v][i].cost, G[v][i].to));
            }
        }
    }
    return ret;
}

int main() {
    int n, m;
    while (cin >> n, n) {
        G.clear(); G.resize(n);
        used.clear(); used.resize(n);
        cin >> m;
        int a, b, d;
        char c;
        for (int i=0; i<m; ++i) {
            cin >> a >> c >> b >> c >> d;
            G[a].push_back((edge){b, d / 100 - 1});
            G[b].push_back((edge){a, d / 100 - 1});
        }
        cout << mst() << endl;
    }
    return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 X,Y;

int main(){
  cin >> X >> Y;
  int ans = 1;
  i64 now = X;
  while(now * 2 <= Y) ans++,now *= 2;

  cout << ans << endl;
}




Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
struct edge{
	int from,to;ll val;
	friend bool operator <(edge x,edge y) {return x.val>y.val;}
}e;
priority_queue<edge> q;
struct po{
	int num,x,y;
}a[100005];
int fa[100005];
int cmp1(const po &u,const po &v) {return u.x<v.x;}
int cmp2(const po &u,const po &v) {return u.y<v.y;}
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].num=fa[i]=i;
	}
	sort(a+1,a+n+1,cmp1);
	for(int i=2;i<=n;i++)
	{
		e.from=a[i-1].num;
		e.to=a[i].num;
		e.val=a[i].x-a[i-1].x;
		q.push(e);
	}
	sort(a+1,a+n+1,cmp2);
	for(int i=2;i<=n;i++)
	{
		e.from=a[i-1].num;
		e.to=a[i].num;
		e.val=a[i].y-a[i-1].y;
		q.push(e);
	}
	int cnt=0;ll ans=0;
	for(;cnt<n-1;)
	{
		e=q.top();q.pop();
		int x=find(e.from),y=find(e.to);
		if(x==y) continue;
		ans+=e.val;
		fa[x]=y;
		cnt++;
	}
	printf("%lld\n",ans);
    return 0;
}

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

int main() {

    int n;
    cin >> n;

    double sum = 0;

    for (int i = 0; i < n; i++) {
        
        double x;
        string u;

        cin >> x >> u;

        if (u == "BTC") {
            x *= 380000;
        }

        sum += x;
        
    }
    
    cout << sum << endl;

    return 0;
    
}

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

int len1, len2;
char s[101], t[101];

int main(void)
{
    cin>>s>>t;
    len1=strlen(s);
    len2=strlen(t);
    if(len2-len1!=1)
    {
        printf("No\n");
        return 0;
    }
    
    for(int i=0; i<len1; i++)
    {
        if(s[i]!=t[i])
        {
            printf("No\n");
            return 0;
        }
    }
    
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main(void){
    int N, D, X, ans=0;
    std::cin >> N >> D >> X;
    --D;

    for (int i=0; i<N; ++i) {
        int a;
        std::cin >> a;
        ans += D / a + 1;
    }

    ans += X;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 1e18L+5
using namespace std;
ll c=0;
ll n;
ll dp[100001];
bool vis[100001];
void  dfs(vector<int> v[],int s,ll ind[]){
    vis[s]=true;
    for(auto m: v[s]){
            dp[m]=max(dp[m],dp[s]+1);
            ind[m]--;
            if(ind[m]==0)
              dfs(v,m,ind);
    }
}
int32_t main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll m;
   cin>>n>>m;
   vector<int> v[n+1];
   ll indegree[n+1];
   memset(vis,false,sizeof(vis));
  for(int i=1;i<=n;i++){
      dp[i]=0;
      indegree[i]=0;
  }
   for(int i=0;i<m;i++){
       int x,y;
       cin>>x>>y;
       v[x].pb(y);
       indegree[y]++;
   }
   
   for(int i=1;i<=n;i++){
       if(!vis[i]&&indegree[i]==0){
           dfs(v,i,indegree);
       }
   }
   ll ma=INT_MIN;
   for(int i=1;i<=n;i++){
       ma=max(ma,dp[i]);
   }
   cout<<ma;
}




Measured memory_bytes: 12032
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [H, A] = r.nn()

    return Math.ceil(H / A)
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 7500
#include <algorithm>
#include <iostream>

int main() {
	int A, B, C;
	std::cin >> A >> B >> C;

	const int max = std::max({A, B, C});

	const int answer = A + B + C + max * 10 - max;

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 256
//ABC156C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	int d = 0;
	for(int i=0;i<n;i++){
		cin >> x.at(i);
		d += x.at(i);
	}
	int p = d/n;
	int q = p+1;
	int a = 0, b = 0;
	for(int i=0;i<n;i++){
		a += pow(p-x.at(i),2);
		b += pow(q-x.at(i),2);
	}
	int ans = min(a,b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    f(n, 'a', "");
}
fn f(n: usize, a: char, cur: &str) {
    if cur.len() == n {
        println!("{}", cur);
        return;
    }
    for c in b'a'..((a as u8) + 1) {
        let mut cur = cur.to_string();
        cur.push(c as char);
        f(n, if (c as char) == a { (c + 1) as char } else { a }, &cur)
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    if((S[2] == S[3]) &&(S[4] == S[5])){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    dic={}
    for _ in range(n):
        s=input()
        if not s in dic.keys():
            dic[s]=0
        else:
            dic[s]+=1
    m=max(dic.values())
    ans=[]
    for each in dic.keys():
        if dic[each]==m:
            ans.append(each)
    for each in sorted(ans):
        print(each)
resolve()

Measured memory_bytes: 32988
#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define  mem memset(a,0,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;

typedef long long ll;
using namespace std;

int main()
{
    int c[4][4];
    int i,j,sum=0;
    int x=0;
    for(i=1;i<=3;i++)
    {
        for(j=1;j<=3;j++)
        {
            cin>>c[i][j];
            if(i==j)
                sum+=c[i][j];
        }
    }
    int a1,a2,a3,b1,b2,b3;
    int flag;
    for(a1=0;a1<=sum;a1++)
    {
        b1=c[1][1]-a1;
        b2=c[1][2]-a1;
        b3=c[1][3]-a1;
        a2=c[2][1]-b1;
        a3=c[3][1]-b1;
        flag=1;
        if(c[2][2]!=a2+b2)
            flag=0;
        if(c[2][3]!=a2+b3)
            flag=0;
        if(c[3][2]!=a3+b2)
            flag=0;
        if(c[3][3]!=a3+b3)
            flag=0;
        if(flag)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


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

using namespace std;

int main() {
    
    string s;
    getline(cin, s);
    
    if (s == "SUN")
        cout << 7;
    else if (s == "SAT")
        cout << 1;
    else if (s == "FRI")
        cout << 2;
    else if (s == "THU")
        cout << 3;
    else if (s == "WED")
        cout << 4;
    else if (s == "TUE")
        cout << 5;
    else
        cout << 6;
    
}

Measured memory_bytes: 256
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;
unordered_map<int,bool> done;

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	
    int n;cin>>n;
    int num[n];
    arrayin(num,n)
    int person[n+1];
    for(int i=0;i<=n;i++)
    	person[i]=0;

    bool hoga=true;

    for(int i=0;i<n;i++){
    	person[num[i]]++;
    }

    if(person[0]>1){
    	hoga=false;
    }

    if(n&1){
    	for(int i=n-1;i>=0;i-=2){
    		if(person[i]>2){
    			hoga=false;
    		}
    	}
    }else{
    	for(int i=n-1;i>=1;i-=2){
    		if(person[i]>2){
    			hoga=false;
    		}
    	}
    }

    if(hoga){
    	int res=1;

    	for(int i=0;i<n;i++){
    		int temp=num[i];
    		if(done[temp]){
    			continue;
    		}else{
    			if(temp!=0){
    				res=res*2;
    				res%=MOD;
    				done[temp]=true;
    			}
    		}
    	}

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

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

ll perm(ll n,ll k){
  ll a = 1;
  for(int i = 1;i<=n;i++){
    a = a*i%k;
  }
  return a;
}


int main() {
 ll N,M;
 cin >> N >> M;
 ll k = 1000000000+7;
  int ans = 0;
  if(abs(N-M)>=2) ans = 0;
  else if(abs(N-M) == 0){
    ans = (2*perm(N,k)*perm(M,k))%k;
  }
  else if(abs(N-M) ==1){
    ans = perm(N,k)*perm(M,k)%k;
  }
  
  cout << ans<< endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P, ll>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    ll s = 0, ans = LLINF;
    for(int i=0;i<n;i++){
        s += a[i];
        ans = min(ans, abs(sum-s*2));
    }
    cout << ans << endl;
    return 0;
}

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


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

   int a[300001];
   for (int i = 0; i < n; ++i){
      cin>>c;
      a[i+1]=a[i]+(c=='E');
   }
   a[0]=0;

   int answer=n;
   for (int i = 0; i < n; ++i){
      answer=min(answer,(i-a[i])+a[n]-a[i+1]);
   }

   cout<<answer<<endl;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector< vector<int> > array_2D;
typedef pair<int, pair<int, int> > ppi;
typedef vector<int> vi;



int main() {

    long long a, b, c, d;

    cin >> a >> b >> c >> d;

    long long A = 0;
    A = A + 1* min(d, a);
    d -= min(d, a);

    A = A + 0* min(d, b);
    d -= min(d, b);

    A = A - 1* min(d, c);
    d -= min(d, c);

    cout << A << "\n";
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int hash = Arrays.hashCode(a);
        for (int i = 0; i < k; i++) {
            int[] sum = new int[n+1];
            for (int j = 0; j < n; j++) {
                int l = Math.max(0, j - a[j]);
                int r = Math.min(n, j + a[j] + 1);
                sum[l]++; sum[r]--;
            }
            a[0] = sum[0];
            for (int j = 0; j < n-1; j++) {
                a[j+1] = a[j] + sum[j+1];
            }
            int nhash = Arrays.hashCode(a);
            if(hash == nhash)break;
            hash = nhash;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(a[i] + " ");
        }
        System.out.println(sb.toString().trim());
        sc.close();

    }

}


Measured memory_bytes: 63036
use std::io::*;
use std::cmp;

fn read_spc<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 print<T: std::fmt::Display>(x: T) -> () {
    println!("{}", x);
}

fn main() {
    half_and_half();
}

fn half_and_half() {
    let abcxy: Vec<i64> = read_spc();
    let a = abcxy[0];
    let b = abcxy[1];
    let c = abcxy[2];
    let x = abcxy[3];
    let y = abcxy[4];
    let ab = a + b;
    let c2 = c * 2;
    if ab < c2 {
        print(a * x + b * y);
    } else {
        let m = cmp::min(x, y);
        let d = (x - y).abs();
        let mut ans = c2 * m;
        if x == y {
        } else if x < y {
            let m = cmp::min(c2, b);
            ans += m * d;
        } else {
            let m = cmp::min(c2, a);
            ans += m * d;
        }
        print(ans);
    }
}

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

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void solve() {
  intt a, b, c, d;
  cin >> a >> b >> c >> d;
  intt turn = 1;
  while (1) {
    if (a <= 0) {puts("No"); return;}
    if (c <= 0) {puts("Yes"); return;}
    if (turn) {c -= b; turn = 0;}
    else {a -= d; turn = 1;}
  }
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
  int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int l;
  cin>>l;
  cout<<A[l-1]<<endl;
 return 0; 
}


Measured memory_bytes: 256
import heapq


def dijkstra(g, source):
    n = len(g)
    q = []
    heapq.heapify(q)
    heapq.heappush(q, (0, source))
    d = [float('inf') for _ in range(n)]
    d[source] = 0
    while len(q) > 0:
        cur = heapq.heappop(q)
        cur_pos = cur[1]
        for next in g[cur_pos]:
            next_pos = next[0]
            next_d = d[cur_pos] + next[1]
            if next_d < d[next_pos]:
                d[next_pos] = next_d
                heapq.heappush(q, (d[next_pos], next_pos))
    return d


def main():
    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n):
        inp = list(map(int, input().split()))
        m = inp[0]
        k = inp[1]
        for i in range(k):
            g[m].append((inp[(i+1)*2], inp[(i+1)*2+1]))
    d = dijkstra(g, 0)
    for i in range(n):
        print(i, d[i])


if __name__ == '__main__':
    main()



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

int main(){
  int n;
  cin >> n;
  	vector<long> arr(n);
  vector<long> dp(n,0);
  for(int i = 0; i < n; ++i)cin >> arr[i];
  dp[0] = 0;
  dp[1] = abs(arr[0]-arr[1]);
  for(int i = 2; i < n; ++i){
  	dp[i] = min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2]);
  }
  cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
import numpy as np

N = raw_input()
s = map(int,raw_input().split(" "))

s = np.array(s)
a = len(s[s%2 == 1])
b = len(s[s%2 == 0])


if a%2==0 and b%2==0:
    print "YES"
elif a%2 == 0 and b%2 ==1:
    print "YES"
elif a%2==1 and b%2==0:
    print "NO"
elif a%2==1 and b%2 ==1:
    print "NO"


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

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

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j + i <= n; j++) {
			if ((i * 10000 + j * 5000 + (n-i-j) * 1000)==y) {
				cout << i << " "<<j <<" "<< n-i-j << endl;
				return 0;
			}
			
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
 
namespace abc066_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int i;
            for (i = s.Length / 2 - 1; s.Substring(0, i) != s.Substring(i, i); i--) ;
            Console.WriteLine(i * 2);
        }
    }
}

Measured memory_bytes: 13140
def comb(left, right):
    top = 1
    for i in range(left, left - right, -1):
        top *= i

    bottom = 1
    for i in range(1, right + 1):
        bottom *= i

    return top // bottom

n, a, b = map(int, input().split())
v = list(map(int, input().split()))

v.sort()

min_set = v[-a:]
print(sum(min_set) / len(min_set))
if len(set(min_set)) == 1:
    cnt = v.count(min_set[0])

    result = 0
    for i in range(a, min(cnt, b) + 1):
        result += comb(cnt, i)
    print(result)
else:
    print(comb(v.count(min_set[0]), min_set.count(min_set[0])))


Measured memory_bytes: 3064
a, b, c, d = input()
l = ["+", "-"]
for op1 in l:
    for op2 in l:
        for op3 in l:
            tmp = a + op1 + b + op2 + c + op3 + d
            if eval(tmp) == 7:
                print(tmp + "=7")
                exit()

Measured memory_bytes: 3064
# include <bits/stdc++.h>
/// my holy template
# define F first    
# define S second
# define mp make_pair
# define pii pair<int,int>         
/// eveything goes according to plan
# define long long long  
# define pb push_back
# define sz(a) (int)(a.size())
/// countdown BEGAN. 10 , 9 , 8 ...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right     

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 9223372036854775807;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
int n;

set<int> s;     
                              
int main() 
{
  Read_rap ();
  cin >> n;

  for (int i = 1;i <= n;i ++) {
    int x;  cin >> x;
    if (s.count (x))
      s.erase (x);
    else
      s.insert (x);
  }
  cout << sz(s);


  return 0;
} 










// Coded by Z...

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

using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	int c = n % 500;
	if (a >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

S = [input().split() +[_+1] for _ in range(N)]

for i in range(N):
    S[i][1] = int(S[i][1])

S.sort(key=lambda x: x[0])

now = S[0][0]
pre = []

for i in range(N):
    if now == S[i][0]:
        pre.append(S[i])
    else:
        pre.sort(key=lambda x: x[1],reverse=True)
        for j in range(len(pre)):
            print(pre[j][2])
        pre = [S[i]]
        now = S[i][0]

pre.sort(key=lambda x: x[1],reverse=True)
for j in range(len(pre)):
    print(pre[j][2])

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

int main() {
  string S, T;
  int count = 0;
  cin >> S >> T;
  for (int i = 0; i < 3; i++){
      char a = S.at(i);
      char b = T.at(i);
      if(a == b){
          count++;
      }
  }
  cout << count << endl;


}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100100;
int a[maxn],b[maxn],c[maxn];
long long suma[maxn],sumb[maxn],sumc[maxn];
int main(){
//	freopen("A.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(int i=1;i<=n;i++)
		suma[i]=i;
	for(int i=1;i<=n;i++)
		sumb[i]=suma[lower_bound(a+1,a+n+1,b[i])-a-1];
	for(int i=1;i<=n;i++)
		sumb[i]+=sumb[i-1];
	for(int i=1;i<=n;i++)
		sumc[i]=sumb[lower_bound(b+1,b+n+1,c[i])-b-1];
	for(int i=1;i<=n;i++)
		sumc[i]+=sumc[i-1];
	printf("%lld\n",sumc[n]);
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
string s,ss;
int main(){
	int i,j,k;
	getline(cin,s);
	ss=s;
	reverse(s.begin(),s.end());
	for(i=0;i<s.length();i++){
		if(s[i]=='b') s[i]='d';
        else if(s[i]=='d') s[i]='b';
        else if(s[i]=='p') s[i]='q';
        else if(s[i]=='q') s[i]='p';
	}
	if(s==ss){
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int X, Y, Z, K;
    priority_queue<int64_t> W, ans;
    cin >> X >> Y >> Z >> K;
    vector<int64_t> A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];
    for(int i = 0; i < X; i++) {
        for(int j = 0; j < Y; j++) {
            W.push(A[i] + B[j]);
        }
    }
    for(int i = 0; !W.empty() && i < K; i++) {
        for(int j = 0; j < Z; j++) {
            ans.push(W.top() + C[j]);
        }
        W.pop();
    }
    for(int i = 0; i < K; i++) {
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 43168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
    int r;
    int ans;
    cin >> r;
    ans = r * r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int>v(N);
  rep(i,N)cin >> v[i];
  sort(all(v));
  v.erase(unique(all(v)),v.end());
  cout << v.size() << endl;
  return 0;
}


Measured memory_bytes: 256
X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)

def modinv(a, mod=MOD):
    return pow(a, mod-2, mod)

def combination(n, r, mod=MOD):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

if (X + Y) % 3 != 0:
    print(0)
    exit()

b = (2 * Y - X) // 3
a = X - Y + b

if a < 0 or b < 0:
    print(0)
    exit()


print(combination(a+b, a, MOD))

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

const ll mod = 1e9 + 7;

const ll INF = 1e15;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main() {
	ll n;
	cin >> n;
	vector<ll> as(n), bs(n);
	ll asum = 0, bsum = 0;
	rep(i, n) {
		cin >> as[i];
		asum += as[i];
	}
	rep(i, n) {
		cin >> bs[i];
		bsum += bs[i];
	}
	if (bsum > asum) {
		cout << -1 << endl;
		return 0;
	}
	vector<ll> ps, ms;
	rep(i, n) {
		auto diff = bs[i] - as[i];
		if (diff > 0) {
			ms.emplace_back(diff);
		}
		else if (diff < 0) {
			ps.emplace_back(-diff);
		}
	}
	int i = 0, j = 0;
	ll take = 0;
	ll all = 0;
	sort(ps.begin(), ps.end(), std::greater<ll>());
	while (j < ms.size()) {
		if (take > 0) {
			take -= ms[j];
			j++;
			all++;
		}
		while (i < ps.size() && take <= 0)
		{
			take += ps[i];
			i++;
			all++;
		}
	}
	cout << all << endl;
	return 0;
}


Measured memory_bytes: 2812