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

#define Bye return 0
#define ll long long

using namespace std;

const int M = 1e9+7;

ll modPow(ll a, ll b){
    ll res = 1;
    a %= M;
    while(b>0){
        if(b&1) res = res * a % M;
        a = a * a % M;
        b >>= 1;
    } return res;
}

ll modSum(ll a, ll b){
    return (a%M+b%M)%M;
}

ll modSub(ll a, ll b){
    return ((a%M)-(b%M)+M)%M;
}

ll modMul(ll a, ll b){
    return ((a%M)*(b%M))%M;
}

void solve(){
    ll n; cin>>n;
    cout<<modSub(modSum(modPow(10, n), modPow(8, n)), modMul(2, modPow(9, n)))<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}

void solve(){
	ll n;
	cin>>n;
	vl v(n);
	for(ll i=0;i<n;i++)cin>>v[i];
	rsort(v);
	int pos=0;
	ll ans=0;
	for(int i=1;i<n;i++){
		ans+=v[pos];
		if(i&1)pos++;
	}
	cout<<ans;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	while(numberofsubtestcases--){
		solve();
	}
}

Measured memory_bytes: 4828
fn main() {
    use std::io::*;
    let mut stdin = BufReader::new(stdin());
    let mut s = String::new();
    stdin.read_line(&mut s).unwrap();

    let second = s.trim().parse::<i32>().unwrap();
    let (hour, second2) = divmod(second, 3600);
    let (minute, second3) = divmod(second2, 60);

    println!("{}:{}:{}", hour, minute, second3);
}

fn divmod(mut x: i32, y: i32) -> (i32, i32) {
    let mut divide:i32 = 0;
    while x >= y {
        x -= y;
        divide += 1;
    }
    return (divide, x);
}


Measured memory_bytes: 5028
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, Q; cin >> N >> Q;
	vector<ll> _len(Q);
	for (ll& x: _len) scanf("%lld", &x);
	reverse(_len.begin(), _len.end());
	_len.push_back(N);
	vector<ll> len;
	ll mi = LLONG_MAX;
	for (ll x: _len)
		if (x < mi) {
			len.push_back(x);
			mi = x;
		}
	Q = len.size();
	reverse(len.begin(), len.end());
	vector<ll> dp(Q), ans(N + 1);
	dp[Q - 1] = 1;
	for (int k = Q - 1; k >= 0; k--) {
		ll x = len[k], z = dp[k];
		for (;;) {
			int k = lower_bound(len.begin(), len.end(), x) - len.begin();
			if (!k) break;
			k--;
			dp[k] += (x / len[k]) * z;
			x %= len[k];
		}
		ans[x] += z;
	}
	for (int i = N - 1; i >= 0; i--)
		ans[i] += ans[i + 1];
	for (int i = 1; i <= N; i++)
		printf("%lld\n", ans[i]);
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;//T

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  while((u != NIL) && (k != u->key)){
    if (k < u->key){
    u = u->left;
    } 
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){

    
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y




}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  /*場所を探している*/
  while(x != NIL){
    y = x;
    if (z->key < x->key)
    x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if (y == NIL)
  root = z;
  else if(z->key < y->key)
    y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL) {
    if(u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if(u->right != NIL) inorder(u->right);
  }
}
void preorder(Node u){ 
  if(u != NIL) {
    printf(" %d",u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

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

  return 0;
}

Measured memory_bytes: 19364
x, y = map(int, input().split())
g = [set([1, 3, 5, 7, 8, 10, 12]), set([4, 6, 9, 11]), set([2])]
for s in g:
    if x in s and y in s:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 9084
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int N;

void func(){

	double minimum = (double)BIG_NUM,tmp;
	int ans_S,ans_A,ans_C,M=256,R[N+1],input[N+1],O[N+1],check[256];

	for(int i = 1; i <= N; i++)scanf("%d",&input[i]);

	for(int s = 0; s <= 15; s++){
		for(int a = 0; a <= 15; a++){
			for(int c = 0; c <= 15; c++){
				for(int i = 0; i <= 255; i++)check[i] = 0;
				R[0] = s;
				for(int i = 1; i <= N; i++){
					R[i] = (a*R[i-1]+c)%M;
					O[i] = (input[i]+R[i])%M;
					check[O[i]]++;
				}
				tmp = 0.0;
				for(int i = 0; i <= 255; i++){
					if(check[i] == 0)continue;
					tmp += (double)-1*((double)check[i]/(double)N)*log((double)check[i]/(double)N);
				}

				if(minimum - tmp > 0.0000000001){
					minimum = tmp;
					ans_S = s;
					ans_A = a;
					ans_C = c;
				}
			}
		}
	}

	printf("%d %d %d\n",ans_S,ans_A,ans_C);

}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 2824
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    long max = -1000001;
    long min = 1000001;
    long sum = 0;
    for (int i = 0; i < n; i++) {
        long ai;
        scanf("%ld", &ai);
        if (max < ai) {
            max = ai;
        }
        if (min > ai) {
            min = ai;
        }
        sum += ai;
    }
    printf("%ld %ld %ld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 3224
using System;

class Program{
    class Card{
        public int value;
        public char suit;
        public Card(char suit, int value){
            this.suit=suit;
            this.value=value;
        }
    }

    static void BubbleSort(Card[] C){
        for(var i=0; i<C.Length; i++){
            for(var j=C.Length-1; j>i; j--){
                if(C[j].value<C[j-1].value){
                    var tmp=C[j];
                    C[j]=C[j-1];
                    C[j-1]=tmp;
                }
            }
        }
    }

    static void SelectionSort(Card[] C){
        for(var i=0; i<C.Length; i++){
            var mini=i;
            for(var j=i; j<C.Length; j++){
                if(C[j].value<C[mini].value){
                    mini=j;
                }
            }
            var tmp=C[i];
            C[i]=C[mini];
            C[mini]=tmp;
        }
    }

    public static void Main(){
        var N=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var A=new Card[N];
        var B=new Card[N];
        for(var i=0; i<N; i++){
            A[i]=new Card(s[i][0], int.Parse(""+s[i][1]));
            B[i]=new Card(s[i][0], int.Parse(""+s[i][1]));
        }

        BubbleSort(A);
        for(var i=0; i<N; i++){
            Console.Write(""+A[i].suit+A[i].value);
            if(i>=N-1){
                Console.WriteLine();
            } else{
                Console.Write(" ");
            }
        }
        Console.WriteLine("Stable");

        SelectionSort(B);
        for(var i=0; i<N; i++){
            Console.Write(""+B[i].suit+B[i].value);
            if(i>=N-1){
                Console.WriteLine();
            } else{
                Console.Write(" ");
            }
        }
        var stable=true;
        for(var i=0; i<N; i++){
            if(A[i].suit!=B[i].suit){
                stable=false;
                break;
            }
        }
        if(stable){
            Console.WriteLine("Stable");
        } else{
            Console.WriteLine("Not stable");
            
        }
    }
}

Measured memory_bytes: 9276
n = int(input())
s=[int(input()) for i in range(n)]
ans = sum(s)
s.sort()
if ans % 10 != 0:
    print(ans)
else:
    k = -1
    for i in range(n):
        if s[i]% 10 != 0:
            k = s[i]
            break
    if k >= 0:
        print(ans-k)
    else:
        print(0)

Measured memory_bytes: 3060
import sys
import math
 
# 入力
a, b, c = map(int, input().split())
# 計算
if a < (b + 2*c):
    print("a >= b + 2*cとなるようにしてください")
    sys.exit()
elif a == (b + 2*c):
    print("1")
else:
    max = math.floor((a - c) / (b + c))
    print(max)

    


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, dp[110][4][4][4], ans = 0;

int main() {
	cin >> n;
	REP(i, 4)REP(j, 4)REP(k, 4) dp[3][i][j][k] = 1;
	dp[3][1][2][3] = 0;
	dp[3][1][3][2] = 0;
	dp[3][2][1][3] = 0;
	FOR(no, 3, n) {
		REP(i, 4) {
			REP(j, 4) {
				REP(k, 4) {
					if (j == 1 and k == 3) {
						REP(ne, 4) {
							if (ne != 2) dp[no + 1][1][3][ne] += dp[no][i][j][k];
						}
					}
					else if (j == 2 and k == 1) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][2][1][ne] += dp[no][i][j][k];
						}
					}
					else if (j == 1 and k == 2) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][1][2][ne] += dp[no][i][j][k];
						}
					}
					else if (i == 1 and j == 2) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][2][k][ne] += dp[no][i][j][k];
						}
					}
					else if (i == 1 and k == 2 and j != 2) {
						REP(ne, 4) {
							if (ne != 3) dp[no + 1][j][2][ne] += dp[no][i][j][k];
						}
					}
					else {
						REP(ne, 4) {
							dp[no + 1][j][k][ne] += dp[no][i][j][k];
						}
					}
					REP(ii, 4)REP(jj, 4)REP(kk, 4) dp[no + 1][ii][jj][kk] %= MOD;
				}
			}
		}
	}
	REP(i, 4)REP(j, 4)REP(k, 4) ans += dp[n][i][j][k];
	cout << ans % MOD << endl;
}


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

void solveA(){
  int n,k;
  cin >> n >> k;

  if (k <= (n+1)/2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
void solveB(){
  int a[3],b[3];
  int cnt[4] = {0};
  bool flg = true;

  for(int i=0;i<3;i++){
    cin >> a[i] >> b[i];
    cnt[a[i]-1] ++;
    cnt[b[i]-1] ++;
  }

  for(int i=0;i<4;i++){
    if (cnt[i] >= 3) flg = false;
  }
  if (flg) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}
void solveC(){
  long long k,a,b;
  cin >> k >> a >> b;
  bool flg = true;
  long long bis = 1;
  long long del = b-a;

  if (del<=2) flg = false;

  for(long long i=1;i<=k;i++){
    if (bis>=a && (k-i>=1 && flg)){
	bis+=del;
	i ++;
    }
    else {
      bis ++;
    }
  }
  cout << bis << endl;

}
void solveD(){
}

int main(){
  solveC();
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,l,q,x[100001],a,b,dp[17][100001],ans;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    x[n]=x[n-1]+l+1;
    scanf("%d",&l);
    int p;
    p=1;
    for(int i=0;i<n;i++){
        while(x[p]<=x[i]+l&&p<n){
            p++;
        }
        dp[0][i]=p-1;
    }
    dp[0][n]=dp[0][n-1]=n;
    for(int i=1;i<17;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=dp[i-1][dp[i-1][j]];
        }
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d %d",&a,&b);
        a--;
        b--;
        if(a>b){
            a^=b;
            b^=a;
            a^=b;
        }
        ans=0;
        p=a;
        for(int j=16;j>=0;j--){
            if(dp[j][p]<=b){
                ans+=(1<<j);
                p=dp[j][p];
            }
        }
        if(p!=b){
            ans++;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <random>
using namespace std;
using ll = long long;

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

    int s[2] = {};
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        s[x < a] += 1;
    }

    cout << min(s[0], s[1]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define pb push_back
#define rr return 0
#define fi first
#define se second
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define sz(s) s.size()
using namespace std;
//Debug template by livw
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

//ll pm(ll x,ll y){ll res = 1;while(y>0){if(y&1) res = (res*x)%mod;x= (x*x)%mod;y/=2;}return res;}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
 fastio;
ll x,k,d;
cin>>x>>k>>d;
x=abs(x);
if(x/d>=k)cout<<x-k*d;
else
{
  k-=x/d;
  x-=(x/d)*d;
  if(k%2)cout<<abs(x-d);
  else cout<<abs(x);
}


rr;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n,c;
    cin >> n >> c;
//    for(i,3)for(j,c)table[i][j]=1e9;

    int d[31][31];
    REP(i,c)REP(j,c)cin >> d[i][j];

//    REP(i,c)REP(j,c)cout << d[i][j] << (j!=c-1?" ":"\n");


    int x;
    int table[3][c]={{}};
    REP(i,3)REP(j,c)table[i][j]=0;
    REP(i,n)REP(j,n){
        cin >> x;
        table[(i+j+2)%3][x-1]++;
    }

//    REP(i,3)REP(j,c)cout << table[i][j] << (j!=c-1?" ":"\n");
//    REP(i,c)REP(j,c)cout << d[i][j] << (j!=c-1?" ":"\n");

    ll sum[3][c]={{}};
    REP(i,3)REP(j,c)sum[i][j]=0;

    REP(k,3){
        REP(i,c){
            REP(j,c){
                sum[k][i]+=table[k][j]*d[j][i];
            }
        }
    }
    ll mi=LONG_MAX;

    REP(i,c){
        REP(j,c){
            REP(k,c){
                if(i==j||j==k||k==i)continue;
                mi=min(mi,sum[0][i]+sum[1][j]+sum[2][k]);
            }
        }
    }
    cout << mi << endl;
}


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

int a[4];
int op[3];
bool f=true;

void dfs(int p,int q){
    if(q==4){
        if(p==7){
            f=false;
        }
        return ;
    }
    int t=p;
    t+=a[q];
    if(f) op[q-1]=0;
    dfs(t,q+1);
    t=p;
    t-=a[q];
    if(f) op[q-1]=1;
    dfs(t,q+1);
}

int main(){

    string s;
    cin >> s;
    a[0]=s[0]-'0';
    a[1]=s[1]-'0';
    a[2]=s[2]-'0';
    a[3]=s[3]-'0';

    dfs(a[0],1);
    string o="+-";

    cout << a[0] << o[op[0]] << a[1] << o[op[1]] << a[2] << o[op[2]] << a[3] << "=7" << endl;


    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var zcnt, ocnt int
	for _, c := range s {
		if c == '0' {
			zcnt++
		} else {
			ocnt++
		}
	}

	fmt.Println(2 * min(zcnt, ocnt))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2504
import java.util.*;

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

        int N = sc.nextInt();
        long[] T = new long[N];
        for (int i = 0; i < T.length; ++i) {
            T[i] = sc.nextLong();
        }
        long[] A = new long[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextLong();
        }

        long div = (long)Math.pow(10, 9) + 7;

        long res = solve(T, A);
        System.out.println(res % div);
    }
    private static long solve(long[] T, long[] A) {
        long div = (long)Math.pow(10, 9) + 7;

        int tIdx = maxIdx(T);
        int aIdx = maxIdx(A);
        if (T[tIdx] != A[aIdx]) {
            return 0;
        }

        long[] h = new long[T.length];
        for (int i = 0; i < T.length; ++i) {
            if (i == 0 || T[i - 1] != T[i]) {
                h[i] = T[i];
            }
        }

        List<Integer> avIdx = new ArrayList<>(A.length);
        for (int i = A.length - 1; i > 0; --i) {
            if (i == A.length - 1 || A[i] != A[i + 1]) {
                if (h[i] > 0 && h[i] > A[i]) {
                    return 0;
                }
                h[i] = A[i];
            }
        }
        long res = 1;
        for (int i = 0; i < h.length; ++i) {
            if (h[i] == T[i] && h[i] == A[i]) {
            } else if (h[i] == T[i]) {
                if (h[i] > A[i]) {
                    return 0;
                }
            } else if (h[i] == A[i]) {
                if (h[i] > T[i]) {
                    return 0;
                }
            } else {
                long min = Math.min(T[i], A[i]);
                res *= min;
                res %= div;
            }
        }
        return res;
    }
    private static int maxIdx(long[] a) {
        long max = -1;
        int maxIdx = -1;
        for (int i = 0; i < a.length; ++i) {
            if (a[i] > max) {
                max = a[i];
                maxIdx = i;
            }
        }
        return maxIdx;
    }
}

Measured memory_bytes: 76584
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//manip
template<class T> bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, T &b) {if (a > b) {a = b; return 1;} return 0;}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define brep(i, n) for (int i = n - 1; i >= 0; --i)
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())

int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    ll K; cin >> K;
    int n = 50;
    cout << n << endl;
    int table[50][50] = {0};
    rep(j, 50) table[0][j] = j;
    rrep(i, 1, 50) {
        int key = -1, val = inf;
        rep(j, 50) {
            if (table[i - 1][j] < val) {
                key = j; val = table[i - 1][j];
            }
        }
        rep(j, 50) {
            if (j == key) table[i][j] = table[i - 1][j] + n;
            else table[i][j] = table[i - 1][j] - 1;
        }
    }
    //rep(i, 50) {rep(j, 50) cout << table[i][j] << " "; cout << endl;}
    if (K < 50) {rep(j, 50) cout << table[K][j] << " "; cout << endl;}
    else {
        rep(j, 50) {if (j) cout << " ";
            ll k = K - j;
            ll b = k / n;
            if (k % n) {b = (k + (n - 1)) / n + n - k % n;}
            cout << b;}
        cout << endl;
    }
}

/*
 n = 3
 
 2
 3
 4 1 2
 1 2 3
 2 3 0
 3 0 1
 0 1 2
 
 j = 0, 1, 2, ...で右上にslideしてる
 
 j = 0
 0 3 2 1 4 3 2
 3 2 1, 4 3 2, 5 4 3, ...    a[k]
 1 2 3  4 5 6  7 8 9    k
 が見える
 k % 3 == 0のとこ注目
 
 大きくして規則を
 n = 5
 5 4 3 2 1, 6 5 4 3  2, 7  6  5  4  3, ...
 1 2 3 4 5  6 7 8 9 10 11 12 13 14 15    k
 
 a[k] = (k + (n - 1)) / n + (n - k % n)
 4 -> 5のとこから1たす
 3 -> 5のとこから2たす
 
 
 
 n = 50
 上から下へ          k
  0   1  2 ... 49   0
 50   0  1 ... 48   1
 49  50  0 ... 47   2
 ...
 
  2   3  4 ...
  1   2  3 ... 50  50
 51   1  2 ... 49  51
 
 j = 1
 j = 0のk - 1の見る
 */



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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  ll k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  vector<ll> asum(n + 1), bsum(m + 1);
  for (int i = 0; i < n; ++i) {
    asum[i + 1] = asum[i] + a[i];
  }
  for (int i = 0; i < m; ++i) {
    bsum[i + 1] = bsum[i] + b[i];
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (k < asum[i]) continue;
    int ok = 0, ng = m + 1;
    while (1 < abs(ok - ng)) {
      int mid = (ok + ng) / 2;
      if (bsum[mid] <= k - asum[i]) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    ans = max(ans, i + ok);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8012
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long A, long long B){
  int ans=0;
  for (size_t i = 0; i < 1000000; i++) {
    if(floor(i*0.08) == A && floor(i*0.1) == B){
      ans = i;
      break;
    }
  }
  if(A == 0 && B == 0){
    cout << 0 << endl;
    return;
  }
  cout << (ans == 0 ? -1 : ans) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	string s;
	cin >> s;
	yorn(s[2] == s[3] && s[4] == s[5]);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

const string t = "FESTIVAL";

const int M = 600;
ll dp[M][8];

int main() {
  ll n;
  cin >> n;
  dp[0][0] = 1;
  rrep(i,M-1) {
    rep(j,8) dp[i][j] = dp[i-1][j];
    rep(j,7) {
      dp[i][j+1] += dp[i][j];
    }
    // cout<<i<<" "<<dp[i][7]<<endl;
  }
  string ans;
  drep(i,M) if (i) {
    ll s = dp[i][7];
    while (n >= s) {
      ans += t[7];
      n -= s;
    }
    drep(j,7) ans += t[j];
  }
  reverse(rng(ans));
  cout<<ans<<endl;
  // cout<<sz(ans)<<endl;
  return 0;
}































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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define all(x) x.begin(), x.end()
#define NDEBUG
//#define assert(ignore) ((void)0)
#define reg(i,x) for(ll i=0;i<x;i++)
#define regi(i,a,x) for(ll i=a;i<x;i++)
#define rev(i,n) for(ll i=n-1;i>0;i--)
#define MP make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
 ll INF=1e9;
//bool sortbysec(const std::pair<int,int> &a, const std::pair<int,int> &b) return (a.second < b.second);
// sort(v.begin(),v.end(),sortbysec);
//vector<vector<char>>v(n,vector<char>(m));
/*vi adj[1000];
bool vis[1000];
void initialise()
{
    reg(i,10) vis[i]=false;
}*/
/*void dfs(int s)
{
    vis[s]=true;
    reg(i,adj[i].size())
    {
        if(!vis[adj[s][i]]) dfs(adj[s][i]);
    }
}*/

ll m=1e9+7;
vi l(1e5+1);
/*int leader(int v)
{
    if(l[v]!=v) l[v]=leader(l[v]);
    return l[v];
}
int unite(int v1,int v2)
{
    v1=leader(v1);
    v2=leader(v2);
    l[v1]=v2;
}*/
int main()
{
    int t;
    cin>>t;
    if(t==0) cout<<1;
    else cout<<0;
}


Measured memory_bytes: 3720
#include <cstdio>
#include <algorithm>
using namespace std;

char c[500005];
int back[500005],n,p,maxn=0x3f3f3f3f;
int tmp,front[500005];

int main(void){
	scanf("%d",&n);
	scanf("%s",c+1);
	for(int i=n;i>=1;i--)
	back[i]=back[i+1]+(c[i]=='.');
	for(int i=1;i<=n;i++)
	front[i]=front[i-1]+(c[i]=='#');
	for(int i=1;i<=n;i++)
	if(c[i]=='#')
	maxn=min(maxn,front[i-1]+back[i]);
	if(maxn==0x3f3f3f3f)printf("0");
	else
	printf("%d",min(maxn,front[n]));
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)3e3+5;
bool diagonal(int w,int h,int x,int y) {
    return ((ll)x*y == (ll)(w-x)*(h-y));
}
long double arr(int w,int h,int x,int y) {
    return (long double)h*w/2.0;
    long double a1 = min((ll)x*h,(ll)(w-x)*h);
    long double a2 = min((ll)y*w,(ll)(h-y)*w);
    return max(a1,a2);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(20)<<arr(w,h,x,y)<<" "<<(int)(2*x==w && 2*y==h);
}


Measured memory_bytes: 256
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168"

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

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename R>
struct Kitamasa{
  using VR = vector<R>;
  VR cs;
  vector<VR> rs;
  int m;

  Kitamasa(const VR &C)
    :cs(C),rs(1),m(C.size()){
    rs[0].assign(2*m+1,R::add_identity());
    rs[0][1]=R::mul_identity();
  }

  VR merge(const VR &xs,const VR &ys){
    VR zs(2*m+1,R::add_identity());
    for(int i=1;i<=m;i++)
      for(int j=1;j<=m;j++)
        zs[i+j]=zs[i+j]+(xs[i]*ys[j]);

    for(int i=2*m;i>m;zs[i--]=R::add_identity())
      for(int j=1;j<=m;j++)
        zs[i-j]=zs[i-j]+(cs[m-j]*zs[i]);
    return zs;
  }

  R calc(const VR &A,long long n){
    assert((int)A.size()==m);
    VR res(rs[0]);
    for(int i=0;n;i++,n>>=1){
      if(i>=(int)rs.size())
        rs.emplace_back(merge(rs[i-1],rs[i-1]));
      if(~n&1) continue;
      res=merge(res,rs[i]);
    }
    R ans=R::add_identity();
    for(int i=1;i<=m;i++) ans=ans+(res[i]*A[i-1]);
    return ans;
  }
};
//END CUT HERE
#ifndef call_from_test

#define call_from_test
#include "../mod/mint.cpp"
#undef call_from_test

//INSERT ABOVE HERE
signed TDPC_F(){
  using ll = long long;
  int n;
  ll k;
  scanf("%d %lld",&n,&k);

  using M = Mint<int>;
  vector<M> as(n,1),cs(n,1);
  Kitamasa<M> fib(cs);

  printf("%d\n",fib.calc(as,--k).v);
  return 0;
}
/*
  verified on 2019/12/10
  https://atcoder.jp/contests/tdpc/tasks/tdpc_fibonacci
*/

signed ABC009_D(){
  int k,m;
  scanf("%d %d",&k,&m);

  struct M{
    uint32_t v;
    M(){*this=add_identity();}
    M(uint32_t v):v(v){}
    M operator+(const M &a)const{return M(v^a.v);}
    M operator*(const M &a)const{return M(v&a.v);}
    static M add_identity(){return M(0);}
    static M mul_identity(){return M(~0u);}
  };

  vector<M> as(k),cs(k);
  for(int i=0;i<k;i++) scanf("%u",&as[i].v);
  for(int i=0;i<k;i++) scanf("%u",&cs[k-(i+1)].v);
  Kitamasa<M> v(cs);

  printf("%u\n",v.calc(as,--m).v);
  return 0;
}
/*
  verified on 2019/12/10
  https://atcoder.jp/contests/abc009/tasks/abc009_4
*/

signed main(){
  //TDPC_F();
  //ABC009_D();
  return 0;
}
#endif

#undef call_from_test

template<typename T>
struct Z{
  T v;
  Z(){*this=add_identity();}
  Z(T v):v(v){}
  Z operator+(const Z &a)const{return Z(v+a.v);}
  Z operator*(const Z &a)const{return Z(v*a.v);}
  static Z add_identity(){return Z(0);}
  static Z mul_identity(){return Z(1);}
};

signed main(){
  using ZL = Z<long long>;

  vector<ZL> as({0,0,1}),cs({1,1,1});
  Kitamasa<ZL> K(cs);

  int n;
  while(cin>>n,n)
    cout<<(K.calc(as,n+2).v+3650-1)/3650<<endl;

  return 0;
}



Measured memory_bytes: 3108
#include <iostream>

using namespace std;

unsigned int a[100004];
int N,M;
bool danger[100004];

int main()
{
    cin>>N>>M;
    int t;
    for(int i = 1;i<=M;i++){
        cin>>t;
        danger[t] = 1;
    }
    if(danger[1])
        a[1] = 0;
    else a[1] = 1;
    if(danger[2])
        a[2] = 0;
    else a[2] = a[1]+1;
    for(int i = 3;i<=N;i++){
        if(danger[i])
            a[i] = 0;
        else a[i] = (a[i-1]+a[i-2]) % 1000000007;
    }
    cout<<a[N];
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


struct Robo
{
	int x, y, dir, cost;
	Robo(int x, int y, int dir, int cost)
		: x(x), y(y), dir(dir), cost(cost) { }
};
bool operator<(const Robo& a, const Robo& b)
{
	return a.cost > b.cost;
}
int main()
{
	int w, h;
	while (scanf("%d%d", &w, &h), w)
	{
		int s[32][32];
		rep (y, h)
			rep (x, w)
				scanf("%d", &s[y][x]);
		int c[4];
		rep (i, 4)
			scanf("%d", c + i);

		const int INF = 1 << 26;
		int dis[32][32][4];
		rep (y, h)
			rep (x, w)
				rep (i, 4)
					dis[y][x][i] = INF;

		priority_queue<Robo> q;
		dis[0][0][1] = 0;
		q.push(Robo(0, 0, 1, 0));
		while (!q.empty())
		{
			Robo r = q.top(); q.pop();
			if (r.cost > dis[r.y][r.x][r.dir])
				continue;
			else if (r.x == w - 1 && r.y == h - 1)
			{
				printf("%d\n", r.cost);
				break;
			}

			for (int i = 0; i < 4; ++i)
			{
				int nc = r.cost;
				if (i != s[r.y][r.x])
					nc += c[i];

				int d = 0;
				if (i == 1)
					d = 3;
				else if (i == 2)
					d = 2;
				else if (i == 3)
					d = 1;
				int nd = (r.dir + d) % 4;
				int nx = r.x + dx[nd], ny = r.y + dy[nd];

				if (0 <= nx && nx < w && 0 <= ny && ny < h && nc < dis[ny][nx][nd])
				{
					dis[ny][nx][nd] = nc;
					q.push(Robo(nx, ny, nd, nc));
				}
			}
		}
	}
}

Measured memory_bytes: 0
package main

import (
    "fmt"
    "sort"
)

func main(){
    var N, K int
    fmt.Scan(&N, &K)

    H := make([]int, N)

    for i:=0; i<N; i++{
        fmt.Scan(&H[i])
    }

    sort.Sort(sort.Reverse(sort.IntSlice(H)))

    var count int
    var result int
    
    if K<N{
        for i:=K; i<N; i++{
            count += H[i]
        }
        result = count
    }else if K>=N{
        result = 0
    }

    fmt.Println(result)
    
}


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

int main() {
  int A,B,count=0;
  cin >> A >> B;
  
  vector<int> vec(A);
  rep(i, A) {
    cin >> vec.at(i);
  }
  
  for(int i=0; i<vec.size(); i++) {
    if(vec[i] >= B){
      count++;
    }
  }
  
  cout << count << endl;
  
  
}


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

int solve(int N) {
  int ans = 0;
  for (int x = 1; x * x <= N; ++x)
    for (int y = 1; x * x + y * y + x * y <= N; ++y)
      for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= N; ++z)
        if (x * x + y * y + z * z + x * y + y * z + z * x == N)
          ans++;
  return ans;
}

int main() {
  int N;
  cin >> N;

  for (int i = 1; i <= N; ++i)
    cout << solve(i) << endl;
}


Measured memory_bytes: 3628
N,Q = map(int,input().split())
S = input()

T = []
count = 0
idx = -1
for i,s in enumerate(S):
    if s =='C' and idx ==i-1:
        idx = -1
        count += 1
    elif s =='A':
        idx = i
    T.append(count)
q = []
for _ in range(Q):
    l,r = map(int,input().split())
    q.append([l,r])
for l,r in q:
    print(T[r-1]-T[l-1])

Measured memory_bytes: 92252
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>

using namespace std;
using llint = long long int;
#define int long long int

vector<int> vadd, vxor;

signed main()
{
  string str;
  cin >> str;

  printf("%c%d%c\n", str.front(), str.length() - 2, str.back());
  return 0;
}


Measured memory_bytes: 256
n = gets
cnt = 0
n.length.times do |hoge|
    if hoge != 0 then 
        if n[hoge] == "0" and n[hoge - 1] == "0" then
           n[hoge] = "1"
           cnt += 1
        elsif n[hoge] == "1" and n[hoge - 1] == "1" then
            n[hoge] = "0"
            cnt += 1
        end
    end
end
puts cnt


Measured memory_bytes: 1916
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let t = next();
    let a = next();
    let h = nexts(n);
    let target = (t - a) * 1000 / 6
    let ans = 0;
    let min = 100000;
    let diff = 100000;
    for (let i = 0; i < n; i++) {
        diff = Math.abs(target - h[i]);
        if (min > diff) {
            min = diff;
            ans = i + 1;
        }
    }
    return ans;
}

Measured memory_bytes: 7500
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int q;
	cin >> q;
	int ans = 0;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		bool ok = false;
		int left = 0, right = n;
		while(left <= right){
			int mid = (left + right) / 2;
			if(a[mid] == t){
				ok = true;
				break;
			}else if(a[mid] < t)left = mid + 1;
			else right = mid - 1;
		}
		if(ok)ans++;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3520
import numpy as np
from scipy.sparse.csgraph import connected_components
from collections import deque
n,m=map(int,input().split())
matrix=[[0]*n]*n
matrix=np.array(matrix)
l=deque()
for _ in range(m):
    a,b=map(int,input().split())
    l.append([a,b])
    matrix[a-1][b-1]=1
count=0
for i in range(m):
    [a,b]=l.popleft()
    matrix[a-1][b-1]=0
    k,kk=connected_components(matrix)
    if kk[a-1]!=kk[b-1]:
        count+=1
    l.append([a,b])
    matrix[a-1][b-1]=1
print(count)


Measured memory_bytes: 17136
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
ab_plane = []

for i in range(len(ab)):
    ab_plane.append(ab[i][0])
    ab_plane.append(ab[i][1])

for i in range(N):
    print(ab_plane.count(i+1))


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

using namespace std;

bool isPrime(long long n){
	if(n < 2) return false;
	for(int i = 2; (long long)i * i <= n; i++){
		if(n % i == 0) return false;
	}
	return true;
}
void Solve(){
	long long n;
	cin>>n;
	if(isPrime(n)){
		cout<<1<<'\n';
		return;
	}
	int res = 0;
	vector<long long> prime;
	for(int i = 2; i < 1e6; i++){
		if(isPrime(i)){
			prime.push_back(i);
		}
	}
	for(auto x: prime){
		if(n < x) break;
		int l = 0;
		while(n % x == 0){
			n /= x;
			l++;
		}
		for(int k = 1; k * (k + 1) / 2 <= l; k++){
			//cout<<k<<" "<<res<<endl;
			res++;
		}
		//cout<<res<<endl;
		//cout<<n<<" "<<l<<" "<<res<<endl;
	}
	if(isPrime(n)) res++;
	cout<<res<<'\n';
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
typedef struct{
    long weight;
    long no;
} wn;

bool wncw(const wn& a, const wn& b){
    if(a.weight != b.weight){
        return a.weight < b.weight;
    }else{
        return a.no < b.no;
    }
}
bool wncn(const wn& a, const wn& b){
    if(a.no != b.no){
        return a.no < b.no;
    }else{
        return a.weight < b.weight;
    }
}

using node = vector<long>;
void connect_check(long from, const vector<node>& graph, vector<wn>& a){
    long s=graph[from].size();
    for(long j=0; j<s; j++){
        long to = graph[from][j];
        if(a[from].no!=a[to].no){
            a[to].no=a[from].no;
            connect_check(to, graph, a);
        }
    }
}

int main(void){
    long n, m;
    cin >> n >> m;
    //最初から木
    if(m==n-1){
        cout << "0" << endl;
        return 0;
    }
    if(2*(n-m-1)>n){
        cout << "Impossible" << endl;
        return 0;
    }
    vector<wn> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i].weight;
        a[i].no = -1;
    }
    vector<node> graph(n);
    for(long i=0; i<m; i++){
        long x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    long no=0;
    for(long i=0; i<n; i++){
        if(a[i].no==-1){
            a[i].no=no;
            connect_check(i, graph, a);
            no++;
        }
    }
    long cost_sum=0;
    sort(a.begin(), a.end(), wncn);
    for(long k=0, i=0; k<n-m; k++){
        while(a[i].no!=k) i++;
        cost_sum += a[i].weight;
        a[i].weight = 1e10;
    }
    sort(a.begin(), a.end(), wncw);
    for(long k=0; k<n-m-2; k++){
        cost_sum += a[k].weight;
    }
    cout << cost_sum << endl;
    /*
    for(long i=0; i<n; i++){
        long s=graph[i].size();
        cout << i << " : ";
        cout << a[i].weight << " : ";
        cout << a[i].no << " : ";
        for(long j=0; j<s; j++){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 7808
#include<stdio.h>

int main(void)
{
int n,i,j,k,v;
scanf("%d\n",&n);
int array[n];
for(i=0;i<n;i++) scanf("%d ",&array[i]);
for(i=0;i<n;i++)
{
v=array[i];
j=i-1;
while(j>=0 && array[j]>v)
{
array[j+1]=array[j];
j--;
}
array[j+1]=v;
for(k=0;k<n-1;k++) printf("%d ",array[k]);
printf("%d\n",array[n-1]);}
return 0;
}

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

int main(){
    int antena[5];
    int k;
    for(int i=0;i<5;i++){
        cin >> antena[i];
    }
    cin >> k;
    
    bool f = false;
    for(int i=0;i<4;i++){
        for(int j=i+1;j<5;j++){
            if(antena[j]-antena[i] > k){
                f = true;
            }
        }
    }
    if(f){
        cout << ":(";
    }else{
        cout << "Yay!";
    }
    return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N;
  cin >> N;
  
  for(int i = 111; i<1000; i+=111){
    if(N<=i){
      cout << i << endl;
      break;
    }
  }
    
}

Measured memory_bytes: 256
def chk(k):
  if k*(k-1)//2 != n:
    return False
  l=[[] for i in range(k)];x=1
  for i in range(k):
    for j in range(i+1,k):
      l[i].append(x);l[j].append(x);x+=1
  print("Yes\n"+str(k))
  for i in range(k):
    print(len(l[i]),' '.join(map(str,l[i])))
  return True
  
n=int(input());flag=False
for i in range(1,1000):
  if chk(i):
    flag=True
    exit()
if not flag:
  print("No")

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const unsigned int M = 1000000007;
 
int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int a[n],sm=0,ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sm+=a[i];
	}
	for(int i=0;i<n-1;i++){
		sm=sm-a[i];
		ans= ans%M  + ((a[i]%M)*(sm%M))%M;
	}
	cout<<ans%M;
	return 0; 
} 


Measured memory_bytes: 5228
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    posC = min(C, (A + B) + 1)
    print posC + B

if __name__ == '__main__':
    main()

Measured memory_bytes: 2936