akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

int N;
vector<string> S;

int count(const string &str) {
    int res = 0;
    for (int i = 0; i+1 < str.size(); ++i) {
        if (str[i] == 'A' && str[i+1] == 'B'){
            ++res;
        }
    }
    return res;
}

long long solve() {
    long long res = 0;
    for (int i = 0; i < N; ++i) res += count(S[i]);

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i][0] == 'B' && S[i].back() == 'A') ++a;
        else if (S[i].back() == 'A') ++b;
        else if (S[i][0] == 'B') ++c;
    }
    long long add = 0;
    if (b + c == 0) add = max(0, a-1);
    else add = a + min(b, c);

    res += add;
    return res;
}


int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    S.resize(N);
    for (int i = 0; i < N; ++i) cin >> S[i];
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	AB := sc.nextFloats()
	A := AB[0]
	B := AB[1]

	Aper := 0.08
	Bper := 0.10

	var isOk bool

	for i := 10.0; i <= 1000.0; i++ {
		if math.Trunc(i*Aper) == A && math.Trunc(i*Bper) == B {
			fmt.Println(i)
			isOk = true
			break
		}
	}
	if !isOk {
		fmt.Println(-1)
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	for(;;){
		int x, y;

		scanf("%d %d", &x, &y);
		if (!x && !y)
			break;

		printf(x < y ? "%1$d %2$d\n" : "%2$d %1$d\n", x, y);
	}
	return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(x.begin(),x.end());

  bool ans = (x[0] == x[1] && x[1] != x[2])
          || (x[0] != x[1] && x[1] == x[2]);
  cout << (ans?"Yes":"No") << endl;
}


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

using namespace std;

int main()
{
	string s;
	string p;
	int i, j;
	int y = 0;
	string ans = "No";
	cin >> s;
	cin >> p;

	s = s + s;

	while (1)
	{
		for (i = y; i < s.length(); i++)
		{
			if (s[i] == p[0]) break;
		}
		if (i == s.length())
		{
			break;
		}
		else
		{
			for (j = 0; j < p.length(); j++)
			{
				if (s[i+j] == p[j])
				{
					ans = "Yes";
				}
				else
				{
					ans = "No";
					break;
				}
			}
			if (ans == "Yes") break;
		}
		y++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3156
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    string s;
    cin >> s;
    for (auto &x : s) {
        if (x == '?') {
            x = 'D';
        }
    }
    // int ans = 0;
    // REP(i, s.length() - 1) {
    //     if (s[i] == 'P' && s[i + 1] == 'D') {
    //         ans++;
    //     }
    // }
    // REP(i, s.length()) {
    //     if (s[i] == 'D') {
    //         ans++;
    //     }
    // }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3752
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll dp[110][4][4][4];

int main(){
  int N,o;
  cin>>N;
  dp[0][3][3][3]=1;
  for(int i=0;i<N;i++){
    for(int num3=0;num3<4;num3++){
      for(int num2=0;num2<4;num2++){
        for(int num1=0;num1<4;num1++){
          if(num2==0 && num1==1) o=2;
          else if(num2==0 && num1==2) o=1;
          else if(num2==1 && num1==0) o=2;
          else if(num3==0 && num2==1) o=2;
          else if(num3==0 && num1==1) o=2;
          else o=-1;

          for(int next=0;next<4;next++){
            if(o==next) continue;
            dp[i+1][num2][num1][next]+=dp[i][num3][num2][num1];
            dp[i+1][num2][num1][next]%=MOD;
          }
        }
      }
    }
  }
  ll ans=0;
  for(int num3=0;num3<4;num3++){
    for(int num2=0;num2<4;num2++){
      for(int num1=0;num1<4;num1++){
          ans+=dp[N][num3][num2][num1];
          ans%=MOD;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int change=0;
    if(n%1000==0)
    change=0;
    else if(n<1000)
    {
        change=1000-n;
    }
    else if(n>1000)
    {
        for(int i=1000;i<n;i+=1000)
        {
            change=(i+1000)-n;
        }
    }
    else{
        cout<<"Not valid";
    }
    cout<<change;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 62) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<ll> X(N),Y(N);
    rep(i,0,N)cin >> X[i] >> Y[i];
    ll mini = INF;
    rep(i,0,N)rep(j,0,N)rep(k,0,N)rep(l,0,N){
        ll minX = min({X[i], X[j], X[k], X[l]});
        ll maxX = max({X[i], X[j], X[k], X[l]});
        ll minY = min({Y[i], Y[j], Y[k], Y[l]});
        ll maxY = max({Y[i], Y[j], Y[k], Y[l]});
        int cnt = 0;
        rep(m,0,N){
            if(X[m] >= minX && X[m] <= maxX && Y[m] >= minY && Y[m] <= maxY)cnt++;
        }
        if(cnt >= K){
            //cout << i << " " << j << " " << k << " " << l << endl;
            //cout << minX << " " << maxX << " " << minY << " " << maxY << endl;
            mini = min(mini, (maxX - minX) * (maxY - minY));
        }
    }
    cout << mini << endl;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int a[n+1], b[n+1], c[n+1];
    a[0] = b[0] = c[0] = 0;
    rep(1, n+1) cin >> a[i];
    rep(1, n+1) cin >> b[i];
    rep(1, n) cin >> c[i];

    int happy = 0;
    rep(1, n+1) {
        happy += b[a[i]];
        if (a[i] - a[i-1] == 1) {
            happy += c[a[i-1]];
        }
    }

    cout << happy << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace algorithm
{
	class Program
	{
		public static void Main()
		{
			int[] q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			long[] q2 = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
			int idx = q2.Length %2 == 0 ? q2.Length / 2 -1 : q2.Length / 2 ;
			int l = idx, r = idx+1;
			long[] tmp = new long[q2.Length];

			for (int i = 0; i < q2.Length; i++)
			{
				if (i % 2 == 0)
				{
					tmp[l] = q2[i];
					l--;
				}
				else
				{
					tmp[r] = q2[i];
					r++;
				}

			}

			if (q2.Length % 2 != 0)
			{

				Console.Write(tmp[0]);
				for (int i = 1; i < tmp.Length; i++)
				{
					Console.Write($" {tmp[i]}");
				}
			}
			else
			{
				Console.Write(tmp[tmp.Length-1]);
				for (int i = tmp.Length-2; i >= 0; i--)
				{
					Console.Write($" {tmp[i]}");
				}
			}
			
			
				Console.WriteLine();
			


		}
	}

}




Measured memory_bytes: 37800
n,m=map(int,input().split())
X=[]
M=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    X.append([a-1,b-1])
    M[a-1].append(b-1)
    M[b-1].append(a-1)
ans=0
 
def dfs(x,se):
    visited[x]=1
    for m in M[x]:
        if se!={x,m} and visited[m]==0:
            dfs(m,se)
 
for i in range(m):
    visited=[0]*n
    dfs(0,set(X[i]))
    if 0 in visited:
        ans+=1
print(ans)

Measured memory_bytes: 3064
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
	using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	string s; cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 10948
/* -*- coding:utf-8 -*- */

#include <iostream>

using namespace std;

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

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

int main()
{
  long a, b;
  while(cin >> a >> b, !cin.eof()) 
    cout << gcd(a,b) << ' ' << lcm(a,b) << endl;
  
  return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> num(N);
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        num.at(a-1)++;
    }
    sort(num.rbegin(), num.rend());//!!!
    int sum = 0;
    for (int i=K; i<N; i++) sum += num.at(i);
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 998244353

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

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 210
int x;

int main() {
    string s;
    cin >> s;
    if (s.length() < 4 || s.substr(0, 4) != "YAKI") {
        cout << "No";
    } else {
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
N=int(input())
data_str=input().split()
data=[int(s) for s in data_str]
ans=0
for i in range(N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if data[i]!=data[j] and data[i]!=data[k] and data[k]!=data[j] and data[i]+data[j]>data[k] and data[i]+data[k]>data[j] and data[j]+data[k]>data[i]:
                ans+=1
print(ans)
                

Measured memory_bytes: 9196
a = str(input())
if a[-1] == "2" or a[-1] == "4" or a[-1] == "5" or a[-1] == "7" or a[-1] == "9":
    print("hon")
elif a[-1] ==  "0" or a[-1] ==  "1" or a[-1] ==  "6" or a[-1] ==  "8":
    print("pon")
elif a[-1] == "3":
    print("bon")

Measured memory_bytes: 8908
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>

using namespace std;


int main(){
	int n,q,a,ans=0;
	vector<int> T;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;T.push_back(a);
	}
	sort(T.begin(),T.end());
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> a;
		ans+=binary_search(T.begin(), T.end(), a);
	}
	cout << ans<<endl;
}

Measured memory_bytes: 3456
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    a_list = LI()

    ans = 0
    for a in a_list:
        ans += 1/a
    print(1/ans)

solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,ll>;

//これを見る初心者の方へ:mainより上のいっぱい書いてあるやつはプログラムを簡略化するためのものです。自分も最近知りました。各種コメントをつけているので参考にしてみてください(検索すればqittaとかでも色々見つかるので探してみてください)
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sort(a) sort(ALL(a))//sortの省略
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新



signed main(){
  ll weight[110],value[110];
  ll dp[110][100100]={0};
  
  in(ll,N);
  in(ll,W);
  REP(i,N) cin>>weight[i]>>value[i];
  
  REP(i,N){
    REP(sum_w,W+1){
      if(sum_w-weight[i]>=0){
        chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  out(dp[N][W]);
    
  
}

Measured memory_bytes: 86272
/*                        
                            In the name of Almighty ALLAH
                                    ISLAM IS PEACE

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/


#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb               push_back
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(v)           v.begin(),v.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;



int main() {
    
    FASTIO;
    
    string s;
    cin >> s;
    if(s[s.length()-1]=='s') cout << s << "es" << endl;
    else cout << s << 's' << endl;
    
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
	int n, d;
	int i = 1;
	int cnt = 0;
 
	if (scanf("%d %d", &n, &d) != 0)
		;
 
	while (i <= n)
	{
		cnt++;
		i = i + 2 * d;
		i++;
	}
	printf("%d\n", cnt);
 
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    static int calc(int a) {
    int num =0;
        if(400<=a&&a<=599){
            num=8;
        }else if(600<=a&&a<=799) {
            num=7;
        }else if(800<=a&&a<=999) {
            num=6;
        }else if(1000<=a&&a<=1199) {
            num=5;
        }else if(1200<=a&&a<=1399) {
            num=4;
        }else if(1400<=a&&a<=1599) {
            num=3;
        }else if(1600<=a&&a<=1799) {
            num=2;
        }else if(1800<=a&&a<=1999) {
            num=1;
        }
        System.out.println(num);
        return num;

   }

   public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    calc(a);

   }

}


Measured memory_bytes: 35396
#include<stdio.h>

int main(){
  int a, b, n, gcd, lcm, i, stock, x, y;


  while(scanf("%d %d",&a,&b) != EOF){
    //Ååöñ

    if(a < b){
      stock = a;
      a = b;
      b = stock;
    }
      x = a;
      y = b;


    while(1){
      x = x % y;
      
      stock = x;
      x = y;
      y = stock;

      if(y == 0){
	gcd = x;
	break;
      }
    }

    //Å¬ö{

    lcm = (a / gcd) * b;
    printf("%d %d\n",gcd,lcm);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,t;
  cin >> n >> t;
  vector<P> v(n);
  REP(i,n) cin >> v[i].first >> v[i].second;
  
  VSORT(v);
  
  REP(i,n){
    if(v[i].second <= t){
      cout << v[i].first << endl;
      return 0;
    }
    else continue;
  }
  
  cout << "TLE" << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

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

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

  ll dp[55][2505][55];
  for(int i = 0; i < 55; i++){
    for(int j = 0; j < 2505; j++){
      for(int k = 0; k < 55; k++) dp[i][j][k] = 0;
    }
  }

  for(int i = 0; i < 55; i++) dp[0][0][i] = 1;

  for(int i = 1; i <= n; i++){
    for(int j = 1; j < 2505; j++){
      for(int k = 1; k <= n; k++){
        dp[i][j][k] = dp[i][j][k - 1];
        if(j - x[k] >= 0) dp[i][j][k] += dp[i - 1][j - x[k]][k - 1];

        //if(dp[i][j][k] > 0) cout << " dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << endl;
      }
    }
  }

  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ans += dp[i][a * i][n];
  }

  cout << ans << '\n';
}


Measured memory_bytes: 59520
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int x,y,z,a,b,c,powa,powb,powc;
    int sankaku = 0;
    int eikaku = 0;
    int chokkaku = 0;
    int donkaku = 0;
    while(true){
        cin >> x >> y >> z;
        
        a = x;
        b = y;
        c = z;

        if(a < y){
            a = y;
            b = x;
            c = z;
        }
        if(a < z){
            a = z;
            b = y;
            c = x;
        }

        if(a >= b + c){
            break;
        } else {
            sankaku++;
            powa = a*a;
            powb = b*b;
            powc = c*c;
       
            if(powa < powb + powc){
                eikaku++;
            } else if(powa > powb + powc) {
                donkaku++;
            } else {
                chokkaku++;
            }
        }
        
    }

    cout << sankaku << " " << chokkaku << " " << eikaku << " " << donkaku << endl;
    return 0;

}


Measured memory_bytes: 3108
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	s := make([][]int, m)
	p := make([]int, m)
	for i := range s {
		var k int
		fmt.Scan(&k)
		s[i] = make([]int, k)
		for j := range s[i] {
			fmt.Scan(&s[i][j])
			s[i][j]--
		}
	}
	for i := range p {
		fmt.Scan(&p[i])
	}

	var ans int
	for bit := 0; bit < (1 << uint(n)); bit++ {
		all := true
		for i := 0; i < m; i++ {
			var cnt int
			for _, l := range s[i] {
				if bit&(1<<uint(l)) != 0 {
					cnt++
				}
			}
			if cnt%2 != p[i] {
				all = false
			}
		}
		if all {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int a; cin >> a;
    string s; cin >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
char c[10][10];
int l[10],r[10];
int aaa[114514];
signed main(){
	ic(n) ic(m) ic(k)
	rep(0,i,n+1){
		rep(0,j,m+1){
			if(j*n+i*m-2*i*j==k){
				c("Yes")
				return 0;
			}
		}
	}
	c("No")	
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll N, X, M;
    cin >> N >> X >> M;
    vector<int> f(M, -1);
    ll ans = 0;
    ll A = X;
    vector<int> v;
    for (int i = 0; i < N; i++) {
        if (f[A] == -1) {
            ans += A;
            f[A] = i;
            v.push_back(A);
            A = (A*A) % M;
        }
        else {
            ll l = N-i;
            ll s = 0;
            ll k = l % (i-f[A]);
            for (int j = f[A]; j < i; j++) {
                s += v[j];
                if (j < f[A]+k) {
                    ans += v[j];
                }
            }
            ans += s*(l/(i-f[A]));
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int sum = 0, bad = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1])
            sum += 1;
        else
            bad += 1;
    }
    cout << sum + min(bad, 2 * k) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main(){
    string S, fron="";
    int Q;
    bool r_flag=false;
    cin >> S >> Q;
    int t, f;
    char c;
    rep(i, Q) {
        cin >> t;
        if(t==1) r_flag = !r_flag;
        else{
            cin >> f >> c;
            if(f==1){
                if(r_flag) S.push_back(c);
                else fron.push_back(c);
            }else{
                if(r_flag) fron.push_back(c);
                else S.push_back(c);
            }
        }
    }
    string ans;
    if(r_flag){
        reverse(S.begin(), S.end());
        out(S+fron);
    }else{
        reverse(fron.begin(), fron.end());
        out(fron+S);
    }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll X, Y; cin >> X >> Y;
  if (abs(X - Y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

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

    	int result=K*(int)Math.pow(K-1,N-1);

    	System.out.println(result);


    }
}



Measured memory_bytes: 23764
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int n=s.length();
        String ans;
        if(s.charAt(0)=='A'){
            int count=0;
            for(int i=2;i<n-1;i++){
                if(s.charAt(i)=='C'){
                    count++;
                }
            }
            if(count==1){
                boolean b=true;
                for(int i=0;i<n;i++){
                    if(s.charAt(i)!='A' && s.charAt(i)!='C'){
                        int ascii=s.charAt(i);
                        if(ascii<97 || ascii>122){
                            b=false;
                            break;
                        }
                    }
                }
                if(!b){
                    ans="WA";
                }
                else{
                    ans="AC";
                }
            }
            else{
                ans="WA";
            }      
        }
        else{
            ans="WA";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;

const int NMAX = 50;
ll gBinom[NMAX + 1][NMAX+1];

void CalcBinom(int n)
{
	for (int i = 1; i <= n; i++)
	{
		gBinom[i][1] = i;
		for (int j = 2; j <= i; j++)
		{
			gBinom[i][j] = gBinom[i - 1][j] + gBinom[i - 1][j - 1];
		}
	}
}

int main()
{
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	CalcBinom(N);
	ll nums[NMAX];
	for (int i = 0; i < N; ++i)
	{
		scanf("%lld", &nums[i]);
	}

	sort(nums, nums + N, greater<ll>());
	double s = 0.0;
	for (int i = 0; i < A; ++i)
		s += nums[i];
	printf("%.20lf\n", s / A);

	const ll val = nums[A - 1];
	int ccc[2] = { 0, 0 };
	for (int i = 0; i < N; ++i)
	{
		if (nums[i] == val)
			++ccc[i >= A];
	}
	int u = ccc[0] + ccc[1];
	ll cnt = 0;
	if (val == nums[0])
	{
		for (int i = A; i <= B; ++i)
			cnt += gBinom[u][i];
	}
	else
		cnt = gBinom[u][ ccc[0] ];
	printf("%lld\n", cnt);
	return 0;
}


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

bool isPrime(int n) {
  if(n % 2 == 0) return false;

  for (int i = 3; i * i <= n; i+=2) {
    if(n % i == 0) return false;
  }
  return true;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  if(n == 1) {
    cout << 0 << '\n';
    return 0;
  }

  int N = n;
  map<int,int> mp;
  for (int i = 2; i * i <= N; i++) {
    while(n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }

  if(isPrime(n) && n != 1) mp[n] = 1;
  vector<int> table(50);
  table[0] = 0;
  for (int i = 1; i < 50; i++) {
    table[i] = table[i - 1] + i;
  }

  int ans = 0;
  for (auto it : mp) {
    int val = it.second;
    int cnt = 0;
    for (int i = 0; i < 50; i++) {
      if(val >= table[i]) cnt = i;
      else break;
    }
    ans += cnt;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n; cin >> n;
    vector<pair<ll,ll>> p;
    rep(i,0,n){
        ll tmp; cin >> tmp;
        p.pb(mp(tmp,i));
    }
    // ソート
    sort(all(p));
    // 中央値
    ll med = p[n/2].fi;
    // 未満フラグ
    bool flag[n];
    rep(i,0,n)
        flag[p[i].se] = (p[i].fi >= med ? true : false);

    rep(i,0,n){
        if(flag[i])
            cout << p[n/2 - 1].fi << endl;
        else
            cout << p[n/2].fi << ednl;
    }
}

Measured memory_bytes: 6512
n, t = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
b = sorted(a, reverse=True)
c = set()
k = 1
v = 0
high = 0
ansli = []
for i in range(n - 1):
    c.add(a[i])
    if i == 0 or high == a[i]:
        if i == 0 and b[0] == a[i]:
            v += 1
        while True:
            if b[v] in c:
                v += 1
            else:
                break
        for j in range(k, n):
            if a[j] == b[v] and a[j] not in c:
                high = a[j]
                k = j + 1
                v += 1
                break
            elif a[j] == b[v]:
                v += 1
                while True:
                    if b[v] in c:
                        v += 1
                    else:
                        break
    ansli.append(high - a[i])

ansli.sort(reverse=True)
ans = 1
for i in range(1, n - 1):
    if ansli[i - 1] != ansli[i]:
        break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 17892
n,k=map(int,input().split())
ans=0

if k==0:
    print(n**2)
else:
    for i in range(k+1,n+1):
        if n%i<k:
            ans+=n//i*(i-k)
        else:
            ans+=n//i*(i-k)+n%i-(k-1)
    
    print(ans)

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

typedef long long ll;
const ll MOD = 998244353;

int N, A, B;
ll K;

/*
void make_comb(vector<vector<ll>> &v) {
    for(int i = 0;i <v.size(); i++){
      v[i][0]=1;
      v[i][i]=1;
    }
    for(int k = 1;k <v.size();k++){
      for(int j = 1;j<k;j++){
        v[k][j]=(v[k-1][j-1]+v[k-1][j]);
      }
    }
}


ll comb(int n, int r){
    ll res = 1;
    for (int i = 1; i <= r; i++){
        res = res * (n+1-i)/i % MOD;
    }
    return res;
}
*/

ll pow(int n,ll a){
    if (a == 1){
        return n;
    }else if(a % 2 == 0){
        ll d = pow(n ,a/2);
        return d * d % MOD;
    }
    return n * pow(n,a-1) % MOD;
}


void make_comb(vector<ll> &v){
    ll res = 1;
    v[0] = res;
    v[N] = res;
    for (int i = 1; i <= N/2; i++){
        res = res * (N-i+1) % MOD * pow(i,MOD-2) % MOD;
        v[i] = res;
        v[N-i] = res;
    }
}

int main(){
    cin >> N >> A >> B >> K;

    ll sum = 0;
    vector<ll> Com(N + 1, 0);
    //make_comb(Com);
    make_comb(Com);


    for (int a = 0; a <= N; a++){
        if ((K-a*A)%B == 0){
            int b = (K-a*A)/B;
            if (0 <= b && b <= N){
                sum += (Com[a]) * (Com[b]);
                sum %= MOD;
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define maxn 1005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
char x3[3][10] = {"aab", "c.b", "cdd"};
char x4[6][10] = {"qqwe", "rrwe", "tyuu", "tyii"};
char x5[6][10] = {"aabcc", "b.bdd", "baaee", "fgh..", "fgh.."};
char x7[8][10] = {"..mmkkn",
"ii.g..n",
".aagff.",
"djj...b",
"d..c..b",
"h..ce..",
"h...ell"} ;
char ot[maxn][maxn];
void pt(int x, int y, int tp) {
	if (tp == 3)
		for (int i = 0; i < tp; i++)
			for (int j = 0; j < tp; j++)
				ot[x + i][y + j] = x3[i][j];
	else if (tp == 4)
		for (int i = 0; i < tp; i++)
			for (int j = 0; j < tp; j++)
				ot[x + i][y + j] = x4[i][j];
	else if (tp == 5)
		for (int i = 0; i < tp; i++)
			for (int j = 0; j < tp; j++)
				ot[x + i][y + j] = x5[i][j];
	else	{
		for (int i = 0; i < tp; i++)
			for (int j = 0; j < tp; j++)
				ot[x + i][y + j] = x7[i][j];
	}
}
int n;
void otp() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			printf("%c", ot[i][j]);
		printf("\n");
	}
}
int main() {

	cin >> n;	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			ot[i][j] = '.';
	if (n == 2) {
		cout << -1 << endl;
		return 0;
	}
	else {
		if (n % 3 == 0)
			for (int i = 0; i < n; i += 3)
				pt(i, i, 3);
		else if (n == 7)
			pt(0, 0, 7);
		else if (n == 11)
			pt(0, 0, 7), 
			pt(7, 7, 4); 
		else {
			for (int j = 0; 4 * j <= n; j++) {
				if ((n - 4 * j) % 5 == 0) {
					int ns = 0;
					for (int t = 0; t < j; t++)
						pt(ns, ns, 4), ns += 4;
					while (ns < n)
						pt(ns, ns, 5), ns += 5;
					break;
				}
			}
		}
	}
	otp();
	return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int x = Integer.parseInt(sc.next());
        
        if(x >= 1800){
            System.out.println(1);
        }else if(x >= 1600){
            System.out.println(2);
        }else if(x >= 1400){
            System.out.println(3);
        }else if(x >= 1200){
            System.out.println(4);
        }else if(x >= 1000){
            System.out.println(5);
        }else if(x >= 800){
            System.out.println(6);
        }else if(x >= 600){
            System.out.println(7);
        }else{
            System.out.println(8);
        }
    }
}

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

signed main() {

   int n,T;cin>>n>>T;

   int ans = 10000000;

   for(int i = 0; i < n; i++)
   {
        int c,t;cin>>c>>t;
        if(t<=T) ans =  min(ans,c);
   }

    if(ans == 10000000) cout << "TLE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    long N,M;
    long ans;
    cin >> N >> M ;
    if(N == 1){
        if(M == 1){
            ans = 1;
        }
        else{
            ans = M - 2;
        }
    }
    else if(M == 1){
        ans = N - 2;
    }
    else {
        ans = (N-2)*(M-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 
import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    //================================================================================
    public void solve() {
    	int H = Integer.parseInt(sc.next());
    	int W = Integer.parseInt(sc.next());
    	String s;
    	char[][] A = new char[H][];
    	Set<Integer> set = new HashSet<>();
    	int cnt = 0;
    	for (int i = 0; i < H; i++) {
    		s = sc.next();
    		if(!s.contains("#"))	continue;
			A[cnt] = s.toCharArray();
			for (int j = 0; j < A[cnt].length; j++) {
				if(A[cnt][j] == '#')		set.add(j);
			}
			cnt++;
		}
    	for (int i = 0; i < cnt; i++) {
			for (int j = 0; j < W; j++) {
				if(set.contains(j))	out.print(A[i][j]);
			}
			out.println();
		}
    }
}

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

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

    string ans;
    for(int i=0; i<s.length(); i++){
        if( s[i] == 'B' ) {
            int len = ans.length();
            if(len > 0) {
                ans.erase(len-1);
            }
        }
        else {
            ans += s[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = IOUtils.ReadInts();

            var tkHp = vals[0];
            var tkAtk = vals[1];
            var aoHp = vals[2];
            var aoAtk = vals[3];

            while(true)
            {
                aoHp = aoHp - tkAtk;
                if (aoHp <= 0)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                tkHp = tkHp - aoAtk;
                if (tkHp <= 0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 19000
#include<iostream>
#include<string>
using namespace std;
int casenum;
int runner,strike,out,point;
string str;


int main(){
  cin >> casenum;
  for(int i = 0;i < casenum;i++){
    runner = strike = out = point = 0;
    while(1){
      cin >> str;
      if(str == "HIT"){
	strike = 0;
	if(runner == 3)point += 1;
	else runner++;
      }else if(str == "OUT"){
	out++;
	strike = 0;
	if(out == 3)break;
      }else if(str == "HOMERUN"){
	point += (runner+1);
	runner = strike = 0;
      }
    }
    cout << point << endl;
  } 
  return 0;
}

Measured memory_bytes: 0