akhauriyash/Code-Regression huggingface dataset:
n = int(input())
L = [input().split() for _ in range(n)]
d = {}
for s, p in L:
    if s not in d.keys():
        d[s] = [int(p)]
    else:
        d[s].append(int(p))
for i, v in enumerate(L, start=1):
    v.append(i)
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        for k in range(n):
            if L[k][1] == str(d[i][d[i].index(j)]):
                print(L[k][2])


Measured memory_bytes: 3064
#2桁までなら9個
#4桁までなら9＋数-99
#6桁までなら9＋数-99+数-9999
n=int(input())
c = len(str(n))
#print(c)

if c == 1:
  print(n)
elif c == 2:
  print(9)
elif c == 3:
  print(9+n-99)
elif c == 4:
  print(9+900)
elif c == 5:
  print(9+900+n-9999)
else:
  print(9+900+90000)


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

int main(){
    using namespace std;

    constexpr unsigned long N{200000}, register_length{100}, reg{N - register_length + 1}, one_reg{reg - 1};

    unsigned long cnt{0};
    vector<unsigned long> sim(N);
    const auto& cmp = [&cnt, &sim](unsigned long i, unsigned long j, unsigned long k) -> void {
        cout << "< " << i << " " << j << " " << k << " ";
        ++cnt;
        sim[k] = static_cast<unsigned long>(sim[i] < sim[j]);
    };
    const auto& add = [&cnt, &sim](unsigned long i, unsigned long j, unsigned long k) -> void {
        cout << "+ " << i << " " << j << " " << k << " ";
        ++cnt;
        sim[k] = sim[i] + sim[j];
    };
    const auto& set_one = [&cmp, &add]() -> void {
        add(0, 1, one_reg);
        cmp(2, one_reg, one_reg);
    };
    const auto& bit_and_add = [&cmp, &add](unsigned long i, unsigned long j, unsigned long k) -> void {
        add(i, j, reg);
        cmp(one_reg, reg, reg + 1);
        add(k, reg + 1, k);
    };
    const auto& binary_mul = [&bit_and_add](unsigned long i, unsigned long i_len, unsigned long j, unsigned long j_len, unsigned long k) -> void {
        for(unsigned long i_ofs{0}; i_ofs < i_len; ++i_ofs)for(unsigned long j_ofs{0}; j_ofs < j_len; ++j_ofs)bit_and_add(i + i_ofs, j + j_ofs, k + i_ofs + j_ofs);
    };
    const auto& bin_to_int = [&add](unsigned long beg, unsigned long len, unsigned long k) -> void {
        for(unsigned long i{len}; i--; ) {
            if(i + 1 != len)add(k, k, k);
            add(beg + i, k, k);
        }
    };
    const auto& zero_clear = [&cmp](unsigned long i) -> void {
        cmp(i, i, i);
    };
    const auto& one_clear = [&cmp](unsigned long i) -> void {
        cmp(2, one_reg, i);
    };
    const auto& bit_shift = [&add](unsigned long i, unsigned long s) -> void {
        for(unsigned long itr{0}; itr < s; ++itr)add(i, i, i);
    };
    const auto& int_to_bin = [&sim, &bin_to_int, &bit_shift, &zero_clear, &one_clear, &cmp](unsigned long idx, unsigned long i, unsigned long len) -> void {
        one_clear(reg + 2);
        for(unsigned long itr{1}; itr <= len; ++itr){
            zero_clear(reg);
            one_clear(i + len - itr);
            bin_to_int(i + len - itr, itr, reg);
            bit_shift(reg, len - itr);
            cmp(idx, reg, reg + 1);
            cmp(reg + 1, reg + 2, i + len - itr);
        }
    };

    cout << 5733 << endl;
    sim[0] = 100;
    sim[1] = 1987;
    set_one();
    int_to_bin(0, 100, 30);
    int_to_bin(1, 200, 30);
    binary_mul(100, 30, 200, 30, 300);
    bin_to_int(300, 60, 2);
    cerr << sim[2] << " : " << cnt << endl;
    return 0;
}

Measured memory_bytes: 4640
def main():
    N = int(input())
    adj = []
    for i in range(N):
        adj.append(list(map(int, input().split())))
    mod = 10 ** 9 + 7

    state_list = [[] for _ in range(N + 1)]
    for state in range(2 ** N):
        one_num = 0
        for j in range(N):
            if state >> j & 1:
                one_num += 1
        state_list[one_num].append(state)

    dp = [0] * (2**N)
    dp[0] = 1
    for i in range(N):
        for j in range(N):
            if adj[i][j]:
                for state in state_list[i]:
                    state_new = state | (2**j)
                    if state != state_new:
                        dp[state_new] += dp[state]
                        if dp[state_new] >= mod:
                            dp[state_new] -= mod

    print(dp[-1])


if __name__ == '__main__':
    main()


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

int main(){
  int N,Y;
  cin>>N>>Y;
  int x,y,z;
  
  bool flg=false;
  for(x=0;x<=N;x++){
    for(y=0;y<=N-x;y++){
      //z=(Y-(10000*x+5000*y))/1000;
      //if((z>=0) && (x+y+z<=N)){
      z=N-(x+y);
      if((z>=0) && (10000*x+5000*y+1000*z==Y)){
        flg=true;
        break;
      }
    }
    if(flg){
      break;
    }
  }
  if(flg){
    cout<<x<<" "<<y<<" "<<z<<endl;
  }else{
    cout<<"-1 -1 -1"<<endl;
  }
  
  return 0;
}

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

typedef long long ll ;
int N ;
ll L[87];
int main ()
{
scanf("%d" ,&N );
L[0]=2L , L[1]=1L ;
for ( int i =2; i<=N ; i++) L[i]= L[i-2]+L[i-1];
printf("%lld\n" , L[N]);
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




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

	ll n;
	cin>>n;
	cout<<(1<<ll(log2(n)))<<"\n";

}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int end = s.size() - 2, mid = end/2;
    bool t;
    while(mid > 0){
        t = true;
        FOR(i,0,mid){
            if(s[i] != s[i+mid]){
                t = false;
            }
        }
        if(t){
            cout << end;
            break;
        }
        else
        {
            end -= 2;
            mid = end/2;
        }
        
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 200000
#define INFTY 1000000000

int L[MAX/2+2], R[MAX/2+2];
long long cnt=0;

void merge(int A[], int left, int mid, int right)
{
	int i, j, k;
	

	int n1 = mid-left;
	int n2 = right-mid;
	
	for(i=0; i<n1; i++)
	{
		L[i] = A[left+i];
	
	}
	
	for(i=0; i<n2; i++)
	{
		R[i] = A[mid+i];
	
	}
	
	L[n1] = INFTY;
	R[n2] = INFTY;
	
	i=0;
	j=0;
	
	for(k=left; k<right; k++)
	{
		if( L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			j++;
			cnt = cnt+n1-i;
		}
	}


}

void mergesort(int A[], int left, int right)
{
	int mid;
	
	if(left+1<right)
	{
	
		mid = (left+right)/2;
		mergesort(A, left, mid);
		mergesort(A, mid, right);
		merge(A, left, mid, right);
		
		
	}
	
	
}

int main(void)
{
	int n;
	
	scanf("%d", &n);
	
	int A[MAX];
	
	for(int i=0; i<n; i++)
	{
		scanf("%d", &A[i]);
	}
	
	mergesort(A, 0, n);
	
	printf("%lld\n",cnt);
	
	
	return 0;
}


Measured memory_bytes: 3304
import java.util.*

data class T(val c: Int, val s: String)

fun main(args: Array<String>) {
    val n = getInt()
    val m = HashMap<String, Int>()
    repeat(n) {
        val s = readLine()!!
        val c = if (m.containsKey(s)) m[s]!! else 0
        m[s] = c + 1
    }

    val a = ArrayList<T>()
    a.addAll(m.map { T(it.value, it.key) })
    a.sortBy { it.c }
    val num = a.last().c

    var i = a.size - 1
    val b = ArrayList<String>()
    while (i >= 0) {
        if (a[i].c == num) b.add(a[i].s)
        else break
        i--
    }
    b.sort()
    b.forEach { println(it) }
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 87840
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

ll N;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> N;
    //important idea a vertice of a tree by itself adds exactly 1 disconnected component
    //and an edge of a tree is essential so it takes 2 disconnected components and turns them into one
    //count the number of ranges each vertice is included in - (number of ranges each edge is contained in)
    ll vranges = 0;
    for(int i=1; i<=N; i++) {
        //pick left then pick right
        ll left = i;
        ll right = (N-i)+1;
        vranges+=(left*right);
    }
    ll eranges = 0;
    for(int i=0; i<N-1; i++) {
        int v,u;
        cin >> v >> u;
        int l = min(u,v);
        int r = max(u,v);
        ll left = l;
        ll right = (N-r)+1;
        eranges+=(left*right);
    }
    cout << (vranges-eranges) << "\n";
    
    return 0;
}


Measured memory_bytes: 3624
/**
 *    author:  tourist
 *    created: 29.09.2018 15:26:49       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int,int> mp[2];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[i & 1][x]++;
  }
  vector<pair<int,int>> v[2];
  for (int u = 0; u < 2; u++) {
    for (auto &p : mp[u]) {
      v[u].emplace_back(p.second, p.first);
    }
    if (v[u].size() == 1) {
      v[u].emplace_back(0, -1);
    }
    sort(v[u].rbegin(), v[u].rend());
  }
  int ans = 0;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (v[0][i].second != v[1][j].second) {
        ans = max(ans, v[0][i].first + v[1][j].first);
      }
    }
  }
  cout << n - ans << '\n';
  return 0;
}


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

int main() {
    using namespace std;

    string a, b;
    cin >> a >> b;

    string s = a + b;

    int n = stoi(s);

    int count = 0;
    do {

        if (count * count == n) {
            cout << "Yes" << endl;
            return 0;
        }

        count++;
    } while(count * count <= n);
    

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

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

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

T = list(input())
N = len(T)
alta = []
for i in range(N):
    if T[i] == "?":
        alta.append('D')
    else:
        alta.append(T[i])
print(''.join(alta))

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

struct edge {int to, cost;};
typedef pair<int, int> P;
const int INF=1000000000;

int main() {
    int V, E, s, d[100005];
    cin >> V >> E >> s;
    vector<vector<edge> > g(V);
    for(int i=0; i<E; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        edge ee={b, c};
        g[a].push_back(ee);
    }

    priority_queue<P, vector<P>, greater<P> > pq;
    fill(d, d+V, INF);
    d[s]=0;
    pq.push(P(0, s));

    while(!(pq.empty())) {
        P p=pq.top();
        pq.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0; i<g[v].size(); i++) {
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost) {
                d[e.to]=d[v]+e.cost;
                pq.push(P(d[e.to],e.to));
            }
        }
    }
    for(int i=0; i<V; i++) {
        if(d[i]==INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }





}


Measured memory_bytes: 12904
#include <stdio.h>
     
    int main(void)
    {  
       int ans,i,j,n,d,x;
       int a[100];
     
       scanf("%d",&n);
       scanf("%d%d",&d,&x);
          ans=x;
       for(i=0;i<n;i++)
          scanf("%d",&a[i]);
       
       for(i=0;i<n;i++){
          for(j=0;j<d;j=j+a[i])
                ans++;
       }     
       
        printf("%d\n",ans);
     
       return 0;
    }


Measured memory_bytes: 128
n,k = map(int,input().split())

A = list(map(int,input().split()))
t = 0
c = 0
ans = [0] * n
L = []
s = 0
for _ in range(k):
    if ans[t] == 1:
        n = len(L) - L.index(t)
        temp = (k-c)%n
        t = L[L.index(t):][temp]
        break
    else:
        ans[t] = 1
        L.append(t)
        t = A[t]-1
        c += 1
print(t+1)

Measured memory_bytes: 32376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e6+10;
int n,m;
int num[maxx];
VI G[maxx];
int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n+1){
		scanf("%d",&num[i]);
	}
	rep(i,0,m){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].pb(b);
		G[b].pb(a);
	}
	int cnt=0;
	rep(i,1,n+1){
		int flag=0;
		rep(j,0,SZ( G[i] ) ){
			int t=G[i][j];
			if(num[i]<=num[t]){
				flag=1;
				break;
			}
		}
		if(!flag){
			cnt++;
		}
	}
	cout<<cnt;
} 

Measured memory_bytes: 30260
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  REP(i, a) cin >> p[i];
  REP(i, b) cin >> q[i];
  REP(i, c) cin >> r[i];
  vector<P> pqr;
  REP(i, a) pqr.push_back(make_pair(p[i], 0));
  REP(i, b) pqr.push_back(make_pair(q[i], 1));
  REP(i, c) pqr.push_back(make_pair(r[i], 2));
  sort(all(pqr));
  reverse(all(pqr));
  ll ans = 0;
  int CX = 0, CY = 0, CM = 0;
  int it = 0;
  while (CM<x+y) {
    if(pqr[it].second==0) {
      if(CX<x) {
        ans += pqr[it].first;
        CX++; CM++;
      }
    }else if(pqr[it].second==1) {
      if(CY<y) {
        ans += pqr[it].first;
        CY++; CM++;
      }
    }else {
      ans += pqr[it].first;
      CM++;
    }
    it++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll x;
    cin >> x;
    ll k = 1;
    while((x*k)%360 != 0){
        k++;
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 3508
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

ll gcd(ll a,ll b){
	ll p;
	if (b > a){
		p = a;
		a = b;
		b = p;
	}
	while(b != 0){
		p = a % b;
		a = b;
		b = p;
	}
	return a;
}

int main(){
	ll N;
	cin >> N;
	ll c[N];

	ll ret = 0;
	ll sign = 0;
	ll mina = 1000000000;

	REP(i,N) {
		cin >> c[i];
		if (c[i] < 0) sign++;
		ret += abs(c[i]);
		mina = min(mina,abs(c[i]));
	}

	if(sign%2 == 1){
		ret -= mina*2;
	}


	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

template <typename T> T gcd(T x, T y) { return( y ? gcd(y, x % y) : x); }
template <typename T> T lcm(T x, T y) { return( x / gcd(x, y) * y); }
template <typename T> void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector <ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  ll bak = 1;
  for(int i = 0; i < n; i++) {
    ans = ans * a[i];

    if (bak > ans || ans > 1000000000000000000)  {
      cout << -1  << endl;
      return 0;
    } 
    bak = ans;
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    vector<Int> digits(10, 0);
    string S; cin >> S;

    bool res = true;
    if (S[0] == S[1] or S[1] == S[2] or S[2] == S[3])
        res = false;

    cout << (res ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a, b, c, poi = 1, count =0;
    if(scanf("%d %d %d", &a, &b, &c) ==1){};
    
    while(1){
	
	if (c>0){
	    count +=1;
	    c-= 1;
	    poi = 0;
	}
	if(b>0){
	    count +=1;
	    b -= 1;
	    poi = 1;
	}
	else if (a>0 && poi ==0){
	    a -= 1;
	    poi = 1;
	}
	else {
	    if (poi==1 && c>0) count +=1;
	    break;
	}
    }
    printf("%d\n", count);
    return 0;
}

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

int dp[502][2][10][500][3], m, len[2];
char S[2][550];

inline int solve(int o) {
	memset(dp,0,sizeof(dp));
    dp[0][0][0][0][0] = 1;
    rep(i, len[o])rep(j, 2)rep(k, 10)rep(l, m)rep(d, 3) {
        if (dp[i][j][k][l][d] == 0)continue;
        int s, g, p = S[o][i] - '0';
        if (d == 1) { s = k + 1; g = (j ? 9 : p); }
        else if (d == 2) { s = 0; g = (j ? k - 1 : min(k - 1, p)); }
        else { s = 0; g = (j ? 9 : p); }
        for (int x = s; x <= g; x++) {
            if (x&&k == x)continue;
            int y;
            if (d == 1)y = 2;
            else if (d == 2)y = 1;
            else {
                if (k == 0)y = 0;
                else if (x < k)y = 1;
                else y = 2;
            }
            (dp[i + 1][j || x < p][x][(l * 10 + x) % m][y] += dp[i][j][k][l][d]) %= MOD;
        }
    }
    int sum=0;
    rep(j,10)rep(t,3){
    	(sum+=dp[len[o]][1][j][0][t])%=MOD;
    	if(o)(sum+=dp[len[o]][0][j][0][t])%=MOD;
    }
    return sum;
}
int main() {
    scanf("%s%s%d", S[0], S[1], &m);
    rep(i, 2)len[i] = strlen(S[i]);
    printf("%d\n", (solve(1) + MOD - solve(0)) % MOD);
}

Measured memory_bytes: 62036
import java.util.Scanner;
public class Main
{
  	public static void main(String[] args)
    {
     	Scanner sc = new Scanner(System.in);
      	long a = sc.nextLong();
      	
      	long result = a * (a + 1) / 2;
      	long san = 3 * (a / 3) * (a / 3 + 1) / 2;
      	long go = 5 * (a / 5) * (a / 5 + 1) / 2;
      	long juugo = 15 * (a / 15) * (a / 15 + 1) / 2;
      	
      	System.out.println(result - san - go + juugo);
    }
}

Measured memory_bytes: 35884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

ll p;
vector<vector<ll>> nCk(3000, vector<ll>(3000, 0));

void calc_nCk() {
  nCk[0][0] = 1;
  for (int i = 1; i < p; i++) {
    for (int j = 0; j <= i; j++) {
      ll l = 0, r = 0;
      if (j > 0) l = nCk[i - 1][j - 1];
      if (j < i) r = nCk[i - 1][j - 0];
      nCk[i][j] = (l + r) % p;
    }
  }
  return;
}

int main() {
  cin >> p;

  vector<ll> a(p);
  for (int i = 0; i < p; i++) {
    cin >> a[i];
  }
  calc_nCk();

  vector<ll> b(p, 0);
  for (int i = 0; i < p; i++) {
    if (a[i] > 0) {
      ll powi = 1;
      b[0]++;

      ll temp;
      for (int j = 0; j < p; j++) {
        temp = nCk[p - 1][j];
        temp = (temp * powi) % p;
        if (j % 2 == 0) temp = -temp;
        b[p - 1 - j] = (b[p - 1 - j] + temp) % p;
        powi = (powi * i) % p;
      }
    }
  }
  for (int i = 0; i < p; i++) {
    cout << (b[i] + p) % p << SP;
  }

  return 0;
}

Measured memory_bytes: 70784
#include<stdio.h>

int main(void) {
	int N, L,*apple;
	int i,sum=0;
	scanf("%d%d", &N, &L);

	apple = (int)malloc(sizeof(int)*(N+1));

	for (i = 1; i <= N; i++) {
		apple[i] = L + i - 1;
	}
	if (L >= 0) {
		for (i = 2; i <= N; i++) {
			sum += apple[i];
		}
	}
	else if(L<0&&(L+N)>0){
		for (i = 1; i <= N; i++) {
			if (apple[i] != 0) {
				sum += apple[i];
			}
		}
	}
	else if (L < 0 && (L + N) <= 0) {
		for (i = 1; i < N; i++) {
				sum += apple[i];
		}
	}
	printf("%d\n", sum);
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n, 0);
    
    int runs = 0;
    vector<int> v;

    for(int i = 0; i < n; ++i) {
        cin >> p[i];
        if(p[i] == i + 1) {
            runs += 1;
        } else {
            v.push_back(runs);
            runs = 0;
        }
    }

    if(runs > 0) {
        v.push_back(runs);
    }
    
    int ans = 0;

    for(auto val : v) {
        ans += val / 2 + val % 2;
    }

    cout << ans << "\n";
}

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

#define lol long long
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol abs(lol x){return(x<0?-x:x);}
lol n,m,k,r;
int x[500010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>n>>m;
  if(n<=m) cout <<"unsafe\n";
  else cout <<"safe\n";
  return (0);
}


Measured memory_bytes: 3652
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n-1)]
c=[[] for i in range(n)]
for i in range(n-1):
  c[l[i][0]-1].append(l[i][1]-1)
  c[l[i][1]-1].append(l[i][0]-1)

l2=[list(map(int,input().split())) for i in range(q)]
L4=[0]*n
for i in range(q):
  L4[l2[i][0]-1]+=l2[i][1]
ans=[0]*n
ans[0]=L4[0]

L=[0]
L2=[]
L22=[-1]*n
L3=[]
while len(L2)!=n and len(L)!=0:
  for j in range(len(L)):
    x=L[j]
    L22[x]=1
    for k in range(len(c[x])):
      if L22[c[x][k]]==-1:
        ans[c[x][k]]=ans[x]+L4[c[x][k]]
        L3.append(c[x][k])
  L=L3
  L3=[]
for i in range(n):
  print(ans[i])

Measured memory_bytes: 128672
#include<bits/stdc++.h>
using namespace std;
#define int long long 

char s[110][110];
int dp[110][110];

const int inf = 1000;

signed main(void){
  int h,w; cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){ 
      cin >> s[i][j];
      dp[i][j] = inf;
    }
  }
  
  dp[0][0] = 0;
  
  for(int x = 0; x < h; x++){
    for(int y = 0; y < w; y++){ 
      
      if( x+1 < h ){
        
        int c = (s[x+1][y] == '#' && s[x][y] == '.');
        
        dp[x+1][y] = min(dp[x+1][y],dp[x][y]+c);
      }
      
      if( y+1 < w ){ 
        
        int d = (s[x][y+1] == '#' && s[x][y] == '.');
        
        dp[x][y+1] = min(dp[x][y+1],dp[x][y]+d);
        
      }
    }
  }
  
  int r = ( s[0][0] == '#' );
  
  cout << dp[h-1][w-1]+r << endl;
  
  return 0;
} 
    

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
  int i,j;
  int n;
  cin>>n;
  int x[n];
  int sum=0;
  for(i=0;i<n;i++){
    cin>>x[i];
    sum+=x[i];
  }
  sum/=n;
  int sum2=sum+1;
  ll ans=0;
  ll ans2=0;
  for(i=0;i<n;i++) {
    ans+=(x[i]-sum)*(x[i]-sum);
    ans2+=(x[i]-sum2)*(x[i]-sum2);
  }
  cout<<min(ans,ans2)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    int ap=0,zp=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            ap=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z'){
            zp=i;
            break;
        }
    }

    cout << zp-ap+1 << endl;

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    ll prev = 0;
    map<ll, ll> B;
    ll count = 0;
    cin >> N >> M;
    B[0]++;
    rep(i, N) {
        ll temp;
        cin >> temp;
        temp += prev;
        B[temp % M]++;
        prev = temp;
    }
    iter(i, B) count += i.second * (i.second - 1) / 2;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4224
def solve():
    a, b, c = map(int, input().split())
    if a == b == c:
        ans = "1"
    elif a != b == c:
        ans = "2"
    elif a == b != c:
        ans = "2"
    elif a == c != b:
        ans = "2"
    elif a != b != c:
        ans = "3"

    print(ans)

if __name__ == '__main__':
    solve()



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int N;
int C[501], S[501], F[501];
int main() {
	cin >> N;
	rep(i, N) cin >> C[i] >> S[i] >> F[i];

	int Min[501];
	//0秒後にiからスタートしてN-1に行く最小タイム
	rep(i, N) {
		Min[i] = 0;
		for (int j = i;j<N - 1;j++) {
			if (Min[i] <= S[j]) Min[i] = S[j] + C[j];
			else Min[i] = ((Min[i] - 1) / F[j]+1)*F[j] + C[j];
		}
	}
	rep(i, N) cout << Min[i] << " ";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

A,B,C,D = inputIL()

if A+B == C+D:
  print("Balanced")
elif A+B>C+D:
  print("Left")
else:
  print("Right")


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

int main() {
	long a, b, c, x, y;

	long an, bm, cl;
	long min = 9999999999999;
	long cost1, cost2, cost3;
	vector<long> cost;
	cost.resize(3);
	cin >> a >> b >> c >> x >> y;

	// 1. A と Bのみ買う

	cost[0] = a * x + b * y;

	// 2. C を出きるだけ買って、残りをA、Bで買う

	if (x >= y) {
		cost[1] = 2 * c * y + a * (x - y);
	}
	else {
		cost[1] = 2 * c * x + b * (y - x);
	}

	// 3. Cのみ買う

	if (x >= y) {
		cost[2] = 2 * c * x;
	}
	else {
		cost[2] = 2 * c * y;
	}

	for (int i = 0; i < cost.size(); i++) {
		if (cost[i] < min) {
			min = cost[i];
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n_m = lines.next().unwrap().unwrap();
    let mut n_m = n_m.split_whitespace();
    let n: i64 = n_m.next().unwrap().parse().unwrap();
    let m: i64 = n_m.next().unwrap().parse().unwrap();
    let a = lines.next().unwrap().unwrap();
    let a: Vec<i64> = a.split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut even = false;
    let mut odd = false;

    let mut multiple = 1;
    for &num in a.iter() {
        let num = num / 2;
        if num % 2 == 0 {
            even = true;
        } else {
            odd = true;
        }
        if even && odd {
            println!("0");
            return;
        }
        multiple = lcm(multiple, num);
        if multiple > m || multiple / num % 2 == 0 {
            println!("0");
            return;
        }
    }

    let ans = (m + multiple) / (2 * multiple);
    println!("{}", ans);
}

fn gcd(a: i64, b: i64) -> i64 {
    let mut t = (a, b);
    while t.1 != 0 {
        t = (t.1, t.0 % t.1);
    }
    t.0
}

fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}


Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	ll n;
	cin >> n;
	ll j = 1,ans=1;
	
	for (ll i = 1; i < n; i++) {
		j = i * i;
		if (j <= n) {
			ans = j;
		}
		else {
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll lcm(ll x, ll y)
{
    return (x*y)/__gcd(x,y);
}
int sum(string s)
{
    int x=0,sz=s.size();
    loop(i,0,sz)x+=(s[i]-'0');
    return x;
}

int main()
{
    mego
vector<ll> q1,q2;
int n,m,k,x;
cin>>n>>m>>k;
loop(i,0,n)
{
    cin>>x;
    q1.pb(x);
}
loop(i,0,m){cin>>x;q2.pb(x);}
int ans=0;
//cout<<q1.front()<<" "<<q2.front()<<endl;

x=0;
loop(i,1,n)
q1[i]+=q1[i-1];
loop(i,0,m+1)
{
    if(x>k)break;
    int st=i+(upper_bound(q1.begin(),q1.end(),k-x)-q1.begin());
    ans=max(ans,st);
   if(i<m) x+=q2[i];

}

cout<<ans;
    return 0;
}
//greedy won't work on corner cases like
/*
2 2 11
11 2
10 1
greedy:11
optimal:10,1
*/


Measured memory_bytes: 7864
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
  ll n,k;
  cin >> n >> k;
  int cnt=0;
  while(n){
    n/=k;
    cnt++;
  }
  cout<<cnt<<endl;


}






Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():
    for x in range(N-M+1):
        for y in range(N-M+1):
            match = True
            for r in range(M):
                if not all(A[r+x][c+y] == B[r][c] for c in range(M)):
                    match = False
                    break
            if match:
                return "Yes"

    return "No"
print(check())



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

int main(){
  int a,b;
  cin>>a>>b;
  int h=100;
  int w=100;
  vector<vector<char> > g(h,vector<char>(w));
  for(int i=0;i<h/2;i++){
    for(int j=0;j<w;j++)g[i][j]='#';
  }

  for(int i=h/2;i<h;i++){
    for(int j=0;j<w;j++)g[i][j]='.';
  }

  //aaaaaaa
  int k=0;
  for(int i=0;i<h/2;i+=2){
    for(int j=0;j<w;j+=2){
      if(k==a-1)break;
      k++;
      g[i][j]='.';
    }
  }

  k=0;
  for(int i=h/2;i<h;i+=2){
    for(int j=0;j<w;j+=2){
      if(k==b-1)break;
      k++;
      g[i+1][j]='#';
    }
  }

  //aaaaaaa

  cout<<h<<" "<<w<<endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<g[i][j];
    }
    cout<<endl;
  }

}


Measured memory_bytes: 256
s = input() + "R"
ans = [0] * (len(s) - 1)
f = "R"
cnt = 0
for i, j in enumerate(s):
    if f == "R":
        if j == "L":
            ans[i - 1] += (cnt + 1) // 2
            ans[i] += cnt // 2
            f = "L"
            cnt = 0
            tmp = i
    if f == "L":
        if j == "R":
            ans[tmp] += (cnt + 1) // 2
            ans[tmp - 1] += cnt // 2
            f = "R"
            cnt = 0
    cnt += 1
print(*ans)


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int k;
    cin >> k;
    int a,b;
    cin >> a >>b;
    bool ok = false;
    for(int i=a;i<=b;i++){
        if(i%k == 0) ok = true;
    }
    if(ok) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long 




int main(){ 
      int a,b;
      cin >>a>>b;
      if(a<=5){
            cout<<0<<endl;
      }else if(a<13){
            cout<<b/2<<endl;
      }else{
            cout<<b<<endl;
      }
}

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

string expr;
int p,s,l;
char ans;

int parseInt()
{
	int ret=0;
	while(p<expr.size())
	{
		if(!isdigit(expr[p])) break;
		ret*=10;
		ret+=expr[p]-'0';
		p++;
	}
	
	return ret;
}

string parseStr()
{
	string ret;
	while(p<expr.size())
	{
		if(!isupper(expr[p])) break;
		ret+=expr[p];
		p++;
	}
	
	return ret;
}

bool parse()
{
	int lp=parseInt(), tp=p;
	string str;
	if(expr[p]=='(')
	{
		int ts=s;
		for(int i=0; i<lp; i++)
		{
			p=tp;
			p++;
			if(parse()) return true;
			if(i==0 && s+(s-ts)*(lp-1) < l)
			{
				s+=(s-ts)*(lp-1);
				break;
			}
		}
		p++;
	}
	else
	{
		if(lp==0) lp++;
		str=parseStr();
		

		if(s+str.size()*lp > l)
		{
			int ex=(l-s+str.size()*lp)%(str.size());
			ans=str[ex];
			return true;
		}
		s+=str.size()*lp;
		
	}

	if(p<expr.size() && expr[p]!=')') return parse();
	return false;
}

int main()
{
	while(cin >> expr >> l, (expr!="0"||l))
	{
		p=0; s=0; ans='0';
		
		parse();
		printf("%c\n", ans);
	}
}

Measured memory_bytes: 932
#include<stdio.h>
#include<math.h>
int main()
{
    long long int a,b,n,c;
    scanf("%lld",&n);
    for(a=sqrt(n);a>0;a--)
    {
        if(n%a==0)
        {
            b=n/a;
            break;
        }
    }
    printf("%lld",a+b-2);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;

  double ans = (double)(ceil(n, 2))/n;
  printf("%.16f\n", ans);
  return 0;
}

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

namespace atcoderBeginnerContest134
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] info = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            int c = info[0]/ (2 * info[1] + 1);
            int r = info[0] % (2 * info[1] + 1);
            c += r > 0 ? 1 : 0;
            Console.WriteLine(c);
        }
    }
}


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

int main() {
    int A,B;
    cin>>A>>B;
    int total=A;
    if(B==1){
        cout<<0;
        return 0;
    }
    for(int i=1;i<=500;i++){
        if(total>=B){
            cout<<i;
            break;
        }
        total+=(A-1);
    }
	return 0;
}

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

public class Solution
{
    public static void Swap<T>(ref T lhs, ref T rhs)
    {
        T temp = lhs;
        lhs = rhs;
        rhs = temp;
    }

    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ordered = p.OrderBy(v => v).ToArray();

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                Swap(ref p[i], ref p[j]);
                if (p.SequenceEqual(ordered))
                {
                    Console.WriteLine("YES");
                    return;
                }
                Swap(ref p[i], ref p[j]);
            }
        }

        Console.WriteLine("NO");
    }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  
  string st;
  int count;
  int max = 0;
  
  for (int i = 0; i < N; i++) {
    st = blue.at(i);
    count = 0;
    
    for (int i = 0; i < N; i++){
      if (st == blue.at(i)){
        count++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (st == red.at(i)){
        count--;
      }
    }
    
    if (count > max){
      max = count;
    }
  }
  
  cout << max << endl;
}


Measured memory_bytes: 3636
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a - c) <= d ||(Math.abs(a - b) <= d && Math.abs(b - c) <= d) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
import sys

N = input()
list1 = list(map(int, input().split()))
answer = 1
for i in list1:
    if i == 0:
        print(0)
        sys.exit()
for i in list1:
    answer *= i
    if answer > 10**18:
        print(-1)
        sys.exit()
print(answer)

Measured memory_bytes: 21624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int c = i;
		int ket = 0;
		while (c != 0) {
			ket += c % 10;
			c /= 10;
		}
		if (a <= ket && ket <= b) ans += i;
	}

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


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let v: Vec<i32> = s.split_whitespace().map(|n| n.parse().ok().unwrap()).collect();
    let a = v[0];
    let b = v[1];
    let s = a-1;
    let t = b-1;
    let mut r: i32 = 0;
    let mut o: i32 = 1;
    while o < b {
        o += a-1;
        r += 1;
    }
    println!("{}", r);
}

Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc126/tasks/abc126_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, t, cnt;
    cin >> n >> k;
    long double ans = 0;
    for (int i = 1; i <= n; i++) {
        t = i;
        cnt = 0;
        while (t < k) {
            t = t << 1;
            cnt++;
        }
        ans += 1.0 / (1 << cnt);
    }
    cout << setprecision(9) << ans / n << endl;

    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;

    if(0 < A && 0 < B && A < 10 && B < 10){
        cout << A * B << endl;
    }
    else{
        cout << "-1" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    string s;
    cin>>s;

    reverse(all(s));
    int m = 2019;
    vector<int> count(m,0);
    int t = 0;
    int x = 1;
    int ans = 0;
    rep(i,0,s.length())
    {   
        count[t]++;
        t += (s[i]-'0')*x;
        t %= m;
        ans += count[t];
        x = x*10 % m;
    }

    cout<<ans<<endl;

}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3760
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	int n,k;
	cin >> n >> k;
	
	vint a(n);
	REP(i,n) cin >> a[i];
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	REP(i,k) ans += a[i];
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 3628