akhauriyash/Code-Regression huggingface dataset:
def main():
    d = int(input())
    a = []
    for _ in range(d):
        a.append(int(input()))

    ans = []
    for x in range(d):
        ansans = []
        hoge = a[x]
        for y in range(10):
            hoge = list("{0:08d}".format(hoge ** 2))
            s = ""
            for z in range(2, 6):
                s += hoge[z]
            hoge = int(s)
            ansans.append(hoge)
        ans.append(ansans)

    for x in range(1, d + 1):
        print("Case", x,end= "")
        print(":")
        for y in ans[x - 1]:
            print(y)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7664
#include <iostream>
#include <vector>
#include <functional>
#include <queue>
#include <utility>

constexpr int INF = 1000000000;

int n, d;
int dp[210][2]; // 0: max, 1: min
int data[210][2];
int temp[210];

int main() {
    std::cin >> d >> n;

    for(int i = 0; i < d; ++i) {
        std::cin >> temp[i];
    }

    for(int i = 0; i < d; ++i) {
        data[i][0] = -1;
        data[i][1] = INF;
    }

    int a, b, c;
    for(int i = 0; i < n; ++i) {
        std::cin >> a >> b >> c;

        for(int j = 0; j < d; ++j) {
            if(temp[j] >= a && temp[j] <= b) {
                data[j][0] = std::max(data[j][0], c);
                data[j][1] = std::min(data[j][1], c);
            }
        }
    }

    for(int i = 1; i < d; ++i) {
        dp[i][0] = std::max(
                        dp[i - 1][1] + std::abs(data[i - 1][1] - data[i][0]),
                        dp[i - 1][0] + std::abs(data[i - 1][0] - data[i][0])
                        );
        dp[i][1] = std::max(
                        dp[i - 1][1] + std::abs(data[i - 1][1] - data[i][1]),
                        dp[i - 1][0] + std::abs(data[i - 1][0] - data[i][1])
                        );
    }

    std::cout << std::max(dp[d - 1][0], dp[d - 1][1]) << std::endl;
}

Measured memory_bytes: 3052
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

G = A[0]
for A_i in A:
    G = gcd(A_i, G)

if K > max(A):
    print('IMPOSSIBLE')
elif K % G == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main(){
	ios::sync_with_stdio(0);
	ll cost[4], N;
	rep(i,0,4)
		cin >> cost[i];
	cin >> N;
	N *= 4;
	ll amount[4]={1,2,4,8};
	ll buy[4];
	ll ans = 1e18;
	for(buy[0]=0; buy[0] < 16; buy[0]++)
	for(buy[1]=0; buy[1] < 16; buy[1]++)
	for(buy[2]=0; buy[2] < 16; buy[2]++)
	for(buy[3]=0; buy[3] < 16; buy[3]++)
	for(int remaining=0; remaining < 4; ++remaining){
		ll needs = N;
		ll c = 0;
		rep(i,0,4){
			needs -= buy[i]*amount[i];
			c += cost[i] * buy[i];
		}
		if(needs < 0)
			continue;
		if(needs % amount[remaining])
			continue;
		ll num = (needs)/amount[remaining];
		c += num * cost[remaining];
		ans = min(ans, c);
	}
	cout << ans << 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 all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int k,s;
  cin>>k>>s;
  int ans=0;
  vector<int> a(k+1);
  rep(i,k+1) a[i] = i;
  rep(i,k+1) rep(j,k+1) if(binary_search(all(a),s-i-j)) ans ++ ;
  cout<< ans << 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 all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a + c, min(a + d, min(b + c, b + d))) << endl;
    // end

    return 0;
}


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

int main(void) {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    int sum = a1 + a2 + a3;
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int dp[5][100050]={};
int small(int a,int b){
  if(a>b)return a;
  else return b;
}
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  for(int i=1;i<=n;i++){
    dp[1][i]=small(dp[2][i-1]+a[i-1],dp[3][i-1]+a[i-1]);
    dp[2][i]=small(dp[1][i-1]+b[i-1],dp[3][i-1]+b[i-1]);
    dp[3][i]=small(dp[1][i-1]+c[i-1],dp[2][i-1]+c[i-1]);
  }
  int max=0;
  for(int i=0;i<3;i++){
    if(dp[i+1][n]>max)max=dp[i+1][n];
  }
  cout<<max<<endl;
  return 0;
}


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

using namespace std;

const int N=2e5+10;

int n,a[N];

long long solve(){
        for(int i=1;i<=n;i++) if (a[i]>=i) return -1;
        int cheight=0;
        long long ans=0;
        for(int i=n;i>=1;i--){
                if (cheight>a[i]) return -1;
                if (cheight<a[i]){
                        ans+=a[i];
                        cheight=a[i];
                }
                cheight=max(0,cheight-1);
        }
        return ans;
}
int main(){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        cout<<solve();
}


Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
ans = 0
cnt = 0
for now in range(N-1,0,-1):
  if H[now] <= H[now-1]:
    cnt += 1
  else:
    if cnt > ans:
      ans = cnt
    cnt = 0
else:
  if cnt > ans:
      ans = cnt
print(ans)

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

using namespace std;

#define int long long

signed main(){
    int  n;
    cin>>n;
    int arr[n+10];
    multiset<int> s;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for (int i = 1; i <=n; ++i)
    {
        multiset<int> ::iterator it;
        it=s.lower_bound(arr[i]);
        if(it==s.begin())
        {
            s.insert(arr[i]);
        }else{
            it--;
            s.erase(it);
            s.insert(arr[i]);
        }
        
    }

   cout<<s.size();
    return 0;
}

Measured memory_bytes: 5760
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<cstring>
#include<climits>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
inline int read() {
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c==EOF)exit(0);if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 2000
#define INF 0x3f3f3f3f
#define Mod (int)(1e9+7)
LL fac[MAXN*MAXN+5],inv[MAXN*MAXN+5];
LL Pow(LL x,LL y){
	LL ret=1;
	while(y){
		if(y&1) ret=ret*x%Mod;
		x=x*x%Mod,y>>=1;
	}
	return ret;
}
void Prepare(){
	fac[0]=1;
	for(int i=1;i<=MAXN*MAXN;i++)
		fac[i]=fac[i-1]*i%Mod;
	inv[MAXN*MAXN]=Pow(fac[MAXN*MAXN],Mod-2);
	for(int i=MAXN*MAXN-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%Mod;
	return ;
}
LL f[MAXN+5][MAXN+5];
LL C(int n,int m){
	if(n<m) return 0;
	return fac[n]*inv[m]%Mod*inv[n-m]%Mod;
}
int main(){
	Prepare();
	int n=read(),k=read();
	if(k==1)
		puts("1"),exit(0);
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		f[i][0]=1;
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j]+C(n-i+(n-(j-1))*(k-1)-1,k-2)*f[i][j-1]%Mod)%Mod;
	}
	printf("%lld\n",f[n][n]*fac[n]%Mod);
	return 0;
}

Measured memory_bytes: 92672
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int h,w,k;
  cin>>h>>w>>k;
  char c[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
  }
  int ans=0;
  for(int bit=0;bit<(1<<(h+w));++bit){
    bool temp[h+w];
    for(int i=0;i<h+w;i++){
      temp[i]=true;
    }
    for(int i=0;i<(h+w);++i){
      if(bit & (1<<i)){
        temp[i]=false;
      }
    }
    int q=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(c[i][j]=='#' and temp[i] and temp[j+h]) q++;
      }
    }
    if(q==k) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> food(m + 1, 0);

    if(n == 1){
        int tmp;
        cin >> tmp;
        for(int i = 0; i < tmp; i++){
            int k;
            cin >> k;
            food[k]++;
            //cout << food[k] << endl;
        }
        int cnt = 0;
        for(int i = 0; i < m + 1; i++){
            if(food[i] > 0){
                cnt++;
            }
        }
        cout << cnt << endl;
        return 0;
    }

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        for(int i = 0; i < tmp; i++){
            int k;
            cin >> k;
            food[k]++;
        }
    }

    int cnt = 0;
    for(int i = 0; i < m + 1; i++){
        if(food[i] == n){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
k, t = map(int, input().split())
a = [[int(m), 0] for m in input().split()]
prohibit = 1
ans = 0
if t == 1:
    ans = a[0][0] - 1
else:
    for i in range(k):
        a.sort(reverse=True)
        if a[1][0] == 0:
            ans = a[0][0] - 1
            break
        else:
            if i == 0:
                a[1][1] = 1
            if a[0][1] == 0:
                a[0][0] -= 1
                a[0][1] = 1
                prohibit = 0
            elif a[1][1] == 0:
                a[1][0] -= 1
                a[1][1] = 1
                prohibit = 1
            for j in range(t):
                if prohibit != j:
                    a[j][1] = 0
print(ans)

Measured memory_bytes: 41324
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main()
{
	int A, B;
	int count = 0;
	string str;

	cin >> A >> B;

	for (int i = A; i <= B; i++) {
		str = to_string(i);
		int flag = 1;
		int j = 0;
		while(flag) {
			if (str[j] != str[str.size() - j - 1]) {
				flag = 0;
			}
			if (j == str.size() / 2) {
				count++;
				flag = 0;
			}
			j++;
		}
	}

	cout << count << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			int h = Integer.parseInt(in.next());
			int w = Integer.parseInt(in.next());
			if (h == 0 && w == 0) {
				break;
			}
			for (int i = 1; i <= h; i++) {
				switch (i % 2) {
				case 1:
					for (int j = 1; j <= w; j++) {
						switch (j % 2) {
						case 1:
							System.out.print("#");
							break;
						case 0:
							System.out.print(".");
							break;
						}
					}
					break;
				case 0:
					for (int j = 1; j<= w; j++) {
						switch (j % 2) {
						case 1:
							System.out.print(".");
							break;
						case 0:
							System.out.print("#");
							break;
						}
					}
					break;
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}	


Measured memory_bytes: 35820
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<iterator>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
int arr[maxn];
int main()
{
	int n;
	int k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	int mn = INF;
	for (int i = 0; i + k - 1 < n; i++)
	{
		if (arr[i + k - 1] - arr[i] < mn)
			mn = arr[i + k - 1] - arr[i];
	}
	cout << mn << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

#include<algorithm>
using std::sort;

#include<functional>
using std::greater;

#include<vector>
using std::vector;

int main()
{
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i ++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end(), std::greater<int>());
  
  int alice = 0;
  int bob = 0;
  
  for (int i = 0; i < n; i ++)
  {
    if (i % 2 == 0) alice += a.at(i);
    else bob += a.at(i);
  }
  
  cout << alice - bob << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,mx=0,ans=1;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int c=0;
        int p=i;
        while(p!=0)
        {
            if(p%2==0)
            {

                c++;
            }
            p=p/2;
        }
        if(c>mx)
        {
            mx=c;
            ans=i;
        }
    }
    cout<<ans<<endl;
  //  main ();
}


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

// ????¬???¬??°???
int CharToInt(char s[]) {
	int ans = 0, i = 0;
	while (s[i] != '\0') {
		ans = ans * 10 + s[i] - '0';
		i++;
	}
	return ans;
}

int main() {
	char s[1000];
	int a, b;
	stack<int> S;
	
	while(scanf("%s",s)!=EOF){
			if (s[0] == '+') {
				b = S.top(); S.pop();
				a = S.top(); S.pop();
				S.push(a + b);
			}else if (s[0] == '-') {
				b = S.top(); S.pop();
				a = S.top(); S.pop();
				S.push(a - b);
			}else if (s[0] == '*') {
				b = S.top(); S.pop();
				a = S.top(); S.pop();
				S.push(a * b);
			}else {
				S.push(CharToInt(s));
			}
	}
	printf("%d\n", S.top());
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

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

	vi snuke(n, 0);

	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			snuke[a - 1]++;
		}
	}

	int sum = 0;

	for (int i = 0; i < n; i++) {
		if (snuke[i] == 0) {
			sum++;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3632
<?php
define( "TOP", 0 );
define( "FRONT", 1 );
define( "RIGHT", 2 );
define( "LEFT", 3 );
define( "BACK", 4 );
define( "BOTTOM", 5 );
class Dice
{
	private $labels;
	public function __construct( $labels )
	{
		$this->labels = $labels;
	}
	public function roll( $cmds )
	{
		$len = strlen( $cmds );
		for( $i=0; $i<$len; $i++ ) {
			if( 'E' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[LEFT];
				$this->labels[LEFT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $t;
			} else if( 'S' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[BACK];
				$this->labels[BACK] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[FRONT];
				$this->labels[FRONT] = $t;
			} else if( 'W' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[LEFT];
				$this->labels[LEFT] = $t;
			} else if( 'N' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[FRONT];
				$this->labels[FRONT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[BACK];
				$this->labels[BACK] = $t;
			}
		}
	}
	public function getLabel( $face )
	{
		return $this->labels[ $face ];
	}
}

	$labels = explode( " ", trim( fgets( STDIN ) ) );
	$dice = new Dice( $labels );
	$cmds = trim( fgets( STDIN ) );
	
	$dice->roll( $cmds );
	print $dice->getLabel( 0 );
?>

Measured memory_bytes: 15684
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n;
string c, rx, ry, lx, ly, x[] = {".", ".", "#", "#"}, y[] = {".", "#", ".", "#"}, t;
bool re;

signed main() {
	cin >> n;
	while (1) {
		if (!re) {
			rep(i,4) {
				cout << rx+x[i] << endl << ry+y[i] << endl << flush;
				cin >> t;
				if (t=="end") return 0;
				if (t=="T") {
					rx += x[i], ry += y[i];
					break;
				}
				if (i==3) re = 1;
			}
		} else {
			rep(i,4) {
				cout << x[i]+rx << endl << y[i]+ry << endl << flush;
				cin >> t;
				if (t=="end") return 0;
				if (t=="T") {
					rx = x[i]+rx, ry = y[i]+ry;
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 724
H, W = gets.split.map(&:to_i)

G = []

H.times do
  a = Array.new(W)
  line = gets.chomp.bytes.push 35
  i, j = 0, 0
  while i <= W
    if line[i] == 35
      if j < i
        c = i - j
        k = j
        while k < i
          a[k] = c
          k += 1
        end
      end 
      i += 1
      j = i
    else
      i += 1
    end
  end
  G << a
end 
G << Array.new(W)

ans = 0
G.transpose.each do |ar|
  i, j = 0, 0
  local_max = 0
  while i <= H
    v = ar[i]
    if v.nil?
      if j < i
        local_max += (i - j)
        ans = local_max if ans < local_max
        local_max = 0
      end 
      i += 1
      j = i
    else
      local_max = v if local_max < v  
      i += 1
    end 
  end 
end
STDOUT.puts ans - 1


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int ans = 0;
    rep(i, 5) {
        ll x; std::cin >> x;
        if (x == 0) ans = i+1;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3528
n,m=map(int, input().split())

s = {}

for i in range(1, m+1):
    k, *v = map(int, input().split())
    s[i] = list(v)
p = [0] + list(map(int, input().split()))
ans = 0
for i in range(2**n):
    a = p[:]
    for j in range(n):
        if i & (1 << j) > 0:
            for k in range(1, m+1):
                if j+1 in s[k]:
                    a[k] ^= 1

    if sum(a) == 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    string str;
    cin >> str;
    
    if (str[2] == str[3] && str[4] == str[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
S = list(input())

L = list("KIHBR")
for l in L:
    if not l in "".join(S):
        print("NO")
        sys.exit(0)

N = []
for i in range(len(S)-1):
    if S[i] == "H" or S[i] == "B" or S[i] == "R":
        if S[i+1] != "A":
            N.append(i+1)

i = 0
for n in N:
    S.insert(n+i, "A")
    i += 1
    
if "".join(S) in "AKIHABARA":
    print("YES")
else:
    print("NO")

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const ll MAX_N=1e5;
vvll edge(MAX_N);
vll to(MAX_N);
vector<bool> visited(MAX_N,false);

void dfs(ll now, ll par){
  if(visited[now])
    return;

  visited[now]=1;
  to[now]=par;
  for(auto e:edge[now]){
    dfs(e,now);
  }
}

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

  ll n,m;
  cin>>n>>m;
  REP(i,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  queue<pll> que;
  que.push(pll(0,-1));
  while(!que.empty()){
    ll now=que.front().FI;
    ll par=que.front().SE;
    que.pop();

    if(visited[now])
      continue;
    visited[now]=true;
    to[now]=par;
    for(auto e:edge[now]){
      que.push(pll(e,now));
    }
  }

  yes;
  REP1(i,n)
    cout<<to[i]+1<<endl;
}



Measured memory_bytes: 17892
#include <stdio.h>

int main(){
	int H,A;
	scanf("%d%d",&H,&A);
	if(H%A == 0){
		printf("%d",H/A);
	}
	else if(H > A){
		printf("%d",(H/A)+1);
	}
	else if (H < A){
		printf("%d",1);
	}
	return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    int a[q];
    int b[n]={};
    rep(i,q){
        cin >> a[i];
        b[a[i]-1]++;
    }
    rep(i,n){
         if(b[i]<=q-k){
            cout << "No" << endl;
        } else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int p,m,c;
    cin >> p >> m >> c;
    cout << (p + m + c) << endl;
}

Measured memory_bytes: 3172
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
# import sys
# sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline





def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] -= 1
    r = [a[0] % k]
    for i in range(1,n):
        r.append((r[i - 1] + a[i]) %k)
    
    d = defaultdict(int)
    r = [0] + r
    d[0] = 1
    ans = 0
    for i in range(n):
        if i >= k - 1:
            d[r[i - k  + 1]]-=1
        ans+=d[r[i+1]]
        d[r[i+1]] += 1
    print(ans)



        


if __name__ == '__main__':
    main()
1


Measured memory_bytes: 42712
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int D=stdIn.nextInt();
		int X[][]=new int[N][D];
		double a=0;
		int z=0,y=0,x=0,ans=0;
		while(z<N){
			while(y<D){
				X[z][y]=stdIn.nextInt();
				y++;
			}y=0;
			z++;
		}z=0;
		while(z<N){
			y=z+1;
			while(y<N){
				while(x<D){
					a+=(X[z][x]-X[y][x])*(X[z][x]-X[y][x]);
					x++;
				}x=0;
				double c=Math.sqrt(a);
				int b=(int)c;
				if(b*b==a)
					ans++;
				a=0;
				y++;
			}
			z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
#from math import ceil
#from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
mod=10**9+7
t=1
while t>0:
	t-=1
	n=fi()
	dp=[[1]*4 for i in range(n+2)]
	dp[-1]=[1,0,0,0]
	for i in range(n+1):
		dp[i][0]=dp[i-1][0]*8
		dp[i][1]=dp[i-1][0]+dp[i-1][1]*9
		dp[i][2]=dp[i-1][0]+dp[i-1][2]*9
		dp[i][3]=dp[i-1][3]*10+dp[i-1][1]+dp[i-1][2]
		for j in range(4):
			dp[i][j]%=mod
			
	print(dp[n-1][3])		
		

Measured memory_bytes: 201136
#include<cstdio>
#include<limits>
using namespace std;
void bubbleSort(int A[],int N){
    int flag=1;
    int cnt=0;
    while(flag){
        flag=0;
        for(int i=0;i<N-1;i++){
            for(int j=(N-1);j>i;j--){
                if(A[j]<A[j-1]){
                    int tmp;
                    tmp=A[j];
                    A[j]=A[j-1];
                    A[j-1]=tmp;
                    flag=1;
                    cnt++;
                }
        }
        }
        
    }
    for(int i=0;i<N;i++){
        printf("%d%c",A[i],i==(N-1)?'\n':' ');
    }
    printf("%d\n",cnt);
}

int main(){
    int num;
    scanf("%d",&num);
    int A[num];
    for(int i=0;i<num;i++){
        scanf(" %d",&A[i]);
    }
    bubbleSort(A,num);
    return 0;
}


Measured memory_bytes: 2740
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0

def chmin(a, b):
  if a>b:
    a=b
    return True
  return False

for i in range(1, N):
  if chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1])):
    dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    if i > 1:
      if chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2])):
        dp[i] = dp[i-2] + abs(h[i] - h[i-2])

print(dp[N-1])

Measured memory_bytes: 13924
#include<iostream>

using namespace std;

int main(){
  int a,b,c;
  
  cin>>a>>b>>c;
  
  if(a==b&&b==c){
    cout<<1<<endl;
  }else if(a==b||b==c||a==c){
    cout<<2<<endl;
  }else{
    cout<<3<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); 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; }
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

ll dp[10010][3];

int main(){
    string s;
    cin >> s;
    ll n = (int)s.length();
    ll a[n+1];
    rep(i,n+1){
        a[i] = 0;
    }
    ll cnt = 0;
    rep(i, n)
    {
        if(s[i]=='<'){
            cnt++;
            a[i + 1] = cnt; 
        }
        else{
            cnt = 0;
        }
    }
    cnt = 0;
    for (int i = n - 1; i >= 0;i--){
        if(s[i]=='>'){
            cnt++;
            a[i]=max(a[i], cnt);
        }
        else{
            cnt = 0;
        }
    }
    ll ans = 0;
    rep(i,n+1){
        //cout << a[i] << endl;
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include <iostream>
using namespace std;
typedef long long int ll;
ll n,W;
ll w[1000],v[1000];
ll dp[1000001];
int main()
{
    scanf("%lld%lld",&n,&W);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld%lld",&w[i],&v[i]);
    }
    //start knapsack
    for(int i = 0; i < n; i++)
    {
        for(int k = W; k >= w[i]; k--)
        {
            dp[k] = max(dp[k],dp[k-w[i]]+v[i]);
        }
    }
    printf("%lld\n",dp[W]);
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vp a(n);
    rep(i,n)cin>>a[i].fi>>a[i].se;
    SORT(a);
    int k=0;
    priority_queue<int> q;
    int ans=0;
    REP(i,1,m){
        while(k<n&&a[k].fi<=i){
            q.push(a[k++].se);
        }
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2936
#include <stdio.h>

int main(void)
{
	int m,d;
	while(1){
		scanf("%d %d",&m,&d);
		if(m==0&&d==0){
			break;
		}
		if(m==6){
			d+=1;
		}
		if(m==9||m==12){
			d+=2;
		}
		if(m==1||m==4||m==7){
			d+=3;
		}
		if(m==10){
			d+=4;
		}
		if(m==5){
			d+=5;
		}
		if(m==2||m==8){
			d+=6;
		}
		
		
		if(d%7==1){
			printf("Monday\n");
		}
		if(d%7==2){
			printf("Tuesday\n");
		}
		if(d%7==3){
			printf("Wednesday\n");
		}
		if(d%7==4){
			printf("Thursday\n");
		}
		if(d%7==5){
			printf("Friday\n");
		}
		if(d%7==6){
			printf("Saturday\n");
		}
		if(d%7==0){
			printf("Sunday\n");
		}
	}
	

	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int r = sc.nextInt();
        if (n > 10){
            System.out.println(r);
        } else {
            System.out.println(r+100*(10-n));
        }
    }
}

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

struct union_find{
    vector<int> r;
    
    union_find(int n){
        r = vector<int> (n, -1);
    }
    
    int root(int x){
        if(r[x] < 0){
            return x;
        }else{
            return r[x] = root(r[x]);
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        if (r[rx] > r[ry]) {
            swap(rx, ry);
        }
        r[rx] += r[ry];
        r[ry] = rx;
    }
    
    int size(int x){
        return -r[root(x)];
    }
};

int main() {
    int n, m, a, b;
    cin >> n >> m;
    union_find UF(n);
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        UF.unite(a - 1, b - 1);
    }
    
    int ans = 0;
    
    for(int i = 0; i < n; i ++){
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>

int main( void ) {
  int i, j;
  char card[1000];
  char hoge;
  int x, one, cur;

  while( 1 ) {
    for( i = 0; ; ) {
        scanf( "%c", &card[ i ] ); 
        if( card[ i++ ] == '\n' )
          break;
    }
    card[ i ] = 0;
    if( card[ 0 ] == '0' )
      break;

    cur = 0;
    one = 0;

    for( i = 0; card[ i ]; i++ ) {
      x = atoi( card + i );

      if( 2 <= x && x <= 9 )
        cur += x;
      else if( 10 <= x && x <= 13 )
        cur += 10;
      else
        one++;

      for( j = 0; x > 0; j++ )
        x /= 10;

      i += j;
    }

    for( i = 0; i < one; i++ )
      cur += 1;

    for( i = 0; i < one && cur <= 11; i++ )
      cur += 10;

    if( 22 <= cur )
      printf( "0\n" );
    else
      printf( "%d\n", cur );
  }

  return ( 0 );
}

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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);
	
	int n;
	string s;
	cin >> n >> s;
	string d = s.substr(n/2);
	d += d;
	if(s == d)
	cout << "Yes";
	else
	cout << "No";

	return 0;
}



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

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

	int t = 0, h = 0;
	for (int i = 0; i < n; i++) {
		string s1, s2;
		cin >> s1 >> s2;
		if (s1 > s2) t += 3;
		else if (s1 < s2) h += 3;
		else t++, h++;
	}
	cout << t << " " << h << endl;

	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){
  int m,n;
  cin >> m >> n;
  if(m==n) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 3600
# Studying https://img.atcoder.jp/abc164/editorial.pdf
M = [0]*2019
gets.chomp.bytes.reverse_each.inject([0,1]){|(t,w),b|
	M[t] += 1
	next (t + (b-?0.ord)*w) % 2019, w*10%2019
}.tap{|t,|
	M[t] += 1
}
p M.sum{|_| _*(_-1)/2 }


Measured memory_bytes: 16176
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int h;
int w;
int main()
{
    cin >> h >> w;
    stringstream ss;
    rep(i,1,h)
    {
        string s;
        cin >> s;
        ss << s << endl;
        ss << s << endl;
    }

    cout << ss.str();

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);

	int H,W;
	cin >> H >> W;
	vector<char> grid[H];

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char s;
			cin >> s;
			grid[i].push_back(s);
		}
	}


	int dp[1005][1005] = {0};
	for(int i=0;i<W;i++){
		if(grid[0][i]=='#'){
			break;
		}
		else{
			dp[0][i]=1;
		}
	}
	for(int i=0;i<H;i++){
		if(grid[i][0]=='#'){
			break;
		}
		else{
			dp[i][0]=1;
		}
	}
	for(int i=1;i<H;i++){
		for(int j=1;j<W;j++){
			if(grid[i][j]=='#'){
				continue;
			}
			else{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;

			}
		}
	}
	cout << dp[H-1][W-1] << endl;
	
	

}

Measured memory_bytes: 8600
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;


 
void solve() {
  int n;
  cin >> n;
  cout << ((n >= 30)? "Yes": "No") << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
bool is_ok(ll x, ll y){
    if(x == y) return true;
    else return false;
}
int main(){
    string s;
    cin >> s;
    if(s.size() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    bool flg = true;
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            if(s[i] != 'h') flg = false;
        }
        else{
            if(s[i] != 'i') flg = false;
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception{
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int y = input.nextInt();
        if(x == y){
            System.out.println("a == b");
        }else if(x > y){
            System.out.println("a > b");
        }else
            System.out.println("a < b");
    }
}

Measured memory_bytes: 26268
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	int x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<b){
		x=a;
	}
	else{
		x=b;
	}
	if(c<d){
		y=c;
	}
	else{
		y=d;
	}
	printf("%d\n",x+y);
	return 0;
}


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

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

    for (int i = 0; i < s.size(); ++i) {
        cout << s[i];
        if (i == 3) {
            cout << ' ';
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    int s[M];
    REP(i, M) {
        int k;
        cin >> k;

        int c = 0;
        REP(j, k) {
            int si;
            cin >> si;

            c += 1 << (si - 1);
        }
        s[i] = c;
    }

    int p[M];
    REP(i, M) cin >> p[i];

    int ans = 0;

    REP(i, 1 << N) {
        bool f = true;

        REP(j, M) {
            int c = 0;
            debug(bitset<5>(i), bitset<5>(s[j]))
            REP(k, N) {
                debug(k, i >> k & s[j] >> k);
                if ((i >> k & 1) && (s[j] >> k & 1)) {
                    ++c;
                }
            }
            if (c % 2 == p[j]) continue;

            f = false;
            break;
        }

        if (f) ++ans;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[]d = new int[n];

    int a = 0;
    for(int i=0; i<n; i++) {
    	d[i] = sc.nextInt();
    	a += d[i]*d[i];
    }
    int all = 0;
    for(int i=0; i<n; i++) {
    	for(int j=0; j<n; j++) {
    		all += d[i]*d[j];
     	}
    }
    System.out.print((all-a)/2);
    }
}


Measured memory_bytes: 35632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(n); i++)
vector<int> num(10);
vector<int> collection;
int n,k;
void connect(string s){
  if(stoi(s)>=n){
    collection.push_back(stoi(s));
    return;
  }
  for(int i=0; i<10; i++){
    if(num[i]==1) continue;
    connect(s+to_string(i));
  }
}
int main() {
  cin >> n >> k;
  rep(i,k){
    int m;
    cin >> m;
    num[m]++;
  }
  for(int i=1; i<10; i++){
    if(num[i]==1) continue;
    connect(to_string(i));
  }
  sort(collection.begin(),collection.end());
  //cout << collection.size() << endl;
  //for(int i=0; i<collection.size(); i++){
    //cout << collection[i] << endl;
  //}
  cout << collection[0] << endl;
}

Measured memory_bytes: 640
def update(i,x):
    i += d-1
    bit = ord(x)-97
    seg[i] = 0 | (1<<bit)
    while i > 0:
        i = (i-1)//2
        seg[i] = seg[i*2+1]|seg[i*2+2]
def find(a,b,k,l,r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return seg[k]
    c1 = find(a,b,2*k+1,l,(l+r)//2)
    c2 = find(a,b,2*k+2,(l+r)//2,r)
    return c1|c2
n = int(input())
s = input()
q = int(input())
d = 1
while d < n:
    d *= 2
seg = [0]*(2*d-1)
for i in range(n):
    update(i,s[i])
for i in range(q):
    type,a,b = input().split()
    if type == "1":
        update(int(a)-1,b)
    else:
        part = find(int(a)-1,int(b),0,0,d)
        print(bin(part).count("1"))


Measured memory_bytes: 94408
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,sum1=0,sum2=0;
cin>>N;
vector<int>a(N),r(N);
for(int &x:a)cin>>x;
for(int &x:r)cin>>x;
for(int i=0;i<N;i++){
    if(a[i]>r[i]){
    sum1+=a[i];
    sum2+=r[i];
    }
}
cout<<sum1-sum2;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int n, m, k;
	std::cin >> n >> m >> k;
	
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= m; ++j)
		{
			if (j * (n - i) + i * (m - j) == k)
			{
				std::cout << "Yes";
				return 0;
			}
		}
	}
	
	std::cout << "No";
	return 0;
}

Measured memory_bytes: 256
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      #ifndef ONLINE_JUDGE
      freopen("inputf.in",  "r",   stdin);
      freopen("outputf.in", "w",  stdout);
      #endif
      FastIO
      lld n;
      cin >> n;
      lld r = n%10;
      if (r == 2 || r == 5 || r == 7 || r == 4 || r == 9){
      	cout << "hon";
      }
      else{
      	if (r == 0 || r == 1 || r == 6 || r == 8){
      		cout << "pon";
      	}
      	else{
      		cout << "bon";
      	}
      }
      return 0;
}

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

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)

int main(){
    int n,k;
    cin >> n >> k;
    k--;
    string s;
    cin >> s;

    if(s[k]=='A') s[k] = 'a';
    if(s[k]=='B') s[k] = 'b';
    if(s[k]=='C') s[k] = 'c';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int a,b,h;
  int res=0;
  cin >> a>>b>>h;

  res = (a+b)*h/2;

  cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
flag = False

for i in range(N):
    if A[i] % 2 == 0 and A[i] % 3 != 0 and A[i] % 5 != 0:
        flag = True

if flag:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 9120