akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> va(a);
  vector<int> vb(b);
  for (int i = 0; i < a; ++i) {
    cin >> va[i];
  }
  for (int i = 0; i < b; ++i) {
    cin >> vb[i];
  }
  vector<int> x(m);
  vector<int> y(m);
  vector<int> c(m);
  for (int i = 0; i < m; ++i) {
    cin >> x[i] >> y[i] >> c[i];
  }
  int min_va = *min_element(va.begin(), va.end());
  int min_vb = *min_element(vb.begin(), vb.end());
  int min_vavb = min_va + min_vb;
  int mn = INF;
  for (int i = 0; i < m; ++i) {
    int z = va[x[i] - 1] + vb[y[i] - 1] - c[i];
    mn = min(mn, z);
  }
  cout << min(min_vavb, mn) << endl;
}


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

int main()
{
    int a,b,temp;
    cin>>a;
    cin>>b;

    if(a==1)
    {
        if(b==3)
        {
            temp=2;
        }
        else if(b==2)
        {
            temp=3;
        }
    }

    if(a==2)
    {
        if(b==3)
        {
            temp=1;
        }
        else if(b==1)
        {
            temp=3;
        }
    }

    if(a==3)
    {
        if(b==2)
        {
            temp=1;
        }
        else if(b==1)
        {
            temp=2;
        }
    }

    cout<<temp;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;
 
pi a[100005];

bool cmp(pi x, pi y){
	return x.se < y.se;
}

int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n, m; cin >> n >> m;
	rep(i, m) cin >> a[i].fi >> a[i].se;
	sort(a, a + m, cmp);
	int cur = 0, cnt = 0;
	rep(i, m){
		if(a[i].fi >= cur){
			++cnt;
			cur = a[i].se;
		}
	}
	print(cnt);
	return 0;
}  

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

char s[1005][1005];
int main() {
	int h, w, a, b;
	scanf("%d %d %d %d", &h, &w, &a, &b);
	swap(a, b);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i < a && j < b) s[i][j] = '1';
			else if (i >= a && j >= b)
				s[i][j] = '1';
			else
				s[i][j] = '0';
		}
		s[i][w] = 0;
	}
	for (int i = 0; i < h; i++) printf("%s\n", s[i]);
}


Measured memory_bytes: 2176
import java.util.*;

public class Main{

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

        int min1 = 2001;
        for(int i=0; i<3; i++) min1 = Math.min(min1,sc.nextInt());
        int min2 = 2001;
        for(int i=0; i<2; i++) min2 = Math.min(min2,sc.nextInt());
        System.out.println(min1+min2-50);
    }
}

Measured memory_bytes: 17164
using System;

namespace CADDi_2018_for_Beginners_2
{
    class Class2
    {

        public static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);
            int H = int.Parse(input1[1]);
            int W = int.Parse(input1[2]);

            int count = 0;

            for(int i = 0; i < N; i++)
            {
                string[] input2 = Console.ReadLine().Split(' ');
                int X = int.Parse(input2[0]);
                int Y = int.Parse(input2[1]);

                if(X >= H && Y >= W)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 人数 - 取得
	int liHCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liHCnt);

	// 所持金 - 取得
	int liItm = 1;
	long long llSum = 0;
	for (i = 0; i < liHCnt; i++) {
		int liMoney;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d", &liMoney);

		// 回数 - 加算
		llSum += (liMoney - 1) / liItm;

		// 商品費用
		if (liItm == liMoney) {
			liItm++;
		}
		else if (liItm == 1) {
			liItm = 2;
		}
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llSum);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 256
A, B = map(int, input().split())

a = int(A // 0.08) + 1
b = int(B // 0.1) + 1

ab = []
ab.append(min(a, b))
ab.append(max(a, b))

for i in ab:
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        exit(0)

print('-1')

Measured memory_bytes: 3064
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int m;
    cin >> m;
    long long sum = 0;
    long long acnt = 0;
    while (m--) {
        int d;
        long long cnt;
        cin >> d >> cnt;
        sum += cnt * d;
        acnt += cnt;
    }
    cout << (sum-1)/9 + acnt - 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{  
    // 整数の入力
    int a;
    cin >> a;
    //int len = a.length();
    int count = 0;

    //int judge = 0;
    string s ;
    int len =0;
    int j = 0;
    s = to_string(a);
    len = s.length();
    // スペース区切りの整数の入力
    for ( int i = 0 ; i < len ; i ++)
    {
        //itoa(i,s,10);
        if(s[i] == '2')
            {
                count ++;
            }
       
      
            
    }
    cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
x,k,d = map(int,input().split())
c = abs(x)
if c>k*d:
    print(c-k*d)
    exit()
n = -(-c//d)
ans = abs(c-n*d)
if (k-n)%2==1:
    print(abs(ans-d))
else:
    print(ans)


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

using namespace std;

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

    vector<vector<long long>> dp(n, vector<long long>(2));

    dp[0][0] = a[0];
    dp[0][1] = -1e12;

    for(int i = 1; i < n; i++){
        //-1倍しない場合
        dp[i][0] = a[i] + max(dp[i-1][0], dp[i-1][1]);
        //-1倍する場合
        dp[i][1] = -a[i] + max(dp[i-1][0] - 2*a[i-1], dp[i-1][1] + 2*a[i-1]);
    }

    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
//#include <conio.h>
#define fto(i,x,y) for(i=(x);i<=(y);i++)
#define fdto(i,x,y) for(i=(x);i>=(y);i--)
#define ftoi(i,x,y) for(int i=(x);i<=(y);i++)
#define fdtoi(i,x,y) for(int i=(x);i>=(y);i--)
#define ll long long
#define ld double
#define oo (ll) 2000000000
#define ull unsigned long long
#define ui unsigned int
#define zero 1E-6
#define ii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define miii map<int,int>::iterator
#define ftoimii(it,m) for(map<int,int>::iterator it=m.begin();it!=m.end();it++)
#define ftoimsi(it,m) for(map<string,int>::iterator it=m.begin();it!=m.end();it++)

#define bug(x) printf("%d ", x)
#define sbug(x) printf("%s ", x);
#define abug(a,x,y) ftoi(i,x,y){printf("%d ",a[i]);}
#define wait() getch()
using namespace std;

int main () {
  int A, B, C, X;
  scanf ("%d%d%d", &X, &A, &B);
  printf ("%d", (X-A) % B);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll a[N];
int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++){
        if(a[i]>=a[i-1])
            continue;
        else{
            ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5168
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;
 
void task(){
 	int n; cin >> n;
 	int a;
 	int cnt=0;
 	for(int i=1; i<=n; i++){
 		cin >> a;
 		if((i%2==1) and (a%2==1))cnt++;
 	}
 	cout << cnt << endl;
}

int main(){
        _
        #ifdef OJ
        freopen("inputf.in", "r", stdin);
        freopen("outputf.in", "w", stdout);
        #endif

        int T = 1; //cin >> T;
        while(T--){
            task();
        }
        
return 0;
}




Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K,ans,X;
char a;



int main(){
    cin >> a;
    a = a + 1;
    cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main(){
        int n,m,a[100],b[100],c[100],d[100],count=0,sm,s;
        cin>>n>>m;
        for(int i=0;i<n;i++)cin>>a[i]>>b[i];
        for(int j=0;j<m;j++)cin>>c[j]>>d[j];
        for(int k=0;k<n;k++){
    		s=1000000000;
    		sm=0;
    		for(int l=0;l<m;l++){
    			count=abs(a[k]-c[l])+abs(b[k]-d[l]);
    			if(s>count){
    				sm=l;
    				s=count;
    			}
    			count=0;
    		}
    		cout<<sm+1<<endl;
    		sm=0;
    	}
    	return 0;	
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    sort(p.begin(), p.end());
    int ans=0;
    rep(i, n)ans+=p[i];
    ans -= p[n-1]/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0
for i in range(N):
  j_start = ans + 1
  j_end = (N - i) // 2 + 1
  for j in range(j_start, j_end):
    base = S[i:i+j]
    if base in S[i+j:]:
      ans = max(ans, j)
    else:
      break


print(ans)

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

int main() {
	
	int n;
  	cin>>n;
	vector<vector<int>> input(n,vector<int> (3));
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    {
	        cin>>input[i][j];
	    }
	}
	
	
	vector<int> dp(3,0);
	dp[0]=input[0][0];	dp[1]=input[0][1];	dp[2]=input[0][2];
	for(int i=1;i<n;i++)
	{
	    vector<int> day(3,0);
	    for(int j=0;j<3;j++)
	    {
	        for(int k=0;k<3;k++)
	        {
	            if(j!=k)
	            {
	                day[j]=max(day[j],dp[k]+input[i][j]);
	            }
	        }
	    }
	   // day[0]=max(dp[0]+input[i][1],dp[0]+input[i][2]);
	   // day[1]=max(dp[1]+input[i][0],dp[1]+input[i][2]);
	   // day[2]=max(dp[2]+input[i][1],dp[2]+input[i][0]);
	    dp = day;
	}
	sort(dp.begin(),dp.end());
	cout<<dp[2]<<endl;
    return 0;

}


Measured memory_bytes: 5760
N, K = map(int, input().split())
l = [0]*(10**5+1)

for _ in range(N):
    a, b = map(int, input().split())
    l[a] += b

total = 0
for i, n in enumerate(l):
    total += n
    if total>=K:
        print(i)
        break

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

int main(){
  int n,f[45];
  cin >> n;
  f[0]=1;
  f[1]=1;
  for(int i = 2; i <=n; i++){
    f[i] = f[i-2] + f[i-1];
  }

  cout << f[n] << endl;
  return 0;
}

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

int gcd(int x,int y);

int main(){
   while(true){
      int a,b;
      cin >> a >> b;
      if(cin.eof())
         break;
      int c=gcd(a,b);
      cout << c << ' ' << a/c*b << endl;
   }
   return 0;
}

int gcd(int x,int y){
   if(y==0)
      return x;
   return gcd(y,x%y);
}   

Measured memory_bytes: 2996
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
int cnt=0;
int get_g(int m,int n){
    if(m == 0)return n;
    if(n == 0)return m;
    if(max(m,n)%min(m,n) == 0)return min(m,n);
    
    return get_g(min(m,n),max(m,n)%min(m,n));
}

int main(){
    int n;
    cin >> n;
    int maxg=1;
    vector<int>a,L,R;
    a.resize(n);
    L.resize(n);
    R.resize(n);
    for(int i=0;i<n;i++)cin >> a[i];
    L[0]=0;
    R[n-1]=0;
    for(int i=0;i<n-1;i++)L[i+1]=get_g(L[i],a[i]);
    for(int i=n-2;i>=0;i--)R[i]=get_g(R[i+1],a[i+1]);
    for(int i=0;i<n;i++)maxg=max(maxg,get_g(L[i],R[i]));

    cout << maxg << endl;
    
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,Z,W;
  cin >> N >> Z >> W;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
  if(N==1) cout << abs(A.at(N-1)-W) << endl;
  else cout << max(abs(A.at(N-1)-W),abs(A.at(N-1)-A.at(N-2))) << endl;
}

Measured memory_bytes: 256
N = int(input())
# cnt[i][j] := 先頭がi, 末尾がjで始まるような数
cnt = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
    cnt[int(str(n)[0])][int(str(n)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>

int main(void)
{
    int N;
    std::cin >> N;

    std::vector<int> A;
    int tmp;
    for (int i = 0; i < N; ++i)
    {
        std::cin >> tmp;
        A.push_back(tmp);
    }
    std::cout << std::accumulate(A.begin(), A.end(), 0) - N << std::endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

N = int(input())
a = [int(input()) for x in range(N)]

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

res = gcd(*a)
if res % 2 == 0:
    print("second")
else:
    print("first")

Measured memory_bytes: 11732
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 998244353
#define pl(a,b) a=(a+b)%mod;
#define N 350
ll dp[N][N][N];
int main(){
	string S;
	ll K;
	cin>>S>>K;
	ll n=0,a[N];
	ll cnt=0;
	rep(i,S.size()){
		if(S[i]=='0'){
			a[++n]=cnt;
			cnt=0;
		}
		else{
			cnt++;
		}
	}
	a[++n]=cnt;
	chmin(K,(ll)310);
	rep(i,N)rep(j,N)rep(k,N)dp[i][j][k]=0;
	dp[0][0][0]=1;
	for(ll i=1;i<=n;i++){
		ll cs1[N][N],cs2[N][N];
		rep(j,N)for(ll k=0;k<=K;k++){
			if(j-1>=0&&k-1>=0){
				cs1[j][k]=cs1[j-1][k-1];
			}
			else{
				cs1[j][k]=0;
			}
			pl(cs1[j][k],dp[i-1][j][k]);
			pl(dp[i][j][k],cs1[j][k]);
			/*for(ll s=0;j-s>=0&&k-s>=0;s++){
				pl(dp[i][j][k],dp[i-1][j-s][k-s]);
			}*/
		}
		for(ll j=N-1;j>=0;j--)for(ll k=0;k<=K;k++){
			if(j+2<N){
				cs2[j][k]=cs2[j+1][k];
			}
			else{
				cs2[j][k]=0;
			}
			pl(cs2[j][k],dp[i-1][j][k]);
			pl(dp[i][j][k],cs2[j+1][k]);
			if(j+a[i]+1<N){
				pl(dp[i][j][k],-cs2[j+a[i]+1][k]);
			}
			/*for(ll t=1;t<=a[i]&&j+t<N;t++){
				pl(dp[i][j][k],dp[i-1][j+t][k]);
			}*/
		}
	}
	ll ans=0;
	for(ll k=0;k<=K;k++){
		pl(ans,dp[n][0][k]);
	}
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 340508
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni(),m=ni();
        int corr=0;
        int wrong=0;
        int[]A=new int[n+1];
        boolean[]B=new boolean[n+1];
        
        for (int x=0;x<m;x++) {
            int v=ni();
            if (next().equals("AC")) {
                if (!B[v]) { corr++; B[v]=true; wrong+=A[v]; }
            }
            else {
                if (!B[v]) A[v]++;
            }
        }
        
        System.out.println(corr+" "+wrong);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 41040
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for a in range(A+1):
    for b in range(B+1):
        if (X-a*500-b*100)/50 <= C and (X-a*500-b*100)/50 >= 0:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	while(input.hasNextDouble()){
    		double x1 = input.nextDouble();
    		double y1 = input.nextDouble();
    		double x2 = input.nextDouble();
    		double y2 = input.nextDouble();
    		double x3 = input.nextDouble();
    		double y3 = input.nextDouble();
    		double x4 = (x1+x2+x3)/3.0;
    		double y4 = (y1+y2+y3)/3.0;
    		double px = input.nextDouble();
    		double py = input.nextDouble();
    		if(notintersect(x1,y1,x2,y2,x4,y4,px,py) && notintersect(x2,y2,x3,y3,x4,y4,px,py) && notintersect(x3,y3,x1,y1,x4,y4,px,py)){
    			System.out.println("YES");
    		}else{
    			System.out.println("NO");
    		}
    	}
    }
    
    static boolean notintersect(double x1,double y1,double x2, double y2,double x3, double y3, double x4,double y4){
    	return (((x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3))*((x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4)) > 0);
    }
}

Measured memory_bytes: 23404
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
   long long int H, W,ans;
    cin >> H >> W;
    if(H==1||W==1){
      cout<<1<<endl;
    }
    else{  
     if (H % 2 == 0) {
        H = H / 2;
        ans = H * W;
    }
    else {
        H = (H / 2) + 1;
            ans = H * W - (W / 2);
        }
    cout << ans << endl;
    } 
           

}

















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

const int md = 1000000007;
 	
int main() 
{
	int n;
	scanf("%d", &n);
	int ans = 1;
	for (int i = 0; i < n; i ++) 
	{
		int x;
		scanf("%d", &x);
		if (x <= 2 * i) 
		{
			ans = (long long) ans * (i + 1) % md;
			n --;
			i --;
		}
	}
	for (int i = 1; i <= n; i++) 
		ans = (long long) ans * i % md;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import math
t = 1
for tc in range(t):
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        j = 1
        ans += (n-1) // i
        # while i*j + 1 <= n:
        #     ans += 1
        #     j += 1
    print(ans)


Measured memory_bytes: 9128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;

ll comb[51][51];

void com(int n){
	rep(i,n+1){
		rep(j,i+1){
			if(j==0||j==i){
				comb[i][j]=1LL;
			}
			else comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;cin>>n>>a>>b;
	vector<ll> v;
	com(n);
	rep(i,n){
		ll t;cin>>t;
		v.push_back(t);
	}
	sort(v.begin(),v.end(),greater<ll>());
	double sum=0.0;
	rep(i,a)sum+=v[i];
	sum/=a;
	int x=0,y=0;
	rep(i,n){
		if(v[i]==v[a-1]){
			x++;
			if(i<a)y++;
		}
	}
	ll ret=0LL;
	if(v[0]==v[a-1]){
		nrep(i,a,b+1){
			ret+=comb[x][i];
		}
	}
	else{
		ret+=comb[x][y];
	}
cout.precision(20);
cout<<fixed<<sum<<endl;
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<algorithm>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
   // cout<<t<<endl;
   if(t%1000!=0){
    int r=t/1000;
    r=r+1;
   // cout<<r<<endl;
    int res=(r*1000)-t;
    cout<<res<<endl;
   }
   else
   {
       cout<<0<<endl;
   }


    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

vector<int> monster;

int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  
  ll sum = 0;
  for(int i = 0; i < n; i++)
  {
    int num;
    scanf("%d", &num);
    sum += num;
    monster.push_back(num);
  }
  
  sort(monster.begin(), monster.end(), greater<int>());
  
  ll specials = 0;
  for(int i = 0; i < min(k, n); i++)
    specials += monster[i];
  
  printf("%lld\n", sum-specials);
  
  
  
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n , a[105] , sum = 0 ;
	cin >> n ;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i] ;
	}
	sort(a + 1, a + 1 + n) ;
	for(int i = 1 ; i <= n ; i++){
		if(a[i] != a[i + 1]){
			sum ++ ;
		}
	}
	cout << sum ;
	return 0;
}

Measured memory_bytes: 256
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n, m = nl()
a = nl()

csum = [0]
for x in a:
    csum.append((csum[-1] + x) % m)

d = dict()
ans = 0
for x in csum:
    t = d.get(x, 0)
    ans += t
    d[x] = t + 1
    
print(ans)

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    a-=d,c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
    break;
    }
    if(a<=0){
      cout<<"No"<<endl;
      break;
  }
  }
}

Measured memory_bytes: 3516
#include<iostream>
#define maxn 100006
#define ll long long
using namespace std;

ll DP[maxn][4];
int N;
int prof[maxn][4];


ll max(ll a, ll b) {
	if (a >= b) return a;
	return b;
}

ll cal(int pos, int type) {
	if (pos == N) {
		return 0LL;
	}

	ll &res = DP[pos][type];
	if (res != -1) {
		return res;
	}

	
	for (int i = 1; i <= 3; i++) {
		if (type != i) {
			res = max(res, prof[pos][i] + cal(pos + 1, i));
		}
	}
	return res;
}

int main() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> prof[i][1] >> prof[i][2] >> prof[i][3];
	}

	
		for (int k = 0; k < maxn; k++) {
			for (int i = 0; i <= 3; i++) {
				DP[k][i] = -1;
			}
		}



		cout << cal(0, 0) << endl;


	return 0;
}

Measured memory_bytes: 12800
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, M; cin >> N >> M;
    vector<int> div;
    for(int k=1; k*k<=M; k++) {
        if(M % k == 0) {
            div.push_back(k);
            if(M / k != k) div.push_back(M / k);
        }
    }

    int ans = -1;
    for(auto x : div) {
        int rest = M / x;
        if(rest >= N) chmax(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

const int N = 310;

int main()
{
	long long a[N];
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) cin >> a[i];
	long long state = 0;
	for (int i = 3; i <= n; i++)
		state ^= a[i];
	// a + b = a ^ b + 2 * (a & b) = state 
	long long p = a[1] + a[2];
	if (p < state) {
		printf("-1\n");
		return 0;
	}

	if ((p - state) & 1) {
		printf("-1\n");
		return 0;
	}

	long long r = (p - state) / 2;
	if (r & state) {
		printf("-1\n");
		return 0;
	}

	long long ans = r;
	for (int i = 50; i >= 0; i--) {
	    long long t = (1LL << i);
		if (!(state & t)) continue;
		if ((ans | t) <= a[1]) ans = ans | t;
	}

	if (ans == 0) printf("-1\n");
	else if (ans > a[1]) printf("-1\n");
	else {
		assert ((ans ^ (p - ans)) == state);
		printf("%lld\n", a[1] - ans);
	}
	return 0;
}


Measured memory_bytes: 3252
N, Y = map(int, input().split())
x = y = z = -1
for i in range(N+1):
    for j in range(N+1):
        k = N - i - j
        if k < 0:
            continue
        if i + j + k != N:
            continue
        if 10000 * i + 5000 * j + 1000 * k == Y:
            x = i
            y = j
            z = k
            break
print(x, y, z)


Measured memory_bytes: 3060
n = int(input())
#h, w, k = list(map(int, input().split()))
# A = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
p = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
count = 0
for i in range(1, n-1):
    if p[i] > p[i-1] and p[i] < p[i+1]:
        count += 1
    elif p[i] < p[i-1] and p[i] > p[i+1]:
        count += 1

print(count)


Measured memory_bytes: 9108
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main(void) {

	int n, num=0;

	cin >> n;

	for (int i = 0;; i++)
	{
		if (int(pow(2, i))<=n) {
			num = int(pow(2, i));
		}
		else break;
		
	}

	cout << num << "\n";

	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
d = [int(i) for i in input().split()]

ans = 10**6

for i in range(10**6):
    if ans != 10**6:
        break
    cnt = i
    if n > cnt:
        continue
    while cnt != 0:
        if cnt % 10 in d:
            break
        if cnt < 10:
            ans = i
            break
        cnt = cnt // 10
            
print(ans)

Measured memory_bytes: 3060
import math

x, k, d = (int(x) for x in input().split())

x = abs(x)
k1 = math.floor(x/d)

if k < k1 :
        k1 = k
else :
        k1 = k1

k2 = k1 - k

y = x - k1 * d

if k2%2 == 0 :
        print(abs(y))
else :
        print(abs(y - d))

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define N 300050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;
int n,ar[N];
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>ar[i];
    sort(ar,ar+n);
    reverse(ar,ar+n);
    int ans = ar[0];
    int cnt = 2;
    for(int i=1;i<n;i++){
        if(cnt==n)break;
        ans += ar[i];
        cnt++;
        if(cnt==n)break;
        ans += ar[i];
        cnt++;
    }
    cout<<ans;
  	return 0;
}



Measured memory_bytes: 5180
open System

let ReadIntArray() = Console.ReadLine().Split(' ') |> Array.map int64

let [|n; m; k|] = ReadIntArray() |> Array.map int
let A = ReadIntArray()
let B = ReadIntArray()

let GetPre (xs:int64[]) = 
    for i = 1 to xs.Length-1 do
        xs.[i] <- xs.[i-1] + xs.[i]
GetPre A
GetPre B

let GetUp (xs:int64[]) = 
    let mutable r = -1
    for i = 0 to xs.Length-1 do
        if xs.[i] <= int64(k) then 
            r <- i
    r

let mutable (pa, pb) = ((GetUp A), (GetUp B))

let mutable ans = max (pa + 1) (pb + 1)

pb <- -1

while (pa > -1) do
    while (pb + 1 < m) && (A.[pa] + B.[pb + 1] <= int64(k)) do
        pb <- pb + 1
    ans <- max ans (pa + pb + 2)
    pa <- pa - 1

Console.Write(ans)

Measured memory_bytes: 69332
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */
int ceil(int a, int b){
    if(a % b == 0) return a /b;
    else return a /b + 1;
}


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    int n = input();

    print(n * 800 - n/15 * 200);




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> A = vector<int>(N,0);
  
  for(int i = 0;i<2*M;i++){ 
    int x;
    cin >> x  ;
    A.at(x-1)++;
  }
  
  for(int i = 0;i<N;i++){
  	cout <<  A.at(i) <<endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String target = br.readLine();

        int count = 0;

        while(true){
            String input = br.readLine();
            String[] word = input.split(" ");

            if(word[0].equals("END_OF_TEXT")){
                break;
            }

            for(int i = 0; i < word.length; i++){
//              ??¨????°????????????????
                word[i] = word[i].toLowerCase();

                if(word[i].equals(target)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);	
	double a, b;
	cin >> a >> b;
	cout << fixed << showpoint << setprecision(10) << (a / (1.0 * b));
}

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

#define int long long int 

int32_t main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(n,vector<int>(3,0));
    for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
    cin>>s[i][j];
    int ans=INT_MIN;
    for(int i=0;i<8;i++)
    {
        vector<int> v;
        for(int j=0;j<n;j++)
        {
            int x=0;
            for(int k=0;k<3;k++)
            {
                
                if(((i>>k)&1)==0)
                x+=s[j][k];
                else
                x-=s[j][k];
            }
            v.push_back(x);
            
        }
        sort(v.begin(),v.end());
        std::reverse(v.begin(),v.end());
        int p=0;
        for(int j=0;j<m;j++)
        p+=v[j];
        ans=max(ans,p);
    }
    cout<<ans<<endl;
}
    

Measured memory_bytes: 3700
#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         998244353//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 dp[3005][3005],dp1[3005],n,s,a[3005];
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,c,f,k,b;
    	cin>>n>>s;
    	ll a[n];
    	rep(i,0,n)
    	cin>>a[i];
    	repi(i,1,n)
    	{
    		dp[i][a[i-1]]=i;
    		repi(j,a[i-1]+1,s)
    		{
    			dp[i][j]=dp1[j-a[i-1]];
			}
			repi(j,0,s)
			dp1[j]=(dp1[j]+dp[i][j])%mod;
		}
    	k=0;
    	repi(i,1,n)
    	{
    		k=(k+(dp[i][s]*(n-i+1))%mod)%mod;
		}
    	cout<<k;
	}
	return 0;
}

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

using namespace std;

int main() {
    int h, w; cin >> h >> w;
    vector <vector <char>> v(h, vector <char> (w));
    for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
        cin >> v[i][j];
    
    for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
    {
        if (v[i][j] != '#') {
        int res = 0;
        if (i - 1 >= 0) {
            if (j - 1 >= 0) res += (v[i - 1][j - 1] == '#');
            res += (v[i - 1][j] == '#');
            if (j + 1 < w) res += (v[i - 1][j + 1] == '#');
        }
        if (j - 1 >= 0) res += (v[i][j - 1] == '#');
        res += (v[i][j] == '#');
        if (j + 1 < w) res += (v[i][j + 1] == '#');
        if (i + 1 < h) {
            if (j - 1 >= 0) res += (v[i + 1][j - 1] == '#');
            res += (v[i + 1][j] == '#');
            if (j + 1 < w) res += (v[i + 1][j + 1] == '#');
        }
        v[i][j] = res + '0';
        }
    }
    
    for (auto elem : v) {
    for (auto elem1 : elem)
    cout << elem1;
    cout << endl;
    }
    
	return 0;
}

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

int main(){
    long long a, b;
    cin >> a >> b;
    long long sec = b - a + 1;
    long long ans;
    
    if(a % 2 == 0){
        if(sec % 2 == 0){
            if(sec % 4 == 0)ans = 0;
            else ans = 1;
        }else{
            if((sec - 1) % 4 == 0)ans = b;
            else ans = (1 ^ b);
        }
    }else{
        if(sec % 2 == 0){
            if((sec - 2) % 4 == 0)ans = (a ^ b);
            else ans = ((1 ^ a) ^ b);
        }else{
            if((sec - 1) % 4 == 0)ans = a;
            else ans = (1 ^ a);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, x; cin >> N >> x;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	sort(all(a));
	int ans = 0;
	rep(i, 0, N) {
		x -= a[i];
		if (x < 0)break;
		ans++;
	}
	if (x > 0)ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#import random
import numpy as np
def main():
  d=int(input())
  c=np.array(list(map(int,input().split())))
  s=[None]*d
  r0=[None]*d
  r1=[None]*d
  cm=np.array([0]*26)
  cd=np.array([0]*26)
#t=[None]*d
  for i in range(d):
    s[i]=list(map(int,input().split()))
  s=np.array(s)
#for i in range(d):
#  t[i]=int(input())-1
  for j in range(d):  
    #rand = np.random.randint(26, size = 10) 
    #print(np.argmax(s[j])+1)
    r_i=np.argmax(s[j])
    cd=c*cm
    if np.max(cd>s[i][r_i]):
      r_i=np.argmax(cd)
    r0[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  #r_i+=1
  #print(r_i)
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>80:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
#r0=t
  score0=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score0+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score0+=-np.sum(cd)
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
  #score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r1[j]
    cd=c*cm
    if rand[j]>75:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
    cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r1[j]
    cd=c*cm
    if rand[j]>60:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1

  for j in range(d):  
    print(r0[j]+1) 
 
main()

Measured memory_bytes: 27636
N, M = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
  a[k] //= 2

foo = 1
while a[0]%2 == 0:
  foo *= 2
  a[0] //= 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

for odd in [3, 5, 7]:
  flag = False
  for k in range(N):
    if a[k]%odd == 0:
      a[k] //= odd
      flag = True
  if flag:
    foo *= odd
 
 
import math

lcm = a.pop()
for k in range(1, N):
  b = a.pop()
  lcm = lcm * b // math.gcd(lcm, b)
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)



Measured memory_bytes: 20164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    bool flag = true;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        if (a % 2 == 1)
        {
            flag = false;
        }
    }
    if (flag)
    {
        cout << "second" << endl;
    }
    else
    {
        cout << "first" << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  char s[3010];
  scanf("%s",s);
  int R[3010];
  for(int i=0;i<n;i++){
    R[i]=i;
  }
  for(int i=0;i<m;i++){
    int l,r;
    scanf("%d%d",&l,&r);
    l--;
    r--;
    R[l]=max(R[l],r);
  }
  int S[3010];
  S[0]=0;
  for(int i=0;i<n;i++){
    S[i+1]=S[i]+(s[i]=='1'?1:0);
  }
  long long dp[2][3010]={0};
  bool b=0;
  dp[b][0]=1ll;
  int r=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      dp[!b][j]=0ll;
    }
    int nr=max(R[i]+1,r);
    int p=S[nr]-S[r];
    r=nr;
    //printf("%d %d %d\n",i,r,p);
    for(int j=0;j<=n;j++){
      if(dp[b][j]==0){
	continue;
      }
      if(r-i-(j+p)>0){
	ad(dp[!b][j+p],dp[b][j]);
      }
      if(j+p>0){
	ad(dp[!b][j+p-1],dp[b][j]);
      }
    }
    b=!b;
  }
  printf("%lld\n",dp[b][0]);
  return 0;
}


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

int N, M;
pair<int, int> jobs[100000];

int main(){
    long long ans = 0;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> jobs[i].first >> jobs[i].second;
    }
    sort(jobs, jobs + N);
    
    priority_queue<int> available_rewards;
    int next_job_idx = 0;
    for(int i = 1; i <= M; i++){
        while(next_job_idx < N && jobs[next_job_idx].first <= i){
            available_rewards.push(jobs[next_job_idx].second);
            next_job_idx++;
        }
        if(!available_rewards.empty()){
            ans += available_rewards.top();
            available_rewards.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1660