akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)
int n,q;
vector<int> v;
vector<pair<pair<int,int>,int>> query;
int block;
bool comp(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b) {
  if(a.first.first/block != b.first.first/block)
    return a.first.first/block < b.first.first/block;
  return a.first.second<b.first.second;
}
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>q;
  v.resize(n);
  for(int &i:v)
    cin>>i;
  query.resize(q);
  int pos = 0;
  for(auto &i:query){
    cin>>i.first.first>>i.first.second;
    i.second = pos++;
  }
  
  block = sqrt(n);
  sort(query.begin(),query.end(),comp);

  int curL = 0,curR = 0;
  vector<int> ans(q);
  int freq[n+1];
  memset(freq,0,sizeof freq);
  int si = 0;
  for(auto i:query) {
      int l = i.first.first-1,r = i.first.second-1;
      while (curR <= r) { 
        if(freq[v[curR]] == 0)
          si++;
        freq[v[curR]]++;
        curR++; 
      } 
      while (curR > r+1) { 
        freq[v[curR-1]]--;
        if(freq[v[curR-1]] == 0)
          si--;
        curR--; 
      } 
      while(curL<l) {
        freq[v[curL]]--;
        if(freq[v[curL]] == 0)
          si--;
        curL++;
      }
      while(curL > l) {
        if(freq[v[curL-1]] == 0)
          si++;
        freq[v[curL-1]]++;
        curL--;
      }
      ans[i.second] = si;
  }
  for(int i:ans)
    cout<<i<<"\n";
  return 0;
}

Measured memory_bytes: 27172
import math

def per8_and_per10(n, a, b):
  per8  = n * 0.08 
  per10 = n * 0.1
  if a <= f01_rounding(per8) < a+1 and b <= f01_rounding(per10) < b+1:
    return True
  else:
    return False

def f01_rounding(number):
  number_str = list(str(number))
  number_str_slice = "".join(number_str[:(number_str.index("."))])
  number_int = int(number_str_slice)
  return number_int

a, b = map(int, input().split())
for i in range(1,1010):

  if per8_and_per10(i, a, b):
    print(i)
    exit()
print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#define ll long long

#include <vector>

template <typename T>
class UnionFindTree
{
public:
    UnionFindTree(T size = 0)
    {
        if (size == 0)
            return;

        rank.resize(size + 1);
        parents.resize(size + 1);
        for (T i=0; i<size; ++i)
        {
            //最初は自分自身が親
            parents[i] = i;
            rank[i] = 0;
        }
    }

    // 一方の根をもう一方の根の子にする
    bool Union(T x, T y)
    {
        x = FindRoot(x);
        y = FindRoot(y);
        if (x == y)
            return false;

        //ノードごとの rank を記憶しておき rank が低い方を高い方の子にする
        //例: 6-4-7 / 2-5, Union(6, 2)の場合 2 を 6 の子にする
        if (rank[x] < rank[y])
        {
            parents[x] = y;
            // 子を増やした方の rank を更新
            if (rank[y] == rank[x])
                rank[y]++;
        }
        else
        {
            parents[y] = x;
            // 子を増やした方の rank を更新
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    T FindRoot(T x)
    {
        if (parents[x] == x)
            return x;

        // root にたどり着くまで
        while (parents[x] != x)
        {
            // x の親の親 を x の親とする
            T parent = parents[x];
            parents[x] = parents[parent];
            x = parents[x];
        }

        return x;
    }

    bool IsUnited(T a, T b)
    {
        return FindRoot(a) == FindRoot(b);
    }

private:
    std::vector<T> parents;
    std::vector<T> rank;
};

int main()
{
    int N, K, L;
    std::cin >> N >> K >> L;

    UnionFindTree<ll> roadConnection(N);
    for (ll i=0; i<K; ++i)
    {
        ll pi, qi;
        std::cin >> pi >> qi;
        roadConnection.Union(pi, qi);
    }

    UnionFindTree<ll> railConnection(N);
    for (ll i=0; i<L; ++i)
    {
        ll ri, si;
        std::cin >> ri >> si;
        railConnection.Union(ri, si);
    }

    std::map<std::pair<ll, ll>, ll> answer;
    for (ll i=1; i<=N; ++i)
    {
        answer[{roadConnection.FindRoot(i), railConnection.FindRoot(i)}]++;
    }

    for (ll i=1; i<=N; ++i)
    {
        std::cout << answer[{roadConnection.FindRoot(i), railConnection.FindRoot(i)}] << " ";
    }
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(1, 1);
    for(int i = 2; i * i <= n; i++) {
        int ni = i * i;
        while(ni <= n) {
            a.push_back(ni);
            ni *= i;
        }
    }
    sort(rall(a));
    cout << a[0] << endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool chk = true;
    for(int i=0;i<a+b+1;i++){
        if(i==a){
            if(s[i] != '-')chk = false;
        }else{
            if(s[i] == '-')chk = false;
        }
    }
    if(chk)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
map<char,int> D;
vector<char> ans;
int z=1;
void tengoku(string s){
    if(D[s[0]]<D[s[1]]) ans.push_back(s[0]),D[s[0]]++,D[s[1]]--;
    else ans.push_back(s[1]),D[s[1]]++,D[s[0]]--;
}
int main(){
    ll n,a,b,c;
    ll A=0,B=0,C=0;
    cin>>n>>a>>b>>c;
    D['A']=a,D['B']=b,D['C']=c;
    string s;
    if(a+b+c>=3){
        ll zerokazu=0;
        if(a==0) zerokazu++;
        if(b==0) zerokazu++;
        if(c==0) zerokazu++;
        if(zerokazu<2){
            rep(i,n) cin>>s,tengoku(s);
        }
        else{
            cin>>s;
            if(D[s[0]]==0&&D[s[1]]==0) z=0;
            else{
                if(D[s[0]]==0) D[s[0]]++,D[s[1]]--,ans.push_back(s[0]);
                else D[s[1]]++,D[s[1]]--,ans.push_back(s[1]);
                rep(i,n-1) cin>>s,tengoku(s);
            }
        }
    }
    if(a+b+c==0) z=0;
    if(a+b+c==1){
        rep(i,n){
            cin>>s;
            if(D[s[0]]==0&&D[s[1]]==0) z=0;
            else{
                if(D[s[0]]==0) D[s[0]]++,D[s[1]]--,ans.push_back(s[0]);
                else D[s[1]]++,D[s[0]]--,ans.push_back(s[1]);
            }
        }
    }
    if(a+b+c==2){
        string t[200001];
        rep(i,n) cin>>t[i];
        rep(i,n){
            s=t[i];
            if(D[s[0]]==0&&D[s[1]]==0) z=0;
            else{
                if(D[s[0]]==1&&D[s[1]]==1){
                    if(i==n-1||t[i+1]==s){
                        ans.push_back(s[0]),D[s[0]]++,D[s[1]]--;
                    }
                    else{
                        if(s[0]==t[i+1][0]||s[0]==t[i+1][1]) ans.push_back(s[0]),D[s[0]]++,D[s[1]]--;
                        else ans.push_back(s[1]),D[s[1]]++,D[s[0]]--;
                    }
                }
                else{
                    if(D[s[0]]<D[s[1]]) ans.push_back(s[0]),D[s[0]]++,D[s[1]]--;
                    else ans.push_back(s[1]),D[s[1]]++,D[s[0]]--;
                }
            }
        }
    }
    if(z){cout<<"Yes\n";for(auto i:ans) cout<<i<<"\n";}
    else cout<<"No";
}

Measured memory_bytes: 10012
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,x[105];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	sort(x+1,x+n+1);
	int ans=inf;
	for(int i=x[1];i<=x[n];i++)
	{
		int res=0;
		for(int j=1;j<=n;j++)
			res+=(x[j]-i)*(x[j]-i);
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

val=0
while True:
    Xa = X - val
    Xb = X + val

    if Xa in p:
        pass
    else:
        print(Xa)
        exit()

    if Xb in p:
        pass
    else:
        print(Xb)
        exit()

    val+=1


Measured memory_bytes: 9176
#include<stdio.h>

int main()
{
    int sum_r=0,sum_c[100]= {0},sum=0;
    int i,k,r,c,input;

    scanf("%d %d", &r, &c);

    for(i=0; i<r; ++i)
    {
        sum_r = 0;
        for(k=0; k<c; ++k)
        {
            scanf("%d",&input);

            printf("%d ",input);

            sum_r+=input;
            sum_c[k]+=input;
        }
        sum+=sum_r;
        printf("%d\n",sum_r);
    }

    for(i=0; i<c; ++i)
    {
        printf("%d ", sum_c[i]);
    }
    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 2028
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;

  int ans = 0;
  rep(i, 1, N + 1) {
    int t = N / i;
    int g = (1 + t) * t * i / 2;
    ans += g;
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3592
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let result = hikaku (a,b)
  ; putStrLn result
  }

hikaku :: (Int,Int) -> String
hikaku (x,y)
  | x < y  = "a < b"
  | x == y = "a == b"
  | x > y  = "a > b"

getInts :: IO [Int]
getInts = map read . words <$> getLine

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

typedef long long ll;

const ll MOD = (ll)(1e+9) + 7;
ll N, A, B;

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

ll func(ll x, ll y) {
	ll val = (ll)1;
	for (ll i = x; i >= y; --i) {
		val *= i;
		val %= MOD;
	}
	return val;
}
		
int main(void) {
	cin >> N >> A >> B;

	ll all_cnt = (mod_pow((ll)2, N, MOD) + MOD - 1) % MOD;
	ll func_a = func(N, N - A + 1);
	ll func_b = func(N, N - B + 1);
	ll div_a = func(A, 1);
	ll div_b = func(B, 1);
	ll inv_a = mod_pow(div_a, MOD - 2, MOD);
	ll inv_b = mod_pow(div_b, MOD - 2, MOD);
	ll nCa = func_a * inv_a % MOD;
	ll nCb = func_b * inv_b % MOD;
	ll ans = (all_cnt + MOD - nCa) % MOD;
	ans = (ans + MOD - nCb) % MOD;

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


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll n,x,t; cin >> n >> x >> t;
    ll cnt = (n+x-1)/x;
    out(cnt*t);
}

Measured memory_bytes: 3628
import java.io.*
import java.lang.*


fun solve() {
    val (N,A,B) = rd.readIntArray()
    val X = rd.readLongArray()

    val D = (B + A - 1L)/A
    var ans = 0L

    for (i in 1 until N) {
        val d = X[i] - X[i-1]
        val dc = if (d >= D) B.toLong() else A*d
        ans += dc
    }

    println(ans)
}


//val rd = debug.Reader("arc", "067", "b", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 55820
N = int(input())
A = list(map(int, input().split()))
cnt = 1
	
status = 0
for i in range(N-1):
	if A[i] > A[i+1]:
		if status == 0: status = 1
		elif status == -1:
			status = 0
			cnt += 1
	elif A[i] < A[i+1]:
		if status == 0: status = -1
		elif status == 1:
			status = 0
			cnt += 1
print(cnt)

Measured memory_bytes: 20044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  int t_n = a/d,a_n = c/b;//何回耐えるか
  if(a%d !=0){
    t_n++;
  }
  if(c%b !=0){
    a_n++;
  }
  if(t_n >= a_n){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 3600
a=int(input())
s=[a]
m={a}
while len(s)==len(m):
    if s[-1]%2==0:
        t=s[-1]//2
        s.append(t)
        m.add(t)
    else:
        t=s[-1]*3+1
        s.append(t)
        m.add(t)
print(len(s))

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	int a[3], x=0, y=0;
	cin >> a[0] >> a[1] >> a[2];
	for(int i=0;i<3;i++){
		if(a[i]==5)x++;
		else if(a[i]==7)y++;
	}
	if(x==2&&y==1)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main() {
  int k, s;
  cin >> k >> s;
  int count = 0;
  
  for (int x = 0; x <= k; x++){
    for (int y = 0; y <= k; y++){
        int z = s - x - y;
        if(0 <= z && z <= k)count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
S = list(input())

length = len(S)
S.pop()
for _ in range(length):
    if len(S) % 2 != 0:
        S.pop()
        continue

    if S[:len(S)//2] == S[len(S)//2:]:
        print(len(S))
        break

    else:
        S.pop()


Measured memory_bytes: 9028
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef unsigned long long ull;

typedef struct Item {
  ull v;
  ull w;
  Item(ull v, ull w) : v(v), w(w) {};
} Item;

bool sort_by_cost(const Item& lhs, const Item& rhs) {
  if ((__int128)lhs.v*rhs.w != (__int128)rhs.v*lhs.w) {
    return (__int128)lhs.v*rhs.w > (__int128)rhs.v*lhs.w;
  }
  else {
    return lhs.v > rhs.v;
  }
}

ull solve_greedy(const vector<Item>& items, const int i, ull W) {
  ull greedy_ans = 0;
  for (int k = i; k < items.size() && W > 0; ++k) {
    ull v = items[k].v;
    ull w = items[k].w;
    if (w <= W) {
      greedy_ans += v;
      W -= w;
    }
  }
  return greedy_ans;
}

double solve_relax(const vector<Item>& items, const int i, ull W) {
  double remain_w = W;
  double lp_ans = 0;
  for (int k = i; k < items.size() && fabs(remain_w) > 1e-15; ++k) {
    double v = items[k].v;
    double w = items[k].w;
    double use_m = min(1.0, remain_w/w);
    lp_ans += v*use_m;
    remain_w -= w*use_m;
  }
  return lp_ans;
}

ull ans;
void solve(const vector<Item>& items, const int i, const ull W, const ull total) {
  if (items.size() == i) {
    return;
  }

  ull grd_ans = solve_greedy(items, i, W);
  ans = max(ans, total + grd_ans);

  double lp_ans = solve_relax(items, i, W);
  if (total + lp_ans <= ans) {
    ans = max(ans, total);
    return;
  }

  ull v = items[i].v;
  ull w = items[i].w;

  solve(items, i+1, W, total);

  if (W >= w) {
    solve(items, i+1, W-w, total+v);
  }
}

int main () {
  int N;
  ull W;
  cin>>N>>W;
  vector<Item> items;
  for (int i = 0; i < N; ++i){
    ull v, w, m;
    cin>>v>>w>>m;
    ull k = 1;
    while (m > 0) {
      ull use_m = min(k, m);
      k <<= 1;
      m -= use_m;
      items.push_back(Item(v*use_m, w*use_m));
    }
  }

  sort(items.begin(), items.end(), sort_by_cost);

  solve(items, 0, W, 0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3260
<?php

# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $n, $x);

# 満足度リスト作成
$format = "%d";
for ($i = 1; $i < $n; $i++) {
  $format .= " %d";
}
$prefer = fscanf(STDIN, $format);

//満足度リストを昇順に並べる
asort($prefer);

//満足度が低いやつから配っていく
$count = 0;
foreach($prefer as $p) {
  if($x-$p < 0) {
    break;
  } else {
    $x -= $p;
    $count++;
  }
  if($count === $n) {
    if ($x !== 0) {
      $count -= 1;
    }
  }
}

echo $count;
?>


Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
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; }

char ToUpper(char cX) { return toupper(cX); }
char Tolower(char cX) { return tolower(cX); }

const int MAX = 510000;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
using T = tuple<ll, ll, ll>;
vector<ll> a;
ll N;
void dfs(ll x) {
	if (N < x) {
		return;
	}
	a.emplace_back(x);
	dfs(x * 10 + 7);
	dfs(x * 10 + 5);
	dfs(x * 10 + 3);
}

bool check(ll x) {
	string s = to_string(x);
	ll sev = 0;
	ll fiv = 0;
	ll thr = 0;
	for (ll i = 0; i < s.size(); i++) {
		if (s[i] == '7') {
			sev++;
		}
		else if (s[i] == '5') {
			fiv++;
		}
		else if (s[i] == '3') {
			thr++;
		}
		else {
			return false;
		}

	}
	if (sev > 0 && fiv > 0 && thr > 0) {
		return true;
	}
	else {
		return false;
	}
}
int main()
{
	cin >> N;
	ll res = 0;
	dfs(3);
	dfs(5);
	dfs(7);
	for (auto it = a.begin(); it != a.end(); it++) {
		if (check(*it)) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

string s;
stack <char> st;
int ans;

int main()
{
	//freopen("z.in","rt",stdin);
	//freopen("z.out","wt",stdout);

	cin >>s;
	forn(i,s.size())
	{
		if(s[i]=='S')
			st.push('S');
		if(s[i]=='T')
		{
			if(st.size()>0 && st.top()=='S')
			{
				ans++;
				st.pop();
			}
			else
				st.push('T');
		}
	}
	cout <<s.size()-2*ans;

	return 0;
}

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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define repi(i, a, b)    for(int i = a; i < b; i++)
#define repd(i, a, b)    for(int i = b-1; i >= a; i--)   
#define rep(i, n)        for(int i = 0; i < n; ++i)
#define ll               long long int
#define I                iterator
#define lf               long double
#define pb               push_back
#define pq               priority_queue
#define all(c)           (c).begin(), (c).end()




int main(){
    int n, m;
    cin >> n >> m;
    int l = -1, r = INT32_MAX;
    rep(i, m){
        int tl, tr;
        cin >> tl >> tr;
        if(tl > l){
            l = tl;
        }
        if(tr < r){
            r = tr;
        }
    }
    if((r - l) >= 0){
        cout << (r-l+1)<<endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e18;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}

int t(int n) {
   return powM(2,n+2) - 3;
}

int p(int n) {
   return powM(2,n+1) - 1;
}

int get(int n, int x) {
   if (n == 0) return 1;

   if (x <= 1) {
      return 0;
   } else if (x <= t(n-1) + 1) {
      return get(n-1, x-1);
   } else if (x == t(n-1) + 2) {
      return p(n-1) + 1;
   } else if (x <= 2*t(n-1) + 2) {
      return p(n-1) + 1 + get(n-1, x-(t(n-1)+2));
   } else {
      return p(n);
   }
}

signed main()
{
   int n, x; cin >> n >> x;

   cout << get(n, x) << endl;

   return 0;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
foreach($key->X[0] as $v) {
  if (is_array($v)) {
    $X[]=$v[0];
  }
  else {
    $X[]=$v;
  }
}
$l = count($X);
$str="";
for($i=$l;$i>0;$i=$i-2) {
  if ($str != "") $str .= " ";
  $str .= $X[$i-1];
}
//偶数か奇数かで開始位置が変わる
if ($l%2==0) $st = 0;
else $st = 1;
for($i=$st;$i<$l;$i=$i+2) {
  if ($str != "") $str .= " ";
  $str .= $X[$i];
}
printf("%s\n",$str);


Measured memory_bytes: 81908
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
length = len(S)
ans = [0]*length
now = 'R'
for i in range(length):
    s = S[i]
    if s=='R':
        now = 'R'
        continue
    if s=='L':
        if now=='R':
            now = 'odd'
            plus = i
            ans[plus] += 1
        elif now=='odd':
            now = 'even'
            ans[plus-1]+=1
        else:
            now = 'odd'
            ans[plus]+=1
now = 'L'
for i in range(length-1, -1, -1):
    s = S[i]
    if s=='L':
        now = 'L'
        continue
    if s=='R':
        if now=='L':
            now = 'odd'
            plus = i
            ans[plus] += 1
        elif now=='odd':
            now = 'even'
            ans[plus+1]+=1
        else:
            now = 'odd'
            ans[plus]+=1
print(*ans)

Measured memory_bytes: 83060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

		Arrays.sort(str);
		for (int i = 0; i < str.length; i++) {
			System.out.print(str[i]);
		}
	}
}


Measured memory_bytes: 25044
from fractions import gcd

def lcm(a, b):
    return a // gcd(a, b) * b

A,B,C,D = list(map(int,input().split()))
C1 = B//C
C2 = (A-1)//C
C3 = B//D
C4 = (A-1)//D
C5 = B//lcm(C,D)
C6 = (A-1)//lcm(C,D)
print((B-(A-1))-((C1-C2)+(C3-C4)-(C5-C6)))


Measured memory_bytes: 5076
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
P p[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>a>>b;
        p[i]=m_p(a,b);
    }
    sort(p,p+n);
    Cout(p[n-1].fi+p[n-1].se);
    return 0;
}


Measured memory_bytes: 1792
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n,q=map(int,input().split())
    P=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        P[a-1].append(b-1)
        P[b-1].append(a-1)
    X=[0]*n
    for i in range(q):
        p,x=map(int,input().split())
        X[p-1]+=x
    deq=deque([0])
    visited=[False]*n 
    while deq:
        node=deq.popleft()
        if not(visited[node]):
            visited[node]=True
            for p in P[node]:
                if not(visited[p]):
                    X[p]+=X[node]
                    deq.append(p)
    print(*X)

if __name__=='__main__':
    main()

Measured memory_bytes: 56076
//#include <GOD>
#include <iostream>
# define M_PI   3.14159265358979323846
using namespace std;
typedef long long ll;
#define pb push_back
#define len length
float n;
int main(){
	cin>>n;
//	printf("%.4f", 2*n*M_PI);
	cout<<2*n*M_PI;
}


Measured memory_bytes: 3784
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts s[gets.to_i - 1]

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

class C
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int h = a[0], w = a[1], k = a[2];
		var s = new int[h].Select(_ => Console.ReadLine()).ToArray();
		var none = new string('.', w);

		var m = new int[h, w];
		for (int t = 0, i = 0; i < h; i++)
		{
			if (s[i] == none) continue;

			var cw = s[i].IndexOf('#');
			for (int j = 0; j < cw; j++)
				m[i, j] = t + 1;
			for (int j = cw; j < w; j++)
				if (s[i][j] == '#') m[i, j] = ++t;
				else m[i, j] = t;
		}

		var ch = s.TakeWhile(x => x == none).Count();
		for (int i = 0; i < ch; i++)
			for (int j = 0; j < w; j++)
				m[i, j] = m[ch, j];
		for (int i = ch; i < h; i++)
		{
			if (s[i] != none) continue;

			for (int j = 0; j < w; j++)
				m[i, j] = m[i - 1, j];
		}

		for (int i = 0; i < h; i++)
			Console.WriteLine(string.Join(" ", Enumerable.Range(0, w).Select(j => m[i, j])));
	}
}


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

typedef long long ll;

int N,A,B;
ll v[55];
long double S,D;

ll comb(int n,int r){
	if(r==0) return 1;
	return (n-r+1)*comb(n,r-1)/r;
}

int main(){

cin>>N>>A>>B;

for(int i=0; i<N; i++) scanf("%lld",&v[i]);

sort(v,v+N);

int i=N; int C=B-A; int E=A;
while(E){
	i--;
	S+=v[i]; 
	E--; D++;
}

if(v[i]==v[N-1]){
 double ans=v[i]; ll cnt=0;
 int k=i; int Z=A;
 while(1){
	k--;
	if(v[k]!=v[i]) break;
	Z++;
 }
 if(Z>=B) for(int j=A;j<=B;j++) cnt+=comb(Z,j);
 else for(int j=A;j<=Z;j++) cnt+=comb(Z,j);
 printf("%.16f\n",ans);
 cout<<cnt<<endl;
 return 0;
}
else{
ll p=v[i];
int k=i; int X=1;
while(1){
	k++;
	if(v[k]!=p) break;
	X++;
}
int Z=X; //cout<<p<<endl;
k=i;
while(1){
	k--;
	if(v[k]!=p) break;
	X++;
}
ll cnt=0;
double ans=S/D; 
printf("%.16f\n",ans); //cout<<Z<<" "<<X<<endl;
cout<<comb(X,Z)<<endl;
}

return 0;
 
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int a[12],b[12],c;
main()
{
    while(cin>>c,c)
    {
        for(int i=0;i<12;i++)cin>>a[i]>>b[i];
        bool f=1;
        for(int i=0;i<12;i++)
        {
            c-=a[i]-b[i];
            if(c<=0)
            {
                cout<<i+1<<endl;
                f=0;
                break;
            }
        }
        if(f)cout<<"NA"<<endl;
    }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int R, C, N;
bool onPerimeter(int x, int y) {
	return (x == 0 || x == C) || (y == 0 || y == R);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	 
	cin >> C >> R >> N;

	vector<pii> top, right, bottom, left;

	F0R(i, N) {
		int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
		if (onPerimeter(x1, y1) && onPerimeter(x2, y2)) {
			for (pii point : vector<pii> {{x1, y1}, {x2, y2}}) {
				int x = point.first;
				int y = point.second;
				if (y == 0) {
					top.push_back({x, i});
				} else if (x == C) {
					right.push_back({y, i});
				} else if (y == R) {
					bottom.push_back({x, i});
				} else {
					left.push_back({y, i});
				}
			}
		}
	}
	sort(top.begin(), top.end());
	sort(right.begin(), right.end());
	sort(bottom.rbegin(), bottom.rend());
	sort(left.rbegin(), left.rend());

	vi everything;
	for (pii x : top) everything.push_back(x.second);
	for (pii x : right) everything.push_back(x.second);
	for (pii x : bottom) everything.push_back(x.second);
	for (pii x : left) everything.push_back(x.second);
	
	vi stack; 
	for (int x : everything) {
		if (stack.size() && stack.back() == x) {
			stack.pop_back();
		} else {
			stack.push_back(x);
		}
	}

	print((stack.size() == 0) ? "YES" : "NO");
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
int i,j,k,n,m,x,y,t,f[310][310][310],ans;
char s[310];
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	scanf("%d",&m);
	for (j=1;j<=n;j++)
		for (i=1;i<=n-j+1;i++)
			for (k=0;k<=m;k++)
				if (j==1)f[i][i][k]=1;
				else if (j==2)f[i][i+1][k]=(k||s[i]==s[i+1])?2:1;
				else{
					f[i][i+j-1][k]=max(f[i+1][i+j-1][k],f[i][i+j-2][k]);
					if (s[i]==s[i+j-1])f[i][i+j-1][k]=max(f[i][i+j-1][k],f[i+1][i+j-2][k]+2);
					else if (k)f[i][i+j-1][k]=max(f[i][i+j-1][k],f[i+1][i+j-2][k-1]+2);
				}
	for (i=0;i<=m;i++)ans=max(ans,f[1][n][i]);
	printf("%d\n",ans);
	return 0;
}

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


int main() {
ll N,K;
cin >> N >> K;
rep(i,INF) {
    if (N < pow(K,i)) {
        cout << i << endl;
        return 0;
    }
}



return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int n,a,i;
    long long int sum,max;
    scanf("%d",&n);
    scanf("%d",&a);
    max=a;
    sum=0;
    for(i=1;i<n;i++){
        scanf("%d",&a);
        if(max<a) max=a;
        else{
            sum+=max-a;
        }
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1736
s = input()
n = len(s)
MOD = 13
MOD2 = 10 ** 9 + 7

dp = [[0] * 13 for i in range(n + 1)]
dp[0][0] = 1
for i in range(n, ):
    keta = pow(10, n - i - 1, MOD)
    if s[i] == "?":
        for si in range(10):
            for j in range(MOD):
                dp[i + 1][(j + si * keta) % MOD] += dp[i][j]
                dp[i + 1][(j + si * keta) % MOD] %= MOD2
    else:
        for j in range(MOD):
            dp[i + 1][(j + int(s[i]) * keta) % MOD] += dp[i][j]
            dp[i + 1][(j + int(s[i]) * keta) % MOD] %= MOD2
print(dp[-1][5])

Measured memory_bytes: 62300
//***in the name of GOD***

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie();
#define sz(s) s.size()


int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if((i % 2) && (s[i] == 'R')){
      cout << "No";
      return 0;
    }
    if((i % 2 == 0) && (s[i] == 'L')){
        cout << "No";
        return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 384
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c=0,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,x);
  YES(a+b>=x && a<=x);
}

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

using namespace std;

int main(void) {
    int a, b, c;
    scanf("%d/%d/%d", &a, &b, &c);
    if (b < 4) {
        cout << "Heisei" << endl;

    } else if (b == 4 && c <= 30) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> w(n), s(n), v(n); for (int i = 0; i < n; ++i) cin >> w[i] >> s[i] >> v[i];
  V<> id(n);
  iota(begin(id), end(id), 0);
  sort(begin(id), end(id), [&](int i, int j) { return w[i] + s[i] < w[j] + s[j]; });
  int W = 20000;
  VV<lint> dp; assign(dp, n + 1, W + 1, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= W; ++j) {
      dp[i + 1][j] = dp[i][j];
      if (j >= w[id[i]] and j - w[id[i]] <= s[id[i]]) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[id[i]]] + v[id[i]]);
      }
      if (j > 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - 1]);
    }
  }
  cout << dp[n][W] << '\n';
}

Measured memory_bytes: 160512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  bool x;
  cin>>N>>M;
  vector<string>A(N),B(M);
  for(int i=0;i<N;i++)cin>>A.at(i);
  for(int i=0;i<M;i++)cin>>B.at(i);
  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      x=true;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(A.at(i+k).at(j+l)!=B.at(k).at(l)){
            x=false;
            break;
          }
        }
        if(!x)break;
      }
      if(x)break;
    }
    if(x)break;
  }
  if(x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}


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

#define MAX 100002

int n;

vector<int> v;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	int mx_val = INT_MAX;
	int mx_ich = -1;
	for (int i = 0; i + 1 < v.size(); i++) {
		int pos = v.back();
		pos++;
		pos /= 2;
		int ab = abs(pos - v[i]);
		if (mx_val > ab) {
			mx_val = ab;
			mx_ich = v[i];
		}
	}
	cout << v.back() << " " << mx_ich << endl;
	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i = 0 ,j,n,q,count = 0,left,right,mid;
  int *S,*T;

  scanf("%d",&n);

  S = (int *)malloc(sizeof(int) * n);

  for(i = 0 ; i < n ; i++)
    scanf("%d",&S[i]);

  scanf("%d",&q);

  T = (int *)malloc(sizeof(int) * q);

  for(i = 0 ; i < q ; i++)
    scanf("%d",&T[i]);

  for(j = 0 ; j < q ; j++){
      left = 0;
      right = n;
      while(left < right){
	mid = (left + right) / 2;
	if(S[mid] == T[j]){
	  count++;
	  break;
	}
	else if(T[j] < S[mid])
	  right = mid;
	else
	  left = mid + 1;
      }
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    for (int i = 0; i < n/2; ++i) {
        if (s[i] != s[n-i-1]) ans++;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
using namespace std;
vector<string>v;
ll n,m;
ll calc(ll i,ll j){
    if(i<0||j<0||i>=n||j>=m)
        return 0;
    if(v[i][j]=='#')
        return 1;
    return 0;
}
ll fun(ll i,ll j){
    ll ans=0;
    ans+=calc(i+1,j);
    ans+=calc(i-1,j);
    ans+=calc(i,j+1);
    ans+=calc(i,j-1);
    ans+=calc(i+1,j+1);
    ans+=calc(i+1,j-1);
    ans+=calc(i-1,j+1);
    ans+=calc(i-1,j-1);
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    string s;
    for(ll i=0;i<n;i++){
        cin>>s;
        v.pb(s);
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(v[i][j]=='#')
                continue;
            v[i][j]='0'+fun(i,j);
        }
        cout<<v[i]<<endl;
    }


    return 0;
}



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

using namespace std;

int main() {
  vector<int> v(3);
  vector<int> expected = { 5, 5, 7 };
  for (auto & n : v) cin >> n;
  sort(v.begin(), v.end());
  if (equal(v.begin(), v.end(), expected.begin())) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

int main() {
  char x;
  cin >> x;
  if(x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256