akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 20:36 on 2019-10-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s;
    cin>>s;
    string ans;
    rep(i, s.size()) {
        if(s[i] == '0') {
            ans += '0';
        } else if (s[i] == '1') {
            ans += '1';
        } else  {
            if (!ans.empty()) ans.pop_back();
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))
arr = [0] * 3

for item in a:
    if item % 4 == 0:
        arr[2] += 1
    elif item % 2 == 0:
        arr[1] += 1
    else:
        arr[0] += 1

if arr[1] == 0:
    if arr[2] >= arr[0] - 1:
        # 4 5, 3 3,
        print("Yes")
    else:
        print("No")
elif arr[2] >= arr[0]:
    print("Yes")
else:
    print("No")

print()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;
vector<vector<edge>> G;
vector<ll> d;
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d.begin(), d.end(), 1e18);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        rep(i, G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    G.resize(V);
    d.resize(V);

    rep(i, E) {
        int x, y, d;
        cin >> x >> y >> d;

        G[x].push_back({y, d});
    }

    dijkstra(r);

    rep(i, V) {
        if (d[i] == 1e18)
            cout << "INF";
        else
            cout << d[i];
        cout << "\n";
    }

    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    bool ans = true;
    rep(i, s.size()) {
        if (i%2==0 && s[i]=='L') ans = false;
        if (i%2==1 && s[i]=='R') ans = false;
    }
    cout << (ans?YES:NO) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
inline ll lcm(ll a,ll b) {
	return a/gcd(a,b)*b;
}
inline ll qpow(ll a,ll b) {
	ll r=1,t=a;
	while(b) {
		if(b&1)r=(r*t)%mod;
		b>>=1;
		t=(t*t)%mod;
	}
	return r;
}
inline ll inv1(ll b) {
	return qpow(b,mod-2);
}
inline ll exgcd(ll a,ll b,ll &x,ll &y) {
	if(!b) {
		x=1;
		y=0;
		return a;
	}
	ll r=exgcd(b,a%b,y,x);
	y-=(a/b)*x;
	return r;
}
inline ll read() {
	ll x=0,f=1;
	char c=getchar();
	for(; !isdigit(c); c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c); c=getchar()) x=x*10+c-'0';
	return x*f;
}
int a[100005],b[100005];
map<int,int>lisan;

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

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

	for(int i=1; i<=n; i++)
		lisan[b[i]]=i;

	int ans=0;
	for(int i=1; i<=n; i++) {
		int temp=abs(i-lisan[a[i]]);
		if(temp%2)
			ans++;
	}

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

Measured memory_bytes: 5760
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin>>n;
	Array a(n,0);
	REP(i,n) cin>>a[i];

	Array sum(n+1,0);
	REP(i,n) sum[i+1]=sum[i]+a[i];

	Matrix dp(n+1,Array(n+1,INF));//区間[l,r)のスライムを合成するコスト
	REP(i,n) dp[i][i+1]=0;//スライムiの合成コスト

	rep(d,2,n+1){
		//区間が小さい方から合成
		REP(l,n){
			ll r=l+d;
			if(r>n) break;
			rep(mid,l+1,r){
				chmin(dp[l][r],sum[r]-sum[l]+dp[l][mid]+dp[mid][r]);
			}
		}
	}

	cout<<dp[0][n]<<endl;

	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long int m, n, min, max, sum =0;
    min = 1000001;
    max = -1000001;
    cin >> m;
    for (int i = 1; i <= m; i++){
        cin >> n;
        sum = sum + n;
        if (n < min)
            min = n;
        if (n > max)
            max = n;
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}



int main(){
	ll N, K;//計算に使うんでllにします
	cin >> N >> K;

	ll ans = (N / K) * (N / K) * (N / K);
	if(K%2 == 0) ans += ((N+K/2)/K) * ((N+K/2)/K) * ((N+K/2)/K); 
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3604
use proconio::{fastout, input};

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

    let mut step = Vec::new();
    let mut before_tall = 0;
    for i in a.iter() {
        if before_tall <= *i {
            before_tall = *i;
            step.push(0);
            continue
        }
        step.push(before_tall - i)
    }

    // println!("{:?}", step);
    let ans = step.iter().sum::<usize>();
    println!("{}", ans)
}


Measured memory_bytes: 7392
n = int(input())
dic = {}
ans = []

for i in range(n):
    com = input().split()
    c = com[0]

    if com[1] in dic:
        if c[0] == 'f': ans.append("yes")
        else: pass

    else:
        if c[0] == 'i': dic[ com[1] ] = i
        else: ans.append("no")


for i in ans: print(i)



Measured memory_bytes: 45816
//#include "stdc++.h"
#include <bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =1000000007 ;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define pi 3.141592653589793238462
#define int  long long
vi adj[100001];bool visited[100001];
void dfs(int u)
{
    visited[u]=1;int v;
    for(int i=0;i<adj[u].size();i++)
    {
        v=adj[u][i];
        if(!visited[v])
            dfs(v);
    }
}
int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    int x,y,z,cnt=0,ans=n;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            dfs(i);
            cnt++;
        }
    }
    cout<<min(cnt,ans)<<endl;
    return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];

  int ans = -1001001001; 
  for(int tmp = 0; tmp < (1 << 20); tmp++) {
    bitset<20> s(tmp);
    int x = 0;
    int y = 0;
    rep(i, n) {
      if(s.test(i)) {
        x += v[i];
        y += c[i];
      }
    }
    ans = max(ans, x - y);  
  }

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

Measured memory_bytes: 256
from math import ceil
N = int(input())
A = [int(a) for a in input().split()]

if A[-1] != 2: print(-1)
else:
    PossibleMin, PossibleMax = A[-1], A[-1] + 1
    for i in reversed(range(N-1)):
        PossibleMin = ceil(PossibleMin/A[i]) * A[i]
        PossibleMax = (PossibleMax//A[i]) * A[i] + A[i] - 1
    if PossibleMax >= PossibleMin: print(PossibleMin, PossibleMax)
    else: print(-1)


Measured memory_bytes: 14252
N = input()
A = map(int, raw_input().split())

s = 0
for a in A:
    s = (a - (s / 2)) * 2

s /= 2
result = []
for a in A:
    result.append(s)
    s = (a - (s / 2)) * 2

print " ".join(map(str, result))


Measured memory_bytes: 16104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	bool a=0;
	string b;
	cin>>b;
	for(int i=0;i<b.length();i++)
	{
		if(b[i]=='C')
			a=1;
		if(b[i]=='F'&&a)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  sort(all(A), greater<ll>());
  vector<ll> p, m;
  p.pb(A[0]);
  repp(i, 1, N - 2) {
    if (A[i] >= 0)
      p.pb(A[i]);
    else
      m.pb(A[i]);
  }
  m.pb(A[N - 1]);

  int P = len(p), M = len(m);
  ll ans = 0;
  rep(i, P) {
    ans += p[i];
  }
  rep(i, M) {
    ans -= m[i];
  }

  cout << ans << "\n";

  ll temp = m[M - 1];
  rep(i, P - 1) {
    cout << temp << ' ' << p[i] << "\n";
    temp -= p[i];
  }
  cout << p[P - 1] << ' ' << temp << "\n";
  temp = p[P - 1] - temp;
  rep(i, M - 1) {
    cout << temp << ' ' << m[i] << "\n";
    temp -= m[i];
  }
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];
    reverse(a.begin(), a.end());
    vector<int> ans(n);

    int count1 = 0;
    int count2 = 1;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            ans[count1] = a[i];
            count1++;
        } else {
            ans[n-count2] = a[i];
            count2++;
        } 
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i];
        if (i < n-1) {
            cout << " ";
        } 
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<cmath>

int main(){
  int H, W, Q;
  long D;
  std::cin >> H >> W >> D;
  std::vector<std::vector<long>> XYtoA(H, std::vector<long>(W));
  std::map<long, std::pair<int,int>> AtoXY;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      std::cin >> XYtoA.at(i).at(j);
      AtoXY[XYtoA.at(i).at(j)] = std::make_pair(i, j);
    }
  }
  std::cin >> Q;
  std::vector<long> MPtoEnd(H*W+1,0);
  for(long i = H*W; i > 0; i--){
    if(i+D > H*W) continue;
    MPtoEnd.at(i) = MPtoEnd.at(i+D) + 
                    std::abs(AtoXY[i].first - AtoXY[i+D].first) + 
                    std::abs(AtoXY[i].second - AtoXY[i+D].second);
  }
  for(int i = 0; i < Q; i++){
    long MP = 0;
    long tempL, tempR;
    std::cin >> tempL >> tempR;
    MP = MPtoEnd.at(tempL) - MPtoEnd.at(tempR);
    std::cout << MP << std::endl; 
  }
}

Measured memory_bytes: 8192
//In the name of 'allah'
#include<bits/stdc++.h>
using namespace std;
int main()
{
     string s;
     cin>>s;
     for(int i=0;i<s.size();i++)
     {
         if(s[i]==',')cout<<" ";
         else cout<<s[i];
     }
     return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(auto it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,i;
    string s;
    map<string,ll> mp;

    cin>>n;

    rep1(i,n)
    {
         cin>>s;
         mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;

     return 0;
}


Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

map<int, int> cnt;
int input[200000 + 5];

int N;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> N;
	
	for (int i = 0; i < N; ++i)
	{
		cin >> input[i];
		cnt[input[i]]++;
	}

	ll ans = 0LL;

	for (auto it = cnt.begin(); it != cnt.end(); ++it) ans += 1LL * (it->second) * (it->second - 1) / 2;
	for (int i = 0; i < N; ++i)
	{
		ll cur = 1LL * cnt[input[i]] * (cnt[input[i]] - 1) / 2;
		ll next = 1LL * (cnt[input[i]] - 1) * (cnt[input[i]] - 2) / 2;

		cout << ans - (cur - next) << "\n";
	}

	return 0;
}

Measured memory_bytes: 8320
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int H, W, D;
    cin >> H >> W >> D;
    ll m = 0;
    map<ll, pll> ma;
    rep(i, H) {
        rep(j, W) {
            ll a;
            cin >> a;
            ma[a] = {i, j};
            m = max(m, a);
        }
    }

    vector<ll> table(m + 1, 0);
    for (int i = 0; i < m + 1; i++) {
        if (table[i] != 0)
            continue;
        for (int j = i + D; j < m + 1; j += D) {
            pll a = ma[j], b = ma[j - D];
            table[j] = table[j - D] + abs(a.first - b.first) +
                       abs(a.second - b.second);
        }
    }

    int Q;
    cin >> Q;
    vector<ll> L(Q), R(Q);
    rep(i, Q) {
        cin >> L[i] >> R[i];
        cout << table[R[i]] - table[L[i]] << endl;
    }
}

Measured memory_bytes: 11124
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define met(a,b) memset(a,b,sizeof(a))

int solve(int n)
{
    int ans=0;
    while(n){
        ans+=n%10;
        n/=10;
    }
    return ans;
}

int main()
{
    int n,Min=inf;
    scanf("%d",&n);
    for(int i=1;i<=n/2;i++){
        Min=min(Min,solve(i)+solve(n-i));
    }
    printf("%d\n",Min);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<LL> p(n), m(n);
    rep(i, n) {
        LL x, y;
        cin >> x >> y;
        p[i] = x + y;
        m[i] = x - y;
    }
    sort(p.begin(), p.end());
    sort(m.begin(), m.end());

    LL ans = 0;
    ans = max(ans, p.back()-p.front());
    ans = max(ans, m.back()-m.front());

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6236
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int64 ar[3002];
int64 dp[3002][3002][2];
int main(){
    FAST
    //Do awesome things here
    int n;
    cin >> n;
    rp(i, n){
        cin >> ar[i];
    }
    fre(j, 1, n){
        fr(i, 0, n){
            if(i + j - 1 >= n)  break;
            int l = i, r = i + j - 1;
            if(l == r){
                dp[l][r][0] = ar[l];
                dp[l][r][1] = -1 * ar[l];
            }
            else{
                dp[l][r][0] = max(ar[l] + dp[l + 1][r][1], ar[r] + dp[l][r - 1][1]);
                dp[l][r][1] = min(-1 * ar[l] + dp[l + 1][r][0], -1 * ar[r] + dp[l][r - 1][0]);
            }
        }
    }
    int64 ans = dp[0][n - 1][0];
    cout << ans << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

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

int main() {
	int k,a,b;
	bool ans = false;
	cin >> k >> a >> b;
	for (int i=a;i<=b;i++) if (i%k==0) ans = true;
	if (ans) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	if (t.size()-1==s.size())
	{
		if (t.substr(0,s.size())==s)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	else
	cout<<"No"<<endl;
	
	
}
		


 







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


void solve(long long N, std::vector<long long> A){
  map<long long, bool> tab;
  for(long long i = 0; i < N; i++){
    tab[A[i]] = !tab[A[i]];
  }

  cout << count_if(tab.begin(), tab.end(), [](auto& a){ return a.second; }) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

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


    if (c > b) {
        swap(b, c);
    }
    if (b > a) {
        swap(a, b);
    }
    if (c > b) {
        swap(b, c);
    }

    if (a == b && b == c) {
        cout << 0 << endl;
        return 0;
    }

    ll diff_a_b = a - b;
    if (diff_a_b % 2 == 1) {
        c++;
        b--;
        diff_a_b ++;
    }

    ll count_b = diff_a_b / 2;

    ll diff_a_c = a - c;
    ll count_c = (diff_a_c + 1) / 2;

    ll count_a_c = 0;
    if (diff_a_c % 2 == 1) {
        count_a_c = 1;
    }

    ll ans = count_b + count_c + count_a_c;
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n=int(input())

t1,x1,y1=0,0,0
flg=True
for i in range(n):
    t2,x2,y2=map(int,input().split())
    l=abs(x2-x1)+abs(y2-y1)
    #print(l,t2-t1)
    if l<=(t2-t1) and (t2-t1-l)%2==0:
        t1,x1,y1=t2,x2,y2
    else:
        flg=False
        break
print("Yes" if flg else "No")


Measured memory_bytes: 41836
n = gets.to_i
p = gets.chomp.split.map(&:to_i)
q = gets.chomp.split.map(&:to_i)
pi = nil
qi = nil
cnt = 1
(1..n).to_a.permutation do |s|
  if s == p
    pi = cnt
  end
  if s == q
    qi = cnt
  end
  break if pi != nil && qi != nil
  cnt += 1
end
puts (qi - pi).abs

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define For(start,end) for(int i = (int)start;i<(int)end;i++)
using Int = long long int;
int main(){
    int N;
    cin >> N;
    int rcounter=0;
    vector<char>alter(N);
    for(int i=0;i<N;i++){
        char c;
        cin>>c;
        alter.at(i)=c;
        if(c=='R')rcounter++;
    }

    if(rcounter==0||rcounter==N) cout <<0<< endl;//全部白あるいは黒
    else
    {
        int answer=0;
        for(int i=rcounter;i<N;i++)
        {
            if(alter.at(i)=='R')answer++;
        }
        cout<<answer<<endl;
    }
    
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

llong gcd(int x, int y) {
   if (x < y)
      swap(x, y);
   if (y == 0)
      return x;
   return gcd(y, x % y);
}
llong lcm(int x, int y) {
   return x / gcd(x, y) * y;
}

llong f(llong x, int s, int t) {
   llong res = x;
   res -= x / s;
   res -= x / t;
   res += x / lcm(s, t);
   return res;
}
int main() {
   llong a, b;
   int c, d;
   cin >> a >> b >> c >> d;
   llong ans = f(b, c, d) - f(a - 1, c, d);
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<ll> vec(n);
    cin>>vec;
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=vec[i];
    }
    ll now=0;
    ll ans=LINF;
    for(int i=0;i<n-1;i++){
        now+=vec[i];
        chmin(ans,abs(now-(sum-now)));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	double a,n,i,ans=0;
	string s;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>s;
		if(s=="JPY")ans+=a;
		else{
			ans+=a*380000;
		}
	}
	printf("%.6f\n",ans);
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    string s;
    cin >> s;
    string ss = "";
    ss += s[0];
    int ans = 1;
    string next = "";
    for (int i = 1; i < s.size(); i++) {
        next += s[i];
        if (next != ss) {
            ans++;
            ss = next;
            next = "";
        }
    }
    if (next != "" && next != ss) ans++;
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
vector<int>a;

int main()
{
  int n;
  cin>>n;
  a.resize(n-1);
  for(int i=0;i<n-1;i++)
  {
    cin>>a[i];
  }
  long long sum=a[n-2]+a[0];
  for(int i=n-2;i>=1;i--)
  {
		sum+=min(a[i],a[i-1]); 
  }
  cout<<sum<<endl;
  return 0;
}
      

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll rec(ll n, ll x, ll num){
    if(n == 0) return 1;
    if(x == 1) return 0;
    if(x == num) return 2*rec(n-1, num/2-1, num/2-1)+1;

    ll res = 0;
    if(x < num/2+1){
        res = rec(n-1, x-1, num/2-1);
    }else if(x == num/2+1){
        res = rec(n-1, num/2-1, num/2-1)+1;
    }else{
        res = rec(n-1, num/2-1, num/2-1) + 1 + rec(n-1, x-(num/2+1), num/2-1);
    }
    return res;
}

void solve() {
    ll N, X; cin >> N >> X;
    ll cnt = 1;
    rep(i, N){
        cnt = 2*cnt+3;
    }
    cout << rec(N, X, cnt) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7720
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

cnt = 1
def solve():
    global cnt
    def dfs(x):
        global cnt
        f[x] = cnt
        for y in v[x]:
            if not d[y]:
                d[y] = cnt
                cnt += 1
                dfs(y)
        f[x] = cnt
        cnt += 1

    n = I()
    v = []
    for i in range(n):
        e = LI()
        u = e[2:]
        for i in range(len(u)):
            u[i] -= 1
        v.append(u)
    d = [0]*n
    f = [0]*n
    for i in range(n):
        if not d[i]:
            d[i] = cnt
            cnt += 1
            dfs(i)
    for i in range(n):
        print(i+1,d[i],f[i])
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 6116
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    while(1){
        int n, m, c, s, g; cin>>n>>m>>c>>s>>g;
        if(n == 0) return 0;
        s--, g--;
        int dist[c][n][n];
        fill(dist[0][0], dist[c][0], 1e9);
        for(int i=0; i<c; i++){
            for(int j=0; j<n; j++){
                dist[i][j][j] = 0;
            }
        }

        for(int i=0; i<m; i++){
            int x, y, d, com; cin>>x>>y>>d>>com;
            x--, y--, com--;
            dist[com][x][y] = dist[com][y][x] = min(dist[com][x][y], d);
        }

        for(int i=0; i<c; i++){
            for(int j=0; j<n; j++){
                for(int k=0; k<n; k++){
                    for(int l=0; l<n; l++){
                        dist[i][k][l] = min(dist[i][k][l], dist[i][k][j] + dist[i][j][l]);
                    }
                }
            }
        }

        vector<int> p(c);
        for(int i=0; i<c; i++) cin>>p[i];

        vector<vector<int>> fare(c, vector<int>(20010, 0));
        for(int i=0; i<c; i++){
            vector<int> q(p[i]-1);
            vector<int> r(p[i]);
            for(int j=0; j<p[i]-1; j++) cin>>q[j];
            for(int j=0; j<p[i]; j++) cin>>r[j];

            int id = 0;
            for(int j=1; j<=20005; j++){
                if(id < p[i] - 1 && q[id] < j) id++;
                fare[i][j] = fare[i][j-1] + r[id];
            }
        }

        vector<vector<int>> cost(n, vector<int>(n, 1e9));
        for(int i=0; i<c; i++){
            for(int j=0; j<n; j++){
                for(int k=0; k<n; k++){
                    if(dist[i][j][k] == 1e9) continue;

                    cost[j][k] = min(cost[j][k], fare[i][dist[i][j][k]]);
                }
            }
        }

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                for(int k=0; k<n; k++){
                    cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
                }
            }
        }

        cout << (cost[s][g] == 1e9 ? -1 : cost[s][g]) << endl;
    }
}


Measured memory_bytes: 5300
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

int main(){
    long long n; cin >> n;
    long long m=numeric_limits<long long>::max();
    for(int i=0; i<5; ++i){
        long long a;
        cin >> a;
        m=min(m, a);
    }
    cout << (5+n/m+(n % m == 0 ? -1 : 0)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int D;
  cin >> D;
  const int T = 26;  // type no kazu
  vector<ll> c(T);   // penalty
  REP(i, T) { cin >> c[i]; }
  vector<vector<ll>> s(D, vector<ll>(T));
  REP(i, D) REP(j, T) { cin >> s[i][j]; }
  vector<int> t(D);
  REP(i, D) {
    cin >> t[i];
    t[i]--;
  }

  vector<ll> v(D + 1, 0);
  vector<int> last(T, 0);

  FOR(i, 1, D + 1) {
    last[t[i - 1]] = i;
    // score gain
    v[i] = v[i - 1] + s[i - 1][t[i - 1]];
    // penalty
    REP(j, T) { v[i] -= c[j] * (i - last[j]); }
  }

  // score output
  REP(i, D) { cout << v[i + 1] << endl; }
}

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

int main(){
  int n, a;
   cin >> n;
  for(int i = 0; i < n + 1; i++){
    a = i * 1.08;
    if(a == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m, s, t;
int u[100100], v[100100];
ll a[100100], b[100100];

const int MAX = 100100;
struct edge {
    int to;
    ll cost;
};

vector<edge> G[2][MAX];
ll d[2][MAX];

void dijkstra(int s, int k) {
    priority_queue<P, vector<P>, greater<P> > que;
    for (int i = 0; i < MAX; i++) d[k][i] = 1e18;
    d[k][s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[k][v] < p.first) continue;
        for (int i = 0; i < G[k][v].size(); i++) {
            edge e = G[k][v][i];
            if (d[k][e.to] > d[k][v] + e.cost) {
                d[k][e.to] = d[k][v] + e.cost;
                que.push(P(d[k][e.to], e.to));
            }
        }
    }
}

void solve() {
    for (int i = 0; i < m; i++) {
        G[0][u[i]].push_back(edge{v[i], a[i]});
        G[0][v[i]].push_back(edge{u[i], a[i]});
        G[1][u[i]].push_back(edge{v[i], b[i]});
        G[1][v[i]].push_back(edge{u[i], b[i]});
    }

    dijkstra(s, 0);
    dijkstra(t, 1);
    ll res[n];
    ll cost = 1e18;
    for (int i = n-1; i >= 0; i--) {
        if (cost > d[0][i] + d[1][i]) {
            cost = d[0][i] + d[1][i];
        }
        res[i] = (ll)1e15 - cost;
    }

    for (int i = 0; i < n; i++) {
        cout << res[i] << endl;
    }
}

void input() {
    cin >> n >> m >> s >> t;
    s--; t--;
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--; v[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 22032
#include <bits/stdc++.h>
#define MAX 500005
#define ll long long
using namespace std;

struct node{
    int p1, p2;
    ll s;
    friend bool operator <(node a, node b){
        return a.s > b.s;
    }
};

int n;
ll a[MAX], k;
vector<ll> b, c;

bool check(ll x){
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end());
    ll res = 0;
    for(int i = 0; i < b.size(); i++){
        if(b[i] == 0){
            res += (x>=0)*c.size();
            continue;
        }
        int l = 0, r = c.size()-1, mid, p = -1;
        while(l <= r){
            mid = (l+r)>>1;
            if(b[i]*c[mid] <= x) p = mid, l = mid+1;
            else r = mid-1;
        }
        res += p+1;
    }
    sort(b.begin(), b.end());
    sort(c.begin(), c.end(), greater<ll>());
    for(int i = 0; i < b.size(); i++){
        if(b[i] == 0){
            res += (x>=0)*(b.size()-i-1);
            continue;
        }
        int l = i+1, r = b.size()-1, mid, p = -1;
        while(l <= r){
            mid = (l+r)>>1;
            if(b[i]*b[mid] <= x) p = mid, l = mid+1;
            else r = mid-1;
        }
        res += max(0, p-i);
    }
    for(int i = 0; i < c.size(); i++){
        if(c[i] == 0){
            res += (x>=0)*(c.size()-i-1);
            continue;
        }
        int l = i+1, r = c.size()-1, mid, p = -1;
        while(l <= r){
            mid = (l+r)>>1;
            if(c[i]*c[mid] <= x) p = mid, l = mid+1;
            else r = mid-1;
        }
        res += max(0, p-i);
    }
    return res >= k;
}

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        if(a[i] >= 0) b.push_back(a[i]);
        else c.push_back(a[i]);
    }
    ll l = (ll)-1e18, r = (ll)1e18, mid, ans;
//    cout << check(-12) << endl;
    while(l <= r){
        mid = (l+r)>>1;
        if(check(mid)) ans = mid, r = mid-1;
        else l = mid+1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3700