akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>k;
    rep(i,k)cin>>a[i];
    if(a[k-1]!=2)Cout(-1);
    else{
        reverse(a,a+k);
        ll now=2,noww=3;
        rrep(i,1,k){
                tmp=now/a[i];
                if(now%a[i]!=0){
                tmp++;
                }
                now=tmp*a[i];
        }
        rrep(i,1,k){
                tmp=noww/a[i];
           
                noww=tmp*a[i]+a[i]-1;
        }
        reverse(a,a+k);
        ans=now;
        rep(i,k){
            ans=(ans/a[i])*a[i];
        }
        if(ans!=2)Cout(-1);
        else{
            ans=noww;
            rep(i,k){
                ans=(ans/a[i])*a[i];
            }
            if(ans!=2)Cout(-1);
            else cout<<now<<" "<<noww<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1024
// Problem : E - Knapsack 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 1;
const ll M = 101;
ll dp[M][N]; // dp[i][j] min wt required to obtain value j till ith item
ll n , m;
ll wt[M];
ll val[M];
void solve(){
	cin >> n >> m;
	rep(i , n) cin >> wt[i + 1] >> val[i + 1];
	rep(i ,M){
		rep(j,N) dp[i][j] = inf;
	}
	dp[1][0] = 0;
	dp[1][val[1]] = wt[1];
	for(ll i = 2  ; i <= n ; i++){
		for(ll j = 0 ; j < N ; j++){
			if(j - val[i] >= 0) dp[i][j] = min(dp[i - 1][j] , dp[i - 1][j - val[i]] + wt[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	} 
	ll ans = -inf;
	for(ll j =0 ;  j < N ; j++) if(dp[n][j] <= m) ans = max(ans , j);
	cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n+1,0);
    rep(i,n) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    rep(i,n) {
        b[i+1] = a[i]+b[i];
    }
    int ans = 1;
    rrep(i,n) {
        if(b[i]*2>=a[i]) ans++;
        else break;
        //cout << b[i]<<" "<<a[i]<<" "<<i << endl;
    }
    cout << ans << endl;

    
  return 0;
}



Measured memory_bytes: 4844
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		ll n,m; cin >> n >> m;
		if(n==0 && m==0) break;
		vl a(n),b(m);
		ll s = 0, t = 0;
		rep(i,n) cin >> a[i], s += a[i];
		rep(i,m) cin >> b[i], t += b[i];
		sort(all(a)); sort(all(b));
		if(abs(s-t) & 1){
			cout << -1 << endl;
			continue;
		}
		ll dis = (s-t)/2;
		bool flag = false;
		rep(i,n){
			if(binary_search(all(b),a[i]-dis)){
				cout << a[i] << " " << a[i]-dis << endl;
				flag = true;
				break;
			}
		}
		if(!flag) cout << -1 << endl;
	}
}


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

using namespace std;


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

	int n, k, q;
	cin >> n >> k >> q;
	vector<int> v(q), points(n+1);
	for(int i = 0; i < q; i++) cin >> v[i];
	for(int i = 1; i <= n; i++) points[i] = k;
	for(int i = 0; i < q; i++) {
		points[v[i]]++; // aumentando de quem ganhou
	}
	int vou_decrescer = 0;
	for(int i = 1; i <= n; i++) {
		vou_decrescer += (points[i] - k);
	}
	for(int i = 1; i <= n; i++) {
		points[i] -= vou_decrescer;
		if(points[i] > 0) cout << "Yes\n";
		else cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int n,cur=0,ans=0,here,k;
vector<int> truthTellers;
vector<pair<int,int>> v;
vector<vector<pair<int,int>>> testimonies;
vector<int> testNums;

void checker()
{
    here=0;
    for (int i=0;i<n;++i)
    {
        if (truthTellers[i])
        {
            k=testNums[i];
            for (int j=0;j<k;++j)
            {
                if (testimonies[i][j].second!=truthTellers[testimonies[i][j].first-1])
                {
                    return;
                }
            }
            ++here;
        }
    }
    ans=max(here,ans);
    return;
}

void generate()
{
    if (cur==n)
    {
        checker();
        return;
    }
    truthTellers[cur]=0;
    ++cur;
    generate();
    --cur;
    truthTellers[cur]=1;
    ++cur;
    generate();
    --cur;
    //cout<<"down to "<<cur<<" from "<<cur+1<<"\n";
    return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t,x,y;
    cin>>n;
    for (int i=0;i<n;++i)
    {
        cin>>t;
        testNums.push_back(t);
        while (t--)
        {
            cin>>x>>y;
            v.push_back({x,y});
        }
        testimonies.push_back(v);
        truthTellers.push_back(0);
        v.clear();
    }
    generate();
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import itertools as itr 

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
maxxy = -10**9
for i2 in itr.product((0,1), repeat = n):
    xy = 0
    for j in range(n):
        if i2[j] == 1:
            xy += v[j]
            xy -= c[j]
    if xy > maxxy:
        maxxy = xy
        #print(s)
print(maxxy)

Measured memory_bytes: 42476
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a, b;
	cin >> a >> b;
	if(a < b)
		cout << '<' << endl;
	else if(a > b)
		cout << '>' << endl;
	else
		cout << '=' << endl;
}


Measured memory_bytes: 256
use proconio::input;
// use std::collections::BinaryHeap;
// use std::cmp::Reverse;
use itertools::Itertools;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [i64; n],
    }

    let mut now = a;
    for _ in 0..k {
        if now.iter().all(|x| *x == n as i64) {
            break;
        }

        let mut diff = vec![0i64; n];
        for i in 0..n {
            if now[i] as usize <= i {
                diff[i - now[i] as usize] += 1;
            } else {
                diff[0] += 1;
            }
            if i + (now[i] as usize + 1) < n {
                diff[i + now[i] as usize + 1] -= 1;
            }
        }

        // dbg!(&diff);

        let mut next = vec![0; n];
        let mut nv = 0;
        for i in 0..n {
            nv += diff[i];
            next[i] = nv;
        }

        now = next;
    }

    let ans = now.iter().join(" ");
    println!("{}", ans);
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#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 REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#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 vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
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 << '\n';}
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");}

ll a,b,x;

ll f(ll n)
{
  if(n==-1) return 0;
  else return (n/x)+1;
}

signed main() 
{
  cin>>a>>b>>x;
  ll cnt=f(b)-f(a-1);
  print(cnt);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::list<int> l{};
    int n{};
    std::cin >> n;
    for (auto i = 0; i < n; i++)
    {
        std::string command{};
        int key{};
        std::cin >> command;
        if (command == "insert")
        {
            std::cin >> key;
            l.push_front(key);
        }
        else if (command == "delete")
        {
            std::cin >> key;
            if (l.empty())
                continue;
            auto elm_to_delete = std::find(l.begin(), l.end(), key);
            if (elm_to_delete != l.end())
            {
                l.erase(elm_to_delete);
            }
        }
        else if (command == "deleteFirst")
        {
            l.pop_front();
        }
        else if (command == "deleteLast")
        {
            l.pop_back();
        }
    }
    if (!l.empty())
    {
        auto last_elm{l.end()};
        --last_elm;
        for (auto x = l.begin(); x != l.end(); x++)
        {
            std::cout << *x << ((x != last_elm) ? " " : "");
        }
    }
    std::cout << std::endl;
}



Measured memory_bytes: 34368
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

int KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
		else return true;
	}
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	int n, m;
	cin >> n >> m;

	/*
	 (n+m)C2 の中で総和が偶数になるのは
	 奇+奇=偶 ←
	 奇+偶=奇
	 偶+偶=偶 ←
	 偶+奇=奇
	 より、2つの数がともに偶数であるか奇数であるかである。
	 よって答えになるのは nC2 と mC2 の総和である。
	 Q.E.D.
	 */

	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << rt;

	please AC;
}

Measured memory_bytes: 256
# coding=utf-8

n, q = map(int, input().split())
A = [[] for i in range(n)]

for j in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        A[query[1]].append(query[2])
    elif query[0] == 1:
        print(' '.join(map(str, A[query[1]])))
    elif query[0] == 2:
        A[query[1]].clear()



Measured memory_bytes: 60548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int rd(){
    int a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}
ll rdll(){
    ll a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}

const int N=200005,M=6;
#define ll long long
int n;ll x[N][M],d[N][M],s[N][M];

int main(){
	n=rd();
	for(int i=1;i<=n;i++){
	    int a=rd();
	    if(a)x[i][1]=x[i-1][1]+(a&1);else x[i][1]=x[i-1][1]+2;
	    x[i][0]=x[i-1][0]+a;
	    x[i][2]=x[i-1][2]+((a&1)^1);
	    x[i][3]=x[i][1];
	    x[i][4]=x[i][0];
	}
	//for(int i=1;i<=n;i++){for(int j=0;j<5;j++)printf("%lld ",x[i][j]);printf("\n");}
	//for(int i=0;i<5;i++)s[0][i]=0x3f3f3f3f3f3f3f3fll;
	for(int i=1;i<=n;i++)for(int j=0;j<5;j++){
        d[i][j]=x[i][j];if(j)d[i][j]+=s[i][j-1];
    	s[i][j]=min(s[i-1][j],d[i][j]-x[i][j+1]);
	}
	printf("%lld",d[n][4]);
	return 0;
}

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

int main(){
  
  int N, C; cin >> N >> C;
  vector<vector<int> > stc(N, vector<int> (3, 0) );
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
      cin >> stc[i][j];
    }
  }
  
  sort(stc.begin(), stc.end());
  
  vector<pair<int, int> > tl;
  tl.push_back(make_pair(stc[0][1], stc[0][2]) );
  
  for(int i = 1; i < N; i++){
    int sta = stc[i][0];
    int end = stc[i][1];
    int cha = stc[i][2];
    int sma = 0, dma = 0;
    int t = tl.size();
    bool rep = false;
    for(int j = t - 1; j >= 0; j--){
      int bend = tl[j].first;
      int bcha = tl[j].second;
      if(cha == bcha) bend--;
      
      if(sta > bend){
        rep = true;
        tl[j].first = end;
        tl[j].second = cha;
        break;
      }
    }
    if(!rep){
      tl.push_back(make_pair(end, cha) );
    }
    sort(tl.begin(), tl.end());
  }
  
  cout << tl.size() << endl;
}

Measured memory_bytes: 5760
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct edge{
    ll to,cost;
    edge(ll to,ll cost):to(to),cost(cost) {}
};
vector<vector<edge>> graph;
vector<vector<bool>> used;// 存在する辺はtrue
vector<ll> A;
vector<ll> d1,d2;
ll n,m;
void dij(ll s){
    d1.resize(n);
    for(int i=0;i<n;i++)d1[i]=inf;//訪れていない頂点をinfで初期化
    d1[s]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));//始点を０で置く
    while(!q.empty()){
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1[e.to]>d1[a.se]+e.cost){
                d1[e.to]=d1[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(P(d1[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
}
int main(){
    ll s;
    cin>>n>>m>>s;
    ll node=n;
    n*=2505;
    graph.resize(n);
    for(int i=0;i<m;i++){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;
        for(ll j=0;j<=2500;j++){
            if(j-c>=0){
                graph[a+node*j].emplace_back(b+node*(j-c),d);
                graph[b+node*j].emplace_back(a+node*(j-c),d);
            }
        }
    }
    for(int i=0;i<node;i++){
        ll c,d;
        cin>>c>>d;
        for(ll j=0;j<2500;j++){
            graph[i+node*j].emplace_back(i+node*min(2500ll,j+c),d);
        }
    }
    dij(node*min(2500ll,s));
    for(int i=1;i<node;i++){
        ll ans=inf;
        for(int j=0;j<=2500;j++){
            chmin(ans,d1[i+node*j]);
        }
        cout<<ans<<"\n";
    }
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, T;
struct info {
    ll x, y, h;
};
vector<info> infos;
int main() {
    cin >> N;
    ll tidx;
    REP(i, N) {
        LCIN(x, y, h);
        infos.push_back({x, y, h});
        if(h > 0) tidx = i;
    }
    REP(cx, 101) REP(cy, 101) {
        ll H = infos[tidx].h + abs(cx - infos[tidx].x) + abs(cy - infos[tidx].y);
        bool judge = true;
        REP(i, N) {
            ll x = infos[i].x, y = infos[i].y, h = infos[i].h;
            if(h) {
                if(H - abs(x - cx) - abs(y - cy) != h) {
                    judge = false;
                    break;
                }
            } else {
                if(H - abs(x - cx) - abs(y - cy) > 0) {
                    judge = false;
                    break;
                }
            }
        }
        if(judge) {
            cout << cx << " " << cy << " " << H << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    values, weights, quantity = [], [], []
    for i in range(N):
        v, w, q = map(int, input().split())
        values.append(v)
        weights.append(w)
        quantity.append(q)

    dp = [0 for i in range(W + 1)]
    for i in range(N):
        for r in range(weights[i]):
            j = 0
            beg, end = 0, 0
            deq, deqv = [0] * (W + 1), [0] * (W + 1)
            while j * weights[i] + r <= W:
                # a[j] = dp[i, j * w[i] + r]
                # b[j] = a[j] - j * v[i]
                #      = dp[i, j * w[i] + r] - j * v[i]
                #      = dp[j * w[i] + r] - j * v[i]
                # dp[j * w[i] + r] = b[j] + j * v[i]
                val = dp[j * weights[i] + r] - j * values[i]
                while beg < end and val >= deqv[end - 1]:
                    end -= 1
                # print("DEBUG: i={}, j={}, r={}, end={}".format(i, j, r, end))
                deq[end] = j
                deqv[end] = val
                end += 1
                dp[j * weights[i] + r] = deqv[beg] + j * values[i]

                if deq[beg] == j - quantity[i]:
                    beg += 1

                j += 1

    ans = dp[W]
    print(ans)


main()



Measured memory_bytes: 6980
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf

#define sf1(a)			scanf("%d",&a);
#define sf2(a,b)		scanf("%d%d",&a,&b);

#define ll				long long

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	if(n==m) cout << "Yes\n" ;
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int n = r.i();
        int[] a = r.ii();
        int[] b = new int[n];
        int i = 0;
        int j;
        while((j = n-1-2*i) >= 0){
            b[i] = a[j];
            i++;
        }
        j = 2*i-n;
        while(i < n){
            b[i] = a[j];
            i++;
            j+=2;
        }           
        StringBuilder sb = new StringBuilder();
        for(int x : b)
            sb.append(String.format("%d ", x));
        println(String.valueOf(sb));
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 123072
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, k;
	cin >> n >> k;
	string s;
	do {
		s += '0' + n % k;
		n /= k;
	} while (n);

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


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,max=-1000000,min=1000000,a;
    long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>max) max=a;
        if(a<min) min=a;
        sum=sum+a;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3108
n = int(input())
lst = [None for i in range(n)]
for i in range(n):
    lst[i] = input()

def f(s):
    dic = {}
    for i in s:
        if i in dic:
            dic[i]+=1
        else:
            dic[i]=1
    return dic

dic1 = f(lst[0])
for i in range(1,n):
    dic2 = f(lst[i])
    for i in dic1:
        if i in dic2:
            dic1[i] = min(dic1[i],dic2[i])
        else:
            dic1[i] = 0

ans = ""
for i in dic1:
    ans += i*dic1[i]

ans = sorted(ans)
print("".join(ans))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <set>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    char tmp;
    set<char> st;
    REP(i,n){
        cin>>tmp;
        st.insert(tmp);
    }
    if(st.size()==3){
        cout<<"Three"<<endl;
    }else{
        cout<<"Four"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	string s;
	cin >>s;
	rep(i, s.length()){
		s[i] = 'x';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}

bool solve(int X, int Y,int turn){
  if(X == 1 && Y == 0 || X == 1 && Y == 1 || X == 0 && Y == 0 || X == 0 && Y ==  1){
    return !turn;
  }
  bool t;
  if(turn){
    t = false;
    for(int i=1;X-2*i>0;i++){
      t |= solve(X-2*i,Y+i,!turn);
    }
    for(int i=1;Y-2*i>0;i++){
      t |= solve(X+i,Y-2*i,!turn);
    }
    return t;
  }else{
    t = true;
    for(int i=1;X-2*i>0;i++){
      t &= solve(X-2*i,Y+i,!turn);
    }
    for(int i=1;Y-2*i>0;i++){
      t &= solve(X+i,Y-2*i,!turn);
    }
    return t;
  }
}

int main()
{
  ll X,Y,N,L,R,TMP;
  if(X > Y)
    swap(X,Y);
  cin >> X >> Y;
  if(X <= 1 && Y <= 1){
    cout << "Brown" << endl;
    return 0;
  }
  
  if(abs(X - Y) <= 1){
    cout << "Brown" << endl;
  }else
    cout << "Alice" << endl;
  return 0;
  
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
long long n, k, s;
int main() {
	long long i, j, c, t;
	cin>>n>>k;
	if(k==0) {cout<<n*n; return 0;}
	for(i=k+1, c=1; i<=n; i++, c++) {
		s += n/i * c;
		t = n/i*i+k;
		if(n>=t) s += n-t+1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>


using namespace std;


int main()
{
  int min_a=200000, max_z=-1;
  string s;

  cin >> s;
  for (int i=0; i<s.length(); i++){
    if (s[i] == 'A' && i < min_a) min_a = i;
    if (s[i] == 'Z' && i > max_z) max_z = i;
  }
  cout << max_z - min_a + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,a;
  double z=0;
  char s[10];
  char x[16]={"0123456789abcdef"};
  char b[16][8]={"0000","0001","0010","0011","0100","0101","0110","0111",
		 "1000","1001","1010","1011","1100","1101","1110","1111"};
  scanf("%d",&n);
  //printf("%f\n",1<<-1);
  while(n--){
    char d[40]={0};
    scanf("%s",s);
    for(i=a=0;i<8;i++){
      for(j=0;x[j]-s[i];j++);
      strcat(d,b[j]);
    }
    if(d[0]=='1')printf("-");
    for(i=1;i<32;i++)a=a*2+d[i]-'0';
    z=a/128.0-a/128;
    printf("%d.",a/128);
    if(z==0)printf("0");
    for(;z;z-=a){
      z*=10;
      a=z;
      printf("%d",a);
    }
    printf("\n");    
  }
  return 0;  
}

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

int main(){
	int n;
	int sum = 0;
	cin >> n;
	vector<int> v(n+2);
	v[0] = 0;
	for(int i=1; i<=n; i++){
		cin >> v[i];
		sum += abs(v[i] - v[i-1]);
	}
	v[n+1] = 0;
	sum += abs(v[n]);
	for(int i=1; i<=n; i++){
		if((v[i-1] <= v[i] && v[i] <= v[i+1]) ||
			(v[i-1] >= v[i] && v[i] >= v[i+1])
		) {
			cout << sum << endl;
		} else {
			cout << sum - abs(v[i] - v[i+1]) - abs(v[i] - v[i-1]) + abs(v[i+1] - v[i-1]) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
Scanf.scanf "%d" (fun n ->
    let l = Array.make n 0 in
    let r = Array.make n 0 in
    for i = 0 to n - 1 do
        Scanf.scanf " %d %d" (fun a b -> l.(i) <- a; r.(i) <- b + 1)
    done;

    let rec loop i p q =
        if i = n then p, q else
            let p = if l.(i) > l.(p) then i else p in
            let q = if r.(i) < r.(q) then i else q in
            loop (i + 1) p q
    in
    let p, q = loop 0 0 0 in

    let result1 =
        let rec loop j acc =
            if j = n then acc + max (r.(q) - l.(p)) 0 else
            if j = p || j = q then loop (j + 1) acc else
                loop (j + 1) (max acc (r.(j) - l.(j)))
        in
        loop 0 0
    in
 
    let result2 = (
        let work = Array.init n (fun i -> max (r.(i) - l.(p)) 0, max (r.(q) - l.(i)) 0) in
        Array.sort (fun (a0, b0) (a1, b1) -> compare (-b0, a0) (-b1, a1)) work;
        let s = Array.make (n + 1) 0 in
        let t = Array.make (n + 1) 0 in
        t.(0) <- r.(q) - l.(q);
        s.(n) <- r.(p) - l.(p);
        for i = 1 to n do
            let _, b = work.(i - 1) in
            t.(i) <- min t.(i - 1) b;
        done;
        for i = n - 1 downto 0 do
            let a, _ = work.(i) in
            s.(i) <- min s.(i + 1) a;
        done;

        let rec loop i acc =
            if i = n + 1 then acc else loop (i + 1) (max acc (s.(i) + t.(i)))
        in
        loop 0 0
    )
    in
    Printf.printf "%d\n" @@ max result1 result2
)

Measured memory_bytes: 12888
#include <stdio.h>

int main()
{
    int n, i, count;
    char s[101];
    count = 0;
    scanf("%d", &n);
    for (i=0; i<n; i++)
    {
        scanf("%s", &s[i]);
        if (s[i] == 'Y') {
            count++;
        }
    }
    if (count) {
        printf("Four\n");
    } else {
        printf("Three\n");
    }
    return 0;
}


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

import sys
from collections import deque

def main():
    h, w = map(int, sys.stdin.readline().split())
    s = tuple(list(e for e in line.strip()) for line in sys.stdin.readlines())
    nwhites = sum(si.count('.') for si in s)

    que = deque([(0, 0, 1)])
    d = (1, 0, -1)
    h -= 1
    w -= 1
    while len(que) > 0:
        y, x, nsteps = que.popleft()
        if y < 0 or y > h or x < 0 or x > w or s[y][x] == '#':
            continue
        elif y == h and x == w:
            print(nwhites - nsteps)
            break
        s[y][x] = '#'
        nsteps += 1
        que.extend([(y + dy, x + dx, nsteps) for dy in d for dx in d
                    if (dy != 0 or dx != 0) and dy * dx == 0])
    else:
        print('-1')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bitset>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <vector>
using namespace std;
 
constexpr int MAX_M = 50;
constexpr int MAX_N = 50;
constexpr int mod = 1000000007;
 
enum { A, T, G, C };
 
int na, nt, ng, nc;
int m;

int dp[MAX_N * 4 + 1][MAX_N + 1][MAX_N + 1][MAX_N + 1];
vector<string> rules[MAX_M];
unordered_map<string, int> converter;

int idx[128];

int len = 0; 
vector<bitset<4>> sequence;

inline void calc(int v) {
    for(const auto &s : rules[v]) {
        if(s[0] == '[') {
			if(++len > na + nt + ng + nc) throw "too long";

			bitset<4> tmp;
			for(unsigned i = 1; i < s.size() - 1; ++i) {
				tmp.set(idx[static_cast<int>(s[i])]);
			}
			sequence.emplace_back(tmp);
		}
        else {
			calc(converter[s]);
        }
    }
}

int solve() {
	try {
		calc(0);
	} catch(...) {
		return 0;
	}

	if(len < na + nt + ng + nc) return 0;

	dp[0][0][0][0] = 1;

	for(int i = 0; i < len; ++i) {
		const auto &b = sequence[i];

		for(int a = 0; a <= min(na, i); ++a) {
			for(int t = 0; t <= min(nt, i - a); ++t) {
				for(int g = 0; g <= min(ng, i - (a + t)); ++g) {
					const int c = i - (a + t + g);

					if(b.test(A) && a < na) {
						dp[i + 1][a + 1][t][g] += dp[i][a][t][g];
						if(dp[i + 1][a + 1][t][g] >= mod) dp[i + 1][a + 1][t][g] -= mod;
					}
					if(b.test(T) && t < nt) {
						dp[i + 1][a][t + 1][g] += dp[i][a][t][g];
						if(dp[i + 1][a][t + 1][g] >= mod) dp[i + 1][a][t + 1][g] -= mod;
					}
					if(b.test(G) && g < ng) {
						dp[i + 1][a][t][g + 1] += dp[i][a][t][g];
						if(dp[i + 1][a][t][g + 1] >= mod) dp[i + 1][a][t][g + 1] -= mod;
					}
					if(b.test(C) && c < nc) {
						dp[i + 1][a][t][g] += dp[i][a][t][g];
						if(dp[i + 1][a][t][g] >= mod) dp[i + 1][a][t][g] -= mod;
					}
				}
			}
		}
	}

	return dp[len][na][nt][ng];
}
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

	idx[static_cast<int>('A')] = A;
	idx[static_cast<int>('T')] = T;
	idx[static_cast<int>('G')] = G;
	idx[static_cast<int>('C')] = C;
 
    cin >> na >> nt >> ng >> nc;
	sequence.reserve(na + nt + ng + nc);
 
    cin >> m;
    cin.ignore();
 
    for(int i = 0; i < m; ++i) {
        string line;
        getline(cin, line);
 
        istringstream iss(line);
 
        string symbol;
        iss >> symbol;
 
        symbol = symbol.substr(0, symbol.size() - 1);
        converter[symbol] = i;
 
        for(string in; iss >> in;) {
            rules[i].emplace_back(in);
        }
    }

	cout << solve() << endl;
 
    return EXIT_SUCCESS;
}

Measured memory_bytes: 101656
#include<stdio.h>
int main()
{
    int n,a,b,t,T;
    scanf("%d %d %d",&n,&a,&b);
    T=n*a;
    if(T==b)
        printf("%d\n",T);
    else if(T>b)
        printf("%d\n",b);
    else
        printf("%d\n",T);

    return 0;


}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();
		
		// 計算
		String result = "YES";
		if(s.charAt(0) != t.charAt(2)) result = "NO";
		if(s.charAt(1) != t.charAt(1)) result = "NO";
		if(s.charAt(2) != t.charAt(0)) result = "NO";
		
		// 出力
		System.out.println(result);
	}
}



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

int main(void){
    int c[3][3], d[2][3], e[3][2];
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < 3; ++j){
            d[i][j] = c[i][j] - c[i+1][j]; 
        }
    }
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 2; ++j){
            e[i][j] = c[i][j] - c[i][j+1]; 
        }
    }
    
    if((d[0][0] == d[0][1] && d[0][1] == d[0][2]) && (d[1][0] == d[1][1] && d[1][1] == d[1][2]) && (e[0][0] == e[1][0] && e[1][0] == e[2][0]) && (e[0][1] == e[1][1] && e[1][1] == e[2][1])){
      cout << "Yes" << endl;
      return 0;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
}


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

using namespace std;

vector<vector<long long>> dp;
int main()
{
  int n,w;
  cin>> n>>w;
  dp.resize(n+1,vector<long long>(w+1));
  int x,v;
  for(int i=1;i<=n;i++)
  {
    cin>>x>>v;
    for(int j=0;j<=w;j++)
    {
      dp[i][j]=dp[i-1][j];
      dp[i][j]=max(dp[i][j],(j-x)>=0?(dp[i-1][j-x]+v):0);
    }
  }
  cout<<*max_element(dp[n].begin(),dp[n].end());
  return 0;
}

Measured memory_bytes: 82992
#include<bits/stdc++.h>
using namespace std;
vector<int> graph[53];
bool vis[53];
int n_num=0;
void dfs(int node)
{
    //cout<<node<<endl;
    if(vis[node])return;
    n_num++;
    vis[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {
        dfs(graph[node][i]);
    }
    return;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    //map<int,int>mp;
    vector< pair<int,int> >edges;
    for(int i=0; i<m; i++)
    {
        int u,v;
        cin>>u>>v;
        edges.push_back(make_pair(u,v));

    }
    for(int i=0; i<m; i++)
    {
        for(int i=0; i<=n; i++)
            graph[i].clear();
        for(int j=0; j<m; j++)
        {
            if(i==j)continue;
            int u,v;
            u=edges[j].first;
            v=edges[j].second;
            graph[u].push_back(v);
            graph[v].push_back(u);
            //vis[1]=1;
            //dfs(1);
        }

        memset(vis,0,sizeof(vis));
        n_num=0;
        dfs(1);
        if(n_num!=n)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math

while True:
#    i = 0
    n = int(raw_input())
    if n==0: break
    l = map(float, raw_input().split())
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
    avg=sum(l)/len(l)
    naka=0
    for i in l:
        naka+=(i-avg)**2
    hyo2 = naka/n
    print (hyo2)**0.5

Measured memory_bytes: 4688
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nd = readln.split.to!(int[]);
    auto N = nd[0];
    auto D = nd[1];
    int[][] xs;
    xs.length = N;
    foreach (i; 0..N) {
        xs[i] = readln.split.to!(int[]);
    }

    int c;
    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            int d;
            foreach (k; 0..D) {
                d += (xs[i][k] - xs[j][k]) ^^ 2;
            }
            int dd = sqrt(d.to!double).to!int^^2;
            if (d == dd) ++c;
        }
    }
    writeln(c);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 1100
#define INF ((int)1e9+9)

int main(){
	int temp[MAX], n, q, b, e, m, t;
	vector<int> A;
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>t;
		A.push_back(t);
	}
	
	sort(A.begin(), A.end());
	
	A.erase(unique(A.begin(),A.end()),A.end());
	
	bool flag = false;
	for(int y : A) cout<<(flag++?" ":"")<<y;
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 3536
N=int(input())
SP = [input().split() for _ in [0]*N]
for i,sp in enumerate(SP):
    SP[i][1] = int(sp[1])
    SP[i].append(i+1)
SP.sort(key=lambda x:(x[0],-x[1]))
for _,_,o in SP:
    print(o)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

using P = pair<int, int>;

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

inline bool is_inside(const int& h, const int& w, const int& u, const int& v) {
  return !(u < 0 || h <= u || v < 0 || w <= v);
}

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

  int h, w, d;
  cin >> h >> w >> d;
  vector<vector<int>> a(h, vector<int>(w));
  vector<P> b(h * w);      // 数字 i が置いてある座標
  rep(i, h) rep(j, w) {
    cin >> a[i][j];
    a[i][j]--;
    b[a[i][j]] = {i, j};
  }

  vector<int> costs(h * w, 0);
  for (int i = d; i < h * w; i++) {
    costs[i] = costs[i - d] + abs(b[i-d].first - b[i].first) + abs(b[i-d].second - b[i].second);
  }

  int q;
  cin >> q;
  rep(i, q) {
    int l, r; cin >> l >> r; l--; r--;
    if (l == r) {
      cout << 0 << endl;
    } else {
      cout << costs[r] - costs[l] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4776