akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)


int main(){
    long long N,K,rs=0;
    cin >> N >> K;

    while(N > 0){
        N /= K;
        rs++;
    }
    
    cout << rs << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

		while (true) {
			int a = sc.nextInt();

			if (a == 0)

				break;

			double sum = 0;

			int[] b = new int[a];

			for (int i = 0; i < a; i++) {
				b[i] = sc.nextInt();
				sum += b[i];
			}

			double m = sum / a;
			double aa = 0;

			for (int i = 0; i < a; i++) {
				aa += Math.pow(b[i] - m, 2) / a;
			}

			System.out.println(Math.sqrt(aa));

		}
	}
}



Measured memory_bytes: 31496
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair





int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n: Int = sc.nextLine.toInt
    val k: Int = sc.nextLine.toInt
    val x: Int = sc.nextLine.toInt
    val y: Int = sc.nextLine.toInt

    if (n <= k) println(n * x)
    else println(k * x + y *(n - k))
  }
}


Measured memory_bytes: 27308
n=int(input())
turn=list(map(int,input().split()))
happy=list(map(int,input().split()))
combo=list(map(int,input().split()))
total=0
pre_t=-2
for t in turn:
    total+=happy[t-1]
    if pre_t+1==t:
        total+=combo[pre_t-1]
    pre_t=t
print(total)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int min = sc.nextInt();
        int max = sc.nextInt();

        int count = 0;
        for (int i = min; i <= max; i++) {
            if (isKaibun(i)) count++;
        }

        System.out.println(count);
    }

    private static boolean isKaibun(int n) {
        boolean isKaibun = true;
        String nString = Integer.toString(n);

        for (int i = 0; i < nString.length(); i++) {
            if (nString.charAt(i) == nString.charAt(nString.length()-1-i)) continue;

            // 文字が違うため回文ではない
            isKaibun = false;
            break;
        }

        return isKaibun;
    }
}


Measured memory_bytes: 27860
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int a = in.nextInt();
            int b = in.nextInt();
            int strips = 0;
            int sockets = 1;
            while (sockets < b)
            {
                sockets--;
                sockets += a;
                strips++;
            }
            out.print(strips);
        }

    }
}



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

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

    map<string, int> dic;
    for(int i=0; i<N; i++){
        string s;
        cin>>s;

        dic[s]++;
    }

    vector<pair<int, string>> S;
    for(auto a : dic){
        S.push_back({a.second, a.first});

    }

    sort(S.begin(), S.end());
 
    //cout<<"-------------answer-------------"<<endl;
    
    int max_num = S[S.size()-1].first;
    for(int i=0; i<S.size(); i++){
        if(max_num > S[i].first){

            continue;
        }

        cout<<S[i].second<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 29224
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     int n;
     cin >> n ;
     if(n>=1000) cout << "ABD" << endl;
     else cout << "ABC"<<endl;
}

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

using namespace std;

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl

const int maxn = (int)3e5+5;
typedef long long ll;

int main()
{
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;


    string s;
    cin >> s;

    if(s[0]>='a' && s[0]<='z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}



Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *p;
  struct node *r;
  struct node *l;
  int key;
};

typedef struct node * binary;

binary root;

void insert(int k){
  binary y=NIL;
  binary x=root;
  binary z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->l;
    else
      x=x->r;
  }

  z->p=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->l=z;
  else
    y->r=z;
}

void inorder(binary p){

  if(p->l!=NIL)
    inorder(p->l);

  printf(" %d",p->key);

  if(p->r!=NIL)
    inorder(p->r);

}
void preorder(binary p){

  printf(" %d",p->key);

  if(p->l!=NIL)
    preorder(p->l);

  if(p->r!=NIL)
    preorder(p->r);

}

binary find(binary t,int k){
  while(t!=NIL&&k!=t->key){
    if(k<t->key)
      t=t->l;
    else
      t=t->r;
  }
  return t;
}

int main(){
  int n,i,k;
  char a[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",a);

    if(a[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(a[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

    else{
      scanf("%d",&k);
      if(find(root,k)!=NIL)
        printf("yes\n");
      else
        printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N ,l,sum =0,max_l=0;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> l;
    sum += l;
    max_l = max(l,max_l);
  }
  sum -= max_l;
//   cout << max_l << " " << sum;
  if(max_l<sum){
      cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

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

int n, m, p;
using board = vector<vector<vector<int>>>;

bool in(int x, int y, int z){
    return 0<=x && x<n && 0<=y && y<n && 0<=z && z<n;
}

bool check(board &b, int x, int y, int z, int c){
    vector<int> cnt(13, -1);
    rep(i, 13)rep(j, 2){
        int tx = x, ty = y, tz = z;
        int sgn = j*2-1;
        int tmp = 0;
        rep(_, m){
            if(!in(tx, ty, tz) || b[tx][ty][tz] != c){
                break;
            }
            ++tmp;
            tx += sgn * dx[i];
            ty += sgn * dy[i];
            tz += sgn * dz[i];
        }
        cnt[i] += tmp;
    }
    return *max_element(cnt.begin(), cnt.end()) >= m;
}

int main(){
    while(scanf("%d%d%d", &n, &m, &p) && n){
        board b(n, vector<vector<int>>(n, vector<int>(n, -1)));
        vector<vector<int>> h(n, vector<int>(n, 0));
        int x[p], y[p];
        rep(i, p){
            scanf("%d%d", &x[i], &y[i]);
            --x[i], --y[i];
        }
        bool flag = false;
        rep(i, p){
            b[x[i]][y[i]][h[x[i]][y[i]]++] = i % 2;
            if(check(b, x[i], y[i], h[x[i]][y[i]]-1, i%2)){
                printf("%s %d\n", i%2==0 ? "Black" : "White", i+1);
                flag = true;
                break;
            }
        }
        if(!flag) puts("Draw");
    }
}


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

int dp[3001][3001];

int main()
{
    int i, j;
    stack <char> stk;
    string s, t;
    cin >> s >> t;
    for (i = 1; i <= s.length(); i++)
    {
        for (j = 1; j <= t.length(); j++)
        {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    i = --i;
    j = --j;
    while (dp[i][j] != 0)
    {
        if (dp[i - 1][j] == dp[i][j - 1] && dp[i][j - 1] < dp[i][j])
        {
            stk.push(s[i - 1]);
            i--;
            j--;
        }
        else if (dp[i - 1][j] < dp[i][j - 1])
            j--;
        else
            i--;
    }
    while (!stk.empty())
    {
        cout << stk.top();
        stk.pop();
    }
    cout << "" << "\n";
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  long X;
  cin>>X;
  
  long K=100;
  long sw=0;
  
  while(X>K){
    K=K*1.01;
    sw++;
  }
  
  cout<<sw<<endl;
}




Measured memory_bytes: 3624
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
int bnum[51];

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  vector<ll> a;
  vector<ll> sum;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    a.pb(x);
    if(i == 0)sum.pb(x);
    else sum.pb(x + sum[i - 1]);
  }
  map<ll, bool> mp;
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      ll tmp;
      if(i == 0)tmp = sum[j];
      else tmp = sum[j] - sum[i - 1];
      mp[tmp] = true;
      for(int l = 45; l >= 0; l--){
        if((tmp >> l) % 2 == 1)bnum[l]++;
      }
    }
  }
  vector<int> vec;
  for(int l = 45; l >= 0; l--){
    if(bnum[l] < k)continue;
    int kbit = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
      if((itr->second) && (itr->first >> l) % 2 == 1)kbit++;
    }
    if(kbit < k)continue;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
      if((itr->second) && (itr->first >> l) % 2 == 0)itr->second = false;
    }
    vec.pb(l);
  }
  ll res = 0;
  for(int i = 0; i < vec.size(); i++){
    res += ((ll)1 << vec[i]);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 31488
//
//AtCoder Beginner Contest 168
//C - : (Colon)
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int a, b, h, m;

    cin >> a >> b >> h >> m;

    double hs = h*30+0.5*m;
    double ms = m*6;

    double angle = abs(hs-ms);
    if (angle>180) angle = 360-angle;
 //   MSG(angle);

    double ans = sqrt((a*a)+(b*b)-(2*a*b)*cos(PI / (double)180 * (double)angle));

    cout << fixed;
    cout << setprecision(12) << ans << endl;

//    cout << (a*a)+(b*b)-(double)(2*a*b)*cos(PI / (double)180 * (double)angle) << endl;

    return 0;
}


Measured memory_bytes: 4168
#include <iostream> // cin, cout
#include <algorithm> // sort
#include <vector> // vector
#include <cstdio> // printf
#include <cmath> // M_PI
#include <numeric> // accumulate
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

void call(int n){
	for (int i = 3; i <= n; i++) {
		if (i % 3 == 0)
			cout << " " << i;
		else
			for (int x = i; x > 0; x /= 10)
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
	}
	cout << endl;
}

int		main(void)
{
	int n;
	cin >> n;
	call(n);
	return (0);
}



Measured memory_bytes: 3092
class UnionFind:
    """素集合を木構造として管理する"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """要素xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を統合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """要素xを含む集合の要素数を求める"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を求める"""
        return self.cnt


def is_bipartite(graph, s):
    """頂点sを含むgraphが二部グラフかどうかを判定する"""
    n = len(graph)
    stack = [s]
    visited[s] = 0
    is_bi = True
    while stack:
        v = stack.pop()
        for nxt_v in graph[v]:
            if visited[nxt_v] == -1:
                visited[nxt_v] = visited[v] ^ 1
                stack.append(nxt_v)
            elif visited[nxt_v] ^ visited[v] == 0:
                is_bi = False
    return is_bi


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(m)]


uf = UnionFind(n)
graph = [[] for i in range(n)]
for a, b in edges:
    a -= 1
    b -= 1
    uf.merge(a, b)
    graph[a].append(b)
    graph[b].append(a)


# 連結成分1の要素数
cnt1 = 0
for v in range(n):
    if uf.get_size(v) == 1:
        cnt1 += 1

# 連結成分が1ではない連結成分で二部グラフをなす個数
cnt_bi = 0
# 連結成分が1ではない連結成分で二部グラフをなさない個数
cnt_not_bi = 0

visited = [-1] * n
for v in range(n):
    if visited[v] == -1:
        flag = is_bipartite(graph, v)
        if uf.get_size(v) == 1:
            continue
        if flag:
            cnt_bi += 1
        else:
            cnt_not_bi += 1

ans = n ** 2 - (n - cnt1) ** 2
cnt = cnt_bi + cnt_not_bi
ans += 2 * (cnt_bi ** 2) + (cnt ** 2) - (cnt_bi ** 2)
print(ans)

Measured memory_bytes: 127492
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a=1,b=1,e=0,f=INT_MAX,g,h,x=0;
  cin>>a>>b;
  vector<vector<int>>c(a+1,vector<int>(b+1,INT_MAX));
  vector<vector<char>>d(a+1,vector<char>(b+1));
  rep(i,a){
    rep(o,b){
      cin>>d.at(i).at(o);
    }
  }
  if(d.at(0).at(0)=='#')c.at(0).at(0)=1;
  else c.at(0).at(0)= 0;
  rep(j,a){
    rep(i,b){
      if(d.at(j).at(i)!=d.at(j).at(i+1))c.at(j).at(i+1)=min(c.at(j).at(i)+1,c.at(j).at(i+1));
      else c.at(j).at(i+1)=min(c.at(j).at(i),c.at(j).at(i+1));
      if(d.at(j).at(i)!=d.at(j+1).at(i))c.at(j+1).at(i)=min(c.at(j).at(i)+1,c.at(j+1).at(i));
      else c.at(j+1).at(i)=min(c.at(j).at(i),c.at(j+1).at(i));
    }
  }
  if(d.at(a-1).at(b-1)=='#')cout<<(c.at(a-1).at(b-1)+1)/2;
  else cout<<(c.at(a-1).at(b-1))/2;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int d, t, s;
        scanf("%d%d%d", &d, &t, &s);
        double jikan= (d*1.0/s);
        if(jikan<=t){
                printf("Yes");
        }else{
                printf("No");
        }

        return 0;
}


Measured memory_bytes: 1732
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: u32,
        b: u32
    }
    println!("{}", a * b);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 2108
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    double n,k;
    cin >> n >> k;

    double p;
    if(n>k){
        p=((n-k+1)/n);
        for(int i=1;i<k;i++){
            int now=i;
            double nowp=1/n;
            while(now<k){
                now*=2;
                nowp*=0.500000000;
            }
            p+=nowp;
        }
    }
    else{
        p=0;
        for(int i=1;i<n+1;i++){
            int now=i;
            double nowp=1/n;
            while(now<k){
                now*=2;
                nowp*=0.500000000;
            }
            p+=nowp;
        }
    }
    

    cout << p << endl;

    return 0;
}


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

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

  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll h;
  cin >> h;

  ll ans = 0, cnt = 1;
  while (h > 0) {
    ans += cnt;
    h /= 2;
    cnt *= 2;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

#define M 1000000007

const long long INF = 10000000000000000;

using namespace std;


int main(){
	int N;
	cin>>N;
	vector<long long int> A(N);
	vector<long long int> B(N);
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i];
	}
	long long int sum=0;
	for(int i=N-1;i>=0;i--){
		A[i]+=sum;

		long long int res=A[i]%B[i];
		if(A[i]==0){
			sum+=0;
		}else if(A[i]<B[i]){
			sum+=B[i]-A[i];
		}
		else if(res!=0){
			sum+=B[i]-res;
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 1792
import pprint

N = int(input())
lst = []
for _ in range(N):
  hoge = list(input().split())
  hoge2 = _
  hoge3 = [hoge,hoge2]
  lst.append(hoge3)

lst.sort(key=lambda x:(x[0][0],-int(x[0][1])))

for i in range(N):
  print(lst[i][1]+1)

Measured memory_bytes: 3572
import Control.Applicative

type Card = (String, Int)

type Problem = [Card]

type Result = [Card]

solve :: Problem -> Result

solve xs
    = [x | x <- s ++ h ++ c ++ d, not $ elem x xs] where
        s = [("S", rank) | rank <- [1..13]]
        h = [("H", rank) | rank <- [1..13]]
        c = [("C", rank) | rank <- [1..13]]
        d = [("D", rank) | rank <- [1..13]]

input :: IO Problem

input
    = do
        n <- read <$> getLine
        xs <- inputCards n []
        return xs
        
inputCards :: Int -> Problem -> IO Problem

inputCards 0 xs
    = return xs
    
inputCards n xs
    = do
        [kind, rank] <- words <$> getLine
        inputCards (n - 1) $ (kind, read rank) : xs
    
output :: Result -> IO ()

output []
    = return ()
    
output xs
    = putStrLn $ init $ concat [kind ++ " " ++ show rank ++ "\n" | (kind, rank) <- xs]
    
main :: IO ()

main = output =<< solve <$> input

Measured memory_bytes: 4076
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a;
  for (int i = 0; i < n + n; i++) {
    int x;
    cin >> x;
    a.emplace_back(x, i < n ? 1 : -1);
  }
  sort(a.begin(), a.end());
  long long ans = 1;
  const long long mod = 1e9 + 7;
  int c = 0;
  for (int i = 0; i < n + n; i++) {
    if (c * a[i].second < 0) {
      ans *= 1LL * abs(c);
      ans %= mod;
    }
    c += a[i].second;
  }
  cout << ans << endl;
  return 0;	
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N);
    REP(i,N) cin >> A[i];
    ll sum = A[0];
    for(int i = 1; i < N; i++) sum ^= A[i];
    REP(i,N) {
        ll res = sum^A[i];
        cout << res << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4792
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<T> ReadVec1(int N) {
    vector<T> vec(N);
    for(int i = 0; i < N; i++)
        vec[i] = In<T>();
    return move(vec);
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(j, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() {
    int N = In<int>(), L = In<int>(), sum = 0, absmin=1e8;
    vector<int> aji(N);
    for(int i = 1; i <= N; i++){
        aji[i - 1] = L + i - 1;
        sum += aji[i-1];
    }
    cout << sum - *min_element(aji.begin(), aji.end(),[](int a, int b) { return abs(a) < abs(b); })<< endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define loop(n) for(int i=0;i<n;++i)
typedef long long ll;
typedef vector<int> vi;
ll i,j=0;

int main(){
    int x,y,z;cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;int main(){int n;cin>>n;int x[102],y[102],h[102];for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i];for(int i=0;i<101;i++){for(int j=0;j<101;j++){int a=1;int H=0;for(int k=0;k<n;k++){if(h[k]!=0)H=h[k]+abs(i-x[k])+abs(j-y[k]);}for(int k=0;k<n;k++){if(h[k]!=max(H-(abs(i-x[k])+abs(j-y[k])),0))a=0;}if(a)cout<<i<<" "<<j<<" "<<H<<endl;}}}

Measured memory_bytes: 256
from collections import deque

n,m = map(int, input().split())
P = list(map(lambda x: int(x)-1, input().split()))
XY = list(list(map(lambda x: int(x)-1, input().split())) for _ in range(m))
G = [[] for _ in range(n)]
for x, y in XY:
    G[x].append(y)
    G[y].append(x)

q = deque()
vis = [False]*(n)
ans = 0
for i in range(n):
    set_x, set_px = set(), set()
    q.append(i)
    while q:
        x = q.popleft()
        if vis[x]: continue
        vis[x] = True
        set_x.add(x)
        set_px.add(P[x])
        for y in G[x]:
            if vis[y]: continue
            q.append(y)
    ans += len(set_x & set_px)
print(ans)


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

#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                      \
  cout << #v << ":";                                      \
  for (int i = 0; i < v.size(); i++) cout << " " << v[i]; \
  cout << endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >
#define vll vector<vector<ll> >
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
const int inf = 1000000001;
const ll INF = 1e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
  int n, k, i, j;
  cin >> n >> k;
  vl a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vl sump(n + 1), summ(n + 1);
  for (i = 0; i < n; i++) {
    if (a[i] >= 0) {
      sump[i + 1] = sump[i] + a[i];
      summ[i + 1] = summ[i];
    }
    else {
      sump[i + 1] = sump[i];
      summ[i + 1] = summ[i] + a[i];
    }
  }
  //DEBUG_VEC(sump);
  //DEBUG_VEC(summ);
  ll sum = sump[n];
  ll ans = -INF;
  for (i = 1; i + k - 1 <= n; i++) {
    ans = max(ans, sum - (sump[i + k - 1] - sump[i - 1]));
    ans = max(ans, sum + (summ[i + k - 1] - summ[i - 1]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
/* 
 * ???????????§??????????´? PrintTestCases.java
 *
 * Copyright(C) 2016 Nagasaki Team All Rights Reserved.
 */
/**
 * ??°?????????????????????
 *
 * @author Sakai
 * @version 1.00
 */
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
	/*
	* ??°?????????????????????
	*/
	public static void main(String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader (new InputStreamReader(System.in));
		String str = br.readLine();
		int count = 1;
		while(!str.equals("0")){
			System.out.println( "Case " + count + ": " + str);
			count++;
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 31844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    ll s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe\n";
    } else {
        cout << "safe\n";
    }

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf ("%d%d", &a, &b);
    if (a-b >= 2) printf ("%d", 2 * a - 1);
    else if (b - a >= 2) printf ("%d", 2 * b - 1);
    else printf ("%d", a + b);
    return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = 1000000007;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n, k;
  cin >> n >> k;
  V a(n);
  VIN(n,a);
  vector<P> an(n);
  REP(i,n){
    an.at(i).first = 0;
    an.at(i).second = 0;
  }
  REP(i,n){
    REP(j,n){
      if (i < j && a.at(i) > a.at(j)){
        an.at(i).second++;
      }
      if (i > j && a.at(i) > a.at(j)){
        an.at(i).first++;
      }
    }
  }
  unsigned long long t=0;
  REP(i,n){
    unsigned long long tmp = 0;
    tmp = (((k + 1)) * an.at(i).second + ((k-1)) * an.at(i).first) % MOD;
    if (tmp % 2 == 1 && k % 2 == 1){
      t += (tmp+MOD) * k / 2;
    }else{
      t += tmp * k / 2;
    }
    t %= MOD;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
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;}
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);}
var streams=[];function print(s){streams.push(s);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var k = next();
  return "ACLACLACLACLACL".slice(0,k*3);
}

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

#define ll long long
#define DAY 5000000000000000LL

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s; ll k;
	cin >> s >> k;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] != '1') {
			cout << s[i];
			return 0;
		}
		else {
			k--;
			if (k == 0) break;
		}
	}
	cout << "1";
}

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

int main(){
    string str;
    cin >> str;
    int one,zero;
    one = zero = 0;
    for(auto s : str){
        if(s == '1'){
            one++;
        }
        else{
            zero++;
        }
    }
    cout << str.size()-(max(one,zero)-min(one,zero)) << endl;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}


const int mod = MOD;
const int max_n = 2000050;
struct mint {
  ll x; // typedef long long ll;
  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;
  }
 
  // for prime mod
  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;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);

int main(){
  ll n;cin >> n;
  vl v(n);rep(i,n)cin >> v[i];sort(all(v));rev(all(v));
  mint ans=0;
  mint two=2;
  rep(i,n){
    if(i==0)ans+=two.pow(n-1)*v[i];
    else ans+=two.pow(n-2)*(i+2)*v[i];
  }
  ans*=two.pow(n);
  cout << ans <<endl;
}

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

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

    int ans = 0;
    for(int n=1;n<=N;n+=2){
        int divisor = 0;
        for(int i=1;i<=n;i++){
            if(n%i==0){
                divisor++;
            }
        }
        if(divisor==8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
const int N=5e5+5,mod=1e9+7;
#define ll long long
int a[N],nxt[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int lst=n;
    for(int i=n-1;i>=0;i--)
    {
        nxt[i]=lst;
        if(a[i]) lst=i;
    }
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        int sum=0;
        for(int j=i;j<n;j=nxt[j])
        {
            if(sum&a[j]) break;
            sum^=a[j];
            ans+=nxt[j]-j;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n, min_num, ans;
    cin >> n;
    min_num = 1001001001;
    ans=0;
    rep(i,n){
        int a;
        cin >> a;
        if (a <= min_num){
            ans++;
            min_num = a;
        }
        
    }
    cout << ans << endl;
    return 0;
}

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    ll count = 0;
    cin >> n >> s;
    vector<int> freq(26, 0);
    vector<vector<int>> dp(26, vector<int> (n));
    for(int i = 0; i < n; i++) {
        freq[s[i]-65]++;
        dp['R'-65][i] = freq['R'-65];
        dp['B'-65][i] = freq['B'-65];
        dp['G'-65][i] = freq['G'-65];
    }
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j<n; j++) {
            if(s[j] != s[i]) {
                int ot;
                if('R' != s[i] && 'R' != s[j]) {
                    ot = 'R';
                } else if (s[i] != 'B' && s[j] != 'B') {
                    ot = 'B';
                } else{
                    ot = 'G';
                }
                count += dp[ot-65][n-1] - dp[ot-65][j];
                if(j+j-i < n && s[j+j-i] == ot) {
                    count--;
                }
            }
        }
    }
    cout << count << "\n";
    return 0; 
} 

Measured memory_bytes: 3772
from collections import deque


def main():
  n,q=map(int,input().split())
  node=[[]*n for i in range(n)]
  for i in range(n-1):
    a,b=map(lambda x:int(x)-1,input().split())
    node[b].append(a)
    node[a].append(b)
  
  ans=[0]*n
  for i in range(q):
    p,x=map(int,input().split())
    p-=1
    ans[p]+=x

  root=[0]*n
  edge=[[]*n for i in range(n)]
  root[0]=0
  q=deque([0])
  visited=[False]*n
  visited[0]=True
  
  while q:
    r=q.popleft()
    for e in node[r]:
      if not visited[e]:
        visited[e]=True
        q.append(e)
        root[e]=r
        edge[r].append(e)
  
  
  p=[0]*n
  q=deque(edge[0])
  visited=[False]*n
  while q:
    e=q.popleft()
    p[e]=p[root[e]]+1
    for e2 in edge[e]:
      if not visited[e2]:
        visited[e2]=True
        q.append(e2)
  
  p=sorted(enumerate(p), key=lambda x:x[1])
  for i in range(1,n):
    e=p[i][0]
    r=root[e]
    ans[e]+=ans[r]
    
  print(*ans,sep=' ')


if __name__=='__main__':
  main()

Measured memory_bytes: 108040
a,b,c,d = map(int,input().split())
import fractions
s1 = b//c
s2 = (a-1)//c
p1 = b//d
p2 = (a-1)//d
e = c*d//fractions.gcd(c,d)
q1 = b//e
q2 = (a-1)//e
print(b-a+1-(s1+p1-s2-p2-q1+q2))

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

int main() {
    ll x;
    cin>>x;
    ll c=100;
    ll cnt=0;
    while(c<x){
        c=c*1.01;
        cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    long N, x, a, b, n=0;
    cin >> N >> x >> a;
    for (long i=1; i<N; i++){
        cin >> b;
        if (a + b > x ){
            n += a + b - x;
            if (x - a >= 0){
                b = x - a;
            }else{
                b = 0;
            }
        }
        a = b;
        //cout << n << endl;
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3600
mp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nM = int(Tmp[1])
 
nF = [ 0 for i in range(nM)]
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
  nTmpN = int(Tmp[0])
  for j in range(nTmpN):
    nCnt = int(Tmp[j+1]) - 1
    nF[nCnt] += 1

nAns = 0
for i in range(nM):
  nTmpN = nF[i]
  if nTmpN == nN:
    nAns += 1

print(nAns)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Reader r = new Reader(System.in)) {
            int X = r.i();
            int A = r.i();

            System.out.println(X < A ? 0 : 10);
        }
    }

    public static class Reader implements AutoCloseable {

        private BufferedReader br;

        private String[] buf;

        private int bufidx = -1;

        public Reader(InputStream in) {
            this.br = new BufferedReader(new InputStreamReader(in));
        }

        @Override
        public void close() throws Exception {
            br.close();
        }

        private void readBuf() throws IOException {
            if (bufidx == -1 || bufidx == buf.length) {
                buf = br.readLine().split(" ");
                bufidx = 0;
            }
        }

        public String s() throws IOException {
            readBuf();
            return buf[bufidx++];
        }

        public int i() throws IOException {
            return Integer.parseInt(s());
        }

        public long l() throws IOException {
            return Long.parseLong(s());
        }

        public double d() throws IOException {
            return Double.parseDouble(s());
        }

        public String[] sa() throws IOException {
            readBuf();
            if (bufidx != 0) {
                throw new RuntimeException("illegal read");
            }
            bufidx = -1;
            return buf;
        }

        public int[] ia() throws IOException {
            String[] sa = sa();
            int[] ia = new int[sa.length];
            for (int i = 0; i < sa.length; i++) {
                ia[i] = Integer.parseInt(sa[i]);
            }
            return ia;
        }

        public long[] la() throws IOException {
            String[] sa = sa();
            long[] la = new long[sa.length];
            for (int i = 0; i < sa.length; i++) {
                la[i] = Long.parseLong(sa[i]);
            }
            return la;
        }

        public double[] da() throws IOException {
            String[] sa = sa();
            double[] da = new double[sa.length];
            for (int i = 0; i < sa.length; i++) {
                da[i] = Double.parseDouble(sa[i]);
            }
            return da;
        }

        public int[][] im(int N) throws IOException {
            int[][] im = new int[N][];
            for (int i = 0; i < N; i++) {
                im[i] = ia();
            }
            return im;
        }

        public long[][] lm(int N) throws IOException {
            long[][] lm = new long[N][];
            for (int i = 0; i < N; i++) {
                lm[i] = la();
            }
            return lm;
        }

        public double[][] dm(int N) throws IOException {
            double[][] dm = new double[N][];
            for (int i = 0; i < N; i++) {
                dm[i] = da();
            }
            return dm;
        }

    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> v(3);
	int i = 0;
	while (i<n) {
		cin >> v[0] >> v[1] >> v[2];
		sort(v.begin(), v.end());
		if (sqrt(pow(v[0],2)+pow(v[1],2))==v[2]) cout << "YES" << endl;
		else cout << "NO" << endl;
		i++;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[30];
int q[30];
char str[8];
int main(){
	int sz=0;
	int sz2=0;
	int a;scanf("%d",&a);
	int b;scanf("%d",&b);
	for(int i=0;i<b;i++){
		int c;scanf("%s%d",str,&c);
		if(str[0]=='D')p[sz++]=-c;
	}
	int d;scanf("%d",&d);
	for(int i=0;i<d;i++){
		int c;scanf("%s%d",str,&c);
		if(str[0]=='D'&&str[1]=='D')q[sz2++]=-c;
	}
	std::sort(p,p+sz);
	std::sort(q,q+sz2);
	
	int ret=0;
	for(int i=0;i<=a;i++){
		int val=0;
		for(int j=0;j<i;j++)val-=p[j];
		for(int j=0;j<(a-i)/2;j++)val-=q[j];
		ret=max(ret,val);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1028
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+7;
const int mod = 1e14 ;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
ll a[MAXN];
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int n;ll ans=0,tot=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1,cmp);
	ans=a[1];tot++;
	for(int i=2;i<=n;i++)
	{
		if(tot==n) break;
		ans+=a[i];tot++;
		if(tot==n) break;
		ans+=a[i];tot++;
		if(tot==n) break;
	}
	printf("%lld\n",ans);
	return 0;
 } 

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i] ;
		a[i] *= 2 ;
	}
	vector<ll> ans(n);
	ll sum = 0 ;
	rep(i,n){
		if(i%2==0){
			//plus
			sum += a[i] ;
		} else{
			sum -= a[i];
		}
	}
	ans[0] = sum / 2 ;
	for(int i = 1 ; i < n ; i ++) {
		ans[i] = a[i-1] - ans[i-1] ;
	}
	for(auto x: ans){
		cout << x << " " ;
	}
	cout << endl;

}


Measured memory_bytes: 2944