akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        int N = sc.nextInt();

        int[] a = new int[N];

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }

        boolean flag = true;
        for(int i=0; i<N; i++){
            if(a[i]%2 == 0){
                if(a[i]%3 == 0 || a[i]%5 == 0){
                } else {
                    flag = false;
                }
            }
        }
        
        if(flag) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int n,m,i,j,k;
  while(scanf("%d %d",&n,&m),n||m){
    double d[110][110],max,t[2][100]={0};
    for(i=0;i<n;i++){
      for(j=0;j<n;j++)scanf("%lf",&d[i][j]);
      t[1][i]=1;
    }
    for(i=1;i<m;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++){
	  if(t[1-i%2][k]<t[i%2][j]*d[j][k])t[1-i%2][k]=t[i%2][j]*d[j][k];
	}
      }
    }
    for(i=max=0;i<n;i++){
      if(max<t[m%2][i])max=t[m%2][i];
    }
    printf("%.2f\n",max);
  }
  return 0;
}

Measured memory_bytes: 756
import java.util.*;  
public class Main{
   public static void main(String[] args){
	   Scanner sc = new Scanner(System.in);
	   int N = sc.nextInt();
	   int i;
	   double pow=1;
	   double ans=1;
 for(i = 1; i <= N; i++){
     pow = pow * i;
     ans = pow % (Math.pow(10.0,9.0)+7.0);
     pow=ans;
 }
 System.out.println((int)ans);
     }
 }

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) cout << 'x';
}	

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

using namespace std;
#define ll long long
#define M 1000000007


int main()
{
    ll n;
    cin>>n;
    vector<double>arr(n+1);
    for(ll i=1;i<=n;i++)
    {
        double a;
        cin>>a;
        arr[i]=a;
    }
    double dp[n+1][n+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=n;j++)
            dp[i][j]=0;
    }
    dp[0][0]=1;
    double ans=0;
    ll k=((n+1)/2);
    
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=i;j++)
        {
            dp[i][j]+=dp[i-1][j-1]*(arr[i]);
            dp[i][j-1]+=dp[i-1][j-1]*(1-arr[i]);
            
        }
    }
    for(ll i=k;i<=n;i++)
    {
        ans+=dp[n][i];
    }
   cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 70528
import sys
sys.setrecursionlimit(2000000000)
input=lambda : sys.stdin.readline().rstrip('\n')

n=int(input())
h=list(map(int,input().split()))

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    dp[n] = min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))
    return dp[n]

print(cost(n-1))


Measured memory_bytes: 93592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N,B;
    int total = 0;
    cin >> N;
    vector<int> A(N, 0);
    vector<int> C(N - 1, 0);

    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++){
        cin >> B;
        total += B;
    }
    for(int i = 0; i < N - 1; i++) cin >> C[i];

    for(int i = 0; i < N - 1; i++){
        if(A[i] + 1 == A[i + 1]){
            total += C[A[i] - 1];
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int r[N], c[N];
int32_t main()
{
    IOS;
    int n, q;
    cin>>n>>q;
    set <pii> row, col;
    row.insert({n, n});
    col.insert({n, n});
    while(q--)
    {
        int typ, x;
        cin>>typ>>x;
        if(typ==1)
        {
            pii p={x, -1};
            auto it=row.lower_bound(p);
            c[x]=(*it).ss-1;
            while(1)
            {
                p={c[x], INF};
                auto it=col.upper_bound(p);
                if(it==col.begin())
                break;
                it--;
                pii p1=(*it);
                if(p1.ss<=x)
                break;
                col.erase(p1);
            }
            p={c[x], -1};
            it=col.upper_bound(p);
            if((*it).ss>x)
            col.insert({c[x], x});
        }
        else
        {
            pii p={x, -1};
            auto it=col.lower_bound(p);
            r[x]=(*it).ss-1;
            while(1)
            {
                p={r[x], INF};
                auto it=row.upper_bound(p);
                if(it==row.begin())
                break;
                it--;
                pii p1=(*it);
                if(p1.ss<=x)
                break;
                row.erase(p1);
            }
            p={r[x], -1};
            it=row.upper_bound(p);
            if((*it).ss>x)
            row.insert({r[x], x});
        }
    }
    int ans=((n-2)*(n-2));
    for(int i=1;i<n;i++)
    {
        ans-=(r[i]+c[i]);
        if(r[i])
        ans++;
        if(c[i])
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 11368
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
inline int gcd(int a,int b)
{
	if(a==0)return b;
	else return gcd(b%a,a);
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a=read(),b=read();
	printf("%lld\n",1LL*a/gcd(a,b)*b);
	return 0;
}

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


// N / A == B
// N / B == A

int countDivisor(int N){
	int ans = 0;
	for (int i = 1; i * i <= N; i++)
	{
		if (N % i == 0) {
			if (i * i == N) ans++;
			else ans += 2;
		}
	}
	return ans;
}

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i += 2)
	{
		if (countDivisor(i) == 8) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
while True :
    w = int(input())
    if w == -1 :
        break
    if w < 10 :
        print(4280-1150)
    elif w < 20 :
        print(4280-(1150+(w-10)*125))
    elif w < 30 :
        print(4280-(1150+10*125+(w-20)*140))
    else :
        print(4280-(1150+10*125+10*140+(w-30)*160))


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

int main() {
	string s;
	cin>>s;
	if(s[0] == s[s.size()-1]) {
		if(s.size()%2) puts("Second");
		else puts("First");
	}
	else {
		if(s.size()%2) puts("First");
		else puts("Second");
	}
	return 0;
}

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


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

    ll sum = 1;
    int a = 7 % k;
    int tmp = a;
    bool flg = true;
    while (a) {
        a = 10 * a + 7;
        a %= k;
        if (sum > k) {
            flg = false;
            break;
        }
        sum++;
    }
    if (flg) {
        cout << sum << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main () {
    int k;
    cin >> k;
    int count = 0;
    for (int i=1; i<=k-1; i++) {
        for (int j=i+1; j<=k; j++) {
            if (i%2 ==0 && j%2 ==1) ++count;
            if (i%2 ==1 && j%2 ==0) ++count;
        }
    }
    cout << count << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int x, n, m, ans;
    cin >> x >> n;
    vector<bool> data(102, false);
    bool c=false;
    if(n == 0) {
        ans = x;
    } else {
        REP(i, n) {
            cin >> m;
            data.at(m) = true;
        }
        REP(i, 100) {
            if(data.at(x-i) == false) {
                ans = x-i;
                c = true;
            }
            if(c) break;
            if(data.at(x+i) == false) {
                ans = x+i;
                c = true;
            }
            if(c) break;
        }
    }
    cout << ans << endl;
}


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


signed main(){
	int n,l;
	cin >> n >> l;
	int ans = l*n + (n - 1)*n/2;
	int low = LONG_MAX;
	for(int i = 1 ; i <= n ; i ++){
		if(abs(l + i - 1) < abs(low)) low = (l + i - 1);
	}
	cout << ans - low;
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
int a[105];

int main()
{
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int mx = -1e9;
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			int diff = abs(a[i]-a[j]);
			mx = max(mx, diff);
		}
	}
	cout << mx << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

void setDepth(int,int);
int setHeight(int);
int getSebling(int);
void print(int);

typedef struct{
  int parent;
  int left;
  int right;
}node;

node t[MAX];
int n,d[10000],h[10000];

int main(){
  int i,id,l,r,root=0;
  
  scanf("%d",&n);

  for(i=0;i<=n-1;i++){
    t[i].parent=NIL;
  }

  for(i=0;i<=n-1;i++){
    scanf("%d%d%d",&id,&l,&r);
    t[id].left=l;
    t[id].right=r;
    if(l!=NIL)t[l].parent=id;
    if(r!=NIL)t[r].parent=id;
  }

  for(i=0;i<=n-1;i++){
    if(t[i].parent==NIL)root=i;
  }

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<=n-1;i++){
    print(i);
  }
  return 0;
}


void setDepth(int u,int p){
  d[u]=p;
  if(t[u].left!=NIL)setDepth(t[u].left,p+1);
  if(t[u].right!=NIL)setDepth(t[u].right,p+1);
}


int setHeight(int u){
  int h1,h2;
  h1=h2=0;
  if(t[u].left!=NIL)h1=setHeight(t[u].left)+1;
  if(t[u].right!=NIL)h2=setHeight(t[u].right)+1;
  return h[u]=(h1>h2 ? h1:h2);
}


int getSebling(int u){
  if(t[u].parent==NIL)return NIL;
  if(t[t[u].parent].left!=u&&t[t[u].parent].left!=NIL)
    return t[t[u].parent].left;
  if(t[t[u].parent].right!=u&&t[t[u].parent].right!=NIL)
    return t[t[u].parent].right;
  return NIL;
}


void print(int u){
  int deg=0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",t[u].parent);
  printf("sibling = %d, ",getSebling(u));
  if(t[u].left!=NIL)deg++;
  if(t[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",d[u]);
  printf("height = %d, ",h[u]);
  if(t[u].parent==NIL)printf("root\n");
  else if(t[u].left==NIL && t[u].right==NIL)printf("leaf\n");
  else printf("internal node\n");
}



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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli a, b, k;
    cin3(a,b,k);

    lli c = 0;
    for (lli i = min(a,b); i >= 1; i--) {
        if (a%i == 0 && b%i == 0) {
            c++;
            if (c == k) {
                cout << i << endl;
                return 0;
            }
        }

    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    int i,j,n,Eng[50][26]={},D[26]={};
    char S[51];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",S);
        for(j=0;j<strlen(S);j++) Eng[i][S[j]-97]++;
    }
    for(i=0;i<26;i++) D[i]=Eng[0][i];
    for(i=1;i<n;i++) for(j=0;j<26;j++) if(D[j]>Eng[i][j]) D[j]=Eng[i][j];
    for(i=0;i<26;i++){
        if(D[i]>0){
            for(j=0;j<D[i];j++){
                printf("%c",97+i);
            }
        }
    }
    puts("");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second


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

bool app[50][50][50][50];

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    memset(app,0,6250000);
    string lr[h],rr[h];
    rep(i,h){
      cin>>lr[i]>>rr[i];
    }

    string ans="No";
    int rsx,rsy,lsx,lsy;
    rep(i,h)rep(j,w){
      if(lr[i][j]=='L')lsx=i,lsy=j;
      if(rr[i][j]=='R')rsx=i,rsy=j;
    }

    queue<pair<PI,PI> > Q;
    Q.push(mp(mp(lsx,lsy),mp(rsx,rsy)));

    while(!Q.empty()){
      PI tp=Q.front().F;
      int clx,cly,crx,cry;
      clx=tp.F,cly=tp.S;
      tp=Q.front().S;Q.pop();
      crx=tp.F,cry=tp.S;
      if(lr[clx][cly]=='%' && rr[crx][cry]=='%'){
        ans="Yes";
        break;
      }
      if(lr[clx][cly]=='%' || rr[crx][cry]=='%')continue;
      
      app[clx][cly][crx][cry]=true;

      rep(i,4){
        int nrx=crx+dx[i],nlx=clx+dx[i],nry=cry+dy[i],nly=cly-dy[i];
        if(nrx<0 || nry<0 || nrx>=h || nry>=w || rr[nrx][nry]=='#')nrx=crx,nry=cry;
        if(nlx<0 || nly<0 || nlx>=h || nly>=w || lr[nlx][nly]=='#')nlx=clx,nly=cly;
        if(app[nlx][nly][nrx][nry])continue;
        app[nlx][nly][nrx][nry]=true;
        Q.push(mp(mp(nlx,nly),mp(nrx,nry)));
      }
/*      
      rep(i,h){
        rep(j,w){
          if(clx==i && cly==j)cout<<'L';
          else if(lr[i][j]=='L')cout<<'.';
          else cout<<lr[i][j];
        }
        cout<<" ";
        rep(j,w){
          if(crx==i && cry==j)cout<<'R';
          else if(rr[i][j]=='R')cout<<'.';
          else cout<<rr[i][j];
        }
        cout<<endl;
      }
      cout<<endl;
*/
    }
    cout<<ans<<endl;
  }
}

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

int main(){
	int n=0;
	int m=0;
	int k=0;
	int i=0;
	int j=0;
	int s[200];
	int a[200];
	
	cin>>n;
	cin>>m;
	for(i=0;i<200;i++){
		s[i]=i+1;
		a[i]=0;
	}
	for(i=0;i<m;i++){
		cin>>k;
		if(k==0){
			for(j=0;j<n;j++){
				a[2*j]=s[j];
			}
			for(j=0;j<n;j++){
				a[2*j+1]=s[j+n];
			}
		}else{
			for(j=0;j<2*n;j++){
				if(j<k){
					a[2*n-k+j]=s[j];
				}else{
					a[j-k]=s[j];
				}
			}
		}
		for(j=0;j<2*n;j++){
			s[j]=a[j];
		}
	}
	for(i=0;i<2*n;i++){
		cout<<s[i]<<endl;
	}
}

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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a ;
	cin >> a ;
	cout << a*(1+a*(1+a)) ;
	
	return 0 ;
}


Measured memory_bytes: 3648
str = input()
n, k = str.split(' ')
ni = int(n)
ki = int(k)
str = input()

if ni == ki:
    print(1)
elif ki == 2:
    print(ni-1)
elif ((ni-1)%(ki-1) == 0):
    print(int((ni-1)/(ki-1)))
else:
    print(int((ni-1)/(ki-1))+1)

Measured memory_bytes: 4724
#include <stdio.h>

int
main(int argc, char *argv[])
{
        int a, b;
        int d, r;
        double f;
        
        scanf("%d %d", &a, &b);
        d = a / b;
        r = a % b;
        f = (double)a / (double)b;
        printf("%d %d %f\n", d, r, f);

        return 0;
}

Measured memory_bytes: 636
#include <iostream>

int a[110];
int dp[110][100010];
const int mod = 1e9+7;

int main(){
    int n, k;
    std::cin >> n >> k;
    for(int i = 1; i <= n; i++){
        std::cin >> a[i];
    }
    for(int i = 1; i <= k; i++){
        dp[0][i] = 1;
    }
    for(int i = 0; i <= n; i++){
        dp[i][0] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= k; j++){
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod;
            if(j-a[i]>0){
                dp[i][j] -= dp[i-1][j-a[i]-1];
                dp[i][j] += mod;
                dp[i][j] %= mod;
            }
        }
    }
    int ans = (dp[n][k] - dp[n][k-1]);
    ans = (ans + mod) % mod;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 41216
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

using P = pair<int, int>;
void prp(P& p) {cout << p.first << " " << p.second << endl;}

struct C{
    int pref;
    int num;
};

using PP = pair<int, C>;
int main()
{
    int n, m; cin >> n >> m;
    arr<P> G(n);
    rep(i, m){
        int p, y; cin >> p >> y;
        p--;
        G[p].push_back({y, i});
    }  
    rep(i, n) sort(ALL(G[i]));

    vector<PP> ans;

    rep(i, n) rep(j, G[i].size()){
        P p = G[i][j];
        PP pp;
        pp.first = p.second;

        pp.second.pref = i+1;
        pp.second.num =  j+1;
        ans.push_back(pp);
    }
    sort(ALL(ans), [](const PP &a, const PP &b){
        return a.first < b.first; 
    });

    rep(i, m){
        printf("%06d%06d\n", ans[i].second.pref, ans[i].second.num);
    }
    return 0;}

Measured memory_bytes: 10344
n,m=map(int,input().split())
A=[]
a=list(map(int,input().split()))
for i in range(n):
    A.append([a[i],1])
for i in range(m):
    b,c=map(int,input().split())
    A.append([c,b])
A.sort(key=lambda x:x[0],reverse=True)
#print(A)
l=0
i=0
s=0
while(l<n):
    if l+A[i][1]>n:
        s+=(n-l)*A[i][0]
        break
    l+=A[i][1]
    s+=A[i][1]*A[i][0]
    i+=1
print(s)

Measured memory_bytes: 37804
import sys

n,m = map(int, input().split())

judge = True

a = [-1]*n

if n == 1:
    if m == 0:
        print(0)
        sys.exit()

for i in range(m):
    s,c = map(int, input().split())
    if (a[s-1]==-1) or (a[s-1]==c):
        a[s-1] = c
        
        if (s==1) and (c==0):
            judge = False
            
            if n == 1:
                judge = True
    
    else:
        judge = False

if judge:
    if a[0] == -1:
        a[0] = 1
    
    for i in range(1,n):
        if a[i] == -1:
            a[i] = 0
    
    print(''.join(map(str, a)))

else:
    print(-1)

Measured memory_bytes: 3064
<?php

while(true){
    
    $nums = explode(" ", trim(fgets(STDIN)));
    
    if($nums[0] == "0" && $nums[1] == "0"){
        return;
    }
    
    for($i = 0; $i < $nums[0]; $i++){
        for($j = 0; $j < $nums[1]; $j++){
            echo "#";
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 15268
h, w = map(int, input().split())

m = []
for i in range(h):
    row = list(input())
    m.append(row)

res = 0

mem = [[] for i in range(h)]
dummy = (-1, -1)

for i in range(h):
    _mem = mem[i]
    for j in range(w):
        a = m[i][j]

        if a == "#":
            _mem.append(dummy)
            continue

        c_cnt = 0
        r_cnt = 0

        above = mem[i - 1][j] if i > 0 else dummy
        if above == dummy:
            for ii in range(i + 1, h):
                if m[ii][j] == "#":
                    break
                c_cnt += 1
        else:
            c_cnt = above[0]

        left = mem[i][j - 1] if j > 0 else dummy
        if left == dummy:
            for jj in range(j + 1, w):
                if m[i][jj] == "#":
                    break
                r_cnt += 1
        else:
            r_cnt = left[1]

        res = max(res, c_cnt + r_cnt + 1)
        _mem.append((c_cnt, r_cnt))

print(res)

Measured memory_bytes: 306952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	char a;
	cin >> a;

	if (a >= 'a' && a <= 'z') puts("a");
	else
		puts("A");

	return 0;
}


Measured memory_bytes: 3604
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define cs(ans) setprecision(10)<<fixed<<ans

 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359;
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,X;
	cin>>X>>N;
	vi v(N);
	int mx=-1;
	F0R(x,N)
	{
		// int nb
		cin>>v[x];
		mx=max(mx,v[x]);
	}
	sort(all(v));
	vi res;
	FOR(x,-10000,10100)
	{
		if(!binary_search(all(v),x))
		{
			res.pb(x);
		}
	}
	// pi ans
	pi ans={INT_MAX,INT_MAX};
	F0R(x,sz(res))
	{
		// cout<<abs(X-res[x])<<'-'<<res[x]<<endl;
		if(abs(X-res[x])<ans.f)
		{
			ans.f=abs(X-res[x]);
			ans.s=res[x];
		}
	}
	cout<<ans.s;
	return 0;
	//CHECK CORNER CASES
}
// read the question correctly (ll vs int)
// template by bqi343




Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  if(x) cout << 0 << endl;
  else cout << 1 <<endl;
}


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

#define NMAX 100001
#define MOD 1000000007
#define MAX(a, b) (a > b ? a : b)

using namespace std;

ifstream fin("f.in");
ofstream fout("f.out");

int n, m;
bool isBadStep[NMAX];
int ways[NMAX];

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int aux;
        cin >> aux;
        isBadStep[aux] = 1;
    }
    if(isBadStep[1])
    {
        if(isBadStep[2])
            ways[1] = ways[2] = 0;
        else
        {
            ways[1] = 0;
            ways[2] = 1;
        }
    }
    else
    {
        if(isBadStep[2])
        {
            ways[1] = 1;
            ways[2] = 0;
        }
        else
        {
            ways[1] = 1;
            ways[2] = 2;
        }
    }
    for(int i = 3; i <= n; i++)
    {
        int prevStepOne = i - 1;
        int prevStepTwo = i - 2;
        if(!isBadStep[prevStepOne])
            ways[i] += ways[prevStepOne];
        if(!isBadStep[prevStepTwo])
            ways[i] += ways[prevStepTwo];
        ways[i] %= MOD;
    }
    cout << ways[n] << '\n';
    return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int A[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b;
    cin >> a >> b;
    cout << ceil((b - a) / (float)(a - 1)) + 1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

int main()
{
  long a, b, c;
  std::cin >> a >> b >> c;
  
  std::cout << ((b - a) == (c - b) ? "YES" : "NO") << std::endl;  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	int a=read(),b=read(),c=read();
	a=a*100+b*10+c;
	if(a%4)printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

struct union_find{

    std::vector<int> rank;
    std::vector<int> par;

    union_find(int n){
        rank.resize(n + 1);
        par.resize(n + 1);
        for(int i = 1 ; i <= n ; ++i){
            rank[i] = 1;
            par[i] = i;
        }
    }

    int find(int x){
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x , int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] > rank[y]) par[y] = x;
        else{
            par[x] = y;
            if(rank[x] == rank[y]) rank[y] += 1;
        }
    }

    bool same(int x , int y){
        x = find(x);
        y = find(y);
        return x == y;
    }

};

int main(){

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);

    int n , m;
    std::cin >> n >> m;

    std::vector<int> p;
    int a;
    for(int i = 0 ; i < n ; ++i){
        std::cin >> a;
        p.push_back(a);
    }

    union_find u = union_find(n);

    int x ,y;
    for(int i = 0 ; i < m ; ++i){
        std::cin >> x >> y;
        u.unite(x,y);
    }

    int cont = 0;
    for(int i = 0 ; i < n ; ++i){
        cont += u.same(i + 1 , p[i]);
    }

    std::cout << cont;

    return 0;

}


Measured memory_bytes: 1528
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

class State{
public:
	int id,t;
	double cost;

	State(int tid,int tt,double tcost){
		id = tid;
		t = tt;
		cost = tcost;
	}

	bool operator<(const State &st) const {
		return cost > st.cost;
	}
};

int main(void){
	int n,m,p,a,b;

	while(cin>>n>>m>>p>>a>>b && n){
		int t[n];
		for(int i=0;i<n;i++){
			cin>>t[i];
		}

		int map[m+1][m+1];
		memset(map,0,sizeof(map));
		for(int i=0;i<p;i++){
			int x,y,z;
			cin>>x>>y>>z;
			map[x][y] = map[y][x] = z;
		}

		priority_queue<State> open;
		bool closed[m+1][1<<n];
		memset(closed,0,sizeof(closed));

		open.push(State(a,0,0));
		double ans = -1;

		while(!open.empty()){
			State st = open.top(); open.pop();
			if(closed[st.id][st.t]) continue;
			closed[st.id][st.t] = true;

			if(st.id == b){
				ans = st.cost;
				break;
			}

			for(int i=1;i<=m;i++){
				if(map[st.id][i] == 0) continue;

				for(int j=0;j<n;j++){
					if((st.t & (1<<j)) != 0) continue;
					int nt = (st.t | (1<<j));
					double ncost = st.cost + (double)map[st.id][i] / t[j];
					open.push(State(i,nt,ncost));
				}
			}
		}

		if(ans == -1)
			cout<<"Impossible\n";
		else
			printf("%.3lf\n",ans);
	}

	return 0;
}

Measured memory_bytes: 8980
Sa = list(input())
Sb = list(input())
Sc = list(input())

n = 'a'
while True:
    if n == 'a':
        if not len(Sa):
            ans = 'A'
            break
        n = Sa.pop(0)
    elif n == 'b':
        if not len(Sb):
            ans = 'B'
            break
        n = Sb.pop(0)
    else:
        if not len(Sc):
            ans = 'C'
            break
        n = Sc.pop(0)

print(ans)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  int K;
  cin >> K;
  int A,B;
  cin >> A >> B;
int n = 0;
  for(int i = 0;i < 1000;i++){
    if(K*i >=A && K*i <= B){
      n = 1;
      break;
    }
  }
  if(n == 0){
    cout << "NG" << endl;
  }else{
    cout << "OK" << endl;
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s, t; cin >> s >> t;
	int ans = 0;
	FOR_LT(i, 0, s.size()) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000000000;
const ll MOD = 1000000000 + 7;
const int MAX_H = 100 + 1;
const int MAX_W = 8 + 1;

ll dp[MAX_H][MAX_W];
ll a[MAX_W];
ll b[MAX_W];

int H, W, K;

int rec(int w, int c) {

  if (w == W - 1) {
    for (int i = 0; i < w; i++) {
      if((c>>i & 1) == 1) a[w - i]++;
    }

    if ((c>>0 & 1) == 0) b[w + 1]++;
    if ((c>>(w-1) & 1) == 0) b[1]++;
    for (int i = 0; i < w - 1; i++) {
      if (((c>>(i) & 1) == 0) & ((c>>(i+1) & 1) == 0)) b[w - i]++;
    }
    
    return 0;
  }

  if (!(c & 1)) rec(w + 1, (c<<1) + 1);
  rec(w + 1, (c<<1) + 0);

  return 0;
}

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

  cin >> H >> W >> K;

  if (W == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  rec(1, 0);
  rec(1, 1);

  dp[0][1] = 1;

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {

      if (j == 1) {
	dp[i][j] += (dp[i-1][j]   * b[j]) % MOD;
	dp[i][j] %= MOD;
	dp[i][j] += (dp[i-1][j+1] * a[j]) % MOD;
	dp[i][j] %= MOD;
      }
      else if (j == W) {
	dp[i][j] += (dp[i-1][j-1] * a[j-1]) % MOD;
	dp[i][j] %= MOD;
	dp[i][j] += (dp[i-1][j]   * b[j]) % MOD;
	dp[i][j] %= MOD;	
      }
      else {
	dp[i][j] += (dp[i-1][j-1] * a[j-1]) % MOD;
	dp[i][j] %= MOD;	
	dp[i][j] += (dp[i-1][j]   * b[j]) % MOD;
	dp[i][j] %= MOD;	
	dp[i][j] += (dp[i-1][j+1] * a[j]) % MOD;
	dp[i][j] %= MOD;	
      }
    }
  }

  cout << dp[H][K] << endl;
  return 0;
}








Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <cassert>

using namespace std;
typedef long long ll;

const int INF = 2e9;

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

  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red, green, inv;

  for (int i = 0; i < a; i++) {
    int r;
    cin >> r;
    red.push_back(r);
  }

  for (int i = 0; i < b; i++) {
    int r;
    cin >> r;
    green.push_back(r);
  }

  for (int i = 0; i < c; i++) {
    int r;
    cin >> r;
    inv.push_back(r);
  }

  sort(red.rbegin(), red.rend());
  sort(green.rbegin(), green.rend());
  sort(inv.rbegin(), inv.rend());

  red.erase(red.begin()+x, red.end());
  green.erase(green.begin()+y, green.end());

  ll sum = 0;
  for (int c: inv) {
    int min_r = red.empty() ? INF : red.back();
    int min_g = green.empty() ? INF : green.back();
    if (c <= min(min_r, min_g)) break;
    sum += c;
    if (min_r < min_g) {
      red.pop_back();
    } else {
      green.pop_back();
    }
  }

  for (int c: red) sum += c;
  for (int c: green) sum += c;

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1784
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
  mod = (i64)mod;
  i64 res = 1, p = a % mod;
  while (n) {
    if (n & 1) res = res * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
  cout << sizeof...(rest) << endl;
  std::cout << first;
  if (sizeof...(rest)) std::cout << " ";
  print(rest...);
}
template <typename... A>
void print(const A&... rest) {
  print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
  std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
  std::cout << std::endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s;
  int ans = 0;
  cin >> k >> s;
  rep(x, k + 1) {
    rep(y, k + 1) {
      int z = s - x - y;
      if(z <= k && z >= 0){
        ans++;
        // printf("%d+%d+%d=%d\n", x, y, z, s);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

vector<ll>a;
void dfs(ll cur, int pos, int n){
  if(pos==n){
    a.push_back(cur);
    return;
  }
  int tt = cur % 10;
  for(int j=tt-1;j<=tt+1;j++){
    if(j<0||j>9)continue;
    dfs(cur * 10+j, pos+1, n);
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<=10;i++){
    for(int j=1;j<=9;j++)dfs(j,1, i);
    if(a.size()>=n)break;
  }
  sort(a.begin(),a.end());
  cout<<a[n-1]<<endl;
  return 0;
}

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

int main(){
  int pas[3],dri[2],sum;
 
  cin >> pas[0] >> pas[1] >> pas[2] >> dri[0] >> dri[1];
  sort(pas,pas+3);
  sort(dri,dri+2);

  sum = pas[0]+dri[0]-50;

  cout << sum << endl;
}

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

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

  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }

  sort(s.begin(), s.end());

  for(int i = 0; i < n; i++) cout << s[i];
  cout << endl;

  return 0;

}


Measured memory_bytes: 256
/*
ID: Aman Raj
LANG: C++
TASK: subset
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
//hr
using namespace std;
using namespace __gnu_pbds;
//hy
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
  //# define mod 1e9+7
   ll gcd(ll a,ll b)
   {
       if(a==0)return b;
       return gcd(b%a,a);
   }
//kj
int main()
{

    ll r;
      cin>>r;
       cout<<3*r*r;

      return 0;
}


Measured memory_bytes: 256