akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string S = readString();
  for (int i = 0; i < 1 << 3; i++) {
    int sum = S[0] - '0';
    REP(j, 3) {
      if ((i >> j) & 1)
        sum += S[j + 1] - '0';
      else
        sum -= S[j + 1] - '0';
    }
    if (sum == 7) {
      string s;
      s = S[0];
      REP(j, 3) {
        if ((i >> j) & 1)
          s += '+';
        else
          s += '-';
        s += S[j + 1];
      }
      std::cout << s << "=7" << std::endl;
      return 0;
    }
  }
}


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

int main() {
    long N;
    cin>>N;
    long ans = 0;
    long m = 1;
    while(true){
        if(N/m <= m) break;
        else {
            if(N%m==0){
                if(N%(N/m-1)==0){
                    m++;
                    continue;
                }
                ans += N/m-1;
            }
        }
        m++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>a[i];
  }
  long long ans=0;
  for(int i=0;i<=N-1;i++){
  
    ans+=a[i]-1;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int x, y, s;
	
	while (cin >> x >> y >> s, x || y || s)
	{
		int price1, price2, ans = 0;
		for (int i=1; i<=999; i++)
		{
			for (int j=1; j<=999; j++)
			{
				price1 = i*(100+x)/100 + j*(100+x)/100;
				price2 = i*(100+y)/100 + j*(100+y)/100;
				if (price1 == s)
				{
					ans = max(ans, price2);
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

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

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N; cin >> N;
  rep(i, 9) {
    if (N <= 111 * (i + 1)) {
      cout << 111 * (i + 1) << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <string>
using namespace std;
int a[100010];
char s[100010];
int n, dir[4][2] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}};
int main ()
{
    scanf("%d", &n);
    scanf("%s", s);
    int f = 0;
    for(int i = 0; i < 4; i++)
    {
        a[0] = dir[i][0];
        a[1] = dir[i][1];
        for(int j = 1; j <= n; j++)
        {
            if(!a[j])
            {
                if(s[j%n] == 'o')
                    a[j+1] = a[j-1];
                else
                    a[j+1] = 1^a[j-1];
            }
            if(a[j])
            {
                if(s[j%n] == 'o')
                    a[j+1] = a[j-1]^1;
                else
                    a[j+1] = a[j-1];
            }
        }
        if(a[n] == a[0] && a[n+1] == a[1])
        {
            f = 1;
            break;
        }
    }
    if(f)
    {
        for(int i = 0; i < n; i++)
            if(a[i]) printf("W");
            else  printf("S");
        printf("\n");
    }
    else printf("-1\n");
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<int, int>pint;




int main() {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;

	return 0;
}

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

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

    long long h, mons = 1, count = 1;
    cin >> h;
    while (mons * 2 <= h)
    {
        mons *= 2;
        count += mons;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
using namespace std;

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

	int toppa = 0;
	int brank = 1;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'c') { cout << "No" << endl; }
		
		if (s[i] == 'a' && toppa < a + b) { cout << "Yes" << endl; toppa++; }
		else if(s[i]=='a') { cout << "No" << endl; }

		if (s[i] == 'b' && toppa < a + b && brank <= b) { cout << "Yes" << endl; toppa++; brank++; }
		else if(s[i]=='b') { cout << "No" << endl; }
	} 

	return 0;
}



Measured memory_bytes: 896
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    S = get_input()
    Q = get_input(int)

    # NOTE: need to reverse
    heads = ""
    tails = ""
    direction = 1
    for _ in range(Q):
        query = get_input()
        if query[0] == "1":
            direction *= -1
        else:
            _, F, C = query.split(" ")
            if F == "1":
                if direction == 1:
                    heads += C
                else:
                    tails += C
            else:
                if direction == 1:
                    tails += C
                else:
                    heads += C
     
    if direction == 1:
        print(heads[::-1] + S + tails)
    else:
        print(tails[::-1] + S[::-1] + heads)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21436
import fractions
a = int(input())
num_list = list(map(int, input().split()))
head_gcd_list = [0]
tail_gcd_list = [0]
for i in range(a - 1):
    head_gcd_list.append(fractions.gcd(head_gcd_list[i], num_list[i]))
    tail_gcd_list.append(fractions.gcd(tail_gcd_list[i], num_list[(i*-1) - 1]))
max_gcd = 0
for i,j in zip(head_gcd_list, reversed(tail_gcd_list)):
    current_gcd = fractions.gcd(i, j)
    if(current_gcd > max_gcd):
        max_gcd = current_gcd
print(max_gcd)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, C;
    cin >> N >> C;
    vector<ll> s(N), t(N), c(N);
    ll tMax = 0;
    REP(i, N)
    {
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
        tMax = max(tMax, t[i]);
    }
    vector<double> sD[C], tD[C];
    priority_queue<double, vector<double>, greater<double>> sDQ[C], tDQ[C];
    REP(i, N)
    {
        sDQ[c[i]].push((double)s[i] - 0.5);
        tDQ[c[i]].push((double)t[i]);
    }
    REP(i, C)
    {
        while(!sDQ[i].empty() && !tDQ[i].empty())
        {
            sD[i].push_back(sDQ[i].top());
            sDQ[i].pop();
            tD[i].push_back(tDQ[i].top());
            tDQ[i].pop();
        }
    }

    map<double, ll> countRecord; 
    for (ll i = 1; i <= 2 * tMax; ++i)
    {
        double now = 0.5 * i;
        countRecord[now] = 0;
        REP(i, C)
        {
            if (sD[i].size() == 0)
            {
                continue;
            }

            auto it = lower_bound(ALL(sD[i]), now);
            if (it == sD[i].end())
            {
                if (now < tD[i][tD[i].size() - 1])
                {
                    countRecord[now]++;
                }
            }
            else
            {
                int index = distance(sD[i].begin(), it);
                if (now == sD[i][index]) 
                {
                    countRecord[now]++;
                }
                else
                {
                    if (index - 1 >= 0 && now < tD[i][index - 1]) 
                    {
                        countRecord[now]++;
                    }
                }
            }
        }
    }

    ll ans = 0;
    REPV(it, countRecord)
    {
        ans = max(ans, it->second);
    }

    cout << ans << endl;
}


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

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

    for (int i = 0; i < 50000; i++) {
        float x = (float)i * 1.08F;
        if ((int)x == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_template_matching(void) {
	int n, m;
	string a[50];
	string b[50];
	int match_cnt = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	int sub = n - m;

	for (int i = 0; i <= sub; i++) {
		for (int j = 0; j <= sub; j++) {
			match_cnt = 0;
			for (int k = 0; k < m; k++) {
				
				string a_pick = a[k + i].substr(j,m);
				string b_pick = b[k];
				//cout << i << "," << j <<","<<k<< endl;
				//cout << "a:" << a_pick << endl;
				//cout << "b:" << b_pick << endl;
				if (a_pick != b_pick)break;
				else {
				//	cout << "match!" << endl;
					match_cnt++;
				}
			}
			if (match_cnt == m) {
				cout << "Yes" << endl;
				exit(0);
			}
		}
	}
	cout << "No" << endl;
}

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  vector<ll> line(n);
  map<ll,ll> m;
  foreach(i,line){
    i = in();
    ++m[i];
  }
  ll ans = 0;
  foreach(i,m){
    ans += i.second * (i.second-1) / 2;
  }

  foreach(i,line){
    ans -= m[i] * (m[i]-1) / 2;
    ans += (m[i]-1) * (m[i]-2) / 2;
    cout << ans << endl;
    ans += m[i] * (m[i]-1) / 2;
    ans -= (m[i]-1) * (m[i]-2) / 2;
  }


  return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	char ans='A';
	char a,b,c;
	while(true){
		cin>>a>>b>>c;
		if (cin.eof())break;
		if(a==ans){
			ans=c;
			continue;
		}
		if(c==ans){
			ans=a;
			continue;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600
#define long unsigned long long

// sieve of Erastosthenes
bool arr[100001];
vector<long> pc;  //prime cubics
vector<long> primes;
void prime_list(int sz){
  fill(arr, arr+sz+1, true);
  arr[0]=arr[1]=false;
  for(int i=4;i<=sz;i+=2) arr[i]=false;
  primes.pb(2); pc.pb(8);
  for(long i=3; i<=sz/2; i+=2){
    if(arr[i]){
      if(i*i*i<1e+10) pc.pb(i*i*i);
      primes.pb(i);
      for(long j=i*i; j<=sz; j+=i) arr[j]=false;
    }
  }
}

int main(){
  prime_list(100000);
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n){
    scanf("%ld", &(vec[i]));
    for(long c : pc){
      while(vec[i]%c==0) vec[i]/=c;
    }
  }

  sort(all(vec));
  int res=0;
  map<long, int> mp; // 数と個数
  map<long, long> ref; // 掛けると立方数になるペアの対応表
  rep(i, vec.size()){
    long d=vec[i];
    if(d==1){
      res=1;
      continue;
    }
    if(ref.find(d)!=ref.end()){
      mp[d]++;
      continue;
    }

    long inv=1; // かけたら立方数になる相手

    for(long p : primes){ //素因数分解
      int cnt=0;
      while(d%p==0){
        d/=p;
        cnt++;
      }
      if(cnt==1) inv *= p*p;
      if(cnt==2) inv *= p;
      if(d==1) break;
      if(p>2500) break;
    }

    // N^(1/3) までの素因数を取り出したので，残る因数はそれ以上
    if(d!=1){
      long r = sqrt(d)+0.0001;
      if(d == r*r){
        inv *= r;
      } else {
        inv *= d*d;
      }
    }
    
    mp[vec[i]]++;
    ref[vec[i]]=inv;
    ref[inv]=vec[i];
  }

  for(auto m : mp) if(m.se != 0){
    auto f = mp.find(ref[m.fi]);
    if(f!=mp.end()){
      res += max(m.se, f->se);
      f->se = 0;
    } else {
      res += m.se;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 19968
import java.util.Scanner;

public class Main
{

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int N = scan.nextInt();
        int k = 0;
        int n = 0;
        for (int i = 0; i < N; i++) {
            int f = scan.nextInt();
            int s = scan.nextInt();

            if (a >= s || b <= f) {
                n++;
            } else {
                k++;
            }

        }
        if (k > 0) {
            System.out.println("1");
        } else {
            System.out.println("0");
        }
    }

}



Measured memory_bytes: 26452
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factrial(int n){
  if(n == 0) return 1;
  return n*factrial(n-1);
}

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }




int main(){
  int N,i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <utility>

using namespace std;
typedef pair<int,string> strpair;

int main(){
  vector<strpair> data;
  string str;
  getline(cin,str);
  istringstream iss(str);
  string word;
  while(iss>>word){
    auto it= find_if(data.begin(),data.end(),[word](pair<int,string> p){return p.second==word;});
    if(it==data.end()){
      data.push_back(pair<int,string>(1,word));
    }else{
      (*it).first++;
    }
  }

  sort(data.begin(),data.end(),greater<pair<int,string> >());
  int maxlength=0;
  string maxlengthword;
  for(auto word:data){
    int length=word.second.length();
    if(length>maxlength){
      maxlength=length;
      maxlengthword=word.second;
    }
  }
  cout<<data[0].second<<" "<<maxlengthword<<endl;

}

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

int main() {
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i = 0; i < N; i++) cin >> T.at(i);
  sort(T.begin(), T.end());
  
  int ans = 0;
  int i = 0;
  
  while(i < N){
    ans++;
    int next = C;
    for (int j = 0; j < C; j++){
      if (i + j == N){
        next = j;
        break;
      }
      else if (T.at(i + j) > T.at(i) + K){
        next = j;
        break;
      }
    }
    i += next;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a<=0&&b>=0)cout <<"Zero" <<endl;
	else if(a>0){
		cout << "Positive" <<endl;
	}else if((b-a)%2){
		cout << "Positive" <<endl;
	}else{
		cout << "Negative" <<endl;
	}
	return 0;
}

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

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans=0;
    ll kaku=0;
    if(n%2==0){
        rep(i,(n-2)/2){
            ans+=a[i+1];
        }
        ans*=2;
        ans+=a[0];
    }else{
        rep(i,(n-3)/2){
            ans+=a[i+1];
        }
        ans*=2;
        ans+=a[0];
        ans+=a[(n-1)/2];
    }
    cout << ans << endl;

}

Measured memory_bytes: 4840
#include<stdio.h>

//main
int main(){
  int i,j,n,c,t,s,e=0;
  int r[10][10]; //set

  //loop
  while(1){
    scanf("%d",&n); //input
    if(n==0){  //error
      break;
    }
    e++;

    //init
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	r[i][j]=0;
      }
    }
    c=1;

    //main algorhythm start
    i=-1;
    j=0;
    
    if(n==1){
      printf("Case %d:\n",e);
      printf("%3d\n",1);
    }
    else{  //n>=2
      while(1){  //left up loop
	if(i==n-1){
	  //	  printf("part1\n");
	  break;
	}
	i++;
	r[i][j]=c++;
	//	printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	
	s=i;
	for(t=0;t<s;t++){
	  j++;
	  i--;
	  r[i][j]=c++;
	  //	  printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	}
	if(j==n-1){
	  //	  printf("part2\n");
	  break;
	}
	j++;
	r[i][j]=c++;
	//	printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	s=j;
	for(t=0;t<s;t++){
	  j--;
	  i++;
	  r[i][j]=c++;
	  //	  printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	}
      }
      
      //      printf("left up loop broke i=%d j=%d c=%d\n",i,j,c);
      
      if(i==0){  //right down prepare
	i++;
	r[i][j]=c++;
	//	printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	s=n-i-1;
	for(t=0;t<s;t++){
	  i++;
	  j--;
	  r[i][j]=c++;
	  //	  printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	}
      }
      while(1){  //right down loop
	
	j++;
	r[i][j]=c++;
	//	printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	if(c-1==n*n){
	  //	  printf("part3\n");
	  break;
	}
	
	
	s=n-j-1;
	for(t=0;t<s;t++){
	  i--;
	  j++;
	  r[i][j]=c++;
	  //	  printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	}
	
	i++;
	r[i][j]=c++;
	//	printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	if(c-1==n*n){
	  //	  printf("part4\n");
	  break;
	}
	s=n-i-1;
	for(t=0;t<s;t++){
	  i++;
	  j--;
	  r[i][j]=c++;
	  //	  printf("set:[%d][%d]=%d\n",i,j,c-1); //check
	}
      }
      
      //main alogorhythm end
      
      
      //output
      printf("Case %d:\n",e);
      for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	  printf("%3d",r[i][j]);
	}
	printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
n=int(input())
s=input()
count=0
for i in range(1000):
    if (i<10):
        num="00"+str(i)
    elif (i<100):
        num="0"+str(i)
    else:
        num=str(i)
    k=0
    flag=num[0]
    for j in range(len(s)):
        if (flag==s[j]):
            if (k<2):
                k=k+1
                flag=num[k]
            elif (k==2):
                count+=1
                #print(num)
                break
print(count)

Measured memory_bytes: 42720
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  string akiba = "AKIHABARA";
  for(int i = (1 << 9)-1; i >= 0; --i){
    bool ok = true;
    string t;
    for(int j = 0; j < 9; ++j){
      if((1<<j)&i){
        t += akiba[j];
      }else{
        ok &= akiba[j] == 'A';
      }
    }
    if(ok && t == s){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3572
try:
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    for i in range(N):
        H[i] = abs(A-(T-H[i]*0.006))
    print(H.index(min(H))+1)
except EOFError:
    pass

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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 ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    ll l = 0, r = 1000000000;
    while(r - l > 1) {
        ll mid = (l + r) / 2;
        ll cnt = 0;
        rep(i, n) cnt += ll(ceil(double(a[i]) / double(mid))) - 1;
        if(cnt <= k) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 4848
import sys
n = int(input())
B = list(map(int,input().split()))
ans = []
for i in range(n,0,-1):
    for j in range(i,0,-1):
        if B[j-1] == j:
            del B[j-1]
            ans.append(j)
            break
    else:
        print(-1)
        sys.exit()
for i in ans[::-1]:
    print(i)    

Measured memory_bytes: 3064
/* ex 7_3
   unomi */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int row=0,column=0,i=0,j=0;
    int flag_row[1000],flag_column[1000];
    char grid[1000][1000], **ptr;

    // 行数と列数 の入力を取得
    scanf("%d %d", &row, &column);



    // サイズrowのchar*型ポインタ配列を動的確保
    // 各行の配列へのポインタ分のメモリ領域を確保
    ptr = (char**)calloc(row,sizeof(char*));
    // エラー処理
    if(ptr == NULL){
        exit(1);
    }
    //各行の要素分のメモリ領域を確保
    for(i=0; i<row; i++){
        ptr[i] = (char*)calloc(column, sizeof(char));
        if(ptr[i] == NULL){
            exit(1);
        }
    }



    // grid[row][column] で入力を取得
    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            scanf(" %c", &grid[i][j]);
        }
    }
 
    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            // 黒のマスがあった場合
            if(grid[i][j]=='#'){
                // そのマスがある行と列に対してフラグを建てる
                flag_row[i] = 1;
                flag_column[j] = 1;
            }
        }
    }
 
    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            // 対象のマスの行か列に黒のマスがあるなら、表示
            if(flag_row[i]==1 && flag_column[j]==1) printf("%c",grid[i][j]);
        }
        // 現在の行に黒のマスがあるなら、改行
        if(flag_row[i]==1) printf("\n");
    }

    // 各行の要素分のメモリ領域を解放 -> 各行の配列へのポインタの領域を解放
    for(i=0; i<row; i++){
        free(ptr[i]);
    }
    free(ptr);

    return 0;
}

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

int main(){
  int n,m,a[200010]={},b[200010]={};
  cin>>n>>m;
  int p=0,q=0;
  for(int i=0;i<m;++i){
    int x,y;
    cin>>x>>y;
    if(x==1){
      a[p]=y;
      p++;
    }
    if(y==n){
      b[q]=x;
      q++;
    }
  }
  sort(a,a+p);
  sort(b,b+q);
  int i=0,j=0;
  while(i<p&&j<q){
    if(a[i]==b[j]){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    if(a[i]<b[j]){
        i++;
    }else j++;
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1792
# 2020/03/14
# AtCoder Beginner Contest 086 - C

# Input
n = int(input())
nx = 0
ny = 0
nt = 0

# Check
ans = "Yes"
for i in range(n):
    t, x, y = map(int,input().split())
    dist = abs(nx - x) + abs(ny - y)
    et = t - nt
    if dist > et or (dist <= et and (dist - et) % 2 != 0):
        ans = "No"
        break
    nx = x
    ny = y
    nt = t

# Output
print(ans)


Measured memory_bytes: 3060
# encoding:utf-8
 
def main():
	h, w = list(map(int, input().split()))
	n = int(input())
	nums = list(map(int, input().split()))
	calc(h, w, n, nums)

def calc(h, w, n, nums):
	out_raw = []
	for i, num in enumerate(nums):
		out_raw.extend([str(i + 1) for _ in range(num)])

	for i in range(h):
		tmp = out_raw[i * w:(i + 1) * w]
		if i % 2 == 0:
			print(" ".join(tmp))
		else:
			print(" ".join(tmp[::-1]))

if __name__ == '__main__':
	main()


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
const int MOD = 1e9+7;
using namespace std;
typedef long  ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  int x;cin>>x;
  if(x<1200){
    cout<<"ABC"<<endl;
  }else{
    cout<<"ARC"<<endl;
  }
}

Measured memory_bytes: 256
import math
from collections import Counter

def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
    
def ABC159D(a):
    if a<2:
        return 0
    else:
        return math.factorial(a)//math.factorial(a-2)//2

n=int(input())
a=list(map(int,input().split()))
d = dict()
#for i in a:
#    d=mycounter(d,i)
dd=Counter(a)
#print(d)
p=0
for i in dd.values():p+=ABC159D(i)
print('\n'.join(map(str,[p-dd[i]+1 for i in a])))

Measured memory_bytes: 38040
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
    int n; cin >> n;
    vector<double> x(n), r(n);

    double lv = numeric_limits<double>::lowest(), rv = numeric_limits<double>::max();
    REP(i, n) {
        cin >> x[i] >> r[i];
        lv = max(lv, x[i] - r[i]);
        rv = min(rv, x[i] + r[i]);
    }

    auto f = [&](double k) {
        double ret = numeric_limits<double>::max();

        REP(i, n) {
            ret = min(ret, sqrt(pow(r[i], 2) - pow(x[i] - k, 2)));
        }

        return ret;
    };

    REP(_, 1000) {
        double t1 = (2 * lv + rv) / 3, t2 = (lv + 2 * rv) / 3;

        if (f(t1) >= f(t2)) {
            rv = t2; 
        } else {
            lv = t1;
        }
    }

    cout << fixed << setprecision(10) << f(rv) << endl;

    return 0;
}



Measured memory_bytes: 4388
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int N; cin >> N;
  vector <int> a(N);
  rep(i, N) cin >> a[i];
  vector <int> ans;
  int posi;
  rep(i, N){
    posi = -1;
    rep(j, a.size()){
      if (a[j] == j + 1) posi = j + 1;
    }
    if (posi > 0){
      ans.push_back(posi);
      a.erase(a.begin() + posi-1);
    }
    else{
      break;
    }
  }
  if (posi == -1){
    cout << posi;
  }
  else{
    rep(i, N){
      cout << ans[N-i-1] <<endl;
    }
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  =  vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    string s;
    cin >> s;

    string t = "PD";

    rep(i, s.size()){
        if(s[i] == 'P' && s[i+1] == '?'){
            s[i+1] = 'D';
        }
        else if(s[i] == '?' && s[i+1] == 'D'){
            s[i] = 'P';
        }
        else if(s[i] == '?' && s[i+1] == '?'){
            s[i] = 'P';
            s[i+1] = 'D';
        }
        else if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3708
A,B,C,D,E,F = map(int,input().split())

G = F//100
water = []
for W in range(A,G+1):
    for a in range(G//A+1):
        for b in range(G//B +1):
            if a*A+b*B == W:
                water.append(W)

noudo = 0
ans = (100*A,0)

for W in water:
    sugerlimit = min(W*E,F-100*W)
    for c in range(sugerlimit//C,-1,-1):
        for d in range(sugerlimit//D,-1,-1):
            if c*C+d*D > sugerlimit:
                pass
            else:
                noudo2 = 100*(c*C+d*D)/(100*W+c*C+d*D)
                if noudo2>noudo:
                    ans = (100*W+c*C+d*D,c*C+d*D)
                    noudo = noudo2
                break

print(' '.join(map(str,ans)))
                
                
                

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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
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
#define trace(...)
#endif

#define pb push_back
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using ll = long long int;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int, int>;
using pii = pair<int, int>;

const int inf = 1e9;
const ll infL = (ll) 1e18;
const int N = 100005;
const ll mod = (ll) 1e9 + 7;
const ll mod2 = 998244353LL;

int32_t main(){
	fio;
	
	string s;
	cin >> s;
	int n = (int) s.size();
	if(s[n - 1] == 's')
		s += "es";
	else
		s += "s";
		
	cout << s << '\n';
    return 0;
}

/*

 */


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        if(a[i] > a[i+1]) {
            ans += a[i] - a[i+1];
            a[i+1] = a[i];
        }
    }
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 4792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long k = sc.nextLong();
    k++;
    int[] kk = new int[40];
    long[] c = new long[40];
    for(int i = 0; i < 40; i++) {
      if(k % 2 == 1) kk[i] = 1;
      k /= 2;
    }
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      for(int j = 0; j < 40; j++) {
        if(a % 2 == 1) c[j]++;
        a /= 2;
      }      
    }
    long ans = 0;
    for(int i = 0; i < 40; i++) {
      long t = 0;
      if(kk[39 - i] == 1) {
        for(int j = 0; j < 40; j++) {
          if(j < i) {
            if(kk[39 - j] == 0) {
              t += ((long)Math.pow(2, 39 - j) * c[39 - j]);
            } else {
              t += ((long)Math.pow(2, 39 - j) * ((long)n - c[39 - j]));
            }
          } else if(j == i) {
            t += ((long)Math.pow(2, 39 - j) * c[39 - j]);
          } else {
            t += (long)Math.max((long)Math.pow(2, 39 - j) * c[39 - j], (long)Math.pow(2, 39 - j) * ((long)n - c[39 - j]));
          }
        }
      }
      ans = Math.max(ans, t);
    }
    System.out.println(ans);
  }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> t(n), d(n);
  for (int i = 0; i < n; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  
  priority_queue<pair<int, int>> newsushi, oldsushi;
  for (int i = 0; i < n; i++) {
    newsushi.emplace(d.at(i), t.at(i));
  }
  
  int64_t s = 0, kind = 0;
  vector<int> count(n + 1);
  for (int i = 0; i < k; i++) {
    auto x = newsushi.top();
    newsushi.pop();
    oldsushi.emplace(-x.first, x.second);
    s += x.first;
    if (count.at(x.second) == 0) kind++;
    count.at(x.second)++;
  }
  int64_t ans = s + kind * kind;
  for (int i = k; i < n; i++) {
    auto x = newsushi.top();
    newsushi.pop();
    if (count.at(x.second) != 0) continue;
    oldsushi.emplace(-x.first, x.second);
    count.at(x.second)++;
    kind++;
    s += x.first;
    while (!oldsushi.empty()) {
      auto y = oldsushi.top();
      oldsushi.pop();
      if (count.at(y.second) == 1) continue;
      count.at(y.second)--;
      s += y.first;
      ans = max(ans, s + kind * kind);
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3700
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
char ss[100004];
int len,numg,nump,ans;
int main()
{
	//freopen("AtCoDeer and Rock-Paper.in","r",stdin);
	scanf("%s",ss+1);
	len=strlen(ss+1);
	for(RG int i=1;i<=len;i++)
	 if(ss[i]=='g')
	 {
		if(nump<numg) nump++, ans++; 
		else numg++;
	 }
	 else {
		if(nump<numg) nump++;
		else numg++, ans--;
	 }
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> p;

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

    string s;
    cin >> s;

    int pa, pz;

    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'A') {
            pa = i;
            break;
        }
    }

    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'Z') pz = i;
    }

    cout << pz - pa + 1 << endl;
}

Measured memory_bytes: 720
s = input()
n = len(s)
res = 0
l = []
for i in range(1 << (n-1)):
    cnt = 1
    l = [0]
    for j in range(n-1):
        if (i >> j) & 1:
            l.append(j+1)
    l.append(n)
    for k in range(len(l) - 1):
        res += int(s[l[k]:l[k+1]])  # 何番目の数字までを一つにするかという事を示している

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
 
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
 
ll inv(ll n){
	if(n==1) return 1;
	return (MOD-MOD/n)*inv(MOD%n)%MOD;
}
 
ll c[maxn];
 
 
 
int main()
{
	//IOS;
	ll n,a,b,k;
	cin>>n>>a>>b>>k;
 
	c[0]=1;
	for(int i=1;i<=n;i++){
		c[i]=c[i-1]*inv(i)%MOD*(n-i+1)%MOD;
	}
	ll ans=0;
	REP(i,n+1){
		ll tmp=k-a*i;
		if(tmp%b)continue;
		ll meow=tmp/b;
 
		if(meow<0||meow>n) continue;
 
		ans+=c[i]*c[meow]%MOD;
		ans%=MOD;
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
const int MAXN = 1e5 + 10;
multiset<pair<ll, ll> > S;
vector<ll> A;
ll n, m, sum[MAXN];

int main() {
	cin >> n >> m;
	A.push_back(n);
	for (int i = 0; i < m; i++) {
		ll a;
		cin >> a;
		while (!A.empty() && A.back() >= a)
			A.pop_back();
		A.push_back(a);
	}
	S.insert({ A.back(), 1 });
	A.pop_back();
	while (!A.empty()) {
		ll alph = A.back();
		pair<ll, ll> C = { alph, 0 };
		while (S.lower_bound({ alph + 1, 0 }) != S.end()) {
			set<pair<ll, ll> >::iterator it = S.lower_bound({ alph + 1, 0 });
			pair<ll, ll> t = *it;
			S.erase(it);
			C.second += (t.first / alph) * t.second;
			pair<ll, ll> nw = { t.first % alph, t.second };
			if (nw.first != 0 && nw.second > 0)
				S.insert(nw);
		}
		if (C.second > 0)
			S.insert(C);
		A.pop_back();
	}
	for (pair<ll, ll> a : S)
		sum[a.first] += a.second;
	for (int i = MAXN - 2; i >= 0; i--)
		sum[i] += sum[i + 1];
	for (int i = 1; i <= n; i++)
		cout << sum[i] << '\n';
}

Measured memory_bytes: 9460
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE d(n); rep(i, n)cin >> d[i];
	sort(ALL(d));
	cout << d[n / 2] - d[n / 2 - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
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>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#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 pb push_back
#define print(x) cout<<x<<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)
const ll mod=1000000007;
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);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,A,B,C,ans=0;
  string s;
  cin>>s;
  rep(i,3)ans+=s[i]=='o';
  print(700+ans*100);
  return 0;
}


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

int main(){
        int h, w;
        while(1){
                cin >> h >> w;
                if(h == 0 && w == 0)break;

                for(int i = 0; i < h; i++){
                        for(int j = 0; j < w; j++){
                                if((i + j) % 2 == 0)cout << '#';
                                else cout << '.';
                        }
                        cout << endl;
                }
                cout << endl;
        }
}

Measured memory_bytes: 3108