akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, pair<int, int>> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int h, w;
    string s[51];

    cin >> h >> w;
    REP(i, h)
    cin >> s[i];

    int dis[52][52];

    REP(i, h)
    REP(j, w)
    dis[i][j] = 1e9;

    priority_queue<P, vector<P>, greater<P>> q;
    q.push({0, {0, 0}});

    while (q.size())
    {
        auto p = q.top();
        q.pop();

        if (dis[p.second.first][p.second.second] <= p.first)
            continue;

        dis[p.second.first][p.second.second] = p.first;

        REP(i, 4)
        {
            int ni = p.second.first + di[i];
            int nj = p.second.second + dj[i];

            if (ni < 0 || h <= ni || nj < 0 || w <= nj)
                continue;

            if (s[ni][nj] == '#')
                continue;

            if (dis[ni][nj] <= p.first + 1)
                continue;

            q.push({p.first + 1, {ni, nj}});
        }
    }

    if (dis[h - 1][w - 1] == 1e9)
    {
        cout << -1 << endl;
        return 0;
    }

    int bnum = 0;
    REP(i, h)
    REP(j, w)
    bnum += s[i][j] == '#';

    int res = h * w - (dis[h - 1][w - 1] + 1);
    res -= bnum;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
multiset <pll> m;
ll a[100009];
ll p[100009];
int main()
{
	FAST
	#ifdef ayk_16
    freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	ll n,k;
	string s;
	cin>>n>>k;
	cin>>s;
	a[n]=0;
	a[0]=-1;
	m.insert({0,n});
	for(ll i=n-1;i>=0;i--)
	{
		if(i+k<n)
		{
			if(s[i+k+1]=='0')
			    m.erase(m.find({a[i+k+1],i+k+1}));
		}
		if(s[i]=='1')
		    continue;
		if(m.empty())
			break;
		pll q=*(m.begin());
		a[i]=q.ff+1;
		p[i]=q.ss-i;
		m.insert({a[i],i});
	}
	if(a[0]!=-1)
	{
		ll st=0;
		while(st<n)
		{
			cout<<p[st]<<' ';
			st+=p[st];
		}
	}
	else
		cout<<-1;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
int main() {
	stack<int>A;
	int N; cin >> N;
	vector<int>B(N);
	vector<bool>C(10000, false);
	for (int i = 0; i < N; i++) {
		cin >> B.at(i);
		if (B.at(i) > 0) {
			if (C.at(B.at(i) - 1)) {
				cout << i + 1 << endl;
				return 0;
			}
			else {
				A.push(B.at(i));
				C.at(B.at(i) - 1) = true;
			}
		}
		else {
			if (A.empty()) {
				cout << i + 1 << endl;
				return 0;
			}
			else if (abs(B.at(i)) != A.top()) {
			    cout << i + 1 << endl;
			    return 0;
			}
			else {
				A.pop();
				C.at(abs(B.at(i)) - 1) = false;
			}
		}
	}
	cout << "OK" << endl;
}


Measured memory_bytes: 3128
use proconio::input;

use std::cmp::{max, min};

fn main() {

    input! {
        n: usize,
        aa: [i64; n],
    };


    let mut v = Vec::new();
    for (i, a) in aa.iter().enumerate() {
        v.push((a, i));
    }

    v.sort();
    v.reverse();

    let mut dp = vec![vec![0; n+1]; n+1];

/*
    i = 2

    (x=0, y=2) , (x=1, y=1), (x=2, y=0)
*/

    for i in 0..n {
        let (a,p) = v[i];
        let p = p as i64;
        for x in 0..=i {
            let y = i-x;
            let i = i as i64;
            dp[x+1][y] = max(dp[x+1][y], dp[x][y] + (p - x as i64).abs() * a);
            dp[x][y+1] = max(dp[x][y+1], dp[x][y] + (p - (n as i64 - 1 - y as i64)).abs() * a);
        }
    }

    let mut ans = 0;
    for v in dp {
        for v in v {
            if ans < v {
                ans = v;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 33428
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
// const ll INF = 1LL << 30;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

int main() {
    ll n, k; cin >> n >> k;
    Vl p(n);
    rep(i, 0, n) cin >> p[i];

    sort(ALL(p));
    ll ans = 0;
    rep(i, 0, k) ans += p[i];
    co(ans);

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  map<ll, ll> mp;
  mp[0]++;
  ll ans = 0, now = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    now = (now + a) % m;
    ans += mp[now];
    mp[now]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	char c;
	cin>>c;
	if(c>='A'&&c<='Z')
		cout<<"A\n";
	else if(c>='a'&&c<='z')
		cout<<"a\n";
	return 0;
}




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

int main (){
    int a,b,add,sub,mul,maior;
    cin>>a;
    cin>>b;
    add = a + b;
    sub = a - b;
    mul = a * b;
    if(add<sub){
        maior = sub;
    }else{
        maior = add;
    }
    if(maior<mul){
        cout<<mul<<endl;
    }else{
        cout<<maior<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	ll N;
	// vector<ull> bases = {1000000007, 9973};
	vector<ull> bases = {3, 5};
	cin >> N;
	vector<string> table(N);
	rep(i,0,N) {
		cin >> table[i];
		rep(j,0,N) {
			table[i][j] -= 'a';
		}
	}
	auto hash_pre = make_vec_nd((ull)0, 2, N, N);
	auto hash = hash_pre;
	rep(i,0,2) {
		rep(y,0,N) {
			ull pow = 1;
			ull base = bases[i];
			rep(x,0,N) {
				hash_pre[i][0][y] += pow * (ull)table[y][N-1-x];
				if (x < N-1) {
					pow *= base;
				}
			}
			rep(x,1,N) {
				hash_pre[i][x][y] 
					= base * (hash_pre[i][x-1][y] - pow * (ull)table[y][x-1])
					+ (ull)table[y][(x+N-1)%N];
			}
		}
		rep(x,0,N) {
			ull pow = 1;
			ull base = bases[(i+1)%2];
			rep(y,0,N) {
				hash[i][x][0] += pow * hash_pre[i][x][N-1-y];
				if (y < N-1) {
					pow *= base;
				}
			}
			rep(y,1,N) {
				hash[i][x][y]
					= base * (hash[i][x][y-1] - pow * hash_pre[i][x][y-1])
					+ hash_pre[i][x][(y+N-1)%N];
			}
		}
	}
	ll ans = 0;
	rep(x,0,N) {
		rep(y,0,N) {
			if (hash[0][x][y] == hash[1][x][y]) {
				ans++;
			}
			// cout << "(" << x << "," << y << "): pre " << hash_pre[0][x][y] << " " << hash_pre[1][x][y] << endl;
			// cout << "(" << x << "," << y << "): " << hash[0][x][y] << " " << hash[1][x][y] << endl;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<ll> A(X), B(Y), C(Z);
	rep(i, X) cin >> A[i];
	rep(i, Y) cin >> B[i];
	rep(i, Z) cin >> C[i];
	
	vector<ll> tmp;
	rep(i, X) rep(j, Y) {
		tmp.push_back(A[i] + B[j]);
	}

	sort(tmp.begin(), tmp.end(), greater<ll>());
	vector<ll> vec;
	rep(i, min(X* Y, K)) {
		vec.push_back(tmp[i]);
	}

	priority_queue<ll> pq;
	rep(i, vec.size()) rep(j, Z) {
		pq.push(vec[i] + C[j]);
	}

	rep(i, K) {
		cout << pq.top() << "\n";
		pq.pop();
	}

	return 0;
}

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

int main(){
  int N; cin >> N;
  vi L(N);
  rep(i,N) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  rep(i,N-2){
    for (int j=i+1; j<N-1; j++){
      int ab = L[i] + L[j];
      int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
      int l = j + 1;
      ans += r - l;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
using namespace std;

int main()
{
    int tmp;
    priority_queue<int> q;
    string op;
    for(int i=0; i<2000000; ++i){
        cin >> op;
        if(op == "end"){
            break;
        }
        else if(op == "insert"){
            cin >> tmp;
            q.push(tmp);
        }
        else if(op == "extract"){
            cout << q.top() << endl;
            q.pop();
        }
    }
}


Measured memory_bytes: 6984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s;
    int k;
    vector<string> sub;
    cin >> s >> k;
    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 1; j <= k; j++)
        {
            string tmp = s.substr(i, j);
            sub.push_back(tmp);
        }
    }
    sort(sub.begin(), sub.end());
    unique(sub.begin(), sub.end());
    cout << sub[k - 1] << endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    int mx=0;
    REP(i,n){
        if(s.at(i) == 'I') ans++;
        else ans--;
        mx=max(ans,mx);
    }
    cout<<mx<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

const int MOD = 1000000007;

int main() {

int K; cin >> K ;
string S; cin>>S;

int N=S.size();

if(N<=K) cout << S << endl;

else{
  string T=S.substr(0,K);
  rep(i,3) T.push_back('.');
  cout << T << endl;
}

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;
 
int main() {
   int n; scanf("%d", &n);
   vector<int> a(n);
   for (auto& i : a)
      scanf("%d", &i);
   vector<int> b(n + 1);
   int ans = 0;
   for (int i = 0; i < n; ++i) {
      int b; scanf("%d", &b);
      ans += b;
   }
   vector<int> c(n);
   for (int i = 1; i < n; ++i)
      scanf("%d", &c[i]);
   for (int i = 0; i < n - 1; ++i) {
      if (a[i + 1] == a[i] + 1) {
         ans += c[a[i]];
      }
   }
   printf("%d", ans);
   return 0;
}

Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())

d = deque(S)
flg = True #Trueが前から,
for i in range(Q):
    t, *a = input().split()
    if t == "1":
        flg = not flg
    else:
        if (flg and a[0]=="1") or ((not flg) and a[0]=="2"):
            d.appendleft(a[1])
        else:
            d.append(a[1])
d = list(d)
if flg:
    print(''.join(d))
else:
    print(''.join(d[::-1]))


Measured memory_bytes: 13960
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
#include <atcoder/all>
using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
template <class T>
inline void dump(T &v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U> &v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */

int main() {
    int n, m;
    cin >> n >> m;
    scc_graph scc(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    vvi res = scc.scc();
    cout<<res.size()<<endl;
    rep(i,res.size()){
        cout<<res[i].size()<<" ";
        dump(res[i]);
    }
}


Measured memory_bytes: 40096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  cout<<setprecision(6);
  cout<<fixed;
	double pi=3.141592653589793238;
	double r; cin>>r;
	double val=(double)pi*2*r;
	cout<<val;
	
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int count = 0;
    while (b <= a)
    {
        b *= 2;
        count += 1;
    }
    while (c <= b)
    {
        c *= 2;
        count += 1;
    }
    cout << (count <= k ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3636
c = [list(map(int, input().split())) for _ in range(3)]

diff0 = [x - y for x, y in zip(c[0], c[1])]
diff1 = [x - y for x, y in zip(c[0], c[2])]

if diff0[0] == diff0[1] and diff0[0] == diff0[2] and diff1[0] == diff1[1] and diff1[0] == diff1[2]:
    print('Yes')
else:
    print('No')

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


int main() {
    int n;
    cin>>n;
    int card[n];
    for(int i=0;i<n;i++)cin>>card[i];
    sort(card,card+n,greater<int>());
    int a=0,b=0;
    for (int j = 0; j < n / 2; ++j) {
        a+=card[2*j];
        b+=card[2*j+1];
    }
    if(n%2==1)a+=card[n-1];
    cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>

typedef long long ll;

using namespace std;

struct team_greater
{
	bool operator()(const pair<int, string>& a, const pair<int, string>& b)
	{
		return a.first > b.first;
	}
};
int main()
{
	bool line_break = false;
	int n;
	while (cin >> n && n)
	{
		if (line_break)
			cout << endl;
		else
			line_break = true;

		pair<int, string> team[16];
		for (int i = 0; i < n; ++i)
		{
			string t;
			int a, b, c;
			cin >> t >> a >> b >> c;
			team[i] = make_pair(a*3 + c, t);
		}
		stable_sort(team, team + n, team_greater());
		for (int i = 0; i < n; ++i)
			cout << team[i].second << ',' << team[i].first << endl;
	}

	return 0;
}

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

using namespace std;


int sub[100000];
int cnt[100000][26][26];

struct Trie
{
  Trie *nxt[26];
  int subtree;
  bool end;

  Trie()
  {
    end = false;
    subtree = 0;
    fill_n(nxt, 26, nullptr);
  }
};

int get(Trie *t)
{
  if(t == nullptr) return (0);
  return (t->subtree);
}


void add(string &s, Trie *root)
{
  for(char c : s) {
    c -= 'a';
    if(root->nxt[c] == nullptr) root->nxt[c] = new Trie();
    root = root->nxt[c];
    root->subtree++;
  }
  root->end = true;
}

void update(string &s, Trie *root, int idx)
{
  for(char c : s) {
    c -= 'a';
    sub[idx] += root->end;
    for(int i = 0; i < 26; i++) {
      cnt[idx][i][c] += get(root->nxt[i]);
    }
    root = root->nxt[c];
  }
}

int main()
{
  int N, Q;
  Trie *root = new Trie();
  string s[100000];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> s[i];
    add(s[i], root);
  }
  for(int i = 0; i < N; i++) {
    update(s[i], root, i);
  }
  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int l;
    string t;
    cin >> l >> t;
    for(char &c : t) c -= 'a';
    int ret = sub[--l];
    for(int j = 0; j < 26; j++) {
      for(int k = j + 1; k < 26; k++) {
        ret += cnt[l][t[j]][t[k]];
      }
    }
    cout << ret + 1 << endl;
  }
}


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

const auto W = 'W';
const auto B = 'B';

using Graph = vector<vector<int>>;

int solve(auto& N, auto& G, auto& C) {
  if(all_of(begin(C), end(C), [](auto i) {return i == B;})) return 0;
  if(count(begin(C), end(C), W) == 1) return 1;

  vector<int> degree(N);
  for(auto u=0; u<N; ++u) for(auto v: G[u]) ++degree[u];

  vector<bool> active(N, true);
  queue<int> q;
  for(auto v=0; v<N; ++v) if(degree[v] == 1) q.emplace(v);
  while(!q.empty()) {
    auto u = q.front();
    q.pop();
    if(C[u] != B) continue;
    active[u] = false;
    --degree[u];
    for(auto v: G[u]) if(active[v]) if(--degree[v] == 1) q.emplace(v);
  }

  auto root = 0;
  for(auto v=0; v<N; ++v) if(active[v]) root = v;

  vector<unordered_map<int, int>> cost(N);
  function<int(int, int)> tdp1 = [&](auto pre, auto cur) {
    for(auto nex: G[cur]) if(active[nex]) if(nex != pre) cost[pre][cur] = max(cost[pre][cur], tdp1(cur, nex));
    if(C[pre] == B) cost[pre][cur] += (degree[pre] & 1) ? 1 : -1;
    if(C[pre] == W) cost[pre][cur] += (degree[pre] & 1) ? -1 : 1;
    return ++cost[pre][cur];
  };
  function<void(int ,int , int)> tdp2 = [&](auto pre, auto cur, auto w) {
    vector<int> n = {w};
    for(auto nex: G[cur]) if(active[nex]) if(nex != pre) n.emplace_back(cost[cur][nex]);
    sort(begin(n), end(n), greater<int>());
    for(auto nex: G[cur]) if(active[nex]) {
      if(nex == pre) {
        auto x = 0;
        cost[cur][pre] = w + x;
      } else {
        auto x = 1;
        if(C[nex] == B) x += (degree[nex] & 1) ? 1 : -1;
        if(C[nex] == W) x += (degree[nex] & 1) ? -1 : 1;
        if(n.size() == 1)               tdp2(cur, nex, w    + x);
        else if(cost[cur][nex] == n[0]) tdp2(cur, nex, n[1] + x);
        else                            tdp2(cur, nex, n[0] + x);
      }
    }
  };
  for(auto v: G[root]) tdp1(root, v);
  tdp2(root, root, 0);

  auto x = 0;
  for(auto u=0; u<N; ++u) if(active[u]) for(auto v: G[u]) if(active[v]) x = max(x, cost[u][v]);

  auto res = 2 * (count(begin(active), end(active), true) - 1);
  for(auto v=0; v<N; ++v) if(active[v]) {
    if((C[v] == W) && !(degree[v] & 1)) ++res;
    if((C[v] == B) &&  (degree[v] & 1)) ++res;
  }
  return res - x;
}

int main() {
  int N;
  cin >> N;
  Graph G(N);
  for(auto i=1; i<N; ++i) {
    int x, y;
    cin >> x >> y; --x, --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  string C;
  cin >> C;

  cout << solve(N, G, C) << endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int n;

int a,b,c;
double ans = 0;

int main(){
  cin >> n;
  if(n%2 == 1) ans ++;
  ans = (n/2+ans)/n;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
using  P=pair<ll,ll>;
map<P,ll> mp;
ll nature(ll a){
  if(a>=0){return a;}
  else{return -1*a;}
}
ll gcd(ll a,ll b){
  if(a%b==0){return(b);}
  else{return(gcd(b,a%b));}
}
ll pw(ll x,ll y) {
  ll tmp=x;
  ll res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  ll N,count0=0,rock1=0,rock2=0,ans=1;
  cin>>N;
  map<P,ll> visited;
  vector<ll> A(N);//こっちにーも格納//x座標
  vector<ll> B(N);//必ず正になる//y座標
  for(ll i=0;i<N;i++){
    ll a,b;
    cin>>a>>b;
    if(a==0 && b==0){A.at(i)=0;B.at(i)=0;count0++;}
    else if(a==0 && b!=0){A.at(i)=0;B.at(i)=1;rock1++;}
    else if(a!=0 && b==0){A.at(i)=1;B.at(i)=0;rock2++;}
    else{
      if(a>0&&b>0){A.at(i)=a/gcd(nature(a),nature(b));B.at(i)=b/gcd(nature(a),nature(b));}
      if(a<0&&b>0){A.at(i)=a/gcd(nature(a),nature(b));B.at(i)=b/gcd(nature(a),nature(b));}
      if(a>0&&b<0){A.at(i)=-1*a/gcd(nature(a),nature(b));B.at(i)=-1*b/gcd(nature(a),nature(b));}
      if(a<0&&b<0){A.at(i)=-1*a/gcd(nature(a),nature(b));B.at(i)=-1*b/gcd(nature(a),nature(b));}
    }
    mp[make_pair(A.at(i),B.at(i))]++;
  }
  ll n=N;
  for(ll i=0;i<N;i++){
    ll count=0;
    if(A.at(i)>0 && B.at(i)!=0 && visited[make_pair(A.at(i),B.at(i))]!=54){
      ll x=mp[make_pair(-1*B.at(i),A.at(i))];
      ll y=mp[make_pair(A.at(i),B.at(i))];
      if(x>0 && y>0){
        n-=x+y;
        visited[make_pair(A.at(i),B.at(i))]=54;
        count+=pw(2,x)+pw(2,y)-1;
        if(count%MOD!=0){count=count%MOD;}
        else{count=MOD;}
      }
    }else if(A.at(i)==0 && B.at(i)!=0 && visited[make_pair(0,0)]!=54 && rock1>0 && rock2>0){
      count=pw(2,rock1)+pw(2,rock2)-1;
      n-=rock1+rock2;
      count=(count+MOD)%MOD;
      visited[make_pair(0,0)]=54;
    }
    if(count>0){
      ans*=count;
      ans%=MOD;
    }
  }
  if(count0==0){ll answer=ans*pw(2,n)-1;cout<<(answer+MOD)%MOD<<endl;}
  else{ll answer=ans*pw(2,n-count0)-1+count0;cout<<(answer+MOD)%MOD<<endl;}
}

Measured memory_bytes: 31428
object Main extends App {

  val n = scala.io.StdIn.readInt()
  val s = scala.io.StdIn.readLine()

  def solve(): Int = {
    var ans = 0
    for(i <- 0 until n-2) {
      if(s(i) == 'A' && s(i+1) == 'B' && s(i+2) == 'C') ans += 1
    }
    ans
  }


  println(solve)

}


Measured memory_bytes: 25420
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,a[20];

ll ans(ll l,ll r,ll lx,ll rx){
  if(l+1==r) return 0;
  ll res=1e18;
  for(ll i=l+1;i<r;i++){
    res=min(res,a[i]*(lx+rx)+ans(l,i,lx,lx+rx)+ans(i,r,lx+rx,rx));
  }
  return res;
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define first ff
#define second ss
#define ll long long int
int main()
{
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    int c=0;

    if(2*x==w && 2*y==h) c=1;

    double mx=(w*h)/2.0;
    printf("%.6lf %d",mx,c);

}


Measured memory_bytes: 3732
n = int(input())
nums = [int(i) for i in input().split()]

even_nums = list(filter(lambda x: x % 2 == 0, nums))

divide_num = 0
while len(even_nums) == n:
    even_nums = list(map(lambda x: x / 2, even_nums))
    divide_num+=1
    even_nums = list(filter(lambda x: x % 2 == 0, even_nums))

print(divide_num)


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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int ans = 1'000'000'000;
    for (int p = 1; p <= 100; p++){
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp += (x[i]-p)*(x[i]-p);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

S=input()
T=input()
Sdata=[[] for i in range(0,26)]
Tdata=[[] for i in range(0,26)]

for i in range(0,len(S)):
    Sdata[alphabetlist.index(S[i])].append(i)
for i in range(0,len(T)):
    Tdata[alphabetlist.index(T[i])].append(i)
Sdata.sort()
Tdata.sort()
if Sdata==Tdata:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20784
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	string operator()(ll n) {
		string ret;

		for(;;)
		{
			n--;
			char c='a'+(n%26);
			ret=c+ret;
			n/=26;
			if(n<=0) break;
		}
		return ret;
	}
};

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

	for(;;)
	{
		ll n;
		cin >> n;
		if(cin.fail()) break;
		cout << solve()(n) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int a, b, c, x, y, price = 0;
    cin >> a >> b >> c >> x >> y;

    int min = (x < y ? x : y);
    if((a + b) / 2 >= c) price += c * 2 * min;
    else price += (a * min + b * min);

    if(x == y){
        printf("%d\n", price);
        return 0;
    }
    else if(x > y){
        if(a > c * 2) price += c * 2 * (x - y);
        else price += a * (x - y);
    }
    else{
        if(b > c * 2) price += c * 2 * (y - x);
        else price += b * (y - x);
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll>a(N),b(N),c(M),d(M);

    rep(i,N){
        cin>>a[i]>>b[i];
    }

    rep(i,M){
        cin>>c[i]>>d[i];
    }

    rep(i,N){
        ll ans=-1;
        ll now=INF;
        rep(j,M){
            ll dis=abs(a[i]-c[j])+abs(b[i]-d[j]);

            if(now>dis){
                ans=j+1;
                now=dis;
            }

        }
        cout<<ans<<endl;
    }
    
    


    return 0;
    

}

Measured memory_bytes: 3588
// 2014/08/31 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, R, L;
	cin >> N >> R >> L;

	long long P[100001] = {0};
	int W = 1;

	int T[100001] = {0};
	int tp = 0;

	for(int i=0; i<R; i++){
		int d, t, x;
		cin >> d >> t >> x;

		T[W] += t-tp;
		tp = t;

		P[d] += x;

		if(x>=0){
			if(P[W]<P[d] || (P[W]==P[d] && W>d)){
				W = d;
			}
		}
		else{
			if(W==d){
				W = 1;
				for(int j=2; j<=N; j++){
					if(P[W]<P[j]){
						W = j;
					}
				}
			}
		}
	}

	T[W] += L-tp;

	int C = 1;
	for(int i=2; i<=N; i++){
		if(T[C]<T[i]){
			C = i;
		}
	}
	cout << C << endl;

	return 0;
}

Measured memory_bytes: 2340
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[2][111];
    cin>>n;
    for(int i=0;i<2;++i){
        for(int j=0;j<n;++j){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<2;++i){
        for(int j=0;j<n;++j){
            if(i&&j)a[i][j]=max(a[i-1][j],a[i][j-1])+a[i][j];
            else if(i)a[i][j]=a[i-1][j]+a[i][j];
            else if(j)a[i][j]=a[i][j-1]+a[i][j];
        }
    }
    cout<<a[1][n-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define swap(a,b) a^=b^=a^=b 
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int a,b;
int main(){
	cin>>a>>b;
	if(abs(a-b)>=2)return puts("0"),0;
	int ans=1;
	for(int i=2;i<=a;i++)ans=1ll*ans*i%1000000007;
	for(int i=2;i<=b;i++)ans=1ll*ans*i%1000000007;
	if(a==b)ans=1ll*ans*2%1000000007;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2005,mo=1e9+7,M=4e6+5;
int fac[M],inv[M],f[N][N];
int C(int n,int m){
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int ksm(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mo){
		if(p&1) res=(ll)res*x%mo;
	}
	return res;
}
int main(){
	int n=read(),m=read(),k=n*m;
	For(i,fac[0]=1,k) fac[i]=(ll)fac[i-1]*i%mo;
	inv[k]=ksm(fac[k],mo-2);
	Rep(i,k-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
	f[0][0]=1;
	For(i,1,n) For(j,0,i){
		f[i][j]=f[i-1][j];
		if(j) f[i][j]=(f[i][j]+(ll)C(n-i+(n-j+1)*(m-1)-1,m-2)*f[i][j-1]%mo*(n-j+1))%mo;
	}
	if(m==1) f[n][n]=1;
	cout<<f[n][n];
}

Measured memory_bytes: 48588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int Min=2000000000; 
  rep(i,max(x,y)*2+1){
    int ca=max(0,x-i/2),cb=max(0,y-i/2);
    int cost=ca*a+cb*b+i*c;
    Min = min(Min,cost);  
  }
  cout << Min << endl;
}


Measured memory_bytes: 256
# AOJ 0211 FizzBuzz

def fizzbuzz(k)
  case
  when k % 3 == 0 && k % 5 == 0
    "FizzBuzz"
  when k % 3 == 0
    "Fizz"
  when k % 5 == 0
    "Buzz"
  else
    k.to_s
  end
end

while line = gets
  n_players, n_words = line.split.map {|v| v.to_i}
  break if n_players.zero? && n_words.zero?

  living_players = (1..n_players).to_a
  words = []
  n_words.times {words << gets.chomp}

  player = 0
  words.each.with_index(1) do |word, i|
    break if living_players.length == 1

    if word == fizzbuzz(i)
      # 正解
      player += 1
    else
      # 間違い
      living_players.delete_at(player)
    end

    player %= living_players.length
  end

  puts living_players.join(" ")
end

Measured memory_bytes: 8124
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

int main() {
    int A, B;
    cin >> A;
    cin >> B;

    cout << (6 - A - B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,m,n) for(ll i=m;i<n;i++)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
int h, w, n, a[10010],c[105][105];
signed main() {
	cin >> h >> w >> n;
	rep(i, n) {
		cin >> a[i];
	}
	int sum = 1,cnt=0;
	rep(i,h) {
		if (i % 2 == 0) {
			rep(j, w) {
				c[i][j] = sum;
				cnt++;
				if (cnt == a[sum-1]) {
					cnt = 0;
					sum++;
				}
			}
		}
		else {
			for (int j = w - 1; j >= 0; --j) {
				c[i][j] = sum;
				cnt++;
				if (cnt == a[sum-1]) {
					cnt = 0;
					sum++;
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << c[i][j]<<' ';
		}
		cout << endl;
	}
	ggr;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int x;
    scanf("%d",&x);
    int s,cnt=0;
    for(int i=0;i<x;i++){
        scanf("%d",&s);
        if(s==2||s==3||s==5||s==7){
            cnt +=1;
        }else if(!(1 < s && s <= 10 )&&s%2!=0){
            for(int w=3;w<=s/2;w++){
                if(s%w==0){
                    break;
                }else if(w == 10000||w==s/2){
                    //printf("%d\n",s);
                    cnt +=1;
                    break;
                }
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

class Task{
private:
public:
  int work, time_limit;
  Task(): work(0), time_limit(0){}
  Task(int w, int tl): work(w), time_limit(tl){}
};

bool cmp(const Task &a, const Task &b) {
  return a.time_limit < b.time_limit;
}

int main() {
  int n;
  cin >> n;
  vector<Task> task;
  int work, time_limit;
  for (int i = 0; i < n; i++) {
    cin >> work >> time_limit;
    task.push_back(Task(work, time_limit));
  }


  sort(task.begin(), task.end(), cmp);

  int sum[n];
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      sum[i] = task[i].work;
    } else {
      sum[i] = sum[i-1] + task[i].work;
    }
    if (sum[i] > task[i].time_limit) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
    int x, y, z, temp;
    scanf("%d%d%d", &x, &y, &z);
    temp = y+z;
    int ans = x / temp;
    if(x - ans*temp < z) ans--;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    /* ll t;
    cin>>t;
    while(t--) */
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,f=0;
        cin>>k;
        ll sum=100;
        ll y;
        while(sum<k)
        {
            y=(0.01*sum);
            sum+=y;
            cnt++;

        }
        cout<<cnt<<endl;
    }

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,p;cin >> n >> p;
    vector<vector<ll>> dp(n+1,vector<ll>(2));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        for(int j=0;j<2;j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][(j+a)%2]+=dp[i][j];
        }
    }
    cout << dp[n][p] << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a;
    cin >> a;
    // スペース区切りの整数の入力
    //int b,c;
    //cin >> b >> c;
    // 文字列の入力
    //string s;
    //cin >> s;
    // 出力
    cout << (a*a*a)<< endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n, m, k = [int(item) for item in input().split()]


ans = 1
for i in range(2, k):
    ans = (ans * (n * m - i)) % MOD

for i in range(1, k - 2 + 1):
    ans = (ans * pow(i, MOD - 2, MOD)) % MOD

print((ans * (m ** 2 * n * (n ** 2 - 1) // 6 + n * (n - 1) * m
              * (m ** 2 - 1) // 6 + n * m * (m ** 2 - 1) // 6)) % MOD)


# pairs = []
# for i in range(1, n + 1):
#     for j in range(1, m + 1):
#         pairs.append((i, j))
#
# pairs.sort()
# print(pairs)
#
# brute = 0
# for i in range(len(pairs)):
#     for j in range(i + 1, len(pairs)):
#         brute += abs(pairs[i][0] - pairs[j][0]) + \
#                      abs(pairs[i][1] - pairs[j][1])
#
# print(ans * brute)


Measured memory_bytes: 38768
#include<cstdio>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=101101;
int T,n,k;
int tot;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",a*b);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

std::map<int, int> factor(int x) {
    std::map<int, int> ret;

    for (int p = 2; p * p <= x; ++p) {
        if (x % p != 0) continue;
        ret[p] = 0;
        while (x % p == 0) {
            x /= p;
            ++ret[p];
        }
    }

    if (x > 1) ret[x] = 1;
    return ret;
}

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs;
    std::vector<std::map<int, int>> facts(n);
    for (auto& fact : facts) {
        int x;
        std::cin >> x;
        fact = factor(x);
        xs.push_back(x);
    }

    std::map<int, int> lcm = facts[0];
    for (int i = 1; i < n; ++i) {
        for (auto p : facts[i]) {
            if (!lcm.count(p.first)) lcm[p.first] = 0;
            lcm[p.first] = std::max(lcm[p.first], p.second);
        }
    }

    mint l = 1;
    for (auto p : lcm) {
        l *= mint(p.first).pow(p.second);
    }

    mint ans = 0;
    for (auto x : xs) ans += l / x;
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


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

	int main() {
		int N;
		int a[110];
		cin >> N;
		for (int i = 0; i < N; i++)
		{
			cin >> a[i];
		}
		sort(a, a + N, greater<int>());

		int Alice = 0;
		int Bob = 0;

		for (int i = 0; i < N; i++)
		{
			if (i%2==0)
			{
				Alice = Alice + a[i];
			}
			else {
				Bob = Bob + a[i];
			}

		}
		cout << Alice - Bob << endl;
			 
		
	}


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

int main()
{
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i,n) a[i] = k-q;
    rep(i,q){
        int num;
        cin >> num;
        a[num-1] += 1;
    }
    rep(i,n){
        if(a[i]>0){
            cout << "Yes" << endl;
        } else if (a[i]<= 0) {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int N, X, Y;
vector<int> v[2010];
vector<int> v_dis(2010, INF);
vector<int> ans(2010, 0);

void bfs(int f) {
    rep(i, 2010) v_dis[i] = INF;
    queue<int> q;
    q.push(f);
    int dis = 0;
    v_dis[f] = dis;
    while (!q.empty()) {
        rep(i, v[q.front()].size()) {
            if (v_dis[v[q.front()][i]] > v_dis[q.front()]) {
                v_dis[v[q.front()][i]] = v_dis[q.front()] + 1;
                q.push(v[q.front()][i]);
                //cout << q.front() + 1 << " " << v[q.front()][i] + 1 << endl;
                //cout << "dis" << v_dis[v[q.front()][i]] << endl;
            }
        }
        q.pop();
        //cout << endl;
    }
    rep(i, N) {
        if (i == f) continue;
        ans[v_dis[i]]++;
        //cout << "ans" << ans[v_dis[i]] << endl;
    }
    return;
}

int main() {
    cin >> N >> X >> Y;
    rep(i, N - 1) {
        v[i].push_back(i + 1);
        v[i + 1].push_back(i);
    }
    v[X - 1].push_back(Y - 1);
    v[Y - 1].push_back(X - 1);

    rep(i, N) bfs(i);
    REP(i, 1, N) cout << ans[i] / 2 << endl;
}



Measured memory_bytes: 3660
#include <stdio.h>

int main(void)
{
	int h, w;
	int i, j;

	scanf("%d %d", &h, &w);

	while (h != 0 && w != 0)
	{
		for (i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				printf("#");
			}
			printf("\n");
		}

		scanf("%d %d", &h, &w);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572