akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        long n = in.l();
        long s = in.l();
        int m = (int)Math.sqrt(n);
        long ans = Long.MAX_VALUE;
        for (int b = 2; b <= m; b++) {
            long t = 0;
            long a = n;
            while (a > 0) {
                t += a % b;
                a /= b;
            }
            if (s == t) {
                ans = b;
                break;
            }
        }
        if (ans == Long.MAX_VALUE) {
            if (n == s) {
                ans = s + 1;
            }
            for (int i = 1; i <= Math.min(s, m); i++) {
                long j = s - i;
                long b = (n - j) / i;
                if (m < b && j < b && (n - j) % i == 0 && n == i * b + j) {
                    ans = Math.min(ans, b);
                }
            }
            if (ans == Long.MAX_VALUE) {
                ans = -1;
            }
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32888
#include <iostream>
#include <queue>

#define INF (1<<28)

using namespace std;

#define MAX_H 100
#define MAX_W 100

int H, W;
char S[MAX_H][MAX_W];

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

struct P { int x, y, current, flip; };

bool solve() {
  queue<P> q;

  int used[MAX_H][MAX_W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      used[i][j] = INF;
    }
  }

  q.push(P{0, 0, S[0][0], S[0][0] == '.' ? 0 : 1});

  int ans = INF;

  while (!q.empty()) {
    P p = q.front(); q.pop();
    if (p.flip >= ans) { continue; }
    if (p.x == W-1 && p.y == H-1) { ans = p.flip; continue; }

    for (int i = 0; i < 2; i++) {
      int nx = p.x + dx[i], ny = p.y + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H) {
        if (S[ny][nx] == p.current) {
          if (p.flip < used[ny][nx]) {
            used[ny][nx] = p.flip;
            q.push(P{nx, ny, p.current, p.flip});
          }
        } else {
          int nc = p.current == '.' ? '#' : '.';
          int nf = p.current == '.' ? (p.flip+1) : p.flip;
          if (nf < ans && nf < used[ny][nx]) {
            used[ny][nx] = nf;
            q.push(P{nx, ny, nc, nf});
          }
        }
      }
    }
  }

  cout << ans << endl;
}

int main() {
  cin >> H >> W;
  string s;
  for (int i = 0; i < H; i++) {
    cin >> s;
    if (s.size() == 0) cin >> s;
    for (int j = 0; j < W; j++) {
      S[i][j] = s[j];
    }
  }
  solve();
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int modpow(int a, int b) {
	if (b < 0) return 0;
	int ret = 1;
	for (int i = 30; i >= 0; i--) {
		ret = 1LL * ret * ret % mod;
		if (b & (1 << i)) ret = 1LL * ret * a % mod;
	}
	return ret;
}
int n, a[100009], b[100009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	int pre1 = 0, pre2 = n - 1, ret = 1;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] < a[i]) {
			ret = 1LL * ret * modpow(a[i - 1], i - pre1 - 1) % mod;
			pre1 = i;
		}
	}
	for (int i = n - 2; i >= 0; i--) {
		if (b[i + 1] < b[i]) {
			ret = 1LL * ret * modpow(b[i + 1], pre2 - i - 1) % mod;
			pre2 = i;
		}
	}
	ret = 1LL * ret * modpow(a[pre1], (pre2 - pre1 - 1 <= -1 ? (pre2 == pre1 ? 0 : -1) : pre2 - pre1 - 1)) % mod;
	if (a[n - 1] != b[0]) ret = 0;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void){

int W, H, x, y, r;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

if(x >= r && W-r >= x && y >= r && H-r >=y){
printf("Yes\n");
} else {
printf("No\n");

}
return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<ctype.h>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int a[1001];
int main(){
    int n=read(),sum=0,minn=999999999,maxn=-999999999;
	int ans=minn;
    for(int i=1;i<=n;i++){
        a[i]=read();sum+=a[i];
        minn=min(minn,a[i]);
        maxn=max(maxn,a[i]);
    }
    for(int i=minn;i<=maxn;i++){
        int s=0;
        for(int j=1;j<=n;j++)s+=(a[j]-i)*(a[j]-i);
        ans=min(ans,s);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int main(){
  int n, k, q; cin >> n >> k >> q;
  vector<int> nq(q);
  vector<int> nn(n);
  // input
  for (int i=0; i<q; i++){
    cin >> nq[i];
  }
  // initialize
  for (int i=0; i<n; i++){
    nn[i] = 0;
  }
  // getting score
  for (int i=0; i<q; i++){
    nn[nq[i]-1] += 1;
  }
  for (int i=0; i<n; i++){
    nn[i] += k-q;
  }
  for (int i=0; i<n; i++){
    if(nn[i] >= 1){
      printf("%s\n", "Yes");
    }else{
      printf("%s\n", "No");
    }
  }
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
int a,b,sum=0;//aの倍数秒後にb枚ずつビスケットを生産する。
int t;
scanf("%d %d %d",&a,&b,&t);
while(t+0.5-a>0){
    t=t-a;
    sum=sum+b;
}
printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
n=int(input())
s=input().split(' ')

flag=1
m=0

while flag:
    flag=0
    for j in range(1,n):
        j=n-j
        if int(s[j])<int(s[j-1]):
            a=s[j]
            s[j]=s[j-1]
            s[j-1]=a
            m+=1
            flag=1

print(' '.join(s))
print(m)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int K = 4000001;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    bitset<K> b, b1;
    b[0] = 1;
    for (int i=0; i < n; i++){
        int x = v[i];
        b1 = (b << x);
        b |= b1;
    }
    int S = 0;
    for (int i=0; i < n; i++) S += v[i];
    S++;
    S /=2;
    int i = S;
    while (true){
        if (b[i]){
            cout << i << endl;
            return 0;
        }
        i++;
    }
    return 0;
}





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

const int inf = 1e9+5;

int main() {

    int n;
    cin>>n;

    int arr[n];
    for(int i=0;i<n;++i)
        cin>>arr[i];

    vector<int> dp(n,inf);
    dp[0] = 0;
    for(int i=0;i<n;++i){
            for(int j:{i+1,i+2}){
                if(j<n)
                    dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j]));
            }

    }

    cout<<dp[n-1];
    return 0;
      }


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

int main(){
    string s;
    cin >> s;
    string ans={};
    rep(i, s.size()){
        ans.push_back('x');
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
import Data.List

p :: Char -> Bool
p c =  case c of 'A' -> True
                 'T' -> True
                 'C' -> True
                 'G' -> True
                 otherwise -> False

main :: IO ()
main = do
  s <- getLine
  print $ (\s -> if s == [] then 0 else maximum s) $ map length $ filter (\s -> p $ head s) $ groupBy (\a b -> p a && p b) s


Measured memory_bytes: 380
package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}


Measured memory_bytes: 11952
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
void toStr(int n, int L,char c[])
{
	int i = 0;
	for (i = 0; i < L; i++)
	{
		c[L - 1 - i] = n % 10 + '0';
		n /= 10;
  	}
	return;
}

int toNum(char c[])
{
	int index = 0;
	while (c[index] != '\0')
	{
		
	}
	return 0;
}

int getMax(char c[],int L)
{
	for (int i = 0; i < L - 1; i++)
	{
		for (int j = i + 1; j < L; j++)
		{
			if (c[i] < c[j])
			{
				char tmp = c[i];
				c[i] = c[j];
				c[j] = tmp;
			}
		}
	}
	return atoi(c);
}

int getMin(char c[] , int L)
{
	for (int i = 0; i < L - 1; i++)
	{
		for (int j = i + 1; j < L; j++)
		{
			if (c[i] > c[j])
			{
				char tmp = c[i];
				c[i] = c[j];
				c[j] = tmp;
			}
		}
	}
	return atoi(c);
}
int main()
{
	int a0, L;
	while (cin >> a0 >> L && (a0 != 0 || L != 0))
	{
		int iset[20 + 1] = {};
		int isetIndex = 1;
		int ansA = -1;
		int ansJ = -1;
		int ansIJ = -1;
		iset[0] = a0;
		while (isetIndex <= 20 && ansA == -1)
		{
			char str[20] = {};
			toStr(a0, L, str);
			int ma = getMax(str, L);
			int mi = getMin(str, L);
			int diff = ma - mi;
			a0 = diff;
			iset[isetIndex] = diff;
			isetIndex++;
		}

		bool flag = false;

		for (int i = 20;i > 0;i--)
		{
			for (int j = i - 1; j >= 0; j--)
			{
				if (iset[i] == iset[j])
				{
					flag = true;
					ansJ = j;
					ansA = iset[i];
					ansIJ = i - j;
					break;
				}
			}
		}

		cout << ansJ << " " << ansA << " " << ansIJ << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
def acc_xor(n):
    if n % 4 == 0:
        return 0 ^ n
    elif n % 4 == 1:
        return 1
    elif n % 4 == 2:
        return 1 ^ n
    elif n % 4 == 3:
        return 0


def main():
    A, B = map(int, input().split())

    print(acc_xor(A - 1) ^ acc_xor(B))


main()


Measured memory_bytes: 2940
#include<iostream>
#include<fstream>
#include<stack>
#include<string>
#include <stdlib.h>

using namespace std;

int getTop(stack<int> &s) {
	int tmp = s.top();
	s.pop();
	return tmp;
}

int main() {
	ifstream fin("in.txt");

	string in;
	stack<int> s;

	int ans = 0;

	while (cin >> in){
		if(in == "+") {
			ans = getTop(s) + getTop(s);
			s.push(ans);
		}
		else if (in == "-") {
			int tmp = getTop(s);
			ans = getTop(s) - tmp;
			s.push(ans);
		}
		else if (in == "*") {
			ans =  getTop(s) * getTop(s);
			s.push(ans);
		}
		else if (in == "/") {
			double tmp = (double)getTop(s);
			double tmp2 = getTop(s) / tmp;
			s.push(1.0 / tmp2);
		}
		else s.push(atoi(in.c_str()));		

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1224
#include "bits/stdc++.h"

using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int x,y;
    if(n % 2 == 0){
        x = a[n/2] + a[n/2 - 1];
        y = b[n/2] + b[n/2 - 1];
    }else{
        x = a[n/2];
        y = b[n/2];
    }
    cout << y - x + 1 << endl;
}

Measured memory_bytes: 4776
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {

    ll n; scanf("%lld", &n);

    vector<ll> ans(n-1);
    RANGE(j, 1, n-1) {
        ans[j-1] = 0;
        for (ll l = j & -j; l; ans[j-1]++) l >>= 1;
    }
    RANGE(i, 0, n-2) RANGE(j, 0, n-2-i) {
        cout << ans[j] << " \n"[j==j_end];
    }
    
}

Measured memory_bytes: 512
n,m = map(int,input().split())
ab = []
for _ in range(m):
  ab.append(list(map(int,input().split())))
ab.sort(key = lambda x:x[1])

bridge = [1]*(n-1)
x = -1
for a_b in ab:
  if a_b[0] <= x:
    pass
  else:
    x = a_b[1]-1
    bridge[x-1]=0

print(bridge.count(0))

Measured memory_bytes: 29076
N, K, S = gets.chomp.split(" ").map(&:to_i)

first = true
K.times do
  if !first
    print " "
  end
  first = false
  print S
end
s = S + 1
s = 1 if S == 10**9
(N-K).times do
  print " #{s}"
end
puts ""


Measured memory_bytes: 2812
#include<stdio.h>
int main(){
  long long n,a,b,x,y;
  scanf("%lld %lld %lld",&n,&x,&y);
  while(--n){
    scanf("%lld %lld",&a,&b);
    if(x/a>y/b){
      if(x%a)x=x-x%a+a;
      y=x/a*b;//printf("%lld %lld\n",x,y);
    }
    else{
      if(y%b)y=y-y%b+b;
      x=y/b*a;
    }
  }
  printf("%lld\n",x+y); 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int d, t, s; cin >> d >> t >> s;
	if (d <= t * s) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

struct St{
    bool st;
    bool go;
};

int main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    vector<St> v(n);

    for(int i=0; i<n; i++) {
        v[i].st=0;
        v[i].go=0;
    }

    for(int i=0; i<m; i++) {
        cin >> a >> b;
        if(a>b) {
            int tmp=a;
            a=b;
            b=tmp;
        }
        if(a-1==0) v[b-1].st=1;
        if(b-1==n-1) v[a-1].go=1;
    }

    for(int i=0; i<n; i++) {
        if(v[i].st==1 && v[i].go==1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int T[31];
    T[0] = 1;
    T[1] = 1;
    T[2] = T[1]+T[0];
    for (int i=3; i<=30; i++)
        T[i] = T[i-1]+T[i-2]+T[i-3];
    for (int i=0; i<=30; i++)
        T[i] = (T[i]+3650-1)/3650;

    while (true)
    {
        int n;
        cin>>n;
        if (n==0)
            break;
        cout<<T[n]<<endl;
    }
}

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

int main() {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  int64_t c = C;
  int64_t d = D;
  if (C > D)
  swap(C, D);
  int64_t r = C % D;
  int64_t mul = C * D;
  while (r != 0){
    C = D;
    D = r;
    r = C % D;
  }
  int64_t lcm = mul / D;
  int64_t aquo = A / lcm;
  int64_t bquo = B / lcm;
  int64_t are = A % lcm;
  int64_t bre = B % lcm;
  int64_t cnt = lcm - (lcm / c) - (lcm / d) + 1;
  int64_t head;
  if (are != 0){
    head = are - 1 - ((are - 1) / c) - ((are - 1) / d);
  }
  else{
    head = 0;
  }
  int64_t tail = bre - (bre / c) - (bre / d);
  cout << (bquo - aquo) * cnt - head + tail << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N,K;
    long long int i;
    cin >> N >> K;
    long long int A[N],F[N];
    long long int MAX=1e12+10;
    long long int MIN=0;
    long long int MID;
    long long int k;
    long long int sum=0;
    int flag;
    for(i=0;i<N;i++){
        cin >> A[i];
        sum+=A[i];
    }
    if(sum<=K)cout << 0 << endl;
    else{
    for(i=0;i<N;i++)cin >> F[i];
    sort(A,A+N);
    sort(F,F+N);
    long long int B[N];
    for(i=0;i<N;i++)B[i]=A[i]*F[N-i-1];    
    while(MAX-MIN>1){
        k=0;
        flag=0;
        MID=(MAX+MIN)/2;
        for(i=0;i<N;i++){
            if(B[i]>MID)k+=(A[i]-(MID/F[N-i-1]));
            if(k>K){
                flag++;
                break;
            }
        }
        if(flag>0)MIN=MID;
        else{MAX=MID;}
    }
    cout << MAX << endl;
}}

Measured memory_bytes: 4992
N = int(input())
MOD = 1_000_000_007
A = pow(10, N, MOD) - pow(9, N, MOD)
AorB = pow(10, N, MOD) - pow(8, N, MOD)
print( (A * 2  - AorB) % MOD if N > 1 else 0)


Measured memory_bytes: 9160
n = int(input())
xl_lis = [list(map(int,input().split())) for i in range(n)]
tempx = -(10**10)
ans = 0
xl_lis.sort()
# print(xl_lis)
for i in range(n):
    if tempx > xl_lis[i][0] - xl_lis[i][1] and tempx < xl_lis[i][0] + xl_lis[i][1]:
        ans += 1
    
    elif tempx > xl_lis[i][0] - xl_lis[i][1] and tempx >= xl_lis[i][0] + xl_lis[i][1]:
        ans += 1
        tempx = xl_lis[i][0] + xl_lis[i][1]
    else:
        tempx = xl_lis[i][0] + xl_lis[i][1]
print(n-ans)


Measured memory_bytes: 27872
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main(void){
	int a,m,n,i;//a=n?????????????????°???
	scanf("%d %d",&m,&n);
	while(m!=0){
		if(m!=1){
			for(i=m-1;i>0;i--){
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
					n+=31;
				}
				else if(i==4||i==6||i==9||i==11){
					n+=30;
				}
				else if(i==2){
					n+=29;
				}
			}
		}
		if(n%7==1){
			printf("Thursday\n");
		}
		if(n%7==2){
			printf("Friday\n");
		}
		if(n%7==3){
			printf("Saturday\n");
		}
		if(n%7==4){
			printf("Sunday\n");
		}
		if(n%7==5){
			printf("Monday\n");
		}
		if(n%7==6){
			printf("Tuesday\n");
		}
		if(n%7==0){
			printf("Wednesday\n");
		}
		scanf("%d %d",&m,&n);
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int[] c = new int[m];
		int[] d = new int[m];
		for(int j = 0; j < m; j++) {
			c[j] = sc.nextInt();
			d[j] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			int checkpoint = 1;
			int min = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
			for(int j = 1; j < m; j++) {
				int distance = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if(distance < min) {
					checkpoint = j + 1;
					min = distance;
				}
			}
			System.out.println(checkpoint);
		}
	}
}

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

int main(){
  int H, W, A, B;
  int c[1000]={};
  string s[1000];
  cin >> H >> W >> A >> B;
  for(int i=0; i<B; i++){
    for(int j=0; j<A; j++){
      cout << '0';
    }
    for(int j=A; j<W; j++){
      cout << '1';
    }
    cout << endl;
  }
  for(int i=B; i<H; i++){
    for(int j=0; j<A; j++){
      cout << '1';
    }
    for(int j=A; j<W; j++){
      cout << '0';
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n; cin >> n;
  vector<ll> A(n);
  loop(i,0,n) cin >> A[i];
  sort(A.rbegin(), A.rend());
  n--;
  int idx = 0;
  ll ans = 0;
  ans += A[idx++];
  n--;
  for (; idx<A.size(); idx++) {
    if (n <= 0) break;
    loop(i,0,2) {
      if (n <= 0) break;
      ans += A[idx];
      n--;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4840
<?php
	// Input
	$input = array();
	for($loop_cnt = 0; 28 > $loop_cnt; $loop_cnt++)
	{
		$input[] = (int)trim(fgets(STDIN));
	}
	// Check
	for($loop_cnt = 1; 30 >= $loop_cnt; $loop_cnt++)
	{
		if( !(in_array($loop_cnt, $input)) )
		{
			echo $loop_cnt . "\n";
		}
	}
?>


Measured memory_bytes: 9236
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>

using namespace std;

int main() {
    int sx, sy, tx, ty, x, y;
    cin >> sx >> sy >> tx >> ty;
    x = tx - sx;
    y = ty - sy;
    
    for (int i = 0; i < x; i++)
    {
        cout << 'R';
    }
    for (int i = 0; i < y; i++)
    {
        cout << 'U';
    }
    for (int i = 0; i < x; i++)
    {
        cout << 'L';
    }
    for (int i = 0; i < y; i++)
    {
        cout << 'D';
    }

    cout << 'D';
    for (int i = 0; i < x + 1; i++)
    {
        cout << 'R';
    }
    for (int i = 0; i < y + 1; i++)
    {
        cout << 'U';
    }
    cout << 'L';

    cout << 'U';
    for (int i = 0; i < x + 1; i++)
    {
        cout << 'L';
    }
    for (int i = 0; i < y + 1; i++)
    {
        cout << 'D';
    }
    cout << 'R';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long LL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

using namespace std;


LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL& i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
  // source code
  int a = inputValue();
  int b = inputValue();
  int p = a+b;
  int m = a-b;
  int mu = a*b;
  cout << max(p,max(m,mu)) << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <stdio.h>

using namespace std;
const int NOT_LEAP_YEAR = 19*5+20*5;
const int LEAP_YEAR = 20*10;
const int MAX = 100;

int Mill(int Y,int M,int D){
    int days;
    int quot=(Y-1)/3;
    days= LEAP_YEAR*quot + NOT_LEAP_YEAR*((Y-1)-quot);
    if(Y%3==0){
        days+=(20*(M-1));
    }else{
        days+=(19*((M-1)/2) +20*(M/2));
    }
    days+=D;

    return days;
}

int main(){
    int n,y[MAX],m[MAX],d[MAX];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> y[i] >> m[i] >> d[i];
    }

    int fesDay=Mill(1000,1,1);
    for (int i = 0; i < n; i++)
    {
        cout << fesDay - Mill(y[i], m[i], d[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 3088
import itertools

def solve(S):
    '''
    数字の間に+を入れるパターンと入れないパターンを全てチェックする
    125であれば、 125, 1+25, 12+5, 1+2+5
    +が入る可能性のある場所は右の通り、 1  |ここ!| 2  |ここ!| 5
    よって、組み合わせは 2 ** (文字列数 - 1)
    '''
    
    if len(S) == 1:
        print(int(S))
    else:
        count = 0
        bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
        for pattern in bit_list:
            '''
            ビットの値が1の時に+が入ると考えて、0の時は入らない
            文字列を先頭から調べていき、次の文字との間に+が入る場合、そこまでの文字列をint型に変換して変数「count」に加算する
            +が入る場所の次の文字をstartに記録する
            
            '''
            start = 0
            for end in range(len(pattern)):
                if pattern[end] == 1:
                    count += int(S[start:end+1])
                    start = end + 1

                if end == len(pattern) - 1:
                    count += int(S[start:])

        print(count)


if __name__ == '__main__':
    S = input()
    solve(S)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ceilint(A, B) ((A) + (B - 1)) / (B)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

int main(){

    string s;
    cin >> s;

    char c = s[0];
    int ans = 0;

    rep(i,s.size() - 1){
        if(c != s[i + 1]){
            ans++;
            c = s[i + 1];
        }
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 512
a,b,c,d=input()
x,y=int(a+b),int(c+d)
if 0 < x < 13 and 0 < y < 13:
	print("AMBIGUOUS")
elif 0 < x < 13:
	print("MMYY")
elif 0 < y < 13:
	print("YYMM")
else:
	print("NA")


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
void solve(){
       int a,b,c,d;
       cin>>a>>b>>c>>d;
      
       int t=1;
       int f=-1;
       while(1){
       	 
       	 if(t==1){
       	 	 if(c-b<=0)
       	 	 {
       	 	 	f=1; break;
       	 	 	
       	 	 	
       	 	 }
       	 	 c=c-b;
       	 	 t=0;
       	 }else{
       	 	  if(a-d<=0){
       	 	  	f=0; break;
       	 	  }
       	 	 a=a-d;
       	 	 t=1;
       	  }
       }
      
        if(f==0)cout<<"No";
        else cout<<"Yes";
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();    
}


Measured memory_bytes: 3576
h,w=map(int,input().split())
M=[]


M=[input() for _ in range(h)]

def bfs(x,y):
    dist=[[-1]*w  for _ in range(h)]
    seen=[[False]*w for _ in range(h)]
    stk=[(x,y,0)]
    while stk:
        px,py,dst=stk.pop(0)
        if seen[px][py]:
            continue
        seen[px][py]=True
        
        if M[px][py]=='#':
            dist[px][py]=0
            continue
        
        for x,y in [(-1,0),(1,0),(0,-1),(0,1)]:
            if px+x<0 or px+x>=h or py+y<0 or py+y>=w:
                continue
            else:
                stk.append((px+x,py+y,dst+1))
        dist[px][py]=dst
    ans=0

    for i in range(h):
        ans=max(max(dist[i]),ans)
    return ans

ans=0
for i in range(h):
    for j in range(w):
        if M[i][j]=='#':
            continue
        ans=max(bfs(i,j),ans)

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int fa[200010],siz[200010],ans,n,m;
inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}

int main(){
	n=read(),m=read();for(int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
	for(int i=1,x,y;i<=m;i++)
	{
		x=read(),y=read();
		x=find(x),y=find(y);
		if(x==y)continue;
		siz[x]+=siz[y],fa[y]=x;
	}
	for(int i=1;i<=n;i++) ans=max(ans,siz[i]);
	cout<<ans;
	return 0;
}


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

using namespace std;

int main()
{
    long long a, b, c;
    long long cab, cab_sq, ab4;

    cin >> a >> b >> c;
    
    cab = (c - a - b);
    cab_sq = cab * cab;
    ab4 = 4 * a * b;

    if (cab > 0 && ab4 < cab_sq) {
        cout << "Yes" << "\n";
    }
    else {
        cout << "No" << "\n" ;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b , x;
  cin >> a >> b >> x;
  
  if ( x >= a && (a+b) >= x){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
    int len1, len2;
    char a[12], b[12], c[12];
    scanf("%s %s %s",a, b, c);
    len1=strlen(a);
    len2=strlen(b);
    if(a[len1-1]==b[0] && b[len2-1]==c[0]) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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


int main()
{
    int X,Y;
    cin >> X>>Y;
    vector<int> A(7);
    vector<int> B(4);
    A = {1,3,5,7,8,10,12};
    B = {4,6,9,11};
    bool ok1 = false,ok2 = false;
    for(int i = 0;i < A.size();i++){
        if(X == A[i]){
            ok1 = true;
        }
        if(Y == A[i]){
            ok2 = true;
        }
    }
    if(ok1 && ok2){
        cout << "Yes" << endl;
        return 0;
    }
    ok1 = false;
    ok2 = false;
    for(int i = 0;i < B.size();i++){
        if(X == B[i]){
            ok1 = true;
        }
        if(Y == B[i]){
            ok2 = true;
        }
    }
    if(ok1 && ok2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int ase[8];

int main( )
{
    int n, m, i, j, k;
    int fl = 1;
    cin >> n >> m;
    memset(ase, -1, sizeof ase);
    for (i = 1; i <= m; i++) {
        cin >> j >> k;
        if (ase[j] == -1) {
            ase[j] = k;
        }
        else if (k != ase[j]) {
            fl = 0;
        }
    }
    if (fl == 0) {
        cout << "-1\n";
        return 0;
    }
    if (ase[1] == 0 && n != 1) {
        cout << "-1\n";
        return 0;
    }
    j = 0;
    if (n == 1 && ase[1] == -1) {
        cout << "0\n";
        return 0;
    }
    if (ase[1] == -1) {
        j = j * 10 + 1;
    }
    else {
        j = j * 10 + ase[1];
    }
    for (i = 2; i <= n; i++) {
        if (ase[i] == -1) {
            j = j * 10 + 0;
        }
        else {
            j = j * 10 + ase[i];
        }
    }
    cout << j << "\n";
    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int m; cin >> m;
  int ans = 24+24-m;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3520
use std::io::{stdin, Read};
use rand::prelude::*;

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let d = buf.split_whitespace().next().unwrap().parse().unwrap();
    let mut rng = rand::thread_rng();
    for i in 0..d {
        println!("{}", rng.gen_range(1, 27));
    }
}

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

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

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();

    let mut a = -1;
    let mut z = -1;
    for i in 0..s.len() {
        if a < 0 && s[i] == 'A' {
            a = i as i32;
        }
        if a >= 0 && s[i] == 'Z' {
            z = i as i32
        }
    }
    println!("{}", z - a + 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout<<'\n'
#define sor(x) sort(x.begin(),x.end())
#define rev(v) reverse(v.begin(),v.end())
#define llmax 100000000000000000
#define deb(x) cout<<"value here is "<<x<<"\n"
#define pll pair<ll,ll>
#define vll vector <ll>
#define rub cout<<"ohlala"<<'\n';
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        sum+=(a[i]*a[j]);
    }
    cout<<sum;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	c := 0
	for i := 0; i < N; i++ {
		for i < N-1 && A[i] == A[i+1] {
			i++
		}
		if i < N-1 && A[i] < A[i+1] {
			for i < N-1 && (A[i] < A[i+1] || A[i] == A[i+1]) {
				i++
			}
		} else if i < N-1 && A[i] > A[i+1] {
			for i < N-1 && (A[i] > A[i+1] || A[i] == A[i+1]) {
				i++
			}
		}
		c++
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int x;
    cin >> x;

    unsigned long long int year = 0;

    unsigned long long int amount = 100;

    while(x > amount)
    {
        amount = amount + amount * 0.01;
        year++;
    }

    cout << year << endl;

    return 0;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	prices := make([]int, 3)
	prices[0] = nextInt()
	prices[1] = nextInt()
	prices[2] = nextInt()
	sort.Ints(prices)
	fmt.Println(prices[0] + prices[1])
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  G[u-1].append([v-1,w])
  G[v-1].append([u-1,w])
dist=[-1]*n
from collections import deque
Q,k=map(int,input().split())
q=deque()
q.append(k-1)
dist[k-1]=0
while q:
  cur=q.popleft()
  for nx,nd in G[cur]:
    if dist[nx]!=-1:continue
    dist[nx]=dist[cur]+nd
    q.append(nx)
for i in range(Q):
  x,y=map(int,input().split())
  x-=1
  y-=1
  print(dist[x]+dist[y])


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end();

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}
using namespace std;


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

   int N; cin >> N;
   vector<int> mountains;
   while(N--){
      int m; cin >> m;
      mountains.pb(m);
   }
   
   int can_see = 1;
   int maxM = mountains[0];
   for(int i = 1; i < mountains.size(); i++){
      if(mountains[i] > maxM) maxM = mountains[i];
      if(mountains[i-1] <= mountains[i] && mountains[i] >= maxM){
         can_see++;
      }
   }

   cout << can_see;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,i,j,k;
	int max;

	scanf("%d",&j);

	for(i=0;i<j;i++){
		scanf("%d",&a);
		scanf("%d",&b);
		scanf("%d",&c);

		max=a;
		k=0;
		if(max<=b){
			max=b;
			k=1;
		}
		if(max<=c){
			max=c;
			k=2;
		}

		max=max*max;
		a=a*a;
		b=b*b;
		c=c*c;
		if(k==0 && max==b+c){
			printf("YES\n");
		}
		else if(k==1 && max==a+c){
			printf("YES\n");
		}
		else if(k==2 && max==a+b){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}

return (0);
}

Measured memory_bytes: 0
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <math.h>
    #include<algorithm>
    #include <numeric>
    using namespace std;
     
    int main(){
      int N ,A;
      cin >> N >>A;
      int x[N];
      for(int i=1;i<N+1;i++){
       cin >> x[i]; 
      }
      long long dp[51][2501][51]={};
      dp[0][0][0]=1;
      for(int i=1;i<N+1;i++){
       for(int j=0;j<2501;j++){
         for(int k=0;k<N+1;k++){
           if(k<1 || j<x[i]){
            dp[i][j][k]=dp[i-1][j][k]; 
           }else{
             dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-x[i]][k-1];
           }
         }
       }
      }
      long long ans=0;
      for(int i=1; i<=N; i++){
    ans+=dp[N][i*A][i];
  }
      cout << ans << endl;
      return 0;}



Measured memory_bytes: 51072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.close();

		System.out.println((n%(d*2+1)!=0)? n/(d*2+1)+1:n/(d*2+1));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b == c + d) cout << "Balanced" << endl;
  else if (a + b > c + d) cout << "Left" << endl;
  else if (a + b < c + d) cout << "Right" << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vi t(n);
  REP(i,1,n){
    t.at(i) += t.at(i-1);
    if (s.at(i-1) == 'A' && s.at(i) == 'C'){
      t.at(i)++;
    }
  }
  rep(i,q){
    int l, r;
    cin >> l >> r;
    l--; r--;
    int ans = t.at(r) - t.at(l);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  long long int A1, A2, A3;
  
  scanf("%lld%lld%lld", &A1, &A2, &A3);
  
  if(A1 + A2 + A3 >= 22){
    std::cout << "bust" << std::endl;
  }
  else{
    std::cout << "win" << std::endl;
  }
  
  return 0;
}


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

using namespace std;

int main()
{
    int x, a, b, M, N;
    cin>>x>>a>>b;
    M=abs(x-a);
    N=abs(x-b);
    if(M<N)
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"B"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

public class AtCoder
{
    public static void Main()
    {
        string[] s;
        s = NextS();

        long n;
        n = long.Parse(s[0]);
        bool f = false;
        int a = 0;
        for(int i = 0; i<n; i++)
        {
            s = NextS();
            a = int.Parse(s[0]);
            if (a % 2 == 1) f = true;
        }
        if (f) Console.WriteLine("first");
        else Console.WriteLine("second");       
        
    }

    static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}


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

#define int long long int
#define pb push_back
#define mp make_pair

int32_t main()
{
     
     int n,m;
     
     cin>>n>>m;
     
     for(int i=1e9;i>=1;i--)
     {
          int left=m-(i*n);
          
          if(left>=0)
          {
               if(left%i==0)
               {
                    cout<<i;
                    return 0;
               }
          }
     }
     
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d;
    cin >> n >> d;
    int count=0;
    int j=0;
    for(int i=1;i<=n;i++){
        if(j>2*d) {
            j=0;
            count++;
        }
        j++;
    }
    cout << count+1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll N,D;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  string S;
  cin>>S;
  ll length = 1; 

  for(ll i = 0 ; i<2 ; i++){
    if(S[i] == S[i+1] && S[i] == 'R')
      length++;
  }


  if( count(S.begin() , S.end() , 'R') > 0)
    cout<<length<<'\n';

  else
    cout<<0<<'\n';
   


}



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

  return 0;
}


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

using namespace std;
int n, a, b;

int main()
{
    cin>> n;
    cin>> a>> b;
    for(int i=a; i<=b; i++){
        if(i%n == 0){
            cout<< "OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3632
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcountll(x)
#define F first
#define S second
#define or_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(), order_of_key()
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int mod=1e9+7;
const double eps=1e-9;
const double PI=acos(-1.0);
 
//ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

// ****************************************************


ll arr[300005];

int main()
{
	int n;
	cin>>n;
	for(int i=0; i<n; i++) scanf("%lld", &arr[i]);
	ll ans=0;
	for(int k=0; k<=60; k++){
		int one=0, zero=0;
		for(int i=0; i<n; i++){
			if(arr[i] & (1ll<<k)) one++;
			else zero++;
		}
		ans=(ans+((((one*1ll*zero)%mod)*((1ll<<k)%mod))%mod))%mod;
		// ans=(ans+((one*1ll*zero)%mod*(1ll<<k)%mod)%mod)%mod;
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560