akhauriyash/Code-Regression huggingface dataset:
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

ll a[N];
ll basis[60];

ll norm_comp(ll x) {
	rep(i, 0, 60) {
		if (basis[i] != 0 && (x >> i) & 1) {
			x ^= basis[i];
		}
	}
	return x;
}

void add_elem(ll x) {
	x = norm_comp(x);
	if (x != 0) {
		rep(b, 0, 60) {
			if ((x >> b) & 1) {
				assert(basis[b] == 0);
				basis[b] = x;
				break;
			}
		}
	}
}

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int T;
    cin >> T;
    while (T--) {
    	int n;
    	cin >> n;
    	rep(i, 0, n) {
    		cin >> a[i];
    	}
    	string s;
    	cin >> s;

    	fill(basis, basis + 60, 0);
    	bool fail = false;
    	repb(i, n - 1, -1) {
    		if (s[i] == '0') {
    			add_elem(a[i]);
    		} else {
    			ll x = norm_comp(a[i]);
    			if (x != 0) {
    				fail = true;
    				break;
    			}
    		}
    	}
    	cout << (fail ? "1\n" : "0\n");
    }
    return 0;
}



Measured memory_bytes: 3568
import math
q = int(input())
x = []
for i in range(q):
    x1,y1=[int(i) for i in input().split()]
    x.append([x1,y1])
def so(k):
    n = True
    if k % 2 == 0 and k != 2:
      return False
    for divisor in range(2, math.floor(math.sqrt(k))+1):
      if k % divisor == 0:
        n = False           
    return n
map1 = [None for i in range(100005)]
map2 = [0 for i in range(100005)]
for i in range(2,100001):
  map1[i] = so(i)
for i in range(2,100001):
  if (map1[i] == True and map1[(i+1)//2] == True):
    map2[i] = map2[i-1] +1
  else:
    map2[i] = map2[i-1]
for a,b in x:
  print(map2[b]-map2[a-1])

Measured memory_bytes: 22056
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'p') a++;
    }
    cout << abs(a - (int)s.size() / 2) << endl;
	return 0;
}


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

const int MAX = 200005;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n, k;
    cin >> n >> k;
    COMinit();
    int m = min(n-1, k);
    long long ans = 0;
    rep(i, m+1) {
        ans += COM(n, i) * COM(n-1, i);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
def dise(s):
    if s[0]==s[1]:
        return 1
    else:
        return 0

N=int(input())
s=[]
for i in range(0,N):
    s.append(dise(list(map(int,input().split()))))

for j in range(0,N-2):
    if s[j]==1:
        j+=1
        if s[j]==1:
            j+=1
            if s[j]==1:
                print('Yes')
                break
else:
    print('No')

Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int N;
    double A, T;
    cin >> N;
    cin >> T >> A;
    vector<double> h(N);
    vector<double> tave(N);
    double check1 = 0;
    double check2 = 0;
    int checkn = 0;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        tave[i] = T - h[i] * 0.006;

    }
    check1 = abs(tave[0] - A);
    for(int j = 0; j < N; j++){
        check2 = abs(tave[j] - A);
       // cout << check1 <<" "<< check2 << endl;
        if(check2 < check1){
            check1 = check2;
            checkn = j;
        }
    }
    cout << checkn + 1 << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ball = new int[10];
		for (int i = 0;  i < n; i++){
			for(int j = 0; j < ball.length; j++){
				ball[j] = sc.nextInt();
			}
			boolean judge = true;
			int rb = 0, rc = 0;
			rb = ball[0];
			for(int j = 1; j < ball.length; j++){
				if(rb < ball[j]) rb = ball[j];
				else if(rc < ball[j]) rc = ball[j];
				else judge = false;
			}
			if(judge) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 25924
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
bool test_mode = false;
char expected[220];

int query(const vector<int> &Q)
{
	if (test_mode) {
		int w = 0;
		for (int v : Q) {
			if (expected[v] == 'R') ++w;
			else --w;
		}
		return w > 0 ? 0 : 1;
	}
	printf("?");
	for (int i = 0; i < N; ++i) printf(" %d", Q[i] + 1);
	puts("");
	fflush(stdout);

	char buf[10];
	scanf("%s", buf);
	if (buf[0] == 'R') return 0;
	else return 1;
}

int est()
{
	int ret = 0;
	for (int i = 0; i < N; ++i) {
		int rem = N - 2 * i;
		if (rem <= 0) rem = 1;
		int waf = rem;
		while (waf) {
			waf = (waf + 1) / 2;
			++ret;
			if (waf == 1) break;
		}
	}
	return ret;
}

vector<int> join(const vector<int> &a, const vector<int> &b)
{
	vector<int> ret;
	for (int x : a) ret.push_back(x);
	for (int x : b) ret.push_back(x);
	return ret;
}

int ans[200];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < 2 * N; ++i) ans[i] = -1;

	if (test_mode) {
		for (int i = 0; i < N; ++i) expected[i] = 'R';
		for (int i = 0; i < N; ++i) expected[i + N] = 'B';
		random_device dev;
		mt19937 rnd(dev());
		shuffle(expected, expected + 2 * N, rnd);
	}

	vector<int> Qcom, Ql, Qr;
	for (int i = 0; i < N; ++i) {
		Ql.push_back(i);
		Qr.push_back(i + N);
	}
	int al = query(join(Qcom, Ql)), ar = query(join(Qcom, Qr));
	while (Ql.size() > 1) {
		int mid = Ql.size() / 2;
		vector<int> nq;
		for (int i = 0; i < mid; ++i) nq.push_back(Ql[i]);
		for (int i = 0; i < Ql.size() - mid; ++i) nq.push_back(Qr[i]);
		//for (int v : Qcom) printf("%d ", v); printf("| ");
		//for (int v : Ql) printf("%d ", v); printf("| ");
		//for (int v : Qr) printf("%d ", v); printf("|\n");
		int am = query(join(Qcom, nq));
		if (al == am) {
			for (int i = 0; i < Ql.size() - mid; ++i) Qcom.push_back(Qr[i]);
			Qr.erase(Qr.begin() + 0, Qr.begin() + (Ql.size() - mid));
			Ql.erase(Ql.begin() + mid, Ql.begin() + Ql.size());
		} else {
			for (int i = 0; i < mid; ++i) Qcom.push_back(Ql[i]);
			Qr.erase(Qr.begin() + (Ql.size() - mid), Qr.begin() + Qr.size());
			Ql.erase(Ql.begin() + 0, Ql.begin() + mid);
		}
	}
	vector<int> aaa, bbb;
	for (int i = 0; i < 2 * N; ++i) {
		if (find(Qcom.begin(), Qcom.end(), i) == Qcom.end()) {
			ans[i] = query(join(Qcom, {i}));
			if (ans[i] == 0) aaa.push_back(i);
			else bbb.push_back(i);
		}
	}
	aaa.pop_back();
	bbb.pop_back();
	vector<int> Qcom2 = join(aaa, bbb);
	for (int i = 0; i < 2 * N; ++i) {
		if (ans[i] == -1) {
			ans[i] = query(join(Qcom2, {i}));
		}
	}
	printf("! ");
	for (int i = 0; i < 2 * N; ++i) printf("%c", ans[i] == 0 ? 'R' : 'B');
	puts("");
	fflush(stdout);
	if (test_mode) {
		printf("  ");
		expected[2 * N] = 0;
		puts(expected);
	}
	return 0;
}


Measured memory_bytes: 1228
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		long a = in.nextInt();
		long b = in.nextInt();
		long c = in.nextInt();
		long d = in.nextInt();
		long xy = a * c;
		xy = Math.max(xy, a * d);
		xy = Math.max(xy, b * c);
		xy = Math.max(xy, b * d);
		System.out.println(xy);
	}

}


Measured memory_bytes: 36092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
 int a,b,c; cin>>a>>b>>c;
 int res=0;
 //まず偶気を揃えてその後一番大きい数に合わせて２たす
 if(a%2!=b%2||a%2!=c%2){
 if(a%2==b%2){
     a++; b++; 
 }else if(a%2==c%2){
     a++; c++; 
 }else{
     b++; c++;
 }
 res++;
 }
 int max_a=max(a,max(b,c));
  
 //cout<<a<<" "<<b<<" "<<c<<" "<<res<<endl;
    res+=(max_a-a)/2;
    res+=(max_a-b)/2;
    res+=(max_a-c)/2;
cout<<res<<endl;
}

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

using namespace std;

constexpr int N = 200000;

map<int, int> freq;
int a[N + 1];

int main() {
	long long ans;
	int n, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}

	ans = 0;

	for (i = 1; i <= n; i++) {
		ans += freq[i - a[i]];
		freq[i + a[i]]++;
	}

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

	return 0;
}

Measured memory_bytes: 21560
n=int(input())
b=list(map(int,input().split()))

x=b[0]+b[n-2]

i=1
while n-1>i:
  if b[i-1]<=b[i]:
    x+=b[i-1]
    i+=1
  else:
    x+=b[i]
    i+=1
    
print(x)

Measured memory_bytes: 2940
# 最大ヒープ Maximum heap


def left(i):
    return 2 * i


def right(i):
    return 2 * i + 1


def maxHeapify(A, i):
    l = left(i)
    r = right(i)
    largest = i
    if l <= H and A[l] > A[i]:
        largest = l
    if r <= H and A[r] > A[largest]:
        largest = r
    
    if largest != i:
        tmp = A[i]
        A[i] = A[largest]
        A[largest] = tmp
        maxHeapify(A, largest)

def buildMaxHeap(A):
    for i in range(H//2, 0, -1):
        maxHeapify(A, i)

H = int(input())
A = [-1] + [int(i) for i in input().split()]
buildMaxHeap(A)
for i in range(1, H+1):
    if i == H+1:
        print(A[i])
    else:
        print(" ", A[i], sep="", end="")
print()



Measured memory_bytes: 63968
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

if 0 in a:
    print(0)
    exit()

ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

string s, t;
pair<int, pint> dp[3300][3300];

signed main() {
    cin >> s >> t;
    for (int i = 1; i <= s.length(); i++) {
        for (int j = 1; j <= t.length(); j++) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i - 1] == t[j - 1])
                dp[i][j] = max(dp[i][j], make_pair(dp[i - 1][j - 1].first + 1, pint(i - 1, j - 1)));
        }
    }
    vint ans;
    int x = s.length(), y = t.length();
    for (int i = 0; i < dp[s.length()][t.length()].first; i++) {
        pint p = dp[x][y].second;
        x = p.first, y = p.second;
        ans.push_back(x);
    }
    for (int i = ans.size() - 1; i >= 0; i--)cout << s[ans[i]];
    cout << endl;
}


Measured memory_bytes: 233600
#include<stdio.h>

int main(void)
{
	int a,b,c,x,y,min,p;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	min=x*a+y*b;
	if(x>y)
		p=c*2*x;
	else
		p=c*2*y;
	if(p<min)
		min=p;
	if(x<y)
		p=c*2*x+b*(y-x);
	else
		p=c*2*y+a*(x-y);
	if(p<min)
		min=p;
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
from queue import deque


N, Q = map(int, input().split())

graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)

C = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    C[p - 1] += x

P = [-1] * N

root = 0
q = deque([root])
while q:
    x = q.popleft()
    for y in graph[x]:
        if y == P[x]:
            continue
        C[y] += C[x]
        q.append(y)
        P[y] = x

print(*C)

Measured memory_bytes: 56712
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

LL N, S;

LL calc(LL B) {
	LL temp = 0;
	LL n = N;
	while (n > 0) {
		temp += n % B;
		n -= n % B;
		n /= B;
	}
	return temp;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	int N = S.size();
	if (S[0] != S.back()) {
		if ((N + 1) % 2 == 0)cout << "First\n";
		else cout << "Second\n";
	}
	else {
		if (N % 2 == 0) cout << "First\n";
		else cout << "Second\n";
	}
	return 0;
}


Measured memory_bytes: 3120
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n = int(input())
data = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    data[a].append([b,c])
    data[b].append([a,c])

dist = [-1 for i in range(n)]
q,k = map(int,input().split())
k -= 1
dist[k] = 0

def dfs(now,pre,d):
    dist[now] = d
    for p,q in data[now]:
        if p == pre:
            continue
        dfs(p,now,d+q)

dfs(k,-1,0)

for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    print(dist[x]+dist[y])

Measured memory_bytes: 137940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=2019;

int32_t main(){
    IOS;
    string s;
    cin>>s;
    int a[s.size()];
    int x=0;
    int cur=1;
    int cnt[2019]={0};
   	cnt[0]=1;
    for(int i=s.size()-1;i>=0;i--){
    	x=(x+cur*(s[i]-'0'))%N;
    	cur=(cur*10)%N;
    	cnt[x]++;
    }
    int ans=0;
    for(int i=0;i<2019;i++){
    	ans+=(cnt[i]*(cnt[i]-1)/2);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3744
N = int(input())
W = list(map(int, input().split()))
ans = float('inf')
for i in range(N - 1):
    S1, S2 = 0, 0
    for k in range(N):
        if k <= i:
            S1 += W[k]
        else:
            S2 += W[k]
    ans = min(ans, abs(S1 - S2))

print(ans)

Measured memory_bytes: 3064
#include  <stdio.h>
int main ()
{
    int a,b,c;
    int p,q,r;
    scanf("%d %d %d",&a,&b,&c);
    p=a+b;
    q=a+c;
    r=b+c;
    if(r<=q&&r<=p)
    {
        printf("\n%d\n",r);

    }
    else if (q<=r&&q<p)
    {
        printf("\n%d\n",q);
    }
    else
    {
        printf("\n%d\n",p);

    }
    return 0;
}


Measured memory_bytes: 128
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= m; i++){
        cin >> b[i];
        b[i] += b[i - 1];
    }
    // for(int i = 0; i <= n; i++){
    //     cout << a[i] << " ";
    // }
    // cout << "\n";
    // for(int i = 0; i < m; i++){
    //     cout << b[i] << " ";
    // }
    // cout << "\n";
    ll res = 0;
    for(ll i = 0; i <= n; i++){
        ll x = a[i];
        ll rem = k - x;
        if(rem < 0){
            break;
        }
        auto it = upper_bound(b.begin(), b.end(), rem) - b.begin();
        res = max(res, it - 1 + i);
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6364
def divisor(target):
    divNum = 0

    for i in range(1,target+1):
        if target%i == 0:
            divNum +=1
    
    return divNum

def main():

    N = int(input())
    ans = 0

    for i in range(1,N+1,2):
    
        if 8 == divisor(i):
            ans += 1
    print(ans)








    
if __name__== "__main__":
    main() 











Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int flag = 0;
    while (s.size() > 1)
    {
        if (s.at(0) != s.at(1) || flag)
        {
            ans++;
            flag = 0;
            s = s.substr(1, s.size() - 1);
        }
        else
        {
            ans++;
            flag = 1;
            s = s.substr(2, s.size() - 2);
        }
    }
    cout << ans + s.size() << endl;
}

Measured memory_bytes: 772
#import sys
#input = sys.stdin.readline
def main():
    N, K = map( int, input().split())
    S = input()
    now = S[0]
    cnt = 0
    for s in S[1:]:
        if s == now:
            continue
        now = s
        cnt += 1
    if cnt%2 == 0:
        cnt //= 2
        if cnt <= K:
            print(N-1)
            return
        print(N-1-(cnt-K)*2)
    else:
        cnt //= 2
        if cnt + 1 <= K:
            print(N-1)
            return
        print(N-1-(cnt-K)*2-1)
if __name__ == '__main__':
    main()


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

int main() {
    string s;
    cin >> s;

    rep(i, s.size()) if (s[i] == '?')
        s[i] = 'D';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int MOD = 1e9 + 7;

inline int add(int x, int y){
	ll res = x + y;	
	while(res >= MOD)res-=MOD;
	return res;
}

inline int mul(int x,int y){
	return (1LL * x * y) % MOD;
}

int modpow(int x,int p){
	int res = 1;
	while(p){
		if(p&1)gmul(res,x);
		gmul(x,x);
		p/=2;
	}
	return res;
}

inline int invert(int x){
	return modpow(x,MOD - 2);
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	vector<int> dp(k+1);
	rep(i,1,k+1){
		dp[i] = modpow(i,n);
		int la;
		for(int x = 2;x <= i;x = la + 1){
			la = min(i/(i/x),i);
			gadd(dp[i], MOD - mul(la-x+1, dp[i/x]));
		}
	}
	int ans = 0;
	rep(i,1,k+1){
		gadd(ans, mul(i,dp[k/i]));	
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,x,d;
int f(int y){
  int mx=(n-y+n-1)*y/2;
  int mn=y*(y-1)/2;
  return mx-mn+1;
}
int g(int y){
  int l1=((n-y)+(n-1))*y/2,
      l2=y*(y-1)/2,
      r1=((n-y-d)+(n-1))*(y+d)/2+x,
      r2=(y+d)*(y+d-1)/2+x;
  return max(min(l1,r1)-max(l2,r2)+1,0LL);
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  cin>>n>>x>>d;
  if(!d&&!x)fin(1);
  if(!d)fin(n+1);
  if(!x)fin(n*(n-1)/2+1);
  if(x<0)x*=-1,d*=-1;
  int gcd=__gcd(x,abs(d));x/=gcd;d/=gcd;
  int ans=0;
  for(int i=0;i<=n;i++)ans+=f(i)-g(i);
  fin(ans);
}


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

struct Node {
    Node *ch[2];
    int num;
};

int number(char *&p) {
    int res = 0;
    while (isdigit(*p)) {
        res = res * 10 + *p - '0';
        ++p;
    }
    return res;
}

Node *tree(char *&p) {
    Node *res = new Node;
    for (int i = 0; i < 2; i++) {
        if (i) {
            ++p;
            res->num = number(p);
            ++p;
        }
        if (p[1] == ')') {
            p += 2;
            res->ch[i] = nullptr;
        } else {
            ++p;
            res->ch[i] = tree(p);
            ++p;
        }
    }
    return res;
}

void print(Node *s, Node *t) {
    printf("(");
    for (int i = 0; i < 2; i++) {
        if (i) printf(")[%d](", s->num + t->num);
        if (s->ch[i] && t->ch[i]) print(s->ch[i], t->ch[i]);
    }
    printf(")");
}

int main() {
    char s[1010], t[1010];
    cin >> s >> t;
    char *ss = s, *tt = t;
    print(tree(ss), tree(tt));
    cout << '\n';
}

Measured memory_bytes: 3208
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e13
typedef long long ll;
using namespace std;

int main(){
	int n,limit;
	cin>>n>>limit;
	int w[n];
	ll v[n];
	rep(i,n)cin>>w[i]>>v[i];
	ll dp[n+1][limit*2];
	rep(i,n+1)rep(j,limit*2)dp[i][j]=-INF;
	dp[0][0]=0;
	loop(i,1,limit)dp[0][i]=-INF;
	rep(i,n){
		rep(j,limit){
			dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
		}
	}
	ll ans=0;
	rep(i,limit+1)ans=max(ans,dp[n][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 158080
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int a,b;
  
  scanf("%d %d", &a, &b);
  //scanf("%d %d", &h, &w);
  
  if(b%a==0) printf("%d", a+b);
  else printf("%d", b-a);

  return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
    ll N, K, i; cin >> N >> K;
    vector<ll> A(N);
    for(i = 0; i < N; i += 1) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    ll ans = 0;
    for(i = 0; i < K; i += 1) {
        ans += A[i];
    }
    cout << ans;
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX=260;
int tree[MAX];
int main(){
	memset(tree,-1,sizeof(tree));
	int H;
	cin>>H;
	for(int i=1;i<=H;i++){
		cin>>tree[i];
	}
	for(int i=1;i<=H;i++){
		printf("node %d: key = %d, ",i,tree[i]);
		if(i/2>0)printf("parent key = %d, ",tree[i/2]);
		if(i*2<=H)printf("left key = %d, ",tree[i*2]);
		if(i*2+1<=H)printf("right key = %d, ",tree[i*2+1]);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int mm1 = h1 * 60 + m1;
  int mm2 = h2 * 60 + m2;
  int ans = mm2 - mm1 - k;
  cout << max(0, ans) << endl;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int y = sc.nextInt();
        for (int i = n; i >= 0; i--) {
            if (10000*i > y) {
                continue;
            }
            for (int j = n-i; j >= 0; j--) {
                if (10000*i + 5000*j > y) {
                    continue;
                }
                for (int k = n-i-j; k >= 0; k--) {
                    if (10000*i + 5000*j + 1000*k > y) {
                        continue;
                    }
                    if ((10000*i + 5000*j + 1000*k == y)
                        && (i + j + k == n)) {
                        // 出力
                        System.out.println(i + " " + j + " " + k);
                        return;
                    }
                }
            }
        }
        // 出力
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	    ll n,i,j=0,k,l;
	    cin>>n;
	    REP(i,1,n){
	    	if(i%3!=0&&i%5!=0){
              j+=i;
	    	}
	    }
	    cout<<j;
	return 0;
}


Measured memory_bytes: 3628
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,K = list(map(int, input().split()))
# h = list(map(int, input().split()))

# (N,K), h = map(int, input().split()), list(map(int, input().split()))
N,K,*h = map(int, "\n".join([input(), input()]).split())

# suml = [1e9 for i in range(N)]
# suml[0] = 0


suml = [0]*N

for i in range(1,N):
    e_h = h[i]
# for i,e_h in enumerate(h):
#     if i == 0:
#         continue

    start = max(0, i-K)
    cost  = min(cst + abs( e_h - hgh) for cst, hgh in 
                   zip(suml[start:i], h[start:i]))
    # cost  = min(cst + abs( h[i] - hgh ) for cst, hgh in 
    #               zip(suml[start:i], h[start:i]))
    suml[i] = cost

print(suml[-1])
        



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

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


void solve5b(int a, int b) {
    REP(i,b) {
        cout << "#";
    }
    cout << endl;
    REP(i,a-2) {
        cout << "#";
        REP(j,b-2) {
            cout << ".";
        }
        cout << "#";
        cout << endl;
    }
    REP(i,b) {
        cout << "#";
    }
    cout << endl;
    cout << endl;
}

int main() {
    int a, b;
    while(cin >> a >> b, a+b) {
        solve5b(a, b);
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  n%=10;
  if(n==3)
    cout<<"bon";
  else if(n==0||n==1||n==6||n==8)
    cout<<"pon";
  else
    cout<<"hon";
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	
	int n,m;
	string s[111],t[111];
	
	int co=0,ans=-666;
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	cin>>m;
	for(int i=0;i<m;i++)cin>>t[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)if(s[i]==s[j])co++;
		for(int j=0;j<m;j++)if(s[i]==t[j])co--;
		ans=max(ans,co);
		co=0;
	}
	if(ans<0)ans=0;
	cout<<ans<<endl;
	
	
			
	
	return 0;	
}

Measured memory_bytes: 256
import string

dic = { ch:0 for ch in string.ascii_lowercase }

while True:
    try:
        line = input()

        for ch in line:
            c = ch.lower()

            if c not in dic:
                continue

            dic[c] += 1

    except EOFError:
        break

for ch in string.ascii_lowercase:
    print(ch, ':', dic[ch])



Measured memory_bytes: 6684
fun main(args: Array<String>) {
    val A = readLine()!!.toInt()
    val B = readLine()!!.toInt()
    val C = readLine()!!.toInt()
    val X = readLine()!!.toInt()
    var count = 0

    for (a in 0..A) {
        for (b in 0..B) {
            for (c in 0..C) {
                val total = a * 500 + b * 100 + c * 50
                if (total == X) {
                    count++
                }
            }
        }
    }
    println(count)
}

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

int main()
{
    long long m,k;
    cin >> m >> k;
    if(k >= 1 << m || (m == 1 && k == 1))
    {
        cout << (-1) << endl;
        return 0;
    }
    if(k == 0 && m == 1)
    {
        cout << "1 1 0 0\n";
        return 0;
    }
    int p = 1 << m;
    for(int i = 0; i < p; i++)
    {
        if(i != k)
        {
            cout << i << " ";
        }
    }
    cout << k << " ";
    for(int i = p - 1; i >= 0; i--)
    {
        if(i != k)
        {
            cout << i << " ";
        }
    }
    cout << k << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;

int main(){
    int n;
    int W;
    cin>>n>>W;
    long long int weight[n+1];
    long long int value[n+1];
    
    for(int i=1;i<=n;i++)
        cin>>weight[i]>>value[i];

    long long int dp[W+1][n+1];
    for(int i=0;i<=n;i++)
        dp[0][i]=0;
    for(int i=0;i<=W;i++)
        dp[i][0]=0;

    for(int i=1;i<=W;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = dp[i][j-1];
            if(weight[j]<=i){
                dp[i][j] = max(dp[i][j],value[j]+dp[i-weight[j]][j-1]);
            }
        }
    }
    cout<<dp[W][n];
}


Measured memory_bytes: 79104
import bisect
import sys
from collections import defaultdict
X, N = [int(x) for x in input().split()]
P = []
if N:
    P = [int(x) for x in input().split()]

Pt = defaultdict(bool)
for p in P:
    Pt[p] = True

if Pt[X] == False:
    print(X)
    sys.exit()

xl = X - 1
xr = X + 1
while True:
    if Pt[xl] == False:
        print(xl)
        break
    elif Pt[xr] == False:
        print(xr)
        break
    xl -= 1
    xr += 1

Measured memory_bytes: 9472
import  java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int heights[] = new int[n];
    for(int i = 0; i < n; i++) heights[i] = scan.nextInt();
    scan.close();
    
    int prev = -1;
    boolean judge = true;
    for(int height : heights) {
      if(prev == -1) {
        prev = height;
        continue;
      }
      
      if(prev < height - 1) {
    	  prev = height - 1;
    	  continue;
      }
      
      if(prev > height ) {
        judge = false;
        continue;
      }
    }
    if(judge) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 51012
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f+"\n", a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func ints(cnt int, a ...interface{}) {
	format := strings.Repeat("%d"+" ", cnt)
	format = strings.TrimRight(format, " ") + "\n"
	scanf(format, a...)
}

func intSlice(cnt int) []int {
	a := make([]int, cnt)
	for i := 0; i < cnt; i++ {
		scanf("%d", &a[i])
	}
	return a
}

func strs(cnt int, a ...interface{}) {
	format := strings.Repeat("%s"+" ", cnt)
	format = strings.TrimRight(format, " ") + "\n"
	scanf(format, a...)
}

type intsDesc []int

func (v intsDesc) Len() int           { return len(v) }
func (v intsDesc) Swap(i, j int)      { v[i], v[j] = v[j], v[i] }
func (v intsDesc) Less(i, j int) bool { return v[i] > v[j] }

func main() {
	defer writer.Flush()

	var n int
	var s string
	ints(1, &n)
	strs(1, &s)

	e, w := 0, 0
	for _, d := range s {
		if d == 'W' {
			w++
		} else {
			e++
		}
	}
	leftE, leftW := 0, 0

	minimum := e + w
	for _, d := range s {
		g := 0
		if d == 'E' {
			g = 1
		}
		minimum = min(minimum, leftW+e-leftE-g)
		if d == 'W' {
			leftW++
		} else {
			leftE++
		}
	}
	printf("%d", minimum)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}


Measured memory_bytes: 2432
#include<iostream>
#include<string>
using namespace std;
int main(){
long i,l,m,n,y;
string s;
while(cin>>s){
l=s.size();
y=0;m=1001;
for(i=0;i<l;i++){
if(s[i]=='I')n=1;
else if(s[i]=='V')n=5;
else if(s[i]=='X')n=10;
else if(s[i]=='L')n=50;
else if(s[i]=='C')n=100;
else if(s[i]=='D')n=500;
else if(s[i]=='M')n=1000;
if(m<n)y-=m*2;
y+=n;
m=n;
}
cout<<y<<endl;
}
return 0;
}

Measured memory_bytes: 1180
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll sum=0;
  rep(i,n) sum+=a[i];
  vector<ll> b(n);
  b[0]=sum;
  for(int i=1;i<n;i+=2){
    b[0]-=2*a[i];
  }
  for(int i=1;i<n;i++){
    b[i]=2*a[i-1]-b[i-1];
  }
  rep(i,n){
    cout << b[i] << " ";
  }cout << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007


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

    int n,m;
    cin>>n>>m;
    char val[5+1]={'a','a','a','a','a'};
    bool t=false;
    for(int i=1;i<=m;i++)
    {
        int x;char y;
        cin>>x>>y;
        if(val[x]=='a'){
            val[x]=y;
        }else{
        if(val[x]!=y){
            t=true;
        }
        }
    }

    if(t){
        cout<<-1;
    }else if(val[1]=='0'&&n>=2){
        cout<<-1;
    }else{
     if(val[1]=='a'){
        if(n>=2)
        val[1]='1';
        else
        val[1]='0';
     }
     for(int i=1;i<=n;i++)
     {
         if(val[i]!='a') cout<<val[i];
         else  cout<<0;
     }
    }
}




Measured memory_bytes: 3656
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}


vector<int> pp;
void preparePrime( int maxp )
{
    int i;
    vector<int> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        int k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

void decompositPrime( ll a, vector<pair<ll,ll> >& vv )
{
    int i;
    for(i=0; i<(int)pp.size(); i++) {
        int count = 0;
        while(a % pp[i] == 0 ) {
            a /= pp[i];
            count ++;
        }
        if(count>0) vv.push_back( make_pair( pp[i], count ) );
        if (a==1) break;
    }
    if(a>1) {
        vv.push_back( make_pair( a, 1 ) );
    }

    return;
}

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);

    preparePrime( 2000 );

    map<ll,ll> mp;
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);

        vector<pair<ll,ll> > vv;
        decompositPrime( a[i], vv );
        int k;
        for(k=0; k<(int)vv.size(); k++) {
            ll tmp=mp[vv[k].first];
            mp[vv[k].first]=MAX(tmp, vv[k].second);
        }
    }

    ll ans=1;
    auto it=mp.begin();
    for(; it!=mp.end(); ++it) {
        ll curr=it->first;
        ll num=it->second;
        ans=ans*mpow(curr,num)%MOD;
    }

    ll ans1=0;
    for(i=0; i<n; i++) {
        ans1=(ans1+minv(a[i]))%MOD;
    }
    ans=ans*ans1%MOD;

    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  ll ans = 0, size = s.length();
  for (int i = 0; i < (1 << (size - 1)); i++) {
    bitset<10> b(i);
    ll m = 1;
    for (int j = 0; j < s.length(); j++) {
      ans += (s[s.length() - j - 1] - '0') * m;
      if (b.test(j) == 0)
        m *= 10;
      else
        m = 1;
    }
  }
  cout << ans << endl;
}

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

namespace abc165_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = double.Parse(Console.ReadLine());
            double a = 100; //銀行預金100円
            int answer = 0; //何年後にX円を上回る

            while (a < X)
            {
                a = Math.Truncate(a * 1.01);
                answer ++;
            }

            Console.WriteLine(answer);

            Console.Read();
        }
    }
}



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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

int main(){
    fcin;
    int n;
    cin >> n;
    string s;
    cin >> s;

    string p = "ABC";

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i >= j) continue;
            if(p == s.substr(i, j - i + 1)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc82_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();

            var dic = new Dictionary<int,int>();

            //それぞれの数字の出現回数をメモ
            for(int i=0; i<n; i++){
                if(dic.ContainsKey(input[i])) dic[input[i]]++;
                else dic[input[i]] = 1;
            }

            int cnt=0;
            foreach(KeyValuePair<int,int> item in dic){
                if(item.Key<=item.Value) cnt += item.Value-item.Key;
                else cnt += item.Value;
            }
            WriteLine($"{cnt}");
        }
    }
}

Measured memory_bytes: 26460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long s[100010], t[100010];
int main() {
	int a, b, q;
	cin >> a >> b >> q;
	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < q; i++) {
		long long ans = 1000000000000000000;
		long long x;
		cin >> x;
		auto it = upper_bound(s, s + a, x);
		long long co, co1;
		if (it == s + a) {
			co = 1000000000000000000;
		}
		else {
			co = *it;
		}
		if (it == s) {
			co1 = 1000000000000000000;
		}
		else {
			co1 = *(it - 1);
		}
		auto itr = upper_bound(t, t + b, co);
		long long co2;
		if (itr == t + b) {
			co2 = 1000000000000000000;
		}
		else {
			co2 = *itr;
		}
		long long co3;
		if (itr == t) {
			co3 = 1000000000000000000;
		}
		else {
			co3 = *(itr - 1);
		}
		itr = upper_bound(t, t + b, co1);
		long long co4;
		if (itr == t + b) {
			co4 = 1000000000000000000;
		}
		else {
			co4 = *itr;
		}
		long long co5;
		if (itr == t) {
			co5 = 1000000000000000000;
		}
		else {
			co5 = *(itr - 1);
		}
		if (min(abs(co - x), abs(co2 - x)) + abs(co2 - co) < ans) {
			ans = min(abs(co - x), abs(co2 - x)) + abs(co2 - co);
		}
		if (min(abs(co - x), abs(co3 - x)) + abs(co3 - co) < ans) {
			ans = min(abs(co - x), abs(co3 - x)) + abs(co3 - co);
		}
		if (min(abs(co1 - x), abs(co4 - x)) + abs(co1 - co4) < ans) {
			ans = min(abs(co1 - x), abs(co4 - x)) + abs(co1 - co4);
		}
		if (min(abs(co1 - x), abs(co5 - x)) + abs(co1 - co5) < ans) {
			ans = min(abs(co1 - x), abs(co5 - x)) + abs(co1 - co5);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5168
N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

tmp = max(T)
for i in range(N):
    if tmp % T[i] != 0:
        tmp = T[i]//gcd(tmp, T[i])*tmp

print(int(tmp))

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

int main() {
  int n, x, y; cin >> n >> x >> y; x--; y--;
  vector<int> d(n);
  rep(i, n) {
    for (int j = i+1; j < n; j++)
      d[min({abs(j-i), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x)})]++;
  }
  rep(i, n-1)
    cout << d[i+1] << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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)*}
    };
}
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)*}
    };
}
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, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
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>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;


fn main() {
    input!{
        N: usize,
    }
    println!("{}", N*N*N);
}

Measured memory_bytes: 4352