akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
template <typename T>
struct BinaryIndexedTree{
  int size,bitn=0;
  T I;
  using func=function<T(T,T)>;
  func F;
  vector<T> tree;
  BinaryIndexedTree(int N,T e,func f):size(N+1),I(e),F(f),tree(size,e){}
  BinaryIndexedTree(int N):size(N+1),I(0),F([](T a,T b){return a+b;}),tree(size,0){}
  void act(int i,T x){
    for(++i;i<size;i+=-i&i){
      tree[i]=F(tree[i],x);
    }
  }
  //return F([0,i]);
  T queli(int i){
    T res=I;
    for(++i;i>0;i-=-i&i){
      res=F(tree[i],res);
    }
    return res;
  }
  //sum([l,r));
  T sum(int l,int r){
    // if(--l>--r)return 0;
    assert(--l<=--r);
    if(l<0)return queli(r);
    else return queli(r)-queli(l);
  }
  //only(N,+)
  int lower_bound(int x){
    int i=0;
    if(!bitn){
      i=size;bitn=1;
      while(i){
        i>>=1;bitn<<=1;
      }
      i=0;
    }
    for(int k=bitn;k;k>>=1){
      if(i+k<size&&tree[i+k]<x){
        i+=k;
        x-=tree[i];
      }
    }
    return i;
  }
};
int main(){
  startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,N,Q;
  cin>>N>>Q;
  BinaryIndexedTree<ll> tree(N);
  rep(i,N){cin>>j;tree.act(i,j);}
  while(Q--){
    cin>>i;
    if(i){
      cin>>i>>j;
      print(tree.sum(i,j));
    }else{
      cin>>i>>j;
      tree.act(i,j);
    }
  }
  // }
}

Measured memory_bytes: 8252
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: D.cpp
Time: 16-08-2019T22:36:50+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define mp(i, j) make_pair(i, j)
#define pb(a) push_back(a)
#define ppb(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
int t = 1, n, m, q, ql, qr;
char ch;
vi_t inp, res, cal;
int solve(){
    cal.resize(n+1);
    int sum=0;
    for(int i=n;i>0;i--){
        sum=0;
        for(int j=i+i; j<=n; j+=i){
            sum+=cal[j];
        }
        if((sum+inp[i-1])&1) {
            cal[i]=1;
            res.pb(i);
        }
        else cal[i]=0;
    }
    printf("%d\n", res.size());
    FORE(i, res){
        printf("%d ", i);
    }
    printf("\n");
    return 0;
}

int main(){
    // scanf("%d", &t);
    while(t--){
        scanf("%d", &n);
        inp.resize(n);
        FOR(i,0,n){
            scanf("%d", &inp[i]);
        }
        solve();
    }
}

Measured memory_bytes: 3064
import numpy as np
H, W=map(int, input().split())
A=[]
for i in range(H):
  A.append(list(map(int, input().split())))

B=[]
for i in range(H):
  if i%2==0:
    for j in range(W):
      B.append([A[i][j],i,j])
  else:
    for j in range(1,W+1):
      B.append([A[i][-j],i,W-j])
      
ans=[]


for i in range(len(B)-1):
  a,x,y=B[i][0], B[i][1], B[i][2]
  if a%2==1:
    B[i+1][0]+=1
    ans.append((x,y,B[i+1][1], B[i+1][2]))
print(len(ans))  
for a,b,c,d in ans:
  print(a+1,b+1,c+1,d+1)




Measured memory_bytes: 57152
#include<stdio.h>
int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b) {
		printf("%d\n", a);
	}
	else if(a == b){
		printf("%d\n", a);
	}
	else if (a > b) {
		printf("%d\n", a - 1);
	}
	return 0;
	}



Measured memory_bytes: 128
// AtCoder Regular Contest 076
// C - Reconciled?

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

const ll MOD = 1000000007;

int N, M;

ll calc() {
    ll res;
    ll fact = 1;

    if (N < M) {
        swap(N, M);
    }
    if (N - M > 1) {
        return 0;
    }
    for (int i = 1; i <= M; i++) {
        fact *= i;
        fact %= MOD;
    }
    res = fact * fact % MOD;
    if (N == M) {
        res *= 2;
        res %= MOD;
    } else {
        res *= N;
        res %= MOD;
    }
    return res;
}

int main() {

    cin >> N >> M;
    cout << calc() << endl;

    return 0;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll x;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x;
    cout << 1 - x;
    return 0;
}


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

#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

void enqueue(int);
int dequeue(void);
void BFS(int);

int n,Q[MAX],head=1,tail=1;
int C[MAX],k[MAX],A[MAX][MAX],d[MAX];

int main()
{
  int i,j,id;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++)
    {
      scanf("%d",&id);
      scanf("%d",&k[id]);
      for(j = 1 ; j <= k[id] ; j++)
	{
	  scanf("%d",&A[id][j]);
	}
    }

  for(i = 1 ; i <= n ; i++) //データの初期化
    {
      C[i] = WHITE;
      d[i] = NIL;
    }

  BFS(1);

  for(i = 1 ; i <= n ; i++)
    {
      printf("%d %d\n",i,d[i]);
    }
  
  return 0;
}

void BFS(int s)
{
  int v,j,u;
 
  C[s] = GRAY;
  d[s] = 0;
  enqueue(s);

  while(u = dequeue())
    {
      for(j = 1 ; j <= k[u] ; j++)
	{
	  v = A[u][j];
	  if(C[v] == WHITE)
	    {
	      C[v] = GRAY;
	      d[v] = d[u] + 1;
	      enqueue(v);
	    }
	    
	}
      C[u] = BLACK;
    }

  return;
}

void enqueue(int x)
{
  if(head == tail + 1 || (head == 1 && tail == n)) exit(2);
  Q[tail] = x;
  if(tail == n)
    {
      tail = 1;
    }
  else tail++;

  return;
}

int dequeue()
{
  int x;
  
  if(head == tail) return 0;
  x = Q[head];
  if(head == n)
    {
      head = 1;
    }
  else head++;

  return x;
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main(){
  long long int ans = 0;
  int n, x;
  cin >> n >> x;
  int a[n];
  for(int i = 0; i<n; ++i) cin >> a[i];
  if(a[0]>x){
    ans += a[0] - x;
    a[0] -= ans;
  }
  for(int i = 0; i<n-1; ++i){
    if(a[i]+a[i+1]>x){
      ans += a[i]+a[i+1]-x;
      a[i+1] -= a[i]+a[i+1]-x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    string s;cin >> s;
    int k;cin >> k;
    vector<string> v;
    for(int i=1;i<=5;i++){
        for(int j=0;j<s.size();j++){
            string t;
            for(int k=0;k<i;k++){
                if(j+k>=s.size()) continue;
                t+=s[j+k];
            }
            v.push_back(t);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    cout << v[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    under, over = [], []
    for i in range(N):
        d = A[i] - B[i]
        if d < 0:
            under.append(d)
        elif 0 < d:
            over.append(d)
    over.sort(reverse=True)
    
    ans = len(under)
    lack = -sum(under)
    for i in range(len(over)):
        if lack <= 0:
            break
        lack -= over[i]
        ans += 1
    
    if 0 < lack:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 18292
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int out=0, point=0, base=0,n=0;
   string s;
   
   
   cin>> n;
   while(getline(cin,s)){
      if(s=="HIT"){
         if(base==3){
            point++;
         }else{
            base++;
         }
      }else if(s=="OUT"){
         out++;
      }else if(s=="HOMERUN"){
         point+=base+1;
         base=0;
      }
      if(out==3){
         cout << point << endl;
         point=0;
         out =0;
         base=0;
      }
   }
   
}

Measured memory_bytes: 1212
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1];
	((a*b)&1 ? "Odd" : "Even").writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, x, a, ans = 1000;
  bool c[101] = {};
  cin >> n >> m >> x;
  for(int i=0;i<m;i++){
    cin >> a;
    c[a] = true;
  }
  int sm1 = 0, sm2 = 0;
  for(int i=x;i<=n;i++) sm1 += (c[i]?1:0);
  for(int i=x;i>=0;i--) sm2 += (c[i]?1:0);
  cout << min(sm1, sm2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[100],c=0,n,j,i,s;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j]<a[j-1]){
	s=a[j];
	a[j]=a[j-1];
	a[j-1]=s;
	c++;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n%d\n",a[n-1],c);
       return 0;
       }



Measured memory_bytes: 2104
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int a, b;
    scan(a, b);
    writeln(max(a + b, a - b, a * b));
}


















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    string s,t;
    cin >> s;
    int cntg=0,cntp=0;
    F(i,0,s.size()){
        char ch='g';
        if(cntp+1<=cntg){
            ch='p';
        }
        if(ch=='g') cntg++;
        else cntp++;
        t+=ch;
    }
    int ans=0;
    F(i,0,s.size()){
        if(s[i]=='g' && t[i]=='p') ans++;
        if(s[i]=='p' && t[i]=='g') ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  int mini=t.size();
  for(int i=0;i<s.size()-t.size()+1;i++){
    int cnt=0;
    for(int j=0;j<t.size();j++){
      if(s.at(i+j)!=t.at(j)){
        cnt++;
      }
    }
    if(mini>cnt){
      mini=cnt;
    }
  }
  cout<<mini;
  
}


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

int main(){
	int n;
	cin >> n;
	vector<int> d(105);
	rep(i,n){
		int c;
		cin >> c;
		d[c]++;
	}
	int ans = 0;
	REP(i,100){
		if(d[i] != 0) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        for (int i = 0; i < 1000000000; i++) {
            N /= K;
            if (N == 0) {
                System.out.println(i + 1);
                return;
            }
        }

    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define precise cout << fixed << setprecision(9) <<
#define FOR(i,n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

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

int main(){
	double  w,h,x,y;
	cin >> w >> h >> x >> y;
	precise (w*h)/2 << " " << ((x==(w)/2) && y==((h)/2)) ? 1 : 0;
}

Measured memory_bytes: 384
n, m=map(int, input().split())
a=[]
b=[]
g=[[] for i in range(n)]
for i in range(m):
  ai, bi=map(int, input().split())
  ai-=1
  bi-=1
  g[ai].append(bi)
  g[bi].append(ai)
  a.append(ai)
  b.append(bi)
used=[False for i in range(n)]
dame1=0
dame2=0
def dfs(x):
  used[x]=True
  for y in g[x]:
    if dame1==x and dame2==y:
      continue
    if not used[y]:
      dfs(y)
ans=0
for i in range(m):
  used=[False for i in range(n)]
  dame1=a[i]
  dame2=b[i]
  dfs(a[i])
  if not used[b[i]]:
    ans+=1
print(ans)

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

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	ll a = 0, b = 0;
	string s;
	cin >> s;
	rep(i, s.size())
	{
		if (s[i] == 'a'){
			if (a + b< A + B)
			{
				a++;
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
		else if (s[i] == 'b')
		{
			if (a + b < A + B && b < B)
			{
				b++;
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
import math
import itertools

N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))

def calc(a,b):
    x1, y1 = a
    x2, y2 = b
    return math.sqrt((x1-x2)**2 +(y1 - y2)**2)

ans = 0

for order in itertools.permutations(range(N)):
    tmp = 0
    for i in range(1,N):
        tmp += calc((xy[order[i]]), (xy[order[i-1]]))
    ans += tmp

ans /= math.factorial(N)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<iomanip>
#include<string.h>
using namespace std;
// log10(x)+1  number of digits 
void bubblesort(int arr[], int n);
int main()
{
	double pi = 3.14285714285714285714;
	int r;
	cin >> r;
	cout << fixed << setprecision(20) << 2 * pi*r;
}
void bubblesort(int arr[], int n)
{
	int i = 0, j = 0;
	for (; i < n - 1; i++)
	{
		for (; j < n - 1 - i; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				swap(*&arr[j], *&arr[j + 1]);
			}
		}
	}
}

Measured memory_bytes: 3788
N = int(input())
e = [0] * (N+1)
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j
def num(m): # e の要素のうち m-1 以上のものの個数
    return len(list(filter(lambda x: x >= m-1, e)))
print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
    + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 3064
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      String c = scanner.next();
      int am = scanner.nextInt();
      int pm = scanner.nextInt();
      System.out.printf("%s %d %d\n", c, am + pm, (am * 2 + pm * 3) * 100);
    }
  }
}

Measured memory_bytes: 17200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
void solve()
{
	ll k,s,i,j,z,ans=0;
	cin >> k >> s;
	for (i = 0; i <= k; i++)
	{
		for (j = 0; j <= k; j++)
		{
			z=s-(i+j);
			if(z>=0 && z<=k && (i+j+z)==s)
			{
				ans++;
			}

		}

	}
	cout<<ans<<endl;
}

	int main()
	{
//#ifndef ONLINE_JUDGE
//		freopen("input.txt", "r", stdin);
//		freopen("output1.txt", "w", stdout);
//#endif
		ll t = 1;
		//cin >> t;
		while (t--)
		{
			solve();
		}
	}

Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	int A, B;
	string op;
	cin >> A >> op >> B;
	if (op == "+") {
		cout << A + B << endl;
	}
	else {
		cout << A - B << endl;
	}
}


Measured memory_bytes: 256
import java.io.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/6/23 11:55
 * @see meituan.n2018.Bturn
 */
public class Main {


    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;

    private static void solve() throws IOException {
        int n = nextInt();

        int pre = -1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = nextInt();
            if (a != pre) {
                pre = a;
            } else {
                pre = -1;
                ans++;
            }
        }
        pw.print(ans);
    }

    public static void main(String args[]) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\''); //指定单引号、双引号和注释符号是普通字符
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

        long t = System.currentTimeMillis();
        solve();
        pw.flush();
    }


    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static long nextLong() throws IOException {
        st.nextToken();
        return (long) st.nval;
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}

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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int dis, mx = 0;
    rep(i,N) {
    	if (i == N-1) dis = A[0]+K-A[i];
    	else dis = abs(A[i+1]-A[i]);
    	mx = max(dis, mx);
    }
    int ans = K-mx;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n, m, c;
    int A[30][30];
    int B[30];
    int ans = 0;
    
    cin >> n >> m >> c;
    
    for(int i=0; i<m; i++){
        cin >> B[i];
    }


    for(int i=0; i<n; i++){
        int sum = 0;
        for(int j=0; j<m; j++){
            cin >> A[i][j];
            //cout << A[i][j] << " " << B[j] << "  ";
            sum += A[i][j] * B[j]; 
        }
        sum += c;
        //cout << sum << endl;
        if(sum > 0) ans += 1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll int64_t
#define ull uint64_t
using namespace std;
using namespace std;

int main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
  #endif
  string s;
  cin>>s;
  int r=0;
  if(s[0]=='R' && s[1]=='R'&&s[2]=='R')
  	cout<<"3";
  else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
  	cout<<"2";
  else if(s[0]=='R' || s[1]=='R'|| s[2]=='R')
  	cout<<"1";
  else
     cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3616
N = int(input())
A = list(map(int, input().split()))
ans = []
x = A[N-1]
for i,j in zip(range(N-2, -1, -1), range(3, N+2)) :
  x += A[i]*((-1)**j)
for q in range(N):
  ans.append(x)
  x = 2*A[q] - x
ans = list(map(str, ans))
print(" ".join(ans))

Measured memory_bytes: 18500
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>



using namespace std;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (true) {

		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}

		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}




	return 0;
}


Measured memory_bytes: 3592
(let* 
  ((n (read))
    (vec (make-array n 
            :element-type 'fixnum 
            :initial-contents 
              (sort 
                (loop :as i 
                      :below n 
                      :collect (read))
                #'<))))
  (princ (- (aref vec (/ n 2))
            (aref vec (- (/ n 2) 1)))))
  

Measured memory_bytes: 59752
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int l[11];
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    int sum = 0;
    sort(l, l+n, greater<>());
    for(int i=1; i<n; i++){
        sum += l[i];
    }
    if(l[0]<sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include <atcoder/segtree>
//python3 ac-library/expander.py sol.cpp

int f(int a,int b){return max(a,b);}
int e(){return -1;}
int tmp;
bool cmp(int v){return v<tmp;}

int main(){
   int n,q; cin>>n>>q;
   vector<int> a(n);
   rep(i,0,n)cin>>a[i];
   atcoder::segtree<int,f,e> seg(a);
   rep(i,0,q){
      int t; cin>>t;
      if(t==1){
         int x,v; cin>>x>>v; x--;
         seg.set(x,v);
      }
      if(t==2){
         int lb,rb; cin>>lb>>rb; lb--;
         cout<<seg.prod(lb,rb)<<endl;
      }
      if(t==3){
         int x; cin>>x>>tmp; x--;
         cout<<seg.max_right<cmp>(x)+1<<endl;
      }
   }
   return 0;
}

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

using namespace std;
int mp[102];
char s[10];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	memset(mp,0,sizeof(mp));
	for(int i=0;i<n;i++){
		scanf("%s",s);
		if(!mp[s[0]-'A']){
			mp[s[0]-'A']=1;
			ans++;
		}
	}
	if(ans==3) cout<<"Three"<<endl;
	else  puts("Four");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(float,input().split()))

dp=[[0.0]*(n+1) for i in range(n+1)]
dp[0][0]=1.0

for i in range(n):
 for j in range(n):
  dp[i+1][j+1]+=dp[i][j]*p[i]
  dp[i+1][j]+=dp[i][j]*(1-p[i])

print(sum(dp[-1][(n+1)//2:]))

Measured memory_bytes: 111964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s.at(k-1) == 'A') s.at(k-1) = 'a';
  else if(s.at(k-1) == 'B') s.at(k-1) = 'b';
  else s.at(k-1) = 'c';
  cout << s << endl;
  }


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<PLL> v;
	REP(i, N) {
	  int64 X, L;
	  cin >> X >> L;
	  v.emplace_back(X+L, X-L);
	}
	sort(all(v));
	int64 res = 0, r = -INF_LL;
	REP(i, N) {
	  if (r <= v[i].sc) {
	    res++;
	    r = v[i].fs;
	  }
	}
	cout << res << endl;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  //和が奇数なら、1を加算して切り上げ扱い、偶数ならそのまま
  cout << ((a + b) + (a + b) % 2) / 2 << endl;
}


Measured memory_bytes: 3536
X = gets.chomp.to_i               # 単一整数
    X.freeze
     
    a = 0
    b = 0
     
    for num1 in -118..120 do
      for num2 in -num1..num1 do
        if num1 ** 5 - num2 ** 5 == X then
          a = num1
          b = num2
          break
        end
      end
    end
    puts a.to_s + " " + b.to_s

Measured memory_bytes: 14284
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,p,q,a[100002],ans,x,i;
    while(cin>>n>>p>>q)
    {
        ans=0;
        for(i=0;i<n;i++) cin>>a[i];
        for(i=1;i<n;i++)
        {
            x = a[i]-a[i-1];
            if(p*x<q) ans+=(p*x);
            else ans+=q;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#coding: utf-8
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False for _ in range(N)]
state = 0
heiro = [0]
visited[0] = True
while True:
    state = A[state]-1
    heiro.append(state)
    # print("state", state, A[state])
    if visited[state]:
        break
    visited[state] = True
if K < len(heiro):
    print(heiro[K] + 1)
else:
    cnter = dict(Counter(heiro))
    for k in cnter.keys():
        if cnter[k] == 2:
            v = k
            break
    idx = heiro.index(v)
    K -= idx
    # ans = heiro[idx:-1][K % (len(heiro) - idx - 1)] + 1
    ans = heiro[idx:-1][K % len(heiro[idx:-1])] + 1
    print(ans)

Measured memory_bytes: 36660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
extern inline uint xor128(void){
  static uint x=123456789,y=362436069,z=521288629,w=88675123; 
  uint t=x^(x<<11);
  x=y; y=z; z=w;
  return w=(w^(w>>19))^(t^(t>>8)); 
}
struct node {
  node *l,*r;
  ll val;//値
  ll pri;//優先度
  ll cnt;//部分木のサイズ
  ll sum;//部分木の値の和
  node(ll v) : val(v), cnt(1), sum(v) {
    l = r = NULL;
    pri = xor128();
  }
};

typedef pair<node*,node*> pnn;
struct Treap{
  node* root;
  Treap(){ root = NULL; }

  ll count( node * t){ return !t ? 0:t->cnt; }
  ll sum( node *t ) { return !t ? 0:t->sum; }

  node *update(node *t ){
    t->cnt = count(t->l) + count(t->r) + 1;
    t->sum = sum(t->l) + sum(t->r) + 1;
    return t;
  }

  node *merge(node *l, node *r ){
    if( !l || !r ) return !l ? r : l;

    if( l->pri > r ->pri ){
      l->r = merge(l->r,r);
      return update(l);
    } else {
      r->l = merge(l,r->l);
      return update(r);
    }
  }

  pnn split(node* t,int k){
    if( !t ) return pnn(NULL,NULL);
    if( k <= count(t->l) ){
      pnn s = split(t->l,k);
      t->l = s.second;
      return make_pair(s.first,update(t));
    } else {
      pnn s = split(t->r,k - count(t->l) - 1);
      t->r = s.first;
      return make_pair(update(t),s.second);
    }
  }

  int search(ll v){//v以下がいくつあるか
    node* t = root;
    ll sum = 0;
    while( t ){
      if( t->val <= v ){
        sum += count(t->l) + 1;
        t = t->r;
      } else {
        t = t->l;
      }
    }
    return sum;
  }

  bool isexist(ll v){//vがあるか否か
    node *t = root;
    while( t ){
      if( t->val < v ){
        t = t->r;
      } else if( t->val > v ){
        t = t->l;
      } else  return true;
    }
    return false;
  }

  node* insert(node *t, int k, ll v ){
    pnn s = split(t,k);
    s.first = merge(s.first,new node(v));
    return merge(s.first,s.second);
  }

  node* insert(ll v){
    if( !root ) return root = new node(v);
    return root = insert( root, search(v), v );
  }

  void print(node* v){
    if( !v ) return;
    print(v->l);
    cout << v->val << " ";
    print(v->r);
  }
  void print(){
    cout << "print :";
    print(root);
    cout << endl;
  }
  
};

Treap T;

ll N,K;
ll a[200001];
ll ans=0;
  
int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>a[i];
    a[i]-=K;
  }
  
  ll sum=0;
  T.insert(0);
  
  for(int i=0;i<N;i++){
    sum+=a[i];
    ans+=T.search(sum);
    
    T.insert(sum);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 14336
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

#n=int(raw_input())
n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=0
chk=1
x=IS
y=0
for i in a:
    if x>i:
        x=i
    elif y<i:
        y=i
    if i-x>chk:
        ans=1
    elif i-x==chk:
        ans+=1
    chk=max(chk,i-x)
print ans

Measured memory_bytes: 11328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

const int mx = 2e5;
int n;
int32_t main(){ fast;
	
	cin>>n;
	vector<int> a(n);
//	map<int, int> cnt;
	vector<int> cnt(mx, 0);
	ll tot = 0;
	rep(i, n){
		cin>>a[i];
		tot += cnt[a[i]];
		cnt[a[i]]++;
	}
	rep(i, n){
		cout<<tot - (cnt[a[i]] - 1)<<" ";
	}
}


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

int main(){
  string s;
  cin>>s;
  if((s.at(0)==s.at(1)&&s.at(1)==s.at(2)) || (s.at(1)==s.at(2)&&s.at(2)==s.at(3))) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
import math
a, b = map(int, input().split())


def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp!=1:
        arr[temp] = 1
    if arr==[]:
        arr[n] = 1
    return arr


g = math.gcd(a, b)
print(len(factorization(g))+1)


Measured memory_bytes: 9460
using System;
using System.Text.RegularExpressions;

namespace ITP1_5_D{
    class Sample{
        static void Main(string[] args){
            Sample s = new Sample();
            int num = int.Parse(Console.ReadLine());
            s.call(num);
        }
        void call(int n){
            for(int i=1; i<=n;i++){
                if(i%3 == 0){
                    Console.Write(" {0}",i);
                    continue;
                }
                string x = i.ToString();
                Match mat = Regex.Match(x, "[3]");
                if((string.Compare(mat.Value, "0"))>0){
                    Console.Write(" {0}",i);
                }
            }
            Console.WriteLine();
        }
    }
}


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

int n, s, cnt;

void dfs(int i, int sum, int n){
	if(sum==s&&!n){
		cnt++;
		return;
	}
	if(i==10||!n) return;
	//使用する3つを探索
	//使用しなければカウントされない
	dfs(i+1,sum,n);
	dfs(i+1,sum+i,n-1);
}

int main(){
	while(cin >> n >> s, n!=0||s!=0){
		cnt = 0;
		dfs(0, 0, n);
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
# Onum : Obs. Num
# Rnum : Road Num
# H : Hight of Obs.
# R : Road
Onum, Rnum = map(int, input().split())
H = list(map(int, input().split()))
R = []
good = Onum      # count of good obs.
bad = [0] * Onum    # check list of not good obs.


def mark(idx):
    global good
    if bad[idx] == 0:
        good -= 1
    bad[idx] += 1


for i in range(Rnum):
    R = list(map(int, input().split()))
    if H[R[0] - 1] == H[R[1] - 1]:
        mark(R[0] - 1)
        mark(R[1] - 1)
    elif H[R[0] - 1] > H[R[1] - 1]:
        mark(R[1] - 1)
    elif H[R[0] - 1] < H[R[1] - 1]:
        mark(R[0] - 1)

print(good)


Measured memory_bytes: 20100
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int K;
    string S;

    cin >> K; 

    cin >> S;

    string output;
    if( S.length() > K )
    {
        output = S.substr( 0, K ) + "...";
    } else {
        output = S;
    }

    cout << output << endl;

    return 0;
}

Measured memory_bytes: 3496
MAXN = 45
fibs = [-1] * MAXN


def fib(n):
    """Returns n-th fibonacci number

    >>> fib(3)
    3
    >>> fib(10)
    89
    >>> fib(20)
    10946
    """
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif fibs[n] == -1: 
        fibs[n] = fib(n-1) + fib(n-2)

    return fibs[n]


def run():
    n = int(input())
    print(fib(n))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5612
use std::io;
use std::str::FromStr;
use std::cmp::max;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}


fn main() {
    let (a, b, n) = input_tuple();
    let x: u64;
    if b-1 < n {
        x = b - 1;
    } else {
        x = n;
    }
    let num = a * (x % b) - (a * x) % b;
    println!("{}", num / b);
}


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

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

template <class T>
T gcd(T a, T b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b)
{
	return a / gcd(a, b) * b;
}
int main()
{
	int n, m, p[21];
	while (scanf("%d%d", &n, &m), n || m)
	{
		for (int i = 0; i < m; ++i)
			scanf("%d", p + i);
		p[m] = INT_MAX;
		sort(p, p+m+1);
		for (int i = 1; i < m; ++i)
			for (int j = 0; j < i; ++j)
				if (p[i] % p[j] == 0)
					p[i] = INT_MAX;
		sort(p, p+m+1);
		m = unique(p, p+m+1) - p - 1;

		int num = n;
		ll sum = (ll)n*(n+1)/2;
		for (int i = 1; i < 1 << m; ++i)
		{
			int bits = 0;
			for (int j = i; j; j >>= 1)
				bits += j & 1;

			ll _lcm = 1;
			for (int j = 0; j < m; ++j)
			{
				if (i >> j & 1)
				{
					_lcm = lcm(_lcm, (ll)p[j]);
					if (_lcm > n)
						break;
				}
			}
			ll t = n / _lcm;
			int s = bits & 1 ? -1 : 1;
			num += s * t;
			sum += s * _lcm * t*(t+1)/2;
		}

		printf("%.10f\n", num ? (double)sum / num : 0);
	}

	return 0;
}

Measured memory_bytes: 0
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();

    let mut a = vec![vec![0; n]; n];
    for i in 0..n {
        for j in i + 1..n {
            for k in 0..10 {
                let bi = (i >> k) & 1;
                let bj = (j >> k) & 1;
                if bi != bj {
                    a[i][j] = k + 1;
                    break;
                }
            }
        }
    }

    with_stdout_lock(|mut w| {
        for i in 0..n {
            for j in i + 1..n {
                write!(w, "{}{}", a[i][j], if j == n - 1 { '\n' } else { ' ' }).unwrap();
            }
        }
    });
}


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

int main(void){
	int K,T,a,ma;
	cin>>K>>T;
	rep(i,T){
		cin>>a;
		ma=max(ma,a);
	}
	cout<<max(2*ma-K-1,0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
const ll mod=1000000007;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yes(T b){if(b)out("yes");else out("no");}
template<class T> void Yes(T b){if(b)out("Yes");else out("No");}
template<class T> void YES(T b){if(b)out("YES");else out("NO");}
template<class T> void no(T b){if(b)out("no");else out("yes");}
template<class T> void No(T b){if(b)out("No");else out("Yes");}
template<class T> void NO(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
 


int main(){
    vector<ll>v;
    ll n,k;
    cin>>n>>k;
    rep(i,n){
        ll a;
        cin>>a;
        v.pb(a);
    }
    sort(ALL(v));
    ll ans=0;
    rep(i,k){
        ans+=v[i];
    }

    out(ans);
    
}


Measured memory_bytes: 3616