akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

template<typename T, T MOD = 1000000007>
struct Mint {
	T v;

	Mint() : v(0) {}
	Mint(signed v) : v(v) {}
	Mint(ll t) { v = t % MOD; if (v < 0) v += MOD; }

	Mint pow(ll k) {
		Mint res(1), tmp(v);

		while (k) {

			if (k & 1) res *= tmp;

			tmp *= tmp;
			k >>= 1;
		}



		return res;
	}

	Mint inv() { return pow(MOD - 2); }

	Mint& operator=(Mint a) { if (a.v >= MOD) a.v %= MOD; v = a.v; return *this; }
	Mint& operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; }
	Mint& operator/=(Mint a) { return (*this) *= a.inv(); }
	Mint operator+(Mint a) const { return Mint(v) += a; }
	Mint operator-(Mint a) const { return Mint(v) -= a; }
	Mint operator*(Mint a) const { return Mint(v) *= a; }
	Mint operator/(Mint a) const { return Mint(v) /= a; }

	Mint operator-() { return v ? MOD - v : v; }
	bool operator==(const Mint a) const { return v == a.v; }
	bool operator!=(const Mint a) const { return v != a.v; }
	bool operator < (const Mint a) const { return a < a.v; }


};

using M = Mint<ll>;

M kaijou[20000];


M comb(ll a, ll b) {

	if (b < 0 || a < b)
		return 0;

	return kaijou[a] / (kaijou[b] * kaijou[a - b]);
}

int main() {
	ll N, K;

	cin >> N >> K;
	kaijou[0] = 1;
	rep(i, N) {
		kaijou[i + 1] = kaijou[i] * (i + 1);
	}



	


	for (int i = 1; i <= K; i++) {
		M ans;

	
		if (N - K >= i - 1) {
			if (N - K > i - 1)
				ans = comb(K - 1, i - 1) * (comb(N - K - 1, i - 2) + M(2)*comb(N - K - 1, i - 1) + comb(N - K - 1, i));
			else
				ans = comb(K - 1, i - 1);
		}
		else
			ans = 0;

		cout << ans.v << endl;

	}


	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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

int main(){
	string s;cin>>s;
	vector<vector<int>> dp(s.size()+1,vector<int>(3,0));
	dp[0][1] = 0; dp[0][2] = 0; dp[1][1] = 1; dp[1][2] = 0;
	for(int i = 2; i <= s.size(); ++i){
		chmax(dp[i][1], dp[i-1][2]+1);
		chmax(dp[i][2], dp[i-2][1]+1);
		if(s[i-1] != s[i-2]) chmax(dp[i][1], dp[i-1][1]+1);
		if(i<=3){chmax(dp[i][2], dp[i-2][2]+1); continue;}
		if((s[i-1] != s[i-3] && s[i-2] != s[i-4]))chmax(dp[i][2], dp[i-2][2]+1);
	}
	cout<<max(dp[s.size()][1],dp[s.size()][2])<<endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n),b(100001);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
  }
  int ans=max(b[0]+b[1],b[99999]+b[100000]);
  for(int i=1;i<100000;i++) ans=max(ans,b[i-1]+b[i]+b[i+1]);
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
using namespace std;

int main(){
char x;
while(1){
scanf("%c", &x);
if ( isalpha(x) ) {//アルファベット  
     if ( islower(x) ) {//小文字
          printf("%c", toupper(x));
     } else {//小文字以外
           if ( isupper(x) ) {//大文字
                printf("%c", tolower(x));
           } 
     }
} else {//アルファベット以外
       printf("%c",x);
}if(x ==  '\n' )break;
}
return 0;
}


Measured memory_bytes: 3140
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
nums = []
for i in range(1,n+1):
    nums.append(i)
cards = []
for card in itertools.permutations(nums):
    cards.append(list(card))

p_find = cards.index(p)
q_find = cards.index(q)
print(abs(p_find-q_find))


Measured memory_bytes: 10356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
ll mod(ll i, ll j){
  return ((i%2019)*j)%2019;
}

int main(){
  ll l, r;
  cin >> l>> r;
  ll len=abs(r-l);
 // cout << "len=" << len << endl;
  
  ll ans=INF;
  if(len>=2019){
    cout << "0" << endl;
    return 0;
  }else{
    for(ll k=l; k<=r-1; k++){
      for(ll m=k+1; m<=r; m++){
        ans= min(mod(k, m), ans);
      }
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
 
void solve()
{
    int n;
    cin >> n;

    if(n%1000)
        cout << 1000 - n%1000 << "\n";
    else
        cout << 0 << "\n";
    
    return;
}
 
int main()
{
    fastio;
    solve();
}

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


def main():
    n, m = map(int, input().split())
    ans = [0 for _ in range(30)]

    for i in range(n):
        ka = list(map(int, input().split()))

        for j in ka[1:]:
            ans[j - 1] += 1

    result = 0

    for a in ans:
        if a == n:
            result += 1

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
  
  int n,i,j,res[7];
  double a[4000];
  char b='*';
     
  res[1]=0;  
  res[2]=0;
  res[3]=0;
  res[4]=0;
  res[5]=0;
  res[6]=0;
  
  scanf("%d",&n);
  
  for(i=1;i<n+1;i++){
    
    scanf("%lf",&a[i]);
    
    if( a[i] < 165.0 ){
      res[1]=res[1]+1;
    }
    else if( a[i] >= 165.0 && a[i] < 170.0 ){
      res[2]=res[2]+1;
    }
    else if( a[i] >= 170.0 && a[i] < 175.0 ){
      res[3]=res[3]+1;
    }
    else if( a[i] >= 175.0 && a[i] < 180.0 ){
      res[4]=res[4]+1;
    }
    else if( a[i] >= 180.0 && a[i] < 185.0 ){
      res[5]=res[5]+1;
    }
    else{
      res[6]=res[6]+1;
    }
  }
  
  for( n=1 ; n<7 ; n++ ){
    
    printf("%d:",n);
    
    j=1;
    
    while( j < res[n]+1 ){
      
      printf("%c",b);
      j = j + 1;
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <atcoder/all>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) push_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using namespace atcoder;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
//using mint = modint998244353;
//ll mod = 998244353;
using mint = modint1000000007;
ll mod = 1000000007;

struct union_find{
 
	vl parent;
	vl sizes;
 
	void init(ll n) {
		rep(i, n) parent.push_back(i);
		rep(i, n) sizes.push_back(1);
	}
 
	ll root(ll n){
		if(parent[n] == n) return n;
		return parent[n] = root(parent[n]);
	}
 
	ll size(ll n) {
		return sizes[root(n)];
	}
 
	bool is_same(ll a, ll b){
		return root(a) == root(b);
	}
 
	void unite(ll a, ll b){
		if(is_same(a, b)) return;
		sizes[root(a)] += size(b);
		parent[root(b)] = root(a);
	}
	
	ll group_count(){
		ll ret = 0;
		rep(i, parent.size()) ret += (parent[i] == i);
		return ret;
	}
};
 
void Main(){

	ll N, M;
	cin >> N >> M;
	vvl v(M, vl(2));
	rep(i, M) cin >> v[i][0] >> v[i][1];
	
	union_find uf;
	uf.init(N);
	
	rep(i, M) uf.unite(v[i][0], v[i][1]);
	
	ll ans = uf.group_count() - 1;
	print(ans);

}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





Measured memory_bytes: 11088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int n;
  cin >> n;
  int a;
  int mi = 10000, ma = 0;
  rep(i, n){
    cin >> a;
    mi = min(mi, a);
    ma = max(ma, a);
  }
  
  
      
    
    
    
  

  cout << ma - mi << endl;
  return 0;
}


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

using ll = long long;
using namespace std;

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

    int guusuu = 0;
    int kisuu = 0;
    for (int i = 0; i < n; i++) {
        int j;
        cin >> j;
        j % 2 == 0 ? guusuu++ : kisuu++;
    }
    ll ans;
    if (kisuu == 0) {
        if (p == 0) {
            ans = 1LL << n;
        } else {
            ans = 0;
        }
    } else {
        ans = 1LL << (n - 1);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt();
        Map<String, Integer> maps = new HashMap<>();
        while (n-- > 0) {
            String s = sc.next();
            maps.put(s, maps.getOrDefault(s, 0) + 1);
        }
        pw.println("AC x " + maps.getOrDefault("AC", 0));
        pw.println("WA x " + maps.getOrDefault("WA", 0));
        pw.println("TLE x " + maps.getOrDefault("TLE", 0));
        pw.println("RE x " + maps.getOrDefault("RE", 0));
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

ans =  S.count(".")
l = [0, ans]
for i in range(N):
    if S[i] == "#":
        l[0] += 1
    else:
         l[1] -= 1
    
    if ans > sum(l):
        ans = sum(l)
print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
// int ans;
// string ans;

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

	cin >> N >> M;

    cout << (N * (N-1) + M * (M-1)) / 2 <<  endl;
	return 0;
}

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

int main()
{
	int x, y;

	cin >> x >> y;

	if (x < y)
	{
		cout << "a < b" << endl;
	}
	if (x > y)
	{
		cout << "a > b" << endl;
	}
	if (x == y)
	{
		cout << "a == b" << endl;
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int I, O, T, J, L, S, Z;
	int ans1 = 0, ans2 = 0;
	cin >> I >> O >> T >> J >> L >> S >> Z;

	ans1 = (I / 2) * 2 + O + (J / 2) * 2 + (L / 2) * 2;
	if (I > 0 && L > 0 && J > 0)
	{
		I--, J--, L--;
		ans2 = 3 + (I / 2) * 2 + O + (J / 2) * 2 + (L / 2) * 2;
	}

	cout << max(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k,minx=10000000000;
	cin>>n>>k;
	long long h[n];
	for(long long i=0;i<n;i++)
	{
		cin>>h[i];
	}
	sort(h,h+n);
	long long  i=0,j=k-1;
	while(j!=n){
		minx=min(minx,h[j]-h[i]);
		i++;j++;
	}
	cout<<minx;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
// Need start
#include<vector>
// Need end
using namespace std;

template<typename T>
class Combination {
    private:
        T mod;
        vector<T> factorial, inv_factorial, inv;
    public:
        Combination(int max_number, T _mod):
        mod(_mod), factorial(max_number + 1), inv_factorial(max_number + 1), inv(max_number + 1) {
            factorial[0] = factorial[1] = 1;
            inv_factorial[0] = inv_factorial[1] = 1;
            inv[1] = 1;
            for (int i = 2; i <= max_number; i++) {
                factorial[i] = (factorial[i - 1] * i) % mod;
                inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                inv_factorial[i] = inv_factorial[i - 1] * inv[i] % mod;
            }
        }
        T calc(int n, int k) {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return factorial[n] * (inv_factorial[k] * inv_factorial[n - k] % mod) % mod;
        }
};

using ll = long long;

const ll MOD = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // This sample is Atcoder Beginners Contest 132 D
    ll N, K;
    cin >> N >> K;
    Combination<ll> comb(N, MOD);
    for (int i = 1; i <= K; i++) {
        ll k_div = comb.calc(K - 1, i - 1);
        ll all_div = comb.calc(N - K + 1, i);
        cout << (k_div * all_div) % MOD << endl;
    }
    return 0;
}

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  vector< int > A(3);
  cin >> A;

  whole(sort, A);
  cout << A[2] - A[0] << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    if (S[0] == S[1]) {
        cout << "Bad" << endl;
    } else if (S[1] == S[2]) {
        cout << "Bad" << endl;
    } else if (S[2] == S[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ruby

def f(n)
  ("0" + n.to_s)[-2, 2]
end

def solve(t)
  s = t % 60; t /= 60
  m = t % 60; h = t / 60
  puts "#{f h}:#{f m}:#{f s}"
end

ALL = 120 * 60

while true
  h, m, s = gets.split.map{|x| x.to_i}
  if h < 0 and m < 0 and s < 0
    break
  end
  t = (h*60+m)*60+s
  solve(ALL - t)
  solve((ALL - t) * 3)
end

Measured memory_bytes: 6108
#include <iostream>

using namespace std;

int main(){
	int a,b,c,k;
	cin >> a >> b >> c;
	cin >> k;
	int s[3];
	if(a<b && b<c){
			cout << "Yes";
			return 0;
		}
	for(int i=0;i<k;i++){
		if(a>=b){
			b=b*2;
		}else if(b>=c){
			c=c*2;
		}
		if(a<b && b<c){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
main()
{
    int i,a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int count=0;
    for(i=a;i<=b;i++)
    {
        if(c%i==0)count=count+1;


    }
    printf("%d\n",count);
}



Measured memory_bytes: 2064
#include<iostream>
#include<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1111111];
int memo2[1111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(n>=p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(n<0) return INF;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(p[i]&1 && n>=p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

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

const int N = 44;
int dp[N] = {};
int n;

int rec(int x)
{
	if(x == 0 || x == 1){
		dp[x] = 1;
		return dp[x];
	}
	
	if(dp[x] != 0)
		return dp[x];
	
	return dp[x] = rec(x - 1) + rec(x - 2);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	
	cout << rec(n) << endl;
	
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll s;
  cin >> s;
  
  ll a = 1000000000;
  ll b = 1;

  ll lb = 1;
  ll ub = a;
  while (ub-lb > 1) {
    ll mid = (lb+ub)/2;

    if (a*mid-s <= 0) {
      lb = mid;
    } else {
      ub = mid;
    }
  }
  ll d = a*lb-s < 0 ? ub : lb;
  ll c = a*d-s;

  cout << "0 0 " << a << " " << b << " " << c << " " << d << endl;
  
  return 0;
}


Measured memory_bytes: 256
program prob2
    implicit none
    integer::i, l, p, c
    character(len=10)::x
    read(*,*) x
    l = len_trim(x)
    p = 0
    c = 0
    do i = 3, l-1
        if(ichar(x(i:i)) .eq. ichar('C')) p = p + 1
    end do
    do i = 1, l
        if(ichar(x(i:i)) >= ichar('A') .and. ichar(x(i:i)) <= ichar('Z')) c = c + 1
    end do
    if(p == 1 .and. ichar(x(1:1)) .eq. ichar('A') .and. c == 2) then
        write(*,'(a)') "AC"
    else
        write(*,'(a)') "WA"
    end if
    stop
end program

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

const int maxN = 3e6 + 10, lim = 3e6, mod = 998244353;

int n, m;
int fac[maxN + 1], inv[maxN + 1];
int ans;

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline int C(int n, int m)
{
	if(n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
	scanf("%d %d", &n, &m);

	fac[0] = 1;
	for(int i = 1; i <= lim; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[lim] = mpow(fac[lim], mod - 2);
	for(int i = lim - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	for(int i = 0; i <= min(n, m); i++)
	{
		if((3 * m - i) & 1) continue;
		int t = (3 * m - i) >> 1;
		ans = ADD(ans, 1ll * C(n, i) * C(t + n - 1, n - 1) % mod);
	}

	for(int i = 0; i <= min(n, m); i++)
	{
		if((3 * m - i) & 1) continue;
		int t = (3 * m - i) >> 1;
		if(i < n) ans = SUB(ans, 1ll * n * C(n - 1, i) % mod * C(t + n - m - 2, n - 1) % mod);
		if(i > 0) ans = SUB(ans, 1ll * n * C(n - 1, i - 1) % mod * C(t + n - m - 1, n - 1) % mod);
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
  FAST/**/
   
   string s = "ACL";
   ll k;
   cin>>k;
   
   rep(k)
        cout<<s;
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 3612
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110000];
int q[110000]; // 1: tozan 0: beau
int main(){
	int a;scanf("%d%s",&a,in);
	for(int i=0;i<2;i++)for(int j=0;j<2;j++){
		q[0]=i;q[1]=j;
		for(int k=2;k<a;k++){
			int s=(in[k-1]=='o');
			int t=q[k-1];
			if(s^t){
				q[k]=q[k-2];
			}else{
				q[k]=!q[k-2];
			}
		}
		bool ok=true;
		for(int k=0;k<a;k++){
			int s=(in[k]=='o');
			int t=q[k];
			if(s^t){
				if(q[(k+a-1)%a]!=q[(k+1)%a])ok=false;
			}else{
				if(q[(k+a-1)%a]==q[(k+1)%a])ok=false;
			}
		}
		if(ok){
			for(int k=0;k<a;k++){
				if(!q[k])printf("S");
				else printf("W");
			}
			printf("\n");return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 768
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    ll n,t;
    cin>>n>>t;
    ll ml=mm;
    map<ll,ll>mp;
    for (ll i = 0; i < n; i++)
    {
        ll x;
        cin>>x;
        ml=min(ml,x);
        auto t=mp.find(x-ml);
        if(t==mp.end()) mp.insert({x-ml,1});
        else t->second++;
    }
    //deb(mp);
    cout<<mp.rbegin()->second;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 9788
N = int(input())
leng = 10**6+1
memo = [0]*leng
li = []
for n in map(int, input().split()):
    x = 0
    li.append(n)
    if memo[n] >1:
        pass
    else:
        while x < leng:
            memo[x] +=1
            x += n
count = 0
for n in li:
    if memo[n] == 1:
        count+=1
print(count)

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

int main(void){
    int n, m;

    cin >> n >> m;

    int l[m], r[m];
    rep(i, m){
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    int l_m = 0, r_m = n - 1;

    rep(i, m){
        l_m = max(l_m, l[i]);
        r_m = min(r_m, r[i]);
    }

    int cnt = 0;
    for(int i = l_m ; i <= r_m;  i++){
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
h,w = map(int, input().split())
s = [list(input()) for i in range(h)]
s2 = [[0]*(w+2) for i in range(h+2)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            s2[i+1][j+1] = 1
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            if s2[i+1][j] + s2[i+1][j+2] + s2[i][j+1] + s2[i+2][j+1] == 0:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			char[] a = scan.next().toCharArray();
			int ans = 0, prev = 2;
			for(int i = 0; i < a.length; i++) {
				if(prev == 2) {
					ans++;
					prev = 1;
				}
				else {
					if(a[i] != a[i-1]) {
						ans++;
					}
					else if(i < a.length-1){
						ans++;
						i++;
						prev = 2;
					}
				}
			}
			out.println(ans);
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


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

int main(){
  string s,t;

  for(;;){
    cin >> s;
    cin >> t;

    if(t=="X")break;

    vector<string> v;

    int pos=0;
    while(pos<s.size()){
      string tmp;
      if('A' <= s[pos] && s[pos]<='Z'){
	tmp += (char)(s[pos] + 32);
	pos++;
      }
      while(pos<s.size() && ('a'<= s[pos] && s[pos]<='z'))tmp += s[pos++];
      v.push_back(tmp);
      if(pos<s.size() && s[pos]=='_')pos++;
    }

    string ans;
    if(t=="U"){
      for(int i=0;i<(int)v.size();i++){
	v[i][0] = v[i][0]-32;
	ans += v[i];
      }
    }
    if(t=="L"){
      ans = v[0];
      for(int i=1;i<(int)v.size();i++){
	v[i][0] = v[i][0]-32;
	ans += v[i];
      }
    }
    if(t=="D"){
      ans = v[0];
      for(int i=1;i<(int)v.size();i++)ans += "_" + v[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int N = Integer.parseInt(line[0]);
		int K = Integer.parseInt(line[1]);
		String[] D = br.readLine().split(" ");

		int tf = 0;
		while(true){
			tf = 0;
			for(String s : D){
				if(String.valueOf(N).indexOf(s)!=-1){
					tf++;
				}
			}
			if(tf==0){
				System.out.println(N);
				break;
			}
			
			N++;
		}
	}
}


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

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

	a = a - b;
	c = c - a;
	
	if (c >= 0) {
		cout << c << endl;
	}
	else cout << 0 << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1])

c_l=[]
for b,c in l:
  c_l+=[c]*b
  if len(c_l)>=n:
    break

for i in range(min(n,len(c_l))):
  a[i]=max(a[i],c_l[i])

print(sum(a))

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

int main() {
  ll N;
  cin >> N;
  ll result = 0;
  for (ll i = 1; i * i <= N; ++i) {
    ll sq = pow(i, 2);
    result = max(sq, result);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define forn(i,n) for(int i=1;i<=n;i++) 
#define tests(t) int t; cin>>t; while(t--)

int solve() {
	int n;
	cin>>n;
	int a[n+2];
	forn(i,n) cin>>a[i];
	int ans = 0,maxm = a[1];
	for(int i=2;i<=n;i++) {
		ans += max(0LL,maxm - a[i]);
		maxm = max(maxm,a[i]);
	}
	return ans;
} 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cout<<solve();
	return 0;
}

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

using namespace std;

int arr[3][3];
int main()
{
  for(int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3 ; j++)
      cin>>arr[i][j];
  }
  int n;
  cin>>n;
  while(n--)
  {
    int tmp;
    cin>>tmp;
    for(int i = 0; i < 3; i++)
  	{
    	for (int j = 0; j < 3 ; j++)
          if (tmp == arr[i][j]) arr[i][j] = 0;
  	}
  }
  
  if (!arr[0][0] && !arr[1][1] && !arr[2][2])
    cout<<"Yes";
  else if (!arr[0][2] && !arr[1][1] && !arr[2][0])
    cout<<"Yes";
  
  else if (!arr[0][0] && !arr[0][1] && !arr[0][2])
    cout<<"Yes";
  else if (!arr[1][0] && !arr[1][1] && !arr[1][2])
    cout<<"Yes";
  else if (!arr[2][0] && !arr[2][1] && !arr[2][2])
    cout<<"Yes";
  
  else if (!arr[0][0] && !arr[1][0] && !arr[2][0])
    cout<<"Yes";
  else if (!arr[0][1] && !arr[1][1] && !arr[2][1])
    cout<<"Yes";
  else if (!arr[0][2] && !arr[1][2] && !arr[2][2])
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
S = list(input())
t = 0
for i in range(len(S)):
  if (i+1)%2 == 0:
    if S[i] == "L" or S[i] == "U" or S[i] == "D":
      continue
    else:
      t += 1
  elif (i+1)%2 == 1:
    if S[i] == "R" or S[i] == "U" or S[i] == "D":
      continue
    else:
      t += 1
if t == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		a=new int[n];
		for(int i=0;i<n;i++) a[i]=scan.nextInt();
		dp=new int[n];
		Arrays.fill(dp,-1);
		System.out.println(go(0));
	}
	static int[] dp;
	static int[] a;
	
	public static int go(int at) {
		if(at==a.length-1) return 0;
		if(dp[at]!=-1) return dp[at];
		int res=Integer.MAX_VALUE/2-5;
		if(at<a.length-1) {
			res=Math.min(res,Math.abs(a[at]-a[at+1])+go(at+1));
		}
		if(at<a.length-2) {
			res=Math.min(res,Math.abs(a[at]-a[at+2])+go(at+2));
		}
		return dp[at]=res;
	}
}

Measured memory_bytes: 61024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

#define int long long

main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int a, b, c, d;
    cin >> a >> c >> b >> d;
    int t;
    cin >> t;
    if ((c - d) * t >= abs(b - a))
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 3648
import copy
H, W, K = map(int, input().split())
A = [list(input()) for i in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        B = copy.deepcopy(A)
        for a in range(H):
            if i>>a & 1:
                B[a] = ["."]*W
        for a in range(W):
            if j>>a & 1:
                for m in range(H):
                    B[m][a] = "."
        s = 0
        for m in range(H):
           for n in range(W):
                if B[m][n] == "#":
                    s += 1
        if s == K:
            ans += 1
print(ans)
          

Measured memory_bytes: 71860
#include <iostream>

using namespace std;

int main(){
    int x,ans = 0;
    cin >> x;

    for(int i = x;;i++){
        bool flag = true;
        for(int j = 2;j <= i;j++){
            if(i % j == 0 && j != i){
                flag = false;
                break;
            }
        }

        if(flag){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a=10;
   int b=11;
   int area;
   int perimeter;
   cin >> a;
   cin >> b;
   area=a*b;
   perimeter=2*(a+b);
   cout << area << " "<< perimeter<< endl;
   return 0;
}


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

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)
#define MyDebug

#ifdef MyDebug
	#define debug(x) cout << #x << " : " << x << endl
	#define debugP(x) cout << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

void solve() {
	int a[3];
	rep(i, 0, 3) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << (a[0] + a[1]) << endl;
}

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


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=3009,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline void addto(int &x,int y){x=x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*ret%mod,y>>=1;
		}
		return x;
	}

	int f[N][N<<1][2],n,m;
	int main(){
		n=read<int>(),m=read<int>();
		for(int i=1;i<=n;i++) f[0][i][0]=1;
		f[0][0][1]=1;

		for(int i=0;i<m;i++){
			for(int j=0;j<=n;j++)
				for(int k=0;k<=1;k++){
					if(j){
						if(j!=1) addto(f[i+1][j][k],f[i][j][k]);
						else addto(f[i+1][j][k|1],f[i][j][k]);
					}
					if(j){
						if(j!=1) addto(f[i+1][j-1][k],f[i][j][k]);
						else addto(f[i+1][j-1][k|1],f[i][j][k]);
					}
					if(j!=n){
						addto(f[i+1][j+1][k],f[i][j][k]);
						addto(f[i+1][j][k],f[i][j][k]);
					}
				}
		}
			
		int ans=0;
		for(int i=0;i<=n;i++) ans=add(ans,f[m][i][1]);
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 85852
#include <stdio.h>
#include <string.h>
#define NUM 1000
char hitohude_error(char s[])
{
  int i,j,k;
  char error=0;  
  for(j=0;s[j+1] != '\n';j++) {
	if(s[j] == s[j+1]) {
	  error = 1; break;
	}
  }
  for(j=0; s[j+1] != '\n';j++) {
	if(s[j] == 'A') {
	  if(s[j+1] != 'B' && s[j+1] != 'D') {
		error = 1; break;
	  }
	}
	else if(s[j] == 'B') {
	  if(s[j+1] != 'A' && s[j+1] != 'C' && s[j+1] != 'E') {
		error = 1; break;
	  }
	}	
	else if(s[j] == 'C') {
	  if(s[j+1] != 'B' && s[j+1] != 'F') {
		error = 1; break;
	  }
	}
	else if(s[j] == 'D') {
	  if(s[j+1] != 'A' && s[j+1] != 'E' && s[j+1] != 'G') {
		error = 1; break;
	  }
	}	
	else if(s[j] == 'E') {
	  if(s[j+1] != 'B' && s[j+1] != 'D' && s[j+1] != 'F' && s[j+1] != 'H') {
		error = 1; break;
	  }
	}
	else if(s[j] == 'F') {
	  if(s[j+1] != 'C' &&s[j+1] != 'E' &&s[j+1] != 'I'){
		error = 1; break;
	  }
	}
	else if(s[j] == 'G') {
	  if(s[j+1] != 'D' &&s[j+1] != 'H'){
		error = 1; break;
	  }
	}
	else if(s[j] == 'H') {
	  if(s[j+1] != 'E' &&s[j+1] != 'G' &&s[j+1] != 'I'){
		error = 1; break;
	  }
	}
	else if(s[j] == 'I') {
	  if(s[j+1] != 'F' &&s[j+1] != 'H'){
		error = 1; break;
	  }
	}
  }
  return error;
}

	  
int main()
{
  int i,j,k;
  char s[12];
  static char print[NUM][12];
  int a=0;
  for(i=0;i<NUM;i++) {
	fgets(s,15,stdin);	
	if( hitohude_error(s) ) ;
	else strcpy(print[a++],s);
  }
  for(i=0;i<a;i++) 
	printf("%s",print[i]);
  return 0;
}

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

int a[100], w[210][210];
int main()
{
    int n, m, r, x, y, z;

    scanf("%d%d%d", &n, &m, &r);
    for (int i = 0; i < r; i++) {
        scanf("%d", &a[i]);
    }
    memset(w, 0x3f, sizeof w);
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &x, &y, &z);
        w[x][y] = w[y][x] = z;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                w[j][k] = min(w[j][k], w[j][i] + w[i][k]);
            }
        }
    }
    sort(a, a + r);
    int ans = 0x3f3f3f3f;
    do {
       int s = 0, fg = 0;
       for (int i = 1; i < r; i++) {
            if (w[a[i]][a[i - 1]] != 0x3f3f3f3f) {
                s += w[a[i]][a[i - 1]];
            } else {
                fg = 1;
            }
       }
       if (!fg) {
            ans = min(ans, s);
       }
    } while (next_permutation(a, a + r));
    printf("%d\n", ans);
}


Measured memory_bytes: 384
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

void _psum (int &, int);
int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, k, inv[N], f[N], res[N];
vector <int> X;

int x[] = {0, 0, -1, +1};
int y[] = {-1, +1, 0, 0};
int a[N], b[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	vector <int> ind(n);
	iota (ind.begin(), ind.end(), 0);
	sort (ind.begin(), ind.end(), [&] (int i, int j) {
		return a[i] < a[j];
	});

	int m = n / 2;
	for (int i = 0; i < n; i++)
		if (i < m)
			b[ind[i]] = a[ind[m]];
		else
			b[ind[i]] = a[ind[m - 1]];

	for (int i = 0; i < n; i++)
		cout << b[i] << '\n';
}

int gcd (int a, int b) {
	return !b? a : gcd (b, a % b);
}

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

void _psum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N,T;
  cin>>N>>T;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  ll ans = 0;
  rep(i,N-1){
    ans += min(T,v[i+1]-v[i]);
  }
  ans += T;
  cout<<ans<<endl;
}

Measured memory_bytes: 4760
#include <iostream>

int  main(void) {
	int N, M = 0;
	std::cin >> N;
	std::cin >> M;

	int* L = NULL;
	int* R = NULL;

	L = new int[M];
	R = new int[M];

	int IDmax = 0;
	int IDmin = 0;

	//入力
	for (int ii = 0; ii < M; ii++) {
		std::cin >> L[ii];
		std::cin >> R[ii];
	}

	int tmpIDmax = 0;
	int tmpIDmin = 0;

	IDmax = R[0];
	for (int ii = 0; ii < M; ii++) {
		tmpIDmax = R[ii];
		tmpIDmin = L[ii];

		if (IDmin <= tmpIDmin) {
			IDmin = tmpIDmin;
		}

		if (IDmax >= tmpIDmax) {
			IDmax = tmpIDmax;
		}
	}

	//出力
	if (IDmax >= IDmin) {
		std::cout << ((IDmax - IDmin) + 1);
	}
	else {
		std::cout << 0;
	}

	if (L != NULL) {
		delete[] L;
	}

	if (R != NULL) {
		delete[] R;
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int cnt = 0, border, s = 0;
    for (int i = 0; i < N; i++) cin >> A[i], s += A[i];
    border = s / (4 * M) + (s % (4 * M) > 0);
    for (int i = 0; i < N; i++)
        if (A[i] >= border) cnt++;
    if (cnt >= M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

#define N 100
#define INF 1<<21

int fee[N+1][N+1];
int d[N+1];
bool visit[N+1];
int n, k;

int dijkstra(int a, int b){
    for(int i = 0; i < 101; i++){
        d[i] = INF;
        visit[i] = 0;
    }

    d[a] = 0;

    priority_queue<pair<int,int>> pq;

    pq.push({-d[a], a});

    while(!pq.empty()){
        pair<int,int> now = pq.top();
        pq.pop();

        visit[now.second] = true;
        if(-now.first > d[now.second])   continue;

        for(int j = 1; j <= n; j++){
            if(fee[now.second][j] == INF || visit[j])    continue;
            
            if(fee[now.second][j] + d[now.second] < d[j]){
                d[j] = fee[now.second][j] + d[now.second];
                pq.push({-d[j], j});
            }
        }
    }

    return d[b];
}

int main(){
    while(1){
        cin >> n >> k;
        
        if(n + k == 0)  break;

        for(int i = 0; i < 101; i++){
            for(int j = 0; j < 101; j++){
                fee[i][j] = INF;
            }
        }

        int op, a, b, c, d, e;
        for(int i = 0; i < k; i++){
            cin >> op;
            if(op == 1){
                cin >> c >> d >> e;
                fee[c][d] = fee[d][c] = min(fee[c][d], e);
            }else if(op == 0){
                cin >> a >> b;
                int ans = dijkstra(a, b);
                if(ans == INF)  ans = -1;
                cout << ans << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

struct element {
  int node;
  int from;
};

int values[200001];
int adds[200001];
vector<int> edges[200001];
deque<element> que;

void expand(int node, int from) {
  values[node] = values[from] + adds[node];
  REP(i, edges[node].size()) {
    if (edges[node][i] == from) continue;
    element a = {edges[node][i], node};
    que.push_back(a);
  }
}

int main() {
  int N, Q;
  cin >> N >> Q;
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  REP(i, Q) {
    int a, b;
    cin >> a >> b;
    adds[a] += b;
  }
  element first = {1, 0};
  que.push_back(first);
  while (!que.empty()) {
    element a = que.front();
    que.pop_front();
    expand(a.node, a.from);
  }
  cout << values[1];
  REP(i, N - 1) { cout << " " << values[i + 2]; }

  return 0;
}


Measured memory_bytes: 17268