akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
#define REP(i,n) for (int i=0; i<n; i++)
#define ALL(x) x.begin(), x.end()

string i2s(int n)
{
  stringstream ss;
  ss << n;
  return ss.str();
}

vvi permutations(vi x){
	vvi buf;
	int n=x.size(), i=0;
	sort(ALL(x));
	do{
		vi buf0(n);
		REP(i,n)
			buf0[i]=x[i];
		buf.push_back(buf0);
		buf0.clear();
	}while (next_permutation(ALL(x)));
	return buf;
}

vvi products(vi x, int n){
	int n2=x.size(), n3=(int)pow(n2,n);
	vvi buf(n3);
	REP(i,n3){
		vi buf0(n);
		int tmp = i;
		REP(i2,n){
			buf0[i2] = x[tmp%n2];
			tmp /= n2;
		}
		buf[i] = buf0;
	}
	return buf;
}

int op(int x, int y, int mode){
	switch (mode){
	case 0:
		return x+y;
	case 1:
		return x-y;
	case 2:
		return x*y;
	}
}

string check(vi x, int n){
	int x0=x[0], x1=x[1], x2=x[2], x3=x[3];
	string s0=i2s(x0), s1=i2s(x1), s2=i2s(x2), s3=i2s(x3);
	string ops="+-*", eq1, eq2;
	int n1 = ops.size();
	REP(i1, n1){
		int a1 = op(x0, x1, i1);
		eq1 = "("+s0+" "+ops[i1]+" "+s1+")";
		REP(i2, n1){
			int a2 = op(a1, x2, i2);
			eq2 = "("+eq1+" "+ops[i2]+" "+s2+")";
			REP(i3, n1)
				if (op(a2, x3, i3)==n) return "("+eq2+" "+ops[i3]+" "+s3+")";
			a2 = op(x2, x3, i2);
			eq2 = "("+s2+" "+ops[i2]+" "+s3+")";
			REP(i3,n1)
				if (op(a1, a2, i3)==n) return "("+eq1+" "+ops[i3]+" "+eq2+")";
		}
	}
	return "";
}

vi getx(){
	string line;
	getline(cin,line);
	istringstream is(line);
	vi x;
	int tmp;
	bool end = true;
	while(is>>tmp){
		if (tmp!=0) end = false;
		x.push_back(tmp);
	}
	if (end) x.clear();
	return x;
}

int f0041(){
	int n=10;
	while (true){
		vi x = getx();
		if (x.empty()) return 0;

		vvi xx = permutations(x);
		bool f = true;
		REP(i,(int)xx.size()){
			string s = check(xx[i],n);
			if (s != ""){
				cout<<s<<endl;
				f = false;
				break;
			}
		}
		if (f) cout<<"0"<<endl;
	}
}

int main(void){
	f0041();
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int ans = 0;
  string s;
  cin >> s;
  FOR(i, s.size() / 2) {
    if (s[i] != s[s.size() - 1 - i]) ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w,totalv=0;
    ifstream fin("a.in");
    ofstream fout("a.out");
  cin>>n>>w;

  int W[n+1],V[n+1];
  for(int i=1;i<=n;i++) {cin>>W[i]>>V[i];totalv+=V[i];}

  int dp[totalv+1][n+1];
  memset(dp,0,sizeof dp);
  for(int i=0;i<=n;i++)
    for(int j=0;j<=totalv;j++) dp[j][i]=1000000001;
    for(int i=0;i<=n;i++) dp[0][i]=0;

      for(int i=1;i<=n;i++){
            for(int val=0;val<=totalv;val++){
        dp[val][i]=min(dp[val][i-1],dp[val][i]);

      if(val>=V[i])
        dp[val][i]=min(dp[val-V[i]][i-1]+W[i],dp[val][i]);


    }
  }


  
  int maxx=-1;

    for(int val=0;val<=totalv;val++){
      if(dp[val][n]<=w) {maxx=max(maxx,val);}
    }

  cout<<maxx;


}


Measured memory_bytes: 39680
def ARC067():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
    if A >= B:
        A = B
    ans = 0
    for i in range(1, N):
        if (X[i] - X[i - 1]) * A > B:
            ans += B
        else:
            ans += A * (X[i] - X[i - 1])
    print(ans)
ARC067()

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll lcm(ll x,ll y)
{
	return (x*y)/__gcd(x,y);
}
ll cc(ll a,ll b,ll c)
{
	return (b/c)-((a-1)/c);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll j,l,m,h,w,f,n,k,b,t,ans;
    	cin>>n;
    	pii a[n];
    	rep(i,0,n)
    	{
    		cin>>l>>h;
    		a[i]={h,l};
		}
		sort(a,a+n);
		t=0; f=1;
		rep(i,0,n)
		{
			t+=a[i].S;
			if(t>a[i].F)
			{
				f=0;
				break;
			}
		}
		if(f)
		cout<<"Yes";
		else
		cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define N 500001

typedef struct tree{
  int key;
  struct tree *parent;
  struct tree *left;
  struct tree *right;
} Tree;

Tree *createtree(int);
void insert(Tree *, int);
void inorderwalk(Tree *);
void preorderwalk(Tree *);

Tree *root = NULL;

int main(){

  int m, x[N], i, j;
  char order[N][7];

  scanf("%d", &m);
  for(i = 0; i < m; i++){
    scanf(" %s", order[i]);
    if(order[i][0] == 'i') scanf("%d", &x[i]);
  }

  for(i = 0; i < m; i++){
    if(order[i][0] == 'i'){
      insert(root, x[i]);
    } 
    else{
      assert(root!=NULL);
      inorderwalk(root);
      printf("\n");
      preorderwalk(root);
      printf("\n");
    }
   
  }

  return 0;
}

void insert(Tree *t, int v){
  Tree *x, *y, *z;
  z =  createtree(v);
  y = NULL;
  x = t;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;  
}

void inorderwalk(Tree *x){
  if(x->left != NULL) inorderwalk(x->left);
  printf(" %d",x->key);
  if(x->right != NULL) inorderwalk(x->right);
}

void preorderwalk(Tree *x){
  printf(" %d",x->key);
  if(x->left != NULL) preorderwalk(x->left);
  if(x->right != NULL) preorderwalk(x->right);
}

Tree *createtree(int key){
  Tree *tree = (Tree *)malloc( sizeof(Tree) );
  tree->key = key;
  tree->parent = NULL;
  tree->left = NULL;
  tree->right = NULL;
  return tree;
}

Measured memory_bytes: 29412
#include <iostream>
using namespace std;
int main(void){
    
    char C;
    cin >> C;
    
    if(C == 'A') cout << "T" << endl;
    if(C == 'T') cout << "A" << endl;
    if(C == 'C') cout << "G" << endl;
    if(C == 'G') cout << "C" << endl;



}


Measured memory_bytes: 3012
#include <random>
#include <vector>
#include <cstdio>
#include <iostream>
#include <tuple>
#include <stdexcept>
#include <map>
#include <set>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <numeric>
#include <unordered_map>
#include <bitset>
#include <queue>

#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
#define mod LL(1e9 + 7)
#define mp make_pair
#define pb push_back
#define sqr(xx) ((xx)*(xx))

const int sz = 2e6;

ll n, a[int(2e5) + 20], ans;

ll f(ll x) {
    ll res = 0;
    for (int i = 1; i <= n; i++)
        res += abs(a[i] - x);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] -= i;
    }
    ll l = -1e10, r = 1e10;
    while (r - l > 3) {
        ll m1 = l + (r - l) / 3;
        ll m2 = r - (r - l) / 3;
        if (f(m1) > f(m2))
            l = m1;
        else
            r = m2;
    }

    ll ans = 1e18;
    for (int i = l - 10; i <= l + 10; i++)
        ans = min(ans, f(i));
    cout << ans;
}


Measured memory_bytes: 1792
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
K = list(input())
a = collections.Counter(K)
ans = 0
R = list(itertools.accumulate([1 if K[i] == "R" else 0 for i in range(N)])) + [0]
G = list(itertools.accumulate([1 if i == "G" else 0 for i in K])) + [0]
B = list(itertools.accumulate([1 if i == "B" else 0 for i in K])) + [0]
for i in range(N):
    if K[i] == "R":
        ans += G[i - 1] * B[i - 1]
    elif K[i] == "G":
        ans += R[i - 1] * B[i - 1]
    else:
        ans += R[i - 1] * G[i - 1]
for k in range(2, N):
    for i in range(0, k):
        j = (k + i) / 2
        if j == (k + i) // 2 and j > i:
            j = int(j)
            if K[k] != K[i] and K[k] != K[j] and K[i] != K[j]:
                ans -= 1
print(ans)


Measured memory_bytes: 79588
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int count=0;
		
		for(int i=5;i<=n;i=i*5){
		for(int j=1;j<=n;j++){
		if(j%i==0)
			count++;
		}
		}
		cout<<count<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v); 
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100100100;
const int MOD=(int)1e9+7;
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)

int main() {
    int k,a,b;
    cin>>k>>a>>b;
    bool c=false;
    for(int i=a; i<=b; i++){
        for(int j=0; j<=1000; j++){
            if(j*k==i) c=true;
        }
    }
    if(c)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>c(n-1),s(n-1),f(n-1);
for(int i=0;i<n-1;i++)cin>>c[i]>>s[i]>>f[i];
for(int i=0;i<n;i++){
int t=0;
for(int j=i;j<n-1;j++){
t+=(t<s[j]?s[j]-t:0);
t+=(f[j]-t%f[j])%f[j];
t+=c[j];
}
cout<<t<<endl;
}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define onen(i,n) for(int i=1;i<n+1;i++)

const int MAXW = 1001, MAXN = 1001;
int dp[MAXN][MAXW], w[MAXN], v[MAXN];
int n, maxw;

int main()
{
    int setnum = 1;
    while(cin >> maxw && maxw)
    {
        memset(dp, 0, sizeof(dp));
        char t;
        
        cin >> n;
        REP(n)cin >> v[i] >> t >> w[i];

        rep(i,n)onen(j,maxw)
        {
            dp[i+1][j] = max(dp[i][j], dp[i+1][j-1]);
            if(j>=w[i] ){ dp[i+1][j] = max(dp[i+1][j] , dp[i][j - w[i] ] + v[i]); }
        }

        int maxv = -1, weight = 0;
        onen(j,maxw)if(dp[n][j] > maxv ) { maxv = dp[n][j]; weight = j;}
        
        cout << "Case " << setnum << ":" << endl;
        cout << maxv << endl;
        cout << weight << endl;
        setnum++;
    }

    return 0;

}

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

int main(){
	string str;
	int num[10][10];
	
	while(cin >> str){
		for(int i = 0; i < 10; i++){
			num[0][i] = str[i] - 48;
		}
		for(int i = 1; i < 10; i++){
			for(int j = 0; j < 10 - i; j++){
				num[i][j] = (num[i - 1][j] + num[i - 1][j + 1]) % 10;
			}
		}
		
		cout << num[9][0] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1180
INF = 1000000007

def ex_gcd(a, b):
	x1, x2 = 0, 1
	y1, y2 = 1, 0
	q = 0
	while b:
		x1, x2 = x2, x1 - q * x2
		y1, y2 = y2, y1 - q * y2
		q = a // b
		a, b = b, a % b
	return a, x2, y2

def invert(x, mod=INF):
	return ex_gcd(x, mod)[1] % mod

B, W = map(int, input().split())

p = 0
q = 0
c1, c2 = 0, 1
d1, d2 = 0, 1
s = 1
for k in range(1, B + W + 1):
	if B + 1 < k:
		c1 = c2
		c2 *= invert((k - 1) - B) * (k - 1) % INF
		c2 %= INF
	if W + 1 < k:
		d1 = d2
		d2 *= invert((k - 1) - W) * (k - 1) % INF
		d2 %= INF
	if B < k:
		p += (c2 - c1) * s % INF
		p %= INF
	if W < k:
		q += (d2 - d1) * s % INF
		q %= INF
	print((q + invert(2) * (1 - p - q)) % INF)
	s *= invert(2)
	s %= INF


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

const int INF=1<<27;

int main(){
  int n,m,s,g1,g2;
  while(cin>>n>>m>>s>>g1>>g2,n){
    s--;g1--;g2--;
    int dik[100][100];
    for(int i=0;i<n;i++) 
      for(int j=0;j<n;j++)
	if(i == j )dik[i][j] = 0;
	else dik[i][j]=INF;
    while(m--){
      int b1,b2,c;
      cin>>b1>>b2>>c;
      dik[b1-1][b2-1]=c;
    }

    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  dik[i][j]=min(dik[i][j],dik[i][k]+dik[k][j]);
    int ans=dik[s][g1]+dik[s][g2];
    for(int i=0;i<n;i++) ans = min(ans,dik[s][i]+dik[i][g1]+dik[i][g2]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}

int run() {
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++){
        for(int j=l-1;j>=0;j--){
            string ch="";
            for(int k=0;k<i;k++)
                ch+=s[k];
            for(int k=j+1;k<l;k++)
                ch+=s[k];
            if(ch=="keyence"){
                cout<<"YES";
                return 0;
            }
        }
    }
    cout<<"NO";
}








































Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=998244353;
const int N=2e5+10;
const int inf=1e9;
int n,m,k;
ll f[N];
ll ksm(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll C(ll n,ll m){
	return f[n]*ksm(f[n-m],mod-2)%mod*ksm(f[m],mod-2)%mod;
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>m>>k;
	ll ans=0;
	f[0]=1;
	rep(i,1,n) f[i]=f[i-1]*i%mod;
	rep(i,0,k){
		ans=(ans+m*ksm(m-1,n-i-1)%mod*C(n-1,i)%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

vector<int> Z_Algorithm(string& S) {
  vector<int> A(S.size());
  A[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
  return A;
}

int main()
{
  int N;
  string S;
  cin >> N >> S;

  int ans = 0;
  for (int i = 0; i < N; i++) {
    string T = S.substr(i);
    vector<int> lcp(move(Z_Algorithm(T)));
    for (int j = 0; j < T.size(); j++) {
      int l = min(lcp[j], j);
      ans = max(ans, l);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
n = int(input())
arr = list(map(int, input().split()))

even_arr = list(filter(lambda x: x % 2 == 0, arr))

flag = True
for i in even_arr:
    if i % 3 != 0 and i % 5 != 0:
        flag = False
        break
    
if flag: print("APPROVED")
else: print("DENIED")

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string X; cin >> X;
    int cnt = 0, minus = 0;
    for(int xi: X){
        if(xi == 'S') cnt++;
        else cnt--;
        if(cnt < 0){
            minus++;
            cnt++;
        }
    }
    cout << minus * 2 << endl;
}

Measured memory_bytes: 720
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Point[] red = new Point[N];
		for (int i = 0; i < N; i++)
			red[i] = new Point(sc.nextInt(), sc.nextInt());
		Point[] blue = new Point[N];
		for (int i = 0; i < N; i++)
			blue[i] = new Point(sc.nextInt(), sc.nextInt());
		sc.close();

		Arrays.sort(red, (pt1, pt2) -> (pt2.y - pt1.y));
		Arrays.sort(blue, (pt1, pt2) -> (pt1.x - pt2.x));

		int ans = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (red[j] == null)
					continue;
				if (red[j].x < blue[i].x && red[j].y < blue[i].y) {
					red[j] = null;
					ans++;
					break;
				}
			}
		}

		System.out.println(ans);
	}
}

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

int main(){
	int n,i,j,cnt=0,d;
	cin>>n;
	int a[n];
	for(i=0; i<n; i++){
		cin>>a[i];
	}
	for(i=0; i<n; i++){
		d=1;
		for(j=2; j<=sqrt(a[i]); j++){
			if(a[i]%j==0){
				d=0;
				break;
			}
		}
		if(d==1) cnt++;
	}
	cout<<cnt<<"\n";
}


Measured memory_bytes: 3100
n,goukei = map(int, input().split())
xx,yy,zz = -1,-1,-1
xmax = goukei // 10000
for x in range(0,xmax+1):
  if xx > -1:
    break
  ymax = (goukei-x*10000) // 5000
  for y in range(0, ymax+1):
    ztmp = goukei - (x*10000)- (y*5000)
    if ztmp % 1000 == 0:
      z = ztmp // 1000
      sumxyz = x+y+z
      if sumxyz == n:
        xx,yy,zz = x,y,z
        break

print(xx,yy,zz)

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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.ReadLine();
			var もうちょっとで解けたのにーーー = Console.ReadLine().Split(' ').Select(ダメやった => decimal.Parse(ダメやった));

			Console.WriteLine(もうちょっとで解けたのにーーー.Sum(おしい => おしい - 1));

			return;
		}
	}
}


Measured memory_bytes: 13316
#include<bits/stdc++.h>
#define   ll  long long int
#define   sz  1000100

using namespace std;

ll num[sz];
ll ara[sz];

int main()
{


    ll n,x,y,a,b,i,j,p,d,z,c=1;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>num[i];
    }

    ll m=n/2+1;

    ara[m]=num[1];
    i=m+1;
    j=m-1;

    for(x=2;x<=n;x++)
    {
        if(n%2==0)
        {
            if(c%2==1)
            {
                ara[j]=num[x];
                j--;
            }
            else
            {
                ara[i]=num[x];
                i++;
            }
        }
        else
        {
             if(c%2==0)
            {
                ara[j]=num[x];
                j--;
            }
            else
            {
                ara[i]=num[x];
                i++;
            }
        }
        c++;
    }


    for(i=1;i<n;i++)cout<<ara[i]<<" ";

    cout<<ara[n]<<endl;

    return 0;
}



Measured memory_bytes: 7808
#include<stdio.h>
int main(void)
{
	int i,j,n,k,q,sum,a,s[100001],x[100001];
	scanf("%d %d %d",&n,&k,&q);
	for(i=1;i<=n;i++){
		s[i]=k;
		x[i]=0;
	}
	for(i=0;i<q;i++){
		scanf("%d",&a);
		x[a]++;
	}
	for(i=1;i<=n;i++){
		s[i]=s[i]-(q-x[i]);
	}
	for(i=1;i<=n;i++){
		if(s[i]<=0){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
	}
	return 0;
}
	

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**6)

N = int(input())
A = list(map(int,input().split()))

B = [-1]*N
for j in range(N//2 + 1,N+1):
    B[j-1] = A[j-1]

def rec(i):
    if B[i-1] != -1:
        return B[i-1]
    res = A[i-1]
    for j in range(2*i,N+1,i):
        res -= rec(j)
        res %= 2
    B[i-1] = res
    return res

rec(1)
b = [i for i in range(1,N+1) if B[i-1] == 1]
M = len(b)

print(M)
if b != []:
    print(*b)

Measured memory_bytes: 14452
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		String str = "";
		outside : for(int i = 0; i <= S.length() - T.length(); i++) {
			StringBuilder sb = new StringBuilder(S);
			sb = sb.replace(i, i + T.length(), T);
			//System.out.println(sb);
			for(int j = 0; j < S.length(); j++) {
				if(!sb.substring(j, j + 1).equals("?")) {
					if(j >= i && j <= i + T.length()) {
						if(!S.substring(j, j + 1).equals("?")) {
							if(!sb.substring(j, j + 1).equals(S.substring(j, j + 1))) {
								continue outside;
							}
						}
						//System.out.println(sb.substring(j, j + 1)+":"+sb);
					}else if(S.substring(j, j + 1).equals(sb.substring(j, j + 1))) {
						//System.out.println(sb.substring(j, j + 1)+":"+sb);
					} else {
						//System.out.println(sb.substring(j, j + 1)+":"+"No");
						continue outside;
					}
				} else {
					sb.replace(j, j + 1, "a");
					//System.out.println(sb.substring(j, j + 1)+":"+sb);
				}
			}
			str = sb.toString();
		}
		if(str == "") {
			System.out.println("UNRESTORABLE");
		} else {
			System.out.println(str);
		}
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
//template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

template<class E, class Q,typename C=typename remove_reference<decltype(get<0>(declval<Q&>()))>::type>
struct Dijkstra{
    C maxVal=numeric_limits<C>::max();
    int n;
    vector<vector<E>> edge;
    vector<vector<vector<C>>> distance;
    Dijkstra(int N):n(N){
        edge.resize(n);
        distance=vector<vector<vector<C>>>(n,vector<vector<C>>(n,vector<C>(31,maxVal)));
    }
    void add(int a, E stat, bool dir=true){
        edge[a].push_back(stat);
        if(!dir)return;
        swap(a,get<0>(stat));
        edge[a].push_back(stat);
    }
    C dist(int s,int g){
        auto cmp=[](Q a,Q b){return get<0>(a)>get<0>(b);};
        priority_queue<Q,vector<Q>,decltype(cmp)> pq(cmp);
        C ret=maxVal;
        pq.emplace(0,s,s,0); /*初期値*/
        while(!pq.empty()){ /*中身は自分で書く*/
            double cost;
            int prev,curr,spd;
            tie(cost,prev,curr,spd)=pq.top(); pq.pop();
            if(distance[curr][prev][spd]!=maxVal) continue;
            distance[curr][prev][spd]=cost;
            if(curr==g and spd==1){
                ret=cost;
                break;
            }
            for(auto e:edge[curr]){
                int next,len,limit;
                tie(next,len,limit)=e;
                if(next==prev)continue;
                if(spd+1<=limit and distance[next][curr][spd+1]==maxVal)
                    pq.emplace(cost+(C)len/(spd+1),curr,next,spd+1);
                if(spd<=limit and distance[next][curr][spd]==maxVal)
                    pq.emplace(cost+(C)len/(spd),curr,next,spd);
                if(spd-1<=limit and spd-1>0 and distance[next][curr][spd-1]==maxVal)
                    pq.emplace(cost+(C)len/(spd-1),curr,next,spd-1);
            }
        }
        return ret;
    }
};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,m;
	while(cin>>n>>m,n){
	    int s,g; cin>>s>>g;
	    Dijkstra<tuple<int,int,int>,tuple<double,int,int,int>> ds(n+1);
	    rep(i,m){
	        int x,y,d,c;
	        cin>>x>>y>>d>>c;
	        ds.add(x,make_tuple(y,d,c));
	    }
	    auto ans=ds.dist(s,g);
	    if(ans==numeric_limits<double>::max()){
    	    cout<<"unreachable"<<endl;
	    }else{
	        cout<<setprecision(5)<<fixed<<ans<<endl;
	    }
	}
	return 0;
}



Measured memory_bytes: 15500
#include "stdio.h"
int main(){
    int a,b,c,d,e,ave;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    if (a <= 39)a = 40;
    if (b <= 39)b = 40;
    if (c <= 39)c = 40;
    if (d <= 39)d = 40;
    if (e <= 39)e = 40;
    ave = (a + b + c + d + e) / 5;
    printf("%d\n",ave);
    return 0;
}

Measured memory_bytes: 600
N = int(input())
s = [""]*N
t = [""]*N

for i in range(N):
    ls = input().split()
    s[i] = ls[0]
    t[i] = ls[1]
    t[i] = int(t[i])
X = input()

index=0
for i in range(N):
    if s[i]==X:
        index=i+1

ans=0
if index==N:
    print(0)
    exit()
else:
    for i in range(index,N):
        ans+= t[i]

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
 
int main(void){
  char d[10];
  scanf("%s",d);
  if(strcmp(d,"Sunny")==0){
    printf("Cloudy\n");
  }else if(strcmp(d,"Cloudy")==0){
    printf("Rainy\n");
  }else{
    printf("Sunny\n");
  }
  return 0;
}


Measured memory_bytes: 1552
import java.util.Scanner;

/**
 *
 * @author k17075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int i = 0;
        int x,y;
        Scanner sc = new Scanner(System.in);
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if (x == 0 && y == 0) break;
            if(x>y){
                System.out.println(y + " " + x);
            }else{
                System.out.println(x + " " + y);
            }
        }
    }
}


Measured memory_bytes: 36512
n = gets.chomp("").to_i


a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
c = gets.split(" ").map(&:to_i)

sum = 0
n.times do |i|
  sum += b[a[i]-1]
  if !a[i+1].nil? && a[i]+1 == a[i+1]
    sum += c[a[i]-1]
  end
end

puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define LL long long
using namespace std;

int main(){
  int K, S;
  int ans=0;
  cin >> K >> S;
  REP(i, K+1){
    if(i > S)break;
    REP(j, K+1){
      int k = S - (i + j);
      if(0 <= k && k <= K)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

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

func main() {
	var L, R int
	fmt.Scan(&L, &R)

	if (R - L) >= 2019 {
		fmt.Println(0)
		return
	}

	L, R = L%2019, R%2019
	if L > R {
		fmt.Println(0)
		return
	}

	ans := 2019
	for i := L; i < R; i++ {
		for j := i + 1; j <= R; j++ {
			ans = intMin(ans, (i*j)%2019)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
 int main() {
	int n;
   cin>>n;
   int mx=1;
   unordered_map<string,int> m;
   while(n--) {
   	string s; cin>>s;
     if(m.find(s)!=m.end()) { m.find(s)->second =  m.find(s)->second+ 1; if( m.find(s)->second>mx) mx= m.find(s)->second; }
     else {
     	m.insert(mp(s,1));
     }
   }
   vector<string > str;
   for(auto i : m) {
   	if(i.second == mx) str.pb(i.first);
   }
   sort(str.begin(),str.end());
   for(auto i : str) cout<<i<<"\n";
 }

Measured memory_bytes: 26692
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int Alice = 0;
        int Bob   = 0;
        for (int i=0; i<N; i+=2) {
            Alice += a[i];
        }
        for (int i=1; i<N; i+=2) {
            Bob += a[i];
        }
        System.out.println(Alice - Bob);
    }
}

Measured memory_bytes: 35956
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
string X; 
cin >> X; 
int count = 0; 
int ans = 0; 
int L = X.size(); 
for (int i = 0; i < L; i++){
if(X.at(i) == 'S') {count ++;}
else{count --;}
ans = min(ans, count); 
}
cout << abs(ans) * 2 << endl; 
}

Measured memory_bytes: 640
n = int(input())
a = input()
b = [None] * (n + 1)
r = []
for i in range(n, 0, -1):
    b[i] = (ord(a[2 * i - 2]) + sum(b[i * 2::i])) % 2
    if b[i]:
        r.append(i)
print(len(r))
print(*r)


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

int H, heap[500010];

void maxHeapify(int i)
{
   int l, r, largest;
   l = i * 2;
   r = i * 2 + 1;

   //左の子、自分、右の子の中で最大のノードを選ぶ
   if( l<= H && heap[l] > heap[i])largest = l;
   else largest = i;

   if( r <= H && heap[r] > heap[largest] )largest = r;

   if( largest != i ) {
      swap(heap[i], heap[largest]);
      maxHeapify(largest);
   }
}

int main()
{
   scanf("%d", &H);
   reps(i, 1, H) {
      scanf("%d", &heap[i]);
   }

   for( int i = H /2; i >= 1; --i ) maxHeapify(i);

   reps(i, 1, H )printf( " %d", heap[i] );
   putchar_unlocked('\n');
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum,top,tutmac[N];

bool check(ll x)
{
	ll tut=0;
	fo(i,1,n)
		tutmac[i]=x-ar[i]%x;
	sort(tutmac+1,tutmac+n+1);
	int l=1;
	int r=n;
	while(l<r)
	{

		tutmac[r]=x-tutmac[r];
		ll y=min(tutmac[l],tutmac[r]);
		tutmac[l]-=y;
		tutmac[r]-=y;
		tut+=y;
		if(!tutmac[l])
			l++;
		if(!tutmac[r])
			r--;
		else
			tutmac[r]=x-tutmac[r];


	}
	if(tutmac[l])
		tut+=min(x-tutmac[l],tutmac[l]);
	return m>=tut;

}

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

	fs(ar,n);
	sort(ar+1,ar+n+1);

	fo(i,1,n)
		top+=ar[i];
	for(ll i=1;i*i<=top;i++)
	{
		if(top%i!=0)
			continue;
		// cout<<i<<sp<<top/i<<sp;
		if(check(i))
			sum=max(sum,i);
	
		if(check(top/i))
			sum=max(sum,top/i);
	}
	// cout<<endl;

	cout<<sum;

}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 2304
#include <stdio.h>

int main(){
    long long int a[100000];
    int n,i;
    int flag=1;

    long long int ans=1;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }

    for(i=0;i<n;i++){
        if(a[i]==0){
            printf("0");
            return 0;
        }
    }
    
    for(i=0;i<n;i++){
        if(ans==0) return printf("-1");
        if(a[i]>1000000000000000000/ans){
            printf("-1");  
            return 0;
        }
        ans*=a[i];
    }
    
    printf("%lld",ans);
    return 0;
    

}

Measured memory_bytes: 2508
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n, m, X, Y; cin >> n >> m >> X >> Y;
    int x[n+1], y[m+1];
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    for(int i=0; i<m; i++){
        cin >> y[i];
    }
    x[n] = X;
    y[m] = Y;

    int *pxmax = max_element(x, x+n+1);
    int *pymin = min_element(y, y+m+1);

    int xmax = *pxmax;
    int ymin = *pymin;
    
    if(xmax < ymin){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }

  int max = 0;
  for (int i = 0; i < N; i++) {
    int current = H.at(i);
    int next = i + 1;
    int move = 0;
    while (next < N) {
      if (current >= H.at(next)) {
        current = H.at(next);
        next++;
        move++;
      } else {
        break;
      }
    }
    if (move > max) {
      max = move;
      if (next > N) {
        break;
      } else {
        i = next - 1;
      }
    }
  }

  cout << max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T.at(i);
    }
    int M;
    cin >> M;
    vector<int> P(M), X(M);
    for (int i = 0; i < M; i++) {
        cin >> P.at(i) >> X.at(i);
        P[i]--;
    }

    int sum = accumulate(ALL(T), 0);
    for (int i = 0; i < M; i++) {
        cout << sum - T[P[i]] + X[i] << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2112
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    exit()
del d[0]
for i in range(n-1):
    if d[i]==0:
        print(0)
        exit()
dcnt=[0]*(n)
for i in range(n-1):
    dcnt[d[i]]+=1
for j in range(n-1,-1,-1):
    if dcnt[j]==0:
        del dcnt[j]
    else:
        break
if len(dcnt)==0:
    print(0)
    exit()
dcnt[0]=1
sum=1
for i in range(1,len(dcnt)):
    sum*=pow(dcnt[i-1],dcnt[i])
    sum%=998244353
print(sum)


Measured memory_bytes: 14008
MOD = 1000000007
 
def get_fibonatti_table(n):
    table = [1,1]
    for i in range(2, n+1):
        table.append(table[i-1]+table[i-2])
    return table

def solve():
    H,W,K = map(int, input().split())
    fib_table = get_fibonatti_table(W)
    dp_table = [[0 for _ in range(W+1)] for _ in range(H+1)]
    dp_table[0][1] = 1
    for h in range(1, H+1):
        for w in range(1,W+1):
            weight = fib_table[w-1]*fib_table[W-w]
            dp_table[h][w] = dp_table[h-1][w] * weight
            if 1 < w:
                # w-1を足す
                weight = fib_table[w-2]*fib_table[W-w]
                # print(w,weight)
                dp_table[h][w] += dp_table[h-1][w-1] * weight
            if w < W:
                # w+1を足す
                weight = fib_table[w-1]*fib_table[W-w-1]
                dp_table[h][w] += dp_table[h-1][w+1] * weight
                
    # print(dp_table)
    print(dp_table[H][K] % MOD)
    
solve()

Measured memory_bytes: 3064
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] sieve = new int[1000001];
         for(int d=2; d <= 1000000; d++)
            for(int v=d; v <= 1000000; v+=d)
               if(sieve[v] == 0)
                  sieve[v] = d;
         long res = 0L;
         for(int c=1; c < N; c++)
         {
            int product = N-c;
            long temp = 1L;
            while(product > 1)
            {
               int p = sieve[product];
               int cnt = 1;
               while(product%p == 0)
               {
                  product /= p;
                  cnt++;
               }
               temp *= cnt;
            }
            res += temp;
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 36860
#include <stdio.h>


int main(void){
    long int m=100000;
    int n,i;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        m = (long int)(m * 1.05)-1;
        m = (m/1000+1)*1000;
    }
            
    printf("%ld\n",m);
    
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
map<pair<int,int>,int>mp;
int dx[9] = {-1,-1,-1,0,0,0,1,1,1};
int dy[9] = {-1,0,1,-1,0,1,-1,0,1};
ll ans[12];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll h,w,n;
    cin>>h>>w>>n;
    vector<pair<int,int> > v;
    int x,y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        mp[{x,y}] = 1;
        for(int j=0;j<9;j++){
            int nx = x+dx[j];
            int ny = y+dy[j];
            if(nx<=0 or nx >h or ny<=0 or ny>w)continue;
            v.pb({nx,ny});
        }
    }
    if(n==0){
       cout<<(h-2)*(w-2)<<endl;
       for(int i=1;i<=9;i++)cout<<0<<endl;
       return 0;

    }
    sort(v.begin(),v.end());
    bool con = false;
    x = v[0].fi;
    y = v[0].se;
    int trt = 0;
    for(int j=0;j<9;j++){
        int nx = x+dx[j];
        int ny = y+dy[j];
        if(nx<=0 or nx >h or ny<=0 or ny>w){
            con = true;
        }
        if(mp.count({nx,ny}))trt++;
    }
    if(!con and trt>0)ans[trt]++;
    int z = v.size();
    for(int i=1;i<z;i++){
        if(v[i]==v[i-1])continue;
        x = v[i].fi;
        y = v[i].se;
        trt = 0;
        con = false;
         for(int j=0;j<9;j++){
            int nx = x+dx[j];
            int ny = y+dy[j];
            if(nx<=0 or nx >h or ny<=0 or ny>w){
                con = true;
            }
            if(mp.count({nx,ny}))trt++;
        }
       if(con)continue;
        if(trt==0)continue;
        ans[trt]++;

    }
    ans[0] = (h-2)*(w-2);
    for(int i=1;i<=9;i++)ans[0]-=ans[i];
    for(int i=0;i<=9;i++)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 14696
from itertools import product
def main():
    n, m = map(int, input().split())
    t = [[False]*n for _ in range(m)]
    for i in range(m):
        a = list(map(int, input().split()))
        for v in a[1:]:
            t[i][v-1] = True
    p = list(map(int, input().split()))
    ans = 0
    for a in product([True, False], repeat=n):
        f = True
        for i in range(m):
            cnt = 0
            for j in range(n):
                if t[i][j] and a[j]:
                    cnt += 1
            if cnt%2 != p[i]:
                f = False
                break
        if f:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n) {
        if (!(i&1) && a[i]&1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
# include <iostream>
# include <cstdio>
# include <algorithm>

using namespace std;

long long a[200010],b[200010];
long long N,K;
bool check(long long x)
{
	long long kk = 0;
	for (int i=1;i<=N;i++)
	{
		if (a[i]*b[N-i+1]<=x) continue;
		long long temp = x/b[N-i+1];
		kk+=a[i]-temp;
	}
	if (kk>K) return false;
	else return true;
}
int main(void)
{
//	freopen("aaa.in","r",stdin);
	scanf("%lld%lld",&N,&K); 
	for (int i=1;i<=N;i++)
	scanf("%lld",&a[i]);
	for (int i=1;i<=N;i++)
	scanf("%lld",&b[i]);
	sort(a+1,a+N+1);
	sort(b+1,b+N+1);
	long long l=0,r=10000000000005;
	long long ans = 0;
	while(l<=r)
	{
		long long mid = (l+r)>>1;
		if (check(mid))
			r =(ans=mid)-1;
		else
		    l = mid+1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    ll falg = 1;
    for(ll i = 0; i < s.size(); i++)
    {
        if(s[i] == '7')
            falg = 0;
    }
    if(!falg)
        cout<<"Yes";
    else
        cout<<"No";
}


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

int main() {
  	long n;
  	cin >> n;
  	if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
      cout << "hon" << endl;
    }
  	else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
      cout << "pon" << endl;
    }
  	else{
      cout << "bon" << endl;
    }
}


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

using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

int main() {
	int n,m;
	cin>>n>>m;
	vector<pair<ll,ll>> p(n);
	for(int i=0;i<n;i++){
	    cin>>p[i].first>>p[i].second;
	}
    sort(p.begin(),p.end());
	lli ans=0;
	for(int i=0;i<n;i++){
	    if(m>=p[i].second){
	        ans+=p[i].first*p[i].second;
	        m-=p[i].second;
	    }
	    else if(m<p[i].second){
	        ans+=m*p[i].first;
	        m=0;
	    }
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
n = gets.to_i
a = gets.strip.split.map(&:to_i)
b = gets.strip.split.map(&:to_i)
c = gets.strip.split.map(&:to_i)
a.sort!.reverse!
b.sort!
c.sort!
#二分探索は.bsearch_index{ }・・・これは条件を満たす最初のindexを返す
#二分探索だとO(logN)
sum = 0
for i in 0..n-1
  as = a.bsearch_index {|x| x < b[i]}
  if as == nil
    next
  end
  cs = c.bsearch_index {|x| x > b[i]}
  if cs == nil
    next
  end
  sum += (n-as)*(n-cs)
end
puts sum

Measured memory_bytes: 29264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int x;
  cin >> x;
  int c = x/100;
  if(c*100 <= x && x <= 105*c) cout << 1 << endl; 
  else cout << 0 << endl;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

//包括p但不包括r 
int partition(int *arr,int p,int r) {
	int x = arr[r-1];
	int i,j;
	for (j = p,i = p;j<r;j++) {
		if (arr[j] <= x) {
			int t = arr[i];
			arr[i] = arr[j];
			arr[j] = t;
			i++;
		}
	}
	return i-1;
}

int main() {
	int n;
	cin >> n;
	int *arr = new int[n];
	for (int i=0;i<n;i++) {
		cin >> arr[i];
	}
	int q = partition(arr,0,n);
	for (int i=0;i<n;i++) {
		if (i == q) {
			cout << "[" << arr[i] << "]";
		} else {
			cout << arr[i];
		}
		if (i == n-1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
}


Measured memory_bytes: 3396