akhauriyash/Code-Regression huggingface dataset:
fun main(args:Array<String>){
  val input = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
  val max = readLine()!!.toInt()
  val result = if(recursive(max, input, 2)) "Yes" else "No"
  println(result)
}

fun recursive(count: Int, target: IntArray, color: Int): Boolean {
    if (count == 0) return isSuccess(target)
    for (i in 0..color) {
        var temp = target.copyOf()
        temp[i] *= 2
        if(recursive(count - 1, temp, 2)) return true
    }
    return false
}

fun isSuccess(arr: IntArray): Boolean {
    return when {
        arr.size != 3 -> false
        arr[1] <= arr[0] -> false
        arr[2] <= arr[1] -> false
        else -> true
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> vec1(N,0);
  
  for (int i=0; i<K; i++){
    int d;
    cin >> d;
    
    vector<int> vec2(d);
    
    for (int j=0; j<d; j++){
      cin >> vec2.at(j);
    }
    
    for (int j=0; j<d; j++){
      vec1.at(vec2.at(j) -1)++;
    }
  }
  
  int count=0;
  
  for (int i=0; i<N; i++){
    if (vec1.at(i) == 0){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int a,b;
  cin>>a>>b;
  if(a>=b){cout<<10<<endl;
    
  }
  else cout<<0<<endl;
}

Measured memory_bytes: 256
//ΔAGC020B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int n,a[111111];
int main()
{
	int i;
	LL j,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+1)
		scanf("%d",a+i);
	x=2,y=2;
	for(i=n;i>=1;i=i-1){
		j=a[i];
		x=(x-1)/j+1,y=y/j;
		if(x>y){
			cout<<-1;
			return 0;
		}
		x=x*j,y=y*j+j-1;
	}
	cout<<x<<' '<<y;
	return 0;
}

Measured memory_bytes: 640
n,k=gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
MOD = 10**9+7
ans = 0
n.times do |i|
  lt = rlt = 0
  n.times do |j|
    lt += 1 if a[j] < a[i]
    rlt += 1 if j > i && a[j] < a[i]
  end
  ans += (k*k - (1+k)*k/2) * lt + k*rlt
  ans %= MOD
end
p ans
  


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll n;
    cin >> n;
    
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ll x = n / i;
        ans += i * x * (x + 1) / 2;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int b[n];
    int k=0, c=0, flag = 0;
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
      b[i] = 0;
        if(a[i] == k+1) {
            b[i] = 1;
            k++;
            flag = 1;
        }
    }
    
    if(n)
    
    if(flag == 1){
        for(int i=0;i<n;i++){
            if(b[i] == 0) c++;
        }
    }
    if(c!=0) printf("%d\n",c);
    else if(flag == 1 && c==0) printf("0\n");
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

int n;

int gcd(int x, int y) {
  if (x < y) swap(x, y);

  while (y > 0) {
    x %= y;
    swap(x, y);
  }

  return x;
}

int main()
{
  cin >> n;
  cout << 360 / gcd(360, n);

  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

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

    char tmp=S[0];
    int ans=0;
    int flag=0;
    for(int i=1; i<(int) S.size(); i++){
        if(tmp==S[i]){
            ans++;
        }else if(flag==1){
            flag=0;
            tmp=S[i];
            ans++;
        }else if(K>0){
            K--;
            ans++;
            tmp=S[i];
            flag=1;
        }else{
            tmp=S[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=1<<18;

ll gcd(ll a,ll b){
    ll M=max(a,b);
    ll m=min(a,b);
    if(m==0){
        return M;
    }
    return gcd(m,M%m);
}


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    ll g=a[0];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
    }
    cout<<g<<endl;

}

Measured memory_bytes: 4016
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int tmpl=0;
    int tmpr=0;
    int answer =0;
    for(int i=0;i<N;i++){
      tmpl=sc.nextInt();
      tmpr=sc.nextInt();
      answer = answer+tmpr-tmpl+1;
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 25704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define dbg(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define dbg(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

int main() {
  int r; cin>>r;
  cout << 3*r*r << endl;

  return 0;
}


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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int n, m; cin >> n >> m;
	int s[10], c[10];
	vector<int> ans(n);
	rep(i, 0, n) ans[i] = 0;
	rep(i, 0, m){
		cin >> s[i] >> c[i];
		s[i]--;
	}
	rep(i, 0, m){
		if(s[i]==0 && c[i]==0 && n!=1){
			cout << -1 << endl;
			return 0;
		}
		rep(j, i+1, m){
			if(s[i]==s[j] && c[i]!=c[j]){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	rep(i, 0, m){
		ans[s[i]] = c[i];
	}
	if(n!=1 && ans[0]==0) ans[0] = 1;
	rep(i, 0, n) cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, K = map(int, input().split())
N -= (N // K) * K

tmp1 = N
tmp2 = abs(K - N)
print(min(tmp1, tmp2))




Measured memory_bytes: 7880
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int n;
int memo[100001];
bool visited[100001];
vector<int> h;

int dfs( int i ){
	if( visited[i] ) return memo[i];
	else{
		visited[i] = true;
		return memo[i] = min( dfs(i-2)+abs(h[i]-h[i-2]), dfs(i-1)+abs(h[i]-h[i-1]) );
	}
}

int main(){
	cin >> n;
	for( int i = 0; i < n; ++i ){
		int l; cin >> l;
		h.push_back( l );
	}
	memo[0] = 0; memo[1] = abs(h[1]-h[0]);
	visited[0] = visited[1] = true;
	cout << dfs(n-1) << endl;
	return 0;
}

// 21:39

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    string s; cin >> s;
    bool is_accepted = true;
    if(s[0] != 'A') is_accepted = false;
    
    if(count(s.begin()+2,s.end()-1,'C')!=1) is_accepted = false;
    
    int upper = 0;
    reps(i,1,s.length()-1){
        if('a' <= s[i] && s[i] <= 'z') continue;
        upper++;
    }
    if(upper>1) is_accepted = false;
    
    cout << (is_accepted ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
//#include <random>
//#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}
ll fpow(ll a,ll b,ll m)
{
    if(!b) return 1;
    ll ans=fpow(a*a%m,b/2,m);
    return (b%2?ans*a%m:ans);
}
ll inv(ll a,ll m) {return fpow(a,m-2,m);}
#define MotoHaiyaku ios::sync_with_stdio(false);cin.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define SZ(a) ((ll)a.size())
#define reset(a) memset(a,0,SZ(a))
#define cd(a,b) ((a+b-1)/b)
#define pow2(a) (1LL<<a)
#define LB(a,x) (lower_bound(a.begin(),a.end(),x))
#define LPOS(a,x) (lower_bound(a.begin(),a.end(),x)-a.begin())
#define UB(a,x) (upper_bound(a.begin(),a.end(),x))
#define UPOS(a,x) (upper_bound(a.begin(),a.end(),x)-a.begin())
#define uni(c) c.resize(distance(c.begin(),unique(c.begin(),c.end())))
#define unisort(c) sort(c.begin(),c.end()),uni(c)
int main()
{
    MotoHaiyaku
    ll n,mn=INF;
    cin>>n;
    ll k=2*n;
    for(int i=1;i<=sqrt(k);i++)
    {
        if(k%i==0)
        {
            vector<ll> r,m;
            r.pb(0);
            r.pb(k/i-1);
            m.pb(i);
            m.pb(k/i);
            pair<ll,ll> p=atcoder::crt(r,m);
            if(p.S!=0) mn=min(mn,p.F);
            if(i==1) continue;
            swap(m[0],m[1]);
            r[1]=i-1;
            p=atcoder::crt(r,m);
            if(p.S!=0) mn=min(mn,p.F);
        }
    }
    cout<<min(mn,n);
}


Measured memory_bytes: 3708
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var s = ReadLine();
        var set = new HashSet<char>();
        for (var i = 0; i < s.Length; i++)
            set.Add(s[i]);
        if (set.Count != ALFA.Length)
        {
            for (var i = 0; i < ALFA.Length;i++)
                if (!set.Contains(ALFA[i]))
                {
                    s += ALFA[i];
                    break;
                }
            WriteLine(s);
        }
        else
        {
            var r = -1;
            for (var i = 0; i < s.Length - 1; i++)
            {
                if (s[i] < s[i + 1]) r = i;
            }
            if (r == -1) { WriteLine(-1);return; }
            for (var i = r+1; i < s.Length; i++)
                set.Remove(s[i]);
            var ad = ' ';
            for (var i = ALFA.IndexOf(s[r]) + 1; i < ALFA.Length; i++)
                if (!set.Contains(ALFA[i])) { ad = ALFA[i]; break; }
            s = s.Substring(0, r) + ad;
            WriteLine(s);
        }
    }

    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13396
use itertools::Itertools;
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        ca: [(usize, [usize; m]); n],
    }
    let mut result = n * 1000_000usize;
    for i in 0..=n {
        for js in (0..n).combinations(i) {
            let mut understanding = vec![0usize; m];
            let mut cost = 0usize;
            for j in js {
                let (c, a) = &ca[j];
                cost += c;
                for (i, &ai) in a.iter().enumerate() {
                    understanding[i] += ai;
                }
            }
            if understanding.iter().all(|&a| a >= x) {
                result = result.min(cost);
            }
        }
    }
    if result == n * 1000_000 {
        println!("{}", -1);
    } else {
        println!("{}", result);
    }
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define mod 1000000007
#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x,i,j;
    cin>>x;
    for(i=0;i<=1000;i++)
    {
    	ll n=power(i,5)-x;
    	ll q=abs(n);
    	if(q==1)
    	{
    		if(n<0)
			{
				cout<<i<<" "<<-1;
			}
			else
			{
				cout<<i<<" "<<1;
			}
			return 0;
		}
		if(q==0)
		{
			
    		if(n<0)
			{
				cout<<i<<" "<<0;
			}
			else
			{
				cout<<i<<" "<<0;
			}
			return 0;
		}
    	vector<pll>v;
    	for(j=2;j*j<=q;j++)
    	{
    		if(q%j==0)
    		{
    			int cnt=0;
    			while(q%j==0)
    			{
    				q=q/j;
    				cnt++;
				}
				v.pb({j,cnt});
			}
			
			
		}
		if(q>1)
		v.pb({q,1});
		ll ans=1,flag=0;
		
		
		for(j=0;j<v.size();j++)
		{
			if(v[j].se%5==0)
			{
				ans=ans*power(v[j].fi,v[j].se/5);
			}
			else
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			if(n<0)
			{
				cout<<i<<" "<<-1*ans;
			}
			else
			{
				cout<<i<<" "<<ans;
			}
			return 0;
		}
		else
		{
			continue;
		}
		
    	
    	
	}
}

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

const long long INF = 1e18;

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

int main()
{
	int h, w, k, sy, sx, gy, gx;
	cin >> h >> w >> k >> sy >> sx >> gy >> gx;
	sy--; sx--; gy--; gx--;
	vector<string> g(h);
	for(int i = 0; i < h; i++) cin >> g[i];
	auto toId = [&](int i,int j,int v){
		return (i * w + j) * 4 + v;
	};
	auto modCeil = [&](int x){
		return (x + k - 1) / k * k;
	};
	vector<long long> dist(h * w * 4, INF);
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> q;
	auto push = [&](int i, int j, int v, int x){
		int id = toId(i, j, v);
		if(dist[id] <= x) return;
		dist[id] = x;
		q.emplace(x, id);
	};
	for(int v = 0; v < 4; v++) push(sy, sx, v, 0);
	while(!q.empty()){
		long long d = q.top().first;
		int id = q.top().second;
		q.pop();
		if(dist[id] != d) continue;
		int i = id / w / 4;
		int j = id / 4 % w;
		int v = id % 4;
		for(int nv = 0; nv < 4; nv++) push(i, j, nv, modCeil(d));
		int ny = i + dy[v];
		int nx = j + dx[v];
		if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
		if(g[ny][nx] == '.') push(ny, nx, v, d + 1);
	}
	long long ans = INF;
	for(int v = 0; v < 4; v++) ans = min(ans, dist[toId(gy, gx, v)]);
	if(ans == INF){
		cout << -1 << endl;
	}
	else{
		ans = modCeil(ans) / k;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 44104
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let (x,mut y)= read_two::<u64>();
    let mut count = 0;
    while x <= y {
        count += 1;
        y /= 2;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <cstdio>
using namespace std;

int a[101][101] = {{0}};
int b[101][101] = {{0}};
long long c[101][101] = {{0}};

int main (void)
{
	int n, m, l, i, j, k;

	scanf("%d %d %d", &n, &m, &l);

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

	for (i=1; i<=m; i++){
		for (j=1; j<=l; j++)
			scanf("%d", &b[i][j]);
	}

	for (i=1; i<=n; i++){
		for (j=1; j<=l; j++){
			for (k=1; k<=m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for (i=1; i<=n; i++){
		for (j=1; j<=l; j++){
			printf("%ld", c[i][j]);
			if(j != l)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1188
using System;
using System.Text;

namespace ITP1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            var count = 1;

            while (true)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                sb.AppendLine(string.Format("Case {0}: {1}", count++, n));
            }
            Console.Write(sb);
        }
    }
}

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

int main() {
    ll K, N; cin >> K >> N;
    vector<ll> v(N);
    ll m = 0;
    for (int i = 0; i < N; i++) cin >> v[i];
    for (int i = 1; i < N; i++)
    {
        m = max(m, v[i]-v[i-1]);
    }
    m = max(m, v[0]+(K-v[N-1]));
    
    cout << K - m << endl;
}

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

int main() {
  int n, m;
  int r = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    r += a;
  }
  if (n < r) {
    cout << -1 << endl;
  } else {
    cout << n - r << endl;
  }
}

Measured memory_bytes: 3580
from collections import defaultdict
from itertools import combinations

N = int(input())
D = defaultdict(int)

for _ in range(N):
  S = input()
  if S[0] in "MARCH":
    D[S[0]] += 1

ans = 0
for C in combinations(("M", "A", "R", "C", "H"), 3):
  temp = 1
  for c in C:
    temp *= D[c]
  ans += temp

print(ans)

Measured memory_bytes: 9412
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cerr << x2 - x1 << " " << y2 - y1 << endl;

    //座標1から座標2のベクトルの長さと角度
    double length = sqrt(abs(x2 - x1) * abs(x2 - x1) + abs(y2 - y1) * abs(y2 - y1));
    double angle  = acos((x2 - x1) / length);

    if(y2 - y1 < 0){
        angle = 2.0 * PI - angle;
    }

    double x3d = x2 + cos(angle + (PI * 0.5)) * length;
    double y3d = y2 + sin(angle + (PI * 0.5)) * length;

    int x3 = round(x3d);
    int y3 = round(y3d);

    int x4 = round(x3d + cos(angle + PI) * length);
    int y4 = round(y3d + sin(angle + PI) * length);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

Measured memory_bytes: 512
d = list(map(int, input().split()))
d.sort()
a,b,c=d
r = 0
while a<b:
    a += 2
    r += 1
if a > b:
    r += 1
    b += 1
    c += 1
if a == b:
    r += c - a
    a  = c
    b  = c
print(r)


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

K = int(input())
S = len(input())

mod = 10**9+7
answer = 0
tmp = 0

# 組み合わせの数の計算は以下URLからコピーしてきた：
# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = K+S
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

pow = -1
for i in range(K+1):
  if pow == -1:
    pow = 1
  else:
    pow = (pow*25)%mod
  answer = (answer+pow*cmb(N,i,mod))%mod

print(answer)

Measured memory_bytes: 205420
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n, a, b;
string s;

int main() {
	cin >> n >> a >> b;
	cin >> s;
	int all = a + b;
	int na = b;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'c') {
			cout << "No\n";
			continue;
		}
		if (s[i] == 'a') {
			if (all > 0) {
				--all;
				cout << "Yes\n";
			}
			else {
				cout << "No\n";
			}
		}
		else {
			if (all > 0 && na > 0) {
				--all, --na;
				cout << "Yes\n";
			}
			else {
				cout << "No\n";
			}
		}
	}
	return 0;
}




Measured memory_bytes: 896
def p(A,p,r):
 x=A[r]
 i=p-1
 for j in range(p,r):
  if A[j]<=x:
   i+=1
   A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
n=int(input())
A=list(map(int,input().split()))
k=p(A,0,n-1)
A[k]='['+str(A[k])+']'
print(*A)


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll N;
	cin >> N;
	double dp[3000][3000]={},p[3000]={};
	FOR(i,1,N+1)cin>>p[i];
	double ans=0;
	dp[0][0] = 1.0;
	FOR(i,0,N+1){
		FOR(j,0,N+1){
			if(i>0)dp[i][j] += dp[i-1][j]*p[i+j];
			if(j>0)dp[i][j] += dp[i][j-1]*(1.0-p[i+j]);
			if(i>j&&i+j==N)ans += dp[i][j];
		}
	}
	printf("%.10lf\n",ans);
}

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

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


Measured memory_bytes: 1664
use proconio::*;

fn main() {
    input!{
        n: usize,
        m: usize,
        x: usize,
        ca: [[usize; m+1]; n],
    }

    let mut ans = std::usize::MAX;

    for i in 0..(1<<n) {
        let mut algo = vec![0; m];
        let mut cost = 0;
        for j in 0..n {
            if ((1<<j) & i) > 0 {
                for k in 0..m {
                    algo[k] += ca[j][k+1];
                }
                cost += ca[j][0];
            }
        }
        let mut ok = true;
        for j in 0..m {
            if algo[j] < x {
                ok = false;
            }
        }
        if ok {
            ans = ans.min(cost);
        }
    }

    println!("{}", if ans == std::usize::MAX { -1 } else { ans as i32 });
}


Measured memory_bytes: 2156
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var sum = b.Sum();
            for (int i = 0; i < n - 1; i++)
            {
                if (a[i + 1] == a[i] + 1)
                {
                    sum += c[a[i] - 1];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
int main(void){
    // Here your code !
    int a,b,c,ans;
    scanf("%d %d %d",&a,&b,&c);
    ans=100*a+10*b+c;
    if(ans%4==0){
        printf("YES");
    }else{
        printf("NO");
    }
}


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

int64_t beki(int64_t n,int64_t x){
  vector<int64_t> vec(50);
  int64_t i,s,ans;
  i=0;
  ans=1;
  cin>>n>>x;
  while(x>0){
  vec.at(i)=x%2;
    x=x/2;
  i++;    
  }
  s=n;
  for(int64_t j=0;j<50;j++){
  if(vec.at(j)==1){ans=(ans*s)%1000000007;}  
   s=(s*s)%1000000007; 
   
  } return ans;}
  
 
  
int main() {
int64_t n,k,a;
  a=0;
  cin>>n>>k;
  vector<int64_t> ans(k);
  ans.at(k-1)=1;
  for(int64_t i=k-2;i>=0;i--){
  ans.at(i)=beki(k/(i+1),n);
    for(int64_t j=1;(i+1)*j<=k;j++){
    ans.at(i)=ans.at(i)-ans.at((i+1)*j-1);
     if(ans.at(i)<0) {ans.at(i)=ans.at(i)+1000000007;}
    }
    ans.at(i)=ans.at(i)+beki(k/(i+1),n);
  }
  for(int64_t i=0;i<k;i++){a=a+(i+1)*ans.at(i);
                          while(a>=1000000007){a=a-1000000007;}}
  cout<<a<<endl;
}  

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

int main(){

    char ch1,ch2;
    cin >> ch1 >> ch2;
    
    if(ch1 == 'H'){
        
        cout << ch2 << endl;
    }
    else{
        
        if(ch2 == 'D'){
            
            cout << 'H' << endl;
        }
        else{
            
            cout << 'D' << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i+1<s.size();i++)if(s[i]=='A'&&s[i+1]=='C'){puts("Yes");return 0;}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
using namespace std;

int main()
{

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 1000)
    {
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int f = 0;
        rep(j, n)
        {
            if (s[j] == '0' + c[f])
                f++;
            if (f == 3)
                break;
        }
        if (f == 3)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  long long P=1;
  for (int i=1;i<N+1;i++){
    P=(P*i)%1000000007;
  }
  cout<<P<<endl;
  
  return 0;
}

    
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

double dist(double x1,double y1,double x2,double y2){
	return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}

double dot_product(double x1,double y1,double x2,double y2){
	return x1*x2+y1*y2;
}

int main(){
	double x1,y1,x2,y2,xq,yq;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)){
		double xr,yr,k,xs,ys;
		k=dot_product(x2-x1,y2-y1,xq-x1,yq-y1)/dist(x2,y2,x1,y1);
		xs=x1+k*(x2-x1);
		ys=y1+k*(y2-y1);
		//o(" "<<xs<<" "<<ys);
		xr=2*xs-xq;
		yr=2*ys-yq;
		//xr=x1+(2*k-1)*(xq-x1);
		//yr=y1+(2*k-1)*(yq-y1);
		printf("%.6lf %.6lf\n",xr,yr);
	}
}

Measured memory_bytes: 1240
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{

    ll X;
    cin >> X;
    ll motokin = 100;
    ll i = 1;
    for (; i < 10000; i++)
    {
        double next = motokin * 1.01;
        motokin = floor(next);
        if (motokin >= X)
        {
            break;
        }
    }

    cout << i << endl;

    return;
}

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


Measured memory_bytes: 3688
ip=[int(x) for x in input().split()]
ip.sort()
cnt=0
while ip[1]<ip[2]:
  cnt=cnt+1
  ip[0]+=1
  ip[1]+=1
  
if (ip[1]-ip[0])%2!=0:
  cnt+=1
  ip[1]+=1
  ip[0]+=1
  while ip[0]<ip[1]:
    ip[0]+=2
    cnt+=1
else:
  cnt=cnt+(ip[1]-ip[0])/2
print(int(cnt))



Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int prime(int n)
{
    if (n < 2)
        return 0;
    if (n == 2)
        return 1;
    if (n % 2 == 0)
        return 0;
    int i;
    for (i = 3; i <= sqrt(n); i += 2)
        if (n%i == 0)
            return 0;
    return 1;
}
int main()
{
    int q;
    scanf("%d", &q);
    int i;
    int l[100005], r[100005];
    for (i = 0; i < q; i++)
        scanf("%d %d", &l[i], &r[i]);
    int p[100005];
    for (i = 0; i < 100005; i++)
        p[i] = 0;
    for (i = 0; i < 100005; i++)
        if (i % 2 == 1)
            if (prime(i) == 1 && prime((i + 1) / 2) == 1)
                p[i]++;
    for (i = 1; i < 100005; i++)
        p[i] += p[i - 1];
    for (i = 0; i < q; i++)
        printf("%d\n", p[r[i]] - p[l[i] - 1]);
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MOD (int)1e9+7
int gcd(int x,int y){if(!y)return x;return gcd(y,x%y);}

int main(){
    int x,y,z;scanf("%d %d %d",&x,&y,&z);
    printf("%d %d %d\n",z,x,y);
}

Measured memory_bytes: 128
N = int(input())
P = []
maximum_val = 0
maximum_index = 0

for i in range(N):
	a = int(input())
	P.append(a)
	if a > maximum_val:
		maximum_val = a
		maximum_index = i
print(int(sum(P) - P[maximum_index] / 2))


Measured memory_bytes: 38384
//
// Created by Yoshiki Shino on 2018/07/29.
//

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    ll N, K;
    vector<ll> A;
    cin >> N >> K;
    for (ll i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    ll minOps = 0;
    if (N <= K) {
        minOps = 1;
    } else {
        auto it = find(A.begin(), A.end(), 1);
        ll indexOf1 = distance(A.begin(), it);
//    cout << distance(A.begin(), it) << endl;
        ll leftNumber = indexOf1;
        ll rightNumber = N - indexOf1 - 1;
//        ll leftOps = ceil(1.0 * leftNumber / (K-1));
//        ll rightOps = ceil(1.0 * rightNumber / (K-1));
//        minOps = leftOps + rightOps;
        minOps = ceil(1.0 * (leftNumber + rightNumber) / (K-1));
    }

    cout << minOps << endl;

    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		
		int n = Integer.valueOf(reader.readLine());
		int m = Integer.valueOf(reader.readLine());
		
		int cost[][] = new int[n][n];
		for(int i = 0; i < n; i++){ Arrays.fill(cost[i], 1 << 29); }
		for(int i = 0; i < m; i++){
			String str[] = reader.readLine().split(",");
			int a = Integer.valueOf(str[0]) - 1;
			int b = Integer.valueOf(str[1]) - 1;
			cost[a][b] = Integer.valueOf(str[2]);
			cost[b][a] = Integer.valueOf(str[3]);
		}
		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
				}
			}
		}
		String str[] = reader.readLine().split(",");
		int a = Integer.valueOf(str[0]) - 1;
		int b = Integer.valueOf(str[1]) - 1;
		int c = Integer.valueOf(str[2]);
		int d = Integer.valueOf(str[3]);
		System.out.println(c - d - cost[a][b] - cost[b][a]);
	}
}

Measured memory_bytes: 24164
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int n = sc.nextInt();
		
		for (int i = 1; i <= n; i++) {
			if (i%3 == 0) {
				System.out.print(" " + i);
				continue;
			}
			if (i%10 == 3) {
				System.out.print(" " + i);
				continue;
			}
			int x = i/10;
			while (x > 0) {
				boolean flg = false;
				if (x%10 == 3) {
					System.out.print(" " + i);
					flg = true;
				}
				if (flg) break;
				x /= 10;
			}
		}
		System.out.println();
	}
}



Measured memory_bytes: 28636
N,M=[int(i) for i in input().split()]
edges=[[2**60 for i in range(N)] for j in range(N)]
for i in range(M):
    a,b,c=[int(i) for i in input().split()]
    a-=1
    b-=1
    edges[a][b]=edges[b][a]=c

mini=[[edges[i][j] for i in range(N)] for j in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            mini[i][j]=min(mini[i][j],mini[i][k]+mini[k][j])
res=0
for r in range(N):
    for l in range(r):
        #print(l,".",r,"->",edges[l][r],mini[l][r])
        if edges[l][r] != 2**60 and mini[l][r]<edges[l][r]:
            res+=1
print(res)


Measured memory_bytes: 3496
#include <iostream>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	double W, H, x, y; cin >> W >> H >> x >> y;
	double gx = W / 2;
	double gy = H / 2;

	 
	printf("%0.10f", W * H / 2);
	cout <<" " << ((gx == x && gy == y) ? 1 : 0)<< endl;

	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int gcd(int x, int y){
	while (y){
		x %= y;
		swap(x, y);
	}
	return x;
}

const int mod = 1000000007;

long long pw(long long a, long long b){
	long long res = 1;
	while (b){
		if (b & 1ll)
			res = res * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

const int N = 444;
long long pref[N][N];

int main(){

	int n = nxt(), c = nxt();
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++){
		a[i] = nxt();
	}
	for (int i = 0; i < n; i++){
		b[i] = nxt();
	}

	for (int i = 0; i < N; i++){
		pref[0][i] = i;
	}
	vector<long long> cur(N, 1);
	for (int i = 1; i < N; i++){
		pref[i][0] = 0;
		for (int j = 1; j < N; j++){
			cur[j] = cur[j] * j % mod;
			pref[i][j] = (pref[i][j - 1] + cur[j]) % mod;
		}
	}

	vector<vector<long long>> dp(n + 1, vector<long long>(c + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= c; j++){
			for (int ij = 0; ij <= j; ij++){
				long long hueta = pref[ij][b[i]] - pref[ij][a[i] - 1];
				if (hueta < 0)
					hueta += mod;
				dp[i + 1][j] += hueta * dp[i][j - ij] % mod;
			}
			dp[i + 1][j] %= mod;
		}
	}

	cout << dp[n][c] << "\n";

	return 0;
}


Measured memory_bytes: 3072
N=int(input())
A=list(map(int, input().split()))
count=[0]*10**6
for a in A:
  count[a]+=1
  
ans=0
for a in range(max(A)+1):
  now=count[a-1]+count[a]+count[a+1]
  ans=max(ans, now)
  
print(ans)

Measured memory_bytes: 15868
#include<algorithm>
#include<cstdio>

const int Maxv = 200005; 
int pos[Maxv], dp[Maxv], num[Maxv], ans, n; 

int main(){
    scanf("%d", &n); 
    for (int i = 1; i <= n; i++) {
        scanf("%d", &num[i]); 
        pos[ num[i] ] = i; 
    }
    ans = dp[1] = 1; 
    for (int i = 2; i <= n; i++) {
        if (pos[i] > pos[i - 1]) {
            dp[i] = dp[i - 1] + 1; 
        }
        else {
            dp[i] = 1; 
        }
        ans = std::max(ans, dp[i]); 
    }
    printf("%d\n", n - ans);
    return 0; 
}

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int sum = 0;
        sum += Math.Abs(a[0]);
        for (int i = 1; i < a.Length; i++)
        {
            sum += Math.Abs(a[i - 1] - a[i]);
        }
        sum += Math.Abs(a.Last());
        Console.WriteLine(sum - minusDist(0,a[0],a[1]));
        for (int i = 1; i < a.Length - 1; i++)
        {
            Console.WriteLine(sum - minusDist(a[i - 1], a[i], a[i + 1]));
        }
        Console.WriteLine(sum - minusDist(a[a.Length - 2], a[a.Length - 1], 0));
    }
    static int minusDist(int now, int next, int nextnext)
    {
        int res = 0;
        res += Math.Abs(now - next);
        res += Math.Abs(next - nextnext);
        res -= Math.Abs(now - nextnext);
        return res;
    }
}

Measured memory_bytes: 28252
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

struct UnionFind{
    int N;
    vector<int> node;
    UnionFind(){}
    UnionFind(int N):N(N){
        node.assign(N,-1);
    }
    int get_root(int x){
        if (node[x]<0){
            return x;
        }
        node[x] = get_root(node[x]);
        return node[x];
    }
    void unite(int x,int y){
        int root_x = get_root(x);
        int root_y = get_root(y);
        int larger,smaller;
        if(root_x != root_y){
            if(node[root_x] < node[root_y]){ //size of x is lager than one of y
                larger  = root_x;
                smaller = root_y;
            }else{
                larger  = root_y;
                smaller = root_x;
            }
            node[larger] += node[smaller];
            node[smaller] = larger;
        }
    }
    int size(int x){
        return -node[x];
    }
    bool same(int x,int y){
        return get_root(x) == get_root(y);
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N,Q;
    cin >> N >> Q;
    UnionFind UF(N);
    REP(i,Q){
        int c,x,y; cin >> c >> x >> y;
        if(c){
            cout << UF.same(x,y) << bn;
        }else{
            UF.unite(x,y);
        }
    }

}


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

int main(){
	int n, j, i, max;
	int a[10];
	int b, c;
	cin >> n;
	for (j = 0; j < n; j++) {
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9];
		b = 0;
		c = 0;
		for(i = 0; i < 10; i++){
			if(b > c){
				if (a[i] > b) {
					b = a[i];
				}else if(a[i] > c){
					c = a[i];
				}else{
					break;
				}
			}else{
				if(a[i] > c){
					c = a[i];
				}else if (a[i] > b) {
					b = a[i];
				}else{
					break;
				}
			}
		}

		if(i < 10){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
n = gets.chomp.to_i
t = []
x = []
y = []
(0..(n - 1)).each do |i|
  t[i], x[i], y[i] = gets.chomp.split.map(&:to_i)
end

if (0..(n - 1)).all? {|i|
     tmp = t[i] - (x[i] + y[i])
     0 <= tmp && tmp.even?
   }
  puts 'Yes'
else
  puts 'No'
end

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

void solve(){
    int n;
    cin>>n;
    vector<int> mat(n);
    for(int &x:mat) cin>>x;
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++){
        if(i+1<n) dp[i+1]=min(dp[i+1],dp[i]+abs(mat[i]-mat[i+1]));
        if(i+2<n) dp[i+2]=min(dp[i+2],dp[i]+abs(mat[i]-mat[i+2]));
    }
    cout<<dp[n-1];
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3924
A1, A2, A3 = map(int, input().split())

temp1 = abs(A1 - A2) + abs(A2 - A3)
temp2 = abs(A2 - A3) + abs(A3 - A1)
temp3 = abs(A3 - A1) + abs(A1 - A2)

print(min(temp1, temp2, temp3))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(r<=x && x<=W-r && r<=y && y<=H-r){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long a = inputLongArray[0];
            long b = inputLongArray[1];

            long result = 0;
            long tmp = 1;
            if (a < b)
            {
                for (int i = 0; i < b; i++)
                {
                    result += tmp * a;
                    tmp *= 10;
                }
            }
            else
            {
                for (int i = 0; i < a; i++)
                {
                    result += tmp * b;
                    tmp *= 10;
                }
            }
            
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main(){
  int n,g;
  cin >> n >> g;
  int su=0,mini=10e5,baf;
  for(int i=0;i<n;i++){
    cin >> baf;
    su+=baf;
    mini=min(mini,baf);
  }
  int ans=n;
  ans+=(g-su)/mini;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600