akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const long long mod = 1e9+7;
const int maxn = 1e7+5;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    long long n,wt;
    cin>>n>>wt;
    vector<long long> w(n+1), v(n+1);
    vector<vector<long long>> dp(n+1,vector<long long>(wt+1));
    
    for(int i = 1; i <= n; i++) cin>>w[i]>>v[i];
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= wt; j++){
            dp[i][j] = max(dp[i-1][j],(((j-w[i]) >= 0)? dp[i-1][j-w[i]]+v[i]: 0));
        }
    }
    
    cout<<dp[n][wt]<<"\n";
    
    return 0; 
}


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

using namespace std;

int main()
{
    char s[]="Sunny",c[]="Cloudy",r[]="Rainy";
    char x[100];
    cin >> x;
    if(!strcmp(s,x)) cout << c << endl;
    else if(!strcmp(c,x)) cout << r << endl;
    else if(!strcmp(r,x)) cout << s << endl;
    return 0;
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int x, y, z;
    cin >> x >> y >> z;
    int ans = (x - z) / (y+z);
    cout << ans << endl;
}

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


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace PastQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var n = input.ReadInt;
            var a = input.ReadInt;
            var b = input.ReadInt;

            var answer = 0;
            for (var i = 1; i <= n; ++i)
            {
                var iArr = i.ToString().ToArray();
                var total = 0;
                for (var j = 0; j < iArr.Length; j++)
                {
                    total += int.Parse(iArr[j].ToString());
                }
                if (a <= total && total <= b)
                    answer += i;
            }

            Console.WriteLine(answer);
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


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

int n, ans;
vector<int> p, v;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, p);
	for(int i=0; i<n; ++i)
		p[i] = i+1==p[i]?1:0;
//	for(int i=0; i<n; ++i)
//		cout << p[i] << (i==n-1?"\n":" ");
	for(int i=1; i<n; ++i)
		if(p[i] > 0)
			p[i] += p[i-1];
	for(int i=0; i<n-1; ++i)
		if(p[i] > 0 && p[i+1] == 0) v.push_back(p[i]);
	if(p[n-1] > 0) v.push_back(p[n-1]);
//	for(int i=0; i<(int)v.size(); ++i)
//		cout << v[i] << "\n";
	for(int i=0; i<(int)v.size(); ++i)
		ans += v[i]/2 + (v[i]%2);
	cout << ans << "\n";
}

Measured memory_bytes: 1144
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc009/tasks/abc51_2
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

K, S = map(int, input().split())

count = 0
for X in range(0, min(S + 1, K + 1)):
    for Y in range(0, min(S + 1, K + 1)):
        Z = S - X - Y
        if 0 <= Z <= K:
            count += 1
print(count)                









Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100005
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<int>a(n);
    REP(i,n){
        cin>>a[i];
        a[i]--;
    }
    int tmp=0;
    map<int,int>m;
    m[0]++;
    REP(i,n){
        tmp=a[tmp];
        m[tmp]++;
        if(k<=i+1)break;
        if(m[tmp]>=2){
            k-=i;
            vector<int>S;
        S.push_back(tmp);
        do{
            tmp=a[tmp];
            S.push_back(tmp);
        }while (S[0]!=S[SZ(S)-1]);
        k--;
        tmp=S[k%(SZ(S)-1)];
            break;
        }
    }
    OUT(tmp+1);
    return 0;
}

Measured memory_bytes: 11444
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{ 

  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(ALL(vec));
  vector<int> ov = vec;

  for (int i = 0; i < N-1; i++)
  {
    vec[i+1] += vec[i];
  }
  int pos = 0;
  for (int i = 0; i < N-1; i++)
  {
    if(ov[i+1] > vec[i]*2) pos = i+1;
  }
    
    cout<<N - pos <<endl;
  
  

  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n,h,w;

int main(){
  cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
from math import sqrt
n, m = map(int, input().split())
ans = 1
for i in range(1, int(sqrt(m) + 2)):
    if m % i == 0:
        if i <= m / n:
            ans = max(ans, i)
        if m // i <= m / n:
            ans = max(ans, m // i)
            
print(ans)


Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define fcout cout << fixed << setprecision(10)
int main(){
    int start=0,end;
    cin>>end;
    string s;
    int sheet[end+1];
#define query(i) cout<<i<<endl;cin>>s;if(s[0]=='V')return 0;if(s[0]=='M')sheet[i]=1;else sheet[i]=0;
    query(0);
    sheet[end]=sheet[0];
#define center (start+end)/2
    while (true) {
        query(center);
        if((center-start)%2!=(sheet[center]+sheet[start])%2)end=center;
        else start=center;
    }
}

Measured memory_bytes: 852
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

int getGgd(int a, int b)
{
    int m = max(a, b);
    int n = min(a, b);
    while(n > 0){
        int tmp = m % n;
        m = n;
        n = tmp;
    }
    return m;
}

void func(void)
{
//DEBUG_OUT("----\n");
    int N;
    cin >> N;

    if(N==1){
        int tmp;
        cin >> tmp;
        cout << tmp << endl;
        return;
    }

    int ggd;
    int prev;
    uint64 mul = 0;
    cin >> prev;
    mul = prev;
    for(int i=1; i<N; i++){
        int tmp;
        cin >> tmp;
        ggd = getGgd(prev, tmp);
        prev = ggd;

        mul *= tmp / ggd;;
        prev = mul;
    }

DEBUG_OUT("-----\n");
    cout << mul << endl;
    
    return;
}



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


using namespace std;

typedef long long ll;




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

  int n;
  cin>>n;
  if(n>=30)
  {
      cout<<"Yes\n";
  }
  else
  {
     cout<<"No\n";
  }

}





Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef int64_t LL;
using namespace std;

const int N = 25;
const int mod = 1e9+7;
bool A[N][N];
int n;
int dp[N][1<<21];
LL solve(int k, int used) {
	if(k == n) return 1LL;
    if(dp[k][used]>=0) return dp[k][used];
	LL res = 0;
	for(int i=0; i<n; i++) {
		if(A[k][i] && !((used>>i)&1)) {
			used ^= (1<<i);
			res += solve(k+1, used);
			res %= mod;
			used ^= (1<<i);
		}
	}
	return dp[k][used]=res;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			scanf("%d", &A[i][j]);
		}
	}
    memset(dp, -1, sizeof(dp));
	int ans = solve(0, 0);	
    printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 205056
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/algorithm/cxx11/all_of.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

struct Shogen {
  int x, y;
};

void solve(void)
{
  int N; cin >> N;
  vector<std::unique_ptr<vector<Shogen>>> A{};
  for (int i = 0; i < N; ++i) {
    int sz; cin >> sz;
    auto vc = new vector<Shogen>(sz);
    for (auto& p : *vc) {
      cin >> p.x >> p.y;
      --p.x;
    }
    A.push_back(std::unique_ptr<vector<Shogen>>(vc));
  }

  int ans{};
  int itr = 1 << N;
  while (itr) {
    int res{};
    for (int i = 0; i < N; ++i) {
      if (itr >> i & 0x01) {
        ++res;
        auto isPass = boost::algorithm::all_of(*A[i], [&itr](auto p){
          return ((itr >> p.x) & 0x01) == p.y;
        });
        if (!isPass) goto err;
      }
    }

    chmax(ans, res);
err:
    --itr;
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>> kankei(n+1);
	vector<pair<int,int>> p(m);

	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;

		p.at(i)=make_pair(a,b);
		kankei.at(a).push_back(b);
		kankei.at(b).push_back(a);
	}

	int ans=0;

	for(auto at:p){
		int a=at.first;
		int b=at.second;

		vector<bool> been(n+1,false);
		int cnt=0;
		stack<int> que;
		been.at(1)=true;
		que.push(1);

		while(!que.empty()){
			int now=que.top();
			que.pop();
			cnt++;

			for(auto next:kankei.at(now)){
				if(been.at(next)) continue;
				if((now==a && next==b) || (now==b && next==a)) continue;

				been.at(next)=true;
				que.push(next);
			}
		}

		if(cnt<n) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
list = []

for i in range(1, N+1):
    num = i
    num_sum = 0
    while num > 0:
        num_sum += num % 10
        num = num // 10
    if A <= num_sum and num_sum <= B:
        list.append(i)

print(sum(list))

Measured memory_bytes: 3292
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){

    int N, M; cin >> N >> M;
    map<int, vector<int>> m;
    vector<int> jobs = {};
    for(int i=0; i<N; i++){
        int A, B; cin >> A >> B;
        m[A].push_back(B);
    }
    long ans = 0;
    priority_queue<int> que;
    for(int i=1; i<M+1; i++){
        for(int a:m[i]){
            que.push(a);
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)

int main(){
	io;
	queue<ll>q;
	vector<ll>v(100002);
	for(ll i=1;i<=9;i++){
		q.push(i);
	}
	
	ll c=0;
	while(c<1e5){
		ll val=q.front();
		q.pop();
		v[c]=val;
		c++;
		if((val%10)!=0){
			ll val1=val*10+(val%10-1);
			q.push(val1);
		}
		ll val2=val*10 +(val%10);
		q.push(val2);
		
		if((val%10)!=9){
			ll val3=10*val+(val%10+1);
			q.push(val3);
		}
	}
	
	ll k;
	cin>>k;
	cout<<v[k-1];
	return 0;
}
		
		
	


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

#define fs first
#define sc second
#define mp make_pair
#define eb emplace_back
#define sz(s) ((int) s.size())
#define all(s) s.begin(), s.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef unsigned long long ull;

const ll linf = (ll) 1e18;

const int A = 26;
const int L = 17;
const int B = 315;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

const int di[] = {-1, +0, +1, +0};
const int dj[] = {+0, +1, +0, -1};

const double pi = acos(-1.0);
const double eps = 1e-11;

string s;

inline bool read() {			
	if (!(cin >> s)) {
		return false;
	}
	return true;
}
inline void init() {

}
inline void solve() {
	if (s.find("YAKI") == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
}
int main() {
    #ifdef LOCAL
    	#define name ""
    	freopen(name".in", "r", stdin);
    	freopen(name".out", "w", stdout);
    #endif
    while (read()) {
    	init();
    	solve();
    }
	return 0;
}

Measured memory_bytes: 256
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ 	
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi'> _ < ﾉﾚく　 通って～
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}

int dp[100010][13],ten[100010],a[100010];
signed main() {
    string s;cin >>s;int n;n=s.size();
    memset(dp,0,sizeof(dp));
    ten[0]=1;
    rep(i,n){
        ten[i+1]=ten[i]*10;
        ten[i+1]%=13;
    }
    rep(i,n){
        if(s[i]=='?')a[i]=-1;
        else{
            a[i]=(s[i]-'0')*ten[n-i-1];
            a[i]%=13;
        }
    }
    if(a[0]==-1){
        rep(j,10){
            dp[0][(j*ten[n-1])%13]=1;
        }
    }else{
        dp[0][a[0]]=1;
    }
    for(int i=1;i<n;i++){
        if(a[i]!=-1){
            rep(j,13){
                dp[i][(j+a[i])%13]+=(dp[i-1][j])%mod;
                dp[i][(j+a[i])%13]%=mod;
            }
        }else{
            rep(j,13) {
                rep(k, 10) {
                    dp[i][(j+(k*ten[n-i-1]))%13]+=(dp[i-1][j])%mod;
                    dp[i][(j+(k*ten[n-i-1]))%13]%=mod;
                }
            }
        }
    }
    cout <<dp[n-1][5]%mod<<endl;
}

















Measured memory_bytes: 12160
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

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

    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		char exm;
		exm = n + s[i];
		if(exm>'Z')	exm = exm - 26 ;
		printf("%c",exm);
	}
	printf("\n");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int min = Integer.MAX_VALUE;
		int minValue = 0;
		int total = 0;
		for (int i = 0; i < 5; i++) {
			int x = sc.nextInt();
			int mod = x % 10;
			if (mod != 0 && mod < min) {
				if (minValue != 0) {
					total += (minValue + 9) / 10 * 10;
				}
				min = mod;
				minValue = x;
			} else {
				total += (x + 9) / 10 * 10;
			}
		}
		if (minValue != 0) {
			total += minValue;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> edge(N);
    REP(i,N){
        int a;
        cin >> a;
        a--;
        edge[i].push_back(a);
    }

    vector<int> queue;
    queue.push_back(0);
    int visited[N] = {0};
    REP(cnt,N+2){
        vector<int> tmp;
        while (!queue.empty()){
            int from = queue.back();
            queue.pop_back();
            if (visited[from]==1){
                continue;
            }
            if (from == 1){
                cout << cnt << endl;
                exit(0);
            }
            visited[from] = 1;
            for(auto to:edge[from]){
                if(visited[to] == 0){
                    tmp.push_back(to);
                }
            }
        }
        queue = tmp;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;


int main() {
	int N;cin>>N;
	vector<int>v(N);
	for(int i=0;i<N;++i)cin>>v[i];
	int answer = count_if(v.begin(), v.end(), [](const int a) {return a % 2 == 0; });
	cout<<answer<<endl;
	return 0;
}



Measured memory_bytes: 3096
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
using namespace std;
long long find(vector<long long> &a){
    if(a.size()<2){
        return 0;
    }
    long long x=a[0];
    long long ans=0;
    for(long long i=1;i<a.size();i++){
        if(a[i]>x){
            x=a[i];
        }
        else{
            ans+=(x-a[i]);
        }
    }
    return ans;
}
int main()
{
    long long n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long ans=find(a);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4832
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/function.hpp>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define repr(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n)
    {
        rep(i, n) par[i] = i;
    }

    int root(int x)
    {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    int same(int x, int y)
    {
        return root(x) == root(y);
    }
};

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    int n, m; cin >> n >> m;
    priority_queue<long> q;
    rep(i, n)
    {
        long a; cin >> a;
        q.push(a);
    }
    rep(i, m)
    {
        long a = q.top();
        q.pop();
        q.push(a >> 1);
    }
    long sum = 0;
    rep(i, n)
    {
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;

    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;
    cin >> n;
    vector<lint> v(n);
    REP(i, n) { cin >> v[i]; }

    int V = 100000;

    vector<lint> c1(V), c2(V);

    REP(i,n){
        if(i%2==0){
            c1[v[i]] += 1;
        }else{
            c2[v[i]] += 1;
        }
    }

    priority_queue<pint> que1,que2;
    REP(i, V){
        que1.push(make_pair(c1[i],i));
        que2.push(make_pair(c2[i],i));
    }

    int top1 = que1.top().first;
    //cout << top1 << "\n";
    int top2 = que2.top().first;
    //cout << top2 << "\n";
    if (que1.top().second == que2.top().second){
        que1.pop();
        que2.pop();
        top1 = max(que1.top().first, que2.top().first);
    }

    lint ans;

    ans = n - top1 - top2;
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 4340
/*************************************************************************
    > File Name: aoj2224.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???19??\ ????????? 19??¶52???17?§?
 ************************************************************************/

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

const int MAX_N = 10010;
const int MAX_M = 200000;
struct point{
	int x, y;
}P[MAX_N];
struct edge{
	int from , to;
	double cost;
}E[MAX_M];

int n , m;
int par[MAX_N];

void init_union_find_set()	{ for(int i = 0 ; i <= n ; i++)	par[i] = i; }
int  find(int x)			{ return x == par[x] ? x : par[x] = find(par[x]); }
bool same(int x,int y)		{ return find(x) == find(y); }
void union_set(int x,int y) { x = find(x); y = find(y); if(x!=y) par[y] = x; }

bool cmp(edge a,edge b){
	return a.cost < b.cost;
}
double Kruskal(){
	init_union_find_set();
	sort(E,E+m,cmp);
	double ret = 0;
	for(int i = 0 ; i < m ; i++){
		if( !same(E[i].from,E[i].to) ){
			union_set(E[i].from,E[i].to);
			ret += E[i].cost;
		}
	}
	return ret;
}

double Distence(point a,point b){
	return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) );
}

int main(){
	int from , to;
	double cost , sum;
	while(~scanf("%d%d",&n,&m)){
		sum = 0;
		for(int i = 1 ; i <= n ; i++){
			scanf("%d%d",&P[i].x,&P[i].y);
		}
		for(int i = 0 ; i < m ; i++){
			scanf("%d%d",&E[i].from , &E[i].to);
			E[i].cost = Distence( P[E[i].from] , P[E[i].to] ) * -1;
			sum += ( E[i].cost * -1 );
		}
		double ret = Kruskal();
		printf("%.3lf\n",sum + ret);
	}
	return 0;
}

Measured memory_bytes: 3776
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main(){
	int a[200];
	long long k, x, y, z;
	int s, ans;
	scanf("%lld", &k);
	f(i, 200)a[i] = -1;
	f(i, 100)a[i] = i;
	f(i, 100){
		if (k > 0){
			x = 1;
			y = 0;
			f(j, i){
				x = x * 2;
				if (x <= k)y++;
				else {
					x = x / 2;
					break;
				}
			}
			f(j, 99 - y)a[199 - j] = a[198 - j];
			a[100 + y] = i;
			k -= x;
			if (k == 0)break;
		}
	}
	s = 0;
	f(i, 200){
		if (a[i] >= 0){
			s++;
			a[i]++;
		}
	}
  printf("%d\n",s);
	f(i, s){
		printf("%d", a[i]);
		if (i < s - 1)printf(" ");
		else printf("\n");
	}

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    int minus_cnt = 0;
    int min_a = 1000000001;
    int64_t sum_a = 0;
    rep(i,n) {
        int x;
        cin >> x;
        if (x < 0) minus_cnt++;
        int y = abs(x);
        a[i] = y;
        min_a = min(y, min_a);
        sum_a += y;
    }
    int64_t ans = sum_a;
    if (minus_cnt % 2 == 1) {
        ans -= 2*min_a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b,c;

int main(){
	scanf("%d/%d/%d",&a,&b,&c);
	if(a>2019) printf("TBD\n");
	else if(a<2019) printf("Heisei\n");
	else if(b>4) printf("TBD\n");
	else if(b<4) printf("Heisei\n");
	else if(c>30) printf("TBD\n");
	else if(c<=30) printf("Heisei\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = 1; k * i <= b; i++) {
    int t = k * i;
    if (t >= a && t <= b) return cout << "OK" << endl, 0;
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3632
// Written By NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 262147, mod = 998244353;
int p[maxN];

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

int A[maxN], B[maxN];
inline void FWT(int* f, int n) {
    int len = 1 << n, i, j, l, r;
    for (i = 0; i < n; ++i)
        for (j = 0; j < len; ++j)
            if (j & (1 << i)) {
                l = f[j ^ (1 << i)], r = f[j];
                f[j ^ (1 << i)] = (l + r) % mod, f[j] = (l - r) % mod;
            }
}

int main() {
    int n = read(), lim = (1 << n) - 1, i, sum = 0, d;
    for (i = 0; i <= lim; ++i)
        p[i] = read(), sum += p[i];
    sum = power(sum, mod - 2);
    for (i = 0; i <= lim; ++i)
        p[i] = 1ll * p[i] * sum % mod;
    
    A[0] = lim;
    for (i = 1; i <= lim; ++i)
        A[i] = -1;
    B[0] = p[0] - 1;
    for (i = 1; i <= lim; ++i)
        B[i] = p[i];
    FWT(A, n), FWT(B, n);
    for (i = 0; i <= lim; ++i)
        B[i] = power(B[i], mod - 2);
    for (i = 0; i <= lim; ++i)
        A[i] = 1ll * A[i] * B[i] % mod;
    FWT(A, n);
    d = power(lim + 1, mod - 2);
    for (i = 0; i <= lim; ++i)
        A[i] = 1ll * A[i] * d % mod;
    d = -A[0];
    for (i = 0; i <= lim; ++i)
        A[i] = (A[i] + d) % mod;
    
    for (i = 0; i <= lim; ++i)
        printf("%d\n", (A[i] + mod) % mod);
    return 0;
}


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

int main() {
  int N;
    cin >> N;
  if ( N >9999) {
    cout << "No" << endl;
  }
  else if ( N < 1000) {
    cout << "No" << endl;
  }
  else if ((N % 1000) % 111 == 0) {
    cout << "Yes" <<endl;
  }
  else if ((N % 1110) < 10) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

struct NUM {
	int cnt;
	int m;
	int G[100];
};

int InsertionSort(int A[], int n, int g) {
	int i, v, j, cnt = 0;
	for (i = g; i < n; i++) {
		v = A[i]; j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j]; j = j - g; cnt++;
		}
		A[j + g] = v;
	}
	return cnt;
}

struct NUM ShellSort(int A[], int n) {
	struct NUM num;
	int cnt = 0;
	int m = 0;
	int G[100];
	for (int i = n ; i > 0; i = i / 2) {
		G[m] = i;
		m++;
	}
	for (int i = 0; i < m; i++) {
		cnt += InsertionSort(A, n, G[i]);
	}
	num.cnt = cnt; num.m = m; for (int i = 0; i < m; i++) num.G[i] = G[i];
	return num;
}


int main() {
	int N, A[1000000];
	struct NUM num;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	num = ShellSort(A, N);
	printf("%d\n", num.m);
	for (int i = 0; i < num.m; i++) {
		if (i == num.m - 1) {
			printf("%d\n", num.G[i]);
			break;
		}
		printf("%d ", num.G[i]);
	}
	printf("%d\n", num.cnt);
	for (int i = 0; i < N; i++) {
		printf("%d\n", A[i]);
	}
	return 0;
}


Measured memory_bytes: 6612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010 
#define ll long long
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int n,a[N];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	a[0]=-1;	
	for(int i=1;i<=n;i++)		
		if(a[i]-a[i-1]>1) {puts("-1");return 0;}
	ll ans=0;
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1]+1) ans++;
		else ans+=a[i];	
	printf("%lld",ans);	
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int a[4];
double b[4] = {0.25,0.5,1.0,2.0};
int N;
int ans=INF;


signed main(){
    for(int i=0;i<4;++i)cin>>a[i];
    cin>>N;
    int n = N;
    for(int i=0;i<4;++i){
        for(int j=0;j<4;++j){
            for(int k=0;k<4;++k){
                for(int l=0;l<4;++l){
                    int p = n/b[i];
                    n-=b[i]*p;
                    int q = n/b[j];
                    n-=b[j]*q;
                    int r = n/b[k];
                    n-=b[k]*r;
                    int s = n/b[l];
                    n-=b[l]*s;
                    if(n!=0)continue;
                    int res = a[i]*p+a[j]*q+a[k]*r+a[l]*s;
                    ans=min(ans,res);
                    n=N;
                }
            }
        }
    }
    cout<<ans<<endl;
    //cout<<Q*a+H*b+S*c+D*d<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
//  ll mod(ll val) {
//      ll res = val % MOD;
//      if (res < 0) res += MOD;
//      return res;
//  }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }


int main() {
    int K; std::cin >> K;
    string S; std::cin >> S;
    if (S.size() <= K) {
        std::cout << S << std::endl;
    } else {
        std::cout << S.substr(0, K) + "..." << std::endl;
    }
    // cout << setprecision(10);
    return 0;
}


Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))

for i in range(N-1):
  if A[N-2-i]-A[N-1-i]==1:
    A[N-2-i]-=1
  elif A[N-2-i]-A[N-1-i]>1:
    print('No')
    exit()
print('Yes')


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

#define int long long

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a%b);
}

signed main() {
	int T;
	cin >> T;
	while (T--) {
		int A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A < B || D < B) {
			cout << "No" << endl;
		} else if (C < B - (gcd(B, D) - A % gcd(B, D))) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
}


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

string str;
const int MAXN = 2e5+5;
const int INF=1e9+7;
int dp[MAXN],ix[26+3][MAXN],nx[26+3];
int main(){
   
  cin>>str;
  int n = str.size();
  for (int i = 0; i < 26; ++i)
  {
    nx[i] = n;
  }
  for (int i = n-1; i >=0; i--)
  {
    nx[str[i]-'a'] = i;
    for (int j = 0; j < 26; ++j)
    {
      ix[j][i] = nx[j];
    }
    dp[i] = INF;
  }


  dp[n] = 1;
  for (int i = n-1; i > -1; --i)
    for (int j = 0; j < 26; ++j)
      dp[i] = min(dp[i],dp[ix[j][i]+1]+1);

  for (int i = 0; dp[0]; --dp[0])
  {
    for (int j = 0; j < 26; ++j)
    {
      if(dp[i]==dp[ix[j][i]+1]+1)
      {
        printf("%c",j+'a');
        i = ix[j][i]+1;
        break;
      }
    }
  }

  cout<<endl;

  
}


Measured memory_bytes: 21892
#coding: utf-8

def change_number(nums_list, bit_flag):
    flag = 'Yes'
    for i in range(0, N-1):
        if int(args[i]) <= int(args[i+1]):
            pass
        elif int(args[i])-1 <= int(args[i+1]) and bit_flag[i] == 0:
            args[i] = str(int(args[i])-1)
            bit_flag[i] = 1
            flag = 'try'
        else:
            flag = 'No'
            break

    return flag, nums_list, bit_flag



if __name__ == '__main__':
    N = int(input())
    args = input().split()

    bit_flag = []
    bit_done_flag = []
    for i in range(0, N-1):
        bit_flag.append(0)
        bit_done_flag.append(1)

    flag = 'try'
    nums_list = args
    while flag == 'try':
        flag, nums_list, bit_flag = change_number(nums_list, bit_flag)


    print(flag)


Measured memory_bytes: 12964
#include <iostream>
using namespace std;
int main() {
	while (true) {
		int a, b = 0;
		cin >> a;
		if (a == 0)
			break;
		a = 1000 - a;
		if (a >= 500) {
			a = a - 500;
			b = b + 1;
		}
		b = b + a / 100;
		a = a % 100;
		if (a >= 50) {
			a = a - 50;
			b = b + 1;
		}
		b = b + a / 10;
		a = a % 10;
		if (a >= 5) {
			a = a - 5;
			b = b + 1;
		}
		b = b + a;
		cout << b << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int x = N;
  if(N %2 == 0){
   while(x > 0){
     cout << vec.at(x-1) << endl;
     x -= 2;
   }
   x = 0;
   while(x < N){
     cout << vec.at(x) << endl;
     x += 2;
   }
  }
  
  if(N %2 != 0){
   while(x > 0){
     cout << vec.at(x-1) << endl;
     x -= 2;
   }
   x = 1;
   while(x < N){
     cout << vec.at(x) << endl;
     x += 2;
   }
  }

}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

vector<vector<ll>> dp(4096, vector<ll>(1001, INF));

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M), b(M);
    vector<vector<ll>> c(M, vector<ll>(0));
    rep(i, M){
        cin >> a.at(i) >> b.at(i);
        rep(j, b.at(i)){
            ll x;
            cin >> x;
            x--;
            c.at(i).push_back(x);
        }
    }
    rep(i, M){
        dp.at(0).at(i) = 0;
    }
    rep2(i, 1, 1<<N){
        bitset<12> s(i);
        rep(j, M){
            bitset<12> t = s;
            rep(k, b.at(j)){
                t.set(c.at(j).at(k), 0);
            }
            ll x = 0;
            rep(k, 12){
                if(t.test(k)){
                    x += pow(2, k);
                }
            }
            dp.at(i).at(j+1) = min(dp.at(x).at(j)+a.at(j), dp.at(i).at(j));
        }
    }
    if(dp.at(pow(2, N)-1).at(M) >= 100000*1000+1){
        cout << -1 << endl;
    }
    else{
        cout << dp.at(pow(2, N)-1).at(M) << endl;   
    }
}

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

int main(){
  long N,K,R,S,P;
  cin >>N>>K>>R>>S>>P;
  string T;
  cin >>T;
  
  for(int i=0; i<N-K;i++){
  	if(T[i]==T[i+K]) T[i+K]='?';
  }
  long sum=0;
  for(int i=0;i<N;i++){
  	if(T[i]=='r') sum+=P;
    else if(T[i]=='s') sum+=R;
    else if(T[i]=='p') sum+=S;
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std; 
int main() {
	long long a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	long long ret = a * c;
	ret = max(ret, a * d);
	ret = max(ret, b * c);
	ret = max(ret, b * d);
	printf("%lld", ret);
}

Measured memory_bytes: 1732
N = int(input())
X = [int(x) for x in input().split()]

ind = [i for i in range(N)]
# XのindexをXが昇順になるように並び替える
ind = sorted(ind, key = lambda i : X[i])
ans = [0] * N
for i in range(N // 2):
    ans[ind[i]] = X[ind[N // 2]]
for i in range(N // 2, N):
    ans[ind[i]] = X[ind[N // 2 - 1]]

for i in range(N):
    print(ans[i])

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const ll INF = 1e+18;
const ll MOD = 1e+9+7;

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

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];    
    sort(ALL(A));
    if(A[0] == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i, N)
    {
        if((INF+ans-1) / ans < A[i])
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    if(ans > INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3992
n=gets.to_i
t,a=gets.chomp.split.map(&:to_i)
h=gets.chomp.split.map(&:to_i)

m=Float::INFINITY
ans=0
h.each_with_index do |v, i|
    mm = (a-(t-v*0.006)).abs
    if mm < m
        ans = i+1
        m = mm
    end
end
puts ans

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

int main() {

    int h, w, n, a[10000];
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    bool turn = true;
    int x = 1, y = 1, incx = 1, incy = 1;
    int ans[101][101] = {{0}};
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < a[i]; j++) {
            ans[y][x] = i + 1;
            if(turn) x += incx;
            else     y += incy;
            if(turn && ((incx > 0 && x > w) || (incx < 0 && x == 0) || ans[y][x])) {
                x -= incx;
                incx *= -1;
                y += incy;
                turn = !turn;
            }
            if(!turn && ((incy > 0 && y > h) || (incy < 0 && y == 0) || ans[y][x])) {
                y -= incy;
                incy *= -1;
                x += incx;
                turn = !turn;
            }
        }
    }

    for(int i = 1; i <= h; i++) {
        cout << ans[i][1];
        for(int j = 2; j <= w; j++) {
            cout << " " << ans[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    ll h, w;
    cin >> h >> w;
    vector<vector<pair<ll, ll>>> edge(10);
    vector<vector<ll>> dis(10, vector<ll>(10, INF));
    int c;
    FOR(i, 0, 10)FOR(j, 0, 10) {
        cin >> c;
        if (i == j)continue;
        edge[i].push_back({ j,c });
        dis[i][j] = c;
    }
    vector<ll> a(h* w);
    FOR(i, 0, h* w)cin >> a[i];

    FOR(i, 0, 10)dis[i][i] = 0;
    FOR(k, 0, 10)FOR(i, 0, 10)FOR(j, 0, 10)chmin(dis[i][j], dis[i][k] + dis[k][j]);

    ll ans = 0;
    for (ll i : a)if (i > -1)ans += dis[i][1];
    cout << ans << "\n";
}

Measured memory_bytes: 640
N=int(input())
w=list(map(int,input().split()))
tot_w=sum(w)
ans=10**4
for i in range(N):
    par_w=0
    for j in range(i):
        par_w+=w[j]
    ans=min(abs(tot_w-2*par_w),ans)
print(ans)


Measured memory_bytes: 38512
n, m = map(int, input().split())

ans = ['a' for i in range(n)]
if n == 1 and m == 0:
    ans = ['0']

for i in range(m):
    s, c = input().split()
    s = int(s) - 1
    if ans[s] == 'a' or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        break
else:
    for i in range(n):
        if i == 0 and ans[i] == 'a':
            ans[i] = '1'
        elif ans[i] == 'a':
            ans[i] = '0'
    a = ''
    for _ in ans:
        a += _
    if len(str(int(a))) != n:
        print(-1)
    else:
        print(a)

Measured memory_bytes: 3064