akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var b = new Array(N);
  tmp = input[1].split(" ");
  var ans=0;
  var x = new Array();
  for(var i=0;i<N;i++){
    b[i]=parseInt(tmp[i]);
    if(b[i]>i+1){
      ans=-1;
      break;
    }
    x.splice(b[i]-1,0,b[i]);
  }
  if(ans!=-1){
    ans=x.join("\n");
  }

  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.Scanner;

//Grey Area
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int w = sc.nextInt();
			if((n|w)==0)break;;
			int[] h = new int[12];
			int r = -1;
			int max = 0;
			for(int i=0;i<n;i++){
				int v = sc.nextInt();
				int k = 11;
				while(w*k>v)k--;
				h[k]++;
				r = Math.max(r, k);
				max = Math.max(max, h[k]);
			}
			double a = 0.01;
			for(int i=0;i<=r;i++){
				a += ((r-i)*1.0/r)*h[i]/max;
			}
			System.out.println(a);
		}
	}

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

Measured memory_bytes: 12000
n, m = list(map(int, input().split()))
a = []
for i in range(m):
	a.append(int(input()))
a.sort()
f0 = 1
if len(a) > 0 and a[0] == 1:
	f1 = 0
else:
	f1 = 1
k = 0
for i in range(2, n + 1):
	while k < len(a) and a[k] < i:
		k += 1
	if k == len(a) or a[k] != i:
		f = (f0 + f1) % 1000000007
	else:
		f = 0
	f0 = f1
	f1 = f
	if f0 == f1 == 0:
		break
print(f1)

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

int main(){
  ll k,a,b;
  cin>>k>>a>>b;
  k-=a;
  a-=b;
  if(k<=0){cout<<1<<endl; return 0;}
  if(a<=0)cout<<-1<<endl;
  else{
    cout<<(k+a-1)/a*2+1<<endl;
  }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b;
	cin >> a >> b;
	cout << (a+b+1)/2 << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

typedef struct Node
{
    int value;
    Node *parent, *left, *right;
} Node;

Node *root, *NIL;

Node * treeMinimum(Node *u)
{
    while (u->left != NIL) u = u->left;
    return u;
}
Node * getSuccessor(Node *u)
{
    if (u->right != NIL) return treeMinimum(u->right);
    Node *y = u->parent;
    while (y != NIL && u == y->right) {
        u = y;
        y = y->parent;
    }
    return y;
}
void Delete(Node *u)
{
    Node *y; // to be deleted
    Node *x; // a child of y

    if (u->left == NIL || u->right == NIL) y = u;
    else y = getSuccessor(u);

    // decide the x which is the child of the y
    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != u) {
        u->value = y->value;
    }

    free(y);
}

Node * Find(Node *u, int k)
{
    while (u != NIL && k != u->value) {
        if (k < u->value) u = u->left;
        else u = u->right;
    }
    return u;
}
void Insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->value = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->value < x->value) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->value < y->value) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    cout << " " << u->value;
    inorder(u->right);
}
void preorder(Node *u)
{
    if (u == NIL) return;
    cout << " " << u->value;
    preorder(u->left);
    preorder(u->right);
}

int main(void)
{
    int n, i, x;
    string com;

    cin >> n;

    for (i = 0; i < n; ++i) {
        cin >> com;
        if (com[0] == 'f') {
            cin >> x;
            Node *t = Find(root, x);
            if (t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if (com == "insert") {
            cin >> x;
            Insert(x);
        } else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if (com == "delete") {
            cin >> x;
            Delete(Find(root, x));
        }
    }
    return 0;
}



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

using namespace std;

int pos = 0;
vector<int> post_orders;

void reconstruct(vector<int> pre, vector<int> in, int L, int R){
    if(L >= R) return;
    int c = pre[pos++];
    int m = distance(in.begin(), find(in.begin(),in.end(), c)); 
    reconstruct(pre, in, L, m);
    reconstruct(pre, in, m+1, R);
    post_orders.push_back(c);
}

int main(){
    int const N_MAX = 40;
    int n;
    cin >> n;
        
    vector<int> pre_orders, in_orders;
    pre_orders.resize(n);
    in_orders.resize(n);
    
    for(size_t i = 0; i < n; i++){
        cin >> pre_orders[i];
    }
    for(size_t i = 0; i < n; i++){
        cin >> in_orders[i];
    }    
    
    reconstruct(pre_orders, in_orders, 0, pre_orders.size());
    
    for(size_t i = 0; i < n; i++){
        cout << ((i==0)? "" : " " ) << post_orders[i];
    }
    cout << endl;
    
    
    return 0;
}

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

int main() {
    ll n,k;
    cin>>n>>k;
    ll input_array[n];
    ll answer_array[n];
    for(ll i=0;i<n;i++){
        cin>>input_array[i];
    }
    answer_array[0] = 0;
    for(ll i=1;i<n;i++){
        ll mini = LLONG_MAX;
        for(ll j=1;j<=k;j++){
            if(i - j >= 0 ){
                ll diff = abs(input_array[i] - input_array[i-j]) +answer_array[i-j];
                if(diff < mini){
                    mini = diff;
                } 
            }
        }
        answer_array[i] = mini;
    }
    cout<<answer_array[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5212
//https://twitter.com/chokudai/status/1267093176973549571
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long N;
    long long A[1000000];
    long long sum = 1;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (A[i] == 0)
        {
            cout << "0" << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (sum * A[i] < sum || sum * A[i] > 1000000000000000000)
        {
            cout << "-1" << endl;
            return 0;
        }
        else
        {
            sum = sum * A[i];
        }
    }

    printf("%llu\n", sum);
    return 0;
}

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

int solve(long long N, std::vector<long long> A)
{
    long long sum = A[0];
    for (int i = 1; i < N; i++)
    {
        sum = sum * A[i];
    }

    if (1000000000000000000 < sum)
    {
        cout << "-1" << endl;
    }
    else
    {
        printf("%lld\n", sum);
    }

    //cout << fixed << setprecision(20) << sum << endl;
    return 0;
}

// Generated by 1.1.7.1 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 N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}
*/

Measured memory_bytes: 4528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(System.Console.ReadLine().Trim());
        int[] line = Array.ConvertAll(System.Console.ReadLine().Trim().Split(' '),int.Parse);

        Dictionary<int, int> s = new Dictionary<int, int>();
        Dictionary<int, int> t = new Dictionary<int, int>();
        Dictionary<int, int> tmp;

        for (int i = 0; i < n ; i++)
        {
           
            tmp = (i % 2 == 0) ? s: t;

            if(tmp.ContainsKey(line[i]))
            {
                tmp[line[i]]++;
            }
            else
            {
                tmp.Add(line[i], 1);
            }
        }

        if (s.Count == 1 && t.Count == 1 && s.First().Key != t.First().Key)
        {
            //すでにVVV
            System.Console.WriteLine("{0}",0);
            return;
        }
        else if(s.Count == 1 && t.Count == 1)
        {
            //全要素が同じ
            System.Console.WriteLine("{0}", s.First().Value);
            return;
        }

        int s1 = 0, s2 = 0, t1 = 0, t2 = 0;

        s = s.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
        t = t.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        s1 = s[s.Keys.ToList()[0]];
        t1 = t[t.Keys.ToList()[0]];

        if(s.Keys.ToList()[0] != t.Keys.ToList()[0])
        {
            //最頻値が異なればsもtも最頻値で置換
            System.Console.WriteLine("{0}", (n - s1 - t1));

        }
        else{

            //最頻値が同じならいずれかを2番目の頻度の値で置換
            if (s.Count > 1) s2 = s[s.Keys.ToList()[1]];
            if (t.Count > 1) t2 = t[t.Keys.ToList()[1]];

            //sを最頻値で、tを二番目で書き換え
            //tを最頻値で、sを二番目で書き換え
            int sRlt = n - s1 - t2;
            int tRlt = n - s2 - t1;

            System.Console.WriteLine("{0}", Math.Min(sRlt, tRlt));

        }


    }

    


}


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

const int mod = 1000000007;

struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

mint table[2020];

void init(){
  table[0] = table[1] = 1;
  for (ll i = 2; i < 2020; i++) {
    table[i] = table[i - 1] * i;
  }
}

int main() {
  int n,k;
  cin >> n >> k;

  init();

  for (int c = 1; c <= k; c++) {
    if(n - k + 1 - c < 0) {
      cout << 0 << '\n';
      continue;
    }
    mint ans = 0;
    mint b = table[k - 1] / table[c - 1] / table[k - 1 - (c - 1)];
    mint a = table[n - k + 1] / table[n - k + 1 - c] / table[c];
    ans = a * b;
    cout << ans.x << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 100000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, a[101010], k, q, b[2020], res=inf;
priority_queue<int> qq;
vi ans, v;

void add(int l, int r){

if(r-l+1 < k)return;

rep(i, l, r){
qq.push(-a[i]);
}

int temp = (r-l+1) - k +1 ;

while(temp>0){
    int t = qq.top();qq.pop();
    t = -t;
    ans.pb(t);
    temp--;
}

while(!qq.empty()){
    qq.pop();
}

}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> k >> q;

rep(i, 1, n){

cin >> a[i];
b[i]=a[i];

}

sort(b+1, b+n+1);


rep(i, 1, n){

    v.pb(0);
    rep(j, 1, n){
    if(a[j]<b[i]){v.pb(j);}
    }
    v.pb(n+1);

    int k = v.size();
    //cout << k << endl;
    rep(j, 0, k-2){
    //cout << v[j] << " ";
    add(v[j]+1, v[j+1]-1);

    }
    sort(all(ans));
    //cout << ans.size() << endl;
    if(ans.size()>=q){
        res = min(res,  ans[q-1] - b[i] );
    }
    ans.clear();
    v.clear();

}

cout << res << endl;







return 0;}
///....


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {
 
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans = 0;
  if(N < B){
    ans = N;
  }else{
    ans = B-1;
  }
  ll res =(ll)((A*ans)/B) - A * (ll)(ans/B);

  cout << res << endl;



}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,r,s1,r1,s2,r2;
    int d,d1,d2;
    cin>>r;
    int n=r.size();
    s=r;
    reverse(r.begin(),r.end());
    d=s.compare(r);
    s1=s.substr(0,(n-1)/2);
    r1=s1;
    reverse(r1.begin(),r1.end());
    d1=s1.compare(r1);
    s2=r.substr(0,((n+2)/2 )-1);
    r2=s2;
    reverse(r2.begin(),r2.end());
    d2=s2.compare(r2);
    if(d1!=0||d!=0||d2!=0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;

}


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

signed main() {
  int n;
  cin>>n;
 
 queue<int> a[n];
 int t,k;
 for(int i=0;i<n;i++){
   for(int j=0;j<n-1;j++){
     cin>>t;
     a[i].push(t-1);
   }
 }
 int ans=0,used[n]={};
while(true){
  t=0;
  k=0;
  //cerr<<'q';
  //if(t==0)break;
  for(int i=0;i<n;i++){
    if(a[i].empty())continue;
    t=1;
    if(used[i])continue;
    if((!used[a[i].front()])&&(!a[a[i].front()].empty()&&a[a[i].front()].front()==i)){
      used[a[i].front()]=1;
      used[i]=1;
      a[a[i].front()].pop();
      a[i].pop();
      k=1;
    }
    
  }
  if(t==0)break;
   if(k==0){
      cout<<-1;
      return 0;
    }
  for(int i=0;i<n;i++)used[i]=0;
     
   
    ans++;
    if(ans>10000){
      cout<<999*500;
      return 0;
    }
}
cout<<ans;


    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>

int main(void){
   int n,fib[45],i,sum=0;
   scanf("%d",&n);
   fib[0]=fib[1]=1;
   fib[2]=2;
   if(n!=1 && n!=0){
      for(i=1;i<n;i++)
      fib[i+1]=fib[i]+fib[i-1];
   }

   printf("%d\n",fib[n]);

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string s;
	cin>>s;
	int ans=0;
	fx(s.size()){
		ans+=s.at(x)-'b';
	}

	if(ans==0){
		ce("Yes")
	}else{
		ce("No")
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    double t, a;
    cin >> n >> t >> a;
    double h[n];
    REP(i,0,n) cin >> h[i];
    int ans = 0;
    double sa = 100005;
    REP(i,0,n)
    {
        double tmp = t-h[i]*0.006;
        if(abs(tmp-a)<sa)
        {
            sa = abs(tmp-a);
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>


using namespace std;

typedef long long int ll;


int main()
{
	ll i,o,t,j,l,s,z;
	cin>>i>>o>>t>>j>>l>>s>>z;

	ll ans = 0;
	ans += 2*o;

	ll ijl = min(min(i,j),l);
	ll res = 0;
	if(ijl>0){ // ijlを１個使う
		res += 6 + ((i-1)/2)*4 + ((j-1)/2)*4 + ((l-1)/2)*4;
	}

	ans += max(res,(i/2)*4 + (j/2)*4 + (l/2)*4);
	cout << ans/2 << endl;

	return 0;
}


Measured memory_bytes: 256
A=[list(map(int, input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]

for k in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j]==b[k]:
                A[i][j]=0

if A[0][0]==0 and A[1][0]==0 and A[2][0]==0:
    print("Yes")
elif A[0][1]==0 and A[1][1]==0 and A[2][1]==0:
    print("Yes")
elif A[0][2]==0 and A[1][2]==0 and A[2][2]==0:
    print("Yes")
elif A[0][0]==0 and A[0][1]==0 and A[0][2]==0:
    print("Yes")
elif A[1][0]==0 and A[1][1]==0 and A[1][2]==0:
    print("Yes")
elif A[2][0]==0 and A[2][1]==0 and A[2][2]==0:
    print("Yes")
elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    print("Yes")
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N = gets.chomp
case N.length
when 1
  puts N.to_i
when 2
  puts 9
when 3
  puts N.to_i - 99 + 9
when 4
  puts 999 - 99 + 9
when 5
  puts N.to_i - 9999 + 909
when 6
  puts 99999 - 9999 + 909
end


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



int main() {
    long long ans=0;
    int k, l;
    vector<int> dp(200000);
    string s;
    cin >> s;
    map<int, int> m;
    k=0;
    m[k]=1;
    for(int i=s.size()-1; i>=0; i--) {
        l=(int)(s[i]-'0');
        if(i==s.size()-1) dp[i]=1;
        else dp[i]=dp[i+1]*10;
        dp[i]%=2019;
        k=l*dp[i]+k;
        k%=2019;
        if(m.count(k)) m[k]++;
        else m[k]=1;
    }
    for(int i=0; i<2019; i++) {
        if(m.count(i)) {
            ans+=m.at(i)*(m.at(i)-1)/2;
        }
    }
    cout << ans;
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	if (s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
void swap(int &a, int &b);

int main()
{
	// 状況
	int Current[4][3][10] = {};

	int number;
	cin >> number;

	// Rowデータ格納
	int **Info = new int*[number];
	for (int i = 0; i < number; ++i)
		Info[i] = new int[4];
	
	// Input
	for (int i = 0; i < number; ++i)
	{
		cin >> Info[i][0]
			>> Info[i][1]
			>> Info[i][2]
			>> Info[i][3];

	}

	for (int i = 0; i < number; ++i)
	{
		int Build_id = Info[i][0] - 1;
		int Floor_id = Info[i][1] - 1;
		int Room_id = Info[i][2] - 1;
		int variable = Info[i][3];

		Current[Build_id][Floor_id][Room_id] += variable;

		if (Current[Build_id][Floor_id][Room_id] < 0)
			Current[Build_id][Floor_id][Room_id] = 0;

	}

	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 10; ++k)
			{
				cout << " " << Current[i][j][k];
			}
			cout << endl;
		}
		if (i != 3)
			cout << "####################" << endl;
	}


	return 0;
}




Measured memory_bytes: 3112
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        BigInteger cif = new BigInteger("0");
        BigInteger tot = new BigInteger("0");
        for (int qq = 0; qq < m; ++qq) {
            BigInteger d = new BigInteger(scan.next());
            BigInteger c = new BigInteger(scan.next());
            cif = cif.add(c);
            tot = tot.add(d.multiply(c));
        }
        if (tot.mod((BigInteger.TEN.subtract(BigInteger.ONE))).equals(BigInteger.ZERO)) {
            tot = tot.subtract(BigInteger.TEN.subtract(BigInteger.ONE));
        }
        System.out.println(cif.add(tot.divide(BigInteger.TEN.subtract(BigInteger.ONE))).subtract(BigInteger.ONE));
    }
}


Measured memory_bytes: 90128
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
typedef long long int ll;


bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}
// use case
//sort(V.begin(), V.end(), compare_function);
void print(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}


int solve(vector <int> X, vector <vector <int>> A, vector <int> C, int x)
{
    int c=0;
    for (int i=0; i<X.size(); i++)
    {
        if (X[i]==1)
        {
            c=c+C[i];
        }
    }
    for (int i=0; i<A[0].size(); i++)
    {
        int a=0;
        for (int j=0; j<X.size(); j++)
        {
            if (X[j]==1)
            {
                a=a+A[j][i];
            }
        }
        if (a<x)
        {
            return 1000000000;
        }
    }
    return c;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m,x;
    cin>>n>>m>>x;
    vector <int> C(n,0);
    vector <int> e(m,0);
    vector <vector <int>> A(n,e);
    for (int i=0; i<n; i++)
    {
        cin>>C[i];
        for (int j=0; j<m; j++)
        {
            cin>>A[i][j];
        }
    }
    vector <int> D;
    int d=1;
    D.push_back(d);
    for (int i=0; i<15; i++)
    {
        d=d*2;
        D.push_back(d);
    }
    vector <vector <int>> X(D[n]);
    for (int i=0; i<D[n]; i++)
    {
        vector <int> t;
        int j=i;
        while (j>0)
        {
            t.push_back(j%2);
            j=j/2;
        }
        X[i]=t;
    }
    int ats=1000000000;
    for (int i=0; i<D[n]; i++)
    {
        ats=min(ats,solve(X[i],A,C,x));
    }
    if (ats==1000000000)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<ats<<endl;
    }
    return 0;
}


Measured memory_bytes: 4004
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<int64_t> nums(100002, 0);

int32_t main() {
  uint32_t N;
  cin >> N;

  for (uint32_t i = 0; i < N; i++) {
    int64_t a, b;
    cin >> a >> b;
    nums[a]++;
    nums[b + 1]--;
  }

  uint32_t max_val = 0;
  for (uint32_t i = 0; i < nums.size() - 1; i++) {
    nums[i + 1] += nums[i];
    if (i + 1 <= nums[i + 1] + 1) {
      max_val = max(max_val, i + 1);
    }
  }

  cout << max_val - 1 << endl;

  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int N;
    cin >> N;
    vector<int> c(N);
    for(int i = 0; i < N; ++i) {
        cin >> c[i];
    }
    int Q; cin >> Q;
    vector<ll> cnt(N);
    int ans = 0;
    while(Q--) {
        int t, x, d; cin >> t>> x >> d;
        x--;
        if(t == 1) {
            cnt[x] += d;
            if(cnt[x] > c[x]) {
                ans = x + 1;
                break;
            }
        } else {
            cnt[x] -= d;
            if(cnt[x] < 0) {
                ans = x + 1;
                break;
            }
        }
    }
    cout << ans << endl;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int minNumIndex,maxNumIndex;
  rep(i,N){
    cin >> a[i];
    if(i == 0){
      minNumIndex = i;
      maxNumIndex = i;
    }else{
      if(a[i] < a[minNumIndex])   minNumIndex = i;
      if(a[i] >= a[maxNumIndex])  maxNumIndex = i;
    }
  }
  cout << 2*N-1 << "\n";
  if(abs(a[minNumIndex]) >= abs(a[maxNumIndex])){
    rep(i,N){
      cout << minNumIndex +1<< ' ' << i +1<< "\n";
    }
    for(int i = N-1; i >= 1; i--) {
      cout << i +1<< ' ' << i-1 +1<< "\n";
    }

  }else{
    rep(i,N){
      cout << maxNumIndex +1<< ' ' << i +1<< "\n";
    }
    rep(i,N-1){
      cout << i +1<< ' ' << i+1 +1<< "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int>> PP;


int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

const ll MOD = 1000000007;
const ll INF = 100000000000;




int main(void){
    int A, B, Q;
   
    cin >> A >> B >> Q;
    vector<ll> s, t;
    s.push_back(INF); s.push_back(-INF);
    t.push_back(INF); t.push_back(-INF);
    for (int i = 0; i < A; i++){
        ll a; cin >> a;
        s.push_back(a);
    }
    s.push_back(INF); s.push_back(-INF);
    for (int i = 0; i < B; i++){
        ll b; cin >> b;
        t.push_back(b);
    }
    sort(s.begin(), s.end());
    sort(t.begin(),t.end());

    for (int i = 0; i < Q; i++){
        ll x; cin >> x;
        ll ans = INF;
        int sx, tx;
        sx = lower_bound(s.begin(), s.end(), x) - s.begin() - 1;
        tx = lower_bound(t.begin(), t.end(), s[sx]) - t.begin();
        ans = min(ans, abs(x - s[sx]) + abs(s[sx] - t[tx-1]));
        ans = min(ans, abs(x - s[sx]) + abs(s[sx] - t[tx]));

        sx = lower_bound(s.begin(), s.end(), x) - s.begin();
        tx = lower_bound(t.begin(), t.end(), s[sx]) - t.begin();
        ans = min(ans, abs(x - s[sx]) + abs(s[sx] - t[tx-1]));
        ans = min(ans, abs(x - s[sx]) + abs(s[sx] - t[tx]));

        tx = lower_bound(t.begin(), t.end(), x) - t.begin() - 1;
        sx = lower_bound(s.begin(), s.end(), t[tx]) - s.begin();
        ans = min(ans, abs(x - t[tx]) + abs(t[tx] - s[sx-1]));
        ans = min(ans, abs(x - t[tx]) + abs(t[tx] - s[sx]));

        tx = lower_bound(t.begin(), t.end(), x) - t.begin();
        sx = lower_bound(s.begin(), s.end(), t[tx]) - s.begin();
        ans = min(ans, abs(x - t[tx]) + abs(t[tx] - s[sx-1]));
        ans = min(ans, abs(x - t[tx]) + abs(t[tx] - s[sx]));

        cout << ans << endl;
    }

}



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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    rep(i,n) {
        x-=a[i];
        if(x<0) break;
        ans++;

    }
    if(x>0) ans--;
    cout << ans << endl;
    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))

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

string step;

int dp[100010][2];

void solve() {
	int n = (int)step.size();
	
	for_(i,0,n+1) fill(dp[i], dp[i] + 2, (int)1e9);
	dp[0][0] = dp[0][1] = 0;
	
	int pre = -1;
	
	for_(i,0,n) {
		char si = step[i];
		int sx = (int)(si - '1') % 3;
		
		for_(j,0,2) {
			int nx = (j + 1) % 2;
			if (dp[i][j] == (int)1e9) continue;
			
			if (j % 2) {
				// left
				if (pre == -1) dp[i + 1][nx] = min(dp[i + 1][nx], dp[i][j]);
				else if (sx <= pre) {
					dp[i + 1][nx] = min(dp[i + 1][nx], dp[i][j]);
				} else {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
				}
			} else {
				// right
				if (pre == -1) dp[i + 1][nx] = min(dp[i + 1][nx], dp[i][j]);
				else if (sx >= pre) {
					dp[i + 1][nx] = min(dp[i + 1][nx], dp[i][j]);
				} else {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
				}
			}
		}
		
		pre = sx;
	}
	
	cout << min(dp[n][0], dp[n][1]) << endl;
}
	

int main() {
	while (cin >> step) {
		if (step[0] == '#') break;
		solve();
	}
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	string a_string = to_string(a);
	string b_string = to_string(b);
	string c_string = a_string + b_string;
	int c = stoi(c_string);
	bool square = false;
	for(int i = 1; i <= c; i++){
		if(i * i == c){
			square = true;
			break;
		}
	}
	if(square){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
from decimal import *
A,B=list(map(lambda i:int(i),input().split()))


Amax = (A+0.9)
Amax= Decimal(str(Amax))/ Decimal('0.08')
Amin = Decimal(str(A))/ Decimal('0.08')


Bmax= (B+0.9)
Bmax= Decimal(str(Bmax)) *  Decimal('10')
Bmin = Decimal(str(B)) *  Decimal('10')

As = list(range(math.ceil(Amin), math.floor(Amax)+1))
Bs = list(range(math.ceil(Bmin), math.floor(Bmax)+1))

A_B = set(As) & set(Bs)


if len(A_B)==0:
    print(-1)
else:
    print(min(A_B))


Measured memory_bytes: 5076
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main()
{
   long int n;
   int m;
   scanf("%ld%d",&n,&m);
   int a[m],i;
   long int sum=0;
   for(i=0;i<m;++i)
      {
          scanf("%ld",&a[i]);
          sum+=a[i];
      }
      
    if(sum>n)
       printf("-1");
       
    else
      printf("%ld",n-sum);
   
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
ll n;

vector<ll> Eratosthenes(const int N){
    bool is_prime[N];
    vector<ll> P;
    for(int i = 0; i <= N; i++){
        is_prime[i] = true;//初期化
    }
    ll count = 0;
    for(int i = 2; i <= N; i++){
        if(is_prime[i]){
            for(int j = 2 * i; j <= N; j += i){
                is_prime[j] = false;
            }
            if(i % 5 == 1){
                P.emplace_back(i);
                count++;
                if(count == n){
                    return P;
                }
            }
        }
    }
}

int main(void){
    cin >> n;

    vector<ll> ans = Eratosthenes(1000000);
    fore(a, ans){
        cout << a << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 
long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int main() {
  double a,b,h,m;
  double ans;
  double th;
  cin >> a >> b >> h >> m;
  th = abs(5.0*(h+ m/60.0) - m) * M_PI / 30.0;
  ans = a*a + b*b - 2.0*a*b* cos(th);
  ans = sqrt(ans);
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct edge
{
    int to;
    int cost;
};

// 色を0か1で塗る
void dfs(vector<vector<edge>> &graph, vector<int> &color, int v, int p, int c)
{
    color[v] = c; //塗る
    for (int i = 0; i < (int)graph[v].size(); i++)
    {
        edge e = graph[v][i];
        if (e.to == p)
        {
            continue;
        }
        if (e.cost % 2)
        {
            dfs(graph, color, e.to, v, 1 - c);
        }
        else
        {
            dfs(graph, color, e.to, v, c);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<edge>> graph(n);
    vector<int> color(n, 0);
    for (int i = 0; i < n - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back(edge{v, w});
        graph[v].push_back(edge{u, w});
    }
    dfs(graph, color, 0, -1, 0);
    for (int i = 0; i < n; i++)
    {
        cout << color[i] << endl;
    }
}

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

using namespace std;

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

    vector<char> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    int p1 = 0, p2 = n-1, count = 0;
    while (p1 < p2) {
        while (p1 < p2 && v[p1] != 'W')
            ++p1;

        while (p1 < p2 && v[p2] != 'R')
            --p2;

        if (p2 <= p1)
            break;

        ++count;
        ++p1;
        --p2;
    }

    cout << count << endl;
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    ll x;
    cin>>x;
    ll edge=0;
    ll ans=0;
    for(ll i=0;edge<x;i++){
        edge+=i;
        ans=i;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
S = input()
odds = []
evens = []
for i in range(len(S)):
    if i % 2 == 0:
        odds.append(S[i])
    else:
        evens.append(S[i])

if 'L' not in odds and 'R' not in evens:
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a;
  stack<int> st;
  while (cin >> a) {
    if (a == 0) {
      cout << st.top() << endl;
      st.pop();
    } else {
      st.emplace(a);
    }
  }

  return 0;
}


Measured memory_bytes: 3088
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      // List<String> list = new ArrayList<String>();
      Scanner sc = new Scanner(System.in);
      long X = Long.parseLong(sc.next());

      //黒板の整数
      String answer = "NG";
      long money = 100;
      int count = 0;
      while(true){
        if(money >= X) break;
        money = money + money / 100;
        count++;
      }
      System.out.println(count);
    }
}

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

int main()
{
	int N,D,X,a[110];
	cin >> N >> D >> X;
	int ans = X;
	for(int i=0; i<N; i++){
		cin >> a[i];
		for(int j=0; j*a[i]+1<=D; j++){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		sc.close();
		if(Math.abs(N - M) > 1) {
			System.out.println(0);
			System.exit(0);
		}
		long mod = 1000000007;
		long ans = 1;
		if(N == M) ans = 2;
		for(int i = 1; i <= N; i++) {
			ans *= i;
			ans %= mod;
		}
		for(int i = 1; i <= M; i++) {
			ans *= i;
			ans %= mod;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21460
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n,q; cin >> n >> q;
    string str; cin >> str;
    vector<int> s(n+1,0);

    for(int i = 0; i < n-1; i++) {
        if(str[i]=='A' && str[i+1] == 'C') 
            s[i+1] = s[i]  + 1;
        else {
            s[i+1] = s[i];
        }
    }
    s[n] = s[n-1];

    REP(i, q) {
        int l, r;
        cin >> l >> r;
        r--; l--;
        int ans = s[r] - s[l];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.HashMap;

public class Main {
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		int cnt = 0;
		final String INSERT = "insert";
		final String FIND = "find";
		final int n = scan.nextInt();
		
		HashMap<String, Integer> str = new HashMap<String, Integer>();
	
		for (int i = 0; i < n; i++) {
			final String ord = scan.next();

			if ( ord.equals(INSERT)) {
				str.put(scan.next(), cnt);
				cnt++;
				
			} else if (ord.equals(FIND)) {
				
				final String word = scan.next();
				
				if (str.containsKey(word)) System.out.println("yes");
				else System.out.println("no");
			}
		}
		scan.close();
	}
}



Measured memory_bytes: 273680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll int mod=1e9+7;
double f[3009][3009]={1},p[3009];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lf",&p[i]);
        f[i][0]=f[i-1][0]*(1-p[i]);
        for(int j=1;j<=i;j++)
            f[i][j]=f[i-1][j-1]*p[i]+f[i-1][j]*(1-p[i]);
    }
    double  ans=0.0;
    for(int i=n/2+1;i<=n;i++)
        ans+=f[n][i];
    printf("%.10lf\n",ans);
    return 0;
}

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

#define y1 dmytxdy
#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m,tot;
int v[4005],nxt[4005],h[2005],dep[2005],vis[2005],f[2005],a[2005],b[2005],hv[2005][2];
set<pii> vec[2005];

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}

void dfs(int u){
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==f[u]) continue;
		f[v[p]]=u,dep[v[p]]=dep[u]+1;
		dfs(v[p]);
	}
}

void addtag(int x,int y,int id){
	int tx=0,ty=1;
	while(x!=y){
		if(dep[x]<dep[y]) swap(x,y),swap(tx,ty);
		vec[x].insert(mp(id,tx));
		x=f[x];
	}
}

void change(int id,int c){
	int x=a[id],y=b[id],tx=0,ty=1;
	vector<pii> tmp(0);
	while(x!=y){
		if(dep[x]<dep[y]) swap(x,y),swap(tx,ty);
		vec[x].erase(mp(id,tx));
		hv[x][tx^c]=1;
		if(vec[x].size()==1&&!hv[x][tx^c^1]){
			if(vis[vec[x].begin()->fi]==-1){
				vis[vec[x].begin()->fi]=vec[x].begin()->se^tx^c^1;
				tmp.pb(mp(vec[x].begin()->fi,vec[x].begin()->se^tx^c^1));
			}
			else assert(vis[vec[x].begin()->fi]==(vec[x].begin()->se^tx^c^1));
		}
		x=f[x];
	}
	for(auto r:tmp) change(r.fi,r.se);
}

int main(){
	n=readint(); m=readint();
	for(int i=1;i<n;i++) addedge(readint(),readint());
	dep[1]=1; dfs(1);
	for(int i=1;i<=m;i++){
		a[i]=readint(); b[i]=readint();
		addtag(a[i],b[i],i);
	}
	int ans=0;
	for(int i=2;i<=n;i++) ans+=min((int)vec[i].size(),2);
	printf("%d\n",ans);
	memset(vis,-1,sizeof(vis));
	for(int i=m;i>=1;i--){
		if(vis[i]>=0) continue;
		vis[i]=0;
		change(i,0);
	}
	for(int i=1;i<=m;i++) printf("%d %d\n",vis[i]?b[i]:a[i],vis[i]?a[i]:b[i]);
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector <vector<int>> s(m);
  vector<int> k(m);
  vector<int> p(m);
  rep(i,m){
  //  int k;
    cin>>k[i];
    rep(j,k[i]){
      int temp;
      cin>>temp;
      temp--;
      s[i].emplace_back(temp);

    }
  }
  rep(i,m)cin>>p[i];
  int ans=0;
  int cnt=0;
  //cout<<s[0][0]<<' '<<s[0][1]<<' '<<s[0][2]<<endl;

  for (int b=0;b<(1<<n);b++){
    rep(i,m){
  //    cout<<i<<'i'<<endl;
      int now=0;
      for(auto t:s[i]){
      //  cout<<s[i][2]<<' ';
        if (b & (1<<t)) now++;
      }
      if (now%2!=p[i]){
        cnt=-1;break;
    }
  }
  if (cnt!=-1){
 
    ans++;}
  cnt=0;

  }
  cout<<ans;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

x = N.odd? ? 1 : 0

cnt_tbl = Array.new(N, 0)
A.each{|a|
  cnt_tbl[a] += 1
}

if cnt_tbl[0] == x && (x + 1).step(N, 2).all?{|i| cnt_tbl[i] == 2}
  p 2**(N/2) % (10**9 + 7)
else
  p 0
end


Measured memory_bytes: 8844
n, a, b, c, d = [int(i) for i in input().split()]
S = ' ' + input()

if '##' in S[a:c + 1]:
    print('No')
elif '##' in S[b:d + 1]:
    print('No')
else:
    if c < d:
        print('Yes')
    elif '...' in S[b - 1:d + 2]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}


Measured memory_bytes: 256