akhauriyash/Code-Regression huggingface dataset:
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int m = in.nextInt();
        out.println(n*m);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

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

ll a[N];
ll s;
int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		s+=a[i];
	}
	ll ans=1e18;
	ll s0=0;
	for(int i=1;i<n;i++){
		s0+=a[i];
		ans=min(ans,abs(s-s0-s0));
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, r;
    cin >> n >> r;

    if (n >= 10) {
        cout << r << '\n';
    }
    else {
        cout << r + 100 * (10 - n) << '\n';
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)1000000007
// Big two primes 
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int int
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 



int main()
{
    fio;
	
	int n,m;
	in(n);
	in(m);

	int d = (n*(n-1))/2;
	int e = (m*(m-1))/2;
    
    cout<<(d+e)<<"\n";

	rr;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll A[100000];
int main() {
	int N;
	cin >> N;
	ll all = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		all ^= A[i];
	}
	for (int i = 0; i < N; i++) A[i] &= ~all;
	int r = 0;
	for (int i = 59; i >= 0; i--) {
		int idx = -1;
		for (int j = r; j < N; j++) {
			if (A[j] & (1LL << i)) {
				idx = j;
				break;
			}
		}
		if (idx == -1) continue;
		swap(A[r], A[idx]);
		for (int j = 0; j < N; j++) {
			if (j == r) continue;
			if (A[j] & (1LL << i)) A[j] ^= A[r];
		}
		r++;
	}
	ll ans = 0;
	for (int i = 0; i < r; i++) ans ^= A[i];
	ans = ans * 2 + all;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 21, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll compatible[N], dp[1<<N], n;

ll f(int girls_available) {
    if (girls_available == 0) return 1;
    if (dp[girls_available] != -1) return dp[girls_available];

    ll ans = 0;
    int already_matched = n - __builtin_popcount(girls_available);
    for (int j = 0; j < N; ++j)
        if ((girls_available & compatible[already_matched]) & (1 << j))
            ans = add(ans, f(girls_available & (~(1 << j))));

    return dp[girls_available] = ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    rep (i, 0, n) rep (j, 0, n) { bool x; cin >> x; compatible[i] |= x << j; }
    memset(dp, -1, sizeof(dp));
    cout << f((1<<n)-1) << endl;
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
LL n,k,dp[200005],x,fen[300005],rr;
LL ans;
map<LL,LL>mm;
set<LL>s;
set<LL>::iterator it;
void up(int idx,int val)
{
    while(idx<300005)
    {
        fen[idx]+=val;
        idx+=idx&(-idx);
    }
    return;
}
int ss(int idx)
{
    int re=0;
    while(idx>0)
    {
        re+=fen[idx];
        idx-=idx&(-idx);
    }
    return re;
}
int main()
{
    scanf("%lld %lld",&n,&k);
    s.insert(0);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        dp[i]=dp[i-1];
        dp[i]+=(x-k);
        s.insert(-dp[i]);
    }
    it=s.begin();
    while(it!=s.end())
    {
        rr++;
        mm[-(*it)]=rr;
        it++;
    }
    for(int i=0;i<=n;i++)up(mm[dp[i]],1);
    for(int i=0;i<n;i++)
    {
        up(mm[dp[i]],-1);
        ans+=ss(mm[dp[i]]);
    }
    printf("%lld",ans);
}


Measured memory_bytes: 28760
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[N],b[N],c[N];
int main()
{
    int n,ans=0;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)a[i]=lower_bound(b+1,b+n+1,a[i])-b;
    for(int i=1;i<=n;i++)c[a[i]]=i;
    for(int i=1;i<=n;i++)if(abs(c[i]-i)%2)ans++;
    cout<<(ans+1)/2<<endl;
}


Measured memory_bytes: 8832
function Main(input){
    [a,b]=input.split(' ');
    a=parseInt(a);
    b=parseInt(b);
    if (a>b){
        console.log('a > b');
    }else if (a<b){
        console.log('a < b');
    }else{
        console.log('a == b');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15104
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	double a;
	for (; cin >> a;)
	{
		double a0 = a;
		double sum = a;
		for (int i = 2; i <= 10; i++)
		{
			if (i % 2 == 0)
			{
				a0 = a * 2;
				sum += a0;
			}
			else
			{
				a0 = a / 3;
				sum += a0;
			}
			a = a0;
		}

		cout << fixed << setprecision(8) << sum << endl;
	}
}


Measured memory_bytes: 3268
N, M = map(int, input().split())
L = list(map(int, input().split()))

L.sort()
dist = [0 for _ in range(M-1)]
for i in range(M-1):
    dist[i] = L[i+1] - L[i]
    
dist.sort(reverse=True)
res = sum(dist[N-1:])
print(res)



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

int main(){
    long long n, m;
    cin >> n >> m;

    if(n == 1 && m == 1)        cout << 1 << endl;
    else if(min(n,m) == 1)      cout << max(n,m)-2 << endl;
    else                        cout << (m-2)*(n-2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define Point pair<double, double>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  int s; cin >> s;
  unordered_map<int, int> mp;
  mp[s] = 1;
  int before = s;
  int pos = 2;
  while(true) {
    if (before & 1) {
      s = 3*before+1;
    } else {
      s = before/2;
    }
    if (mp[s] > 0) {
      cout << pos << endl;
      return 0;
    } else {
      mp[s] = pos;
    }
    before = s;
    pos++;
  }
}


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

int main(){
    int n;
    double a[1000] = {};
    cin >> n;
    for (int i = 0; i < n;i++)
        cin >> a[i];
    double sum = 0;
    for (int i = 0; i < n;i++)
    {
        sum += (1 / a[i]);
    }
    sum = 1 / sum;
    cout << sum;
}

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

using namespace std;

#define ll long long
#define PI acos(-1.0)

ll dp[105][105005];
ll n, w, weight[105], cost[105];

ll func(ll indx, ll rest)
{
	if(indx > n) 
	{
		if(rest == 0) return 0;
		else return 10000000000;
	}
	if(rest == 0) return 0;
	if(dp[indx][rest] != -1) return dp[indx][rest];
	
	ll ans1 = 10000000000, ans2 = 10000000000;
	if(rest-cost[indx] >= 0)
	{
	    ans1 = weight[indx] + func(indx+1,rest-cost[indx]);
	}
	ans2 = func(indx+1,rest);
	return dp[indx][rest] = min(ans1,ans2); 
}


int main()
{
	
	scanf("%lld %lld", &n, &w);
	for(ll i = 1;i <= n; i++) scanf("%lld %lld", &weight[i],&cost[i]);
	memset(dp,-1,sizeof(dp));
	for(ll i = 100000; i >= 0; i--)
	{
		ll ans = func(1,i);
		if(ans <= w)
		{
			printf("%lld\n",i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 86400
#include<stdio.h>
#define MAX 500000
#define mugen 2000000000

int S[MAX],L[MAX/2+2],R[MAX/2+2],count;

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int main(){
  int n,i;
  count = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  
  mergeSort(S,0,n);
  
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(int *S,int left,int mid,int right){
  int i,j,k;
  int l,r;

  l=mid-left;
  r=right-mid;

  for(i=0;i<l;i++) L[i]=S[left+i];
  for(i=0;i<r;i++) R[i]=S[mid+i];

  L[l]=mugen;
  R[r]=mugen;

  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]) S[k]=L[i++];
    else S[k]=R[j++];
  }
}

void mergeSort(int *S,int left,int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}



Measured memory_bytes: 5764
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
#include <stack>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;



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

    int n; cin >> n;
    vector<int> h(n); REP(i,n) cin >> h[i];

    vector<int> L(n), R(n); // L index, R index
    stack<int> st; // index
    for(int i=0; i < n; ++i) {
        while(st.size() && h[st.top()] >= h[i]) st.pop();
        L[i] = st.size() == 0 ? 0 : (st.top() + 1);
        st.push(i);
    }

    while(st.size()) st.pop();
    for(int i=n-1; i >= 0; --i) {
        while(st.size() && h[st.top()] >= h[i]) st.pop();
        R[i] = st.size() == 0 ? n : st.top();
        st.push(i);
    }


    long long res = 0;
    for(int i=0; i < n; ++i)
        res = max(res, 1LL * h[i] * (R[i] - L[i]));

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=3e5+100,mod=1e9+7;
ll dp[N][5][3],pd[N];
int32_t main(){
    string s;
    cin >> s;
    ll n=s.size();
    dp[0][0][0]=1;
    for (int i=0;i<n+1;i++){
                if (s[i]=='?' || s[i]=='0')
                    dp[i+1][0][1]+=pd[i];
                if (s[i]=='?' || s[i]=='1')
                    dp[i+1][1][0]+=pd[i];
        for (int j=0;j<5;j++){
               // cout << pd[i] << endl;
            for (int k=0;k<3;k++){
                dp[i][j][k]%=mod;
               // cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
                pd[i]%=mod;
                if (s[i]=='?' || s[i]=='0'){
                    ll a=j,b=k;
                    b++;
                    while(b>=3) b-=2;
                    dp[i+1][a][b]+=dp[i][j][k];
                }
                if (s[i]=='?' || s[i]=='1'){
                    ll a=j,b=k;
                    if (j==0 && b==1){
                        pd[i+1]+=dp[i][j][k];
                    }
                    if (b==2){
                        dp[i+1][j][1]+=dp[i][j][k];
                    }
                    if (b==1 && a>0){
                        dp[i+1][a][0]+=dp[i][j][k];
                    }
                    if (b==0){
                        a++;
                        a=min(a,(ll)4);
                        dp[i+1][a][0]+=dp[i][j][k];
                    }
                }


            }
        }

    }
    n--;
    ll ans=dp[n+1][4][0]+dp[n+1][4][1]+dp[n+1][4][2]+dp[n+1][3][0]+dp[n+1][3][1]+dp[n+1][3][2]+dp[n+1][2][0]+dp[n+1][2][1]+dp[n+1][1][0];
    cout << ans%mod << endl;
}


Measured memory_bytes: 41256
H,W,K = list(map(int, input().split()))
S = []
for i in range(H):
  S.append(input())
  
A = [[0 for i in range(W)] for j in range(H)]

pt = 1
for i in range(H):
  if S[i][:] == "." * W:
    if i > 0:
      A[i][:] = A[i-1][:]
      continue
      
  firstFlg = True
  for j in range(W):
    if firstFlg and S[i][j] == "#":
      for k in range(0,j+1):
        A[i][k] = pt
      pt += 1
      firstFlg = False
    elif S[i][j] == "#":
      A[i][j] = pt
      pt += 1
    else:
      A[i][j] = pt-1

for i in range(H-1,-1,-1):
  if A[i] == [0 for j in range(W)]:
    A[i][:] = A[i+1][:]

for i in range(H):
  print(" ".join(list(map(str,A[i]))))

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c1=0,c=0;
    long long n,i,a1,a2;
    scanf("%lld",&n);
    i=1;
    while(i*i<=n)
    {
        if(n%i==0)
        {
            a1=i;
            a2=n/i;
        }
        i++;
    }
    while(a1)
    {
        a1/=10;
        c++;
    }
    while(a2)
    {
        a2/=10;
        c1++;
    }
    printf("%d",max(c,c1));
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(' ').map { it.toInt() }
    var ans = Int.MAX_VALUE
    if (x <= y) ans = Math.min(ans, y - x)
    if (-x <= y) ans = Math.min(ans, 1 + y + x)
    if (x <= -y) ans = Math.min(ans, -y - x + 1)
    if (-x <= -y) ans = Math.min(ans, -y + x + 2)
    println(ans)
}

Measured memory_bytes: 38248
h,w=map(int,input().split())
n=int(input())
a=[int(i) for i in input().split()]

c=[0 for _ in range(h*w)]

x=0
for i in range(1,n+1):
    c[x:x+a[i-1]]=[i]*(a[i-1])
    x+=a[i-1]

for i in range(0,h):
    if i%2==0:
        for j in range(w*i,w*(i+1)):
            print(c[j],end=" ")
    else:
        for j in range(w*(i+1)-1,w*i-1,-1):
            print(c[j],end=" ")
    print()


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

using namespace std;

const int MAXN = 1000000 + 10;
int n;
int a[MAXN];

int t[] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 50000};
int k[9];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < 8; j++) {
            if (a[i] >= t[j] && a[i] < t[j+1]) {
                k[j] = 1;
            }
        }
        if (a[i] >= t[8]) {
            k[8]++;
        }
    }
    //sort(a, a+n);

    int r = 0;
    for (int i = 0; i < 8; i++) r += k[i];
    int mi = (r == 0) ? 1 : r;
    int ma = r + k[8];

    cout << mi << " " << ma << "\n";


    return 0;
}


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

int main()
{
  long int n,m;
  cin >> n >> m;
  vector<pair<int,int> > v;
  long int a,b,c;
  for(int i=0;i<n;++i){
    cin >> a;
    v.push_back(make_pair(a,1));
  }
  for(int i=0;i<m;++i){
	cin >> b >> c;
    v.push_back(make_pair(c,b));
  }
  sort(v.begin(),v.end(),greater<>());
  long int sum=0;
  long int cnt=n;
  for(int i=n;i>0 && cnt>0;--i){
    if(cnt-v[n-i].second>=0) sum += (long)v[n-i].first*v[n-i].second;
    else sum += v[n-i].first*cnt;
    cnt-=v[n-i].second;
  }
  cout << sum << endl;
  return 0;
}

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

int main(void){
	int W,a,b;
	cin >> W >> a >> b;
	int ans;
	if( (a+W)<b){
		ans = b - (a+W);
	}else if(a<=b && b<=(a+W))ans = 0;
	else if(a<=(b+W)&&(b+W)<=(a+W))ans=0;
	else ans = a- (b+W);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    bool greater=false;
    bool lower=false;
    for(int i=0;i<min((int)s.size(),(int)t.size());i++)
    {
        if(s[i]<t[t.size()-i-1])
        {
            lower=true;
            break;
        }
        if(s[i]>t[t.size()-i-1])
        {
            greater=true;
            break;
        }
    }
    if(greater){
        cout<<"No\n";
    }
    else
    if(lower){
        cout<<"Yes\n";
    }
    else
    {
        if(s.size()>=t.size()){
            cout<<"No\n";
        }
        else
        {
            cout<<"Yes\n";
        }
    }
}

Measured memory_bytes: 3592
n, m = map(int, input().split())
p = 1000000007
dp = [0] * n
c = 0
for _ in range(m):
    a = int(input())
    dp[a - 1] = -1
for i in range(1, n):
    if i <= 1:
        if dp[0] != -1 and dp[1] != -1:
            dp[0], dp[1] = 1, 2
        elif dp[0] == -1 and dp[1] != -1:
            dp[0], dp[1] = 0, 1
        elif dp[0] != -1 and dp[1] == -1:
            dp[0], dp[1] = 1, 0
        else:
            c = -1
    if i >= 2 and dp[i] != -1:
        if dp[i - 1] == -1 and dp[i - 2] != -1:
            dp[i] = dp[i - 2]
        elif dp[i - 1] != -1 and dp[i - 2] == -1:
            dp[i] = dp[i - 1]
        elif dp[i - 1] != -1 and dp[i - 2] != -1:
            dp[i] = (dp[i - 1] + dp[i - 2]) % p
        else:
            c = -1
if c == -1:
    print(0)
elif n == 1:
    print(1)
else:
    print(dp[n - 1])

Measured memory_bytes: 6900
#include <stdio.h>

int min(int a,int b){return a>b ? b : a;}
int max(int a,int b){return a>b ? a : b;}

int main(void){
    int H,W,d;
    scanf("%d %d %d",&H,&W,&d);
    char unko[H][W];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++){
        int po;
        po=i+j;
        po-=d;
        while(po<0)po+=d*2;
        po%=d*2;
        int buri;
        buri=i-j;
        buri-=d;
        while(buri<0)buri+=d*2;
        buri%=d*2;
        if(po<d&&buri<d)unko[i][j]='R';
        else if(po>=d&&buri<d)unko[i][j]='G';
       else  if(po<d&&buri>=d)unko[i][j]='B';
       else  if(po>=d&&buri>=d)unko[i][j]='Y';
       else unko[i][j]='N';
    }
    for(int i=0;i<H;i++){for(int j=0;j<W;j++)printf("%c",unko[i][j]);printf("\n");}
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<60)

signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n)cin>>a[i];

    double dp[501][502];
    rep(i,501)rep(j,502)dp[i][j] = -INF;
    dp[0][0] = 0;

    vector<int> rs(n+1,0);
    rep(i,n)rs[i+1] = a[i];
    for(int i=1;i<=n;i++){
        rs[i] += rs[i-1];
    }

    auto ave = [&](int l,int r){
        int sum = rs[r] - rs[l];
        return (double)sum/(r-l);
    };

    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=1;k<=n;k++){
                if(i-k<0 or j-(k-1)<0)break;
                dp[i][j] = max(dp[i][j],dp[i-k][j-(k-1)]+ave(i-k,i));
            }
        }
    }

    double ans = -INF;
    for(int j=n-m;j<=n;j++){
        ans = max(ans,dp[n][j]);
    }
    printf("%.20lf\n",ans);
}



Measured memory_bytes: 5200
#include<stdio.h>

int main(void) {
   char s[4];
   int cnt = 0;

   scanf("%s", s);
   
   for(int i = 0; i < 3; i++) {
      if(s[i] == s[i+1]) {
         cnt++;
      }
   }

   if(cnt == 0) {
      printf("Good\n");
   } else {
      printf("Bad\n");
   }
   return 0;
}


Measured memory_bytes: 1660
import java.util.Scanner;

class Main {

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

        while (n != 0) {
            int c[] = new int[10];
            int i = 0;
            int g = 0;
            for (i = 0; i < 10; i++) {
                int ice = i;
                c[ice] = 0;
            }
            for (g = 0; g < n; g++) {
                int ice = scan.nextInt();
                c[ice] += 1;
            }
            for (int f = 0; f < 10; f++) {
                if (c[f] == 0) {
                    System.out.println("-");
                } else {
                    for (int b = 0; b < c[f]; b++) {
                        System.out.print("*");

                    }
                    System.out.println("");
                }

            }
            n = scan.nextInt();
        }

    }

}



Measured memory_bytes: 61168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi 2*acos(0.0)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cin >> ar[i];
		}
		int ans =0 ;
		for(int i =0 ;i < n ;i++){
			for(int j = i+1 ;j < n ;j++){
				ans+=ar[i]*ar[j];
			}
		}
	cout << ans ;
	}
	
	return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>
#include<string.h>
int N,T,L,B,E[101],i,j,k,t,p;
double dp[101][101];
int main()
{
	for(;scanf("%d%d%d%d",&N,&T,&L,&B),N;)
	{
		memset(E,0,sizeof(E));
		memset(dp,0,sizeof(dp));
		for(i=0;i<L;E[t]=1,i++)scanf("%d",&t);//1 ha lose
		for(i=0;i<B;E[t]=2,i++)scanf("%d",&t);//2 ha back
		for(i=0;i<T;i++)
			for(j=0;j<N;dp[i][j]/=6,j++)
				for(k=1;k<7;k++)
				{
					p=j+k>N?(2*N-j-k):j+k;
					if(p==N)
						dp[i][j]+=1;
					else if(E[p]==1)
					{
						if(i>1)
							dp[i][j]+=dp[i-2][p];
					}
					else if(E[p]==2)
						dp[i][j]+=dp[i-1][0];
					else
						dp[i][j]+=dp[i-1][p];
				}
		printf("%f\n",dp[T-1][0]);
	}
	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int A,B; cin >> A >> B;
    if(B % A == 0) cout << A+B << endl;
    else cout << B-A << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int a,b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a*b });
	return(0);
}


Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]

def f():
    a = [(-1, 0), (0, -1), (0, 1), (1, 0)]
    for h in range(H):
        for w in range(W):

            if s[h][w] == "#":
                f = True
                for x, y in a:
                    h2 = h + x
                    w2 = w + y
                    if 0 <= h2 < H and 0 <= w2 < W:
                        if s[h2][w2] == "#":
                            f = False
                if f:
                    print("No")
                    return
    print("Yes")
    return

f()

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int a,b;cin >> a >> b;
  cout << max(0,a-(b*2)) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N) {
        if (i%2==0 && a[i]%2==1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
int i,j,n,m,t,k;
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=n;i>1;i--)
{
	if(a[i-1]>a[i]){a[i-1]--;
	if(a[i-1]>a[i])
	{cout<<"No";
	return 0;
	}
	}
}
cout<<"Yes";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	string t="keyence";
	rep(i,n)FOR(j,i,n){
		string now="";
		rep(k,n){
			if(i<=k && k<j) continue;
			now.push_back(s[k]);
		}
		if(now==t){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    double N, K;
    cin >> N >> K;
    
    vector<double> p(N);
    REP(i, N) cin >> p[i];

    double temp = 0;
    double sum = 0;
    for(int i = 0; i < K; i++) {
        sum += p[i];
    }
    temp = sum;
    for(double i = K; i < N; i++) {
        temp -= p[i-K];
        temp += p[i];
        if (temp > sum) sum = temp;
    }
    
    double ans = 0;
    ans = (sum + K) / 2;
    printf("%.15f\n", ans);

    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
struct edge{int to,cost;};
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
ll i,j;

ll n,m,ans=0;
ll a,b,c,k,num=0;
ll d[500005];

int main(){
	cin>>n>>a>>b;
	memset(d,0,sizeof(d));
	c = a*b;
	if((a+b>n+1) || (a*b<n)){
		cout<<-1;
	}else if(a!=1){
		d[1]=b;
		n-=b;

		for(i=2;i<=a;i++){
			d[i]=n/(a-1);
		}
		for(i=2;i<=1+n%(a-1);i++){
			d[i]++;
		}
		for(i=1;i<=a;i++){
			num += d[i];
			for(j=1;j<=d[i];j++){
				cout<<num-j+1<<" ";
			}
		}
	}else{
		for(i=n;i>=1;i--){
			cout<<i<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repd(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto& a:x)
#define all(c) c.begin(), c.end()
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX 100007
 
typedef vector<int> vi;
typedef pair<int,int> pii;


int32_t main()
{
  int flag=0,n;
  string s,t,y;
  cin>>s>>t;
  n=s.size();
  if(s==t)
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  repa(i,1,n)
  {
    y=s[n-1];
    y+=s.substr(0,n-1);
    if(y==t)
    {
      flag=1;
      break;
    }
    s=y;
  }
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;

}

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


int main(void)
{
    int N;
    cin>>N;
    long long sum=0;
    int l,r;
    for(int i=1;i<=N;i++)
    {
        cin>>l>>r;
        sum+=(r-l+1);
    }
    cout <<sum <<endl;
    return 0;
}


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


ans = 0
now = 0
sum = 0
E = [0] * n

for i in range(n):
    E[i] = 0.5 + p[i]/2
    now += E[i]
    if(i == k-1):
        ans = now
    elif(i >= k):
        now -= E[i-k]
        ans = max(ans,now)

print(ans)

Measured memory_bytes: 71792
#include <iostream>
#include <vector>
using namespace std;
int sum_max = 0;

int func(vector<int> A, int n, int max, int q, int min, int k, vector<int> a, vector<int> b, vector<int> c, vector<int> d){
    if(n == k){
        int sum = 0;
        for(int i = 0; i < q; i++){
            if(A[b[i]-1]-A[a[i]-1] == c[i]) sum += d[i];
        }

        if(sum > sum_max){
            sum_max = sum;
            return 0;
        }
    }
    else{
        for(int i = min; i <= max; i++){
            A[k] = i;
            func(A, n, max, q, i, k+1, a, b, c, d);
        }
    }
    return 0;
}

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for(int i = 0; i < q; i ++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    vector<int> A(n);
    func(A, n, m, q, 1, 0, a, b, c, d);
    cout << sum_max;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s;
    cin >> s;
    bool ans;
    if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3] and s[3] == s[0]) ans = 0;
    else if(s[0] == s[1] and s[2] == s[3]) ans = 1;
    else if(s[0] == s[2] and s[1] == s[3]) ans = 1;
    else if(s[0] == s[3] and s[1] == s[2]) ans = 1;
    else ans = 0;
    cout << (ans ? "Yes" : "No") << endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define rep(i,a,b)  for( i=a;i<=b;i++)
#define re(i,a,b)  for( i=a;i>=b;i--)
#define pie  2 * acos(0.0)
using namespace std;
void solve();
int main()
{
	
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
 //cin >> T;
 while(T--)
 {solve();
}	 
}
void solve()
{
    int n;
    cin>>n;
    cout<<n+n*n+n*n*n;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, a, mn, mx;
    deque<int> q;
    vector<pair<int, int>> res;
    cin>>n;
    rep(i, n) {
        cin>>a;
        q.push_back(a);
    }
    sort(all(q));
    mx = q.back();
    mn = q.front();
    q.pop_back();
    q.pop_front();
    while(q.front() < 0 && !q.empty()) {
        res.push_back({mx, q.front()});
        mx -= q.front();
        q.pop_front();
    }
    while(!q.empty()) {
        res.push_back({mn, q.back()});
        mn -= q.back();
        q.pop_back();
    }
    cout<<mx - mn<<endl;
    each(p, res) {
        cout<<p.first<<' '<<p.second<<endl;
    }
    cout<<mx<<' '<<mn<<endl;
}


Measured memory_bytes: 4468
import java.util.Scanner;

public class Main {
    public static int [][]dp;
    public  static  void main(String []args){
        Scanner sc= new Scanner(System.in);
        int N=sc.nextInt();
        int W= sc.nextInt();
        int []w= new int[N];
        int []v= new int[N];
        dp= new int[N+1][W+1];
        for(int i=0;i<N;i++){
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
        }

        System.out.println(maxValue(w,v,W,N));
    }
    static long maxValue(int []w,int []v,int W,int N){
        long [][]dp= new long[N+1][W+1];
        for (int i=0;i<=N;i++){
            for(int j=0;j<=W;j++){
                if(i==0||j==0)
                    dp[i][j]=0;
                else if(w[i-1]<=j)
                    dp[i][j]=Math.max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
        return dp[N][W];
    }
}


Measured memory_bytes: 162516
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  if((a+b)%2==0) OUT((a+b)/2);
  else OUT("IMPOSSIBLE");
}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <math.h>

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v;

    for ( long long int i = 0; i <= n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
    }

    if ( n == 0 ) {
        if ( v[0] != 1 ) {
            cout << -1 << endl;
        } else {
            cout << 1 << endl;
        }
        return 0;
    }

    if ( v[0] != 0 ) {
        cout << -1 << endl;
        return 0;
    }

    vector< mp::cpp_int > w;
    w.push_back( 1 );
    mp::cpp_int cnt = 1;
    for ( long long int i = 1; i <= n; i++ ) {
        cnt *= 2;
        cnt -= v[i];
        if ( cnt < 0 ) {
            cout << -1 << endl;
            return 0;
        }
        w.push_back( cnt );
    }
    if ( cnt > 0 ) {
        for ( long long int i = n; i >= 1; i-- ) {
            w[i] -= cnt;
            if ( w[i] < 0 ) {
                cout << -1 << endl;
                return 0;
            }
            if ( cnt <= w[i-1] ) {
                cnt = 0;
                break;
            }
            cnt -= w[i-1];
        }
        if ( cnt > 0 ) {
            cout << -1 << endl;
            return 0;
        }
    }

    mp::cpp_int ans = 0;
    for ( long long int i = 0; i <= n; i++ ) {
        ans = ans + v[i];
        ans = ans + w[i];
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 619280
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "a.cpp"

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

  n %= 10;

  if (n == 3) {
    puts("bon");
  } else {
    for (auto&& i : {2, 4, 5, 7, 9}) {
      if (i == n) {
        puts("hon");
        return 0;
      }
    }

    puts("pon");
  }
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int a[300010];
int main(){
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		a[t]=t;
	}
	for(int i=1;i<=300000;i++){
		a[i]=max(a[i],a[i-1]);
	}
	
	while(q--){
		int ans=0;
		int t;
		scanf("%d",&t);
		for(int i=t;i<=300000;i+=t){
			ans=max(ans,a[i-1]%t);
		}
		ans=max(ans,a[300000]%t);
		printf("%d\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 2400
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use num_integer::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let a: usize = read!();
    let b: usize = read!();
    let c: usize = read!();

    let ans = if a.is_even() || b.is_even() || c.is_even() {
        0
    } else {
        *[a * b, a * c, b * c].iter().min().unwrap()
    };

    println!("{}", ans);
}


Measured memory_bytes: 2068
while True:
    count = 0;
    N, X = map(int, input().split());
    if N ==0 and X ==0:
        break;
    for i in range(1,N+1):
        for j in range(1,N+1):
            if i == j:
                continue;
            for k in range(1,N+1):
                if i == k:
                    continue;
                if j == k:
                    continue;
                if i + j + k == X:
                    count += 1;
    print(int(count/6));


Measured memory_bytes: 5592
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val C = IntArray(N - 1)
    val S = IntArray(N - 1)
    val F = IntArray(N - 1)

    (0..(N-2)).forEach {
        val (c, s, f) = readLine()!!.split(" ").map { it.toInt() }
        C[it] = c
        S[it] = s
        F[it] = f
    }

    // O(N)
    (0..(N-2)).forEach {i ->
        var t = S[i]
        var station = i
        // Simulate
        // O(N)
        while (station != N - 1) {
            // Wait until the next train comes
            // Find a time quickly that meats t>=S && T%F = 0
            if (t < S[station]) {
                t = S[station]
            } else if (t.mod(F[station]) != 0) {
                // O(100)
                while (t.mod(F[station]) != 0) {
                    t++
                }
            }
            // Train leaves
            t += C[station]
            station++
            // Arrive
        }
        println(t)
    }

    // Print for Nth station
    println(0)
}


Measured memory_bytes: 37936