akhauriyash/Code-Regression huggingface dataset:
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3937659
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL dp[111111][3];
LL abc[111111][3];

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++) for(int j = 0; j < 3; j++) scanf("%lld", &abc[i][j]);
    
    // 2. dp更新.
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                // (j, k) = (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1) の 6通り を 処理.
                if(j != k) dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j]);
            }
        }
    }
    
    // for(int i = 0; i <= N; ++i){
    //     for(int j = 0; j < 3; j++) printf("dp[%d][%d]=%lld ", i, j, dp[i][j]);
    //     printf("\n");
    // }
    
    // 3. 出力.
    printf("%lld\n", max(dp[N][0], max(dp[N][1], dp[N][2])));
    return 0;
}

Measured memory_bytes: 5248
import bisect
import itertools
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

acc1 = [0]+list(itertools.accumulate(a))
acc2 = list(itertools.accumulate(b))

ans = 0
for i in range(n+1):
    num = i
    temp = acc1[i]
    rest = k-temp

    if rest >= 0:
        hoge = bisect.bisect_right(acc2,rest)

        num += hoge

        if num > ans:
            ans = num

print(ans)



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

int main() {
  int N, X;
  cin >> N >> X;
  
  int D = 0;
  int counter = 1;
  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    
    D = D + L;
    if (D <= X) 
      counter++;
  }
  
  cout << counter << endl;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> cnt(n);
  int a;
  for (int i = 0; i < k; ++i){
	cin >> a;
	for (int j = 0; j < a; ++j){
		int b;
		cin >> b;
		++cnt[--b];	
	}
  }
  int c = 0;
  for (int i : cnt){
	if (i == 0) ++c;
  }
  cout << c << "\n";
return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
const int max_n=510000;
ll fac[max_n], finv[max_n], inv[max_n];
// テーブルを作る前処理 O(max_n)
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv [mod%i] *  (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算 O(1)
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    init();
    ll n,k;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    ll ans=0;
    rep(i,n-1){
        ans+=(v[i+1]-v[i])*((modcom(n,k)-modcom(n-i-1,k)-modcom(i+1,k))%mod);
        ans=(ans%mod+mod)%mod;
    }
    out(ans);
}

Measured memory_bytes: 12928
sx, sy, tx, ty = map(int, input().split())
route1, route2, route3, route4 = '', '', 'L', 'R'
dis_x = tx - sx
dis_y = ty - sy
route1 = 'U' * dis_y + 'R' * dis_x
route2 = 'D' * dis_y + 'L' * dis_x
route3 += 'U' * (dis_y+1) + 'R' * (dis_x+1) + 'D'
route4 += 'D' * (dis_y+1) + 'L' * (dis_x+1) + 'U'
print(route1 + route2 + route3 + route4)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> vc(n);	
  for(int i=0;i<n;i++)
  cin>>vc[i];
  int ans = 0,q,a;
  cin>>q;
  sort(vc.begin(),vc.end());
  while(q--){
  cin>>a; 
  
  if(binary_search(vc.begin(),vc.end(),a))
  ans++;
  
}
printf("%d\n",ans);	
	
}


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

int main() {
  int N, A;
  cin >> N >> A;
  if (N >= 500) {
    N = N - (N / 500) * 500;
  }
  if (N <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
#include <string>
#include <cctype>

int main() {
    string deck, subset1, subset2;
    int m, h;
    while (1){
        cin >> deck;
        if (deck == "-") break;

        cin >> m;
        for (int i = 1; i <= m; i++){
            cin >> h;
            subset1 = deck.substr(0,h);
            subset2 = deck.substr(h,deck.size()-1);
            deck = subset2 + subset1;
        }
        cout << deck << "\n";
    }

    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
 
 
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  int sum=0;
  rep(j,n-1){
    sum += a[j];
  }
  if(a[n-1] < sum){
    cout << "Yes" ;
  }
  else{
    cout << "No";
  }
 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

   int main(void){
   int a,b,c;
   scanf("%d %d %d", &a, &b ,&c);
   int max = a;
   if (b > max) max = b;
   if (c > max) max = c;
   printf("%d\n", a + b + c - max);
   return (0);
}




Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
int main(){
    int N,x;
    cin >>N>>x;
    int a[N];
    int i;
    for(i=0;i<N;i++){
      cin >> a[i];
    }
    sort(a,a+N);
    int cnt=0;
    for(i=0;i<N-1;i++){
      if(x>=a[i]){
        x-=a[i];
        cnt++;
      }
    }
    if(a[N-1]==x)cnt++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int r;
  cin >> r;
  cout<< r*r <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(void){
   int X;
   cin>>X;
   int ans=0;
   for(int i=1;i<=X;i++){
       ans=ans+i;
       if(ans>=X) {cout<<i; break;}
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define pb push_back
using namespace std;

int n, x, y;
const int MAXN = 2e3 + 10;

vector <int> g[MAXN];
int sp[MAXN][MAXN];
int cnt[MAXN];
bool used[MAXN];

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

    cin >> n >> x >> y;
    forn(i, 1, n - 1) {
        g[i].pb(i + 1);
        g[i + 1].pb(i);
    }
    g[x].pb(y);
    g[y].pb(x);

    forn(i, 1, n) {
        sp[i][i] = 0;
        forn(i, 1, n) used[i] = false;
        queue <int> q;
        q.push(i);
        while(!q.empty()) {
            int now = q.front();
            q.pop();
            if(used[now]) continue;
            used[now] = true;
            for(auto it: g[now]) {
                q.push(it);
                if(sp[i][now] + 1 < sp[i][it] || sp[i][it] == 0) sp[i][it] = sp[i][now] + 1;
            }
        }
    }

    forn(i, 1, n) {
        forn(j, i + 1, n) cnt[sp[i][j]]++;
    }

    forn(i, 1, n - 1) cout << cnt[i] << "\n";

    return 0;
}


Measured memory_bytes: 16128
#include <iostream>
using namespace std;
int s[20001];
int main(void){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        s[a]=i;
    }
    for(int i=1;i<=n;i++){
        cout<<s[i]+i*20000<<" ";
    }
    cout<<endl;
    for(int i=n;i>=1;i--){
        cout<<i*20000<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];
int isVisited[1 + NMAX];

vector <int> adj[1 + NMAX];

int main() {

  int n, m, a, b, ans = 0;
  bool good = true;
  cin >> n >> m;
  for(int i = 1;i <= n;i++){
    cin >> v[i];
  }
  for(int i = 1;i <= m;i++){
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(int i = 1;i <= n;i++){
    if(isVisited[i] == false){
      isVisited[i] = true;
      good = true;

      for(int j = 0;j < adj[i].size();j++){

        if(v[i] > v[adj[i][j]]){
          isVisited[adj[i][j]] = true;
        }else{
          good = false;
        }
      }
      if(good){
        ans++;
      }
    }

  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 9552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    cout<<n*n<<endl;
}

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

using namespace std;

const int MAX_N = 13, MAX_M = 1e3 + 200;
const ll INF = 0x3f3f3f3f3f3f3f3f;

ll dp[MAX_M][(1 << MAX_N)], n, m, ai[MAX_M], keymp[MAX_M];

int main()
{
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= m; i++)
    {
        int tmp, tmpx;
        scanf("%lld%d", &ai[i], &tmp);
        while (tmp--)
            scanf("%d", &tmpx), keymp[i] |= (1 << (tmpx - 1));
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
    {
        dp[i][0] = 0;
        for (int stat = 0; stat < (1 << n); stat++)
            dp[i][stat] = dp[i - 1][stat];
        for (int stat = 0; stat < (1 << n); stat++)
            dp[i][stat | keymp[i]] = min(dp[i][stat | keymp[i]], dp[i - 1][stat] + ai[i]);
    }
    if (dp[m][(1 << n) - 1] == INF)
        puts("-1");
    else
        printf("%lld", dp[m][(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 77184
/**
 *    author:  tourist
 *    created: 20.11.2019 16:54:11       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<int> mask(n);
  int ans = 0;
  function<void(int, int)> Dfs = [&](int v, int pr) {
    int lowest = 0;
    for (int u : g[v]) {
      if (u == pr) {
        continue;
      }
      Dfs(u, v);
      lowest |= (mask[u] & mask[v]);
      mask[v] |= mask[u];
    }
    int bit = 1 << (lowest == 0 ? 0 : 32 - __builtin_clz(lowest));
    while (mask[v] & bit) {
      bit <<= 1;
    }
    mask[v] &= ~(bit - 1);
    mask[v] |= bit;
    ans = max(ans, 31 - __builtin_clz(mask[v]));
  };
  Dfs(0, -1);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ret = 0;
    auto div2 = [](ll x){
        ll ret = 0;
        while(x % 2 == 0){
            x /= 2;
            ret++;
        }
        return ret;
    };
    rep(i,n){
        ret += div2(a[i]);
    }
    cout << ret << endl;
}

Measured memory_bytes: 384
import random


d = int(input())
c = list(map(int,input().split()))
s = []

class field:
    def __init__(self):
        self.ans = [-1 for i in range(365)]
        self.last = [-1 for i in range(26)]


    def score_day(self,day,type):
        inc = s[day][type]
        dec = 0
        for i in range(26):
            dec += c[i]*(day-self.last[i])

        return  inc-dec


for i in range(d):
    arr = list(map(int,input().split()))
    s.append(arr)

best_score = 0
alloc = []

F = field()
ans = 0
good = []
childs = 70
badchild = 20
for day in range(d):
    if day == 0:
        tp_scores = []
        for j in range(25):
            prob = j
            befl = F.last[prob]
            F.last[prob] = day
            sc = F.score_day(day, prob)
            tp_scores.append([-sc, j,F.last.copy(),str(j)])

            F.last[prob] = befl

        tp_scores.sort()
        good = tp_scores
    else:
        tp_scores = []
        for i in range(min(childs,len(good))):
            befs = good[i][0]
            befp = good[i][1]
            befl = good[i][2]
            befa = good[i][3]
            F.last = befl
            for j in range(25):
                prob = j
                bt = F.last[prob]
                F.last[prob] = day
                sc = F.score_day(day,prob)
                tp_scores.append([befs-sc,j,F.last.copy(),befa+","+str(j)])

                F.last[prob] = bt

        tp_scores.sort()
        good = tp_scores[:childs]

        if len(tp_scores) > childs:
            rest =len(tp_scores)-childs
            pick = min(badchild,rest)
            sp = random.sample(range(childs,len(tp_scores)),pick)
            for sss in sp:
                good.append(tp_scores[sss])


# print(good[0])


# for g in good:
#     tp = 0
#     root = list(map(int,g[-1].split(",")))
#     F = field()
#     for i in range(len(root)):
#         F.ans[i] = root[i]
#         F.last[root[i]] = i
#         tp += F.score_day(i,root[i])
#     print(root,tp)


root = map(int,good[0][-1].split(","))

for r in root:
    print(r+1)


Measured memory_bytes: 192780
//Rafiqul Islam, MBSTU,ICT

#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test ;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
#define endl "\n"
#define all(v) v.begin(),v.end()
#define SET(a)      memset((a), -1, sizeof(a))
#define CLR(a)      memset((a), 0, sizeof(a))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const ll mod = 998244353;
const ll maxn = 1e6+5;

ll power(ll x, unsigned long long y)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x)%mod;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x)%mod;  // Change x to x^2
    }
    return res%mod;
}
ll modOp(ll a, ll b)
{
    ll c = a % b;
    if (c < 0)
        c += b;
    return c;
}
ll iv[maxn + 1];
void mod_inv()
{
    iv[1] = 1;
    for(ll i = 2 ; i <= maxn ; i++ )
    {

        iv[i] = (mod - mod/i * iv[mod%i]%mod)%mod;
        //cout << iv[i] << endl;
    }
}

ll Logn(ll n, ll base)
{
    return (n > base - 1) ? 1 + Logn(n / base, base) : 0;
}
vector<vector<int>> adj;
vector<int>sub_tree_size;
vector<array<int,2>> edge;
void dfs(int child, int parant)
{
    sub_tree_size[child] = 1;
    for(int x: adj[child])
    {
        if(x == parant)
            continue;

        dfs(x,child);
        sub_tree_size[child] += sub_tree_size[x];
    }

}
int isPrime[1000001] ;
vector< vector<ll> > pff(1000000), pr(1000000);
void sieve(int n)
{
    for(int i = 2 ; i*i <= n ; i++)
    {
        if(isPrime[i] == 0)
        {
            for(int j = i+i ; j <= n; j = j + i)
            {
                isPrime[j] = 1;
            }
        }
    }
    return;
}
ll dp[500005];
void run_case()
{
    ull a;
    double b;
    cin >> a >> b;

    ull c = round(b*100);

    ull ans = a*c;
    cout << ans/100 << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    run_case();
    //main();
    return 0;
}


Measured memory_bytes: 50108
S=input()
S_check=[]
S_check2 =[]

for i in range (0,len(S)):
    S_check2.append(S[i])
    
    
for i in range (0,len(S)//2):
    S_check.append(S[i])

S_check.append(S[len(S)//2])

for i in range (0,len(S)//2):
    S_check.append(S[i])
    



if S_check==S_check2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() { // こういうやつはstackを使う
	string s;
	cin >> s;
	int n = s.size();
	stack<char> st;
	int ans = 0;
	rep(i,n) {
		if (st.empty() || st.top() == s[i]) st.push(s[i]);
		else {
			st.pop();
			ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    if (k > (n + 1) / 2) {
        cout << "-1" << endl;
        return 0;
    }
    ll t = (n + 1) / 2;
    vector<int> a(n), b(n), c(n);
    if (n % 2) {
        for (int i = 0; i < n / 2 + 1; i++) {
            a[i] = i;
            b[i] = 2 * n - 1 - 2 * i;
            c[i] = a[i] + b[i] + t;
        }
        for (int i = n / 2 + 1; i < n; i++) {
            a[i] = i;
            b[i] = 2 * n - 2 - 2 * (i - n / 2 - 1);
            c[i] = a[i] + b[i] + t;
        }
    } else {
        for (int i = 0; i < n / 2; i++) {
            a[i] = i;
            b[i] = 2 * n - 1 - 2 * i;
            c[i] = a[i] + b[i] + t;
        }
        for (int i = n / 2; i < n; i++) {
            a[i] = i;
            b[i] = 2 * n - 2 - 2 * (i - n / 2);
            c[i] = a[i] + b[i] + t + 1;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] + k << " " << b[i] + k << " " << c[i] + k << endl;
    }
}

Measured memory_bytes: 3456
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception {
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String buf = br.readLine();
	int x = Integer.parseInt(buf);
	int y = (int) Math.pow(x,3);
	System.out.println(y);
	}
}

Measured memory_bytes: 24272
from heapq import heappush, heappop
import sys
input = sys.stdin.readline


# def dijkstra(graph: list, node: int, start: int) -> list:
#     # graph[node] = [(cost, to)]
#     INF = float('inf')
#     dist = [INF] * node
#
#     dist[start] = 0
#     heap = [(0, start)]
#     while heap:
#         cost, thisNode = heappop(heap)
#         for NextCost, NextNode in graph[thisNode]:
#             dist_cand = dist[thisNode] + NextCost
#             if dist_cand < dist[NextNode]:
#                 dist[NextNode] = dist_cand
#                 heappush(heap, (dist[NextNode], NextNode))
#     return dist
#     # dist = [costs to nodes]
def dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list:
    # graph[v_from] = [(cost, v_to), ...]
    dist = [INF] * n

    dist[v_s] = 0
    heap = [(0, v_s)]  # heap = [(dist[v], v), ...]
    while heap:
        _, v_from = heappop(heap)
        for cost, v_to in graph[v_from]:
            dist_cand = dist[v_from] + cost
            if dist_cand < dist[v_to]:
                dist[v_to] = dist_cand
                heappush(heap, (dist[v_to], v_to))
    return dist
    # dist = [costs to nodes]


n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    l, r, c = map(int, input().split())
    l -= 1
    r -= 1
    edge[l].append((c, r))
for i in range(1, n):
    edge[i].append((0, i - 1))

INF = 10**15
dist = dijkstra(edge, n, 0, INF=INF)
ans = dist[-1] if dist[-1] != INF else -1

print(ans)


Measured memory_bytes: 43808
#include<stdio.h>
#include<algorithm>
using namespace std;
#define MLOG 17
int n,m,q;
int a[100005];
int p[100005][18];
void init()
{
    int i,x,l,r,mid,ans;
    for(i=1;i<=n;i++)
    {
        ans = i;
        l = i; r = n;
        while(l<=r)
        {
            mid = (l+r)/2;
            if(a[mid]-a[i]<=m)
            {
                ans = mid;
                l = mid+1;
            }
            else r = mid-1;
        }
        p[i][0] = ans;
    }
    for(i=1;i<=MLOG;i++)
    {
        for(x=1;x<=n;x++) p[x][i] = p[p[x][i-1]][i-1];
    }
}
int get(int x,int cnt)
{
    int i,now;
    now = x;
    for(i=0;i<=MLOG;i++)
    {
        if(cnt&1) now = p[now][i];
        cnt/=2;
    }
    return now;
}
main()
{
    int i,x,y,l,r,mid,ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    scanf("%d%d",&m,&q);
    init();
    for(i=0;i<q;i++)
    {
        scanf("%d%d",&x,&y);
        if(x>y) swap(x,y);
        l = 0; r = n;
        while(l<=r)
        {
            mid = (l+r)/2;
            if(get(x,mid)>=y)
            {
                ans = mid;
                r = mid-1;
            }
            else l = mid+1;
        }
        printf("%d\n",ans);
    }
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  string s, t; cin>>s>>t;
  rep(i,0,n) {
    cout<<s[i];
    cout<<t[i];
  }
  cout<<endl;
}



Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    if (N < 1200) {
        std::cout << "ABC" << std::endl;
    }
    else if (N < 2800) {
        std::cout << "ARC" << std::endl;
    }
    else {
        std::cout << "AGC" << std::endl;
    }

    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int a,b,c,d;cin>>a>>b>>c>>d;
  while(a>0&&c>0)
  {
    c-=b;
    if(c<=0)
    {
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<=0)
    {
      cout<<"No"<<endl;
      break;
    }
  }
}



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

constexpr int lim = 100;

int h, w, n;
int a[(lim+1) * (lim+1)];
int c[lim+1][lim+1];

int main(){
  cin >> h >> w >> n;
  for(int i=1; i<=n; i++) cin >> a[i];

  int i=1;
  for(int y=1; y<=h; y++){
    if(y % 2){
      for(int x=1; x<=w; x++){
        if(a[i] == 0) i++;
        c[y][x] = i;
        a[i]--;
      }
    } 
    else{
      for(int x=w; x>=1; x--){
        if(a[i] == 0) i++;
        c[y][x] = i;
        a[i]--;
      }
    }
  }

  for(int y=1; y<=h; y++){
    for(int x=1; x<=w; x++) cout << c[y][x] << " ";
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return sol;
}

ll gcd( ll a, ll b )
{
   if( b == 0 )
      return a;
   else
   {
      return gcd( b, a % b );
   }
}
void solve()
{
	int n;
	cin >> n;
	while (n)
	{
		int d = n % 10;
		if (d == 7)
		{
			cout << "Yes";
			return;
		}
		n = n/10;
	}
	cout << "No";
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 3624
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int64_t i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	int64_t n,wt;	cin >> n >> wt;
	int64_t w[n], v[n];
	Rep(i,0,n){
		cin >> w[i] >> v[i];
	}
	int64_t dp[n+1][wt+1];
	Rep(i,0,n+1){
		Rep(j,0,wt+1){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
			}else if(w[i-1] <= j){
				dp[i][j] = max((v[i-1]+dp[i-1][j-w[i-1]]), dp[i-1][j]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[n][wt] << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	return 0;
}

Measured memory_bytes: 79232
#include <stdio.h>
#include <string.h>

char str[100000];
int  result[100000] = {0};
int N;

void print() {

        for (int i = 0 ; i < N ; i++) {
                printf("%d ", result[i]);
        }
}
int main() {
        scanf("%s", &str);
        N = strlen(str);

        // 左から
        int count = 0;
        for (int i = 0 ; i < N ; i++) {
                if (str[i] == 'R') {
                        count++;
                } else {
                        int L = count / 2;
                        int R = count - L;

                        result[i - 1] += R;
                        result[i    ] += L;

                        count = 0;
                }
        }


        // 右から
        count = 0;
        for (int i = N - 1 ; i >= 0 ; i--) {
                if (str[i] == 'L') {
                        count++;
                } else {
                        int R = count / 2;
                        int L = count - R;

                        result[i - 0] += R;
                        result[i + 1] += L;

                        count = 0;
                }
        }

        print();
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int N, Q;
	cin >> N >> Q;
	Graph G(N+1);
	for (int i = 0; i < N -1; ++i) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> dist(N+1, 0);
	for (int i = 0; i < Q;i++) {
		int a, b;
		cin >> a >> b;
		dist[a] = dist[a] +b;
	}
	queue<int> que;
	vector<bool> point(N + 1, 0);
	que.push(1);
	point[1] = true;
	while (!(que.empty())) {
		int v = que.front();
		que.pop();
		for (int nv : G[v]) {
			if (point[nv] == true) {
				continue;
			}
			point[nv] = true;
			dist[nv] = dist[v] +dist[nv];
			que.push(nv);
		}
	}
	for (int i = 1; i < N+1; ++i) {
		cout << dist[i] << " ";
	}
}

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

using namespace std;

int main(void){
  string str;
  cin >> str;
  bool flag = true;
  if(str.length()%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<str.length();i++){
    if(i%2 == 0){
      if(str[i] != 'h')
	flag = false;
    }
    if(i%2 == 1){
      if(str[i] != 'i')
	flag = false;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,N,H,W,ans;
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])printyes;
  else printno;
  return 0;
}

Measured memory_bytes: 256
def inv(a,m):
    b=m
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % m

mod=998244353
n,m,k=map(int,input().split())
frac=[1 for i in range(n+1)]
frac_inv=[1 for i in range(n+1)]
beki=[m for i in range(n+1)]

for i in range(1,n+1):
    frac[i]=frac[i-1]*i%mod
    frac_inv[i]=inv(frac[i],mod)
    beki[i]=beki[i-1]*(m-1)%mod
ans=0
for i in range(n-k,n+1):
    ans+=beki[i-1]*frac[n-1]*frac_inv[n-i]*frac_inv[i-1]%mod
print(ans%mod)

Measured memory_bytes: 94300
#include <stdio.h>

#define N 10000
#define Q 500

int s[N];
int n;

int linearSearch(int);

int main()
{

  int i, j, q, c = 0;
  int t[Q];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);

  for(j=0; j<q; j++){
    scanf("%d", &t[j]);
  }

  for(j=0; j<q; j++){
    if(linearSearch(t[j]) == 1){
      c++;
    }
  }

  printf("%d\n", c);

  return 0;

}

int linearSearch(int key)
{

  int a = 0;
  s[n] = key;

  while(s[a] != key){
    a++;
  }
    if(a == n){
      return 0;
    }

    else return 1;
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        String data[] = reader.readLine().split(" ");
        int a = Integer.parseInt(data[0]);
        int b = Integer.parseInt(data[1]);
        int d;
        int r;
        String f;

        d = a / b;
        r = a % b;
        f = (String.format("%.5f", ((double) a / (double) b)));

        sb
                .append(d)
                .append(" ")
                .append(r)
                .append(" ")
                .append(f)
                .append("\n");
        System.out.println(sb);
    }
}

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

using namespace std;
#define int long long
string temp = "01+-*()=";

int A(string&, int&);

int B(string&, int&);

int C(string&, int&);

int C(string& S, int& idx)
{
  int ret = 0;
  if(isdigit(S[idx])) {
    if(isdigit(S[idx + 1]) && S[idx] == '0') throw (0LL);
    while(isdigit(S[idx])) ret = ret * 2 + S[idx++] - '0';
  } else if(S[idx] == '(') {
    ret = A(S, ++idx);
    if(S[idx] != ')') throw (0LL);
    ++idx;
  } else if(S[idx] == '-') {
    ret = -C(S, ++idx);
  } else {
    throw (0LL);
  }
  return (ret);
}

int B(string& S, int& idx)
{
  int ret = C(S, idx);
  while(S[idx] == '*') {
    ret *= C(S, ++idx);
  }
  return (ret);
}

int A(string& S, int& idx)
{
  int ret = B(S, idx);
  while(S[idx] == '+' || S[idx] == '-') {
    if(S[idx] == '+') ret += B(S, ++idx);
    else ret -= B(S, ++idx);
  }
  return (ret);
}

signed main()
{
  string S;
  int conv[32];
  memset(conv, -1, sizeof(conv));

  cin >> S;

  vector< char > num;
  for(char& c : S) {
    if(isalpha(c)) num.push_back(c);
  }
  sort(begin(num), end(num));
  num.erase(unique(begin(num), end(num)), end(num));
  for(int i = 0; i < S.size(); i++) {
    if(isalpha(S[i])) conv[i] = lower_bound(begin(num), end(num), S[i]) - begin(num);
  }

  if(num.size() > temp.size()) {
    cout << 0 << endl;
    return (0);
  }
  sort(begin(temp), end(temp));

  vector< string > ss;
  do {
    string T = S;
    for(int i = 0; i < S.size(); i++) {
      if(~conv[i]) T[i] = temp[conv[i]];
    }
    if(count(begin(T), end(T), '=') == 1 && T.front() != '=' && T.back() != '=') {
      ss.push_back(T);
    }
  } while(next_permutation(begin(temp), end(temp)));
  sort(begin(ss), end(ss));
  ss.erase(unique(begin(ss), end(ss)), end(ss));

  int ret = 0;
  for(string& al : ss) {
    string L = "", R = "";
    bool which = false;
    for(int i = 0; i < al.size(); i++) {
      if(al[i] == '=') {
        which = true;
        continue;
      }
      (which ? R : L) += al[i];
    }
    R += "$";
    L += "$";
    int idx;


    try {
      int ll = A(L, idx = 0);
      if(idx + 1 != L.size()) continue;
      int rr = A(R, idx = 0);
      if(idx + 1 != R.size()) continue;


      ret += ll == rr;
    } catch(int e) {}
  }
  cout << ret << endl;
}

Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(b<a)a=b
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
constexpr int dx[] = {1, 0, -1,  0};
constexpr int dy[] = {0, 1,  0, -1};
constexpr char dir[4] = {'r', 'u', 'l', 'd'};
#define N 4
#define N2 16
#define LIMIT 100
int MDT[N2][N2];
struct Puzzle {
	int f[N2];
	int space, MD;
};
Puzzle state;
int limit;
int path[LIMIT];
int getAllMD(Puzzle pz) {
	int sum = 0;
	rep(i, 0, N2) {
		if(pz.f[i] == N2) continue;
		sum += MDT[i][pz.f[i] - 1];
	}
	return sum;
}
bool isSolved() {
	rep(i, 0, N2) if(state.f[i] != i + 1) return false;
	return true;
}
bool dfs(int depth, int prev) {
	if(state.MD == 0) return true;
	if(depth + state.MD > limit) return false;
	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;
	int tx, ty;
	rep(r, 0, 4) {
		tx = sx + dx[r];
		ty = sy + dy[r];
		if(tx < 0 || tx >= N || ty < 0 || ty >= N) continue;
		if(max(prev, r) - min(prev, r) == 2) continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
		swap(state.f[tx * N + ty], state.f[sx * N + sy]);
		state.space = tx * N + ty;
		if(dfs(depth + 1, r)) { path[depth] = r; return true; }
		state = tmp;
	}
	return false;
}
string iterative_deepening(Puzzle in) {
	in.MD = getAllMD(in);
	string ans = "";
	for(limit = in.MD; limit <= LIMIT; ++limit) {
		state = in;
		if(dfs(0, -100)) {
			ans = "";
			rep(i, 0, limit) ans += dir[path[i]];
			return ans;
		}
	}
	return "unsolvable";
}
int main() {
	rep(i, 0, N2) {
		rep(j, 0, N2) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle in;
	rep(i, 0, N2) {
		cin >> in.f[i];
		if(in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	P(len(iterative_deepening(in)));
	return 0;
}

Measured memory_bytes: 3192
N = int(input())
x, y = 0, 0
b = False
for _ in range(N):
    T, X, Y = map(int, input().split())
    if abs(X-x)+abs(Y-y) > T or abs(X-x)+abs(Y-y)+T&1:
        b = True
print("YNeos"[b::2])

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    double BTC, result;
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> u[i];
        if(u[i] == "BTC") {
            BTC += x[i];
        }
        else {
            result += x[i];
        }
    }
    result += BTC * 380000;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      char[] c = sc.next().toCharArray();
      int n = c.length;
      int cnt = 1;
      Queue<Integer> q = new ArrayDeque<>();
      for(int i = 1;i < n;i++){
      	if(c[i]==c[i-1])cnt++;
        else{
          q.add(cnt);
          cnt = 1;
        }
      }
      q.add(cnt);
      while(q.size()!=0){
      	int a = q.poll();
        int b = q.poll();
        for(int i = 1;i <= a-1;i++)System.out.print(0+" ");
        System.out.print(b/2+(a+1)/2);
        System.out.print(" ");
        System.out.print((b+1)/2+a/2);
        if(b!=1||q.size()!=0)System.out.print(" ");
        for(int i = 1;i <= b-1;i++){
          if(q.size()==0&&i==b-1)System.out.print(0);
          else System.out.print(0+" ");
        }
      }
      System.out.println("");
    }
}

Measured memory_bytes: 49976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
    string S;
    string T;
    cin >> S >> T;

    if(T.substr(0, S.size()) == S) {
        cout << "Yes" << endl;
        return;
    }

    cout << "No" << endl;
}

void B() {
    ll A, B, C, K;

    cin >> A >> B >> C >> K;

    ll tot = 0;
    R1(K) {
        if(i < A) {
            tot += 1;
        }
        else if(i >= (A+B)) {
            tot -=1;
        }
    }

    cout << tot << endl;
}

void ps(ll k, ll l, ll r, vector<vector<long long>> & powerSets, vector<long long> & currSet) {
    if(k == 0) {
        powerSets.push_back(currSet);
    }

    for(int i = l; i < r; ++i) {
        currSet.push_back(i);
        ps(k - 1, i + 1, r, powerSets, currSet);
        currSet.pop_back();
    }
}
void C() {
    ll N, M, X;

    cin >> N >> M >> X;

    vi cis(N, 0);
    vector<vector<long long>> mij(N, vector<long long>(M));

    R1(N) {
        cin >> cis[i];
        R2(j, M) {
           cin >> mij[i][j];
        }

    }

    vi prices;
    vector<vector<long long>> powerset;
    vector<long long> currSet;
    for(int i = 1; i <= N; ++i) {
        ps(i, 0, N, powerset, currSet);
    }
    ll minPrice = mal();
    for(auto s : powerset) {
        ll price = 0;
        vi av(M, 0);
        for(auto book : s) {
            price += cis[book];
            for(int i = 0; i < mij[book].size(); ++i) {
                av[i] += mij[book][i];
            }
        }
        bool lvlOk = true;
        for(auto lvl : av) {
            if(lvl < X) {
                lvlOk = false;
                break;
            }
        }
        if(lvlOk)
            minPrice = min(minPrice, price);
    }

    if(minPrice != mal())
        cout << minPrice << endl;
    else
        cout << -1 << endl;
}

void D() {
}

void E() {
}

int main()
{
    C();
}

Measured memory_bytes: 3924
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,M;cin >> N >> M;
  if(abs(N-M)>=2){
    cout << 0 << endl;
    return 0;
  }
  ll dog=1,monk=1;
  rep(i,N){
    dog*=(i+1);
    dog%=MOD;
  }
  rep(i,M){
    monk*=(i+1);
    monk%=MOD;
  }
  if(N==M){
    cout << (dog*monk)%MOD*2%MOD << endl;
  }
  else{
    cout << (dog*monk)%MOD << endl;
  }
}

Measured memory_bytes: 256