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


int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    long long X = N / (A + B);
    long long Xmod = N % (A + B);
    if (Xmod > A) cout << X * A + A << endl;
    else  cout << X * A + Xmod << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    if(b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	var op string

	fmt.Scanf("%d %s %d", &a, &op, &b)
	if op == "+" {
		fmt.Printf("%d\n", a+b)
	} else {
		fmt.Printf("%d\n", a-b)
	}
}


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

int main() {
    int n, q;
    cin >> n >> q;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    reverse(a.begin(), a.end());
    
    long long s = 0;
    vector<long long> sum, right;
    for (int i = 0; i+i < n; i++) {
        s += a[i];
        sum.emplace_back(s);
        right.emplace_back((a[i]+a[i+i])/2);
    }
    const int m = sum.size();
    reverse(sum.begin(), sum.end());
    reverse(right.begin(), right.end());
    
    long long add = 0;
    for (int i = 0; i < m; i++) {
        sum[i] += add;
        add += a[(n-1)/2*2-i*2];
    }
    auto answer = [&] (long long x) -> long long {
        int id = lower_bound(right.begin(), right.end(), x) - right.begin();
        return sum[min(id, m-1)];
    };
    
    while (q--) {
        long long x;
        cin >> x;
        cout << answer(x) << endl;
    }
    return 0;
}

Measured memory_bytes: 3444
#include <stdio.h>
 
typedef struct{
  char c;
  int value;
}card;
 
int main(){
  char space;
  int i, j, n, min, flag;
  card a[36], b[36], x;

  scanf("%d\n",&n);
  for(i = 0; i < n; i++){
    scanf("%c%d%c", &a[i].c, &a[i].value, &space);
    b[i] = a[i]; 
  }
   
  for(j = 0; j < n; j++){
    flag = 0;   
    for(i= n-1; i > j; i--){
      if(a[i].value < a[i-1].value){
        x = a[i];
        a[i] = a[i-1];
        a[i-1] = x;
        flag = 1;
      }
    }
    if(flag == 0) break;
  }
 
  for(j = 0; j < n; j++){
    min = j;
    for(i = j; i < n; i++){
      if(b[i].value < b[min].value)
        min = i; 
    }   
    if(min != j){
      x = b[j];
      b[j] = b[min];
      b[min] = x;
    }
  }
 
  for(i = 0; i < n-1; i++){
    printf("%c%d ", a[i].c, a[i].value);
  }
  printf("%c%d\n", a[n-1].c, a[n-1].value);
  printf("Stable\n");

  for(i = 0; i < n-1; i++){
    printf("%c%d ", b[i].c, b[i].value);
    if(a[i].c != b[i].c){
      flag = 2;
    }
  }

  printf("%c%d\n", b[n-1].c, b[n-1].value);

  if(flag == 2){
    printf("Not stable\n");
  }
  else printf("Stable\n");
 
  return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC157A - Duplex Printing

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int ans = (n / 2) + (n % 2);

        System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
ll q,h,s,d,n;
cin >>q>>h>>s>>d;
ll o;
cin >>n;
if(q*2>=h){
  if(h*2>=s) o=s;
  else o=h*2;
}
else{
  if(q*4>=s) o=s;
  else o=q*4;
}
if(o*2>=d) {
  if(n%2==1) cout <<(n/2)*d+o<<endl;
  else cout <<(n/2)*d<<endl;
}
else{
  cout << n*o<<endl;
}
}


Measured memory_bytes: 256
import numpy as np

h, w = list(map(int, input().split()))
A = np.array([list(input()) for i in range(h)])

D = A[A == "."]

while True:

    B = A[np.any(A != ".", axis= 1)]
    B = B[:, np.any(A != ".", axis = 0)]

    if np.array_equal(A, B) == True:
        break
    else:
        A = B 

for i in range(len(A)):
    print("".join(A[i]))

Measured memory_bytes: 12504
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
if n%2==0:
  for x in range(n):
    if x%2==0:
      b.append(a[x])
    else:
      b.appendleft(a[x])
if n%2==1:
  for y in range(n):
    if y%2==0:
      b.appendleft(a[y])
    else:
      b.append(a[y])
print(*b)

Measured memory_bytes: 25412
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;

vector<int> v[N], dp(N);
bool visit[N];

void dfs(int node) 
{
   visit[node] = 1;

   for(auto& x : v[node]) {
      if(!visit[x]) {
         dfs(x);
         dp[node] = max(dp[node], 1 + dp[x]);
      } else {
         dp[node] = max(dp[node], 1 + dp[x]);
      }
   }
}

int main()
{
   int n, m;
   scn(n); scn(m);

   rep(i, 0, m) {
      int a, b;
      scn(a); scn(b);

      v[a].pb(b);
   }

   int cnt = 0;

   rep(i, 1, n+1) {
      if(!visit[i]) {
         dfs(i);
      }
   }

   rep(i, 1, n+1) {
      cnt = max(cnt, dp[i]);
   }

   prin(cnt);
   return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         INT_MAX-100
#define vl          vector<ll>
#define vvl         vector<vector<ll>>
#define F           first
#define S           second
#define db          double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
//const int N;

void solve()
{
   ll h,w; cin>>h>>w;
   char a[h][w];
   rep(i,0,h)
    rep(j,0,w)
      cin>>a[i][j];
   ll dp[h][w];
   memset(dp,0,sizeof dp);
   rep(i,0,w) { if(a[0][i]=='#') break; else dp[0][i]=1; }
   rep(i,0,h) { if(a[i][0]=='#') break; else dp[i][0]=1; }
   rep(i,1,h){
       rep(j,1,w){
           if(a[i][j]=='#') dp[i][j]=0;
           else
           {
               dp[i][j]=(dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
           }
       }
   }
   cout<<dp[h-1][w-1];
}
int main()
{
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long LL;
#define REP(i,N) for (int i=0; i<N; i++)

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  cout << (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=10**9+7

p=0
p_=0
for i,j in enumerate(A):
  p+=len(list(filter(lambda x:x>j,A)))
  p_+=len(list(filter(lambda x:x<j,A[i:])))


ans=p_*K+p*K*(K-1)//2

print(ans%mod)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

int n, m;
double l[21], a[21], b[21];
double d[(1 << 20)];
double c[21][21];

double dist(int p, int q){
    return (l[p] - l[q]) * (l[p] - l[q]) + (a[p] - a[q]) * (a[p] - a[q]) + (b[p] - b[q]) * (b[p] - b[q]); 
}

int bit_sum(int mask){
    int res = 0;
    while(mask){
        res += mask & 1;
        mask >>= 1;
    }
    return res;
}

signed main(){
    cin >> n >> m;
    rep(i, 0, n){
        cin >> l[i] >> a[i] >> b[i];
    }
    rep(i, 0, n){
        rep(j, 0, n){
            c[i][j] = dist(i, j);
        }
    }
    for(int mask = 0; mask < (1 << n); mask++){
        rep(j, 0, n){
            if(mask & (1 << j)) continue;
            double tmp = 0;
            rep(k, 0, n){
                if(mask & (1 << k)){
                    tmp += c[j][k];
                }
            }
            d[mask | (1 << j)] = d[mask] + tmp;
        }
    }
    double ans = 0.0;
    rep(i, 0, (1 << n)){
        if(bit_sum(i) == m) ans = max(ans, d[i]);
    }
    printf("%.15lf\n", ans);
}

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

long long rec(int n, long long x) {
    if (n == 0) return 1;
    long long len = (1LL<<(n+1)) - 3;
    long long num = (1LL<<n) - 1;
    if (x == 1) return 0;
    else if (x <= len + 1) return rec(n-1, x-1);
    else if (x == len + 2) return num + 1;
    else if (x <= (len + 1) * 2) return num + 1 + rec(n-1, x-len-2);
    else return num * 2 + 1;
}

int main() {
    int N; long long X;
    cin >> N >> X;
    cout << rec(N, X) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <queue>

#define pb push_back
#define mp make_pair
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, loop=b; i<=loop; ++i)
#define REV(i, a, b) for(int i=a, loop=b; i>=loop; --i)
#define mize(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)
#define shl(k) ((k) << 1)
using namespace std;

const int N = 5001;
int n, a[N], c[N][N], v[N], A, B;
int64_t f[N][N], INF = 1e15;

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

    cin >> n >> A >> B;
    FOR(i, 1, n) {
        cin >> a[i];
        v[a[i]] = i;
    }

    FOR(i, 1, n) {
        c[i][i] = a[i];
        FOR(j, i+1, n) c[i][j] = max(c[i][j-1], a[j]);
    }

    FOR(i, 0, n) FOR(j, 1, n) f[i][j] = INF;
    f[0][1] = (a[1]==1 ? 0 : B);
    f[v[1]][1] = 0;


    FOR(j, 1, n-1) FOR(i, 0, n) {
        ///cout << i <<' '<< j <<' '<< f[i][j] << endl;
        if (v[j+1] <= i)
            mize(f[i][j+1], f[i][j]+A);
        else {
            mize(f[v[j+1]][j+1], f[i][j]);
            mize(f[i][j+1], f[i][j] + (c[i+1][v[j+1]-1] > j+1 ? B : 0));
        }
    }

    int64_t ans = INF;
    FOR(i, 0, n) mize(ans, f[i][n]);
    cout << ans;
}


Measured memory_bytes: 293248
#include<iostream>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b || a == c || b == c){
    if(a == b && a == c){
      cout << "No\n";
    }
    else{
      cout << "Yes\n";
    }
  }
  else{
    cout << "No\n";
  }
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int n = Integer.parseInt(strs[0]);
		int len = Integer.parseInt(strs[1]);
		
		strs = new String[n];
		for(int i = 0 ; i < n ; i++){
			strs[i] = br.readLine();
		}
		
		for(int i = 0 ; i < strs.length ; i++){
			for(int j = i+1 ; j < strs.length ; j++){
				int cmp = strcmp(strs[i],strs[j]);
				if(cmp == -1){
					String b = strs[i];
					strs[i] = strs[j];
					strs[j] = b;
				}
			}
		}
		String res = "";
		for(int i = 0 ; i < strs.length ; i++){
			res += strs[i];
		}
		
		System.out.println(res);
		
	}
	//1:< 0:== -1:>
	static int strcmp(String left,String right){
		int len = Math.min(left.length(),right.length());
		
		for(int i = 0 ; i < len ; i++){
			if(left.charAt(i) > right.charAt(i)){
				return -1;
			}else
			if(left.charAt(i) < right.charAt(i)){
				return 1;
			}
		}
		
		if(left.length() > right.length()){
			return -1;
		}else
		if(left.length() < right.length()){
			return 1;
		}
		
		return 0;
	}
}


Measured memory_bytes: 13652
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += i;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21332
#include <stdio.h>
#include <cstring>
#include <iostream>
using namespace std;

/*std::string replace_with_str (std::string str, std::string str_from, std::string str_to) {
    std::string::size_type pos = 0;
    while (pos = str.find(str_from, pos), pos != std::string::npos) {
        str.replace(pos, str_from.length(), str_to);
        pos += str_to.length();
    }
    return str;
}*/


int main(void) {
    std::string helix;
    int max=0, tmp=0;

    cin >> helix;
    size_t len = helix.length();

    //helix = replace_with_str(helix, "T", "A");
    //helix = replace_with_str(helix, "G", "A");
    //helix = replace_with_str(helix, "C", "A");

    for (int i=0; i<len; i++) {
      if (helix[i] == 'A' || helix[i] == 'T' || helix[i] == 'G' || helix[i] == 'C') {
        tmp++;
        if (max < tmp) max = tmp;
      } else {
        if (max < tmp) max = tmp;
        tmp = 0;
      }
    }

    // debug
    //cout << helix << endl;
    cout << max << endl;

    return 0;
}


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

int n, m;
typedef pair<int, int> P;
vector<P> g[1010];
bool e[1010][1010];
int dis[1010][1010];
vector<int> pre[1010][1010];
int ans;

void dijkstra(int a){
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, a));
	while(!q.empty()){
		P p = q.top();
		q.pop();
		int v = p.second;
		for(int i=0; i<g[v].size(); ++i){
			int to = g[v][i].second;
			int co = g[v][i].first;
			if(dis[a][to] > dis[a][v] + co){
				dis[a][to] = dis[a][v] + co;
				q.push(P(dis[a][to], to));
				pre[a][to].clear();
				pre[a][to].push_back(v);
			}else if(dis[a][to] == dis[a][to] + co){
				pre[a][to].push_back(v);
			}
		}
	}
}

int main(){
	cin >> n >> m;
	for(int i=0; i<m; ++i){
		int a, b, c;
		cin >> a >> b >> c;
		g[a-1].push_back(P(c, b-1));
		g[b-1].push_back(P(c, a-1));
		e[a-1][b-1] = true;
		e[b-1][a-1] = true;
	}
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			if(i != j) dis[i][j] = 1e9+7;
	for(int i=0; i<n; ++i)
		dijkstra(i);
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j){
			for(int k=0; k<pre[i][j].size(); ++k){
				e[j][pre[i][j][k]] = false;
				e[pre[i][j][k]][j] = false;
			}
		}
	}
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			if(e[i][j]) ++ans;
	ans /= 2;
	cout << ans << endl;
}

Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int a,b;
	cin>>a>>b;
	
	if(a<=9 & b<=9)
	{
		int res = a*b;
		cout<<res<<endl;
		
	
	}
	else
	cout<<-1<<endl;
}

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

const ll MOD = 998244353;
template<ll MOD> struct ModInt {
    ll value;
    ModInt() : value(0) {}
    ModInt(const ll& v) : value(v % MOD) {
        if ( value < 0 ) value += MOD;
    }
    ModInt<MOD>& operator=(const ModInt& o) {
        value = o.value;
        return *this;
    }
    inline bool operator==(const ModInt& o) {
        return value == o.value;
    }
    inline bool operator!=(const ModInt& o) {
        return value != o.value;
    }
    ModInt<MOD>& operator+=(const ModInt& o) {
        value += o.value;
        if ( value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD>& operator-=(const ModInt& o) {
        value += MOD - o.value;
        if (value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD>& operator*=(const ModInt& o) {
        value *= o.value;
        value %= MOD;
        return *this;
    }
    ModInt<MOD>& operator/=(const ModInt& o) {
        value *= inverse(o.value);
        value %= MOD;
        return *this;
    }
    ModInt<MOD> operator-() {
        return ModInt<MOD>(-value);
    }
    ModInt<MOD> operator+(const ModInt& o) {
        ModInt<MOD> r(*this);
        r += o;
        return r;
    }
    ModInt<MOD> operator-(const ModInt& o) {
        ModInt<MOD> r(*this);
        r -= o;
        return r;
    }
    ModInt<MOD> operator*(const ModInt& o) {
        ModInt<MOD> r(*this);
        r *= o;
        return r;
    }
    ModInt<MOD> operator/(const ModInt& o) {
        ModInt<MOD> r(*this);
        r /= o;
        return r;
    }
    ModInt<MOD> pow(ll n) {
        ModInt<MOD> t(*this), r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) r *= t;
            t *= t;
            n >>= 1;
        }
        return r;
    }
private:
    ll inverse(ll a) {
        ModInt<MOD> t(a);
        return t.pow(MOD - 2).value;
    }
};
template<ll MOD> std::ostream& operator<< (std::ostream& os, const ModInt<MOD>& o) {
    os << o.value;
    return os;
}
template<ll MOD> std::istream& operator>> (std::istream& is, ModInt<MOD>& o) {
    is >> o.value;
    return is;
}

using Int = ModInt<MOD>;


ll solve() {
    ll N, S;
    cin >> N >> S;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    vector<Int> dp(S+1), dpt(S+1);
    dp[0] = Int(2).pow(N);
    for ( int i = 0; i < N; i++ ) {
        swap(dp,dpt);
        for ( int j = 0; j < S+1; j++ ) dp[j] = dpt[j];
        ll a = A[i];
        for ( int j = 0; j < S+1; j++ ) {
            if ( j+a <= S ) {
                dp[j+a] += dpt[j]/2;
            }
        }
    }
   return dp[S].value;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    int hoge = n/x;
    if(n%x)hoge++;
    cout << hoge*t << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b+c<=a){
		if(b<c)
		cout<<b<<" 0"<<endl;
		else
		cout<<c<<" 0"<<endl;
	}
	else{
		if(b<c)
			cout<<b<<" "<<b+c-a<<endl;
		else
			cout<<c<<" "<<b+c-a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 507
#define M 200007
bitset<N> S[N];
struct str
{
    int x,y;
}p[M];
bool vis[N],flag[N];
int n,m;
int main()
{
    int i,j,x,y;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        p[i]={x,y};
    }
    reverse(p+1,p+m+1);
    for(i=1;i<=n;i++)
    {
        memset(vis,0,sizeof(vis));
        vis[i]=true;
        for(j=1;j<=m;j++)
        {
            x=p[j].x,y=p[j].y;
            if(vis[x]&&vis[y])
            {
                flag[i]=true;
                break;
            }
            if(vis[x])vis[y]=true;
            else if(vis[y])vis[x]=true;
        }
        for(j=1;j<=n;j++)
            if(vis[j])
                S[i][j]=1;
    }
    int ans=0;
    for(i=1;i<=n;i++)
    {
        if(flag[i])continue;
        for(j=i+1;j<=n;j++)
        {
            if(flag[j])continue;
            if((S[i]&S[j]).count()==0)
                ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

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

  int N,M,X; cin >>N >>M >>X;
  vi cost(N);
  vvi book(N,vi(M));
  rep(i,0,N) {
    cin >>cost[i];
    rep(j,0,M) {
      cin >>book[i][j];
    }
  }
  vi ans;
  rep(bit,0,1<<N) {
    int c=0;
    vi rikai(M);
    rep(i,0,N) {
      if (bit&(1<<i)) {
        c+=cost[i];
        rep(j,0,M) {
          rikai[j]+=book[i][j];
        }
      }
    }
    bool flag=true;
    rep(i,0,M) {
      if (X>rikai[i]) {
        flag=false;
      }
    }
    if (flag) {
      ans.push_back(c);
    }
  }
  if (ans.size()!=0) {
    sort(all(ans));
    cout <<ans[0] <<'\n';
  } else {
    cout <<-1 <<'\n';
  }
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
const int nmax=200005;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;cin >> n >> m >> k;
    ll ans=0;
    COMinit();
    for(ll i=1;i<=n-1;i++){
        (ans+=i*m%mod*m%mod*(n-i)%mod)%=mod;
    }
    for(ll i=1;i<=m-1;i++){
        (ans+=i*n%mod*n%mod*(m-i)%mod)%=mod;
    }
    (ans*=com(n*m-2,k-2))%=mod;
    cout << ans << endl;
}

Measured memory_bytes: 4992
d,n=map(int,input().split())

for i in range(1,n+1):
    if i==n and n!=100:
        if d==0:
            print(i)
        elif d==1:
            print(100*i)
        else:
            print(100*100*i)
    if i==n and n==100:
        if d==0:
            print(101)
        elif d==1:
            print(100*(n+1))
        else:
            print(100*100*(n+1))

Measured memory_bytes: 3064
use std::io;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut cnt = vec![0; n];
    for _ in 0..m {
        let (a, b) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1)
        };
        cnt[a] += 1;
        cnt[b] += 1;
    }
    if cnt.iter().all(|x| x % 2 == 0) { println!("YES"); }
    else { println!("NO"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
    cout<<fixed<<setprecision(16);
    ll n;
    cin>>n;
    vector<ll> sx(n),sy(n);
    vector<pair<double,ll>> a(n);
    double mx=0;
    double my=0;
    rep(i,n){
        cin>>sx[i]>>sy[i];
        double ang=450-atan2(sx[i],sy[i])*180/acos(-1);
        if(ang>=360)ang-=360;
        a[i]=make_pair(ang,i);
        mx+=sx[i];
        my+=sy[i];
    }
    sort(a.begin(),a.end());
    double ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i;j<n;j++){
            double x=0;
            double y=0;
            for(ll k=i;k<=j;k++){
                x+=sx[a[k].second];
                y+=sy[a[k].second];
            }
            ans=max(ans,sqrt(x*x+y*y));
            ans=max(ans,sqrt((mx-x)*(mx-x)+(my-y)*(my-y)));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
vector<ll int> v;
ll int dp[105][100005];
ll int fun(ll int i,ll int n)
{
    if(n==0)
    {
        dp[i][n]=1;
        return 1;
    }
    if(i==0)
    {
        if(n<=v[0])
            dp[i][n]=1;
        else
            dp[i][n]=0;
        return dp[i][n];    
    }
    else
    {
        ll int sum=0;
        if(dp[i][n-1]==-1)
            dp[i][n-1]=fun(i,n-1);
        sum=(sum%mod+dp[i][n-1]%mod)%mod;      
        if(dp[i-1][n]==-1)
            dp[i-1][n]=fun(i-1,n);
        sum=(sum%mod+dp[i-1][n]%mod)%mod;
        if(n>v[i])
        {
            if(dp[i-1][n-v[i]-1]==-1)
                dp[i-1][n-v[i]-1]=fun(i-1,n-v[i]-1);
            sum=(sum%mod-dp[i-1][n-v[i]-1]%mod+mod)%mod;
        }
        dp[i][n]=sum%mod;
        return dp[i][n];
    }
}
int main()
{
    ll int N,K,i,j,x;
    cin>>N>>K;
    for(i=0;i<N;i++)
    {
        cin>>x;
        v.pb(x);
    }
    for(i=0;i<N+5;i++)
    {
        for(j=0;j<K+5;j++)
        dp[i][j]=-1;
    }
    dp[0][0]=1;
    dp[N][K]=fun(N,K);
    cout<<dp[N][K]<<endl;
    return 0;
}

Measured memory_bytes: 88576
#include<stdio.h>

int main(){
    int x[4],y[4],i,j,h,b;
    while(~scanf("%d%d%d%d\n%d%d%d%d",x,x+1,x+2,x+3,y,y+1,y+2,y+3)){
        h=b=0;
        for(i=0;i<4;i++){
            for(j=0;j<4;j++){
                if(x[i]==y[j]){
                    if(i==j) h++; else b++;
                }
            }
        }
        printf("%d %d\n",h,b);
    }
    return 0;
}

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

int main(){
  int n,x,y;
  cin>>n>>x>>y;
  vector<int> ans(n,0);
  
  vector<vector<int>> def(n,vector<int>(n));//デフォルトの距離
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i>j)
        def.at(i).at(j)=i-j;
      else
        def.at(i).at(j)=j-i;
    }
  }
  vector<vector<int>> dis(n,vector<int>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int a;
      //int ans;
      if(i<j)
        a=def.at(i).at(x-1)+1+def.at(y-1).at(j);
      else
        a=def.at(j).at(x-1)+1+def.at(y-1).at(i);
      
      dis.at(i).at(j)=min(def.at(i).at(j),a);
      ans.at(dis.at(i).at(j))++;
      
      //cout<<i+1<<","<<j+1<<" "<<dis.at(i).at(j)<<endl;
    }
  }
  for(int i=1;i<n;i++)
    cout<<ans.at(i)/2<<endl;
  
  
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int n;
long long anss= LONG_MAX;


long long b[100005]={-1};
long long  cal(int a[], int n,int j,long long ans)
{ //out<<"here";
  
  if(j>n-1){
   //   cout<<ULONG_MAX;
    return LONG_MAX; 
  }
  if(j==n-1){
     // cout<<"here";
     
    return ans;
   
  }
  long long ans1 = ans + abs(a[j+1]-a[j]);
  long long ans2 = ans + abs(a[j+2]-a[j]);
  if(b[j]==-1){
      //cout<<j<<"here"<<endl;
      if(j+2!=n){ 
      b[j]= min(cal(a,n,j+1,ans1),cal(a,n,j+2,ans2));
      }else{
          
          b[j]=cal(a,n,j+1,ans1);
      }
      
      return b[j];
  }else{
      
      return b[j];
  }
  
}


int main()
{
  
  cin>>n;
  
  int a[n+1]={0};
  
  for(int i=0;i<n;i++){		
   		cin>>a[i];   
  }
  
  for(int i=0;i<100005;i++){
      b[i]=-1;
      
  }
  b[0]=0;
  b[1]=abs(a[0]-a[1]);
  for(int i=2;i<=n;i++){
      b[i]= min(b[i-1]+abs( a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
  }

  
  
  cout<<b[n-1];
  
  
  
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x=i,y=n/i*i,z=(y-x)/i+1;
		ans+=(x+y)*z/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3648
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main() {
	long x = readln.chomp.to!long;
	long left = 0;
	long right = x + 1;
	while (right - left > 1) {
		long mid = (left + right) / 2;
		long five = mid / 2;
		long six = mid - five;
		if (five * 5 + six * 6 < x) {
			left = mid;
		} else {
			right = mid;
		}
	}
	right.writeln;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int w,h,n;
int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};
string mp[20];

struct dat{
  int y1,x1;
  int y2,x2;
  int y3,x3;
};


int D[14][14][15][15][15][15];
queue<dat> Q;
void DD(dat &a,int b){D[a.y1-1][a.x1-1][a.y2-1][a.x2-1][a.y3-1][a.x3-1] = b;}
int DD(const dat &a){return D[a.y1-1][a.x1-1][a.y2-1][a.x2-1][a.y3-1][a.x3-1];}

bool check(const dat &a){
  if(mp[a.y1][a.x1]=='#') return 0;
  if(n>=2&&mp[a.y2][a.x2]=='#') return 0;
  if(n>=3&&mp[a.y3][a.x3]=='#') return 0;
  return DD(a)==-1;
}

void update(const dat &a){
  int cost = DD(a);

  for(int i=0;i<5;i++){
    int ny1 = a.y1+dy[i], nx1 = a.x1+dx[i];
    for(int j=0;j<5;j++){
      int ny2 = a.y2+dy[j], nx2 = a.x2+dx[j];
      if(n<=1) ny2 = 15,nx2 = 14;
      for(int k=0;k<5;k++){
	int ny3 = a.y3+dy[k], nx3 = a.x3+dx[k];
	if(n<=2) ny3 = 14,nx3 = 15;

	dat nt = (dat){ny1,nx1,ny2,nx2,ny3,nx3};
	if(!check(nt))continue;
	
	if((ny1==ny2&&nx1==nx2) ||(ny2==ny3&&nx2==nx3) ||(ny3==ny1&&nx3==nx1))continue;//same pos
	if(((a.y1==ny2&&a.x1==nx2) && (a.y2==ny1&&a.x2==nx1)) || // swap positoin
	   ((a.y2==ny3&&a.x2==nx3) && (a.y3==ny2&&a.x3==nx2)) ||
	   ((a.y3==ny1&&a.x3==nx1) && (a.y1==ny3&&a.x1==nx3)) )continue;
	
	Q.push(nt);
	DD(nt,cost+1);
      }
    }
  }
}

bool goal(const dat &s,const dat &t){
  char a = mp[s.y1][s.x1];
  char b = mp[s.y2][s.x2];
  char c = mp[s.y3][s.x3];
  char A = mp[t.y1][t.x1];
  char B = mp[t.y2][t.x2];
  char C = mp[t.y3][t.x3];
  return toupper(a)==A&&(n<=1||toupper(b)==B)&&(n<=2||toupper(c)==C);
}

int bfs(dat start){
  memset(D,-1,sizeof(D));
  while(!Q.empty())Q.pop();
  Q.push(start);
  DD(start,0);
  
  while(!Q.empty()){
    dat t = Q.front();Q.pop();
    if(goal(start,t)) return DD(t);
    update(t);
  }
  return 0;
}

int main(){
  while(1){
  cin>>w>>h>>n;
  if(!w&&!h&&!n)break;
  cin.ignore();
  for(int i=0;i<h;i++)getline(cin,mp[i]),mp[i]+='#';
  
  dat start = (dat){15,15,15,14,14,15};
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(!islower(mp[i][j]))continue;
      if(start.y1==15) start.y1=i,start.x1=j;
      else if(start.y2==15) start.y2=i,start.x2=j;
      else start.y3=i,start.x3=j;
    }
  cout<<bfs(start)<<endl;
  }
  return 0;
}

Measured memory_bytes: 47604
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	ans = 0
	for i in 1:n
		k = div(n,i)
		ans += i*(k*(k+1))>>1
	end
	println(ans)
end

main()

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

int main() {
	string a,b,c;
 	cin >> a >> b >> c;
	printf("%c",toupper(a.at(0)));
	printf("%c",toupper(b.at(0)));
	printf("%c",toupper(c.at(0)));
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
//↓,→,↑,←


#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll m = mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= m; b >>= 1;}(x *= a) %= m; b--;} return x;}
vec readvec(ll read) { vec res(read); for (int i = 0; i < read; i++) { cin >> res[i]; } return res;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5], rfact[fact_table + 5];

void c3_init() {
    fact[0] = rfact[0] = 1;
    for (ll i = 1; i <= fact_table; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table], mod - 2, mod);
    for (ll i = fact_table; i >= 1; i--) {
        rfact[i - 1] = rfact[i] * i;
        rfact[i - 1] %= mod;
    }
    return;
}
ll c3(ll n, ll r) {
    return (((fact[n] * rfact[r]) % mod ) * rfact[n - r]) % mod;
}
*/



struct Timer {
    int64_t start; const int64_t CYCLES_PER_SEC = 2800000000;
    Timer() { reset(); }
    void reset() { start = getCycle(); }
    inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
    inline int64_t getCycle() {
        uint32_t low, high; __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((int64_t)low) | ((int64_t)high << 32); 
    } 
};

bool multicase = false;


void solve() {
    ll n;
    cin >> n;
    ll res = mypow(10, n) - (mypow(9, n) + mypow(9, n) - mypow(8, n));
    res += mod * 10ll;
    res %= mod;
    p(res);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;
}



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

/** 
 * @brief dijkstra using set
 * O(nlogn)
 */
#define int long long
const int INF = 1 << 30;
const int N = 1e5 + 10;
vector<pair<int, int>> g[N];
int n, m, s;
int d[N];
bool visited[N];

void dijkstra(int source) {
  fill (d, d + n, INF);
  d[source] = 0;
  using p = pair<int, int>;
  set<p> s;
  s.insert({0, source});
  while (!s.empty()){
    int u = s.begin() -> second;
    s.erase(s.begin());
    for (auto it : g[u]){
      if (d[it.first]  > d[u] + it.second){
        s.erase({d[it.first], it.first});
        d[it.first] = d[u] + it.second;
        s.insert({d[it.first], it.first});
      }
    }
  }
}

int32_t main(){
  cin >> n >> m >> s;
  for (int i = 0; i < m; i++){
    int u, v, cost;
    cin >> u >> v >> cost;
    g[u].push_back({v, cost});
  }
  dijkstra(s);
  for (int i = 0; i < n; i++){
    if (d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}


Measured memory_bytes: 20624
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
const ll INF=(1e16);
int n,t;
ll a[maxn],dp[maxn][20],ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=0;i<=n;i++)
	for (int j=0;j<19;j++) dp[i][j]=-INF;
	dp[0][0]=0;
	ans=-INF;
	int R;
	for (int i=1;i<=n;i++) {
		for (int j=0;j<=10;j++) {
			dp[i][j]=-INF;
			if ((i+1)/2-j<=0) continue;
			R=i-1;
			if (i==1) R=1;
			for (int k=max(0,i-10);k<R;k++) {
				t=(k+1)/2-((i+1)/2-j-1);
				//if (i==1&&j==0) printf("%d %d %lld\n",k,t,dp[k][t]);
				if (0<=t&&t<=10) {
					if (dp[k][t]!=-INF) {
						dp[i][j]=max(dp[i][j],dp[k][t]+a[i]);
					}
				}
			}
			//printf("%d %d %d %lld\n",i,j,(i+1)/2-j,dp[i][j]);
			if ((i+1)/2-j==n/2) ans=max(ans,dp[i][j]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 36572
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=100005;
int n;
vector<pair<int,int> >res;
int main()
{
	scanf("%d",&n);
	int k=1;
	while(k<n) k<<=1;
	if(k==n)
	{
		printf("No");
		return 0;
	}
	res.push_back(make_pair(1,2));
	res.push_back(make_pair(2,3));
	res.push_back(make_pair(3,n+1));
	res.push_back(make_pair(n+1,n+2));
	res.push_back(make_pair(n+2,n+3));
	for(int i=2;2*i+1<=n;i++)
	{
		res.push_back(make_pair(2*i,2*i+1));
		res.push_back(make_pair(2*i+1,n+1));
		res.push_back(make_pair(n+1,n+2*i));
		res.push_back(make_pair(n+2*i,n+2*i+1));
	}
	if(n%2==0)
	{
		for(int x=2;x<=n-1;x++)
		{
			int y=n^1^x;
			if(y!=x&&y>=2&&y<=n-1)
			{
				int i,j;
				if(x&1) i=x;
				else i=x+n;
				if(y&1) j=y;
				else j=y+n;
				res.push_back(make_pair(n,i));
				res.push_back(make_pair(n+n,j));
				break;
			}
		}
	}
	printf("Yes\n");
	for(auto [x,y]:res)
		printf("%d %d\n",x,y);
	return 0;
}


Measured memory_bytes: 5280
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }

    let mut sw = Vec::new();
    for _ in 0..m {
        input! {
            k: usize,
            s: [u32; k],
        }
        let mut sw_byte: u32 = 0;
        for elem in s {
            sw_byte += 2_u32.pow(elem - 1)
        }
        sw.push(sw_byte);
    }

    input! {
        p: [u32; m],
    }

    let mut ans = 0;
    for light in 0..2_u32.pow(n as u32) {
        let mut flag = true;
        for i in 0..m {
            if (light & sw[i]).count_ones() % 2 != p[i] {
                flag = false;
                break;
            }
        }
        if flag {
            ans += 1;
        }
    }

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

Measured memory_bytes: 2200
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    ll n=s.size() , ans = 0;
    string str="";
    for(ll i=0;i<n;i++){
        if(s[i]=='A' || s[i]=='C')str+=s[i];
        else{
            if(i+1<n && s[i+1]=='C')str+="D",i++;
            else str+='C';
        }
    }
    n=str.size();
    for(ll i=0,cnt=0;i<n;i++){
        if(str[i]=='A')cnt++;
        else if(str[i]=='C')cnt=0;
        else{
            ans+=cnt;
        }
    }
    cout<<ans;
}




Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,i,j,n,m,k,cnt=0,sum=0,c=0;
    cin>>n>>m>>k;
    for(i=1;i<=k;i++){
        if(i%2==1){
            if(n%2!=0){
                n=n-1;
                n=n/2;
                m=m+n;
            }
            else{
                n=n/2;
                m=m+n;
            }
        }
        else{
            if(m%2!=0){
                m=m-1;
                m=m/2;
                n=n+m;
            }
            else{
                m=m/2;
                n=n+m;
            }
        }
    }
    cout<<n<<" "<<m<<endl;
    return 0;
}



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

using namespace std;

#define LL long long

int main()
{
	int n,T;
	scanf("%d%d",&n,&T);
	LL ans=0;
	int last;
	scanf("%d",&last);
	for(int i=2;i<=n;i++)
	{
		int t;
		scanf("%d",&t);
		ans+=min(t-last,T);
		last=t;
	}
	ans+=T;
	printf("%I64d\n",ans);
	return 0;
}

Measured memory_bytes: 384
c=[]
for _ in range(3):
  c.append(list(map(int,input().split())))
for i in range(2):
  if c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1] or c[i][1]-c[i+1][1]!=c[i][2]-c[i+1][2]:
    print('No')
    exit()
  if c[0][i]-c[0][i+1]!=c[1][i]-c[1][i+1] or c[1][i]-c[1][i+1]!=c[2][i]-c[2][i+1]:
    print('No')
    exit()
print('Yes')

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret=false;
            var s = Console.ReadLine();
            int X = int.Parse(s);
            var x10 = X % 100;
            var xover = X / 100;
            if (X == 0)
            {
                ret = false;
            }
            else if (xover * 5 >= x10)
            {
                ret = true;
            }
            else ret = false;

            if (ret)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
            //Console.ReadLine();

        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}
int n;
vector<vector<pii> > G;
vector<int> d;

void dfs(int v, int p) {
  for (pii P : G[v]) {
    int nv = P.F;
    int cost = P.S;
    if (nv == p) continue;
    d[nv] = d[v] + cost;
    d[nv] %= 2;
    dfs(nv, v);
  }
}
void solve() {
  cin >> n;
  G.resize(n);
  d.resize(n);

  rep(i, n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    c %= 2;
    G[a].eb(b, c);
    G[b].eb(a, c);
  }

  dfs(0, -1);
  rep(i, n) cout << d[i] << endl;
}


Measured memory_bytes: 8192
#include<iostream>  
    #include<map>  
    #include<vector>  
    using namespace std;  
      
    int main(){  
      
      int n, p, m, q;  
      string s, o, u;  
      map < string ,int > mp;  
      vector < string > vec;  
      
      while(cin >> n, n){  
      
        map < string ,int > mp;  
        vector < string > vec;  
          
        for(int i=0;i<n;i++){  
          cin >> s >> p;  
          mp[s] = p;  
          vec.push_back(s);  
        }  
      
        cin >> m;  
        for(int i=0;i<m;i++){  
          cin >> s >> p;  
      
          int k = 0;  
          for(int i=0;i<p;i++){  
        cin >> o;  
        k += mp[o];  
          }  
      
          mp[s] = min(mp[s], k);  
        }  
        cin >> s;  
        cout << mp[s] << endl;  
      }  
      
    }  

Measured memory_bytes: 1224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(4);
            out.println(Math.min(a[0], a[1]) + Math.min(a[2], a[3]));
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



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

	int N,W;
		int v[100],w[100];
		int dp[1000][10004];
int dfs(int i,int omosa){
	//int a1=0,a2=0;
	//cout<<i<<" "<<omosa<<endl;
	if(dp[i][omosa]>=0)return dp[i][omosa];
	if(i==N){
	dp[i][omosa]=0;
	 return 0;//すべての商品を試したとき.
	}
	
	if(omosa<w[i])return dp[i][omosa]=dfs(i+1,omosa);
	

	int a1=dfs(i+1,omosa);
	int a2=dfs(i+1,omosa-w[i])+v[i];
	//cout<<a1<<"#"<<a2<<endl;
	dp[i][omosa]=max(a1,a2);
	return max(a1,a2);

}

int main(){
	cin>>N>>W;
	for(int i=0;i<N;i++)cin>>v[i]>>w[i];
//	for(int i=0;i<N;i++)cout<<v[i]<<" "<<w[i]<<endl;
	for(int i=0;i<1000;i++){
		for(int j=0;j<10004;j++){
			dp[i][j]=-1;
		}
	}
	cout<<dfs(0,W)<<endl;
	
	return 0;
	}

Measured memory_bytes: 40244
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();
		Set<String> subs = new HashSet<>();
		for (int i = 0; i < s.length(); i++) {
			for (int j = i + 1; j < i + 1 + k && j <= s.length(); j++) {
				subs.add(s.substring(i, j));
			}
		}
		List<String> sublist = new ArrayList<>(subs);
		Collections.sort(sublist);
		System.out.println(sublist.get(k - 1));

	}
}


Measured memory_bytes: 25044