akhauriyash/Code-Regression huggingface dataset:
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
string s;
cin>>s;
vector<ll>rt(s.size(),0),lt(s.size(),0);
ll lft=s.size()-1;
for(ll i=s.size()-2;i>=0;i--)
{
    if(s[i]=='R')
    {
        rt[i]=lft;
    }else
    {
        lft=i;
    }
}
ll right=0;
for(ll i=1;i<s.size();i++)
{
    if(s[i]=='L')
    {
        lt[i]=right;
    }else
    {
        right=i;
    }
}
vector<ll>ans(s.size(),0);
for(ll i=0;i<s.size();i++)
{
    if(s[i]=='R')
    {
        ll dif=rt[i]-i;
        if(dif&1)
        {
            ans[rt[i]-1]++;
        }else
        {
            ans[rt[i]]++;
        }
    }else
    {
        ll dif=fabs(lt[i]-i);
        if(dif&1)
        {
            ans[lt[i]+1]++;
        }else
        {
            ans[lt[i]]++;
        }
    }
}
for(ll i=0;i<ans.size();i++)
{
    cout<<ans[i]<<" ";
}

return 0;
}


Measured memory_bytes: 3024
#include <iostream>

using namespace std;

int main() {
	int N;
	int A[210];
	
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int cnt = 0;
	while (true) {
		bool isEven = true;
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 != 0) {
				isEven = false;
			}
		}
		if(isEven == false){
			break;
		}
		else {
			for (int i = 0; i < N; i++) {
				A[i] = A[i] / 2;
			}
			cnt++;
		}
	
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<vector<int>> adj;

string ans = "Fennec";

void solve(){
    queue<int> q;
    q.push(1);
    vector<int> used(N+1,-1);
    used[1] = 0;
    while(!q.empty()){
        int now = q.front();q.pop();
        for(int next : adj[now]){
            if(used[next]==-1){
                used[next] = now;//どこからやってきたのかを格納
                q.push(next);
            }
        }
    }

    //フェネックとすぬけくんの初期位置の距離を求める
    //きた道を逆にたどって距離を求める
    int dist_1_to_N = 0;
    int now = N;
    while(now!=1){
        now = used[now];
        dist_1_to_N++;
    }

    queue<int> p;

    vector<int> color(N+1,-1);//0なら黒、1なら白とする
    color[1] = 0;color[N] = 1;
    //フェネックとすぬけくんの間に色を塗る
    int vertex = N;
    int numof_white = (dist_1_to_N-1)/2;
    while(vertex!=1){
        vertex = used[vertex];
        color[vertex] = (numof_white>=1);
        if(numof_white>=1) p.push(vertex);
        numof_white--;
    }

    p.push(N);
    while(!p.empty()){
        int now = p.front();p.pop();
        for(int next : adj[now]){
            if(color[next]==-1){
                color[next] = 1;
                p.push(next);
            }
        }
    }

    int white_counter = 0;
    for(int i=1;i<=N;i++) white_counter += (color[i]==1);
    if(white_counter>=N-white_counter) ans = "Snuke";
}
 
int main(){
    cin >> N;
    adj = vector<vector<int>>(N+1);
    for(int i=0;i<=N-2;i++){
        int a,b;cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
 
    solve();

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

Measured memory_bytes: 6656
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
void Main()
{
    int T,n,k;
    cin>>T;
    while(T--)
    {
        cin>>n>>k;
        if(!n)
        {
            cout<<"Bob"<<endl;
            continue;
        }
        if(k % 3 != 0) cout<<(n % 3 == 0 ? "Bob" : "Alice")<<endl;
        else
        {
            if(n %(k+1) == 0)
            {
                cout<<"Bob"<<endl;
                continue;
            }
            int num = (n %(k+1) -1) / 3;
            if(num == (k-1)/3) cout<<"Alice"<<endl;
            else cout<<(n % (k+1) %3 == 0 ? "Bob" : "Alice")<<endl;
        }
    }
}
int32_t main()
{
    IOS;
    double x1,x2,xp,y1,y2,yp,s,ansx,ansy;
    int q;
    bool Xt = false,Yt = false;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    scanf("%d",&q);

    if(y1 == y2)
    {
        Xt = true;
    }
    else if(x1 == x2)
    {
        Yt = true;
    }
    else
    {
        s= (y2-y1)/(x2-x1);
    }

    for(int i=0; i<q; i++)
    {
        scanf("%lf %lf",&xp,&yp);
        if(Xt)
        {
            printf("%.10lf %.10lf\n",xp,y1);
        }
        else if(Yt)
        {
            printf("%.10lf %.10lf\n",x1,yp);
        }
        else
        {
            ansx = (yp*(x2-x1)*(y2-y1)+xp*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
            ansy = ((x1-x2)*ansx+yp*(y2-y1)+xp*(x2-x1))/(y2-y1);
            printf("%.10lf %.10lf\n",ansx,ansy);
        }

    }

    return 0;
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b) << endl;

    return 0;
}


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

int main(){
    int a;
    cin >> a;
    vector<vector<ll>> A(a,vector<ll>(2));
    rep(i,a) rep(j,2) cin >> A.at(i).at(j);
    //Aのi番目には座標が入っている
    vector<ll> num(a);
    rep(i,a) num.at(i) = i;
    double sum;
    do{
        rep(i,a-1){
            sum += sqrt(pow(A.at(num.at(i+1)).at(0) - A.at(num.at(i)).at(0),2) + pow(A.at(num.at(i+1)).at(1) - A.at(num.at(i)).at(1),2));
        }
    }while(next_permutation(num.begin(),num.end()));

    int mul = 1;
    for(int i = 1;i<= a;i++) mul*= i; 
    cout << fixed << setprecision(10) << (double)sum/(double)mul << endl;
}

Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-3-24 21:05:52
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, Q;
string S;
int l[100010];
int r[100010];
int imos[2][100010];

int main()
{
  cin >> N >> Q >> S;
  for (auto i = 0; i < Q; i++)
  {
    cin >> l[i] >> r[i];
    l[i]--;
  }
  fill(&imos[0][0], &imos[0][0] + 100010, 0);
  for (auto i = 0; i < N - 1; i++)
  {
    if (S[i] == 'A' && S[i + 1] == 'C')
    {
      imos[0][i + 1]++;
      imos[1][i + 2]++;
    }
  }
  for (auto i = 1; i <= N; i++)
  {
    imos[0][i] += imos[0][i - 1];
    imos[1][i] += imos[1][i - 1];
  }
  for (auto i = 0; i < Q; i++)
  {
    if (imos[1][r[i]] == imos[0][r[i]])
    {
      cout << imos[1][r[i]] - imos[1][l[i] + 1] << endl;
    }
    else
    {
      cout << imos[1][r[i]] - imos[1][l[i] + 1] << endl;
    }
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> w(n,0);
	for(int i = 0;i<n;i++)
	{
		cin >> w.at(i);
	}
	int mn = 10000;
	for(int i = 1;i<n;i++)
	{
		int sm1=0,sm2=0;
		for(int j=0;j<n;j++)
		{
			if(j+1 > i)
			{
				sm2 += w.at(j);
			}
			else
			{
				sm1 += w.at(j);
			}
		}
		mn = min(mn,abs(sm1 - sm2));
	}
	cout << mn << endl;
	return 0;
}


Measured memory_bytes: 256
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let rec factorize acc i n =
  if n <= 1 then acc
  else if n < i * i then n :: acc
  else if n mod i = 0 then factorize (i :: acc) i (n / i)
  else factorize acc (i + 1) n
let factorize n =
  match factorize [] 2 n with
  | [] -> []
  | p :: ps ->
      let (acc, p, n) = List.fold_left (fun (acc, p, n) q ->
        if p = q
        then (acc, p, n + 1)
        else ((p, n) :: acc, q, 1)) ([], p, 1) ps in
      (p, n) :: acc

let () = Scanf.scanf "%d %d" @@ fun a b ->
  Printf.printf "%d\n" @@
  ( + ) 1 @@
  List.length @@
  factorize (gcd a b)



Measured memory_bytes: 384
import numpy as np
from collections import deque

def main():
    H, W = map(int, input().split())
    maze = [input() for _ in range(H)]

    # BFS is better-suited for distances from a given node

    def bfs(i, j):
        dist = [[-1 for _ in range(W)] for _ in range(H)] # dist to each node
        dist[i][j] = 0
        q = deque([(i, j)])

        while q:
            i, j = q.popleft()
            if i+1 < H and maze[i+1][j] == '.' and dist[i+1][j] == -1:
                q.append((i+1, j))
                dist[i+1][j] = dist[i][j] + 1
            if i-1 >= 0 and maze[i-1][j] == '.' and dist[i-1][j] == -1:
                q.append((i-1, j))
                dist[i-1][j] = dist[i][j] + 1
            if j+1 < W and maze[i][j+1] == '.' and dist[i][j+1] == -1:
                q.append((i, j+1))
                dist[i][j+1] = dist[i][j] + 1
            if j-1 >= 0 and maze[i][j-1] == '.' and dist[i][j-1] == -1:
                q.append((i, j-1))
                dist[i][j-1] = dist[i][j] + 1

        return max(max(i) for i in dist)
   
    ret = 0
    for i in range(H):
        for j in range(W):
            if maze[i][j] == '.':
                ret = max(ret, bfs(i, j))
    print(ret)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12496
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    int count=0,count2=0,j,a;
    for(int i=10;i<=N;i++){
        if(i%2==1){
            count2=1;
            for(int j=2;j<=i;j++){
                if(i%j==0){
                    count2++;
                }
            }
            if(count2==8) count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

//a=97,z=122

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

using namespace std;

char g[2048][2048];
int m1[2028][2048], m2[2028][2048];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) cin >> g[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)
			if (g[i][j] == '.') {
				m1[i][j] = 1;
				if (j > 0) m1[i][j] += m1[i][j - 1];
			}
		for (int j = w - 2; j >= 0; j--)
			if (g[i][j] == '.') m1[i][j] = max(m1[i][j], m1[i][j + 1]);
	}

	for (int j = 0; j < w; j++) {
		for (int i = 0; i < h; i++)
			if (g[i][j] == '.') {
				m2[i][j] = 1;
				if (i > 0) m2[i][j] += m2[i - 1][j];
			}
		for (int i = h - 2; i >= 0; i--)
			if (g[i][j] == '.') m2[i][j] = max(m2[i][j], m2[i + 1][j]);
	}

	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			ans = max(ans, m1[i][j] + m2[i][j] - 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 36736
import java.io.*;
import java.util.*;
class Main
{
public static void main (String args[])
{
   Scanner sc=new Scanner(System.in);
   int a[]=new int[3];
    a[0]=5;
    a[1]=7;
     a[2]=5;
    int b[]=new int[3];
    for(int i=0;i<3;i++)
      {b[i]=sc.nextInt();}
     int count=0;
    for(int i=0;i<3;i++)
     {
       for(int j=0;j<3;j++)
        {
          if(b[i]==a[j])
          {
             a[j]=0;
             count++;
              break;
           }
         }
       }
  if(count==3)
{
  System.out.println("YES");
}
else
System.out.println("NO");
   

}
}

Measured memory_bytes: 22868
int = int(input())
l = [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81]
if int in l:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
//
//  main.cpp
//  ABC121
//
//  Created by hiroaki on 2019/03/15.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int main(){
    int H,W,h,w;
    cin >>H>>W>>h>>w;//h==行,w==列
    cout<<H*W-(h*W+H*w-h*w)<<endl;
    return 0;
}
/*int main() {
    int n,m,c;
    cin>>n>>m>>c;
    vector<vector<int>> A;
    vector<int> B(m);
    for (int i=0; i<m; i++) {
        cin>>B.at(i);
    }
    for (int i=0; i<n; i++) {
         vector<int> v(m);
        for (int j=0; j<m; j++) {
            cin >> v.at(j);
        }
        A.push_back(v);
    }
    int success = 0;
    for (int i=0; i<n; i++) {
        int sum =0;
        for (int j=0; j<m; j++) {
            sum +=A[i][j]*B[j];
        }
        if (sum+c>0) {
            success++;
        }
    }
    cout<<success<<endl;
    return 0;
}*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=10010000;
int nod[S+5];

void Sieve()
{
    for(int i=1;i<=S;i++)
    {
        for(int j=i;j<=S;j+=i)nod[j]++;
    }
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    Sieve();
    int n;
    while(~sf("%d",&n))
    {
        ll ans=0;
        for(ll i=1;i<=n;i++)
        {
            ans+=(i*nod[i]);
        }
        pf("%lld\n",ans);
    }
    return 0;
}
 






































Measured memory_bytes: 42884
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def cnt(a,b):
    if a >= b:
        return cnt(a-b,b+1)
    else:
        return b - 1
    

c = collections.Counter(prime_factorize(n))
cn = 0
for i in c.values():
    cn += cnt(i,1)

print(cn)

# print(list(c.values()))

Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
int k, x;
int main () {
  //freopen(".inp", "r", stdin);
  //freopen(".out", "w", stdout);
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  cin >> k >> x;
  int l = x - k + 1;
  while (l <= x + k - 1) {
    cout << l << " ";
    ++ l;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int n, pos{0};
vi pre, in, post;
inline void rec(int l, int r) {
	if(l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(all(in), root));
	rec(l, m);
	rec(m + 1, r);
	post.eb(root);
}
inline void solve() {
	rec(0, len(pre));
	cout << post[0];
	rep(i, 1, n) cout << " " << post[i];
	cout << endl;
}
int main() {
	cin >> n;
	pre.resize(n); in.resize(n); post.reserve(n);
	rep(i, 0, n) cin >> pre[i];
	rep(i, 0, n) cin >> in[i];
	solve();
	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n,dp[100010][13];
string s;

signed main(){
	cin >> s;
	n = s.length();
	dp[0][0] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 13;j++){
			if(s[i] == '?'){
				for(int k = 0;k < 10;k++){
					(dp[i + 1][(j * 10 + k) % 13] += dp[i][j]) %= MOD;
				}
			}else{
				(dp[i + 1][(j * 10 + s[i] - '0') % 13] += dp[i][j]) %= MOD;
			}
		}
	}
	cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
//int n,m,c;
//string s;
int n;
int d[105][2];
long long ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ans+=n/i;
		if(n%i==0) ans--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace ABC091
{
    class Program
    {
        static void Main(string[] args)
        {
            //問題1
            int[] input = new int[3];
            input = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();

            if (input[0] + input[1] >= input[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.ReadLine();


        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long X, long long Y, long long Z){
  cout << Z << ' ' << X << ' ' << Y << endl;
}

signed main(){
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  long long Z;
  scanf("%lld",&Z);
  solve(X, Y, Z);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define maxn        998244353
#define mod         1000000007
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int solve()
{
	int n;
	cin >> n;
	int a[n], sum = 0;
	rep0(n)cin >> a[i];
	rep1(n - 1)sum += max(0ll, a[i - 1] - a[i]), a[i] += max(0ll, a[i - 1] - a[i]);
	cout << sum;
	return 0;
}
signed main()
{
	OJ();
	IOS
	//tc
	solve();
	//extime
	return 0;
}

Measured memory_bytes: 5212
n,m = map(int,input().split())
lst_l = []
lst_r = []
for _ in range(m):
    l,r = map(int,input().split())
    lst_l.append(l)
    lst_r.append(r)

max_l = max(lst_l)
min_r = min(lst_r)

count = 0
for i in range(n):
    if max_l <= i+1 <= min_r:
        count += 1

print(count)

Measured memory_bytes: 16788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace How_Many_Divisors
{
    class Program
    {
        public static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int ans = 0;
            for (int i = a; i <= b; ++i)
            {
                if (c % i == 0) ++ans;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 9244
N = int(input())
t,x,y = 0,0,0
f = True
for i in range(N):
    ti,xi,yi = map(int, input().split())
    p=ti-t
    d=abs(xi-x)+abs(yi-y)
    if p<d or p%2 != d%2:
        f = False
        break 
    t,x,y = ti,xi,yi
print('Yes' if f else 'No')


Measured memory_bytes: 3060
import numpy as np

S = list(map(int,input()))
S_len = len(S)
Tmp_S =[]
First_S = S[0]
for _ in range(S_len):
    Tmp_S.append(First_S)
    First_S = First_S ^ 1

S_np = np.array(S)
Tmp_S_np = np.array(Tmp_S)

TF_S = np.array(S_np == Tmp_S_np)
print(np.sum(TF_S == False))

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

int main() {
    int n;
    cin >> n;
    
    int a_i;
    cin >> a_i;
    long long total, max, min;
    total = max = min = a_i;
    for(int i=1; i < n; i++) {
        cin >> a_i;
        if (a_i > max) {
            max = a_i;
        } else if (a_i < min) {
            min = a_i;
        }
        total += a_i;
    }
    cout << min << " " << max << " " << total << endl;
    
    return 0;
}


Measured memory_bytes: 3104
N,K,Q = map(int,input().split())
A = []
p1 = [int(0)] * N
for i in range(Q):
    p1[int(input()) - 1] += 1
p2 = list(map(lambda x: x+(K-Q), p1))


for i in range(N):
    if(p2[i] > 0):
        print("Yes")
    else:
        print("No")

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

typedef long long ll;
typedef pair<int, int> ii; 

int main(int argc, char const *argv[]) {
	int n, p; 
	cin >> n >> p;
	int even = 0, odd = 0;
	for(int i = 0; i < n; i++) {
		int x; cin >> x; 
		if(x & 1) odd++;
		else even++;
	}
	if(even == n) {
		if(p == 1) puts("0"); 
		else printf("%lld\n", 1ll << n);
	} else {
		printf("%lld\n", 1ll << (n - 1));
	}
}

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

using namespace std;

class BinaryIndexedTree{
    int n;
    vector<int> node;

public:
    BinaryIndexedTree(int n_ = 0){
        n = n_;
        node.assign(n + 1, 0);
    }

    void add(int k, int x){
        ++k;

        while(k <= n){
            node[k] += x;
            k += k & -k;
        }

        return;
    }

    int get(int r){
        int res = 0;

        while(r > 0){
            res += node[r];
            r -= r & -r;
        }

        return res;
    }
};

constexpr long long MOD = 1000000007;
constexpr int M = 101010;

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

    vector<long long> fact(M + 1, 1LL);
    for(int i = 0 ; i < M ; ++i){
        fact[i + 1] = fact[i] * (i + 1) % MOD;
    }

    int n;
    while(cin >> n, n){
        vector<int> p(n);
        for(int i = 0 ; i < n ; ++i){
            p[i] = i;
        }

        int r;
        cin >> r;

        for(int i = 0 ; i < r ; ++i){
            int s, t;
            cin >> s >> t;
            --s;
            --t;
            swap(p[s], p[t]);
        }

        BinaryIndexedTree bit(n);

        long long ans = 0;
        for(int i = 0 ; i < n ; ++i){
            ans += (p[i] - bit.get(p[i])) * fact[n - i - 1];
            ans %= MOD;
            bit.add(p[i], 1);
        }

        cout << ans << '\n';
    }

    cout << flush;

    return 0;
}


Measured memory_bytes: 4400
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;

    int d,r;
    double f,aa=a,bb=b;



    d = a/b;
    r = a%b;
    f = aa/bb;



    printf("%d %d %.8lf\n",d,r,f);

    return 0;

}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
struct node {
	ll a,b;
	bool operator<(const node& qq){
		return this->b>qq.b;
	}
} p[100010];
int main() {
	ios::sync_with_stdio(false);
	int n;
	ll h;
	cin>>n>>h;
	for(int j=1; j<=n; j++) cin>>p[j].a>>p[j].b;
	sort(p+1,p+n+1);
	//for(int j=1; j<=n; j++) cout<<p[j].a<<" "<<p[j].b<<endl;
	if(n!=1) {
		ll ans=0,sum=0,maxa=0,maxab;
		for(int j=1; j<=n; j++) {
			if(maxa<p[j].a) {
				maxa=p[j].a;
				maxab=p[j].b;
			} else if(maxa==p[j].a) {
				if(maxab>p[j].b)
					maxab=p[j].b;
			}
		}
		for(int j=1; j<=n; j++) {
			if(p[j].b>=maxa) {
				sum+=p[j].b;
				ans++;
				if(sum>=h) break;
			}
		}
		//cout<<ans<<" "<<maxa<<" "<<maxab<<endl;
		if(sum>=h) cout<<ans;
		else if((h-sum)%maxa==0) cout<<(h-sum)/maxa+ans;
		else cout<<(h-sum)/maxa+ans+1;
	} else {
		if((h-p[1].b)%p[1].a==0) cout<<((h-p[1].b)/p[1].a)+1;
		else cout<<(h-p[1].b)/p[1].a+2;
	}

	return 0;
}



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

int main() {
	int N, M, L, R, ansL, ansR;
	cin >> N >> M;
	ansL = 0, ansR = N;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		ansL = max(ansL, L);
		ansR = min(ansR, R);
	}
	cout << max(0, ansR - ansL + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int q;
  cin >> s >> q;
  deque<char> deq;
  for (auto e : s)
    deq.push_back(e);
  bool front = true;
  rep(query, q) {
    int x;
    cin >> x;
    if (x == 1)
      front ^= 1;
    else {
      int f;
      char c;
      cin >> f >> c;
      bool pb = (f == 1)^front;
      if (pb)
        deq.push_back(c);
      else
        deq.push_front(c);
    }
  }
  if (front) {
    while (!deq.empty()) {
      char c = deq.front();
      deq.pop_front();
      cout << c;
    }
  } else {
    while (!deq.empty()) {
      char c = deq.back();
      deq.pop_back();
      cout << c;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 976
n = int(input())
b = list(map(int,input().split()))

ans = []

for i in range(n):
    tmp = -1
    for j,e in enumerate(b):
        if j + 1 == e:
            tmp = max(tmp, e)
    if tmp == -1:
        print(-1)
        exit()
    else:
        ans.append(tmp)
        b = b[:tmp-1] + b[tmp:]

for i in ans[::-1]:
    print(i)


Measured memory_bytes: 64496
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 333;

int n,m;
char a[N], b[N];
char s[N][N];
int d[N][N], v[N][N];

int get(int py) {
	FOR(i,n) {
		a[i] = s[i][py];
		b[i] = s[i][py+1];
	}
	for (int dif = -n; dif <= n; dif++) {
		for (int h = 1; h <= n; h++) {
			int add = 0;
			if (h-1+dif >= 0 && h-1+dif < n) add = a[h-1] == b[h-1+dif];
			if (h+dif-1 >= 0 && h+dif <= n)
				v[h][h+dif] = v[h-1][h+dif-1] + add;
		}
	}
	a[n]=b[n]=0;
	//printf("a=%s, b=%s\n", a, b);
	//FOR(x,n+1) FOR(y,n+1) {
	//	printf("%d ", v[x][y]);
	//	if (y==n) printf("\n");
	//}
	//printf("d=\n");
	for (int x = 0; x <= n; x++) for (int y = 0; y <= n; y++) {
		d[x][y] = 1e9;
		if (x==0 || y==0) d[x][y]=0;
		else {
			d[x][y] = min(d[x][y], d[x-1][y] + v[x][y]);
			d[x][y] = min(d[x][y], d[x][y-1] + v[x][y]);
		}
		//printf("%d ", d[x][y]);
		//if (y==n) printf("\n");
		//printf("%d %d %d\n", x, y, d[x][y]);
	}
	//printf("res = %d\n", d[n][n]);
	return d[n][n];
}

void test() {
	scanf("%d%d", &n, &m);
	FOR(i,n) scanf("%s", s[i]);
	int res = 0;
	FOR(j,m-1) res += get(j);
	printf("%d\n", res);
}

int main() {
	test();
	return 0;
}


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

#define REP(i, a, b)  for(int i = a, _b = b; i < _b; ++i)
#define FOR(i, a, b)  for(int i = a, _b = b; i <= b; ++i)
#define FORD(i, a, b) for(int i = a, _b = b; i >= b; --i)

using namespace std;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef long long llong;

char grid[55][55];
int H, W;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
#ifdef Home
   freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
   cin >> W >> H;
   REP(i, 0, W) {
   	REP(j, 0, H) {
   		cin >> grid[i][j];
   		if(grid[i][j] == '.')
   			grid[i][j] = '0';
   	}
   }
   
   REP(x, 0, W) {
   	REP(y, 0, H) {
   		if(grid[x][y] == '#') {
   			REP(i, 0, 8) {
   				int nx = x + dx[i];
   				int ny = y + dy[i];
   				if(nx >= 0 and nx < W and ny >= 0 and ny < H and grid[nx][ny] != '#') {
   					grid[nx][ny]++;
   				}
   			}
   		}
   	}
   }
   
   REP(x, 0, W) {
   	REP(y, 0, H) {
  			cout << grid[x][y];
   	}
   	cout << endl;
   }
   return 0;
}

Measured memory_bytes: 256
/* -----------------------------------------------------------------------------
	AtCoder Beginner Contest 139
	E - League
	g++ bc139E.cpp

----------------------------------------------------------------------------- */
#include <cstdio>
#include <stack>
#include <algorithm>

using namespace std;

#define MAX_N 	1001	// 選手数の最大

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int 	N;					// 選手数
int 	gcnt[MAX_N];		// 消化試合数
int		A[MAX_N][MAX_N];	// 試合順序
stack<int> q;


int main () {

	int total_match;

	// 選手数の読込み
	scanf("%d", &N);
	// ベクトルの読込みと偏角計算
	for(int i = 1; i <= N; i++) {
		A[i][0] = 0;
		for(int j = 1; j < N; j++) scanf("%d", A[i] + j);
		gcnt[i] = 1;
	}

	// 初期設定
	total_match = 0;	// 総試合数
	for(int i = 1; i <= N; i++) { 
		int you=A[i][gcnt[i]];
 		// 対戦相手は本日試合しおらず，対戦順が合致
		if(A[you][gcnt[you]] == i) q.push(i);
	}

	while(!q.empty()) {
		int i = q.top(); q.pop();
		// iさんは全員と対戦済み
		if(gcnt[i] == N) continue;
		// 対戦相手
		int you=A[i][gcnt[i]];
		// 対戦相手は本日試合しおらず，対戦順が合致
		if(gcnt[you] < N && A[you][gcnt[you]] == i) {
				// 対戦
				A[i][gcnt[i]] = A[you][gcnt[you]] = std::max(A[i][gcnt[i]-1], A[you][gcnt[you]-1]) + 1;
				gcnt[i]++; gcnt[you] ++; 
				q.push(i); q.push(you);
				total_match++;
		}
	}

	if(total_match < N * (N - 1) / 2) printf("%d\n", -1);
	else {
		int day = A[1][N-1];
		for(int i = 2; i < N; i++)
			if(day < A[i][N-1]) day = A[i][N-1];
		printf("%d\n", day);		
	}
	return 0;
}

Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

void couting_sort(vector<int> &a, vector<int> &b, int k)
{
	vector<int> c(k + 1);
	
	for (int i = 0; i < a.size() - 1; i++)
	{
		c.at(a.at(i))++;
	}

	for (int i = 1; i <= k; i++)
	{
		c.at(i) += c.at(i - 1);
	}


	for (int i = a.size() - 2; i >= 0; i--)
	{
		b.at(c.at(a.at(i))) = a.at(i);
		c.at(a.at(i))--;	
	}
}

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

	vector<int> a(n + 1);
	vector<int> b(n + 1);

	int k = -INF;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a.at(i));

		k = max(k, a.at(i));
	}

	couting_sort(a, b, k);

	for (int i = 1; i <= n; i++)
	{
		cout << (i == 1 ? "" : " ") << b.at(i);
	}


	cout << endl;
}


Measured memory_bytes: 18316
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> num(n+1);
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j+= i) num[j]++;
    }
    ll ans = 0;
    for(int i=1;i <= n;i++) ans += 1LL* i * num[i];
    cout << ans << endl;
}

Measured memory_bytes: 42268
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int cnt = 0;
    for(int i=1; i<=N; ++i){
        if(i!=p[i-1]) cnt++;
    }
    cout << (cnt==2||cnt==0 ? "YES": "NO") << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	string str;

	getline( cin, str );

	for ( unsigned int i = 0; i < str.length(); i++ )
	{
		if ( 'a' <= str[i] && str[i] <= 'z' )
		{
			str[i] = toupper( str[i] );
		}
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, k;
  cin >> n >> k;
  if (n%k == 0) dump(0);
  else dump(1);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
for i in range(n):
    x[i], y[i] = map(int,input().split())
ans = 0.0
def dis(i, j):
    return ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
for i in range(n):
    for j in range(i+1,n):
        ans += dis(i,j)
print(ans*2/n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef string::const_iterator Cursol;
string Cipher(Cursol& c);


string str;


char Letter(Cursol& c){
  char ci;
  switch(*c){
  case '+':
    ci = Letter(++c);
    if(ci == '?') return '?';
    else return (ci + 1 - 'A') % 26 + 'A';
  case '-':
    ci = Letter(++c);
    if(ci == '?') return '?';
    else return (ci - 'A' + 25) % 26 + 'A';
  case '?':
    return '?';
  default:
    return *c;
  }
}

string String(Cursol& c){
  string s;
  switch(*c){
  case '[':
    c++;
    s = Cipher(c);
    reverse(s.begin(), s.end());
    return s;
  default:
    s.resize(1);
    s[0] = Letter(c);
    return s;
  }
}

string Cipher(Cursol& c){
  string s;
  while(c != str.end() && *c != ']'){
    s += String(c);
    c++;
  }
  return s;
}

int main(){
  Cursol c;

  while(cin >> str, str != "."){
    string s = Cipher(c = str.begin());
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '?') s[i] = 'A';
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double ans = 0;
    for(int i = 0; i < n; i++) {
      double x = sc.nextDouble();
      String u = sc.next();
      if(u.equals("JPY")) {
        ans += x;
      } else {
        ans += (x * (double)380000);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string n; cin>>n;
	if (n[0]==n[1]&&n[1]==n[2]||n[1]==n[2]&&n[2]==n[3]) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }
        for (int i = n - 1; i > 0; i--) {
            if (h[i] < h[i - 1]) {
                h[i - 1]--;
            }
            if (h[i] < h[i - 1]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 47952
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll n;
set<ll> t;

bool can(int x){
	bool f3=0,f5=0,f7=0;
	while(x){
		if(x%10==3)f3=1;
		if(x%10==5)f5=1;
		if(x%10==7)f7=1;
		x/=10;
	}
	return f3&&f5&&f7;
}

void dfs(ll cur){
	if(cur>n){
		return ;
	}
	if(can(cur))t.insert(cur);
	dfs(cur*10+3);dfs(cur*10+5);dfs(cur*10+7);
}

int main(){

	cin>>n;
	dfs(0);
	int res=t.size();
	cout<<res;

	return 0;
}


Measured memory_bytes: 1536
s = input()
k = int(input())
c = 0
i = 0
if s[0]*len(s) == s:
    print(len(s)*k//2)
else:   
        
    while i<len(s)-1:
        if s[i] == s[i+1]:
            c += 1
            i += 2
        else:
            i += 1
    if s[0] == s[-1] and i==len(s)-1:
        s_ = s + s
        c0 = 0
        i = 0
        while i<len(s_)-1:
            if s_[i] == s_[i+1]:
                c0 += 1
                i += 2
            else:
                i += 1
        if 2*c == c0:
            print(k*c)
        else:
            c += 1
            print(k*c-1)
    else:
        print(k*c)

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void go(auto& grid, int dep) {
    if (2 * dep + 1 >= grid.size()) {
        const int H = grid.size();
        const int W = grid[0].size();

        set<string> matches;
        for (int i = 0; i < W; i++) {
            string col(H, '.');
            for (int j = 0; j < H; j++)
                col[j] = grid[j][i];

            string tmp = col;
            reverse(all(tmp));
            if (matches.count(tmp)) {
                matches.erase(tmp);
            } else {
                matches.insert(col);
            }
        }

        if (!matches.size()) {
            cout << "YES\n";
            exit(0);
        } else if (matches.size() == 1) {
            string elt = *matches.begin();
            string tmp = elt;
            reverse(all(tmp));
            if (elt == tmp) {
                cout << "YES\n";
                exit(0);
            }
        }
    } else {
        const int H = grid.size();
        for (int pr = dep + 1; pr < H - dep; pr++) {
            if ((H&1) && (pr == H/2)) continue;
            swap(grid[pr], grid[H - dep - 1]);
            go(grid, dep + 1);
            swap(grid[pr], grid[H - dep - 1]);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int H, W;
    cin >> H >> W;

    vector<string> grid(H);
    for (int i = 0; i < H; i++) {
        cin >> grid[i];
    }

    if (H&1) {
        int m = H / 2;
        for (int i = 0; i < H; i++) {
            swap(grid[i], grid[m]);
            go(grid, 0);
            swap(grid[i], grid[m]);
        }
    } else go(grid, 0);

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



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a[102],b[102];
	int n;
	int time[1001];
	cin>>a[0]>>b[0];
	cin>>n;
	int i;
	for(i=0;i<1000;i++){
		time[i]=0;
	}
	for(i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	

	for(i=0;i<=n;i++){
		time[a[i]]++;
		time[b[i]]--;
	}
	
	for(i=0;i<1000;i++){
		if(0<i){
			time[i]+=time[i-1];
		}
	}
	
	bool flg=false;
	
	for(i=0;i<1000;i++){
		if(time[i]>1){
			flg=true;
		}
	}
	
	cout<<((flg)?"1":"0")<<endl;
	
	return 0;
}


Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		sc.nextLine();
		String s = sc.nextLine();

		long cntR = cnt(s,'R');
		long cntG = cnt(s,'G');
		long cntB = cnt(s,'B');

		long anti = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				int k = 2*j - i;
				if(k < n) {
					if(s.charAt(i) !=  s.charAt(j) && s.charAt(j) != s.charAt(k) && s.charAt(i) != s.charAt(k)) {
						anti++;
					}
				}
			}
		}

		System.out.println(cntR * cntG * cntB - anti);
	}

	public static long cnt(String str,char c) {
		long cnt = 0;

		for(char x:str.toCharArray()) {
			if(c == x) {
				cnt++;
			}
		}

		return cnt;
	}

}


Measured memory_bytes: 36896
N, K = map(int, input().split())
As = list(map(int, input().split()))
tl = [0]
ts = {0}

t = 0
for i in range(N):
    t = As[t]-1
    if t in ts:
        break
    else:
        tl.append(t)
        ts.add(t)

d = tl.index(t)
p = i - d + 1

if K > d:
    idx = (K - d) % p + d
else:
    idx = K

print(tl[idx]+1)


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

using namespace std;

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

  int n;
  cin >> n;
  int cmd;

  bitset<64> bs(0);
  int val;
  for (int i = 0; i < n; i++) {
    cin >> cmd;
    switch (cmd) {
      case 0:
        cin >> val;
        cout << bs.test(val) << endl;
        break;

      case 1:
        cin >> val;
        bs.set(val);
        break;

      case 2:
        cin >> val;
        bs.reset(val);
        break;

      case 3:
        cin >> val;
        bs.flip(val);
        break;

      case 4:
        cout << bs.all() << endl;
        break;

      case 5:
        cout << bs.any() << endl;
        break;

      case 6:
        cout << bs.none() << endl;
        break;

      case 7:
        cout << bs.count() << endl;
        break;

      case 8:
        cout << bs.to_ullong() << endl;
    }
  }
}




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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int gcd(int a,int b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int kaizyou(int N){
  int num=1;
  for(int i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int mod=1e9+7;

signed main() {
  int a,b,c;
  cin >> a >> b >>c;
  int d=a-b;
  if(d>c){
    cout << 0 << endl;
  }
  else{
    cout << c-d << endl;
  }
  
} 
  
  
  

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


int MOD=1000000007;

int main(void){
    priority_queue<long long> que;
    long long N,M,sum=0;
    cin >> N >> M;
    long long A,B=0;
    for(long long i=0; i<N; i++){
        cin >> A;
        que.push(A);
    }
    for(long long i=0; i<M; i++){
      B=que.top();
      que.pop();
        B/=2;
        que.push(B);
        if(que.top()==0) break;
    }
    for(long long i=0; i<N; i++){
        sum+=que.top();
        que.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 1400