akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
ans = 0
ok = [False]*N
for i in range(N):
    if i < K:
        if T[i] == 'r':
            ans += P
        elif T[i] == 's':
            ans += R
        else:
            ans += S
    else:
        if T[i] == 'r':
            if T[i - K] == 'r':
                if ok[i - K]:
                    ans += P
                else:
                    ok[i] = True
            else:
                ans += P
        elif T[i] == 's':
            if T[i - K] == 's':
                if ok[i - K]:
                    ans += R
                else:
                    ok[i] = True
            else:
                ans += R
        else:
            if T[i - K] == 'p':
                if ok[i - K]:
                    ans += S
                else:
                    ok[i] = True
            else:
                ans += S
print(ans)

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

int main(void){
  int i,n,sum;
  cin >> n;

  int *b = new int[n-1];
  int *a = new int[n];

  for(i=0;i<n-1;i++){
    cin >> b[i];
  }
  sum = 0;

  for(i=0;i<n;i++){
    if(i==0){
      a[i] = b[i];
    }else if(i==(n-1)){
      a[i] = b[i-1];
    }else{
      if(b[i-1]<b[i]){
        a[i] = b[i-1];
      }else{
        a[i] = b[i];
      }

    }
    sum = sum + a[i];
    //cout << sum <<"\n";


  }

  cout << sum << "\n";

  delete[] b;
  delete[] a;

  return 0;

}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  s,p = map(str, input().split())
  a.append([s,int(p),i+1])
  a.sort(key=lambda x:x[1],reverse =True)
  a.sort(key =lambda x:x[0])
for e in a:
  print(e[2])

Measured memory_bytes: 3060
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define YES            cout<<"YES"<<endl;
#define NO             cout<<"NO"<<endl;
#define sz(x)          x.size()
#define ll             long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>());
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>());
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll a,b;
    cin >> a >> b;
    ll k=a+b;
    if(k%2==0)
    {
        cout << k/2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE"  << endl;
    }

	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int x, y, z; std::cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  std::cout << x << " " << y << " " << z << "\n";
}


Measured memory_bytes: 256
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

void MAIN() {

    ll a, b;
    cin >> a >> b;
    cout << 6 - a - b << '\n';

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0;i<n;i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  for(int i = 0 ;i<n;i++){
  cout << s.at(i);
  }
}

Measured memory_bytes: 256
//JI SRI KRISHNA.//
#include<iostream>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a<=b)
    {
        for(i=0;i<b;i++)
            cout<<a;
        cout<<endl;
    }
    else
    {
        for(i=0;i<a;i++)
            cout<<b;
        cout<<endl;
    }
}


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

int main(){
    string s;
    int num,MIN=999;
    int ans;

    cin >>s;

    for (int i = 0; i < s.length()-2; i++){
        num = 100*(s[i]-'0')  + 10*(s[i+1]-'0') +(s[i+2]-'0');
        if(MIN > abs(753-num)){
            MIN=abs(753-num);
            ans=num;
        }
    }
    //cout << ans <<endl;
    cout << MIN <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import std.stdio,std.string,std.conv;

int main()
{
	string ans[1024];
	int count = 0;
	string[] _s = readln.chomp.split(" ");
	foreach(i;0.._s.length)
	{
		string s;
		foreach(j;0.._s[i].length)
		{
			if(_s[i][j] != ',' && _s[i][j] != '.')
			{
				s ~= _s[i][j];
			}
		}

		if(2 < s.length && s.length < 7)
		{
			ans[count] = s;
			count++;
		}
	}

	foreach(i;0..count)
	{
		if(i == count - 1)
		{
			ans[i].writeln;
		}
		else
		{
			write(ans[i]," ");
		}
	}
	return 0;
}

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

int main() {
  int n, y;
  cin>>n>>y;
  for (int i=0; i<=n; i++) {
    if (10000 * i > y) {
      break;
    }
    for (int j=0; i+j<=n; j++) {
      int z = 10000 * i + 5000 * j;
      if (z > y) {
        break;
      }
      int k = n - i - j;
      if (z + 1000 * k == y) {
        cout<<i<<" "<<j<<" "<<k<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	if (s[0] == s[1] && s[0] == s[2]) {
		cout << "Yes\n";
	}
	else if (s[1] == s[2] && s[1] == s[3]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=2017;
const int SEGSIZE=1<<16;
const int INF=1<<29;
const LL p=1e9+7;
bool maps[SIZE][SIZE];
LL N,x;
int main(){
	cin >> N;
	VI nums;
	REP(i,N){
		cin >> x;
		nums.PB(x);
	}
	sort(ALL(nums),greater<ut>());
	VI twins;
	REP(i,N){
		if(i && nums[i]==nums[i-1]){
			twins.PB(nums[i]);
			i++;
		}
	}
	twins.PB(0);
	twins.PB(0);
	cout << twins[0] * twins[1] << endl;
	return 0;
}

Measured memory_bytes: 1908
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll l,r;
    cin >> l >> r;

    ll ans = INF;

    for(ll i = l; i < r && i < l + 2019; i++){
        for(ll j = i+1; j <= r && j < i + 2020; j++){
            ans = min(ans,(i*j)%2019);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  
  for(int i=0;i<ty - sy;i++){
    cout << "U";
  }
  for(int i=0;i<tx - sx;i++){
    cout << "R";
  }
  for(int i=0;i<ty - sy;i++){
    cout << "D";
  }
  for(int i=0;i<tx - sx;i++){
    cout << "L";
  }
  cout << "L";
  for(int i=0;i<ty - sy + 1;i++){
    cout << "U";
  }
  for(int i=0;i<tx - sx + 1;i++){
    cout << "R";
  }
  cout << "D";
  cout << "R";
  for(int i=0;i<ty - sy + 1;i++){
    cout << "D";
  }
  for(int i=0;i<tx - sx + 1;i++){
    cout << "L";
  }
  cout << "U" << endl;
  
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	rep(i, N) cin >> S[i];

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

	map<string, int> m;
	rep(i, N) {
		m[S[i]]++;
	}

	int cnt = m.size();
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 25132
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <cmath>
#include <vector>

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

  int32_t N, Z, W;
  std::cin >> N >> Z >> W;
  std::vector<int32_t> a(N);
  for (auto& i : a) {
    std::cin >> i;
  }

  if (N >= 2) {
    std::cout << std::max(std::abs(W - a[N-1]), std::abs(a[N-1] - a[N-2])) << std::endl;
  } else {
    std::cout << std::abs(W - a[N-1]) << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll uni[100005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    ll n,a,b;
    vector<pair<ll,ll> > v,s;
    cin>>n;
    map<pair<ll,ll>,ll> mp;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.pb(make_pair(a,b));
        mp[make_pair(a,b)]=i;
        s.pb(make_pair(b,a));
    }
    sort(be(v));
    sort(be(s));
    multiset<pair<ll,pair<ll,ll> > > ms;
    ll d;
    for(int i=0;i<n-1;i++){
        d=min(abs(v[i+1].first-v[i].first),abs(v[i+1].second-v[i].second));
        ms.insert(make_pair(d,make_pair(mp[v[i]],mp[v[i+1]])));
    }
    for(int i=0;i<n;i++)swap(s[i].first,s[i].second);
    for(int i=0;i<n-1;i++){
        d=min(abs(s[i+1].first-s[i].first),abs(s[i+1].second-s[i].second));
        ms.insert(make_pair(d,make_pair(mp[s[i]],mp[s[i+1]])));
    }
    ll ans=0;
    multiset<pair<ll,pair<ll,ll> > > ::iterator itr;
    while(!ms.empty()){
        itr=ms.begin();
        d=(*itr).first;
        a=(*itr).second.first;
        b=(*itr).second.second;
        ms.erase(itr);
        if(root(a)!=root(b)){
            connect(a,b);
            ans+=d;
        }
    }
    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 22880
#include <iostream>
using namespace std;
	typedef long long int lli;
	const int MaxN=100005;
	int cub[2000];
int main(){
	lli N,K,cant,i,j,p,q,res=0;
	cin>>N>>K;
	for(i=0;i<K;i++){
		cin>>cant;
		for(j=0;j<cant;j++){
			cin>>p;
			cub[p]+=1;
		}
	}
	for(i=1;i<=N;i++){
		if(cub[i]==0)res+=1;
	}
	cout<<res;
}

Measured memory_bytes: 3168
#include<stdio.h>
int main()
{
	long long int n,m;
	while(scanf("%lld %lld",&n,&m)!=EOF)
	{
		if(m/2<=n)
		{
			printf("%lld\n",m/2);
		}
		else
		{
			printf("%lld\n",n+(m-2*n)/4);
		}
	}
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        List<int> list = new List<int>();

        while (true) {
            string v = Console.ReadLine();
            if (string.IsNullOrEmpty(v) == true) { break; }

            list.Add(int.Parse(v));
        }

        list.Sort();
        Console.WriteLine(list[list.Count - 1]);
        Console.WriteLine(list[list.Count - 2]);
        Console.WriteLine(list[list.Count - 3]);
    }
}

Measured memory_bytes: 9252
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N, D;

double dis(int i, int j,vector< vector<int> > vec){
  double res = 0;
  for(int k = 0; k < D; k++){
    res += pow(vec[i][k] - vec[j][k], 2);
  }
  return sqrt(res);
}

int main(){
  cin >> N >> D;
  vector< vector<int> > X(N, vector<int>(D));
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> X[i][j];
    }
  }

  int cnt = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      double res = dis(i,j,X);
      double res2 = (double)((int)res);
      if(res == res2) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
# problem 4
# Snuke the wizard
N, Q = map(int, input().split())
S = list(input())
que = [tuple(input().split()) for _ in range(Q)]


def isout_l(X):
    # 左にはみ出るか
    if X == 0:
        return True
    now = X-1
    for alpha, dire in que:
        if S[now] == alpha:
            if dire == "R":
                now += 1
                if now == N:
                    return False
            else:
                now -= 1
                if now == -1:
                    return True
    return False


def isout_r(X):
    # 右にはみ出るか
    if X == N+1:
        return True
    now = X-1
    for alpha, dire in que:
        if S[now] == alpha:
            if dire == "R":
                now += 1
                if now == N:
                    return True
            else:
                now -= 1
                if now == -1:
                    return False
    return False


l_limit = 0  # 左にはみ出さない物の最も小さい番目
if isout_l(1) == False:
    l_limit = 1

elif isout_l(N) == True:
    l_limit = N+1
else:
    l = 1
    r = N
    while r-l > 1:
        Med = (l+r)//2
        if isout_l(Med):
            l = Med
        else:
            r = Med
    l_limit = r

r_limit = 0  # みぎにはみ出さない最も大きい番目
if isout_r(N) == False:
    r_limit = N
elif isout_r(1) == True:
    r_limit = 0

else:
    l = 0
    r = N+1
    while r-l > 1:
        Med = (r+l)//2
        if isout_r(Med):
            r = Med
        else:
            l = Med
        r_limit = l
print(r_limit-l_limit+1)

Measured memory_bytes: 103368
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1; i<n; i++){
		if(n%i==0){
			ans+=(n/i-1);
		}
		else ans+=n/i;
	}
	cout<<ans<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


Measured memory_bytes: 3648
N, K = map(int, input().split())

A = list(map(int, input().split()))

# import numpy as np

# N = 200000
# K = 9999
# A = np.random.randint(1, 10 ** 9, N)

i = 0

for k in range(K, N):
    if A[i] < A[k]:
        print("Yes")
    else:
        print("No")
    i += 1
    

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

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);

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

    int sum;
    sum = 0;
    for (int i = 0; i < N; i++){
        if (V[i] > C[i]){
            sum += (V[i] - C[i]);
        }
    }
    cout << sum << endl;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int tmp = 0, ans = n;
    while(tmp < n){
        if(s[tmp] == s[tmp + 1]){
            ans--;
        }
        tmp++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, m;

const ULL mx = 1000000000000000000;

unsigned long long a[100003];

int main()
{
	//File("");
    n = gi();
    long long ans = 1;
    for (int i = 1; i <= n; i+=1) cin >> a[i];
    sort(a + 1, a + 1 + n);
    if (a[1] == 0)
    {
    	puts("0");
    	return 0;
    }
    for (int i = 1; i <= n; i+=1)
    {
    	ans *= a[i]; 
    }
    if (ans > mx || ans == 0) ans = -1;
    printf("%lld\n", ans);
	return 0;
}	

Measured memory_bytes: 4440
#include <bits/stdc++.h>
#include <cmath>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
unsigned ll f(unsigned ll x){
	if(x==1){return 1;}
	unsigned ll a=f(x/2);
	return a*2+1;
}
int main()
{
unsigned ll h;	
	cin>>h;cout<<f(h)<<endl;
    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char buf[100005];

int main(){

	scanf("%s",buf);

	int len;
	for(len = 0; buf[len] != '\0'; len++);

	for(int i = 0; i < len-1; i++){
		if(buf[i] == buf[i+1]){

			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		if(i+4 < len && buf[i] == buf[i+2]){

			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}

	printf("-1 -1\n");

	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 1024;
int N,M;
vector<P2> V[MC];
vector<P2> E;
bool ans[200010];
bool visited[MC];

void dfs(int q){
	visited[q] = 1;
	for(auto u : V[q]){
		if(visited[u.first]) continue;
		dfs(u.first);
	}
}

int main(){
	cin >> N >> M;
	repp(i,0,M){
		int a,b;
		cin >> a >> b;
		V[a].PB(MP(b,i));
		E.PB(MP(a,b));
	}
	repp(i,1,N+1){
		fill(visited,visited+MC,0);
		visited[i] = 1;
		repp(j,0,V[i].size()){
			if(visited[V[i][j].first]) ans[V[i][j].second] = 1;
			else dfs(V[i][j].first);
		}
		fill(visited,visited+MC,0);
		visited[i] = 1;
		repm(j,V[i].size()-1,-1){
			if(visited[V[i][j].first]) ans[V[i][j].second] = 1;
			else dfs(V[i][j].first);
		}
	}
	repp(i,1,N+1){
		fill(visited,visited+MC,0);
		dfs(i);
		repp(j,0,M) if(E[j].second == i && visited[E[j].first]) ans[j] ^= 1;
	}
	repp(i,0,M) cout << (ans[i] ? "diff" : "same") << endl;
	return 0;
}


Measured memory_bytes: 6000
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  while(1){
    int H,W;
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



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

typedef long long ll;

ll A,B,C;
ll X,Y;

int main()
{
    scanf("%lld%lld%lld",&A,&B,&C);
    scanf("%lld%lld",&X,&Y);

    ll ans = 1001001001001001;
    for(int i = 0; i <= 200000; i += 2)
    {
        ll res = C * i;
        res += max(0LL,X - i / 2) * A;
        res += max(0LL,Y - i / 2) * B;
        ans = min(res,ans);
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

long long int ans;
int main(){
    int K;
    cin >> K;
    
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            for(int k=1; k<=K; k++){
                ans += __gcd(i, __gcd(k,j));
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF  numeric_limits<int_fast64_t>::max();
#define intf int_fast64_t
int main(){
   intf n,k;
   cin >>n >>k;

   cout << min(n%k,k-(n%k)) <<endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y



def solve(L):
    L = [tuple(ord(c)-ord('a') for c in reversed(s)) for s in L]
    trie = ([None]*26, [])

    for s in L:
        node = trie
        for c in s[:-1]:
            leaf,_ = node
            if leaf[c] is None:
                leaf[c] = ([None]*26, [])
            node = leaf[c]
        node[1].append(s[-1])
    
    cnt = 0
    for s in L:

        app = [0]*26
        for c in s:
            app[c] += 1

        node = trie
        for c in s:
            if node is None:
                break
            leaf,tail = node
            for d in tail:
                if app[d] > 0:
                    cnt += 1
            app[c] -= 1
            node = leaf[c]
    return cnt - len(L)




if __name__ == '__main__':
    N = int(readline())
    L = [s.decode().rstrip() for s in read().split()]
    print(solve(L))

Measured memory_bytes: 510332
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  char a, b;
  cin >> a >> b;
  if (a=='H' and b=='H') cout << 'H' << endl;
  else if (a=='H' and b=='D') cout << 'D' << endl;
  else if (a=='D' and b=='H') cout << 'D' << endl;
  else cout << 'H' << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let (ans, _, _) = A[1..].iter().fold((1, A[0], 0), |(res, prev, sign), &a| {
        let d = a - prev;
        if d == 0 { (res, a, sign) }
        else if d > 0 && sign >= 0 || d <= 0 && sign <= 0 { (res, a, d) }
        else { (res + 1, a, 0) }
    });

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100100;
int  n , deg[N] , cnt[16];
int ans , dp[1<<16] , msk;
int ok[1<<16];

int main(){

scanf("%d",&n);
for(int i=1;i<n;i++){
    int u,v,c;
    scanf("%d %d %d",&u,&v,&c);
    deg[u] ^= c;
    deg[v] ^= c;
}

for(int i=0;i<n;i++)cnt[deg[i]]++;
for(int i=1;i<16;i++){
    ans += (cnt[i]>>1);
    if( cnt[i]&1 )
        msk |= (1<<i);
}

for(int i=0;i<(1<<16);i++){
    int x =0;
    for(int j=0;j<16;j++)
        if( i&(1<<j) )
         x ^= j;
    ok[i]=(x==0);
}

for(int i=0;i<(1<<16);i++){
    int j = i ;
    while( j ){
        if( ok[j] )
            dp[i] = max( dp[i] , 1+dp[i^j] );
        j=(j-1)&i;
    }
}

printf("%d\n",ans+__builtin_popcount(msk)-dp[msk]);
return 0;
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e9
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b)
        cout << 0 << endl;
    else
    {
        if (n == 1)
        {
            if (a == b)
                cout << 1 << endl;
            else
                cout << 0 << endl;
        }
        else if (n == 2)
            cout << 1 << endl;
        else
            cout << abs(a + b * (n - 1) - (b + a * (n - 1))) + 1 << endl;
    }
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H+2,(vector<char>(W+2,'0')));
  string s;
  for (int i=1;i<=H;i++){
    cin >> s;
    for (int j=1;j<=W;j++){
      if (s[j-1]=='#'){
        a[i-1][j-1]+=1;
        a[i-1][j]+=1;
        a[i-1][j+1]+=1;
        a[i][j-1]+=1;
        a[i][j]='#';
        a[i][j+1]+=1;
        a[i+1][j-1]+=1;
        a[i+1][j]+=1;
        a[i+1][j+1]+=1;
      }
    }
  }
  for (int i=1;i<=H;i++){
    for (int j=1;j<=W;j++){
      a[i][j]= a[i][j]<'.' ? '#' : a[i][j];
      cout << a[i][j];
    }
    cout << endl;
  }
}


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

int main(void){
  int A,P;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  A=atoi(p);
  p=strtok(NULL," \n");
  P=atoi(p);
  
  printf("%d",(3*A+P)/2);
  
  return 0;
}

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

typedef pair<int, int> pi;
typedef pair<int, pi> pii;


map<pi, int> ma;
vector<pi> adj[555555];
deque<int> dq;

int n, m, p, q, c, cur, dist[555555];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cin >> n >> m;
	cur = n+1;
	for(int i = 0; i < m; i++){
		cin >> p >> q >> c;
		if(ma[pi(p, c)] == 0) ma[pi(p, c)] = cur++;
		if(ma[pi(q, c)] == 0) ma[pi(q, c)] = cur++;
		adj[p].push_back(pi(1, ma[pi(p, c)]));
		adj[ma[pi(p, c)]].push_back(pi(0, p));
		adj[q].push_back(pi(1, ma[pi(q, c)]));
		adj[ma[pi(q, c)]].push_back(pi(0, q));
		adj[ma[pi(p, c)]].push_back(pi(0, ma[pi(q, c)]));
		adj[ma[pi(q, c)]].push_back(pi(0, ma[pi(p, c)]));
	}
	memset(dist, -1, sizeof(dist));
	dist[1] = 0;
	dq.push_back(1);
	while(!dq.empty()){
		int f = dq.front(); dq.pop_front();
		for(auto it:adj[f]){
			if(dist[it.second] == -1 || dist[it.second] > dist[f]+it.first){
				dist[it.second] = dist[f]+it.first;
				if(it.first) dq.push_back(it.second);
				else dq.push_front(it.second);
			}
		}
	}
	cout << dist[n];
}

Measured memory_bytes: 59136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            for (var i = 0; i < str.Length; i++)
            {
                if (i % 2 != 0)
                {
                    if (str[i] == 'R')
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    if (str[i] == 'L')
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


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

#define PB push_back
#define MP make_pair
#define fi first
#define se second

typedef long long LL;

const double EPS=1e-9;
const double PI=acos(-1.0);
const int MAXN=100005;
const LL MOD=1000000007;
const int dx[8]={-1, 0, 1, -1, 1, -1, 0, 1}, dy[8]={-1, -1, -1, 0, 0, 1, 1, 1};

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main(){
	base();
	int n, a, b, inp, ans=0;
	cin>>n>>a>>b;

	for(int i=0; i<n; i++){
		cin>>inp;
		if(inp>=a&&inp<b) continue;
		ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for _ in range(H)]
A = [[0]*W for _ in range(H)]
B = [(1,0),(0,1),(-1,0),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            A[i][j] = "#"
for i in range(H):
    for j in range(W):
        if A[i][j] != "#":
            for dx,dy in B:
                if 0 <= j+dx <= W-1 and 0 <= i+dy <= H-1:
                    if A[i+dy][j+dx] == "#":
                        A[i][j] += 1
for i in A:
    print(*i, sep = "")

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
 
typedef long long T;
 
struct point { 
    T x,y;
    int i; 
    point operator - (const point &rhs) const {
        return {x-rhs.x, y-rhs.y};
    }
    T operator * (const point &rhs) const {
        return x*rhs.x + y*rhs.y;
    }
    T operator % (const point &rhs) const {
        return x*rhs.y - y*rhs.x;
    }
    T len2() const {
        return x*x + y*y;
    }
};
 
int compare(T x, T y) {
    if(y - x > 0) return -1;
    if(x - y > 0) return 1;   
    return 0;
}
 
T cross(point p, point q, point r) { return (r-q)%(p-q); }
 
int turn(point p, point q, point r) { return compare(cross(p,q,r), 0); }
 
int cw(point p, point q, point r) { return turn(p,q,r) < 0; }
 
double angle(point a, point o, point b) // angle AOB (in radians)
{
    point u = a - o; // u: vector oa
    point v = b - o; // v: vector ob
    return acos(u * v / sqrt(1.0 * u.len2() * v.len2())); 
}

bool cmp(const point &p, const point &q)
{
    return p.x < q.x || (p.x == q.x && p.y < q.y);
}
 
vector<point> convex_hull(vector<point> &p)
{
    int n = (int)p.size(), k = 0;
    vector<point> h(2 * n);
    sort(p.begin(), p.end(), cmp);
    for(int i = 0; i < n; i++) 
    {
        while(k >= 2 && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    for(int i = n - 2, t = k + 1; i >= 0; i--) 
    {
        while(k >= t && cw(h[k-2], h[k-1], p[i])) k--;
        h[k++] = p[i];
    }
    h.resize(k); h.pop_back(); 
    return h;
}
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(10);
    int n,m;
    vector<point> p,h;
    double ans[105];
    while(cin >> n)
    {
        p = vector<point>(n);
        for(int i = 0; i < n; i++)
        {
            cin >> p[i].x >> p[i].y;
            p[i].i = i;
        }
        h = convex_hull(p);
        for(int i = 0; i < n; i++)
            ans[i] = 0;
        m = h.size();
        for(int i = 0; i < m; i++)
            ans[h[i].i] = (M_PI - angle(h[(i-1+m)%m], h[i], h[(i+1)%m])) / (2*M_PI);
        for(int i = 0; i < n; i++)
            cout << ans[i] << '\n';
    }
    return 0;
} 

Measured memory_bytes: 384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();

    BigDecimal l = new BigDecimal(r);
    BigDecimal ret = l.multiply(new BigDecimal(2))
        .multiply(new BigDecimal("3.141592"));

    System.out.println(ret.toString());
  }
}


Measured memory_bytes: 36164
#include <cstdio>
#include <vector>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        int e = 0, o = 0;
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
                (i & 1 ? o : e) += a[i];
        }
        if (n & 1) {
                int lb = 0, ub = 100000000;
                while (ub - lb > 1) {
                        int mid = (lb + ub) / 2;
                        vector<int> b = a;
                        for (int i = 0; i < n - 1; i += 2) {
                                if (b[i] < mid || b[i + 1] < b[i]) {
                                        b[i + 2] += b[i] - b[i + 1];
                                }
                        }
                        (b[n - 1] >= mid ? lb : ub) = mid;
                }
                printf("%d %d\n", lb + o, e - lb);
        } else {
                printf("%d %d\n", max(e, o), min(e, o));
        }
        return 0;
}



Measured memory_bytes: 2572
#include<stdio.h>
#include<string.h>
int main()
{
    int len1,len2,len,i,x,y;
    char a[51],b[51];
    while(scanf("%s",a)!=EOF)
    {
        x=0;y=0;
        getchar();
        scanf("%s",b);
        getchar();
        len1=strlen(a);
        len2=strlen(b);
        len=len1+len2;
        for(i=0;i<len;i++)
        {
            if(i%2==0)
                printf("%c",a[x++]);
            else
                printf("%c",b[y++]);
        }
        printf("\n");
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
    }
    return 0;
}


Measured memory_bytes: 128
# ARC064C - Boxes and Candies (ABC048C)
def main():
    n, x = list(map(int, input().split()))
    A = list(map(int, input().split()))
    ans = A[0] - x if A[0] > x else 0
    A[0] = min(A[0], x)
    for i in range(n - 1):
        dif = A[i] + A[i + 1] - x
        if dif > 0:
            A[i + 1] -= dif
            ans += dif
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14068
w=input()
w1=input()
num=len(w)
num1=len(w1)
start=-1
if num<num1:
  b1=False
for i in range(num-num1+1):
  b=True
  for j in range(num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
if start==-1:
  print("UNRESTORABLE")
else:
  word=""
  for i in range(num):
    if i<start:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    elif start<=i and i<=start+num1-1:
      word+=w1[i-start]
    else:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
  print(word)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>

int main(int argc, char *argv[]){
    double a,b,x;
    std::cin >> a >> b >> x;
    double V = a*a*b;
    double theta;
    const double pi = std::acos(-1.0);
    if(x<=V/2.0){
        theta = std::atan((b*b*a)/(2.0*x));
    }else{
        theta = std::atan(2.0*(V-x)/(a*a*a));
    }
    std::cout << std::setprecision(12) << theta*180.0/pi << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if w >= v:
    print('NO')
    sys.exit()

min_a = -1 * v * t + a
max_a = v * t + a
min_b = -1 * w * t + b
max_b = w * t + b

if min_a <= min_b and max_b <= max_a:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9200
def func(a):
    if(0 == a % 4):
        return(a)
    if(1 == a % 4):
        return(1)
    if(2 == a % 4):
        return(a + 1)
    if(3 == a % 4):
        return(0)

A, B = list(map(int, input().split()))

print(func(A - 1) ^ func(B))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
ll mod = 1000000007;

int main()
{
	// 入力
	ll A, B;
	cin >> A >> B;
	ll ans = 0;

	if (A % 2 == 1 && B % 2 == 0) {
		ans = A ^ B;
		if (B - A - 1 > 0 && ((B - 1 - A) / 2) % 2 == 1) ans ^= 1;
	}
	else if (A % 2 == 1) {
		ans = A;
		if (B - A  > 0 && ((B  - A) / 2) % 2 == 1) ans ^= 1;
	}
	else if (B % 2 == 0) {
		ans = B;
		if (B - A  > 0 && ((B  - A) / 2) % 2 == 1) ans ^= 1;
	}
	else {
		if (B - A + 1 > 0 && ((B  - A + 1) / 2) % 2 == 1) ans ^= 1;

	}
	// else ans = 0;


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 2500

signed main() {
    int n, m, s;
    cin >> n >> m >> s;
    using T = tuple <ll, ll, ll>;
    vector<T> G[n];
    int u, v, a, b;
    rep(i, m) {
        cin >> u >> v >> a >> b;
        u--;
        v--;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }
    ll c[n], d[n];
    rep(i, n) {
        cin >> c[i] >> d[i];
    }
    ll dist[n][MAX + 1];
    fill(dist[0], dist[n], LINF);
    priority_queue<T, vector<T>, greater<T>> que;
    for (int j = 0;; j++) {
        int nxt = min(s + c[0] * j, (ll)MAX);
        dist[0][nxt] = d[0] * j;
        que.emplace(dist[0][nxt], nxt, 0);
        if (s + c[0] * j > MAX) break;
    }
    while (!que.empty()) {
        T t = que.top();
        que.pop();
        int cnt = get<1>(t), v = get<2>(t);
        if (dist[v][cnt] < get<0>(t)) continue;
        for (int i = 0; i < G[v].size(); i++) {
            int to = get<0>(G[v][i]), need = get<1>(G[v][i]);
            ll cost = get<2>(G[v][i]);
            for (int j = 0;; j++) {
                if (cnt - need < 0) break;
                int nxt = min(cnt - need + c[to] * j, (ll)MAX);
                if (dist[to][nxt] > dist[v][cnt] + cost + d[to] * j) {
                    dist[to][nxt] = dist[v][cnt] + cost + d[to] * j;
                    que.emplace(dist[to][nxt], nxt, to);
                }
                if (cnt - need + c[to] * j > MAX) break;
            }
        }
    }
    for (int v = 1; v < n; v++){
        ll ans = LINF;
        for (int j = 0; j <= MAX; j++) {
            ans = min(ans, dist[v][j]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 101712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin>>n;
    vi p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    vi idx(n);
    rep(i,n){
        idx[p[i]]=i;
    }
    set<int> s;
    ll ans=0;
    drep(x,n){
        int i=idx[x];
        ll c=0;
        s.insert(i);
        vi l(2,-1),r(2,n);
        vi ls(2),rs(2);
        {
            auto it=s.find(i);
            rep(j,2){
                if(it==s.begin()) break;
                it--;
                l[j]=*it;
            }
        }
        {
            auto it=s.find(i);
            rep(j,2){
                it++;
                if(it==s.end()) break;
                r[j]=*it;
            }
        }
        ls[0]=i-l[0];ls[1]=l[0]-l[1];
        rs[0]=r[0]-i;rs[1]=r[1]-r[0];
        c=(ll)ls[0]*rs[1]+(ll)ls[1]*rs[0];
        ans+=c*(x+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
def abc109_b():
    n = int(input())
    words = [input() for _ in range(n)]
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            return "No"
    if len(set(words)) != len(words):
        return "No"
    return "Yes"


print(abc109_b())

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

using namespace std;

int main(){
  long N,K;
  long a;
  cin >> N >> K;
  for(long i = 0;i < N; i++){
    cin >> a;
  }
  if((N-1)%(K-1) == 0) cout << long((N-1) / (K-1)) << endl;
  else cout  << long((N-1)/ (K - 1)) + 1 << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    int c;
    foreach (i; 0..N-2) {
        if (S[i..i+3] == "ABC") ++c;
    }
    writeln(c);
}

Measured memory_bytes: 256