akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[18][18];
int kosu[18][18];
int ans;

int main(){
  int x,y;
  
  while(1){
    cin>>x>>y;
    if(x==0 && y==0) break;
    
    fill(dp[0],dp[18],0);
    fill(kosu[0],kosu[18],0);
    ans=0;
    
    for(int i=0;i<y;i++){
      for(int l=0;l<x;l++){
        cin>>kosu[i][l];
      }
    }
    for(int i=0;i<x;i++)
      if(kosu[0][i]==0) dp[0][i]=1;
    
    for(int i=0;i<y;i++){
      for(int l=0;l<x;l++){
        
        if(kosu[i][l]==2 && kosu[i+2][l]!=1){
          dp[i+2][l]+=dp[i][l];
          //dp[i][l]=0;
        }
        if(kosu[i][l]==0 && i < y - 1)
          for(int z=-1;z<2;z++)
            if(l+z >= 0 && l+z < x && (z==0 || kosu[i+1][l+z]==0)) 
            	dp[i+1][l+z]+=dp[i][l];
        if(kosu[i][l]==0 && i == y - 1) dp[y][l] += dp[y-1][l];
      }
    }
    for(int i=y;i<y+2;i++){
      for(int l=0;l<x;l++){
        ans+=dp[i][l];
      }
    }
    
    /*for(int i=0;i<y+2;i++){
	for(int j=0;j<x;j++) cout << dp[i][j] << ' ';
	cout << endl;
    }*/
    
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
void bfs(const vector<vector<bool>>&, vector<vector<int>>&, int x, int y);
int mx = 0;
int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> map(h + 2, vector<bool>(w + 2));
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        for(int j = 0; j < w; j++){
            if(s[j] == '.'){
                map[i + 1][j + 1] = true;
            }
        }
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(map[i][j]){
                vector<vector<int>> dis(h + 2, vector<int>(w + 2, -1));
                bfs(map, dis, i, j);
            }
        }
    }
    cout << mx;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void bfs(const vector<vector<bool>>& map, vector<vector<int>>& dis, int x, int y){
    queue<pair<int, int>> q;
    dis[x][y] = 0;
    q.emplace(x, y);
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int d = dis[p.first][p.second];
        mx = max(mx, d);
        for(int i = 0; i < 4; i++){
            int cx = p.first + dx[i];
            int cy = p.second + dy[i];
            if(!map[cx][cy] || dis[cx][cy] != -1) continue;
            dis[cx][cy] = d + 1;
            q.emplace(cx, cy);
        }
    }
}

Measured memory_bytes: 256
while 1:
    try:l=list(map(int,input().split(',')))
    except:break
    b,a=l.pop(),l.pop()
    t=a*(sum(l)/(a+b))
    m=0
    for i in range(10):
        if 0<t-m<l[i]:i+=1;break
        elif not t-m:break
        else:m+=l[i]
    print(i)

Measured memory_bytes: 7616
#include<iostream>
#include<cmath>

int main(){

    double a, b, c;
    std::cin >> a >> b >> c;

    auto s = 0.5 * a * b * std::sin(M_PI * c / 180.0);
    auto k = a + b + std::sqrt(a * a + b * b - 2.0 * a * b * std::cos(M_PI * c / 180.0));
    auto h = 2.0 * s / a;

    std::printf("%f %f %f\n", s, k, h);

    return 0;
}



Measured memory_bytes: 3444
#include<iostream>
using namespace std;
typedef long long ll;

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

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    ll ans = 1;
    for(ll i = 2; i*i <= g; i++){
        if(g%i) continue;
        ans++;
        while(g%i == 0) g /= i;
    }
    if(g != 1)    ans++;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {

	int n, k;
	cin >> n >> k;
	set<int> s;
	REP(i, k) {
		int d;
		cin >> d;
		REP(j, d) {
			int l;
			cin >> l;
			s.insert(l);
		}
	}

	cout << n - s.size() << endl;

}


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

using namespace std;

bool inRange(double l, double c, double r) {
    return l <= c && c <= r;
}

double dfs(int K, double R, double L, double P, double E, double T, double prob) {
    double center = (R+L) / 2;
    double ans = 0;

    if(inRange(T-E, R, T+E) && inRange(T-E, L, T+E)) return prob;
    if(T+E < R || T-E > L) return 0;
    if(K == 0) {
        if(inRange(T-E, center, T+E)) return prob;
        return 0;
    }
    
    if(center < T) {
        return dfs(K-1, center, L, P, E, T, prob*(1-P)) + dfs(K-1, R, center, P, E, T, prob*P);
    }
    else {
        return dfs(K-1, center, L, P, E, T, prob*P) + dfs(K-1, R, center, P, E, T, prob*(1-P));
    }

    return 0;
}

int main() {
    ios::sync_with_stdio(0);
    int K, R, L;
    cin >> K >> R >> L;
    double P, E, T;
    cin >> P >> E >> T;

    printf("%.6f\n", dfs(K, R, L, P, E, T, 1.0));

    return 0;
}

Measured memory_bytes: 0
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    long long n,sum;
    long long min,max;
    cin >> n;
    long long array[n];
    sum = 0;
    for (int i=0; i<n; ++i ){
    cin >> array[i];
    sum += array[i];
    }
    
    //cout << (long long)*max_element(array, array+n) << endl;
    
    min = *min_element(array, array+n);
    max = *max_element(array, array+n);
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  ll k;
  cin>>s>>k;
  ll n=sz(s);
  vector<vvll> dp(105,vvll(4,vll(2)));
  dp[0][0][0]=1;
  rep(i,n)rep(j,4)rep(u,2){
    ll nd=s[i]-'0';
    rep(d,10){
      ll ni=i+1,nj=j,nu=u;
      if(u==0){
        if(d>nd) continue;
        if(d<nd) nu=1;
      }
      if(d!=0) nj++;
      if(nj>3) continue;
      dp[ni][nj][nu]+=dp[i][j][u];
    }
  }
  COUT(dp[n][k][1]+dp[n][k][0]);
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  long long int a,b,c,x,y;
  while(scanf("%lld %lld",&a,&b) != EOF){
    x = a, y = b;
    while(b != 0){
      c=a%b;
      a=b;
      b=c;
    }
    printf("%lld %lld\n",a,x*y/a);
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;


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

    int n;
    cin >> n;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i<(n); i++)
using namespace std;
using P = pair<int,int>;
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i<(n); i++)
using namespace std;
using P = pair<int,int>;
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <set>

int main() {
    int a,b;
    cin >> a>>b;
    double ans; /* 計算結果 */
    ans =( double(a) + double(b))/2.0 + 0.999999;

    cout << (int) ans;

    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
using namespace std;
int main()
{
    string input;
    int num1, num2;
    cin >> num1;
    cin >> input;
    cin >> num2;
    if (input == "+")
    {
        cout << num1 + num2;
    }

    else if (input == "-")
    {
        cout << num1 - num2;
    }
    return 0;
}

Measured memory_bytes: 256
N, K, S = map(int, input().split())

if S == 10**9:
    ans = ' '.join([str(S) for _ in range(K)]+[str(1) for _ in range(N-K)])
else:
    ans = ' '.join([str(S) for _ in range(K)]+[str(S+1) for _ in range(N-K)])

print(ans)

Measured memory_bytes: 11272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n;
  cin >> n;
  n--;
  cout << n * (n+1) / 2 << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  //whytf you have to write such statements
  while(n>0){
    if(n%7==0||n%4==0)break;
    n-=4;
  }
  cout<<(n>0?"Yes":"No");
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

long long int i,j;

long long int solve(long long int a,long long int b,long long int c){
	return max(a,max(b,c))-min(a,min(b,c));
}

int main(){
	long long int n,k;
	cin>>n>>k;
	long long int a,b,ans;
	long long int dp[100005];
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++){
		cin>>a>>b;
		dp[a]+=b;
	}
	for(i=0;i<100005;i++){
		if(k<=dp[i]){
			ans = i;
			break;
		}else{
			k-=dp[i];
		}
	}

	//output
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
a = sorted(inl())
print(sum(a[:k]))

Measured memory_bytes: 9204
fun main(args: Array<String>) {
    val noUse = readLine()!!.toInt()
    val xl: List<Int> = readLine()!!.split(" ").map(String::toInt)
    val sortedxl = xl.sortedDescending()
    val a = sortedxl.filterIndexed{index, value -> index % 2 == 0}.sum()
    val b = sortedxl.filterIndexed{index, value -> index % 2 == 1}.sum()
    println(a - b)
}


Measured memory_bytes: 37864
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1e16;

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

int main() {
  int N;
  cin >> N;
  vector<ll> as(N + 1, 0);
  int a;
  for(int i = 1; i <= N; ++i) {
    cin >> a;
    as[i] = as[i - 1] + a;
  }
  ll ans = INF;
  for(int i = 1; i < N; ++i) {
    auto x = as[i];
    auto y = as[N] - as[i];
    chmin(ans, abs(x - y));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}
func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println((a * b) / gcd(a, b))

}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll choose(int n,int r){
	if(n<r)return 0;
	ll s=1;
	rep(i,0,r)s=s*(n-i)/(i+1);
	return s;
}

ll v[60];
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	rep(i,1,n+1)scanf("%lld",v+i);
	sortdown(v+1,n);
	
	ll s=0;
	rep(i,1,a+1)s+=v[i];
	printf("%.9f\n",(double)s/a);
	
	ll m=v[a];
	int l=a,r=a;
	while(l>1&&v[l-1]==m)l--;
	while(r<n&&v[r+1]==m)r++;
	if(l==1){
		//r個の中から、a個以上b個以下取る
		ll ans=0;
		rep(i,a-l+1,b-l+2)ans+=choose(r-l+1,i);
		printf("%lld\n",ans);
	}else{
		//r-l+1個の中から、a-l+1個とる
		printf("%lld\n",choose(r-l+1,a-l+1));
	}
	return 0;
}

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

using namespace std;

int sumDigits(int n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main () {
    int N, A, B; cin >> N >> A >> B;
    int res = 0;

    for (int i = 1; i <= N; i++) {
        int sum = sumDigits(i);

        if (A <= sum && sum <= B) {
            res += i;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <bitset> 

using namespace std;

#define daymax ( 30 + 1 )

int main(void){
	
	int n;

	while ( true ) {
		cin >> n;
		if( !n ) break;
		vector< bitset< 50 > > schedule( daymax );
		vector< vector< bitset< 50 > > > dp( daymax, vector< bitset< 50 > >( n ) );
		for( int i = 0; i < daymax; i++ )
			schedule[i].reset();
		for( int i = 0; i < n; i++ ) {
			int num;
			cin >> num;
			for( int j = 0; j < num; j++ ) {
				int tmp;
				cin >> tmp;
				schedule[tmp].set( i );
			}
		}

		for( int i = 0; i < dp.size(); i++ )
			for( int j = 0; j < dp[i].size(); j++ ) {
				dp[i][j].reset();
				dp[i][j].set(j);
			}

		int ans = -1;
		for( int i = 1; i < daymax && ans < 0 ; i++ ) {
			for( int j = 0; j < n && ans < 0; j++ ) {
				for( int k = 0; k < n && ans < 0 ; k++ ) {
					if( j == k || ( ( schedule[i].test(j) && schedule[i].test(k) ) ) ) {
						dp[i][j] |= dp[i-1][k];
					}
					if( dp[i][j].count() == n ) {
						ans = i;
					}
				}
			}
		}
		cout << ans << endl;

	}

	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int x;
    cin>>x;
    for(int a = 1 ; a <= 3500 ; a++){
        for(int b = 1 ; b <= 3500 ; b++){
            int num = a * b * x;
            int den = -(b * x) - (a * x) + (4 * a * b);
            if(num < 0 && den < 0){
                num *= -1 , den *= -1;
                if(num % den == 0 && num / den <= 3500){
                   cout<<a<<" "<<b<<" "<<num / den<<endl;
                    return;
                }
            }else if(num > 0 && den > 0){
                if(num % den == 0 && num / den <= 3500){
                    cout<<a<<" "<<b<<" "<<num / den<<endl;
                    return;
                }
            }
        }
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3624
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
z =[a, b, c]
x, y = map(int, input().split())
for i in z:
    if x in i:
        if y in i:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 2940
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, x, t) = InputLine.to_ia

  puts ((n.to_f / x.to_f).ceil.to_i * t)
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

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

    //freopen("input.txt", "r", stdin);

    string sa, sb;
    cin>>sa;
    sb=sa;

    if(sb[0]=='0')
        sb[0]='1';
    else
        sb[0]='0';

    int n=sa.length(), cna=0, cnb=1;

    for(int i=1; i<n; i++)
    {
        if(sa[i-1]==sa[i])
        {
            cna++;
            if(sa[i]=='0')
                sa[i]='1';
            else
                sa[i]='0';
        }
    }

    for(int i=1; i<n; i++)
    {
        if(sb[i-1]==sb[i])
        {
            cnb++;
            if(sb[i]=='0')
                sb[i]='1';
            else
                sb[i]='0';
        }
    }

    cout<<min(cna, cnb)<<endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int n = Integer.parseInt(s);
		int sn = 0;
		for (String str : s.split("")) {
			sn += Integer.parseInt(str);
		}

		if (n % sn == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define db(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#define rep(i,b)for(auto i=(0);i<(b);++i)
#define fo(i,a,b)for(auto i=(a);i<=(b);++i)
#define ford(i,a,b)for(auto i=(a);i>=(b);--i)
#define all(x) (x).begin(),(x).end()
#define vv vector
#define pb push_back
template<typename X>void MA(X&a,X b){a=max(a,b);}template<typename X>void MI(X&a,X b){a=min(a,b);}
template<typename X>void clr(X&x,int a){memset(x,a,sizeof(a));};typedef long long ll;typedef long double ld;
typedef array<int,2>i2;typedef vv<int>vi;int cond=0,multi=0,gcj=0;

struct solver_t;solver_t *solver;
struct solver_t{


  void solve(){
    ll N,H;cin>>N>>H;
    vv<ll>WIELD(N),TH(N);
    rep(i,N)cin>>WIELD[i]>>TH[i];

    sort(all(WIELD));

    ll best_wield=WIELD.back();
    sort(all(TH));
    ll turns=0;
    while(H>0){
      if(TH.size()&&TH.back()>best_wield){
        H-=TH.back();
        TH.pop_back();
        turns++;
      }
      else {
        turns+=(H+best_wield-1)/best_wield;
        break;
      }
    }
    cout<<turns<<"\n";
  }
  void gen(){}
  void brute(){}
};

int main(int argc,char** argv){
  fo(i,1,argc-1)for(int j=0;argv[i][j];j++)if(argv[i][j]=='.')freopen(argv[i],"r",stdin);
  fo(i,1,argc-1)if(argv[i]==string("q"))cond=1<<30;
  fo(i,1,argc-1)if(argv[i]==string("gen")){(solver=new solver_t())->gen();exit(0);}
  fo(i,1,argc-1)if(argv[i]==string("brute")){(solver=new solver_t())->brute();exit(0);}
  ios::sync_with_stdio(false),cin.tie(0);
  cout.setf(ios::fixed),cout.precision(10);int t;if(multi||gcj)cin>>t;else t=1;
  fo(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(gcj)cout<<"Case #"<<i<<": ";
    solver = new solver_t();
    solver->solve();
  }return 0;
}
template class std::vector<int>;
template class std::vector<ll>;


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const long long INF = LLONG_MAX / 10;
  int H, W, K;
  cin >> H >> W >> K;
  int dx[4] = {-1, 0, 0, 1};
  int dy[4] = {0, -1, 1, 0};
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--, y1--, x2--, y2--;
  string ike[H];
  for (int i = 0; i < H; i++) {
    cin >> ike[i];
  }
  using P = pair<int, int>;
  queue<pair<long long, P>> que;
  que.emplace(0, P(x1 * W + y1, -1));
  long long dist[H * W];
  fill(dist, dist + H * W, INF);
  dist[x1 * W + y1] = 0;
  while (!que.empty()) {
    long long cost;
    P p;
    tie(cost, p) = que.front();
    que.pop();
    int x = p.first / W, y = p.first % W;
    if (dist[p.first] < cost) continue;
    if (x == x2 && y == y2) break;
    for (int d = 0; d < 4; d++) {
      if (d == p.second) continue;
      int cx = x, cy = y;
      for (int i = 1; i <= K; i++) {
        cx += dx[d];
        cy += dy[d];
        if (cx < 0 || H <= cx || cy < 0 || W <= cy) break;
        if (ike[cx][cy] == '@') break;
        if (dist[cx * W + cy] <= dist[x * W + y]) break;
        if (dist[cx * W + cy] > cost + 1) {
          dist[cx * W + cy] = cost + 1;
          que.emplace(dist[cx * W + cy], P(cx * W + cy, 3 - d));
        }
      }
    }
  }
  cout << (dist[x2 * W + y2] == INF ? -1 : dist[x2 * W + y2]) << endl;
  return 0;
}


Measured memory_bytes: 14276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



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

	ll ans = -1;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
 ll n, k;
 cin >> n >> k;
 ll ans = 1;
 while(n / k > 0){
   n = n / k;
   ans++;
 }
 cout << ans << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> counts(100010, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    counts[A]++;
  }

  int totalEat = 0;
  bool isEating = false;
  for (int i = 0; i < 100010; i++) {
    if (counts[i] >= 3) {
      int eat = (counts[i] - 1) / 2;
      counts[i] -= 2 * eat;
      totalEat += eat;
    }

    if (counts[i] == 2) {
      counts[i] = 1;
      if (!isEating) {
        totalEat++;
      }
      isEating = !isEating;
    }
  }
  printf("%d\n", N - 2 * totalEat);

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int A[1000000];
    for(int i=0;i<n;i++)
        cin>>A[i];
    sort(A,A+n);
    if(A[n/2] == A[n/2-1])
    {
        cout<<0;
        return 0;
    }
    else
    {
        cout<<A[n/2] - A[n/2-1];
        return 0;
    }
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int n,k;
vi ans;
int pos;
void forword()
{
    //dbg(ans);
    if(ans[pos])
    {
        ans[pos]--;
        if(ans[pos])
        {
            for(int j=pos+1;j<n;j++) ans[j]=k;
            pos=n-1;
        }
        else pos--;
    }
}
int main()
{
    cin>>k>>n;
    if(k%2==0)
    {
        ans=vi(n);
        ans[0]=k/2;
        for(int i=1;i<n;i++) ans[i]=k;
    }
    else {
        pos=n-1;
        ans=vi(n,(k+1)/2);
        for(int i=0;i<n/2;i++)
            forword();
        while(!ans.back()) ans.pop_back();
    }
    print(ans);
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

ll dp[100010];
ll h[100010];

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

	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < 100010; i++) dp[i] = INF;

	dp[0] = 0;

	for (int i = 1; i < n; i++)
	{
		if (i == 1) chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		else
		{
			chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
			chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM =  1000000007;

int main()
{
    // 整数の入力
    ll N;
    ll total = 0;
    string s;
    cin >> N;
    cin >> s;
    char last = '-';
    for (int i = 0;i< N;i++){
        if (s[i] != last){
            total++;
            last = s[i];
        }
    }

    cout << total <<endl;
    return 0;
}

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

int main(void){
  int N, Q, temp;
  long long K;
  cin >> N >> K >> Q;
  vector<int> P(N,K - Q);
  for(int i = 0; i < Q; i++){
    cin >> temp;
    P[temp - 1]++;    
  }
  for(int i = 0;  i < N; i++){
    if(P[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0; 
}

Measured memory_bytes: 3784
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int a,b,c;

		Scanner stdIn = new Scanner(System.in);

		a = Integer.parseInt(stdIn.next());
		b = Integer.parseInt(stdIn.next());
		c = Integer.parseInt(stdIn.next());

		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll x;
	cin >> x;

	ll ans=x/11*2LL,rest=x%11;
	
	if(rest>0) ans++;
	if(rest>6) ans++;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, x, m = map(int, input().split())
ans = x
L = [0 for i in range(m+1)]
L[x] = 1

A = [x]
t = True
count = 2
while t:
    x = (x*x)%m
    if L[x] != 0:
        start = L[x]
        t = False
    else:
        L[x] = count
        count += 1
        A.append(x)

if A[-1] == 0:
    if len(A) - 1 > n:
        ans = sum(A[:n])
    else:
        ans = sum(A)

elif len(A) >= n:
    ans = sum(A[:n])
else:
    length = len(A)-start+1
    ans = sum(A[:(start-1)])
    t = (n-start+1) // length 
    s = (n-start+1) % length
    ans += sum(A[(start-1):])*t 
    ans += sum(A[start-1:(start-1+s)])
print(ans)

Measured memory_bytes: 13448
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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 (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) swap(a, b); while (b) swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// ランレングス圧縮 O(N)
template <class RandomAccessIterator>
vector<ll> run_length(RandomAccessIterator first, RandomAccessIterator last) {
    vector<ll> rl;
    for (RandomAccessIterator itr = first; itr != last; ) {
        RandomAccessIterator jtr = itr++;
        while ((itr != last && *itr == *(itr-1))) itr++;
        rl.push_back(itr - jtr);
    }
    return rl;
}

// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> imos(n+1, 0);
    REP(i, n) imos[i+1] = imos[i] + a[i];
    sort(ALL_OF(imos));

    auto rls = run_length(ALL_OF(imos));
    ll ans = 0;
    for (auto &rl : rls) {
        ans += rl * (rl - 1) / 2;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 5620
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long[] block = {a,b,c};
		long judge = a*b*c;
		long ans;
		if(judge%2==0) {
			ans = 0;
		}
		else {
			Arrays.sort(block);
			long min = block[0]*block[1]*(block[2]/2);
			long max = block[0]*block[1]*((block[2]+1)/2);
			ans = max-min;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35716
#include <stdio.h>
#include <string.h>

static int d[ 9 ];

static int
solve (
  const int r
  )
{
  int res = 0;

  if ( r >= 9 )   return ( 1 );
  if ( !d[ r ] )  return solve ( r + 1 );

  if ( r + 2 < 9
    && d[ r + 1 ] && d[ r + 2 ] )
  {
    --d[ r ]; --d[ r + 1 ]; --d[ r + 2 ];
    res = solve ( r );
    ++d[ r ]; ++d[ r + 1 ]; ++d[ r + 2 ];
  }
  if ( res ) return ( res );

  if ( d[ r ] >= 3 )
  {
    d[ r ] -= 3;
    res = solve ( r );
    d[ r ] += 3;
  }

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int cs = 0;
    char s[ 14 ], *p;

    if ( !( ~scanf ( " %s", s ) ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    for ( p = s; *p != '\0'; ++p ) ++d[ *p - '1' ];

    for ( i = 0; i < 9; ++i )
    {
      if ( d[ i ] >= 4 ) continue ;

      ++d[ i ];
      for ( j = 0; j < 9; ++j )
      {
        int res;

        if ( d[ j ] < 2 ) continue ;
        d[ j ] -= 2;
        res = solve ( 0 );
        d[ j ] += 2;

        if ( res )
        {
          if ( cs++ ) putchar ( ' ' );
          printf ( "%d", i + 1 );
          break ;
        }
      }
      --d[ i ];
    }

    puts ( cs ? "" : "0" );
  }

  return ( 0 );
}

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

print(x,y,z)

Measured memory_bytes: 65920
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m,c,i,j,a,s,ans=0;
  cin >> n >> m >> c;
  vector<int> b(m+5,0);
  for (i=0;i<m;i++) cin >> b.at(i);
  for (i=0;i<n;i++){
    s=0;
    for (j=0;j<m;j++){
      cin >> a;
      s+=a*b.at(j);
    }
    if (s+c>0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int n,d,x;

int main(){ _;
  cin>>n;
  cin>>d>>x;
  vector<int> a(n);
  int ans=0;
  REP(i,n) cin>>a[i];
  REP(i,n)
    ans+=(1+(d-1)/a[i]);
  cout<<ans+x<<endl;

  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll ans = -INF;

  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> jump_list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    jump_list.emplace_back(v - 1);
  }

  vector<ll> point_list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    point_list.emplace_back(v);
  }

  for (ll start = 0; start < N; start++) {
    ll total_point = 0;
    ll current_position = start;
    vll round;
    for (;;) {
      current_position = jump_list[current_position];
      total_point += point_list[current_position];
      round.emplace_back(point_list[current_position]);
      if (current_position == start) {
        break;
      }
    }

    ll current_point = 0;
    for (ll i = 0; i < round.size(); i++) {
      if (i >= K) {
        break;
      }
      current_point += round[i];

      ll calculated = current_point;

      if (total_point > 0) {
        calculated += total_point * ((K - i - 1) / round.size());
      }

      ans = max(ans, calculated);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;



void solve()
{
    int s; cin >> s;
    vector<int> v;
    FOR(i, 3, s + 1)
    {
        v.push_back(i);
    }
    vector<ll> table(s + 1);
    table[0] = 1;
    int n = sz(v);
    FOR(i, 1, s + 1)
    {
        trav(j, v)
        {
            if (i - j >= 0) table[i] += table[i - j];
            table[i] %= mod;
        }
    }
    cout << table[s];
}


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    /*int tc; cin >> tc;
    while (tc--)*/
        solve();

    return 0;
}


Measured memory_bytes: 3156
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans int

func main() {
	reader.Split(bufio.ScanWords)
	A, _ := strconv.Atoi(read())
	B, _ := strconv.Atoi(read())
	C, _ := strconv.Atoi(read())

	if A-B < C {
		fmt.Println(C - (A - B))
	} else {
		fmt.Println(0)
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int ans = -1;
	int a, b;
	cin >> a >> b;
	if (a <= 9 && b <= 9)
		ans = a * b;
	cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli power(lli a,lli b,lli m){if(b==0)	return 1;if(b==1)	return a%m;lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void Solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n;
    vll v(n);
    cin >> v;
    rep(i,0,n)	sum+=v[i];
    map<lli,lli>ma;
    rep(i,0,n)	ma[v[i]]++;
    cin >> t;
    while(t--){
    	cin >> a >> b;
    	sum-=(ma[a]*a);
    	sum+=(ma[a]*b);
    	ma[b]+=ma[a];
    	ma[a]=0;
    	cout<<sum<<endl;
    }
    
    
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	lli t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		Solve(c);
		c++;
	}


	return 0;
}

Measured memory_bytes: 10032
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n;
int ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int l,r;
		cin>>l>>r;
		ans=ans+(r-l+1);
	}
	cout<<ans;
	return 0;
}


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

int main(){
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    int n,k;
    cin>>n>>k;
    k-=1;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        if(i==k) s[i] = tolower(s[i]);
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#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 <climits>
#include <ctime>
#include <cassert>
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 all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, q;
    while(cin >> n >> q) {
        if(!n && !q) break;
        int a[110] = {};
        rep(i,0,n) {
            int m, inp; cin >> m;
            rep(j,0,m) {
                cin >> inp;
                a[inp]++;
            }
        }

        int ma = 0, ans = 0;
        repq(i,1,100) {
            if(q <= a[i] && ma < a[i]) {
                ma = a[i];
                ans = i;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2992