akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>

using namespace std;

#define MOD 1000000007
#define INF 1050000000

int main() {
	long long int n; cin >> n;
	long long int a[5];

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


	long long int ans = 0;
	long long int m = pow(10, 17);

	for (int i = 0; i < 5; i++) {
		long long int tmp = a[i];
		m = min(m, tmp);
	}


	if (n == m) {
		cout << 5 + n / m - 1 << endl;
	}
	else if(m==1) {
		cout << 5 + n / m - 1 << endl;
	}
	else {
		cout << 5 + n / m << endl;
	}




}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define MAXN 8100

int main()
{
    string s;
    int gx, gy;
    cin >> s >> gx >> gy;
    int n = s.size();
    // cout << n << endl;
    vector<int> t;
    int cnt = 0;
    repi(i, n, 0)
    {
        if (s[i] == 'F')
            cnt++;
        else
        {
            t.push_back(cnt);
            cnt = 0;
        }
    }
    if (cnt > 0)
        t.push_back(cnt);
    vector<vector<bool>> x(MAXN, vector<bool>(MAXN * 2, false)), y(MAXN, vector<bool>(MAXN * 2, false));
    x[0][MAXN] = true;
    y[1][MAXN] = true;
    n = t.size();
    // cout << n << endl;
    // repi(i,n,0){
    //     cout << t[i] << " ";
    // }
    // cout << endl;
    int lx = 0, ly = 1;
    repi(i, n + 1, 1)
    {
        repi(j, MAXN * 2, 0)
        {
            if (i % 2)
            {
                if (x[i - 1][j])
                {
                    // cout << "x " << j << endl;
                    lx = i + 1;
                    x[i + 1][j + t[i - 1]] = true;
                    if (i != 1)
                        x[i + 1][j - t[i - 1]] = true;
                }
            }
            else
            {
                if (y[i - 1][j])
                {
                    // cout << "y " << j << endl;
                    ly = i + 1;
                    y[i + 1][j + t[i - 1]] = true;
                    y[i + 1][j - t[i - 1]] = true;
                }
            }
        }
    }
    // repi(i,n + 2,0){
    //     repi(j,MAXN*2,0){
    //         if(x[i][j])cout << "X : " << i << " " << j << endl;
    //         if(y[i][j])cout << "y : " << i << " " << j << endl;
    //     }
    // }
    if (x[lx][MAXN + gx] && y[ly][MAXN + gy])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 35328
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b;
  cin>>a>>b;
  if(b=='H'){
    cout<<a<<endl;
  }
  
  else if(b=='D'&&a=='D'){
    cout<<'H'<<endl;
  }

  else if(b=='D'&&a=='H'){
cout<<'D'<<endl;
  }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
 
int n;
 
int get (int x) {
	return x * (x + 1) / 2;
}
 
main () {
	cin >> n;
	cout << get(n) - get(n / 3) * 3 - get(n / 5) * 5 + get(n / 15) * 15 << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	ll A;
	double B;
	cin >> A >> B;
	ll b = B * 100 + 0.5;
	cout << A * b / 100 << endl;

	return 0;
}


Measured memory_bytes: 3764
from fractions import gcd
from functools import reduce
def lcm(x,y):
    return (x * y) // gcd(x, y)
MOD = 10**9+7


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

l = reduce(lcm,a)%MOD
ans=0
for i in range(n):
    ans+=l*pow(a[i],MOD-2, MOD)
    ans%=MOD

print(int(ans))

Measured memory_bytes: 67432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
 
int main() {
  long long int n,k;
  cin>>n>>k;
  if(k==1){
  cout<<0<<endl;
  }else{
    n=n%k;
  while(abs(n-k)<n){
  n=abs(n-k);
  }
    cout<<n<<endl;
  }
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
  	cin >> N;
  	vector< tuple<int, string, int> > p;
  	int idx = 0;
  	string city;
  	int score;
  	int index = 1;
  	while(cin >> city >> score)
    {
      p.push_back(make_tuple(index, city, score));
      index++;
    }
  	//sort(p.begin(), p.end(), compare_by_b);
	sort(p.begin(), p.end(), compare_by_string);
  	for(int i=0;i<N;i++)
    {
      cerr << get<0>(p[i]) << ":" << get<1>(p[i]) << " " << get<2>(p[i]) << endl;
      cout << get<0>(p[i]) << endl;
    }
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include<ctype.h>
using namespace std;
char toupper(char c); 
char toupper(char c) {
  return (c - 0x20);
}
int main(){
string a,b,c;
cin >> a>>b>>c;
char d,e,f;
d =a[0];
e =b[0];
f =c[0];
cout << toupper(d) <<toupper(e) << toupper(f) << endl;

    return 0;

}







Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,i,j,max,min,ans;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  max=a[1]-a[0];
  min=a[0];
  for(i=1;i<n;i++){
    ans=a[i]-min;
    if(max<ans){
      max=ans;
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> P;
#define Mod 1000000007

int main () {
    ll i,j;
    ll n,k;
    cin>>n>>k;
    k++;

    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];

    ll one[42],zero[42];
    fill(one,one+41,0);
    fill(zero,zero+41,0);

    j=0;
    while(j<=40){
        for(i=0;i<n;i++){
            if(a[i]%2) one[j]++;
            else zero[j]++;
            a[i]=a[i]>>1;
        }
        j++;
    }


    ll ans=0;
    for(i=0;i<=40;i++){
        if(k>>i&1){
            ll re=one[i]<<i;
            for(j=i+1;j<=40;j++){
                if(k>>j&1) re+=zero[j]<<j;
                else re+=one[j]<<j;
            }

            for(j=0;j<=i-1;j++){
                re+=max(one[j],zero[j])<<j;
            }

            if(re>ans) ans=re;
        }


    }

    cout<<ans<<endl;

  
    
}

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

using namespace std;

///==================================================================================///

///for
#define F(i,n) for(int i=0;i<n;i++)
#define Fb(i,n) for(int i=n-1;i>=0;i--)
#define Fi(i,l,r) for(int i=l;i<=r;i++)
#define Fbi(i,r,l) for(int i=r;i>=l;i--)
///push and pop
#define pusb push_back
#define pusf push_front
#define popb pop_back
#define popf pop_front
///pair
#define fi first
#define se second
#define mp make_pair
///values
#define INF 2000000000
#define llINF (long long)9000000000000000000

///types
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
///pairs
typedef pair<int,int> II;
typedef pair<int,II> III;
typedef pair<double,double> DD;
typedef pair<string,string> SS;
///vectors
typedef vector<int> VI;
typedef vector<II> VII;
typedef vector<III> VIII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef vector<string> VS;
///queues
typedef priority_queue<int,vector<int>,greater<int> > PQI_min;
typedef priority_queue<int> PQI_max;
typedef priority_queue<II,vector<II >,greater<II > > PQII_min;
typedef priority_queue<II > PQII_max;
typedef queue<int> QI;
typedef queue<II > QII;
///stack
typedef stack<int> SI;
typedef stack<II > SII;

///functions
template<class T> T modulo(T x, T p) {
    if(x>=0) return x%p;
    return p + x%p;
}
template<class T> T gcd(T a, T b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
template<class T> T lcm(T a, T b) {
    return a*b/gcd(a,b);
}

///==================================================================================///

ll get_sum(int a, int b, int c) {
    return (a*a + b*b + c*c)/2;
}
int same(int a, int b, int c) {
    return (a==b && b==c) ? 1 : 3;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    //freopen("3.in","r",stdin);
    //freopen("out.out","w",stdout);
    ///==================================================///
    
    int n; cin>>n;
    VI ans(n+1,0);

    Fi(x,1,100) Fi(y,1,100) Fi(z,1,100) {
        ll s=x*x+y*y+z*z+x*y+x*z+y*z;
        if(s<=n) ans[s]++;
    }
    Fi(i,1,n) cout<<ans[i]<<'\n';

    return 0;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
//#define int long long

signed main(){
    int n; cin >> n;
    map<int, int> x;
    
    rep(i,n){
        int a; cin >> a;
        x[a-1]++;
        x[a]++;
        x[a+1]++;
    }
    
    int ans = 0;
    for(auto p : x){
        ans = max(ans, p.second);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4736
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 99999.
       01 B PIC 99999.
       01 temp1 PIC 9999.
       01 temp2 PIC 9999.
       01 N PIC 9999.
       PROCEDURE DIVISION.
       MAIN.
        ACCEPT INP.
        PERFORM VARYING temp1 FROM 1 BY 1 UNTIL INP(temp1:1)=SPACE
        END-PERFORM.
        SUBTRACT 1 FROM temp1.
        MOVE INP(1:temp1) TO A.
        ADD 2 TO temp1.
        PERFORM VARYING temp2 FROM temp1 BY 1 UNTIL INP(temp2:1)=SPACE
        END-PERFORM.
        COMPUTE N=temp2 - temp1.
        MOVE INP(temp1:N) TO B.
        COMPUTE A = A * B.
        COMPUTE B = A / 2.
        COMPUTE A = A - B * 2.
        IF A = 0 THEN
            DISPLAY "Even"
        ELSE
            DISPLAY "Odd"
        END-IF.
        STOP RUN.

Measured memory_bytes: 636
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
import bisect #二部探索
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
mod = 10**9 + 7
INF = 10**9 + 7
from operator import mul
from functools import reduce

def main():
    n = int(input())    
    ans = (pow(10, n, mod=mod) -(pow(9, n, mod=mod) + pow(9, n, mod=mod) - pow(8, n, mod=mod))) % mod
    print(ans)
    return 0

if __name__ == "__main__":
    main()

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

long long ck_keta(long long x);

int main(){
    long long N;
    long long ans = 0, n;

    std::cin >> N;

    for(long long i = 1; i <= N; i++){
        n = ck_keta(i);
        ans = ans + n%2;
    }

    std::cout << ans;
}

long long ck_keta(long long x){
    long long keta = 1;
    double d_x = round((double)x);
    while(d_x >= 10.0){
        d_x = d_x/10.0;
        keta++;
    }
    return keta;
}

Measured memory_bytes: 3596
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
inline int in(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
//---------------------------------------------------------------
//---------------------------------------------------------------
//---------------------------------------------------------------
//---------------------------------------------------------------
int n,Q,ch,M[3],ans;
char c[200004],a[200004],s[200004];
int check(int ind){
	for(int i=0;i<Q;i++)
		if(c[i]!=s[ind])continue;else
		if(a[i]=='L')ind--;
		else 		 ind++;
	if(ind>=n)return 2;
	if(ind<0)return 1;
	return 0;
}
void solve(){
	int l=-1,r=n;
	while(r-l>1){
		int mid=(l+r)/2;
		ch=check(mid);
//		cout<<mid<<" "<<ch<<endl;
		if(ch==2)r=mid;
		else l=mid;
	}
	if(check(r)!=2)r++;
	M[2]=r;
	l=-1,r=n;
	while(r-l>1){
		int mid=(l+r)/2;
		ch=check(mid);
//		cout<<mid<<" "<<ch<<endl;
		if(ch==1)l=mid;
		else r=mid;
	}
	if(check(r)!=1)r--;
	M[1]=r;
}
void read(){
	cin>>n>>Q;
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<Q;i++)
		cin>>c[i]>>a[i];
}
void print(){
	ans=1+(M[2]-1)-(M[1]+1);
//	cout<<M[2]<<" "<<M[1]<<endl;
	cout<<ans<<endl;
}
int main(){FAST;xRand;
read();
//check(2);
solve();
print();
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/






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

int main(){
    string s; cin >> s;
    int N=s.size();
    int K; cin >> K;
    long long dp[N+1][2][101]={};
    dp[0][1][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=K;j++){
            int d=s[i]-'0';
            dp[i+1][0][j+1]+=dp[i][0][j]*9;
            dp[i+1][0][j]+=dp[i][0][j];
            if(d==0){
                dp[i+1][1][j]+=dp[i][1][j];
            }else{
                dp[i+1][1][j+1]+=dp[i][1][j];
                dp[i+1][0][j+1]+=dp[i][1][j]*(d-1);
                dp[i+1][0][j]+=dp[i][1][j];
            }
        }
    }
    cout << dp[N][0][K]+dp[N][1][K] << endl;
}

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

int main() {
    int a, b, k; cin >> a >> b >> k;
    for (int i = 0; i < k; i++) {
        a /= 2; b += a;
        swap(a, b);
    }
    if (k & 1) swap(a, b);
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int L,N;

int main(){
    cin>>N>>L;
    string S[N];
    rep(i,N)cin>>S[i];
    sort(S,S+N);
    rep(i,N)cout<<S[i];
    cout<<endl;

}


Measured memory_bytes: 256
n = gets.to_i
v = gets.strip.split.map(&:to_i)

a = []
b = []

for i in 0..(n/2)-1

    a.push(v[2*i])
    b.push(v[(2*i)+1])

end

a.sort!
b.sort!

acount = []
ax = []
ai = 0
bcount = []
bx = []
bi = 0

for i in 0..(n/2)-2

    if a[i] != a[i+1]

        acount.push(i-ai+1)
        ax.push(a[i])
        ai = i+1 

    end

end

acount.push((n/2)-ai)
ax.push(a[(n/2)-1])

for i in 0..(n/2)-2

    if b[i] != b[i+1]

        bcount.push(i-bi+1)
        bx.push(b[i])
        bi = i+1 
    end

end

bcount.push((n/2)-bi)
bx.push(b[(n/2)-1])

if acount.count(acount.max) == 1 && bcount.count(bcount.max) == 1 && ax[acount.index(acount.max)] == bx[bcount.index(bcount.max)]

    if acount.size == 1 && bcount.size == 1

        puts n/2 

    else

        if acount.sort[-2] < bcount.sort[-2]

            puts (n-acount.max-bcount.sort[-2])

        else

            puts (n-bcount.max-acount.sort[-2])

        end

    end

else

    puts (n-acount.max-bcount.max)

end


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

#define LL long long
#define ULL unsigned long long

#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) (((l)+(r))>>1)

const int MOD = (int) 1e9 + 7;
const double eps = (double) 1e-8;
const int maxn = (int) 1e5 + 20;
const double pi = (double) acos(-1.0);

struct Node
{
    LL sum;
    int cnt;
    Node *lch, *rch;

    Node() {sum = cnt = 0; lch = rch = NULL;}
};

void ins(int val, int l, int r, int id, Node *&rt)
{
//    cout <<l <<" " <<r <<endl;
    if(rt == NULL) rt = new Node();
    rt->cnt++;
    rt->sum += val;
    if(l == r) return ;
    int mid = MID(l, r);

    if(val <= mid) ins(val, lson, rt->lch);
    else ins(val, rson, rt->rch);
}

inline int sz(Node *rt) {if(rt == NULL) return 0;  return rt->cnt;}
int find_mid(int k, int l, int r, int id, Node *rt)
{
    if(l == r) return l;
    int mid = MID(l, r);
    if(sz(rt->lch) < k) return find_mid(k - sz(rt->lch), rson, rt->rch);
    return find_mid(k, lson, rt->lch);
}

complex<LL> get(int L, int R, int l, int r, int id, Node *rt)
{
    if(rt == NULL || L > R) return complex<LL> (0, 0);
    if(L <= l && r <= R) return complex<LL> (rt->cnt, rt->sum);

    int mid = MID(l, r);
    if(R <= mid) return get(L, R, lson, rt->lch);
    if(mid < L)  return get(L, R, rson, rt->rch);
    return get(L, R, lson, rt->lch) + get(L, R, rson, rt->rch);
}


void work()
{
    int Q;
    cin >>Q;

    Node *rt = 0;
    LL c = 0;
    while(Q--)
    {
        int opt;
        cin >>opt;
        if(opt == 1)
        {
            int x, y;
            cin >>x >>y;
            ins(x, -1e9, 1e9, 1, rt);
            c += y;
        }
        else
        {
            int mid = find_mid((rt->cnt + 1) / 2, -1e9, 1e9, 1, rt);
            complex<LL> l = get(-1e9, mid, -1e9, 1e9, 1, rt), r = get(mid + 1, 1e9, -1e9, 1e9, 1, rt);

            LL ans = mid * l.real() - l.imag() + r.imag() - r.real() * mid;
            cout <<mid <<" " <<ans + c <<endl;
        }
    }
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r" ,stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416

    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	getline(cin,s);
	rep(i,SIZE(s)){
		if(s[i]!=' ' && s[i]!='.') s[i]-=32;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 2980
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }
};

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    ll res = 0;
    if(abs(a - b) % 2 == 1){
        ll a2 = min(abs(1-a), abs(n-a));
        ll b2 = min(abs(1-b), abs(n-b));
        ll c = min(a2, b2);
        res += c;
        res += (abs(a-b)-1)/2+1;
    }
    else{
        res = abs(a-b)/2;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}

int main()
{
	int n,k;
	cin>>n>>k;int tot=0;
	while(n) n/=k,++tot;
	print(tot,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
	long double d,ans;
	cin>>d;
	d=d/3;
	ans=d*d*d;
	cout<<ps(ans,10);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b,c;
    cin>>a>>b>>c;
    string s=a+b+c;
    if (s=="575"||s=="557"||s=="755") {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    string s,t;cin>>s>>t;
    ll ss=s.size();
    ll st=t.size();
    ll memo=10000;
    if(ss==st){
        ll kari=0;
        rep(j,st){
            if(s[j]!=t[j]) {
                kari++;
            }
        }
        memo=min(memo,kari);
    }else {
    rep(i,ss-st){
        ll kari=0;
        rep(j,st){
            if(s[i+j]!=t[j]) {
                kari++;
            }
        }
        memo=min(memo,kari);
    }
    }
    cout<<memo<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 110;

int n;
int l[N << 1];

int main() {
    scanf("%d", &n);
    n <<= 1;
    for (int i = 1; i <= n; ++i)
        scanf("%d", &l[i]);
    sort(l + 1, l + n + 1);
    int res = 0;
    for (int i = 1; i <= n; i += 2)
        res += l[i];
    printf("%d\n", res);
    return 0;
}

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

typedef long long int ll;
const ll N = 1000010;

ll a1[N];

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

    for (int i = 0; i < n;i ++) cin >> a1[i];

    sort(a1,a1+n);
    ll x1 = -1, x2 = -1, y1 = 0, y2 = 0;
    int i = n-1;
    for (i = n-1; i > 0; i --){
        if ( a1[i] == a1[i-1] ){
            x1 = a1[i]; break;
        }
    }
    i -= 2;
    for ( ; i > 0; i --){
        if ( a1[i] == a1[i-1] ){
            x2 = a1[i]; break;
        }
    }

    if ( x1 != -1 && x2 != -1 ) cout << x1 * x2 << "\n";
    else cout << "0\n";

    //main();


    return 0;
}


Measured memory_bytes: 1024
chomp($n = <>);

$r = "No";
for $i (1 .. 9){
	if($n % $i == 0){
		$m = $n / $i;
		if(($m >= 1) and ($m <= 9)){
			$r = "Yes";
			last;
		}
	}
}

print "$r\n";


Measured memory_bytes: 384
import math
def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i+1 for i in range(1,n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e%p != 0]

_primes = eratosthenes(10**5+1)
primes = [False]*(10**5+1)
for p in _primes:
    primes[p] = True
    
like_2017 = [False] * (10**5+1)

for p in _primes:
    if primes[(p+1)//2]:
        like_2017[p] = True
    
c = 0
C = [0]
for i in range(1,10**5+1):
    if like_2017[i]:
        c += 1
    C.append(c)

q = int(input())
for i in range(q):
    left,right = map(int,input().split())
    print(C[right]-C[left-1])

Measured memory_bytes: 55236
#include <iostream>
#include <iterator>
#include <string>
#include <algorithm>
#include <locale>

using namespace std;

int main()
{
  string s;
  while (getline(cin, s), s != "0") {
    int sum = 0;
    for (char c : s)
      sum += (c - '0');
    cout << sum << endl;
  }
}


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

int bingo[3][3];
bool check[3][3];

int main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++) cin >> bingo[i][j];
    }
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++) check[i][j] = false;
    }
    int n;
    cin >> n;
    int b;
    for (int x = 0; x < n; x++)
    {
        cin >> b;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (bingo[i][j] == b) check[i][j] = true;
            }
        }
    }
    bool flag;
    for (int i = 0; i < 3; i++)
    {
        flag = true;
        for (int j = 0; j < 3; j++)
        {
            if (!check[i][j]) flag = false;
        }
        if (flag)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        flag = true;
        for (int j = 0; j < 3; j++)
        {
            if (!check[j][i]) flag = false;
        }
        if (flag)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    flag = true;
    for (int i = 0; i < 3; i++)
    {
        if (!check[i][i]) flag = false;
    }
    if (flag)
    {
        cout << "Yes" << endl;
        return 0;
    }
    flag = true;
    for (int i = 0; i < 3; i++)
    {
        if (!check[2 - i][i]) flag = false;
    }
    if (flag)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,r;cin>>n>>r;
  int ans = r + max(0,10-n)*100;
  print(ans);
  return 0; 
}


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

using namespace std;

#define ll             long long
#define vi             vector<int>
#define FOR(x, l, r)   for (int x = l; x <= r; ++x)
#define RFOR(x, l, r)   for (int x = l; x >= r; --x)

const int N = (int) 2e5 + 5;
const int INF = (int) 1e9 + 7;
int ini(){
    int x;
    scanf("%d",&x);
    return x;
}
long long inl(){
    long long x;
    scanf("%lld",&x);
    return x;
}
int main()
{
    int a,b,r[10],i=0;
    a=ini();
    b=ini();

    while(b>0){
        r[i++]=b%10;
        b/=10;
    }
    for(int j=i-1;j>=0;j--){
        a=a*10+r[j];
    }
    int s=sqrt(a);
    if(s*s==a)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}



Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int H, W;
char mas[500][500];
int min_cost[500][500];

int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

int bfs(int sx, int sy, char c) {
	for (int i = 0; i < 500; i++) {
		for (int j = 0; j < 500; j++) {
			min_cost[i][j] = -1;
		}
	}

	queue<pair<int, int>> que;
	que.emplace(sx, sy);
	min_cost[sx][sy] = 0;

	while (!que.empty()) {
		auto p = que.front();
		que.pop();

		//終了条件、ゴールにたどり着いたらその時の最短距離を返す
		if (mas[p.second][p.first] == c)return (min_cost[p.first][p.second]);

		for (int i = 0; i < 4; i++) {
			int nx = p.first + vx[i], ny = p.second + vy[i];

			//範囲外判定
			if (nx < 0 || ny < 0 || nx >= W || ny >= H)continue;

			//もういったマスにはいかない
			if (min_cost[nx][ny] != -1)continue;

			//壁は進めない
			if (mas[ny][nx] == '#')continue;

			//次に行く前に距離を更新して
			min_cost[nx][ny] = min_cost[p.first][p.second] + 1;

			//次にいく
			que.emplace(nx, ny);
		}
	}

	return -1;
}

int main() {
	cin >> H >> W;

	int proc = 0;

	for (int i = 0; i < H; i++) {
		cin >> mas[i];

		for (int j = 0; j < W; j++) {
			if (mas[i][j] == '#')++proc;
		}
	}

	mas[H - 1][W - 1] = 'G';

	auto s = bfs(0, 0, 'G');

	if (s == -1)cout << -1 << endl;
	else cout << H * W - s - proc - 1 << endl;
}

Measured memory_bytes: 1280
import java.util.*;
public class Main{
  public static int sumOfDigits(int input){
    int sum = 0;
    while(input>0){
      sum+=input%10;
      input/=10;
    }
    return sum;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = sumOfDigits(n);
    String ans = "No";
    if(n%sum==0)ans="Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
n,k,q=gets.chomp.split(" ").map(&:to_i)

array = Array.new(n, 0)

q.times do
    a = gets.to_i
    array[a-1] = array[a-1] + 1
end

l = q-k
array.each do |i|
    puts i <= l ? "No" : "Yes"
end


Measured memory_bytes: 3196
#include<stdio.h>

int main(){
  int i,j,n,u,v,k,adj[200][200];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    if(k!=0){
      for(j=1;j<=k;j++){
	scanf("%d",&v);
	adj[u][v]=1;
      }
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",adj[i][j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }
  return 0;

}



Measured memory_bytes: 2108
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int longest = 0;
		int count = 0;
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i) == 'A' || s.charAt(i) == 'C' || s.charAt(i) == 'G' || s.charAt(i) == 'T'){
				count++;
				if(count > longest){
					longest = count;
				}
			}else{
				count = 0;
			}
		}
		System.out.println(longest);
	}
}


Measured memory_bytes: 35528
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {

string s;
	cin>>s;
	 s[3]='8';
	 cout<<s<<endl;
return 0;
}







Measured memory_bytes: 256
store_score = {}
win_hands = {"s": "r", "r": "p", "p": "s"}
scores = {}

def resolve():
    # k飛ばしで文字列を抽出し、それらの文字列ごとに最適なpathを考える
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()

    global scores
    scores = {"s": S, "r": R, "p": P}

    total_score = 0
    for i in range(K):
        # print(T[i::K])
        target_text = T[i::K]
        # print(target_text)
        target_text += "o"

        previous_select = "o"
        local_score = 0
        for j in range(len(target_text) - 1):
            previous_select, score = judge(previous_select, target_text[j], target_text[j+1])
            local_score += score    

        total_score += local_score

    print(total_score)
                        

def judge(previous_select, current_machine, next_machine):
    # print(previous_select, current_machine, next_machine)
    ideal_hand = win_hands[current_machine]
    if previous_select == ideal_hand:
        # もし前回と同じハンドが理想ハンドならば、次回のハンドに邪魔しない手を選ぶ
        select = next_machine
        score = 0
    else:
        select = ideal_hand
        score = scores[select]
    # print(select, score)
    return select, score


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3444
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
 
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
 
int t[3][3];
int limit;
 
int getHeuri(){
  int res=0,a;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(t[i][j]==0)continue;
      a=t[i][j]-1;
      res+=abs(a/3-i)+abs(a%3-j);
    }
  }
  return res;
}
 
bool check(int depth,int prev,int py,int px){
  int heuri=getHeuri();
  if(heuri+depth>limit)return false;
  if(heuri==0)return true;
  for(int i=0;i<4;i++){
    if(abs(i-prev)==2)continue;
    int ny=py+dy[i],nx=px+dx[i];
    if(ny<0||nx<0)continue;
    if(ny>=3||nx>=3)continue;
    swap(t[ny][nx],t[py][px]);
    if(check(depth+1,i,ny,nx)) return true;
    swap(t[ny][nx],t[py][px]);
  }
  return false;
}
 
void solve(int py,int px){
  for(limit=0;;limit++){
    if(check(0,99,py,px)){
      cout<<limit<<endl;
      return;
    }
  }
}
 
int main(){
  int py,px;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>t[i][j];
      if(t[i][j]==0){
    py=i;
    px=j;
      }
    }
  }
  solve(py,px);
  return 0;
}

Measured memory_bytes: 1160
f=f=1,*(1..m=1000003).map{f=f*_1%m}
$<.map{x,d,n=_1.split.map &:to_i
d&&p(d<1?x.pow(n,m):(u=f[n+t=x*d.pow(m-2,m)%m-1])?u*f[t].pow(m-2,m)*d.pow(n,m)%m:0)}

Measured memory_bytes: 31008
#include <stdio.h>
#include <string.h>
int main(){
    char s[150];
    int i,j,flag,flag1=0;
    while(scanf("%s",s) != EOF){
        flag=0;
        j=strlen(s);
        if(j != 1){
            for(i=0,j=j-1;s[i]!='\0';i++,j--){
                if(s[i] != s[j]){
                    flag=1;
                }
            }
        }
        if(flag == 0){
            flag1++;
        }
    }
    printf("%d\n",flag1);
    return (0);
}

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

N, M = map(int, input().split())
A = list(list(input()) for i in range(N))
B = list(list(input()) for i in range(M))

ans = False
for i in range(N):
    for j in range(N):
        if i + M - 1 >= N or j + M - 1 >= N:
            continue
        match = True
        for y in range(M):
            for x in range(M):
                if A[i + y][j + x] != B[y][x]:
                    match = False
        if match:
            ans = True

print('Yes' if ans else 'No')


Measured memory_bytes: 3064
use std::io;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .ok();
  line
}

fn line_to_vec_i32(line: &str) -> Vec<i32> {
  line
    .trim()
    .split_whitespace()
    .map(|s| { s.parse::<i32>().unwrap_or(0) })
    .collect()
}

fn main() {
  let mut idx = 1;
  loop {
    let line = get_line();
    let v = line_to_vec_i32(&line);
    if v[0] == 0 {
      break;
    }
    else {
      println!("Case {}: {}", idx, v[0]);
      idx += 1;
    }
  }
}



Measured memory_bytes: 5052
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    char c='A';
    int ans=0;
    rep(i,s.length()){
        if(c>=s[i])ans++;
        c=s[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3228
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int fx = 0;
		int x = n;
		while(x != 0) {
			fx += x % 10;
			x /= 10;
		}
		if(n % fx == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
	int n, l;
	cin >> n >> l;
	string s[n];
	for (int i = 0;i < n;i++)cin >> s[i];
	sort(s, s + n);
	for (int i = 0;i < n;i++)cout << s[i];
	cout << endl;
}


Measured memory_bytes: 256