akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, t;
int m[1010];
int l[1010];
int k[1010];
bool used[1010];

bool calc(int op, int sum) {
  MEMSET(used, false);
  priority_queue<int> que;
  REP(i, op) {
    que.push(-m[i]);
    used[i] = true;
    sum -= m[i];
  }
  while (!que.empty()) {
    int start = -que.top();
    que.pop();
    if (start + sum / op > t) { return false; }
    int mintime = 1000000000;
    int target = -1;
    REP(i, n) {
      if (used[i]) { continue; }
      int p = start % (l[i] + k[i]);
      if (p <= l[i]) {
        mintime = start;
        target = i;
        break;
      } else {
        p = start + (l[i] + k[i] - p);
        if (p < mintime) {
          mintime = p;
          target = i;
        }
      }
    }
    if (target != -1 && mintime + m[target] > t) { return false; }
    if (target != -1) {
      que.push(-mintime - m[target]);
      used[target] = true;
      sum -= m[target];
    }
  }
  return true;
}

int main() {
  int test_case = 0;
  while (scanf("%d %d", &n, &t), n|t) {
    test_case++;
    int sum = 0;
    REP(i, n) {
      scanf("%d %d %d", &m[i], &l[i], &k[i]);
      sum += m[i];
    }
    REP(iter, n) {
      if (calc(iter + 1, sum)) {
        printf("%d\n", iter + 1);
        goto next;
      }
    }
next:;
  }
}

Measured memory_bytes: 940
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {if (a > b) a = b;}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {if (a < b) a = b;}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 10050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


void solve() {
	string S, T; cin >> S >> T;
	int ans = 0;
	REP(i, S.size()) {
		if (S[i] != T[i])ans++;
	}
	print(ans);
}

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

	 //int q;
	 //cin >> q;
	 //while (q--)
	solve();
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii \                               
  ios_base::sync_with_stdio(false); \                                      
  cin.tie(NULL);  \
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}
 
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
 
 
 
int main(){
	adiii
	ll x;cin>>x;
	ll f=1;
	ll a1,a2;
	rep(a,0,2000){
		rep(b,-1*2000,a){
			if(binpow(a,5) - binpow(b,5) == x){f=0;a1=a;a2=b;break;}
		}
		if(f==0) break;
	}
	
	cout<<a1<<" "<<a2<<endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int mape[505][505];
int ans[505][505];
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	memset(mape,0,sizeof(mape));
	memset(ans,0,sizeof(ans));
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		mape[l][r]++;
	}
	for(int i=1;i<=500;i++){
		for(int j=1;j<=500;j++){
			ans[i][j]=ans[i][j-1]+mape[i][j]; 
			//cout<<ans[i][j]<<endl;
		}
	}
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		int now=0;
		for(int j=l;j<=r;j++){
			now+=ans[j][r];
		}
		cout<<now<<endl;
	}
} 

Measured memory_bytes: 2944
N = int(input())
P = [int(input()) for i in range(N)]

A = {}
for i, p in enumerate(P):
    A[p] = i

cnt = 1
res = 0
for i in range(1, N):
    if A[i] < A[i + 1]:
        cnt += 1
    else:
        res = max(res, cnt)
        cnt = 1
res = max(res, cnt)
print(N - res)

Measured memory_bytes: 34976
#include<stdio.h>
#include<stdlib.h>
int cmp(const int *a, const int *b){
  return *a - *b;
}
int gcd(int a, int b){
  return b?gcd(b,a%b):a;
}
int main(){
  int n,k,ans=0,m;
  scanf("%d%d",&n,&k);
  if(n==1){
    int x;
    scanf("%d",&x);
    puts(x-k?"IMPOSSIBLE":"POSSIBLE");
    return 0;
  }
  int a[111111];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i)m=gcd(a[i],a[i-1]);
  }
  qsort(a,n,4,cmp);
  for(int i=n-1;i>=0&&a[i]>=k;i--){
    if((a[i]-k)%m==0)ans=1;
    if(ans)break;
  }
  puts(ans?"POSSIBLE":"IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 892
a=[list(map(int,list(input().split()))) for i in range(3)]
n=int(input())
b = [int(input()) for _ in range(n)]

ans="No"
for i in range(3):
    #縦
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        ans="Yes"
        break
    #横
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        ans="Yes"
        break
#斜め
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        ans="Yes"
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
        ans="Yes"

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	VL v(n - 1);
	cin >> v;

	ll ans = *v.begin() + *v.rbegin();
	REP(i, n - 2) {
		ans += std::min(v[i], v[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);
		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int c = sc1.nextInt();

		if(a > 0 && a == b && b == c ) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

		sc1.close();

	}

}

Measured memory_bytes: 21972
#include <cstdio>
int n,y;
int main()
{
	scanf("%d%d",&n,&y);y/=1000;
	for(int i=0;i<=n;++i)
	for(int j=0;j<=n-i;++j)
		if(i+j*5+(n-i-j)*10==y){printf("%d %d %d\n",n-i-j,j,i);return 0;}
	printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
cnt = 0
if n == 1 and m == 1:
  corner = 0
  wall = 0
if n > 1 and m > 1:
  corner = 4
  wall = max(0, n-2) * 2 + max(0, m-2) * 2
if n == 1 and m > 1:
  corner = 2
  wall = 0
if n > 1 and m == 1:
  corner = 2
  wall = 0
print(n * m - corner - wall)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define MOD 1e9+7
#define lb lower_bound
#define ub upper_bound
#define dst distance
ll INF = 1e18;

int N;
ll A[201000],ans=INF,a,b,c,d,e,f,g,h;

ll query(ll a, ll b, ll c, ll d){
  //cout<<a<<' '<<b<<' '<<c<<' '<<d<<'\n';
  return max({a,b,c,d}) - min({a,b,c,d});
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt","r",stdin);
	cin>>N;
	for(int i =1;i<=N;++i){cin>>A[i];if(i)A[i] += A[i-1];} 
	for (int i =1;i<=N;++i){
		ll big = 0;
		ll small = INF;
		ll L = A[i]/2;

		auto it = ub(A+1,A+N+1,L);
		auto jt = --it;
		++it;
    a = *it;
    b = A[i] - *it;
    c = *jt;
    d = A[i] - *jt;

		L = (A[N] + A[i])/2;
		it = ub(A+1,A+N+1,L);
		jt = --it;
		++it;
		
		e = *it - A[i];
    f = A[N] - *it;
    g = *jt - A[i];
    h = A[N] - *jt;

    //cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<' '<<g<<' '<<h<<'\n';
    ans = min({ans, query(a,b,e,f), query(a,b,g,h), query(c,d,e,f), query(c,d,g,h)});
	}
	cout << ans;
}

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

using namespace std;

int main()
{
   long long n;
   cin>>n;
   map<string,long long>m;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       sort(s.begin(),s.end());
       ++m[s];
   }
 long long ans=0;
 for(auto it:m)
   {
       long long x=(it.second);
       ans+=(x*(x-1))/2;
   }
   cout<<ans<<endl;

   
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i, n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10632
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
            for(int j=i+1;j<s.size();j++){
                if(s[j]=='F'){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
long long t,p,s=0,a,i;
  cin >> t>>p;
for(i=0;i<p;i++){
cin>>a;
s+=a;
}
  if(s>t)cout<<-1;
  else cout<<t-s;
  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <math.h>

int s[10000];
int top=0;

int isEmpty(){
if(s[top]==0) return 1;
 else return 0;
}

void push(int x){
top++;
s[top]=x;
}

int pop(){
if(isEmpty()) {
fprintf(stderr,"under\n");
}
 else{
top--;
return s[top+1];
}

}

int main(){
char a[10000];
int x, y;

while(scanf("%s",a) != EOF){
if(a[0]=='+'){
push(pop()+pop());
}
 else if(a[0]=='-'){
x=pop();
y=pop();
push(y-x);
}
 else if(a[0]=='*'){
push(pop()*pop());
}
 else push(atoi(a));

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



Measured memory_bytes: 2144
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	map_search
# CreatedDate:  2020-07-15 11:12:11 +0900
# LastModified: 2020-07-15 11:20:15 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    q = int(input())
    dictionary = dict()
    for _ in range(q):
        command = list(input().split())
        if int(command[0]) == 0:
            dictionary[command[1]] = int(command[2])
        else:
            print(dictionary[command[1]])



if __name__ == "__main__":
    main()



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

int main() {
  long long n, t;
  long long l = 0;
  cin >> n >> t;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a - l < t)
      ans += a - l;
    else
      ans += t;
    l = a;
  }

  cout << ans + t;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    map<int, int> ma;
    vector<int> cnt(200005);//for all Ai
    rep(i,n){
        int a; cin >> a;
        cnt[a]++;
    }
    sort(RALL(cnt));
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += cnt[i];
    }
    cout << max(0, n-sum) << endl;
}

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

int main() {
int a[1000001]={};
int n=0;
cin>>n;
for(int i=1;i<=100;i++)
{
    for(int j=1;j<=100;j++)
    {
        for(int k=1;k<=100;k++)
        {
            a[(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i)]++;
        }
    }
}
 for(int i=1;i<=n;i++)cout<<a[i]<<endl;
}


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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

int main() {

    int X, N;
    cin >> X >> N;

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

    if(N == 0) {
        cout << X << endl;
        return 0;
    }

    int min = 100000;
    int result = -1;
    for(int i=-100; i<=101; i++) {
        if(find(p.begin(), p.end(), i) == p.end()) {
            int temp = abs(i - X);
            if(temp < min) {
                min = temp;
                result = i;      
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;


int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    if(n >= b - 1) cout << a * (b - 1) / b << endl;
    else cout << a * n / b << endl;
}


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

int main()
{
  long double x1;
  long double y1;
  long double x2;
  long double y2;
  long double dis;
  
  cin >> x1 >> y1 >>x2 >>y2;
  
  dis=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  
  cout << fixed << setprecision(5) << dis << "\n";
}

Measured memory_bytes: 1292
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    s64 h, w, k;
    cin >> h >> w >> k;

    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;
    vector< string > field(h);
    rep (i, h) cin >> field[i];

    const s64 inf = 1e18;
    s64 d[h][w];
    rep (i, h) rep (j, w) d[i][j] = inf;

    queue<P> q;
    q.emplace(si, sj);
    d[si][sj] = 0;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        auto from = q.front(); q.pop();
        s64 fi = from.first;
        s64 fj = from.second;
        rep (i, 4)
        {
            rep (j, k)
            {
                s64 ni = fi + dy[i] * (j + 1);
                s64 nj = fj + dx[i] * (j + 1);
                if (!(IN(0, h, ni) && IN(0, w, nj))) break;
                if (d[ni][nj] < d[fi][fj] + 1 || field[ni][nj] == '@') break;
                if (d[ni][nj] != inf) continue;
                d[ni][nj] = d[fi][fj] + 1;
                q.emplace(ni, nj);
            }
        }
    }

    s64 ans = d[ti][tj];
    if (ans == inf) cout << "-1\n";
    else cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 13288
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define maxn 10010
#define INFTY (1<<30)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
vector<pair<int,int> > adj[maxn]; //加权有向图的邻接表表示法

void dijkstra(int s)
{
    priority_queue<pair<int,int> > PQ;
    int color[maxn],d[maxn],p[maxn]; //p数组可以不要
    for(int i=0;i<n;i++)
    {
        color[i]=WHITE;
        d[i]=INFTY;
        p[i]=-1;
    }
    d[s]=0;
    PQ.push(make_pair(s,0));
    color[s]=GRAY;

    while(!PQ.empty())
    {
        pair<int,int> f=PQ.top();PQ.pop();
        int u=f.second;
        color[u]=BLACK;

        //if(d[u]<f.first*(-1)) continue; //去除最小值，如果不是最短路径就忽略

        for(int j=0;j<adj[u].size();j++)
        {
            int v=adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[v]>d[u]+adj[u][j].second)
            {
                d[v]=d[u]+adj[u][j].second;
                //优先级队列默认优先最大值，所以要乘以-1
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }

    for(int i=0;i<n;i++)
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
}
int main()
{
    int k,u,v,c;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra(0);
    return 0;
}


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

using namespace std;

#define int long long

const int mod = 1e9 + 7;
int n, x, y, z, dp[45][1 << 20], maxmask, needmask;

signed main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> x >> y >> z;
    maxmask = (1 << (x + y + z) );
    needmask = (1 << (z - 1) ) + (1 << (y + z - 1) ) + (1 << (x + y + z - 1) );
    dp[0][0] = 1;

    for (int i = 1; i <= n; ++i) {
        for (int mask = 0; mask <= maxmask; ++mask) {
            if(!dp[i - 1][mask]) continue;
            for (int nex = 1; nex <= 10; ++nex) {
                if(mask == maxmask) {
                    dp[i][mask] += dp[i - 1][mask]; dp[i][maxmask] %= mod;
                    continue;
                }
                int nmask = ( (mask << nex) | (1 << (nex - 1) ) ) & (maxmask - 1);
                if( (nmask & needmask) == needmask) nmask = maxmask;
                dp[i][nmask] += dp[i - 1][mask]; dp[i][nmask] %= mod;
            }
        }
    }

    cout << dp[n][maxmask];

    return 0;
}


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

#define REP(i,a,b) for(int i=a;i<(b);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

bool dp[100010];

vector<string> vt = {
  "dream",
  "dreamer",
  "erase",
  "eraser",
};

int main() {
  string s; cin >> s;
  int N = s.size();
  dp[0] = 1;
  rep(i, N) {
    if (!dp[i]) { continue; }
    rep(j, vt.size()) {
      int n = vt[j].size();
      if (i + n > N) { continue; }
      bool f = 1;
      rep(k, n) {
        if (s[i + k] != vt[j][k]) {
          f = 0;
          break;
        }
      }
      dp[i + n] |= f;
    }
  }
  cout << (dp[N] ? "YES" : "NO") << "\n";
}


Measured memory_bytes: 512
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  const usize n = scan<usize>();
  std::vector<u64> a(n + 1_z), b(n);
  for (auto &e : a) {
    std::cin >> e;
  }
  for (auto &e : b) {
    std::cin >> e;
  }
  u64 ans = static_cast<u64>(0);
  for (const auto i : rep(0_z, n)) {
    const u64 l = std::min(a[i], b[i]);
    a[i] -= l;
    b[i] -= l;
    ans += l;
    const u64 r = std::min(a[i + 1_z], b[i]);
    a[i + 1_z] -= r;
    b[i] -= r;
    ans += r;
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int tab[60][60][60], i, j, k, a, b, c;

int go(int a, int b, int c) {
	if (a == b && a == c) return 0;
	if (a > 55 || b > 55 || c > 55) return INF;
	if (tab[a][b][c] != -1) return tab[a][b][c];
	int minn = INF;
	minn = min(minn, go(a+1, b+1, c));
	minn = min(minn, go(a+1, b, c+1));
	minn = min(minn, go(a, b+1, c + 1));
	minn = min(minn, go(a+2, b, c));
	minn = min(minn, go(a, b+2, c));
	minn = min(minn, go(a, b, c+2));
	if (minn != INF) minn += 1;
	tab[a][b][c] = minn;
	return minn;
}

int main() {
scanf("%d %d %d", &a, &b, &c);
for (i=0;i<=55;i++) for (j=0;j<=55;j++) for(k=0;k<=55;k++) tab[i][j][k] = -1;
printf("%d\n", go(a, b, c));
return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>

using namespace std;

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

    int cnt = 0;
    
    for(int i = 0; i < q; i++){
        int tmp;
        scanf("%d", &tmp);
        for(int j = 0; j < n; j++){
            if(s[j] == tmp){
                cnt++;
                break;
            }
        }
    }

    printf("%d\n", cnt);
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int idx[26];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin >> s >> t;
  ll cnt[s.size()][26];
  memset(cnt,0,sizeof(cnt));
  int n = s.size();
  vector<int> alpha[26];
  rep(i,n){
    alpha[s[i] - 'a'].push_back(i);
  }
  int prev = -1;
  ll ans = 0;
  rep(i,t.size()){
    if(alpha[t[i] - 'a'].size() == 0){
      cout << -1 << "\n";
      return 0;
    }
    int tch = t[i] - 'a';
    int nidx;
    if(upper_bound(all(alpha[tch]),prev) == alpha[tch].end()){
      nidx = alpha[tch][0];
    }else{
      nidx = *upper_bound(all(alpha[tch]),prev);
    }
    if(prev < nidx) ans += nidx - prev;
    else ans += (s.size()-prev) + nidx ;
    // cerr << ans << " " << nidx << endl;
    prev = nidx;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 21456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    int64_t a, b, x;
    cin >> a >> b >> x;
    // [0, b] - [0, a-1] = [a,b]
    int64_t ans = (b/x);
    if(a > 0) {
        ans -= (a-1)/x;
    } else {
        // including 0
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
 
public class Main {
    static char[] cl = {'3','5','7'};
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        int len = String.valueOf(n).length();
        int[] used = new int[3];
        System.out.println(dfs(len,0,n,"",used));
    }
    
    private static long dfs(int len, int digit, long max, String s, int[] used){
        if(len == digit){
            if(Long.parseLong(s) <= max && used[0] >= 1 && used[1] >= 1 && used[2] >= 1){
                return 1;
            }else{
                return 0;
            }
        }
        long ret = used[0] >= 1 && used[1] >= 1 && used[2] >= 1 ? 1 : 0;
        int i = 0;
        for(char c : cl){
            used[i]++;
            ret += dfs(len,digit+1,max,s+c,used);
            used[i]--;
            i++;
        }
        return ret;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 26068
#include <stdio.h>

int main(){
  int a[100];
  int n,s=0;

  scanf("%d",&n);

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

s+=a[0];

for (int i = 0;i < n-2;i++){
  if(a[i]>a[i+1])
  s+=a[i+1];
  else
  s+=a[i];
}
s+=a[n-2];
  printf("%d",s);
  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
five = 0
seven = 0
a = map(int, raw_input().split())
for i in a:
    if i == 5:
        five = five + 1
    if i == 7 :
    	seven = seven + 1

if five == 2 and seven == 1:
	print "YES"
else:
	print "NO"



Measured memory_bytes: 2568
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
// dp[i][j] is the minimum cost incurred had the array been arr[i->j]
ll sum(ll lef, ll rig, vl &a)
{
	ll s=0;
	for(ll i=lef; i<=rig; i++)
	{
		s+=a[i];
	}
	return s;
}
void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    forr(i, n)
    {
    	cin>>a[i];
    }
    vector<vl> dp(n, vl(n, (ll)1e18));
    forr(i, n)
    {
    	forr(j, n)
    	{
    		if(i>=j)
    			dp[i][j]=0;
    	}
    }
    for(ll i=n-2; i>=0; i--)
    {
    	for(ll j=i+1; j<=n-1; j++)
    	{
    		for(ll k=i; k<=j-1; k++)
    		{
    			ll s=sum(i, j, a);
    			dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+s);
    		}
    	}
    }
    cout<<dp[0][n-1]<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;

int main()
{
	int N, C, K;
	int ans = 0;
	cin >> N >> C >> K;

	vector<int> T(N);
	for (int i = 0;i < N;i++)
	{
		cin >> T[i];
	}

	sort(T.begin(), T.end());

	for (int i = 0;i < N;i++)
	{
		int j = i + 1;
		int count = 1;
		ans++;

		while (j < N && count < C)
		{
			if (T[j] <= T[i] + K && T[i] + K <= T[j] + K)
			{
				count++;
				j++;
			}
			else
				break;
		}

		i = j - 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n;

bool is_prime(int x){
    for(int i=2; i*i<x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

signed main(void){
    cin >> n;
    for(int i=n; i<10*n; i++){
        if(is_prime(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	int ans = 0;
	cin >> n;
	rep(i, n){
		int in;
		cin >> in;
		while(in % 2 == 0){
			ans++;
			in /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int n, a[200005];

int main(){
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	long long res = 0;
	long long sum = 0;
	int p = -1;
	
	for(int i = 0; i < n; i++){
		while(p + 1 < n && ((sum ^ a[p + 1]) == (sum + a[p + 1]))){
			p++;
			sum += a[p];
		}
		
		res += (p - i + 1);
		sum -= a[i];
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <queue>
#include <cstring>

using namespace std;

int main()
{
	int n;
	int ans[100], intime[100];
	int chair[17];
	
	queue<int> q;
	memset(chair, -1, sizeof(chair));
	
	int time = 0;
	while (1){
		if (time % 5 == 0) q.push(time / 5);
		
		for (int i = 0; i < 17; i++){
			int y = chair[i];
			if (y == -1) continue;
			if (time - intime[y] == 17 * (y % 2) + 3 * (y % 3) + 19)
				chair[i] = -1;
		}
		
		rep:;
		if (q.size() > 0){
			int x = q.front();
			int num;
			num = 2 + 3 * (x % 5 == 1);
			
			for (int i = 0; i <= 17 - num; i++){
				bool ok = true;
				for (int j = i; j < i + num; j++)
					if (chair[j] != -1) ok = false;
				if (ok){
					intime[x] = time; ans[x] = time - x * 5;
					if (x == 99) goto end;
					q.pop();
					for (int j = i; j < i + num; j++)
						chair[j] = x;
					goto rep;
				}
			}
		}
		time++;
	}
	end:;
	while (~scanf("%d", &n)) printf("%d\n", ans[n]);
	return (0);
}

Measured memory_bytes: 1032
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Vector;

public class Main extends Thread {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		System.out.println(Math.min(b, n * a));
	}

}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
namespace 令和{
    class ABC{
        static void Main(){
            int n = int.Parse(Console.ReadLine());
            //bool[] isEven = new bool[n-1];
            List<int[]>[] tonari = new List<int[]>[n+1];
            int[] ans = new int[n+1];
            for(int i=0;i<n+1;i++){
                tonari[i] = new List<int[]>();
                ans[i] = -1;
            }
            int u,v,w;
            for(int i=1;i<n;i++){
                string[] uvw = Console.ReadLine().Split();
                u = int.Parse(uvw[0]);
                v = int.Parse(uvw[1]);
                w = int.Parse(uvw[2]);
                tonari[u].Add(new int[2]{v,w});
                tonari[v].Add(new int[2]{u,w});
                /*
                if(w[i]%2==0){
                    isEven[i] = true;
                }else{
                    isEven[i] = false;
                }
                */
            }
            Queue<int> q = new Queue<int>();
            q.Enqueue(1);
            ans[1] = 0;
            while(q.Count!=0){
                int p = q.Dequeue();
                foreach(int[] tnr in tonari[p]){
                    if(ans[tnr[0]]==-1){
                        ans[tnr[0]] = (tnr[1]+ans[p])%2;
                        q.Enqueue(tnr[0]);
                    }
                }
            }
            for(int i=0;i<n;i++){
                Console.WriteLine(ans[i+1]);
            }
 
 
        }
    }
}

Measured memory_bytes: 38944
n = int(input())

s = ''
while (n > 0):
    r = n % 26

    if r == 0:
        s = 'z' + s
        n = (n - 26) // 26
    else:
        c = chr((r - 1) + ord('a'))
        s = c + s
        n //= 26

print(s)

Measured memory_bytes: 9204
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String[] s = new String[2];
        s[0] = fs.next();
        s[1] = fs.next();
        if (s[0].charAt(0) == s[1].charAt(2) && s[0].charAt(1) == s[1].charAt(1) && s[0].charAt(2) == s[1].charAt(0))
            System.out.println("YES");
        else
            System.out.println("NO");
    }

}


Measured memory_bytes: 83412
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

#define lint long long int
#define INF 99999999



int main()
{
    int n, ans=0;
    lint l[100];
    
    cin >> n;
    for (int i = 0; i < n; i++) cin >> l[i];
    
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i] &&
                    l[i]+l[j] > l[k] && l[j]+l[k] > l[i] && l[k]+l[i] > l[j]) ans++;
            }
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 3588
#include <stdio.h>

int main(void) {
	int i,ii, n, b, f, r, v,A1[3][10]={0},A2[3][10]={0},A3[3][10]={0},A4[3][10]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		switch(b){
			case 1:
			A1[f-1][r-1] += v;
			break;
			case 2:
			A2[f-1][r-1] += v;
			break;
			case 3:
			A3[f-1][r-1] += v;
			break;
			case 4:
			A4[f-1][r-1] += v;
			break;
		}
	}
	for(i=0;i<3;i++){
		for(ii=0;ii<10;ii++) printf("%2d",A1[i][ii]);
		printf("\n");
	}
	printf("####################\n");
		for(i=0;i<3;i++){
		for(ii=0;ii<10;ii++) printf("%2d",A2[i][ii]);
		printf("\n");
	}
	printf("####################\n");
		for(i=0;i<3;i++){
		for(ii=0;ii<10;ii++) printf("%2d",A3[i][ii]);
		printf("\n");
	}
	printf("####################\n");
		for(i=0;i<3;i++){
		for(ii=0;ii<10;ii++) printf("%2d",A4[i][ii]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  vector<ll> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll K; cin >> K;
  cout << v[K-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 101;
const int K = 1e5 + 1;
int dp[2][K];
int a[N];
int n, k;

int dynamic(int turn, int left)
{
    if (dp[turn][left] != -1)
        return dp[turn][left];
    int ans = 0;
    if (turn == 0)
    {
        ans = -11;
        for (int i = 0; i < n; i++)
        {
            if (left >= a[i])
                ans = max(ans, dynamic(!turn, left - a[i]));
        }
    }
    if (turn == 1)
    {
        ans = 11;
        for (int i = 0; i < n; i++)
        {
            if (left >= a[i])
                ans = min(ans, dynamic(!turn, left - a[i]));
        }
    }
    dp[turn][left] = ans;
    return ans;
}

void solve()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    mem1(dp);
    if (dynamic(0, k)>0)
    {
        cout << "First" << endl;
    }
    else
        cout << "Second" << endl;

}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMAX(a,b) (a)=max((a),(b))
#define CHMIN(a,b) (a)=min((a),(b))

#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

int n;
int x[125],y[125],h[125];

int main(){
	cin>>n;
	REP(i,n)cin>>x[i]>>y[i]>>h[i];
	REP(cx,101)REP(cy,101){
		int hmax = (1<<30) + (1<<29);
		int hmin = -1;
		REP(i,n){
			int sa = abs(x[i]-cx)+abs(y[i]-cy);
			if(h[i]==0){
				CHMIN(hmax, sa);
			}else{
				CHMAX(hmin, h[i]+sa);
				CHMIN(hmax, h[i]+sa);
			}
		}
		if(hmax==hmin){
			printf("%d %d %d\n",cx,cy,hmin);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256