akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    String S = sc.next();
    StringBuffer sb = new StringBuffer(S);
    S = sb.reverse().toString();
    String[] T = S.split("");
    long C = 0;
    long BC = 0;
    long ABC = 0;
    long AB = 1;
    long X = 1;
    for (String i: T){
      if ("?".equals(i)) {
        ABC = (ABC * 3 + BC) % 1000000007;
        BC = (BC * 3 + C) % 1000000007;
        C = (C * 3 + X) % 1000000007;
        X = (X * 3) % 1000000007;
      } else if ("C".equals(i)) {
        AB = 0;
        C += X;
      } else if ("B".equals(i)) {
        BC += C;
      } else if ("A".equals(i)) {
        ABC += BC;
      }
 	}
  	System.out.println(ABC % 1000000007);
  }
}


Measured memory_bytes: 32584
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    vector<ll> v;
    rep (i, 3) {
        ll tmp;
        cin >> tmp;
        v.pb(tmp);
    }
    ll cnt = 0;
    while (!(v[0] == v[1] && v[1] == v[2])) {
        sort(all(v));
        if (v[0] == v[1]) {
            v[0] += 1;
            v[1] += 1;
        } else {
            v[0] += 2;
        }
        ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> D(n + 1);
  cin >> D[0];
  V<> d(n);
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    D[i + 1] = min(abs(D[i] - d[i]), D[i]);
  }

  V<> a(n);
  a[n - 1] = 1;
  for (int i = n - 1; i > 0; --i) {
    a[i - 1] = 2 * a[i] <= d[i] ? a[i] : d[i] + a[i];
  }

  int q; cin >> q;
  while (q--) {
    int i; cin >> i, --i;
    cout << (a[i] <= D[i] ? "YES\n" : "NO\n");
  }
}

Measured memory_bytes: 7808
A,B,K=list(map(int,input().split()))
numbers=[]
for i in range(K):
    if A+i not in numbers and A+i<=B:
        numbers.append(A+i)
for i in range(K):
    if B-i not in numbers and B-i>=A:
        numbers.append(B-i)
numbers.sort()
for number in numbers:
    print(number)

Measured memory_bytes: 3060
import static java.lang.System.*;
import java.util.*;

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

        int n = sc.nextInt();
		int q = sc.nextInt();
		
		String s = sc.next();
		int[] count = new int[n];
		Arrays.fill(count, 0);
		for(int i=1; i<n; i++) {
			if(s.charAt(i-1) == 'A' && s.charAt(i) == 'C') count[i] = count[i-1] + 1;
			else count[i] = count[i-1];
		}
		
		for(int i=0; i<q; i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			
			out.println(count[r]-count[l]);
		}
	}
}

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

using namespace std;
using ll = long long;



int main() {
    vector<ll> R;

    stack<pair<int, string>> st;
    int l = 1;
    while(R.size() < 100000) {
        for(int i = 9; i > 0; i--) {
            st.push(make_pair(l, to_string(i)));
        }
        while(!st.empty()) {
            auto p = st.top();
            st.pop();
            string s = p.second;
            if((int) s.size() == p.first) {
                R.push_back(stoll(s));
                if(R.size() == 100000) break;
                continue;
            }
            int c = s[s.length() - 1] - '0';
            for(int i = c + 1; i >= c - 1; i--) {
                if(i < 0 || i > 9) continue;
                st.push(make_pair(p.first, s + to_string(i)));
            }
        }
        l++;
    }
    int K;
    cin >> K;
    cout << R[K - 1] << endl;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	int v[n], c[n];
	FOR(n) cin >> v[i];
	FOR(n) cin >> c[i];
	int ans = 0;
	FOR(n) if(v[i] > c[i]) ans += v[i] - c[i];
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

#define INF 1.0e9

long long cnt = 0;

void merge(vector<int> &A, int left, int mid, int right){
    int n1 = mid-left;
    int n2 = right - mid;
    vector<int> L(n1+1,0);
    for(int i=0; i<n1; ++i){
        L[i] = A[left+i];
    }
    vector<int> R(n2+1,0);
    for(int i=0; i<n2; ++i){
        R[i] = A[mid+i];
    }
    L[n1] = INF;
    R[n2] = INF;
    int i=0;
    int j=0;
    for(int k=left; k<right; ++k){
        if( L[i] < R[j] ){
            A[k] = L[i];
            ++i;

        }else{
            A[k] = R[j];
            ++j;
            cnt+=n1-i;
        }
    }
    return;
}

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

    return;
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n,0);
    for(auto&& x : A){
        cin >> x;
    }

    mergesort(A,0,n);

    cout << cnt << endl;

}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=505;
int n,a[Maxn][Maxn];
LL dp[Maxn][Maxn];
LL S1[Maxn][Maxn],S2[Maxn][Maxn];
LL Q1(int x1,int x2,int y1,int y2){
	if (x1>x2 ||y1>y2) return 0;
	return S1[x2][y2]-S1[x1-1][y2]-S1[x2][y1-1]+S1[x1-1][y1-1];
}
LL Q2(int x1,int x2,int y1,int y2){
	if (x1>x2 || y1>y2) return 0;
	return S2[x2][y2]-S2[x1-1][y2]-S2[x2][y1-1]+S2[x1-1][y1-1];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (i==j) continue;
			scanf("%d",&a[i][j]);
			if (i<j){
				S1[i][j]=a[i][j];
			}
			else{
				S2[i][j]=a[i][j];
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			S1[i][j]+=S1[i-1][j]+S1[i][j-1]-S1[i-1][j-1]; 
			S2[i][j]+=S2[i-1][j]+S2[i][j-1]-S2[i-1][j-1]; 
		}
	}
	for (int i=0;i<Maxn;i++){
		for (int j=0;j<Maxn;j++){
			dp[i][j]=1e18;
		}
	}
	LL ans=1e18;
	for (int i=1;i<=n;i++){
		dp[i][0]=Q1(1,i,1,i);
	}
	//cout<<S1[3][3]<<' '<<S2[3][3]<<endl;
	//cout<<Q1(1,3,1,3)<<" "<<Q2(1,3,1,3)<<endl;
	for (int i=2;i<=n;i++){
		for (int j=1;j<i;j++){
			for (int k=0;k<j;k++){
				if (dp[j][k]==1e18) continue;
				dp[i][j]=min(dp[i][j],dp[j][k]+Q1(j+1,i,j+1,i)+Q2(j+1,i,1,k));
			}
		//	cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
		}
	}
	ans=Q1(1,n,1,n);
	for (int i=1;i<=n;i++){
		for (int j=0;j<i;j++){
			ans=min(ans,dp[i][j]+Q1(i+1,n,i+1,n)+Q2(i+1,n,1,j));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7296
#062-A
par=[]
rank=[]
def init(a): #初期化
    for i in range(a):
        par.append(i)
        rank.append(0)
def find(x): #根を見つける
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
    return par[x]
def unite(x,y): #併合
    x=find(x)
    y=find(y)
    if rank[x]==rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1
    return
def same(x,y): #同じ集合か判定
    return find(x)==find(y)

init(12)
unite(0,2)
unite(0,4)
unite(0,6)
unite(0,7)
unite(0,9)
unite(0,11)
unite(3,5)
unite(3,8)
unite(3,10)

x,y=map(int,input().split())
print('Yes' if same(x-1,y-1) else 'No')

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int max_L = 0;
  int min_R = 10e6;
  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    
    max_L = max(L, max_L);
    min_R = min(R, min_R);
  }
  
  int ans = 0;
  if (min_R - max_L < 0) {
    ans = 0;
  } else {
    ans = min_R - max_L + 1;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a, $b);
$result = '';
if ($a === $b) {
    for ($i = 0; $i < $a; $i ++) {
        $result .= $b;
    }
} elseif ($a < $b) {
    for ($i = 0; $i < $b; $i ++) {
        $result .= $a;
    }
} else {
    for ($i = 0; $i < $a; $i ++) {
        $result .= $b;
    }
}
echo $result;

Measured memory_bytes: 3828
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
c = collections.Counter(prime_factorize(n))
ans = 0


for l in c.items():
    x = l[1]
    y = 1
    z = 0
    for i in range(1,x+1):
        z += 1 #同じ数のカウンター
        if z > y+1:
            z = 1
            y += 1
    ans += y

print(ans)


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

int main()
{
    int d[300000];
    int alphabet_max = 26;
    long long N;
    const long long MOD = 1000000007;
    cin >> N;
    string S;
    cin >> S;
    long long kosuu[26];
    for (int i = 0; i < alphabet_max; i++)
    {
        kosuu[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (S.at(j) == 'a' + i)
            {
                kosuu[i]++;
            }
        }
        kosuu[i]++;
    }
    long long ans = 1;
    for (int i = 0; i < alphabet_max; i++)
    {
        ans *= kosuu[i];
        ans %= MOD;
    }
    if (ans == 0)
    {
        cout << MOD - 1 << endl;
        return 0;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repl(i, a, b) for (ll i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = b; i >= (a); --i)
#define repdl(i, a, b) for (ll i = b; i >= (a); --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1'000'000'007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll dp[1000005][2][2];
int main() {
  IOS;
  int n; cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  dp[1][0][0] = 8, dp[1][0][1] = dp[1][1][0] = 1;
  for (int i = 2; i <= n; i++) {
    dp[i][0][0] = dp[i - 1][0][0] * 8 % MOD;
    dp[i][1][0] = (dp[i - 1][0][0] + dp[i - 1][1][0] * 9 % MOD) % MOD;
    dp[i][0][1] = (dp[i - 1][0][0] + dp[i - 1][0][1] * 9 % MOD) % MOD;
    dp[i][1][1] = (dp[i - 1][0][1] + dp[i - 1][1][0] + dp[i - 1][1][1] * 10 % MOD) % MOD;
  }
  cout << dp[n][1][1] << endl;
}


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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int n,m,q;
int a[105];
int main()
{
	while (cin >> n >> q, n)
	{
		memset(a, 0, sizeof(a));
		REP(i, n)
		{
			cin >> m;
			int d;
			REP(j, m)
			{
				cin >> d;
				a[d]++;
			}
		}
		int* max = max_element(a,a+104);
		if (*max >= q) cout << max-a << endl;
		else cout << 0 << endl;
	}
	return 0;
}

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

int main(){
  long N;
  cin >> N;
  if(N%2==1){
    cout << "0" << endl;
    return 0;
  }
  N/=2;
  long ans =0;
  while(N!=0){
    ans += N/5;
    N/=5;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + a[i + 1], sum + int(a[i + 1]))
        dfs(i + 1, f + "-" + a[i + 1], sum - int(a[i + 1]))

a = input()
dfs(0, a[0], int(a[0]))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  int a,b,ans;
  cin>>a>>b;
  if(a<b) ans=2*b-1;
  else if(a==b) ans=2*a;
  else ans=2*a-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i,n) for (int i=1; i<=(int)n; i++)
#define FF(i,n) for (int i=0; i<(int)n; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pi pair < int , int >
#define re(x) (int)x.size()
#define y1 u228
#define vi vector <int>
using namespace std;
typedef long long ll;
const int N = 1e5+228;
const int big = 2e9;
const int md = 1e9 + 7;
string a;
int k,f[10010][110][2];
void up(int &x,int y){x=(x+y)%md;}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("input.txt","r",stdin);
    cin>>a;
    cin>>k;
    f[0][0][0]=1;
    FF(i,re(a)){
        FF(s,2){
            FF(sm,k){
                FF(j,10){
                    if (s==0 && j>(a[i]-'0')) continue;
                    up(f[i+1][(sm+j)%k][s|(j<(a[i]-'0'))],f[i][sm][s]);
                }
            }
        }
    }
    cout<<(f[re(a)][0][0]+f[re(a)][0][1]-1+md)%md;
    return 0;
}







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

int main(){
    float ans = 0;
    int N;

    cin >> N;

    if(N%2 == 0){
        ans = (float)1/2;
    }
    else{
        ans = (float)(N/2+1) / N;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

//素因数分解
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    T tmp=0;
    if(n%2==0){
        tmp=0;while(n%2==0){tmp++;n/=2;}
        ret.push_back(make_pair(2, tmp));
    }
    if(n%3==0){
        tmp=0;while(n%3==0){tmp++;n/=3;}
        ret.push_back(make_pair(3, tmp));
    }
    for (T i=5;i*i<=n;i+=4) {
        if(n%i==0){
            tmp=0;while(n%i==0){tmp++;n/=i;}
            ret.push_back(make_pair(i,tmp));
        }
        i+=2;
        if(n%i==0){
            tmp=0;while(n%i==0){tmp++;n/=i;}
            ret.push_back(make_pair(i,tmp));
        }
    }
    if(n!=1)ret.push_back(make_pair(n,1));
    return ret;
}

int main(){
    INT(n);
    vector<int> yakusuu(n+1,0);
    for(int i=2;i<=n;i++){
        vector<pair<ll,ll>> prime=prime_factor((ll)i);
        rep(j,prime.size()){
            yakusuu[prime[j].first]+=prime[j].second;
        }
    }
    ll ans=1;
    for(int i=2;i<=n;i++){
        (ans*=(yakusuu[i]+1))%=MOD;
    }
    out(ans);
}

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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

int main() {
  char c;
  cin >> c;
  c++;

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
int n,k;
ll re = 0;
cin >> n >> k;
  for (int i=k+1;i<=n;i++) {
      re += (i - k) * (n / i);
      if (n % i >= k) {
        re += (n % i) - k;
        if (k > 0) {re++;}
      }
    }
  cout << re << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
using namespace std;
vector <pair<double,double>> x;
double degree30=atan(1)*2/3;
void fractals(){
	int len=(x.size()-1)*4;
	double x1,y1,x2,y2,x3,y3,a,a1,b1,a2,b2;
	for (int i=1;i<len;i+=4){
		x1=x[i-1].first;
		y1=x[i-1].second;
		x2=x[i].first;
		y2=x[i].second;
		x.insert(x.begin()+i,make_pair((x1*2+x2)/3,(y1*2+y2)/3));
		x.insert(x.begin()+i+1,make_pair((x1+x2*2)/3,(y1+y2*2)/3));
		a=(y2-y1)/(x2-x1);
		a1=tan(atan(a)+degree30);
		b1=y1-x1*a1;
		a2=tan(atan(a)-degree30);
		b2=y2-x2*a2;
		x3=(b2-b1)/(a1-a2);
		y3=(abs(a1)<100)?x3*a1+b1:x3*a2+b2;
		x.insert(x.begin()+i+1,make_pair(x3,y3));
	}
}
int main(){
	int n;
	scanf("%d",&n);
	x.push_back(make_pair(0.0,0.0));
	x.push_back(make_pair(100.0,0.0));
	for (int i=0;i<n;i++) fractals();
	int s=x.size();
	for (int i=0;i<s;i++){
		printf("%.9f %.9f\n",x[i].first,x[i].second);
	}
	return 0;
}


Measured memory_bytes: 3912
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, N: int, A: "List[int]"):
    if sum(A) >= H:
        print(YES)
    else:
        print(NO)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, N, A)

if __name__ == '__main__':
    main()


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

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * N;

N root,NIL;
int maxh;

N treeSearch(N z,int k){
  while(z != NIL && k != z->key){
    if(k < z->key) z = z->l;
    else z = z->r;
  }
  return z;
}

void insert(int k){
  int H;
  N y = NIL;
  N x = root;
  N z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else {
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else {
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(N z){
  if(z == NIL)return;
  inorder(z->l);
  printf(" %d",z->key);
  inorder(z->r);
}
void preorder(N z){
  if(z == NIL)return;
  printf(" %d",z->key); 
  preorder(z->l);
  preorder(z->r);
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  maxh = 0;
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0] == 'f'){
      scanf("%d",&x);
      N t = treeSearch(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20460
import java.util.*;

public 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();
        sc.close();
        System.out.println(b > a * c ? c : b / a);
    }
}


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

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        if (n[i] == '1') n[i] = '9';
        else n[i] = '1';
    }
    cout << n << endl;
}

Measured memory_bytes: 256
using System;

namespace fight1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = a * b;
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 17864
<?php
fscanf(STDIN, '%d%d', $H, $W);
for($y = 0; $y < $H; $y++){
    $map[$y] = str_split(fgets(STDIN));
    for($x = 0; $x < $W; $x++){
        if($map[$y][$x] == '#'){
            $list[$y][$x] = 1;
        }
    }
}
$count = 0;
$HM = $H - 1;
$WM = $W - 1;
while($list){
    $nextList = [];
    foreach($list as $y => $xs)foreach($xs as $x => $_){
        if($x && $map[$y][$x-1] == '.')$nextList[$y][$x-1] = $map[$y][$x-1] = 1;
        if($y && $map[$y-1][$x] == '.')$nextList[$y-1][$x] = $map[$y-1][$x] = 1;
        if($x < $WM && $map[$y][$x+1] == '.')$nextList[$y][$x+1] = $map[$y][$x+1] = 1;
        if($y < $HM && $map[$y+1][$x] == '.')$nextList[$y+1][$x] = $map[$y+1][$x] = 1;
    }
    $list = $nextList;
    if($list)$count++;
}
echo $count;


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

int main() {

    int N, K;
    cin >> N >> K;

    int A[2000020];
    rep(i, N) {
        int a;
        cin >> a;
        A[a-1]++;
    }

    sort(A, A+N);
    int ans = 0;
    rep(i, N-K) ans += A[i];

    cout << ans << endl;

    return 0;
}

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

#define FOR(i,N) for(int i=0;i<N;i++)

int main(){
    long long H,W,Q,M,X,K,N,x,cnt=0,min=-1,max=0,sum=0;
    cin >> H >> W >> K;
    vector<vector<char>>c(H,vector<char>(W));
    FOR(i,H)FOR(j,W)cin >> c[i][j];

    FOR(is,1<<H)FOR(js,1<<W){
        int n=0;
        FOR(i,H)FOR(j,W){
            if(is & 1<<i)continue;
            if(js & 1<<j)continue;
            if(c[i][j]=='#')n++;
        }
        if(n==K)cnt++;
    }
    cout <<cnt;
}


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

const int MAX_N = 1e5 + 1;

bool is_red[MAX_N];
int cnt[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, X, Y;
    cin >> N >> M;
    is_red[0] = true;
    for (int i = 0; i < N; i++) cnt[i] = 1;
    for (int i = 0; i < M; i++) {
        cin >> X >> Y;
        X--, Y--;
        cnt[X]--, cnt[Y]++;
        if (is_red[X]) is_red[Y] = true;
        if (cnt[X] == 0) is_red[X] = false;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (is_red[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
m, d = map(int, input().split())
if d<22 or m<4 : print(0)
else:
    res = 0
    for i in range(22,d+1):
        i1, i10 = i%10, i//10
        if i1 < 2 or i10 < 2: continue
        elif m >= i1 * i10: res += 1
    print(res)

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

//Compiler version g++ 6.3.0

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==3&&b==1||a==1&&b==3){
      cout<<"2";
    }
    else if(a==1&&b==2||a==2&&b==1){
      cout<<"3";
    }
    else 
    cout<<"1";
}

Measured memory_bytes: 256
def solve(S):
    S = S[::-1]
    for _ in range(len(S) // 5 + 1):
        if S[:5] == "dream"[::-1]:
            S = S[5:]
        if S[:5] == "erase"[::-1]:
            S = S[5:]
        if S[:6] == "eraser"[::-1]:
            S = S[6:]
        if S[:7] == "dreamer"[::-1]:
            S = S[7:]
    if len(S):
        return "NO"
    else:
        return "YES"
#
# assert(solve("erasedream") == "YES")
# assert(solve("dreameraser") == "YES")
# assert(solve("dreamerer") == "NO")
# assert(solve("dreamdreamerer") == "NO")
# assert(solve("erasdreamerer") == "NO")
# assert(solve("dreameraserer") == "NO")

if __name__ == "__main__":
    S = input()
    print(solve(S))


Measured memory_bytes: 3316
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int nax = 1e6+6;
   vector<ll> adj[nax];
    ll depth[nax];
    bool visited[nax];





int main()
{

    ll n,m;
    cin>>n>>m;

    for(ll i=1;i<=n;i++){
        visited[i]=false;
        depth[i]=INT_MAX;
    }
    for(ll i=0;i<m;i++){
        ll a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    depth[1]=0;
    queue<ll>q;
    q.push(1);
    ll ans[n+1];
    while(!q.empty()){
        ll v = q.front();
            ll mind = INT_MAX;
        q.pop();

                visited[v]=true;
        for(ll i=0;i<adj[v].size();i++){

            if(visited[adj[v][i]]==false){
            depth[adj[v][i]]=depth[v]+1;
            q.push(adj[v][i]);
            visited[adj[v][i]]=true;
            }
            if(depth[adj[v][i]]<mind){
                ans[v]=adj[v][i];
                mind = depth[adj[v][i]];
            }

        }


    }
    bool possible = true;
    for(ll i=1;i<=n;i++){
        if(!visited[i]){
            possible=false;
            break;
        }
    }
    if(!possible)cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        for(ll i=2;i<=n;i++){

            cout<<ans[i]<<endl;
        }


    }

    return 0;
}


Measured memory_bytes: 34968
import math
t_health, t_strength, a_health, a_strength = list(map(int, input().split()))

count_a = math.ceil(a_health / t_strength)
count_t = math.ceil(t_health / a_strength)

if count_a == count_t:
  print("Yes")
else:
  print("Yes" if count_t > count_a else "No")


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

using namespace std;

#define llong long long 
typedef pair<int, int> P;

typedef struct data{
	int now;
	int time;
	int dep;

	bool operator > (const data& right) const{
		return dep == right.dep ? time > right.time : dep > right.dep;
	}

}data;

int c, n, m, s, d;
vector<P> edges[101];
int cost[101][11];
priority_queue<data, vector<data>, greater<data> > q;

void solve(){
	data D;
	D.now = s;
	D.time = 0;
	D.dep = 0;
	q.push(D);

	while(!q.empty()){
		data nd = q.top(); q.pop();
		int nowp = nd.now;
		int nowtime = nd.time;
		int nowdep = nd.dep;

		if(cost[nowp][nowdep] < nowtime) continue;

		for(int i = 0; i < edges[nowp].size(); i++){
			P edge = edges[nowp][i];
			if(cost[edge.first][nowdep] > cost[nowp][nowdep] + edge.second){
				data in;
				in.now = edge.first;
				in.time = cost[nowp][nowdep] + edge.second;
				in.dep = nd.dep;
				cost[in.now][in.dep] = in.time;
				q.push(in);
			}

			if(nowdep < c){
				if(cost[edge.first][nowdep + 1] > cost[nowp][nowdep] + edge.second / 2){
					data in;
					in.now = edge.first;
					in.time = nowtime + (edge.second / 2);
					in.dep = nowdep + 1;
					cost[in.now][in.dep] = in.time;
					q.push(in);
				}			
			}

		}
	}

	return;
}

int main(){
	while(cin >> c >> n >> m >> s >> d, n){
		fill_n(*cost, 101 * 11, 99999999);
		for(int i = 0; i <= c; i++){
			cost[s][i] = 0;
		}
		for(int i = 0; i < m; i++){
			int n, to, cos;
			cin >> n >> to >> cos;
			edges[n].push_back(P(to, cos));
			edges[to].push_back(P(n, cos));
		}

		solve();

		// cout << cost[d][c] << endl;
		int minc = 999999999;
		for(int i = 0; i <= c; i++)
			minc = min(minc, cost[d][i]);
		cout << minc << endl;
		for(int i = 0; i < 101; i++){
			edges[i].clear();
		}
	}

	return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int n,a,b,dig,tmp;
long long x,y;
vector<long long> ans;
int main(int argc,char const* argv[])
{
  int n;
  long long y;
  int sen,gosen=0,itiman=0;
  cin >> n >> y;
  sen = y/1000;
  while(sen+gosen+itiman>n )
    {
      if((sen+gosen+itiman)==n) break;
      if((sen+gosen+itiman)>=(n+9))
	{
	  sen-=10;
	  itiman++;
	}
      if((sen+gosen+itiman)< (n+9) && (sen+gosen+itiman)>n)
	{
	  sen-=5;
	  gosen++;
	}
      
      //cout << sen << ' ' << gosen << ' ' <<  itiman << endl;
    }

  if(sen+gosen+itiman !=n)
    {
      while(sen+gosen+itiman<n)
	{
	  if((sen+gosen+itiman)>=n) break;
	  itiman--;
	  gosen+=2;
	}
    }
  if((sen+gosen+itiman)!=n || sen <0 || gosen <0 || itiman <0)
    {
      cout << -1 << ' ' << -1 <<' ' << -1 << endl;
      return 0;
    }
	
  cout << itiman << ' ' << gosen  << ' ' << sen << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#define EPS 1e-10
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n) 
using namespace std;

int main(){
  int n,a,b;
  bool DP[1000000];
  int cnt;

  while(cin >> n >> a  >> b && a && n && b){
    cnt=n;
    for(int i=0;i<=n;i++)DP[i] = false;  
    DP[0] = true;
    rep(i,n+1){  
      if(DP[i]){    
	if(a+i<=n && !DP[a+i]){
	  cnt--;
	  DP[a+i] = true;
	}
	if(b+i<=n && !DP[b+i]){
	  cnt--;
	  DP[b+i] = true;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define xx first
#define yy second
#define ln 17
#define off 2


using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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

#define maxn 200005

int Next[26][maxn] ;
int dp[maxn] , ch[maxn] ;

char s[maxn] , ans[maxn] ;

const int l = 26 ;

int main()
{
    int i , j , k , m , n ;

    scanf("%s",s) ;

    n = strlen(s) ;

    for( i=0 ; i<l ; i++ ) Next[i][n] = n ;

    for(i=n-1 ; i>=0 ; i--)
    {
        for(j=0 ; j<l ; j++) Next[j][i] = Next[j][i+1] ;
        Next[ s[i]-'a' ][i] = i ;
    }

    dp[n] = 1 ; dp[n+1] = 0 ;

    for(i=n-1 ; i>=0 ; i--)
    {
        dp[i] = n+100 ;
        for(j=0 ; j<l ; j++)
        {
            if( dp[ Next[j][i]+1 ]+1 < dp[i] )
            {
                dp[i] = dp[ Next[j][i] + 1 ] + 1 ;
                ch[i] = j ;
            }
        }
    /*    printf("%d--->%c\n",i,ch[i]+'a') ;
        for(j=0 ; j<l; j++) printf("%d:%d ",j,Next[j][i]) ;
        printf("\n") ; */
    }

//    DBG ;

    int cur = 0 , len = 0 ;

    while( cur < n )
    {
  //      printf("%d\n",cur) ;
        ans[ len++ ] = ch[cur] + 'a' ;
        cur = Next[ ch[cur] ][ cur ] + 1 ;
    }

    ans[len] = '\0' ;

    printf("%s\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 22272
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

double calc(double a,double b,double c){
	double s = (a+b+c)/2;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}

void func(double a,double l,double x){

	double tmp = (l+x)/2;

	printf("%.10lf\n",calc(a,l,l)+calc(tmp,tmp,l)*2);
}


int main(){

	double a,l,x;

	while(scanf("%lf %lf %lf",&a,&l,&x) != EOF){
		func(a,l,x);
	}
}

Measured memory_bytes: 3108
<?php
fscanf(STDIN,"%d %d",$N,$K);
$h = [];
for($i=0;$i<=$N-1;$i++){ 
  fscanf(STDIN,"%d",$h[$i]);
}
$ans =10000000000;
sort ($h);
for($i=0;$i<=$N-$K;$i++){
$anst =$h[$i+$K-1]-$h[$i] ;
if ($anst <= $ans ){
$ans = $anst;
}
}
echo $ans;


?>

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

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

  int n, a[200200], b[200200] = {0};
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];

  int cntB = 0;
  for (int i = n; i; i--)
  {
    int sum = 0;
    for (int j = i * 2; j <= n; j += i)
      sum ^= b[j];
    if (sum != a[i])
    {
      cntB++;
      b[i] = 1;
    }
  }

  cout << cntB << endl;
  for (int i = 1; i <= n; i++)
    if (b[i])
      cout << i << ' ';
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a+b)>(c+d))
		cout<<"Left"<<"\n";
	else if((a+b)<(c+d))
		cout<<"Right"<<"\n";
	else
		cout<<"Balanced"<<"\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void){

    int n;
    cin>>n;
    string u, d;
    cin>>u;
    cin>>d;

    ll ans = 1;
    ll mod = 1000000007;

    int piv;

    for(int i=0;i<n;i++){
        if(u[i] == u[i+1]){
            if(i==0){
                ans *= 6;
                piv = 2;
            }else{
                if(piv == 2){
                    ll temp = ans;
                    ans = temp + temp*2;
                    piv = 2;
                }else{
                    ans *= 2;
                    piv = 2;
                }
            }
            i++;
        }else{
            if(i==0){
                ans *= 3;
                piv = 1;
            }else{
                if(piv == 2){
                    ans *= 1;
                    piv =1;
                }else{
                    ans *= 2;
                    piv = 1;
                }
            }
        }
        ans = ans%mod;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using LD = long double;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<LL> a(n);
    LL ans = 0;
    for (auto& i : a) cin >> i;
    vector<LL> b = a;
    for (int i = 0; i < n; i++) {
        if (i) {
            if (a[i - 1] < 0) {
                if (a[i] + a[i - 1] <= 0) {
                    ans += 1 - (a[i] + a[i - 1]);
                    a[i] = 1;
                } else {
                    a[i] += a[i - 1];
                }
            } else {
                if (a[i] + a[i - 1] >= 0) {
                    ans += a[i] + a[i - 1] + 1;
                    a[i] = -1;
                } else {
                    a[i] += a[i - 1];
                }
            }
        } else {
            if (a[i] <= 0) {
                ans += 1 - a[i];
                a[i] = 1;
            }
        }
    }
    a = b;
    LL tmp = ans;
    ans = 0;
    for (int i = 0; i < n; i++) {
        if (i) {
            if (a[i - 1] < 0) {
                if (a[i] + a[i - 1] <= 0) {
                    ans += 1 - (a[i] + a[i - 1]);
                    a[i] = 1;
                } else {
                    a[i] += a[i - 1];
                }
            } else {
                if (a[i] + a[i - 1] >= 0) {
                    ans += a[i] + a[i - 1] + 1;
                    a[i] = -1;
                } else {
                    a[i] += a[i - 1];
                }
            }
        } else {
            if (a[i] >= 0) {
                ans = a[i] + 1;
                a[i] = -1;
            }
        }
    }
    cout << min(ans, tmp) << '\n';
}


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

int main()
{
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> x(n);
  for(int i = 0;i < n;i++) cin >> x[i];
  int l = 0;
  for(int i = 0;i < n;i++){
    if(x[i] < abs(x[i] - k)) l += 2*x[i];
    else l += 2*abs(x[i] - k);
  }
  cout << l << endl;
}


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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n,m ,c ; 
    cin >> n >> m >> c; 
    vector <ll> b(m);
    for(auto &i : b) cin >> i;
    int cnt=0;
    while(n--)
    {
        ll ans=0,x;
        for(int i=0;i< m;i++)
        {
            cin >> x; 
            ans+= x*b[i];
        }
        if(ans+c> 0) cnt++;
    }
    cout << cnt << endl;
    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3552
#pragma region
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;
#pragma endregion



int A[100005];
int n,m,ans=0,t;



int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<=b) return !printf("%d\n", a);
    if(a>b)return !printf("%d\n", a-1);
    return 0;
    /*
    for (int i = 0; i < n; ++i)
    {
    	scanf("%d",&A[i]);
    }*/
    
    

    
       
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M; cin >> N >> M;
  vector<int> road(M*2);
  int count=0;
  for (int i=0;i<M*2;i++){
    cin >> road.at(i);
  }
  for (int j=0;j<N;j++){
    for (int i=0;i<M*2;i++){
      if (j+1==road.at(i)) count++;
    }
    cout << count << endl;
    count=0;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:usize, s:chars};
    let mut csum_w = vec![0i64;n+1];
    for i in 0..n {
        csum_w[i+1] = csum_w[i];
        if s[i] == 'W' {
            csum_w[i+1] += 1;
        }
    }
    //debug!(csum_w);

    let mut mn:i64 = INF_I64;
    for i in 0..n {
        //debug!(csum_w[i]);
        //debug!(csum_w[n]-csum_w[i+1]);
        //debug!((n-i-1) as i64 - (csum_w[n]-csum_w[i+1]));
        mn = min(mn, csum_w[i] + (n-i-1) as i64 - (csum_w[n]-csum_w[i+1]));
    }

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

Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define li long int
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y>
#define qq(x) queue<x>
#define pqq(x) priority_queue<x> 
#define search(x,y,z) binary_search(x,y,z)
#define pi(x,y) pair<x,y>
#define forf(i,x,y) for(ll i=x;i<y;i++)
#define forl(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define pp push
#define po pop
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define vp(x,y) vec(pi(x,y) )
#define vv(x) vector<vector<x> >
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{
	fastio;
	/*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif*/
	
	int n;
	cin>>n;
	int size=log10(n)+1;
	int r=n/pow(10,size-1),p=0;
	while(size--)
		p=p*10+1;
	if(r*p>=n)
		cout<<r*p;
	else
		cout<<((r+1)*p);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll a, b;
    cin >> a >> b;
    if(a<=9&&a>=1){
        if(b<=9&&b>=1){
            cout << a*b;
            return 0;
        }
    }
    cout << -1;
}

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

def main()
  lines = readlines.map {|l| l.chomp }
  n = lines[0].to_i
  h = Hash.new(0)
  (1..n).each do |i|
    s = lines[i].chars.sort.join
    h[s] += 1
  end
  ans = 0
  h.each do |k, c|
    ans += c * (c - 1) / 2
  end
  puts ans
end


if __FILE__ == $0
  main
end


Measured memory_bytes: 24284
def bfs(u)
	$q.push([u, 0])
	$d[u] = 0
	while $q != []
		f = $q.first
		distance = f[1] + 1
		$l[f[0]].each do |i|
			if $d[i] == nil
				$q.push([i, f[1]+1]) if i != u
				$d[i] = distance
			end
		end
		$q.shift
	end
end



n = gets.chomp.to_i
$l=[]
$q = []
$d = Array.new(n+1)
n.times do
	u, k, *v = gets.chomp.split(" ").map(&:to_i)
	$l[u] = v
end
bfs(1)
$d.each_with_index do |val,i|
	next if i == 0
	val = -1 if val == nil
	puts "#{i} #{val}"
end


Measured memory_bytes: 8900
// AOJ 2079: Dance Dance Revolution
// 2017.10.4 bal4u@uu

#include <stdio.h>

char buf[100003];

int main()
{
	int n, ans;
	char *p;

	scanf("%d", &n);
	while (n-- > 0) {
		scanf("%s", buf+1);
		p = buf, *p++ = '0'; ans = 1;
		while (*p) {
			if (*p == *(p-1)) { ans = 0; break; }
			p++;
		}
		puts(ans ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 1804
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
    H = list(map(int, input().split()))
    ab.append(H)

for i in range(M):
    H = list(map(int, input().split()))
    cd.append(H)

for i in range(N):
    s = abs(ab[i][0] - cd[0][0])+abs(ab[i][1] - cd[0][1])
    ans = 1
    for j in range(M):
        if s > abs(ab[i][0] - cd[j][0])+abs(ab[i][1] - cd[j][1]):
            ans = j+1
            s = abs(ab[i][0] - cd[j][0])+abs(ab[i][1] - cd[j][1])
    print(ans)


Measured memory_bytes: 3064