akhauriyash/Code-Regression huggingface dataset:
// Devarshi

#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001;

int gcd(int a,int b){

if(a<b) swap(a,b);
if(b==0) return a;
return gcd(a%b,b);

}


int main(){

ll n,x;
cin>>n>>x;

ll a[n+1];

forn(i,n) cin>>a[i];
a[n]=x;


if(n==1){
    cout<<abs(a[0]-x);
    return 0;
}

sort(a,a+n+1);


ll dif=INT_MAX;

int ans;
int a1=0,b;
fore(i,1,n){
    b=a[i]-a[i-1];
ans=gcd(a1,b);
a1=ans;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define MOD 1000000007

int main(){
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
    #endif

    int n;
    scanf("%d",&n);

    ll a[n];
    ll sum=0;
    
    fo(i,n) cin>>a[i];

    int ar[n];

    ar[0] = a[0];

    for(int i=1; i<n; i++) {
        ar[i] = (ar[i-1] + a[i])%MOD;
    }

    for(int i=0; i<n-1; i++) {
        sum = (sum+(ar[i]*a[i+1])%MOD)%MOD;
    }

    cout<<sum;

    return 0;
}

Measured memory_bytes: 6028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

bool doit(string s){
    rep(i,s.size()){
        if(s.at(i)!='A' and s.at(i)!='T' and s.at(i)!='C' and s.at(i)!='G') return false;
    }
    return true;
}
signed main(){
    string s; cin>>s;
    for(int j=s.size(); j>=0; j--){
        for(int i=0; i+j<=s.size(); i++){
            if(doit(s.substr(i,j))){
                cout<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
n,t = gets.split.map(&:to_i)
t_arr = []

n.times do |i|
  s = gets.split.map(&:to_i)
  if s[1] <= t
    t_arr << s
  end
end

if t_arr.count == 0
  puts "TLE"
  exit
end

c_arr = []
t_arr.each do |x|
  c_arr << x[0]
end

p c_arr.min


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    string s, t; cin >> s >> t;
    int ans = 0;
    REP(i, s.length()) {
        if (s[i] != t[i]) ans++;
    }
    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3852
n = int(raw_input())
r = 1.0
for i in range(1,n+1):
    r = r * i
    if r > 1.0e+9 + 7:
        r = (r % (1.0e+9+7))
        #r -= ri * (10.0e+9+7)

print str(int(r))

Measured memory_bytes: 5764
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;

int main(int argc, char const *argv[])
{
  int n, k;
  int x[100000];

  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> x[i];
  }

  int min = INT_MAX;
  for (int i = 0; i < n - k + 1; i++)
  {
    int distance = abs(x[i]);
    if (distance > abs(x[i + k - 1]))
    {
      distance = abs(x[i + k - 1]);
    }
    distance = distance + abs(x[i + k - 1] - x[i]);
    min = min > distance ? distance : min;
  }
  cout << min;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define iris 19260817
using namespace std;

bool v[100010];
vector<int> edge[100010],ans;

void dfs(int a,int f)
{
	if(!v[a])
	{
		ans.emplace_back(a);
	}
	v[a]=1;
	for(int b:edge[a])
	{
		if(!v[b] && b!=f)
		{
			dfs(b,a);
			return;
		}
	}
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m,i,a,b;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
	}
	dfs(1,0);
	reverse(ans.begin(),ans.end());
	dfs(1,0);
	cout<<ans.size()<<'\n';
	for(i=0;i<ans.size();i++)
	{
		if(i)
		{
			cout<<' ';
		}
		cout<<ans[i];
	}
	cout<<'\n';
	
	return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if (a+b > c+d ) {
		cout << "Left" << endl;
	} else if (a+b == c+d) {
		cout << "Balanced" << endl;
	} else {
		cout << "Right" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;


int main() {

  int a, b, c;
  cin >> a >> b >> c;
  int x, y;
  cin >> x >> y;

  int ans = a * x + b * y;
  if( a + b > 2*c ){
    int tmp = min(x,y);
    ans = tmp*2*c;
    if( x != tmp ) ans += (x-tmp)*a;
    if( y != tmp ) ans += (y-tmp)*b;
  }
  int aaa = 2 * c * max(x,y);
  ans = min(ans, aaa);


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






// EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

class flow {
    struct edge {
        int to,cap,rev;
        edge(int to,int cap,int rev):to(to),cap(cap),rev(rev) {}
    };
    int n;
    vector<vector<edge>> G;
    vi level,iter;

    void bfs(int s) {
        level.assign(n,-1);
        queue<int> q;
        level[s] = 0;
        q.push(s);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(auto& e : G[v]) {
                if(e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v]+1;
                    q.push(e.to);
                }
            }
        }
    }
    int dfs(int v,int t,int f) {
        if(v == t) return f;
        rep2(i,iter[v],G[v].size()) {
            auto &e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to,t,min(f,e.cap));
                if(d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    explicit flow(int n):n(n),G(n),level(n),iter(n) {}
    void add_edge(int from,int to,int cap) {
        G[from].eb(to,cap,G[to].size());
        G[to].eb(from,0,G[from].size()-1);
    }
    // O(|E||V|^2) dinic-algorithm
    int max_flow(int s,int t) {
        int fl = 0;
        while(true) {
            bfs(s);
            if(level[t] < 0) return fl;
            iter.assign(n,0);
            int f;
            while((f = dfs(s,t,inf)) > 0) fl += f;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int X,Y,e;
    cin >> X >> Y >> e;
    int s = X+Y,t = s+1;
    flow fl(t+1);
    rep(_,e) {
        int x,y;
        cin >> x >> y;
        fl.add_edge(x,X+y,1);
    }
    rep(i,X) fl.add_edge(s,i,1);
    rep(i,Y) fl.add_edge(X+i,t,1);
    cout << fl.max_flow(s,t) << endl;
}



Measured memory_bytes: 3308
object Main {
  def main(args: Array[String]): Unit = {
    val factors = io.StdIn.readLine.split(" ").map{_.toInt}
    if( factors( 0 )%factors( 1 ) == 0 ) println( factors( 0 )/factors( 1 ) )
    else                                 println( factors( 0 )/factors( 1 ) + 1 )
  }
}

Measured memory_bytes: 54292
a, b, k = map(int, input().split())
for i in range(a, a + k):
    if(i < a or i > b): continue
    print(i)
for i in range(b - k + 1, b + 1):
    if (a <= i and i <= a + k - 1): continue
    if(i < a or i > b): continue
    print(i)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  int A,B,C,K;
  cin >> A>> B>>C>>K;
  int sum=0;
  
  sum+=min(A,K);
  K-=min(A,K);
  
  K-=min(B,K);
  
  sum-=min(C,K);
  K-=min(C,K);
  
  
  cout << sum << endl;
  
  return 0;
  
}


Measured memory_bytes: 3600
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N =sc.nextInt();
    int T =sc.nextInt();
    int A =sc.nextInt();
    int[] H = new int[N];
    double mindelta = Double.MAX_VALUE;
    int ans=0;
    for(int i=0; i<N;i++){
      H[i]=sc.nextInt();
      double temp = T- H[i]*0.006;
      double delta = Math.abs(A-temp);
      if (mindelta>delta){
        mindelta=delta;
        ans=i;
      }
    }
    System.out.println(ans+1);

  }
}


Measured memory_bytes: 22996
#include<iostream>
#include<queue>
#include<map>
using namespace std;
int main(){
  while(1){
    int n,m,a,max=0;
    priority_queue<pair<int,pair<int,int > > > b;
    cin>>n>>m>>a;
    if(n+m+a==0)break;
    for(int i=0;i<m;i++){
      int h,p,q;
      cin>>h>>p>>q;
      b.push(make_pair(h,make_pair(p,q)));
      if(h>max)max=h;
    }
    while(!b.empty()){
      if(b.top().second.first==a||b.top().second.second==a){
	if(b.top().second.first==a)a=b.top().second.second,b.pop();
	else  a=b.top().second.first,b.pop();
      }else b.pop();
    }
    cout<<a<<endl;
  }
  return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int og = ceil(n / 1.08);
    if ((int)(og * 1.08) == n) {
        cout << og << endl;
    } else {
        cout << ":(" << endl;
    }

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


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

template<typename T>
constexpr T modpow(T a,T n,T mod=1000000007){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

std::vector<long long> fac;
std::vector<long long> ifac;

template <typename T>
T modcomb(T a, T b,T MOD=1000000007){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    long long tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

void combinit(int maxn){
    long long MOD=1000000007;
    fac.resize(maxn+1);
    ifac.resize(maxn+1);
    fac[0] = 1;
    ifac[0] = 1;
    for(long long i = 0; i<maxn; i++){
        fac[i+1] = fac[i]*(i+1) % MOD;
        ifac[i+1] = ifac[i]*modpow(i+1, MOD-2) % MOD;
    }
}

using namespace std;
using ll=long long;

int main(){
    ll MOD=1000000007;
    ll n,k;
    cin>>n>>k;
    combinit(n);
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll r=n-1-i;
        ll l=i;
        ll cnt=modcomb(l,k-1);
        cnt-=modcomb(r,k-1);
        if(cnt<0)cnt+=MOD;
        if(a[i]<0)a[i]+=MOD;
        ans+=(a[i]*cnt)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
import itertools
x,y,z,k = list(map(int, input().split())) 
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
 
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
del a[min(k,x):]
del b[min(k,y):]
del c[min(k,z):]
 
ab = [i + j for (i, j) in list(itertools.product(a, b))]
 
ab.sort(reverse=True)
del ab[min(k,x*y):]
 
abc = [ij + h for (ij, h) in list(itertools.product(ab, c))]
 
abc.sort(reverse=True)
 
for g in range(k):
  print(abc[g])

Measured memory_bytes: 272408
#C

N = int(input())
X = map(int, input().split())

import numpy as np

X = np.array(list(X))

min_cost = np.inf
for n in range(1, 101):
  cost = np.sum(np.square(X-n))
  if cost < min_cost:
    min_cost = cost
print(min_cost)

Measured memory_bytes: 12504
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  multiset<int> st;
  for (int i = 0; i < (1 << n); i++) {
    int a;
    cin >> a;
    st.insert(-a);
  }
  vector<int> cur;
  cur.push_back(*st.begin());
  st.erase(st.begin());
  while (st.size()) {
    vector<int> nxt;
    for (int i : cur) {
      auto res = st.upper_bound(i);
      if (res == st.end()) {
        cout << "No" << endl;
        return 0;
      }
      nxt.push_back(*res);
      st.erase(res);
    }
    for (int i : nxt) cur.push_back(i);
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 13984
#include<iostream>
using namespace std;
int n,dp[1001][8];
string str;
int change(char ch){
  if(ch=='J')return 0;
  if(ch=='O')return 1;
  else return 2;
}
int main(){
  cin>>n>>str;
  for(int i=0;i<1001;i++){
    for(int j=0;j<8;j++){
	dp[i][j]=0;
    }
  }
  //j=0 o=1 i=2
  dp[0][4]=1;
  for(int i=0;i<n;i++){
    if(str[i]=='J'){
      dp[i+1][1]=0;//I
      dp[i+1][2]=0;//O
      dp[i+1][3]=0;//OI
      dp[i+1][4]=dp[i][7]+dp[i][6]+dp[i][5]+dp[i][4];//J
      dp[i+1][5]=dp[i][1]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];//JI Iテ」ツ?徽テ」ツ?古ゥツ債オテ」ツつ津・ツ可催ヲツ猟・テ」ツつづ」ツ?。テ」ツ?凝」ツ?暗」ツ?」テ」ツ??
      dp[i+1][6]=dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];//JO
      dp[i+1][7]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];//JOI
    }else if(str[i]=='O'){
      dp[i+1][1]=0;//I
      dp[i+1][2]=dp[i][2]+dp[i][3]+dp[i][6]+dp[i][7];//O
      dp[i+1][3]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][5]+dp[i][6]+dp[i][7];//IO
      dp[i+1][4]=0;
      dp[i+1][5]=0;
      dp[i+1][6]=dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];
      dp[i+1][7]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];//JOI
    }else{
      dp[i+1][1]=dp[i][1]+dp[i][3]+dp[i][5]+dp[i][7];
      dp[i+1][2]=0;
      dp[i+1][3]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][5]+dp[i][6]+dp[i][7];//IO
      dp[i+1][4]=0;
      dp[i+1][5]=dp[i][1]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];
      dp[i+1][6]=0;
      dp[i+1][7]=dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6]+dp[i][7];//JOI
    }
    for(int j=0;j<8;j++)dp[i+1][j]%=10007;
  }
  int sum=0;
  for(int i=0;i<8;i++)sum+=dp[n][i];
  cout<<(sum)%10007<<endl;


 
  return 0;
}

Measured memory_bytes: 1236
def solve():
  N = int(input())
  s = input()
  mod = 10**9+7
  dp = [[0]*N for _ in range(N)]
  dp[-1][0]=1
  for i in range(N-2,-1,-1):
    if s[i]=='>':
      for j in range(N-i-2,-1,-1):
        dp[i][j] = dp[i][j+1]+dp[i+1][j]
        dp[i][j] %= mod
    else:
      for j in range(1,N-i):
        dp[i][j] = dp[i][j-1]+dp[i+1][j-1]
        dp[i][j] %= mod
  ans = sum(dp[0])%mod
  return ans
print(solve())

Measured memory_bytes: 139364
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int n;
	cin>>n;
	int h[n+1];
	FOR0(n) cin>>h[i+1];
	int dp[n+5];
	FOR0(n+3) dp[i]=inf;
	dp[1]=0;dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n];
}



Measured memory_bytes: 1024
def main():
    def plus(a,b):
        if a=="":
            return b
        elif b=="":
            return a
        elif a=="A":
            if b=="A":
                return "B"
            else:
                return ""
        else:
            if b=="A":
                return ""
            else:
                return "A"
    def minus(a,b):
        if b=="A":
            b="B"
        elif b=="B":
            b="A"
        return plus(a,b)
    dp1=[""]
    dp2=[""]
    s=input()
    t=input()
    q=int(input())
    abcd=[list(map(int,input().split())) for _ in [0]*q]
    for i in s:
        dp1.append(plus(dp1[-1],i))
    for i in t:
        dp2.append(plus(dp2[-1],i))
    for a,b,c,d in abcd:
        a,b,c,d=dp1[a-1],dp1[b],dp2[c-1],dp2[d]
        print(["NO","YES"][minus(b,a)==minus(d,c)])
main()

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

int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main() {
    int n;
    cin >> n;
    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }
    string march = "MARCH";
    vector<int> count_march(5);
    for (int i = 0; i < n; i++) {
        string name;
        cin >> name;
        char ini = name[0];
        int pos = march.find(ini);
        if (pos == string::npos) continue;
        else count_march[pos]++;
    }
    int64_t ans = 0;
    int p = 5;
    int q = 3;
    int bit = (1<<q)-1; // 0b111 : 7
    for (;bit < (1<<p); bit = next_combination(bit)) {
        vector<int> S;
        int64_t subtotal = 1;
        for (int i = 0; i < p; i++) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }
        for (int i = 0; i < S.size(); i++) {
            subtotal *= count_march[S[i]];
        }
        ans += subtotal;
    }
    cout << ans << endl;   
}

Measured memory_bytes: 256
import queue

n, k = map(int, input().split())
edges = []
for _ in range(n-1):
  edges.append(list(map(int, input().split())))
mod = 10**9+7

edge_dict = {}
for i in range(1, n+1):
  edge_dict[i] = set()

for edge in edges:
  edge_dict[edge[0]].add(edge[1])
  edge_dict[edge[1]].add(edge[0])

visited = set()
q = queue.LifoQueue()
q.put(1)

num_cases = 1
while not q.empty():
  node = q.get()
  
  visited.add(node)
  num_available_colors = k -2 if node is not 1 else k -1
  
  for child in (edge_dict[node] - visited):
    num_cases *= num_available_colors
    num_available_colors -= 1
    num_cases %= mod
    q.put(child)

print((k*num_cases)%mod)

Measured memory_bytes: 71576
import java.util.Arrays;
import java.util.Scanner;

public class Main
{

	public static void main( String[] args )
	{

		Scanner s = new Scanner( System.in );

		int n = s.nextInt();
		int[] strengths = new int[3*n];
		
		for(int i = 0; i < 3*n; i++)
		{
			strengths[i] = s.nextInt();
		}
		
		Arrays.sort( strengths );
		
		int l = 0, r = 3*n - 1;
		long sum = 0;
		while(l < r)
		{
			sum += strengths[r-1];
			r -= 2;
			l++;
		}

		System.out.println( sum );
		
		s.close();

	}

}


Measured memory_bytes: 92480
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

const int NODE = 333333;

vector<vector<ll>> v(NODE);

ll tmp[NODE];
ll ans[NODE];
ll fact[NODE];
ll ko[NODE];

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

void syl(){
	fact[0] = 1;
	for(int i = 1;i < NODE - 1;i++){
		fact[i] = fact[i-1] * i % MOD;
	}
}

void seica(int node, int pre){
	ll now = 1;
	ll sum = 0;
	vector<ll> child;
	REP(i, v[node].size()){
		int aite = v[node][i];
		if(aite == pre)continue;
		seica(aite, node);
		child.PB(ko[aite]);
		sum += ko[aite];
		now = now * tmp[aite] % MOD;
	}
	now = now * fact[sum] % MOD;
	REP(i, child.size())now = mod_div(now, fact[child[i]]);
	tmp[node] = now;
	ko[node] = sum + 1;
}

void keymoon(int node, int pre, ll pre_ko, ll pre_tmp){
	ll now = mod_div(pre_tmp, fact[pre_ko]);
	ll sum = pre_ko;
	REP(i, v[node].size()){
		int aite = v[node][i];
		if(aite == pre)continue;
		sum += ko[aite];
		now = now * tmp[aite] % MOD;
		now = mod_div(now, fact[ko[aite]]);
	}
	now = now * fact[sum] % MOD;
	ans[node] = now;

	REP(i, v[node].size()){
		int aite = v[node][i];
		if(aite == pre)continue;
		ll n_ko = sum - ko[aite] + 1;
		ll n_tmp = now;
		n_tmp = mod_div(n_tmp, fact[sum]);
		n_tmp = mod_div(n_tmp, tmp[aite]);
		n_tmp = n_tmp * fact[ko[aite]] % MOD;
		n_tmp = n_tmp * fact[n_ko - 1] % MOD;
		keymoon(aite, node, n_ko, n_tmp);
	}
}

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

	ll n;cin >> n;
	REP(i, n - 1){
		ll a, b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);
		v[b].PB(a);
	}

	syl();
	seica(0, -1);
	keymoon(0, -1, 0, 1);

	//SHOW1d(tmp, n);

	REP(i, n)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 28784
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int maxA = -1;
		int ans = 0;
		for(int i = 0; i < N; i++){
			int A = sc.nextInt();
			int B = sc.nextInt();
			if(A > maxA){
				maxA = A;
				ans = A + B;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int n;
	cin>>n;
	char s1[n];
	char s2[n];
	REP(i,n)
	{
		cin>>s1[i];
	}
	REP(i,n) cin>>s2[i];
	if(s1[0]==s2[0])
	{
		lli ans=3;
		FOR(i,1,n-1)
		{
			if(s1[i]==s2[i])
			{
				if(s1[i-1]==s2[i-1])
				{
					ans*=2;
				}
			}
			else if(s1[i]==s1[i-1]&&s2[i]==s2[i-1])
			{
				if(s1[i-2]==s2[i-2])
				{
					ans*=2;
				}
				else ans*=3;
			}
			ans%=MOD;
		}
		cout<<ans<<endl;
	}
	else
	{
		lli ans=6;
		FOR(i,2,n-1)
		{
			if(s1[i]==s2[i])
			{
				if(s1[i-1]==s2[i-1])
				{
					ans*=2;
				}
			}
			else if(s1[i]==s1[i-1]&&s2[i]==s2[i-1])
			{
				if(s1[i-2]==s2[i-2])
				{
					ans*=2;
				}
				else ans*=3;
			}
			ans%=MOD;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 2e5 + 5;

int n, mo, a[N], as;

int calc(int m) {
	int ans = 0;
	fo(i, 1, m) ans = max(ans, (a[i] + a[2 * m - i + 1]) % mo);
	fo(i, 1, n - m) ans = max(ans, (a[2 * m + i] + a[2 * n - i + 1]) % mo);
	return ans;
}

int main() {
	scanf("%d %d", &n, &mo);
	fo(i, 1, 2 * n) scanf("%d", &a[i]);
	sort(a + 1, a + 2 * n + 1);
	int as = 0;
	for(int l = 0, r = n; l <= r; ) {
		int m = l + r >> 1;
		int ye = 1;
		fo(i, 1, n - m) if(a[2 * m + i] + a[2 * n - i + 1] < mo) ye = 0;
		if(ye) {
			as = m;
			r = m - 1;
			continue;
		}
		l = m + 1;
	}
	int ans = calc(as);
	if(as < n) ans = min(ans, calc(as + 1));
	pp("%d\n", ans);
}


Measured memory_bytes: 1024
num = (3, 5, 7)
list_357 = ["3", "5", "7"]
list_357_tmp = []
list_753 = []
for i in range(8):
    for j in num:
        for k in list_357:
            list_357_tmp.append(str(j) + k)
    list_357.extend(list_357_tmp)
    list_357_tmp.clear()
for i in list_357:
    if "3" in i and "5" in i and "7" in i:
        list_753.append(int(i))
list_753=set(sorted(list_753))
list_753=sorted(list_753)
N = int(input())
ans = 0
for i in range(len(list_753)):
    if N < list_753[i]:
        ans = i
        break
    elif i == len(list_753)-1:
        ans = i+1
print(ans)

Measured memory_bytes: 26464
R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

dp0 = [[0]*(C+1) for _ in range(R+1)]
dp1 = [[0]*(C+1) for _ in range(R+1)]
dp2 = [[0]*(C+1) for _ in range(R+1)]
dp3 = [[0]*(C+1) for _ in range(R+1)]
for i in range(R+1):
    for j in range(C+1):
        v = V[i][j]

        la = lb = lc = ld = 0
        if j > 0:
            la = dp0[i][j-1]
            lb = dp1[i][j-1]
            lc = dp2[i][j-1]
            ld = dp3[i][j-1]
            dp2[i][j] = max(dp2[i][j], lc, lb + v)
            dp3[i][j] = max(dp3[i][j], ld, lc + v)

        if i > 0:
            max_p = max(dp0[i-1][j], dp1[i-1][j], dp2[i-1][j], dp3[i-1][j])
            dp0[i][j] = max(dp0[i][j], max_p, la)
            dp1[i][j] = max(dp1[i][j], max_p + v, lb, la + v)

print(max(dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C]))


Measured memory_bytes: 432444
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;
int main(void)
{
    int a, b;
    cin >> a >> b;
    int p[3];
    p[0] = a + b;
    p[1] = a - b;
    p[2] = a * b;
    int res = p[0];
    for (size_t i = 0; i < 2; i++)
    {
        if(p[i+1] > res)
        {
            res = p[i + 1];
        }
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
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();
        //文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
        line = line.trim();
        //半角スペースを区切り文字として扱う
        String[] readLineArray = line.split("[\\s+]");
        //変数に配列を代入
        int a = Integer.parseInt(readLineArray[0]);
        int b = Integer.parseInt(readLineArray[1]);
        int c = Integer.parseInt(readLineArray[2]);
        if((a<b)&&(b<c)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 17088
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        ans += 1
        x -= a[i]
    else:
        break
else:
    if x != 0:
        ans -= 1


print(ans)


Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	puta(min(a,b),max(0,a+b-n));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll n,a;
ll x[51]={};
ll dp[51][51][2503];

ll dfs(int i, int cnt, int sum){
    if(dp[i][cnt][sum]!=-1)return dp[i][cnt][sum];
    if (i == n){
        return cnt != 0 && sum == cnt * a;
    }
    ll res = 0;
    res += dfs(i+1, cnt, sum) + dfs(i + 1, cnt + 1, sum + x[i]);

    return dp[i][cnt][sum] = res;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin>>n>>a;
    for(int i=0; i<n; i++)cin>>x[i];
    cout<<dfs(0,0,0)<<endl;
}

Measured memory_bytes: 51200
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i,m,n) for(unsigned long long int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50,vector<int>(4,0));


int ans = 0;
int MA = 0;
int N, M, Q;

vector<int> vvvf;

int set(int x,int y) {
	if (x == N - 1) {
		rep(i, y, M + 1) {
			vvvf[x] = i;
			rep(j, 0, Q) {
				if (vvvf[vec[j][1]-1] - vvvf[vec[j][0]-1] == vec[j][2]) {
					vvvf[N] += vec[j][3];
				}
			}
			if (vvvf[N] > MA) MA = vvvf[N];
			vvvf[N] = 0;
		}
		vvvf.resize(N + 1, 0);
		return 0;
	}else {
		rep(i, y, M + 1) {
			vvvf[x] = i;
			set(x+1, i);
		}
	}
	return 0;
}

int main() {
	cin >> N >> M >> Q;
	v.resize(N);
	
	rep(i, 0, Q)cin >> vec[i][0] >> vec[i][1] >> vec[i][2] >> vec[i][3];
	vvvf.resize(N + 1, 0);
	set(0,1);

	cout << MA << '\n';
	
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll H_, N;
vpll AB;
vll dp;

void search(void){
  REP(i,H_){
    REP(j,N){
      chmin(dp[i+AB[j].first], dp[i]+AB[j].second);
    }
  }
  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(H_,N);
  AB.resize(N);
  REP(i,N){
    IN(AB[i].first, AB[i].second);
  }

  dp.resize(100000, INFLL);

  dp[0] = 0;
  search();

  ll ans = INFLL;
  FOR(i,H_,100000){
    if(dp[i]>=0) chmin(ans, dp[i]);
  }

  OUT(ans);
  return 0;
}


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



int main()
{
	int n;
	long double product=1,sum=0;
	cin>>n;
	long long arr[n+10];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		product*=arr[i];
	}
	for(int i=0;i<n;i++)
	{
		sum+=product/arr[i];
	}
	cout<<setprecision(10)<<product/sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int d[500010],x[500010],n;
LL D[500010],l,S[500010],s[500010],ans;
int main(){
	cin>>l>>n;
	FOR(i,1,n) getint(x[i]);
	//left first
	FOR(i,0,n-1) d[i]=x[i+1]-x[i];
	d[n]=l-x[n];
	FOR(i,0,n) D[i]=1ll*d[i]*i;
	s[0]=d[0];
	FOR(i,1,n) s[i]=s[i-1]+d[i];
	S[0]=D[0];
	FOR(i,1,n) S[i]=S[i-1]+D[i];
	FOR(i,1,n){
		//1~i-1
		LL t=0;
		if (i&1){
			int too=i>>1;
			//too-1 2
			//too-2 4
			//0 ...
			t+=(2ll*too)*(too>=1?s[too-1]:0ll)-2ll*(too>=1?S[too-1]:0ll);
			//too+1 1
			//too+2 3
			//i-1 ...
			t+=2ll*(S[i-1]-S[too])-(2ll*too+1)*(s[i-1]-s[too]);
			t+=1ll*i*(l-x[i]);
			ans=max(ans,t);
		}
		else{
			int too=i>>1;
			//too-1 1
			//too-2 3
			//0 ...
			t+=(2ll*too-1)*(too>=1?s[too-1]:0ll)-2ll*(too>=1?S[too-1]:0ll);
			//too+1 2
			//too+2 4
			//i-1 ...
			t+=2ll*(S[i-1]-S[too])-(2ll*too)*(s[i-1]-s[too]);
			t+=1ll*i*(l-x[i]);
			ans=max(ans,t);
		}
	}
	//right first
	FOR(i,1,n/2) swap(x[i],x[n-i+1]);
	FOR(i,1,n) x[i]=l-x[i];
	FOR(i,0,n-1) d[i]=x[i+1]-x[i];
	d[n]=l-x[n];
	FOR(i,0,n) D[i]=1ll*d[i]*i;
	s[0]=d[0];
	FOR(i,1,n) s[i]=s[i-1]+d[i];
	S[0]=D[0];
	FOR(i,1,n) S[i]=S[i-1]+D[i];
	FOR(i,1,n){
		//1~i-1
		LL t=0;
		if (i&1){
			int too=i>>1;
			//too-1 2
			//too-2 4
			//0 ...
			t+=(2ll*too)*(too>=1?s[too-1]:0ll)-2ll*(too>=1?S[too-1]:0ll);
			//too+1 1
			//too+2 3
			//i-1 ...
			t+=2ll*(S[i-1]-S[too])-(2ll*too+1)*(s[i-1]-s[too]);
			t+=1ll*i*(l-x[i]);
			ans=max(ans,t);
		}
		else{
			int too=i>>1;
			//too-1 1
			//too-2 3
			//0 ...
			t+=(2ll*too-1)*(too>=1?s[too-1]:0ll)-2ll*(too>=1?S[too-1]:0ll);
			//too+1 2
			//too+2 4
			//i-1 ...
			t+=2ll*(S[i-1]-S[too])-(2ll*too)*(s[i-1]-s[too]);
			t+=1ll*i*(l-x[i]);
			ans=max(ans,t);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const int INF = 1000000007;

const int MAX_H = 50;
const int MAX_W = 50;

// 下、右、上、左
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int H, W;

char field[MAX_H][MAX_W + 1];
char cpy[MAX_H][MAX_W + 1];

int memo[MAX_H][MAX_W];

int bfs(int i, int j)
{
    queue< pair<int, int> > que;

    // スタート地点をキューに入れる
    que.push(make_pair(i, j));

    while (que.size())
    {
        pair<int, int> p = que.front();
        que.pop();

        i = p.first;
        j = p.second;

        // 行った
        cpy[i][j] = '#';

        if (i == H - 1 && j == W - 1) return 0;
        REP (k, 4)
        {
            int ni = i + dy[k];
            int nj = j + dx[k];

            if (ni < 0 || H <= ni
                || nj < 0 || W <= nj
                || cpy[ni][nj] == '#'
                || memo[ni][nj] < INF)
            {
                continue;
            }

            memo[ni][nj] = memo[i][j] + 1;
            que.push(make_pair(ni, nj));
        }
    }
    return -1;
}

int main()
{
    cin >> H >> W;

    int bcnt = 0;
    REP (i, H)
    {
        cin >> field[i];

        REP (j, W)
        {
            if (field[i][j] == '.') bcnt++;
            memo[i][j] = INF;
        }
    }

    memcpy(cpy, field, sizeof field);

    memo[0][0] = 1;

    // 幅優先探索 Breadth-First Search
    int ret = bfs(0, 0);

    if (ret == -1) printf("%d\n", ret);
    else printf("%d\n", bcnt - memo[H - 1][W - 1]);

    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n; cin>>n;
	vl a(n+1, 0);
	forne(x, 100) forne(y, 100) forne(z, 100){
		int val = x*x + y*y + z*z + x*y + x*z + y*z;
		if(val<=n) a[val]++;
	}
	forne(i, n) cout<<a[i]<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3644