akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////

string s,t;
pii p[3001][3001];
int dp[3001][3001];
bool v[3001][3001];
int s1(int i, int j)
{
    if(i==s.size() or j==t.size())
        return 0;
    if(v[i][j])
        return dp[i][j];
    v[i][j] = 1;
    if(s[i]==t[j])
    {
        dp[i][j] = 1+s1(i+1,j+1);
        p[i][j] = {i+1,j+1};
    }
    else
    {
        dp[i][j] = max(s1(i+1,j),s1(i,j+1));
        if(s1(i+1,j)>s1(i,j+1))
            p[i][j] = {i+1,j};
        else
            p[i][j] = {i,j+1};
    }

    return dp[i][j];
}

void solve()
{
    cin >> s >> t;
    s1(0,0);
    int l = 0;
    int r = 0;
    while(l!=s.size() and r!=t.size())
    {
        if(s[l]==t[r])
            cout << s[l];
        int l1 = p[l][r].fr;
        int r1 = p[l][r].sc;
        l = l1;
        r = r1;
    }
}
 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 220416
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;

int N, M;
vector<pair<int, int>> a;
vector<int> b;
int main() {
    cin >> N >> M;
    a = vector<pair<int, int>> (M);
    rep(i, M) cin >> a[i].first >> a[i].second;
    // 終点で小さい順ソート
    sort(all(a), [](auto x, auto y) -> bool { return x.second < y.second; });
    //まず一番小さい終点の橋を壊す
    b.push_back(a[0].second-1);
    rep10(i, M) {
        bool ok = false;
        //i番目の要望が達成できているかチェック
        rep(j, (int)b.size()) {
            if (b[j] >= a[i].first && b[j] < a[i].second) ok = true;
        }
        //達成できていない場合、終点の橋を壊す
        if (!ok) b.push_back(a[i].second-1);
    }
    cout << b.size() << endl;
    return 0;
}

Measured memory_bytes: 4004
#include <cstdio>

using namespace std;

long long K;
int main() {
  scanf("%lld", &K);

  printf("%d\n",50);
  for(int i=0;i<50;++i)
    if(i<K%50)
      printf("%lld ",49 + K/50 + 51 - K%50);
    else
      printf("%lld ",49 + K/50 - K%50);
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <queue>
#define ll long long
using namespace std;

int main(){
    ll N;
    cin>>N;
    map<string,ll> m;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 3660
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

char a[59];

map<pair<int,int>,int> mp;
int vis[159];
int main()
{
    fast;
    ll n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3652
sx,sy,tx,ty = map(int, input().split())

ans = ""
# 1周目
ans += (ty-sy)*"U" + (tx-sx)*"R" + (ty-sy)*"D" + (tx-sx)*"L"
# 2周目
ans += "L" + (ty-sy+1)*"U" + (tx-sx+1)*"R" + "DR" + (ty-sy+1)*"D" + (tx-sx+1)*"L" + "U"
print(ans)

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

int main (){
	string a, b, c ,j ,k;
	cin >> a >> b >> c;
	int d ,e ,f ,g = -1, h = 0, i = 0 ,x = 0;
	d = a.size();
	e = b.size();
	f = c.size();
	j = "d";
	while (1 > x){
		if (j == "a" || j == "d") {
			if (g == d ) {
				k = "A";
				x = 1;
			}
			g = g + 1;
			if (g >= 1 ) j = a[g - 1];
			else j = "a";
		}
		else if (j == "b") {
			if (h == e ) {
				k = "B";
				x = 1;
			}
			h = h + 1;
			j = b[h - 1];
		}
		else if (j == "c") {
			if (i == f ) {
				k = "C";
				x = 1;
			}
			i = i + 1;
			j = c[i - 1];
		}
	}
	cout << k << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
a = [int(x) for x in input().split()]

i = 1
ans = 0
for x in a:
    if x == i:
        i += 1
    else:
        ans += 1

if ans == N:
    print(-1)
else:
    print(ans)

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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t;
    return 0;
}


Measured memory_bytes: 3648
S = int(input())

x2 = 1
y2 = 10**9

quotient = S//(10**9)
mod = S%(10**9)

if mod != 0:
    x3 = quotient+1
    y3 = -(mod-10**9)
else:
    x3 = quotient
    y3 = mod
    
print(" ".join(map(str,[0,0,x2,y2,x3,y3])))

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll D, N;
    cin >> D >> N;
    ll ans = N;
    if(N == 100) ans++;
    rep(i, D) ans *= 100;
    cout << ans << endl;
    return 0;
}


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

int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;

    if(s==u)
    {
        cout<<a-1<<" "<<b;
    }
    else if(t==u)
    {
         cout<<a<<" "<<b-1;
    }
    return 0;

}


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

int a[1000005];

int main() {
  int n, l; cin >> n >> l;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  multiset<int> m;
  for (int i = 1; i <= l; i++)
    m.insert(a[i]);
  for (int i = l + 1; i <= n; i++) {
    cout << *m.begin() << " ";
    m.erase(m.find(a[i - l]));
    m.insert(a[i]);
  }
  cout << *m.begin() << endl;
}



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

#define int long long


#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define all(v) v.begin(),v.end()
using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

using D=double;
 D eps=1e-10;

D inf=1e20;
struct CHT{
  deque<pint>v;
  void add(int a,int b){
    pint t(a,b);
    while(v.size()>1&&check(v[v.size()-2],v[v.size()-1],t))v.pop_back();
    v.pb(t);
  }

  D query(D x){
    if(v.size()==0)return inf;
    int l=-1,r=v.size()-1;
    while(l+1<r){
      int mid=(l+r)/2;
      if(f(v[mid],x)+eps>=f(v[mid+1],x))l=mid;
      else r=mid;
    }
    return f(v[r],x);
  }

  bool check(const pint p1,const pint p2,const pint p3){
    return (p2.first-p1.first)*(p3.second-p2.second)>=(p2.second-p1.second)*(p3.first-p2.first);
  }
  D f(pint a,D x){
    return a.first*x+a.second;
  }
};



int N;
int X[222222],V[222222];
signed main(){
  cout << fixed << setprecision(20);

  cin>>N;
  int xz,vz;
  cin>>xz>>vz;
  rep(i,N){
    cin>>X[i]>>V[i];X[i]-=xz;V[i]-=vz;
  }
   
  vpint lef,rig;
  rep(i,N){
    if(X[i]<0&&V[i]>0){
      lef.pb(pint(-V[i],-X[i]));
    }
    if(X[i]>0&&V[i]<0){
      rig.pb(pint(V[i],X[i]));
    }
  }

  sort(all(lef));sort(all(rig));
  reverse(all(lef));reverse(all(rig));
  CHT chtl,chtr;
  for(auto p:lef)chtl.add(p.first,p.second);
  for(auto p:rig)chtr.add(p.first,p.second);

  rep(i,N){
    int x=X[i];
    int v=V[i];

    D  ans=inf;
    
    
    if(x>0){
      if(v<0)ans=-1.0*x/v;
      D  lb=0,rb=3e9;
      rep(t,70){
          D mid=(lb+rb)/2;
          if(-chtl.query(mid)>=mid*v+x)rb=mid;
          else lb=mid; 
      }
      if(rb<=2e9+eps)ans=min(ans,rb);
    }
    else{
      if(v>0)ans=-1.0*x/v;
      D lb=0,rb=3e9;
      rep(t,70){
        D mid=(lb+rb)/2;
        if(chtr.query(mid)<=mid*v+x)rb=mid;
        else lb=mid;
      }
      if(rb<2e9+eps)ans=min(ans,rb);
    }


    if(ans>3e9)puts("-1");
    else cout << ans << endl;
  }
 }  



Measured memory_bytes: 12428
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define ll long long int

using namespace std;

int main(){
 ll ans = 1;
 int n; cin>>n;
 string s; cin>>s;
 int box[30] = {};
 for(int i=0;i<s.size();i++){
   int num = s[i] - 'a';
   box[num]++;
 }

 for(int i=0;i<29;i++){
   if(box[i] == 0) continue;
   ans *= (box[i] + 1);
   ans %= 1000000007;
 }
 cout<<ans-1<<endl;
  return 0;
}
 


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	string s;
	cin >> s;
	if (s == "SUN"){ cout << 7 << endl; }
	else if (s == "MON"){ cout << 6 << endl; }
	else if (s == "TUE"){ cout << 5 << endl; }
	else if (s == "WED"){ cout << 4 << endl; }
	else if (s == "THU"){ cout << 3 << endl; }
	else if (s == "FRI"){ cout << 2 << endl; }
	else{ cout << 1 << endl; }
}

Measured memory_bytes: 256
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
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)); }
int main()
{
    _fast_
    ll t = 1;
   // cin>>t;
    while(t--){
    string s;
    cin>>s;
    deque<char>ans;
    f(s.length())
    {
        ans.pb(s[i]);
    }
    ll query;
    cin>>query;
    ll tt,ff;
    char c;
    ll cnt = 0;
    while(query--)
    {
        cin>>tt;
        if(tt == 1)
        {
            cnt++;
        }
        else if(tt == 2)
        {
            cin>>ff>>c;
            if(ff == 1)
            {
                if(cnt%2)
                {
                    ans.push_back(c);
                }
                else
                {
                    ans.push_front(c);
                }
            }
            else
            {
                if(cnt%2)
                {
                    ans.push_front(c);
                }
                else
                {
                    ans.push_back(c);
                }
                
            }
            
        }
    }
    if(cnt%2)
    {
        ll siz = ans.size();
        f(siz)
        {
            cout<<ans.back();
            ans.pop_back();
        }
    }
    else
    {
        ll siz = ans.size();
        f(siz)
        {
            cout<<ans.front();
            ans.pop_front();
        }
    }
    
    }
    return 0;
}

Measured memory_bytes: 976
while True:
    sequence = []
    n = input()
    if n ==0:
        break
    for i in range(n):
        sequence.append(int(raw_input()))
    max_sum=-100000
    sum=0
    while len(sequence)!=0:
            sum+=sequence.pop(0)
            if max_sum<sum:
                max_sum=sum
            if sum<0:
                sum=0

    print max_sum

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,a,b,s=1e12+7,aa,bb; cin>>n;
	for(auto i=1;i<=sqrt(n);++i){
		if(n%i==0){
			a=i;
			b=n/i;
			if(a+b<s){
				s=a+b;
				aa=a;
				bb=b;
			}
		}
	}
	//cout<<a<<' '<<b<<'\n';
	cout<<abs(aa-1)+abs(bb-1)<<'\n';
	//cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

int main() {
	char a, b = 'a';
	int k=0;
	rep(i, 4) {
		cin >> a;
		if (a == b) {
			k++;
			break;
		}
		b = a;
	}
	if (k == 1) cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
int dx[] = {1, 0, -1, 0}; // {down , right , up , left}
int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
//int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; //Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int n;
vector<int> adj[100];
string col = "RGB";

char getCur(char frst , char sec){
  for (int i = 0; i < 3; ++i)
    if(frst != col[i] && sec != col[i])
      return col[i];
}

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  string s;
  cin >> n;
  cin >> s;
  int len = SZ(s);
  for (int i = 0; i < len; ++i)
    adj[s[i]].push_back(i);

  ll cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j){
      if(s[i] == s[j])
        continue;
      char curChar = getCur(s[i], s[j]);
      int sz = SZ(adj[curChar]);
      int idx = lower_bound(adj[curChar].begin(), adj[curChar].end(), j + (j - i)) - adj[curChar].begin();
      cnt += (sz - (lower_bound(adj[curChar].begin(), adj[curChar].end(), j + 1) - adj[curChar].begin()));
      if(idx < sz && adj[curChar][idx] == j + (j - i))
        cnt--;
    }
  }
  cout << cnt << "\n";

  return 0;
}


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

const int MAX = 510000;
const int MOD=1000000000+7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n,k,i;
  cin >> n >> k;
  COMinit();
  for(int i=1;i<=k;++i){
    cout << COM(k-1,i-1)*COM(n-k+1,i)%MOD << endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int i;
  vector<string> s(n);
  for(i = 0; i < n; i++){
    cin >> s.at(i);
  }
  
  int m;
  cin >> m;
  
  vector<string> t(m);
  for(i = 0; i < m; i++){
    cin >> t.at(i);
  }
  
  int j, ans = 0, point = 0;
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(s.at(i) == s.at(j)) point++;
    }
    for(j = 0; j < m; j++){
      if(s.at(i) == t.at(j)) point--;
    }
    ans = max(ans, point);
    point = 0;
  }
  
  cout << ans << endl;
}

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


void solve() {

  int arr[3];
  rep(i,3) {
    scanf("%d", &arr[i]);
  }
  sort(arr, arr+3);
  cout << arr[0]+arr[1] << "\n";
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (t, x) = sc.nextInts(2)
    println(1.0 * t / x)
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 31520
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    rep(i,3){
        string s;
        cin >> s;
        cout << s[i];
    }

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int l, r;
	cin >> l >> r;

	if (r - l + 1 >= 2019) {
		cout << 0 << endl;
	}
	else {
		long long minn = INF;
		for (long long i = l; i < r; ++i) {
			for (long long j = i + 1; j <= r; ++j) {
				if ( (i * j) % 2019 < minn) {
					minn = (i * j) % 2019;
				}
			}
		}

		cout << minn << endl;
	}



	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1.0);
const db ERR = 1e-8;
const int MAXN = 1e7;

int main(int argc, char const *argv[]){
    int n,d,x;
    int a[MAX_SIZE];
    scanf("%d",&n);
    scanf("%d%d",&d,&x);
    int ans=x;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        ans+=(d+a[i]-1)/a[i];
    }
    
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H,A,tmp;
	vector <int> points;
	cin>>H>>A;
	for(int i=1;i<=A;i++){
		cin>>tmp;
		points.push_back(tmp);
	}
	tmp=0;
	for(int i=0;i<points.size();i++)tmp+=points[i];
	if(tmp>=H)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

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

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

  vector<int> v;

  for (int i = 0;i<N;i++)
  {
    cin >> A;
    v.push_back(A);
  }

  int a = 0;
  int b;
  int num;

  for(int i=0;i<N;i++)
  {
    if (a != max(v[i],a))//更新されるとき
    {
      b = a;
      a = max(v[i],a);
      num = i;
    }
    else if(b < v[i])
    {
      b = v[i];
    }

  }


  for (int i=0;i<N;i++)
  {
    for (int j=0;i<N;i++)
    {
      if(i!=num)
      {
        cout << a << endl;
      }
      else
      {
        cout << b << endl;
      }

    }
  }

  return 0;
}


Measured memory_bytes: 2548
n,m = map(int,input().split())
H = list(map(int,input().split()))
AB = []
ans = 0

for i in range(m):
    a,b = map(int,input().split())
    ai = a-1
    bi = b-1
    AB.append([ai,bi])
    AB.append([bi,ai])

AB = sorted(AB)
    
import collections
que = collections.deque()

for i in AB:
    que.append(i)

for i in range(n):
    compare = []
    
    while que:
        if que[0][0] == i:
            ab = que.popleft()
        else:
            break
            
        if ab[0] == i:
            compare.append(H[ab[1]])
    
    c = len(compare)
    
    if c > 0 and H[i] > max(compare):
        ans += 1
    
    if c == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 115320
def solve(A,N,M):
    #正しく並べると
    #Nが奇数: N-1 N-3 .... 2 0 2 .... N-3 N-1
    #Nが偶数: N-1 N-3 ... 3 1 1 3 ... N-3 N-1
    #になるはず

    A.sort(reverse = True)

    if N % 2 != 0:
        if A[len(A)-1] == 0:
            A.pop()
        else:
            return 0

    ans = pow(2,len(A)//2,M)
    a = 1
    if N % 2 != 0:
        a += 1
    while len(A) > 0:
        if A[len(A)-1] == a and A[len(A)-2] == a:
            A.pop()
            A.pop()
            a += 2
        else:
            return 0
    return ans

def main():
    N = int(input())
    A = list(map(int,input().split()))
    M = 10**9 + 7

    print(solve(A,N,M))

if __name__ == "__main__":
    main()


Measured memory_bytes: 20560
#include <bits/stdc++.h>
#define gcj "Case #"
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

int n, k, a[110], ans[110000];

int solve(int mode, int lef) {
	if (ans[lef] != -1)
		return ans[lef];

	if (lef == 0)
		return 0;

	ans[lef] = 0;

	for (int i = 1; i <= n; i++) {
		if (lef >= a[i]) {
			ans[lef] += (1 ^ solve(mode^1, lef - a[i]));
		} else {
			break;
		}
	}

	ans[lef] = (ans[lef] > 0);

	return ans[lef];
}

int main() {
	fastio;
	memset(ans, -1, sizeof(ans));
	cin>>n>>k;

	for (int i = 1; i <= n; i++)
		cin>>a[i];

	int fin_ans = solve(1, k);

	cout<<(fin_ans ? "First\n" : "Second\n");

	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  cin.ignore();
  rep(i,n){
    string s;
    getline(cin,s);
    string ans="";
    rep(j,s.size()){
      if(j+6<s.size() && s.substr(j,7)=="Hoshino")
        ans+="Hoshina",j+=6;
      else
        ans+=s[j];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2988
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace
{
	struct Combination
	{
		Combination(int n, ll mod)
		{
			v.resize(n+1, std::vector<ll>(n + 1, 0));
			for (size_t i = 0; i < n + 1; ++i) {
				v[i][0] = 1;
				v[i][i] = 1;
			}
			for (size_t j = 1; j < n + 1; ++j) {
				auto p = v[j - 1].cbegin();
				auto dst = v[j].begin();
				for (size_t k = 1; k < (j >> 1) + 1; ++k) {
					*(++dst) = (*p + *(++p));
					if (*dst > mod)
						*dst %= mod;
					v[j][j - k] = v[j][k];
				}
			}
		}
		ll Get(int n, int r)
		{
			return v[n][r];
		}
		std::vector<std::vector<ll> > v;

	};
}
void ABC132D()
{
	int N, K;
	cin >> N >> K;
	ll MOD = 1000000007;
	Combination comb(N, MOD);
	for (int i = 1; i <= K; ++i)
	{
		ll alpha = comb.Get(N - K + 1, i);
		ll beta = comb.Get(K - 1, i - 1);
		cout << (alpha * beta) % MOD << endl;
	}
}
int main()
{
	ABC132D();
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n+1,vector<int>(n+1));
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= n; ++j) cin >> a[i][j];
  }
  ll N = (1<<n);
  vector<ll> match(N);
  match[0] = 1;
  for(int boy = 1; boy <= n; ++boy){
    for(int k = 1; k < N; ++k){
      if(__builtin_popcount(k) == boy){
        for(int girl = 0; girl < n; ++girl){
          if(a[boy][girl+1] and (k&(1<<girl))){
            match[k] = (match[k]+match[k-(1<<girl)])%mod;
          }
        }
      }
    }
  }
  cout << match[N-1];
  return 0;
}

Measured memory_bytes: 19552
n, k = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)
(k...n).each do |i|
  prv = 1r
  nxt = prv / a[i-k].to_r * a[i].to_r
  puts (prv < nxt) ? "Yes" : "No"
end


Measured memory_bytes: 33772
import java.util.*;

public class Main {
    static int N;
    static int M;
    static int K;
    static String S;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        S = sc.next();
        int a = 0;
        int b = 0;
        int c = 0;
        for (int i = 0; i < S.length(); i++) {
            switch(S.charAt(i)) {
                case 'a':
                    a++;
                    break;
                case 'b':
                    b++;
                    break;
                case 'c':
                    c++;
                    break;
            }
        }
        int max = -1;
        int min = 10000000;
        max = Math.max(a, max);
        max = Math.max(b, max);
        max = Math.max(c, max);
        min = Math.min(a, min);
        min = Math.min(b, min);
        min = Math.min(c, min);
        if (max - min <= 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S == "SUN") {
  cout << 7 << endl;
  }
  if (S == "MON") {
  cout << 6 << endl;
  }
  if (S == "TUE") {
  cout << 5 << endl;
  }
  if (S == "WED") {
  cout << 4 << endl;
  }
  if (S == "THU") {
  cout << 3 << endl;
  }
  if (S == "FRI") {
  cout << 2 << endl;
  }
  if (S == "SAT") {
  cout << 1 << endl;
  }
  }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    int sum = 0;
    int overseas = 0;
    rep(i, n) {
        if(s[i] == 'a') {
            if(sum < a + b) {
                print("Yes");
                sum++;
            } else {
                print("No");
            }
        } else if(s[i] == 'b') {
            if(sum < a + b && overseas < b) {
                print("Yes");
                sum++;
                overseas++;
            } else {
                print("No");
            }
        } else {
            print("No");
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(){
	
	int H,W,i,h;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=0;i<H;i++){
			for(h=0;h<W;h++)printf("#");
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 2044
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0:
                print("#", end = "")
            elif i != 0 and i != H - 1:
                if j == 0:
                    print("#", end = "")
                elif j != 0 and j != W - 1:
                    print(".", end = "")
                else:
                    print("#", end = "")
            else:
                print("#", end = "")
        print("")
    print()


Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a (N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0 && a[i] % 2 != 0){
      ans++;
    }else{
      continue;
    }
  }
  cout << ans << endl;
}

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

int main() {
  string o, e;
  cin >> o >> e;
  
  int i;
  for(i = 0; i < min(o.size(), e.size()); i++){
    cout << o.at(i) << e.at(i);
  }
  
  if(o.size() > e.size()) cout << o.at(o.size() - 1);
  
  cout << endl;
}

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

int main(){
  int N,A[200],i,j,ans;
  bool chk=0;
  cin>>N;
  for(i=0;i<N;i++){
    cin>>A[i];
  }
  
  for(i=0;i<10;){
    for(j=0;j<N;j++){
      if(A[j]%2!=0){
        chk=1;
        break;
      }
      A[j]=A[j]/2;
    }
    if(chk==1)break;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
use strict;

my @args = split(' ',<>);
my $sx = @args[0];
my $sy = @args[1];
my $ex = @args[2];
my $ey = @args[3];

my $xdist = $ex - $sx;
my $ydist = $ey - $sy;

# print($xdist);
# print($ydist);

for (my $i=0; $i<$xdist; $i++) {
  print("R")
}
for (my $i=0; $i<$ydist; $i++) {
  print("U")
}
for (my $i=0; $i<$xdist; $i++) {
  print("L")
}
for (my $i=0; $i<$ydist; $i++) {
  print("D");
}

print("D");

for (my $i=0; $i<$xdist+1; $i++) {
  print("R")
}

for (my $i=0; $i<$ydist+1; $i++) {
  print("U")
}

print("L");
print("U");


for (my $i=0; $i<$xdist+1; $i++) {
  print("L")
}
for (my $i=0; $i<$ydist+1; $i++) {
  print("D")
}

print("R");




Measured memory_bytes: 4900
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
PX = [list(map(int,input().split())) for _ in [0]*Q]

E = [[] for _ in [0]*N]
for a,b in AB:
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

V = [0]*N
for p,x in PX:
    p-=1
    V[p] += x

q = [0]
done = [False]*N
while q:
    i = q.pop()
    done[i] = True
    for j in E[i]:
        if done[j] : continue
        V[j] += V[i]
        q.append(j)

print(*V)

Measured memory_bytes: 143480
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
	int k, x;
  	cin >> k >> x;
  	if (k*500 >= x)
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
    return 0;
}



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

#define int long long
double EPS = 1e-9;

int p, q, a, N;
int dfs(int n, int pre, int pro, double sum) {
  if ( fabs(sum-(double)p/q) < EPS ) return 1;
  if ( n == N ) return 0;
  if ( sum > (double)p/q ) return 0;  

  int ret = 0;
  for ( int i = pre; i <= 12000; i++ ) {
    if ( pro*i > a ) return ret;
    ret += dfs(n+1, i, pro*i, sum+(double)1/i);   
  }

  return ret;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  while ( cin >> p >> q >> a >> N, p ) {
    cout << dfs(0, 1, 1, 0) << endl;
  }  
  
  return 0;
}



Measured memory_bytes: 3156
import sys

lines = [line for line in sys.stdin]

n,m = map(int,lines[0].split())

A=[map(int,lines[1+r].split()) for r in range(n)]
b=[int(lines[1+n+r]) for r in range(m)]

ab = []
for r in A:
    ab.append(0)
    for (a,c) in zip(r,b):
        ab[-1] += a*c

for i in ab:
    print (i)

Measured memory_bytes: 6596
import java.util.*;

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

        List<Integer> l1 = Arrays.asList(1, 3, 5, 7, 8, 10, 12);
        List<Integer> l2 = Arrays.asList(4, 6, 9, 11);
        List<Integer> l3 = Arrays.asList(2);

        if (l1.contains(x) && l1.contains(y)
                || l2.contains(x) && l2.contains(y)
                || l3.contains(x) && l3.contains(y)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 20948
n = int(input())
if 2 <= n <= 3:
    print(2)
elif n == 1:
    print(1)
elif 4 <= n <= 7:
    print(4)
elif 8 <= n <= 15:
    print(8)
elif 16 <= n <= 31:
    print(16)
elif 32 <= n <= 63:
    print(32)
else:
    print(64)

Measured memory_bytes: 3060
from collections import deque
def dfs(G,v,h,w):
    stack = deque([v])
    connected = set([v])
    while stack:
        u = stack.popleft()
        x,y = u
        dx = [-1,0,1]
        dy = [-1,0,1]
        for i in range(3):
            for j in range(3):
                s = x + dx[i]
                t = y + dy[j]
                if 0 <= s < h and 0 <= t < w:
                    if G[s][t] == 1:
                        if (s,t) not in connected:
                            stack.appendleft((s,t))
                            connected.add((s,t))
    return connected

def solve(C,h,w):
    node = set()
    ans = 0
    for i in range(h):
      for j in range(w):
        if C[i][j] == 1 and (i,j) not in node:
          node = node|dfs(C,(i,j),h,w)
          ans += 1
    print(ans)

def main():
    h = 0
    w = 0
    while h >= 0 and w >= 0:
        w,h = map(int,input().split(" "))
        if h == w == 0:
            return
        C = [list(map(int,input().split(" "))) for _ in range(h)]
        solve(C,h,w)
  

if __name__ == "__main__":
    main()


Measured memory_bytes: 6436
// WeirdBugsButOkay

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define _dbg(x) cout << #x << " is " << (x) << endl;
#define dbg(v, x) cout << #v << ": "; for(int i = 0; i < (x); i++)  cout << (v)[i] << " "; cout << endl;

using namespace std;

void solve()
{
    ll a, b, k;
    cin >> k;
    cin >> a >> b;
    for(ll i = a; i <= b; i++)
    {
        if(i % k == 0)
        {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1;
    //cin >> q;
    for(int i = 0; i < q; i++)
    {
        solve();
    }
    return 0;
}


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



int main()
{
  const int N=2e5+20;

int n,a[N];
long long ans;
map <int,int> m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans+=m[a[i]-i];
		m[-a[i]-i]++;
	}

	cout<<ans;
}


Measured memory_bytes: 21472
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	ll N; cin >> N;
	vector<tuple<int, string, int>> a(N);
	rep(i, N) {
		get<0>(a[i]) = i + 1;
		string s; ll p;
		cin >> s >> p;
		get<1>(a[i]) = s, get<2>(a[i]) = p;
	}

	sort(all(a), [](tuple<int, string, int> x, tuple<int, string, int> y) {
		if (get<1>(x) != get<1>(y)) return get<1>(x) < get<1>(y);
		else return get<2>(x) > get<2>(y);
	});
	rep(i, N) {
		cout << get<0>(a[i]) << endl;
	}

}

Measured memory_bytes: 256
N,M = map(int,input().split())
SC = [tuple(map(int,input().split())) for i in range(M)]

for n in range(1000):
    if len(str(n)) != N: continue
    for s,c in SC:
        if str(n)[s-1] != str(c):
            break
    else:
        print(n)
        exit()
print(-1)

Measured memory_bytes: 9184
from collections import deque
S=list(input())
Q=int(input())
query=[]
reverseflg=False
S=deque(S)

for i in range(Q):
  query.append(list(input().split()))

for q in range(Q):
  if query[q][0]=="1":
    reverseflg= not reverseflg
  
  if query[q][0]=="2":
    if query[q][1]=="1":
      if reverseflg== False:
        S.appendleft(query[q][2])
      else:
        S.append(query[q][2])
    
    else:
      if reverseflg== False:
        S.append(query[q][2])
      else:
        S.appendleft(query[q][2])

if reverseflg==True:
  S.reverse()
  
print(''.join(S))


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

using namespace std;

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

int main(){
  string s;
  while(cin >> s, s != "0"){
    int dp[80010][11],len = s.size(),res = 0;
    memset(dp,0,sizeof(dp));
    dp[0][c(s[0])] = 1;
    for(int i = 1 ; i < len ; i++){
      if(c(s[i]) > 0){ dp[i][c(s[i])]++; }
      for(int j = 0 ; j < 11 ; j++){
        dp[i][(10*j+c(s[i]))%11] += dp[i-1][j];
      }
      res += dp[i][0];
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 4760
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 = 1000000007;
int rui(int a, int b) {
    if(b == 0) {
        return 1;
    }
    return rui(a, b - 1) * a;
}
int main() {
    set<string> all;
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, 0, N) {
        cin >> s[i];
        all.insert(s[i]);
    }
    int M;
    cin >> M;
    vector<string> t(M);
    rep(i, 0, M) {
        cin >> t[i];
        all.insert(t[i]);
    }
    int max = -1000000000;
    for(auto st : all) {
        int tmp = 0;
        rep(i, 0, N) {
            if(st == s[i]) {
                tmp++;
            }
        }
        rep(i, 0, M) {
            if(st == t[i]) {
                tmp--;
            }
        }
        chmax(max, tmp);
    }
    if(max < 0) {
        cout << 0 << endl;
    } else {
        cout << max << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define mian main
using namespace std;
char a[100000007];


int mian(){
	scanf("%s",a + 1);
	int len = strlen(a + 1);
	int flag = 0;
	for(int i = 1;i <= len;i++){
		if(a[i] == 'C'){
			flag = 1;
			continue;
		}
		if(a[i] == 'F' && flag == 1){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128