akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n) INC(i, 0, n)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int main(){
    string n;
    cin >> n;
    uint len = n.length();

    int ans1 = n.at(0) - '0' - 1;
    ans1 += (len - 1) * 9;
    int ans2 = 0;
    REP(i, len){
        ans2 += n.at(i) - '0';
    }
    cout << max(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	string s; cin >> s;
	rep(i,s.size()) s[i] = 'x';
	cout << s << endl;
}




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

int main() {
  int count;
  string s,t;
  cin >> s >> t;
  rep(i,3){
    if(s[i]==t[i]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int cnt = 0;

void cal(int n){
    int m = n % 10, l = n % 100 - m;
    if(n / 1000 == ((m * 10) + l / 10)) cnt++;
}

int main(){
    int a, b;

    cin >> a >> b;

    int n = a;

    while(n <= b){
        cal(n);
        n++;
    }

    cout << cnt << endl;
}

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

int main(){

	int j, n, cnt, prime[10001];

	fill(prime, prime+10001, 1);
	prime[0] = 0;
	prime[1] = 0;
	for(int i=0; i<10001; i++){
		if(prime[i] == 1){
			for(int j=2; i * j<10001; j++){
				prime[i * j] = 0;
			}
		}
	}
	while(cin >> n){
		cnt = 0;
		for(int i=1; i<=n; i++){
			j = n - i + 1;
			if(prime[i] == 1 && prime[j] == 1){
				cnt++;
			}
		}
		
		cout << cnt << endl;
	}
	
	return 0;

}

Measured memory_bytes: 1196
"""bit全探索"""

ticket = tuple(map(int, input()))
res = []

for i in range(8, 16):
    s = ticket[0]
    equation = str(s)
    for j in range(1, 4):
        if int(bin(i)[-j]):
            s += ticket[j]
            equation += "+" + str(ticket[j])
        else:
            s -= ticket[j]
            equation += "-" + str(ticket[j])

    if s == 7:
        equation += "=7"
        res.append(equation)

print(res[0])


Measured memory_bytes: 38256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

int N, X;
int MIN = 10000;

/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  cin >> N >> X;
  REP(i, N) {
    int m;
    cin >> m;
    MIN = min(MIN, m);
    X -= m;
  }

  cout << N + X / MIN << endl;
  return 0;
}

Measured memory_bytes: 256
###############################################################################

from bisect import bisect_left as binl
from copy import copy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def safe_ref(listlist, x, y):
    if x < 0 or y < 0 or x >= len(listlist) or y >= len(listlist[0]):
        return None
    try:
        return listlist[x][y]
    except:
        return None

def main():
    h, w = intin()
    alistlist = []
    for i in range(h):
        alistlist.append([s for s in input()])

    count = 0
    check_list = []

    for i, alist in enumerate(alistlist):
        for j, a in enumerate(alist):
            if a == '#':
                count += 1
                check_list.append((i, j))

    for repeated in range(h * w * 3):
        if count == h * w:
            print(repeated)
            return

        new_alistlist = copy(alistlist)
        next_list = []

        for i, j in check_list:
            if safe_ref(alistlist, i+1, j) == '.':
                new_alistlist[i+1][j] = '#'
                next_list.append((i+1, j))
                count += 1
            if safe_ref(alistlist, i-1, j) == '.':
                new_alistlist[i-1][j] = '#'
                next_list.append((i-1, j))
                count += 1
            if safe_ref(alistlist, i, j+1) == '.':
                new_alistlist[i][j+1] = '#'
                next_list.append((i, j+1))
                count += 1
            if safe_ref(alistlist, i, j-1) == '.':
                new_alistlist[i][j-1] = '#'
                next_list.append((i, j-1))
                count += 1

        check_list = next_list
        alistlist = new_alistlist


if __name__ == '__main__':
    main()


Measured memory_bytes: 131468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n;
  cin >> n;
  vector<bitset<32>> a(n);
  for (int i=0; i<n; i++){
    ll t; cin>>t;
    a[i] = bitset<32>(t);
  }
  bitset<32> x = 0;
  rep(i, n) {
    x ^= a[i];
  }
  rep(i, n) {
    a[i] ^= x;
  }
  rep(i, n) {
    if (i>0) cout << " ";
    cout << a[i].to_ullong();
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
ll n,m,l,a,b,c,x,y; 
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin>>n>>a;
  if(n%500<=a){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}  

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  for (int i = 0; i < s.size(); i ++) {
    char t = s[i] + n;
    if (t > 'Z') t -= 26;
    s[i] = t;
  }

  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l!=NIL) calcDepth(T[u].l, p+1);
  if(T[u].r!=NIL) calcDepth(T[u].r, p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);

  return 0;
}




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

namespace VS_atcoder
{

    class Program
    {
        static void Main(string[] args)
        {

            long N = int.Parse(Console.ReadLine());
            long A = int.Parse(Console.ReadLine());

            if (N % 500 > A)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

            return;

        }


    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23380
A, B, K = map(int, input().split())
ans = []

for i in range(K):
    if A + i <= B:
        ans.append(A + i)
for i in range(K):
    if B - K + i + 1 not in ans and A <= B - K + i + 1:
        ans.append(B - K + i + 1)
ans.sort()
for a in ans:
    print(a)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for(int i = 0; i < N; i++) {
    B.at(A.at(i) - 1) = i + 1;
  }
  for(int i = 0; i < N; i++) {
    if(i != N - 1) {
      cout << B.at(i) << " ";
    }
    else cout << B.at(i) << endl;
  }
}

Measured memory_bytes: 1664
h, w = readline.split.map(&:to_i)
s = h.times.flat_map do
    readline.chomp.chars
end
res = s.reduce(Hash.new(0)){|a, x| a[x] += 1; a}.values.sort.reverse

u4 = (h / 2) * (w / 2)
u2 = if h % 2 == 1 then w / 2 else 0 end + if w % 2 == 1 then h / 2 else 0 end
u1 = if h % 2 == 1 && w % 2 == 1 then 1 else 0 end

raise "No matched" unless u4 * 4 + u2 * 2 + u1 == h * w

if res.map{|i| i / 4}.reduce(:+) < u4
    puts "No"
    exit
end

res.map!{|i|
    a = i / 4
    d = [a, u4].min
    u4 -= d
    i - 4 * d
}

if res.map{|i| i / 2}.reduce(:+) < u2
    puts "No"
    exit
end

puts "Yes"
    

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)

using namespace std;

vector<string> split(const string &str, char delim)
{
  istringstream iss(str); string tmp; vector<string> res;
  while(getline(iss, tmp, delim)) res.push_back(tmp);
  return res;
}


int main()
{
  vector<int> v;
  string s;
  while(cin >> s)
  {
    auto u = split(s,',');
    for(auto a : u) v.push_back(atoi(a.c_str()));
  }
  int n = sqrt(v.size());
  vector<vector<int> > T(n,vector<int>(n,0));
  int c = 0;
  REP(i,2*n-1) REP(j,((i<n)?i+1:2*n-1-i))
  {
    if(i<n) T[i-j][j] = v[c++];
    else T[n-j-1][i-n+1+j] = v[c++];
  }
  FOR(i,1,n-1) { T[0][i] += T[0][i-1]; T[i][0] += T[i-1][0];}
  FOR(i,1,n-1) FOR(j,1,n-1) T[i][j] += max(T[i-1][j],T[i][j-1]);
  cout << T[n-1][n-1] << endl;
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 1e5 + 5;

ll a[kN], d[kN], c, M;

int main() {
	int n; rd(n); c = (ll)n * (n + 1) / 2;
	for(int i = 1; i <= n; ++i) rd(a[i]), M += a[i];
	if(M % c != 0) { printf("NO"); return 0; }
	M /= c;
	for(int i = 1; i <= n; ++i) d[i] = a[i % n + 1] - a[i];
	for(int i = 1; i <= n; ++i)
		if(d[i] > M || (M - d[i]) % n != 0) {
			printf("NO"); return 0;
		}
	printf("YES");
	return 0;
}

Measured memory_bytes: 1792
/**************************
 *   Saidur Rahman Sajol  *
 * Dept. of CSE,IUBAT(162)*
 **************************/
#include <bits/stdc++.h>
using namespace std;

#define PI 2*acos(0.0)
#define l long
#define ll long long 
#define ul unsigned long
#define ull unsigned long long

ull minimum(ull a,ull b){
  return (a<b)?a:b;
}
ull maximum(ull a,ull b){
  return (a>b)?a:b;
}
ull great(ull a,ull b){
	if(b==0) return a;
  return great(b,a%b);
}
vector<int>stl;
vector<int>stl1;
set<string>pb;
map<char,int>mp;
vector<pair<int,int> >freak;
vector<pair<int,int> >freak1;

int main(){
	double n,m;
	cin>>n>>m;
	double k=m*2;
	double h=k-n;
	cout<<h<<endl;
	return 0;
}


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

#define weight first
#define val second

const int XD = 1e5 + 2;
pair <int,int> item[ 101 ], dp[ XD ][ 101 ];

pair <int,int> maxp( pair <int,int> x, pair <int,int> y )
{
    if( x.val == y.val ) return ( x.weight < y.weight )? x:y;
    return ( x.val > y.val )? x:y;
}
int main()
{
    ios_base::sync_with_stdio( false );
    int n, w; cin >> n >> w;
    int sum = 0;
    for( int i = 1; i <= n; i++ )
    {
        cin >> item[ i ].weight >> item[ i ].val;
        sum += item[ i ].val;
    }
    int wynik = 0;
    for( int i = 1; i <= sum; i++ )
    {
        for( int j = 1; j <= n; j++ )
        {
            if( item[ j ].val > i )
            {
                dp[ i ][ j ].weight = dp[ i ][ j - 1 ].weight;
                dp[ i ][ j ].val = dp[ i ][ j - 1 ].val;
            }
            else if( dp[ i - item[ j ].val ][ j - 1 ].weight + item[ j ].weight > w )
            {
                dp[ i ][ j ].weight = dp[ i ][ j - 1 ].weight;
                dp[ i ][ j ].val = dp[ i ][ j - 1 ].val;
            }
            else dp[i][j]=maxp(dp[i][j-1],{dp[i-item[j].val][j-1].weight+item[j].weight,dp[i-item[j].val][j-1].val+item[j].val});
            wynik = max( wynik, dp[ i ][ j ].val );
          }
    }
    cout << wynik;
    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string X;
    cin >> X;
    ll N = X.length();
    
    stack<char> S;
    
    for (int i = 0; i < N; i++) {
        if(S.empty()){
            S.push(X[i]);
        }    
        else if(S.top() == 'S' && X[i] == 'T'){
            S.pop();
        }
        else{
            S.push(X[i]);
        }
    }
    int ans = S.size();
    printf("%d\n", ans);

}

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

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


Measured memory_bytes: 3624
//author Eterna
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))
#define pb(x) push_back(x)
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\in.txt", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\out.txt", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%I64d\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 20;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
inline int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
inline ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
int arr[maxn + 5], n, res = 1, now;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)cin >> arr[i];
	now = arr[1];
	for (int i = 2; i <= n; ++i) {
		if (arr[i] >= now) {
			now = arr[i];
			++res;
		}
	}
	cout << res << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int nax=1e7+5;
int lpd[nax];
void solve(){
	int n;
	cin>>n;
	for(int i=0;i<nax;i++){
		lpd[i]=i;
	}
	for(int i=2;i<nax;i++){
		if(lpd[i] != i) continue;
		for(int j=2*i;j<nax;j+=i){
			if(lpd[j]==j) lpd[j]=i;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		int g=1;
		int x=i;
		while(x > 1){
			int p=lpd[x];
			int l=0;
			while(x%p==0){
				l++;
				x/=p;
			}
			g*=(l+1);
		}
		ans+=(ll)i*g;
	}
	cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tt;
    tt=1;
    while(tt--)
        solve();
    return 0;
}


Measured memory_bytes: 42708
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    K = get_ln_int_inputs()[0]

    N = 50
    n = K // N
    initNum = N + n - 1
    remK = K % N

    l = []

    fn = initNum + 1 + (N - remK)
    for _ in range(remK):
        l.append(fn)

    ln = initNum - remK
    for _ in range(remK, N):
        l.append(ln)

    print(N)
    print(" ".join(map(str, l)))


main()

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {
    private static int n;
    private static int[] A = new int[20];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        n = sc.nextInt();
        for(int i=0; i<n; i++) A[i] = sc.nextInt();
        int q = sc.nextInt();
        for(int i=0; i<q; i++) {
            int M = sc.nextInt();
            if(solve(0,M)) System.out.println("yes");
            else System.out.println("no");
        }
    }

    static boolean solve(int i, int m){
        if(m == 0) return true;
        if(i >= n) return false;
        // solve(i+1, m)はその要素を使わない
        // solve(i+1, m - A[i])はその要素を使う
        boolean res = solve(i + 1,m) || solve(i + 1, m - A[i]);
        return res;
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 24772
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

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

bool ok(vector<vector<int> > p){
	rep(i,2)rep(j,4) if(p[i][j] != i * 4 + j) return false;
	return true;
}

void swap(int &u, int &v){
	int t = u;
	u = v;
	v = t;
}

int memo[8][8][8][8][8][8][8][8];

int& get_num(const vector<vector<int> > &vvi){
	return memo[vvi[0][0]][vvi[0][1]][vvi[0][2]][vvi[0][3]][vvi[1][0]][vvi[1][1]][vvi[1][2]][vvi[1][3]];
}

int main(){
	clock_t c1, c2;
	vector<vector<int > > s(2, vector<int>(4));
	rep(i, 2)rep(j, 4) s[i][j] = i * 4 + j;
	memset(memo, -1, sizeof(memo));
	c1 = clock();
	get_num(s) = 0;
	queue<vector<vector<int> > > que;
	que.push(s);
	while(!que.empty()){
		vector<vector<int> > p = que.front();
		que.pop();
		int num = get_num(p);
	//	cout << num << endl;
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 4; j++){
				if(p[i][j] == 0){
					for(int k = 0; k < 4; k++){
						int i2 = i + dy[k];
						int j2 = j + dx[k];
						if(0 <= i2 && i2 < 2 && 0 <= j2 && j2 < 4){
							swap(p[i][j], p[i2][j2]);
						//	cout << get_num(p) << endl;
							if(get_num(p) == -1){
								get_num(p) = num + 1;
						//		cout << get_num(p) << endl;
								que.push(p);
							}
							swap(p[i][j], p[i2][j2]);
						}
					}
				}
			}
		}
	}
	c2 = clock();
	//cout << (double)(c2 - c1) / CLK << endl;
	while(cin >> s[0][0] >> s[0][1] >> s[0][2] >> s[0][3]
	>> s[1][0] >> s[1][1] >> s[1][2] >> s[1][3]){
		cout << get_num(s) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();
    
    let mut ans = 0.0;
    for i in 1..n+1 {
        let mut sum = 1.0 / n as f64;
        let mut now = 1.0;
        while now * i as f64 <= (k-1) as f64 {
            now *= 2.0;
        }
        ans += sum / now;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import sys
import bisect
input = sys.stdin.readline

S = list(input().strip())
N = len(S) - 1

ans = 0
for i in range(1 << N):
    t = []
    
    for j in range(N):
        if (i >> j) & 1:
            t.append(j)

    if len(t) == 0:
        ans += int("".join(map(str, S)))
    else:
        a = S[0]
        for i in range(N):
            if i in t:
                a += "+{}".format(S[i + 1])
            else:
                a += str(S[i + 1])
                
        ans += eval(a)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int a[4];
    char op[3];
    for (int i = 0; i < 4; i++)
        a[i] = getchar() - '0';
    for (int i = 0; i < 8; i++) {
        int res = a[0];
        if (i & 4) res -= a[1];
        else res += a[1];
        if (i & 2) res -= a[2];
        else res += a[2];
        if (i & 1) res -= a[3];
        else res += a[3];
        if (res == 7) {
            op[0] = i & 4? '-': '+';
            op[1] = i & 2? '-': '+';
            op[2] = i & 1? '-': '+';
            printf("%d%c%d%c%d%c%d=7\n", a[0], op[0], a[1], op[1], a[2], op[2], a[3]);
            return 0;
        }
    }
}


Measured memory_bytes: 128
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
using static System.Console;

namespace testConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            ReadLine();
            var n = Array.ConvertAll(ReadLine().Split(), int.Parse);

            var longest = 0;
            var sum = 0;

            foreach(var i in n)
            {
                sum += i;
                if (longest < i) longest = i;
            }

            sum -= longest;
            if (sum > longest) WriteLine("Yes");
            else WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll Count_even(ll x){
    ll tmp = 0;
    while(x%2==0){
        tmp++;
        x/=2;
    }
    return tmp;
}


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

    int n;
    cin >> n;
    vl a(n);
    ll even = 0;
    rep(i,n){
        cin >> a[i];
        even += Count_even(a[i]);
    }
    cout << even << endl;
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	string s;
	cin >> s;
	for(char i = 'a'; i <= 'z'; i++) {
		if(s.find(i) == string::npos) {
			cout << s << i << '\n';
			return 0;
		}
	}
	int n = (int) s.size();
	for(int i = n - 2; i >= 0; i--) {
		if(s[i] < s[i + 1]) {
			char last = 'z';
			for(int j = i + 1; j < n; j++) {
				if(s[j] > s[i]) {
					last = min(last , s[j]);
				}
			}
			s[i] = last;
			cout << s.substr(0, i + 1) << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long sum = 0;
		int cnt = 0;
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int ai = a[i];
			if (ai < 0) {
				cnt++;
			}
			ai = Math.abs(ai);
			min = Math.min(min, ai);
			sum += ai;
		}
		if (cnt % 2 == 0) {
			System.out.println(sum);
		} else {
			System.out.println(sum - min * 2);
		}
	}
}


Measured memory_bytes: 49892
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

map<int,int> prm;

signed main(){
    FASTER;
    int n,k;cin>>n>>k;
    vi v(n);cin>>v;
    
    for(int i=0;i+k<n;i++){
        if(v[i]<v[i+k])cout<<"Yes\n";
        else cout<<"No\n";
    }
    
    
}

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

using ll = long long;

int main() {

    int n, q;

    cin >> n >> q;

    vector<ll> v(n);

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


    for(int i = 0; i < q; ++i) {
        
        ll num;

        cin >> num;

        int right;
        right = 0;

        ll sum = 0;
        ll result = 0;

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

            while(right < n && sum + v[right] <= num) {
                sum += v[right];
                ++right;
            }


            result += right - left;

            if(left == right)
                ++right;
            else 
                sum -= v[left];


        }

        cout << result << endl;


    }

    return 0;


}


Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class BDigitalGifts {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    double res = 0;
	    string u;
	    double x;
	    for(int i=0; i<n; i++){
            in >> x >> u;
            if(u == "JPY"){
                res += x;
            }else{
                res += x * 380000.0;
            }
	    }

	    out << fixed << setprecision(5) << res << endl;
	}
};


int main() {
	BDigitalGifts solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        Program p = new Program();
        var input = p.ConvertIntArray(p.ReadInput());
        var N = input[0];
        var K = input[1];
        var menber = p.ConvertIntArray(p.ReadInput());
        var count = 0;
        for(var i = 0; i<N; i++)
        {
            if(menber[i] >= K)
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 17760
n = int(input())
lis = []

for i in range(n):
	a = int(input())
	lis.append(a)
kou = sorted(lis, reverse=True)

for i in range(n):
	if lis[i] < kou[0]:
		print(kou[0])
	else:
		print(kou[1])

Measured memory_bytes: 14112
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H, W = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(H)]
A = np.array([list(input()) for _ in range(H)], 'U1')
eq = A == '.'

dp = np.zeros(W+1, dtype=int)
dp[1] = 1

for i in range(1,H+1):
    prev = dp.copy()
    for j in range(1,W+1):
        if eq[i-1][j-1]:
            dp[j] = prev[j] + dp[j-1]
        else:
            dp[j] = 0
    dp %= mod

print(dp[-1])

Measured memory_bytes: 25168
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b ;
    if(n*a < b){
        cout << n*a << endl;
    }else
    {
        cout << b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
s=input()
if s=='<':
  print(1)
  sys.exit()
if s[0]=='<':
  s=s[1:]
if s[-1]=='>':
  s=s[:-1]
s=list(s.split('><'))

ans=0
for i in s:
  a=[i.count('<'),i.count('>')]
  a_max=max(a)
  a_min=min(a)
  ans+=(a_max+1)*(a_max+2)//2
  ans+=a_min*(a_min+1)//2
print(ans)

Measured memory_bytes: 9756
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int a,b,c;
	vector<int> d;
	while(1){
		d.clear();
		c = 0;
		cin >> a;
		if(a == 0)break;
		for(int i = 0;i < a;i++){
			cin >> b;
			d.push_back(b);
		}
		sort(d.begin(),d.end());
		for(int i = 1;i < d.size()-1;i++){
			c+=d[i];
		}
		cout << c/(d.size() - 2) <<endl;
	}	
	return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c;
    string s,s1;
    cin >> s >> s1;
    if(s[0] > s1[0])
        cout << ">" << endl;
    else if (s[0] < s1[0]) cout << "<" << endl;
    else  cout << "=" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
        
        
int main() {
        int n;
        cin >> n;
        vector<int> d(n);
        rep(i,n) cin >> d.at(i);
        int ans = 0;
        rep(i,n)for(int j=i+1;j<n;j++){
                ans += d.at(i)*d.at(j);
        }
        
        cout << ans << endl;
        
        return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a.at(i);
    int count = 0;
    rep(i, 0, N){
        while(a.at(i) % 2 == 0){
            a.at(i) /= 2;
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int i,j,k,r,c,b;
  cin >> r >> c;
  int Ur[100]={};
  int Uc[100]={};
  int U=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    Ur[i]+=b;
    Uc[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      Ur[i]+=b;
      Uc[j]+=b; 
    }
    cout << " " <<Ur[i] << endl;
    U+=Ur[i];
  }
  cout << Uc[0];
  for(j=1;j<c;j++){
    cout << " " << Uc[j];    
  }
  cout << " " << U <<  endl;
}


Measured memory_bytes: 3088
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        final int R = Integer.parseInt(sc.next());
        final int S = Integer.parseInt(sc.next());
        final int P = Integer.parseInt(sc.next());
        final char T[] = sc.next().toCharArray();
        sc.close();

        List<Character> C = new ArrayList<>();
        for (char t : T) {
            if (t=='r') {
                C.add('p');
            } else if (t=='s') {
                C.add('r');
            } else {
                C.add('s');
            }
        }
        for (int i=0; i<N-K; i++) {
            if (C.get(i)==C.get(i+K)) {
                C.set(i+K,'x');
            }
        }
        long sum = 0;
        for (char c : C) {
            if (c=='p') {
                sum += P;
            } else if (c=='r') {
                sum += R;
            } else if (c=='s') {
                sum += S;
            }
        }
        
        System.out.println(sum);
    }
}

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

#define ll long long int



// 問題点全部プラスでK回取り出せばいいときうまく行かない(K-1回しか取り出してくれない)
int main(){
	int N,K;
	cin>>N>>K;
	vector<ll> vec(N);
	priority_queue<ll,vector<ll>,greater<ll>> pque;
	ll ans=0;

	for(int i=0;i<N;i++)
		cin>>vec.at(i);

	for(int A=0;A<min(N,K)+1;A++){
		for(int B=0;B<min(N,K)-A+1;B++){ //min(N,K)-A+1に変更。+1してみた。エラー減ったけど...

		
			for(int i=0;i<A;i++)
				pque.push(vec.at(i));
			for(int i=0;i<B;i++) 
				pque.push(vec.at(N-i-1));

			for(int i=0;i<K-A-B;i++){
				if(!pque.empty() && pque.top()<0)
					pque.pop();
				else
					break;
			}
			ll wa = 0;

			while(!pque.empty()){
				wa += pque.top();
				pque.pop();
			}
			ans = max(ans,wa);
			
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.length() <= k)cout << s;
  else {for(int i=0; i<k; i++){
    cout << s[i];
  }
  cout << "...";
  }
  

return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b;
  cin >> a >> b;
  --a;
  --b;
  cout << b / a + ((b%a) ? 1 : 0) << "\n";
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

vll num, nump;

ll rec(ll N, ll X) {

  if (N == 0) {
    return X <= 0 ? 0 : 1;
  } else if (X <= 1 + num[N - 1]) {
    return rec(N - 1, X - 1);
  } else {
    return nump[N - 1] + 1 + rec(N - 1, X - 2 - num[N - 1]);
  }

}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  ll N, X;
  cin >> N >> X;

  num.push_back(1);
  nump.push_back(1);
  for (int i = 1; i <= 50; i++) {
    num.push_back(num[i - 1] * 2LL + 3LL);
    nump.push_back(nump[i - 1] * 2LL + 1LL);
  }
  
  // cout << num[N] << endl;
  // cout << nump[N] << endl;

  cout << rec(N, X) << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
*P, = map(int, input().split())
cum = [0] * (N + 1)
for i in range(N):
    cum[i+1] = cum[i] + (P[i] * (P[i] + 1) / 2) / P[i]
ans = 0
for i in range(N-K+1):
    ans = max(ans, cum[i+K] - cum[i])
print(ans)

Measured memory_bytes: 24556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 1000000007;
struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }
	int root(int x) {
		if (par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	bool issame(int x, int y) { return root(x) == root(y); }
	bool merge(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) { return -par[root(x)]; }
};
int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	int p[n];
	rep(i, n) scanf("%d", p + i);
	UnionFind tree(n);
	while (q--) {
		int a, b;
		scanf("%d%d", &a, &b);
		tree.merge(a - 1, b - 1);
	}
	vector<pair<int, int>> a[n];
	rep(i, n) a[tree.root(i)].push_back({i, p[i] - 1});
	int ans = 0;
	rep(i, n) {
		if (a[i].empty()) continue;
		int N = a[i].size();
		set<int> s;
		rep(j, N) {
			s.insert(a[i][j].first);
			s.insert(a[i][j].second);
		}
		ans += N * 2 - s.size();
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  ll N, M;
  cin >> N >> M;

  cout << abs((N - 2) * (M - 2)) << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		for(int i=0; i<S.length(); i++) {
			if(i%2==0) {
				System.out.print(S.charAt(i));
			}
		}
		System.out.println();
	}

}


Measured memory_bytes: 31104
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    cnt = 0
    for i in range(len(s)):
        if s[i] != s[-i-1]:
            cnt += 1
    print(cnt // 2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int[] a = new int[n];
    ArrayList<Integer> list = new ArrayList<Integer>();
    int[] ans = new int[n];
    list.add(0);
    for(int i = 0; i < n; i++) {
      if(s.charAt(i) == 'R') {
        
      } else {
        a[i] = 1;
      }
      if((i < n - 1) && (s.charAt(i) != s.charAt(i + 1))) list.add(i + 1);
    }
    list.add(n);
    int[] b = new int[n];
    for(int i = 0; i < list.size() - 1; i++) {
      for(int j = list.get(i); j < list.get(i + 1); j++) {
        if((i % 2) == 0) {
          b[j] = list.get(i + 1);
        } else {
          b[j] = list.get(i) - 1;
        }
      }
    }
    for(int i = 0; i < n; i++) {
      if(a[i] == 0) {
        int t = b[i] - i;
        if((t % 2) == 0) {
          ans[b[i]]++;
        } else {
          ans[b[i] - 1]++;
        }
      } else {
        int t = i - b[i];
        if((t % 2) == 0) {
          ans[b[i]]++;
        } else {
          ans[b[i] + 1]++;
        }        
      }
    }
    for(int i = 0; i < n; i++) {
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 45020