akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const lli mod = 1e9 + 7;
lli h, w;
vector<string> bd;
vector<vector<lli>> c;
int main() {
  cin >> h >> w;
  read_n(bd, h);
  for (lli i=0; i<h; ++i) bd[i].push_back('#');
  bd.emplace_back(w+1, '#');
  for (lli i=0; i<h+1; ++i) c.emplace_back(w+1, 0);
  c[0][0] = 1;
  queue<pair<lli, lli>> q;
  q.emplace(0, 0);
  while (!q.empty()) {
    auto p = q.front(); 
    lli x = p.first, y = p.second;
    q.pop();
    if (bd[y][x+1] != '#') {
      c[y][x+1] = (c[y][x] + c[y][x+1]) % mod;
      if (bd[y][x+1] == '.') {
	q.emplace(x+1, y);
	bd[y][x+1] = '*';
      }
    }
    if (bd[y+1][x] != '#') {
      c[y+1][x] = (c[y][x] + c[y+1][x]) % mod;
      if (bd[y+1][x] == '.') {
	q.emplace(x, y+1);
	bd[y+1][x] = '*';
      }
    }
  }
  cout << c[h-1][w-1] << endl;
  return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))


int n;
double t[110][2];
int weak[110];
bool visit[110];
const ll MOD = 100000007;
ll combi[110][110];

int main() {
  MEMSET(combi, 0);
  combi[0][0] = 1;
  REP(i, 103) {
    REP(j, 103) {
      combi[i + 1][j] = (combi[i + 1][j] + combi[i][j]) % MOD;
      combi[i + 1][j + 1] = (combi[i + 1][j + 1] + combi[i][j]) % MOD;
    }
  }
  while (scanf("%d", &n), n) {
    MEMSET(visit, false);
    REP(i, n) {
      int from;
      double p, q;
      scanf("%lf %d %lf", &p, &from, &q);
      t[i][0] = 1.0 / p;
      t[i][1] = 1.0 / q;
      weak[i] = from;
    }
    double ans = 0.0;
    ll cnt = 1;
    int total = 0;
    REP(i, n) {
      if (visit[i]) { continue; }
      double sum = 0.0;
      double minCost = 1e+10;
      int lcnt = 0;
      int index = i;
      int ltotal = 0;
      while (!visit[index]) {
        ltotal++;
        visit[index] = true;
        sum += t[index][1];
        double cost = t[index][0] - t[index][1];
        if (fabs(cost - minCost) < EPS) {
          lcnt++;
        } else if (cost - minCost <= -EPS) {
          minCost = cost;
          lcnt = 1;
        }
        index = weak[index];
      }
      ans += sum + minCost;
      cnt = (cnt * lcnt) % MOD;
      total += ltotal;
      cnt = (cnt * combi[total][ltotal]) % MOD;
    }
    printf("%.11f %lld\n", ans, cnt);
  }
}

Measured memory_bytes: 0
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [N, M] = lines[0].split(' ').map(Number)

const map = Array(N + 1).fill().map(_ => [])

for (let i = 1; i <= M; i++) {
    const [A, B] = lines[i].split(' ').map(Number)
    map[A].push(B)
    map[B].push(A)
}

const ans = Array(N + 1).fill(0)

let next = [1]
let i = 0
while (i = next.shift()) {
    for (let j = 0; j < map[i].length; j++) {
        if (!ans[map[i][j]]) {
            ans[map[i][j]] = i
            next.push(map[i][j])
        }
    }
}

ans[1] = 'Yes'
for (let i = 2; i <= N; i++) {
    if (!ans[i]) {
        ans[1] = 'No'
        break
    }
}
if (ans[1] === 'No') {
    console.log('No')
} else {
    ans.shift()
    console.log(ans.join("\n"))    
}

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

int main(){
  string A,B,C;
  cin>>A>>B>>C;
  A.append("E");
  B.append("E");
  C.append("E");
  char state='a';
  int i_a=-1,i_b=-1,i_c=-1;
  while(true){
    if(state=='a'){
      i_a ++;
      if(A[i_a]=='E'){
        cout << "A" << endl;
        return 0;
      }
      state = A[i_a];
    }else if(state=='b'){
      i_b ++;
      if(B[i_b]=='E'){
        cout << "B" << endl;
        return 0;
      }
      state = B[i_b];
    }else{
      i_c ++;
      if(C[i_c]=='E'){
        cout << "C" << endl;
        return 0;
      }
      state = C[i_c];
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    string sIn;
    int iLength;
    int i;
    char cStr;
    getline(cin,sIn);
    iLength=sIn.length();
    locale l = locale::classic();
    for (i=0;i<iLength;i++){
        cStr=sIn[i];
        if (isupper(cStr)){
            cout << tolower(cStr,l);
        }else{
            if (islower(cStr)){
                cout << toupper(cStr,l);
            }else{
                cout << cStr;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3192
#include <stdio.h>
long long p = 1000000007;
long long n, a, b, ans;
long long ka, kb, ja, jb;
long long rui(long long rui_a, long long rui_b) {
	if (rui_b == 0)return 1;
	if (rui_b == 1)return rui_a % p;
	long long rui_c;
	rui_c = rui(rui_a, rui_b / 2);
	rui_c = rui_c * rui_c % p;
	if (rui_b % 2) {
		return rui_c * rui_a % p;
	}
	return rui_c;
}
int main() {
	scanf("%lld%lld%lld", &n, &a, &b);
	ans = rui(2, n) - 1;
	ka = 1; kb = 1; ja = 1; jb = 1;
	for (long long i = 1; i <= a; i++) {
		ka *= i;
		ka %= p;
	}
	for (long long i = 1; i <= b; i++) {
		kb *= i;
		kb %= p;
	}
	for (long long i = n; i > n - a; i--) {
		ja *= i;
		ja %= p;
	}
	for (long long i = n; i > n - b; i--) {
		jb *= i;
		jb %= p;
	}
	ans -= ja * rui(ka, p - 2) % p;
	ans -= jb * rui(kb, p - 2) % p;
	ans += 2 * p;
	ans %= p;
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
#define F first
#define S second

int main() {
	int n, m, x[8] = { 1,2,3,4,5,6,7,8 }, ans = 0;
	bool l[10][10] = {};
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		l[a][b] = true;
		l[b][a] = true;
	}
	do {
		bool a = {};
		REP(i, n - 1) if (!l[x[i]][x[i + 1]]) a = true;
		if (!a) ans++;
	} while (next_permutation(x + 1, x + n));
	cout << ans << endl;
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		byte vals[][] = new byte[n][n];
		byte valsT[][] = new byte[n][n];
		for (int i = 0; i < n; i++) {
			String l = scanString();
			for (int j = 0; j < n; j++) {
				vals[i][j] = valsT[j][i] = (byte) l.charAt(j);
			}
		}
		int ans = 0;
		shift: for (int shift = 0; shift < n; shift++) {
			for (int i = 0; i < n; i++) {
				int ii = (i + n - shift) % n;
				byte[] vi = vals[i];
				byte[] viT = valsT[ii];
				for (int j = 0, jj = shift; j < n; j++, jj++) {
					if (jj == n) {
						jj = 0;
					}
					if (vi[j] != viT[jj]) {
						continue shift;
					}
				}
			}
			ans += n;
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

double dis(int a, int b, vector<int> X, vector<int> Y){
  double c = (X[a]-X[b])*(X[a]-X[b])+(Y[a]-Y[b])*(Y[a]-Y[b]);
  return sqrt(c);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  vector<vector<int>> memo(n, vector<int>(n));
  vector<int> x(n), y(n), vec(n);
  int zyo = 1;
  rep(i, n) {
    cin >> x[i] >> y[i];
    vec[i] = i;
    zyo *= i+1;
  }
  double ans, sum = 0;
  
  do{
    rep(i, n-1) {
      sum += dis(vec[i], vec[i+1], x, y);
    }
  }while (next_permutation(vec.begin(), vec.end()));
  
  ans = sum/zyo;
  
  printf("%.7lf", ans);
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	int n;cin>>n;
	
	for(int i=0;i*4<=n;i++){
		for(int j=0;i*4+j*7<=n;j++){
			if(i*4+j*7==n){
				cout<<"Yes"<<endl;return 0;
			}
		}
	}
	
	cout<<"No"<<endl;
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string S;
    i64 K;
    cin >> S >> K;
    rep(i,0,K){
        if(S[i]!='1'){
            cout << S[i] << endl;
            return;
        }
    }

    cout << 1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) {
  for (; a; swap(b %= a, a));
  return b;
}
inline ll lcm(ll a, ll b) {
  return a * (b / gcd(a, b));
}

signed main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll cc = b/c - a/c;
    cc += (a%c == 0);
    ll dd = b/d - a/d;
    //dd += (b%d == 0) + (a%d == 0);
    ll lcmcd = lcm(c, d);
    ll ee = b/lcmcd - a/lcmcd;
    ll ans = b - a + 1 - (cc + dd - ee);
    cout << ans << nl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  int i=1;
  bool flag = false;
  while(i<=B){
      if(K*i>=A&&K*i<=B){
          flag = true;
          break;
      }
      i++;
  }
  if(flag){
     cout << "OK" << endl;
  }else{
      cout << "NG" << endl;
  }
}


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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    int n;cin >> n;string s;cin >> s;
//    cout << s.substr(0 , n / 2) << " " << s.substr(n / 2 , n / 2) << endl;
    if(n % 2 == 0 && s.substr(0 , n / 2) == s.substr(n / 2 , n / 2))cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <iterator>
#include<algorithm>
#include<fstream>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
const int maxn = 2e5 + 5;
int  path[maxn];
bool vis[maxn];
vector<int>v[maxn];
queue<int>q;
void init()
{
    for (int i = 0; i < maxn; i++)vis[i] = 0;
    for (int i = 0; i < maxn; i++)v[i].clear();
    for (int i = 0; i < maxn; i++)path[i] = -1;
}
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    vis[1] = 1;
    q.push(1);
    int cnt = 1;

    while (!q.empty())
    {
        int t = q.front();
        q.pop();
        for (int i = 0; i < v[t].size(); i++)
        {
            int p = v[t][i];
            if (vis[p] == 1)continue;
            else { vis[p] = 1; cnt++; }
            path[p] = t;
            q.push( p );
        }

    }
    if (cnt < n) { cout << "No" << endl; return 0; }
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++)cout << path[i] << endl;

}

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

int main () {
  string S, T;
  cin >> S >> T;
  
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      count++;
    }
  }
    cout << count;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

dp = [[0, -100000000000] for i in range(n+1)]

for i in range(n):
    dp[i+1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i])
    dp[i+1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i])
    
print(dp[n][0])


Measured memory_bytes: 25588
a=input()
an=0
for i in range(len(a)):
  for j in range(i,len(a)):
   if len(a)-j-2>0:
       k1=len(a)-j-2
   else:
       k1=0
   if i-1>0:
       k2=i-1
   else:
       k2=0
   an+=int(a[i:j+1])*(2**(k1+k2))
print(an)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100100;
int i,j,k,n,m,q,ch,X;
int a[N],b[N],A[N],B[N],C[N],r[N],ans[N];
struct cc {
	int t,a,q;
	bool operator < (const cc &n) const {
		return t<n.t;
	}
} Q[N];
void R(int &x) {
	x=0;ch=getchar();
	while (ch<'0' || '9'<ch) ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
}
void W(int x) {
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int main() {
	R(X);
	R(n);
	for (i=1;i<=n;i++) R(r[i]);
	R(q);
	for (i=1;i<=q;i++) R(Q[i].t),R(Q[i].a),Q[i].q=i;
	sort(Q+1,Q+q+1);
	a[0]=0;b[0]=X;A[0]=0;B[0]=X;C[0]=0;
	for (i=1;i<=n;i++) {
		if (i&1) {
			int t=-(r[i]-r[i-1]);
			if (B[i-1]+t<0) {
				a[i]=X;A[i]=0;
				b[i]=X+1;B[i]=0;
				C[i]=0;
			}
			else {
				b[i]=b[i-1];
				B[i]=B[i-1]+t;
				if (A[i-1]+t>=0) {
					a[i]=a[i-1];
					A[i]=A[i-1]+t;
					C[i]=C[i-1]+t;
				}
				else {
					a[i]=-(C[i-1]+t);
					A[i]=0;
					C[i]=C[i-1]+t;
				}
			}
		}
		else {
			int t=r[i]-r[i-1];
			if (A[i-1]+t>=X) {
				a[i]=-1;A[i]=X;
				b[i]=0;B[i]=X;
				C[i]=X;
			}
			else {
				a[i]=a[i-1];
				A[i]=A[i-1]+t;
				if (B[i-1]+t<=X) {
					b[i]=b[i-1];
					B[i]=B[i-1]+t;
					C[i]=C[i-1]+t;
				}
				else {
					b[i]=X-(C[i-1]+t);
					B[i]=X;
					C[i]=C[i-1]+t;
				}
			}
		}
	}
	j=0;
	for (i=1;i<=q;i++) {
		while (j<n && r[j+1]<=Q[i].t) j++;
		int &res=ans[Q[i].q];
		if (Q[i].a<=a[j]) res=A[j];
		else {
			if (Q[i].a>=b[j]) res=B[j];
			else res=Q[i].a+C[j];
		}
		if (j&1) res+=Q[i].t-r[j];
		else res-=Q[i].t-r[j];
		if (res<0) res=0;
		if (res>X) res=X;
	}
	for (i=1;i<=q;i++) W(ans[i]),puts("");
}

Measured memory_bytes: 4992
package main 

import (
        "fmt"
        "unicode/utf8"
)

func main () {
        var s string
        var  ana int
        so := []string{}
        fmt.Scan(&s)
        ss := utf8.RuneCountInString(s)
        for i := 0 ; i < ss ; i++ {
                ko := i + 1
                lo := s[i:ko]
                so = append (so, lo)
        }
        for kk := 0 ; kk < ss ; kk++ {
                for ii:= 0 ; ii < ss ; ii++ {
                        if  so[kk] == so[ii]{
                                ana += 1
                        }
                }
        }
        if ana == ss{
                fmt.Println("yes")
        }  else if ana != ss{
                fmt.Println("no")
        }
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		if (n % 2 == 0)
			System.out.println(0.5);
		else
			System.out.println((double) (n + 1) / (2 * n));

	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxi =2e5 + 5;
 
char a[maxi];
 
int main() {
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++) {
		cin >> a[i];
	}
	int ans = 0 , i = 0 , j = n - 1;
	while(i < j) {
		if(a[j] == 'R' && a[i] == 'R') {
			i++;
		}
		else if(a[j] == 'R' && a[i] == 'W'){
			i++; j--;
			ans++;
		}
		else {
			j--;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3744
import java.util.*;

class Main{
    void solve(){
	int n;
	int[] S;
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	S = new int[n];
	for ( int i = 0; i < n; i++ ) S[i] = sc.nextInt();

	double res = 0.0;
	Arrays.sort(S);

	for ( int d = 0; d < n-1; d++ ){
	    int c = d+1;
	    int a = n-1;
	    int b = n-2;
	    if ( d == n-3 ){
		b = d-1;
	    } else if ( d == n-2 ){
		a = d-2;
		b = d-1;
	    }
	    res = Math.max(res, 1.0*(S[a]+S[b])/(S[c]-S[d]));
	}

	System.out.println(String.format("%.8f", res));
    }

    public static void main(String[] args){
	new Main().solve();
    }
	
}



Measured memory_bytes: 32012
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> c(9);
	for (int i = 0; i < 9; i++) {
		cin >> c.at(i);
	}
	if ((c.at(0) - c.at(1)) == (c.at(3) - c.at(4)) && (c.at(3) - c.at(4)) == (c.at(6) - c.at(7)) && c.at(1) -c.at(2) == c.at(4) - c.at(5) && c.at(7) - c.at(8) == c.at(4) - c.at(5) && c.at(0) - c.at(3) == c.at(1) - c.at(4) && c.at(1) - c.at(4) == c.at(2) - c.at(5) && c.at(3) - c.at(6) == c.at(4) - c.at(7) && c.at(4) - c.at(7) == c.at(5) - c.at(8)) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 384
n,a,b = map(int,input().split())
xi = [int(i) for i in input().split()]

ans = 0

for i in range(1,n):
    tmp_a = (xi[i] - xi[i-1])*a
    if tmp_a >= b:
        ans += b
    else:
        ans += tmp_a
        
print(ans)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,h[100010],a[100010],b[100010],t[100010],ans;
int main()
{
	cin>>n>>m;ans=n;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=m;i++)
	{
		cin>>a[i]>>b[i];
		if(h[a[i]]>h[b[i]])t[b[i]]++;
		if(h[a[i]]<h[b[i]])t[a[i]]++;
		if(h[a[i]]==h[b[i]]){t[b[i]]++;t[a[i]]++;}
	}
	for(int i=1;i<=n;i++)
	{
		if(t[i]!=0)ans--;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string ans = "second";
    for(int i=0;i<n;++i) {
        int x;
        cin>>x;
        if(x%2){
            ans = "first";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i) {
		int c = i;
		int sum = 0;
		while (c > 0) {
			sum += c % 10;
			c /= 10;
		}
		if (a <= sum && sum <= b) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = map(int, input().split())
    A = [int(v) // 2 for v in input().split()]

    def gcd(v1, v2):
        v = v1 % v2
        if v == 0:
            return v2
        return gcd(v2, v)

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    lcma = reduce(lcm, A)

    if next(filter(lambda v: (lcma // v) % 2 == 0, A), None) is not None:
        print(0)
        exit()

    print((M + lcma) // (2 * lcma))


main()


Measured memory_bytes: 14748
fun main(args : Array<String>) {
    val (n, y) = readLine()!!.split(" ").map { it.toInt() }

    for (i in 0..n) {
        for (j in 0..n-i) {
            val y10000 = 10000 * i
            val y5000 = 5000 * j
            val b1000 = Math.max(0, n - i - j)
            val y1000 = b1000 * 1000

            if (y10000 + y5000 + y1000 == y) {
                println("$i $j $b1000")
                return
            }
        }
    }

    println("-1 -1 -1")
}



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

#define N 4
#define N2 16

struct puzzle {
	int f[N2];
	int space;
	int depth;
	int MD;
	puzzle() { depth = 0; }
	bool operator <( const puzzle p ) const
	{
		for( int i = 0; i < N2; i++ ) {
			if( f[i] == p.f[i] ) continue;
			return f[i] < p.f[i];
		}
		return false;
	}
};

struct state {
	puzzle p;
	int score;
	bool operator >( const state s ) const
	{
		return score > s.score;
	}
};

int MDT[N2][N2];

int getSum( puzzle x )
{
	int sum = 0;
	for( int i = 0; i < N2; i++ ) {
		if( x.f[i] == N2 ) continue;
		sum += MDT[i][x.f[i] - 1];
	}
	return sum;
}

int main()
{
	puzzle sp;
	for( int i = 0; i < N2; i++ ) {
		cin >> sp.f[i];
		if( sp.f[i] == 0 ) {
			sp.space = i;
			sp.f[i] = N2;
		}
	}

	for( int i = 0; i < N2; i++ ) {
		for( int j = 0; j < N2; j++ ) {
			MDT[i][j] = abs( i / N - j / N ) + abs( i % N - j % N );
		}
	}
	state s;
	sp.MD = getSum( sp );
	s.p = sp;
	s.score = sp.MD;
	int dirh[] = { 0, 0, -1, 1 };
	int dirv[] = { -1, 1, 0, 0 };
	priority_queue<state, vector<state>, greater<state> > que;
	map<puzzle, int> m;
	que.push( s );
	int ans = 0;
	while( !que.empty() ) {
		state ts = que.top();
		que.pop();
		puzzle tp = ts.p;
		if( tp.MD == 0 ) {
			ans = tp.depth;
			break;
		}
		m[tp] = 1;
		int sy = tp.space / N;
		int sx = tp.space % N;
		for( int i = 0; i < 4; i++ ) {
			int nx = sx + dirh[i];
			int ny = sy + dirv[i];
			if( nx < 0 || N <= nx || ny < 0 || N <= ny ) continue;
			int ni = ny * N + nx;
			puzzle v = tp;
			v.MD -= MDT[ni][v.f[ni] - 1];
			v.MD += MDT[tp.space][v.f[ni] - 1];
			swap( v.f[ni], v.f[v.space] );
			v.space = ni;
			if( m.find( v ) == m.end() ) {
				v.depth++;
				state news;
				news.p = v;
				news.score = v.MD + v.depth;
				que.push( news );
			}
		}
	}

	cout << ans << endl;
}



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

using namespace std ;

#define N 500
#define M 200000

int n , m ;
int dp[N][N] , a[M] , b[M] , vis[M] ;

int main()
{
    scanf("%d%d" , &n , &m ) ;
    for(int i = 1 ; i <= m ; i++ ){
        scanf("%d%d" , &a[i] , &b[i] ) ;
    }
    for(int i = 1 ; i <= n ; i++ ){
        dp[i][i] = 1 ;
        for(int j = m ; j >= 1 ; j-- ){
            if( dp[i][a[j]] && dp[i][b[j]] ) vis[i] = 1 ;
            else if( dp[i][a[j]] ) dp[i][b[j]] = 1 ;
            else if( dp[i][b[j]] ) dp[i][a[j]] = 1 ;
        }
    }
    int ans = 0 ;
    for(int i = 1 ; i <= n ; i++ ){
        if( vis[i] ) continue ;
        for(int j = i + 1 ; j <= n ; j++ ){
            if( vis[j] ) continue ;
            int t = 0 ;
            for(int k = 1 ; k <= n ; k++ ){
                if( dp[i][k] && dp[j][k] ) t = 1 ;
            }
            ans += ( t == 0 ) ;
        }
    }
    printf("%d\n" , ans ) ;
    return 0 ;
}

Measured memory_bytes: 1792
#include<stdio.h>
main(){
  int a,b,c,d,e,f,g=0;
  while(1){
    g=0;
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)break;
    for(c=1;c<a+1;c++){
      for(d=1;d<a+1;d++){
	for(e=1;e<a+1;e++){
	  f=c+d+e;
	  if(f==b && c!=d && d!=e && c!=e && c<=d &&d<=e){
	    g=g+1;
	  }
	}
      }
    }
    printf("%d\n",g);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
     
#define int  unsigned long long
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e5 + 11;
int p[N], sz[N];

int get(int x){
  if (p[x] == x) return x;
  return p[x] = get(p[x]);
}

void unite(int x, int y){
  x = get(x), y = get(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  p[y] = x;	
}

void solve(){
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    p[i] = i, sz[i] = 1;
  vector<int> check(m);
  for (int i = 1; i <= n; i++){
	 int k;
	 cin >> k;
	 for (int j = 1; j <= k; j++){
	   int idx;
	   cin >> idx;
	   if (check[idx] > 0) unite(i, check[idx]);
	   else check[idx] = i;
	 }
  }
  int ret = 0;
  for (int i = 1; i <= n; i++)
    ret += get(i) == i;
  if (ret == 1) cout << "YES" << endl;
  else cout << "NO" << endl;  	
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();	
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> m;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(i > 0) m[i-a[i]]++;
    }
    ll ans = 0;
    for(int i = 0; i < n-1; i++)
    {
        int v = a[i] + i;
        ans += m[v];
        m[i+1-a[i+1]]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 21100
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<vector<ll>> score(8, vector<ll>(n));
    rep(i, n){
        ll x, y, z;
        cin >> x >> y >> z;

        //３つのプラマイを優先に
        rep(j, 8){
            ll v = 0;
            
            //ビットが立っていると正が嬉しい
            if(j & 1)v += x;
            else v -= x;

            if(j & 2)v += y;
            else v -= y;

            if(j & 4)v += z;
            else v -= z;
            
            score[j][i] = v;
        }
    }

    ll ans = 0;
    rep(i, 8){
        sort(ALL(score[i]), greater<ll>());
        ll res = 0;
        rep(j, m)res += score[i][j];
        ans = max(ans, res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll INF = (1LL<<34);
P t[100];
ll dp[100][100];
  
P on(P x,P y){
  return P(x.first,y.second);
}
  
ll cost(P x,P y){
  return x.first*x.second*y.first*y.second;
}
  
int compute(int a,int b){
  if(dp[a][b]!=INF)return dp[a][b];
  if(a==b)return 0;

  ll sum;
  P X,Y;
  for(int i=a;i<b;i++){
    X=on(t[a],t[i]);
    Y=on(t[i+1],t[b]);
      
    sum=cost(X,Y);
    sum = compute(a,i)+ sum +compute(i+1,b) ;
    dp[a][b]=(sum<dp[a][b]?sum:dp[a][b]);
  
  }
  return dp[a][b];
}
  
int main(){
  
  while(cin>>n&&n){
    for(int i=0;i<n;i++)cin>>t[i].first>>t[i].second;
    for(int i=0;i<100;i++)for(int j=0;j<100;j++)dp[i][j]=INF;
    cout<<compute(0,n-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int inf = TEN(9) + 10;

int N, M;
vi A;
int rui[100010];

int calc(int x)
{
	int res = 0;
	
	rep(i, N) {
		res += upper_bound(all(A), x - A[i], greater<int>()) - begin(A);
	}

	return res;
}

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

	A.resize(N);

	rep(i, N) cin >> A[i];
	sort(all(A), greater<int>());

	int ok = 0, ng = inf;

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		int tmp = calc(mid);

		if (tmp >= M) {
			ok = mid;
		} else {
			ng = mid;
		}
	}

	int counter = calc(ok);

	int ans = 0;

	rep(i, N) {
		rui[i + 1] += rui[i] + A[i];
	}

	rep(i, N) {
		int pos = upper_bound(all(A), ok - A[i], greater<int>()) - begin(A);

		ans += rui[pos] + A[i] * pos;
	}

	ans -= (counter - M) * ok;

	cout << ans << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
n, k, *a = map(int, open(0).read().split())
ans = 10**18
for i in range(2 << n):
    h = 0
    c = 0
    b = 0
    for j in range(n):
        if a[j] > h:
            b += 1
            h = a[j]
        elif i >> j & 1:
            c += h - a[j] + 1
            h += 1
            b += 1
    if b >= k:
        ans = min(ans, c)
print(ans)


Measured memory_bytes: 73552
// ConsoleApplication2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <bits/stdc++.h>

using namespace std;




int main() {
	int H, W;
	cin >> H >> W;
	

	vector<vector<char>>A(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {          /*受け取り*/
			cin >> A.at(i).at(j);
		}
	}

	int x[8] = {-1,-1,-1,0,0,1,1,1};
	int y[8] = {-1,0,1,1,-1,-1,0,1};

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A.at(i).at(j) == '#') {
				continue;
			}int count = 0;
			for (int k = 0; k < 8; k++) {
				int ni = i + y[k];
				int nj = j + x[k];

				if (0 <= ni && 0 <= nj && ni < H && nj < W) {

				if (A.at(ni).at(nj) == '#') {
					
					count = count + 1;
					
				}
			  }
			}A.at(i).at(j) = char(count + '0');

				
		}
	}

	cout << endl;/*図の出力*/
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << A.at(i).at(j);
		}cout << endl;
	}
}



Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#define Max 10000000
typedef struct  {
        char name[100];
        int t;

} P;
P Q[Max];
int head,tail,n;
int isFull(){
        return head==(tail+1)%Max;
}
void initialize(){
        head=0;
        tail=0;
}
int isEmpty(){
        if(head==tail) {
                return 1;
        }
        else return 0;
}
void enqueue(P x){
        if(isFull()) {
                fprintf(stderr,"Overflow\n");
        }
        Q[tail]=x;
        if(tail+1==Max) {
                tail=0;
        }
        else{
                tail++;
        }

}

P dequeue(){
        if(isEmpty()) {
                fprintf(stderr,"Underflow\n");

        }
        if(head+1==Max) {
                head=0;
        }
        else{
                head++;


        }
        P x=Q[head];

        return x;

}
int min(int a,int b){
        return a < b ? a : b;
}
int main(){
        int L=0,c;
        int i,q;
        P a;
        scanf("%d%d",&n,&q);
        for(i=0; i<n; i++) {
                scanf("%s",&Q[i+1].name);
                scanf("%d",&Q[i+1].t);
        }

        head=0;
        tail=n+1;
        while(head!=tail) {
                a=dequeue();
                c=min(q,a.t);
                a.t=a.t-c;
                L=L+c;
                if(a.t>0) enqueue(a);
                else{
                        if(head-tail!=0)
                                printf("%s %d\n",a.name,L);
                }
        }
        return 0;

}



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

int main(){
    int N;cin>>N;
    int cnt=0;
    ll abs_min=1e+9;
    vector<ll> A(N,0);
    rep(i,N){
        cin>>A[i];
        abs_min = min(abs_min,abs(A[i]));
        if(A[i]<0)cnt++;
    }
    ll ans=0;
    rep(i,N)ans+=abs(A[i]);
    if(cnt%2 == 1)ans-=2*abs_min;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	vector<int> Vec;
	Vec.reserve(3);
	int n;
	for (int i=0; i<3; i++) {
		cin >> n;
		Vec.push_back(n);
	}
	sort(Vec.begin(), Vec.end());
	for (int i=0; i<3; i++) {
		cout << Vec[i];
		if (i < 2) {
			cout << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		for (int i = 0; i < N; i++) {
			T[i] = sc.nextInt();
		}
		int M = sc.nextInt();
		int[][] PX = new int[M][2];
		for (int i = 0; i < M; i++) {
			PX[i][0] = sc.nextInt();
			PX[i][1] = sc.nextInt();
		}
		for (int i = 0; i < M; i++) {
			int index = PX[i][0] - 1;
			int time = PX[i][1];
			int total = 0;
			for (int j = 0; j < N; j++) {
				if (j == index) {
					total += time;
				} else {
					total += T[j];
				}
			}
			System.out.println(total);
		}
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<string> 
using namespace std;
int n,m;
string s;
bool no=false;
int main()
{
	cin>>s;
	if(s[2]=='n')
		cout<<"Cloudy"<<endl;
	else if(s[2]=='o')
		cout<<"Rainy"<<endl;
	else
		cout<<"Sunny"<<endl;			
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
queue<P > que;
void move(string st,int x){
  int pos;
  int look[4]={-3,3,-1,1};//up do le ri
  for(int i=0;i<9;i++){
    if(st[i]=='0'){
      pos=i;
      break;
    }
  }
  for(int i=0;i<4;i++){
    string str=st;
    if(i==2&&pos%3==0)continue;
    if(i==3&&pos%3==2)continue;
    int npos=pos+look[i];
    if(npos>8||npos<0)continue;
    swap(str[pos],str[npos]);
    que.push(P(str,x+1));
  }
}
int main(){
  string puzzle="";
  string goal="123456780";
  map<string,bool> ma;
  for(int i=0;i<9;i++){
    int x;
    cin >> x;
    puzzle+='0'+x;
  }
  que.push(P(puzzle,0));
  while(1){
    P p=que.front();que.pop();
    string puz=p.first;
    int x=p.second;
    if(puz==goal){
      cout << x << endl;
      break;
    }
    if(ma[puz])continue;
    else ma[puz]=1;
    move(puz,x);
  }
  return 0;
}

Measured memory_bytes: 24452
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


s = ns()

cur = 0
anum = 0
bcnum = 0
ans = 0

while cur < len(s):
    if s[cur:cur+1] == "A":
        anum += 1
        cur += 1

    elif s[cur:cur+2] == "BC":
        bcnum += 1
        ans += anum
        cur += 2

    else:
        anum = 0
        bcnum = 0
        cur += 1

print(ans)

Measured memory_bytes: 3500
K=int(input())

G=[1,2,3,4,5,6,7,8,9]

def Judge1(number):
    letter=str(number)
    judge=1
    if number==1:
        judge=0
    elif letter[0]!='1':
        judge=0
    else:
        for i in range(1,len(letter)):
            if letter[i]!='0':
                judge=0
                break 
    return judge

def Judge9(number):
    letter=str(number)
    judge=1
    for i in range(len(letter)):
        if letter[i]!='9':
            judge=0
            break
    return judge

def generate(number):
    if Judge1(number)==1:
        return [number*10,number*10+1]
    elif Judge9(number)==1:
        return [number*10+8,number*10+9]
    else:
        letter=str(number)
        newnumber=int(letter+letter[-1])
        return [newnumber-1,newnumber,newnumber+1]

def Generate(L):
    A=[]
    for i in range(len(L)):
        A.extend(generate(L[i]))
    return A

def check(number):
    letter=str(number)
    judge=1
    for i in range(len(letter)-1):
        if abs(int(letter[i])-int(letter[i+1]))>1:
            judge=0
            break
    return judge

Ans=[G]
ANS=[1,2,3,4,5,6,7,8,9]
for x in range(9):
    N=Generate(Ans[-1])
    NN=[]
    for y in range(len(N)):
        if check(N[y])==1:
            NN.append(N[y])
    Ans.append(NN)
    ANS.extend(NN)


#print(Ans)
#print(LastANS)
#print(len(ANS))
print(ANS[K-1])





    

    


Measured memory_bytes: 14448
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18:1e9+10;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vi c(m);
		rep(i,m)cin>>c[i];
		vi x(n);
		rep(i,n)cin>>x[i];
		vvi dp(n+1,vi(256,inf));
		dp[0][128]=0;
		rep(i,n)rep(j,256)if(dp[i][j]!=inf){
			rep(k,m){
				int ne=j+c[k];
				ne=max(ne,0);
				ne=min(ne,255);
				dp[i+1][ne]=min(dp[i+1][ne],dp[i][j]+(ne-x[i])*(ne-x[i]));
			}
		}
		int out=inf;
		rep(i,256)out=min(out,dp[n][i]);
		cout<<out<<endl;
		
	}
}







Measured memory_bytes: 23796
#include <iostream>
#include <cmath>

using namespace std;

int main () {
	int n, k;
	cin >> n >> k;
	int vis[n];
	long long dp[n];
	dp[0] = 0;
	
	for (int i=0; i<n; i++){
		cin >> vis[i];
	}
	
	for (int i=1; i<n; i++){
		dp[i] = 1000000000000;
		for (int j=1; j<=k; j++){
			if (i-j < 0) continue;
			dp[i] = min(dp[i], dp[i-j]+abs(vis[i]-vis[i-j]));
		}
	}
	
	cout << dp[n-1];
return 0;
}



Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#define maxn 100005
int h[maxn];
int dp[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
		cin>>h[i];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
s = input()

answer = "Yes"

for i in range(len(s)):
	if i % 2 == 0:
		if s[i] not in ["R", "U", "D"]:
			answer = "No"
	else:
		if s[i] not in ["L", "U", "D"]:
			answer = "No"
	if answer == "No":
		print(answer)
		exit()
print(answer)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    cin >> n;

    if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
    {
        cout << "hon" << endl;
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int data[5][11];
int n;

void ShowaBan(){
	REP(i,n){
		REP(j,5){
			cout << data[j][i] << " ";
		}
		cout << endl;
	}
	cout << endl;
}

int solve(){
	int res = 0;
	REP(i,n){
		int lt = 2;
		int rt = 2;
		while(lt>=0){
			if(data[lt][i]==data[2][i]) lt--;
			else {
				lt++;
				break;
			}
		}
		while(rt<=4){
			if(data[rt][i]==data[2][i]) rt++;
			else {
				rt--;
				break;
			}
		}
		if(rt==5) rt=4;
		if(lt==-1) lt = 0;
		int num = rt-lt+1;
		if(num>=3){
			res += num*data[2][i];
			FOR(j,lt,rt+1){
				data[j][i]=-1;
			}
		}
	}

	//ShowaBan();
	REP(j,5){
		queue<int> qt;
		for(int i=n-1;i>-1;i--){
			if(data[j][i]!=-1) qt.push(data[j][i]);
		}
		REP(i,11) data[j][i] = 0;
		int t = n-1;
		while(!qt.empty()){
			data[j][t] = qt.front();
			qt.pop();
			t--;
		}

	}

	//ShowaBan();
	return res;
}
int main(){

	while(1){
		cin >> n;
		if(n==0) break;
		REP(i,5)REP(j,11) data[i][j] = 0;
		REP(i,n)REP(j,5) cin >> data[j][i];
		ll int ans = 0;
		while(1){
			int tmp = solve();
			if(tmp<=0) break;
			ans += tmp;
		}
		cout << ans << endl;
	}
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}



li a[100100];

int main() {
    li n;
    cin >> n;
    rin{
        cin >> a[i];
    }
    rin{
        if (a[i] % 2 > 0) {
            puts("first");
            return 0;
        }
    }
    puts("second");


    return 0;
}

Measured memory_bytes: 1024