akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main() {
	int N, i, j, num = 0, a;
	int A[100000];
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		for (j = 0; j < N; j++) {
			if (A[i] < A[j]) {
				num = A[i];
				A[i] = A[j];
				A[j] = num;
			}
		}
	}
	a = A[N - 1] - A[0];
	printf("%d", a);
	/*for (i = 0; i < N; i++) {
		printf("%d ", A[i]);
	}*/
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    String input1 = scanner.next();
    String input2 = scanner.next();
    int a = Integer.parseInt(input1);
    int b = Integer.parseInt(input2);
    int c = (a-1) * (b-1);

    System.out.println(c);
    scanner.close();
  }
}

Measured memory_bytes: 22228
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

import numpy as np
x = np.array(x)

counter = 0
for i in range(n):
    y = x[i]
    for j in range(n):
        z = x[j]
        if j != i:
            dist = np.sqrt(np.sum((y - z) ** 2))
            if dist == int(dist):
                counter += 1

print(int(counter / 2))


Measured memory_bytes: 21892
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int n, m;
vector<int> x, xs;
int ret = 0;
int main(void) {
	cin >> n >> m;
	if (n > m) {
		cout << ret << endl;
	}
	else {
		for (size_t i = 0; i < m; i++) {
			int xi;
			cin >> xi;
			x.push_back(xi);
		}
		sort(x.begin(), x.end());
		ret = x.back() - x.front();
		for (size_t i = 0; i < m - 1; i++) {
			xs.push_back(x[i + 1] - x[i]);
		}
		sort(xs.begin(), xs.end());
		ret -= accumulate(xs.end() - n + 1, xs.end(), 0);
		cout << ret << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  rep(i, n) cin >> a[i + 1];

  vector<int> b(n + 1);
  for (int i = n; i >= 1; i--) {
    int sum = 0;
    for (int j = i + i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum ^ a[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (int i : ans) cout << i << endl;
  return 0;
}

Measured memory_bytes: 3064
n, k = map(int, input().split())
li_a = list(map(int, input().split()))
mod = 10**9+7
li = []
lll = 0
for i in li_a:
    if i < 0:
        li.append((abs(i), -1))
        lll += 1
    elif i == 0:
        li.append((0, 0))
    else:
        li.append((i, 1))
li.sort()
if lll == n:
    ans = 1
    if k %2 ==1:
        for i in range(k):
            ans *= -li[i][0]
            ans %= mod
        print(ans)
        exit()
    else:
        for i in range(k):
            ans *= li[n-1-i][0]
            ans %= mod
        print(ans)
        exit()
ans = 1
guki = 1
for i in range(n-1, n-k-1, -1):
    ans *= li[i][0]
    ans %= mod
    guki *= li[i][1]
if guki > 0:
    print(ans)
else:
    P, M, p, m = 10**6, 1000000, 1000000, 1000000
    P1, M1, p1, m1 = True, True, True, True
    for i in range(n-k, n):
        if li[i][1] > 0:
            Plus = li[i][0]
            P = i
            P1 = False
            break
    for i in range(n-k, n):
        if li[i][1] < 0:
            Mini = li[i][0]
            M = i
            M1 = False
            break
    if n-k-1 >= 0:
        for i in range(n-k-1, -1, -1):
            if li[i][1] >= 0:
                plus = li[i][0]
                p = i
                p1 = False
                break
        for i in range(n-k-1, -1, -1):
            if li[i][1] <= 0:
                mini = li[i][0]
                m = i
                m1 = False
                break
    ans1 = 1
    ans2 = 1
    if (not P1) and (not m1):
        for i in range(n-1, n-k-1, -1):
            if i == P:
                continue
            ans1 *= li[i][0]
            ans1 %= mod
        ans1 *= li[m][0]
        ans1 %= mod
    if (not p1) and (not M1):
        for i in range(n-1, n-k-1, -1):
            if i == M:
                continue
            ans2 *= li[i][0]
            ans2 %= mod
        ans2 *= li[p][0]
        ans2 %= mod
    if (not p1) and (not P1) and (not M1) and (not m1):
        if mini*Mini > plus*Plus:
            print(ans1)
        else:
            print(ans2)
    elif (not p1) and (not M1):
        print(ans2)
    elif (not m1) and (not P1):
        print(ans1)
    else:
        ans = 1
        for i in range(k):
            ans *= li[i][0]
            ans %= mod
        ans *= -1
        ans %= mod
        print(ans)


Measured memory_bytes: 112864
#include <iostream>
using namespace std;
int main()
{
	int n,a,sum=0;
	cin>>n;
	a=n;
	while (a!=0)
	{
		sum+=a%10;
		a/=10;
	}
	if (n%sum==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;	
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N;
	cin >> N;
 
	// 解法
	int base[100] = {0};
	int absN = abs(N);
	
	int amari = 0;
	int i = 0;
	while (absN > 0) { // n が 0 になるまで
		amari = absN%2;
		if (amari==1){
			base[i] = 1;
			if (N>0 && i%2==1){
				absN = absN/2+1;
			}
			else if (N<0 && i%2==0){
				absN = absN/2+1;
			}
			else{
				absN = absN/2;
			}
		}
		else{
			absN = absN/2;
		}
		++i;
	}
	if (N==0) cout << 0 << endl;
	else{
		for (int k = 0; k < i; ++k) {
			cout << base[i-k-1];
		}
		cout << endl;
	}
	
}
 


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9+7;
	char[] s;
	int N;

	public void solve(){
		s = next().toCharArray();
		N = s.length;

		int ans = INF;

		for(int i = 0;i < 26;i++){

			List<Integer> list = new ArrayList<>();
			list.add(-1);
			for(int j = 0;j < N;j++){
				if(s[j] == 'a' + i){
					list.add(j);
				}
			}

			if(list.size() == 1)continue;

			int max = 0;
			for(int j = 0;j < list.size()-1;j++){
				max = Math.max(max,list.get(j+1)-list.get(j)-1);
			}
			max = Math.max(max,N - list.get(list.size()-1)-1);
			ans = Math.min(ans,max);
		}

		out.println(ans == INF ? 0 : ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

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

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

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

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

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

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

using namespace std;

int main()	{
  string a, b;
  cin >> a >> b;
  string c = a + b;
  int j = 0, k = 0;
  for (int i = 0; i < a.length() + b.length(); i++)	{
    if (i % 2 == 0)	{
      c[i] = a[j];
      j++;
    }
    else	{
      c[i] = b[k];
      k++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,y; cin >> n >> y;
    for(int ty = 0;ty <= n;++ty){
        for(int tz = 0;ty + tz <=n;tz++){
            if(10*n -5*ty - 9*tz == y/1000){
                cout << n-tz-ty << " " << ty << " " << tz << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    REP(i, n){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    if(n <= k){
        cout << 0 << endl;
    }
    else{
        cout << accumulate(h.begin(), h.begin()+(n-k), 0LL) << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <algorithm>
int main()
{
    int N,L,i;
    scanf("%d %d",&N,&L);
    int a[N],ab[N];
    for(i=0;i<N;i++)
    {
        a[i]=L+i;
        ab[i]=abs(L+i);
    }
    int *m=std::min_element(ab,ab+N);
    int s=0;
    for(i=0;i<N;i++)
    {
        if(i!=m-ab)s+=a[i];
    }
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n ;
	vector<int> x(n);
	rep(i, n) cin >>x[i];
	sort(x.begin(), x.end());
	int maX= MOD;
	rep2(i, x[0], x[n-1] + 1) {
		int sum = 0;
		rep(j, n) sum += (x[j] - i)*(x[j] - i);
			maX = min(maX, sum);
	}
	cout << maX;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
#define SEG_LEN (1 << 20)
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
template <class T>
class segment_tree_Max{
  private:
    vector<long long>seg;
    int seg_size = SEG_LEN * 2;
  public:
    segment_tree_Max(){
      seg.resize(seg_size);
      for(int i = 0; i < seg_size; i++)seg[i] = -INF;
    }
    void update(int ind,int n){
      ind += SEG_LEN;
      seg[ind] = n;
      while(true){
        ind /= 2;
        if(ind == 0)break;
        seg[ind] = max(seg[ind * 2],seg[ind * 2 + 1]);
      }
    }
    long long Max(int l,int r){
      l += SEG_LEN;
      r += SEG_LEN + 1;
      long long ans = -INF;
      while(l < r){
        if(l % 2 == 1){
          ans = max(seg[l],ans);
          l++;
        }
        if(l >= r)break;
        l /= 2;
        if(r % 2 == 1){
          ans = max(seg[r - 1],ans);
          r--;
        }
        r /= 2;
      }
      if(ans == -INF)return 0;
      return ans;
    }
}; 
int main(){
  int n,q;
  string s;
  cin >> n >> s >> q;
  vector<segment_tree_Max<ll>>seg(26);
  rep(i,n)seg[s[i] - 'a'].update(i,1);
  rep(i,q){
    int type;
    cin >> type;
    if(type == 1){
      int ind;
      char c;
      cin >> ind >> c;
      ind--;
      seg[s[ind] - 'a'].update(ind,0);
      seg[c - 'a'].update(ind,1);
      s[ind] = c;
    }
    if(type == 2){
      ll tmp = 0;
      int l,r;
      cin >> l >> r;
      l--,r--;
      rep(j,26)tmp += seg[j].Max(l,r);
      cout << tmp << endl;
    }
  }
  return 0;
}
 

Measured memory_bytes: 427012
#include <stdio.h>
#include <stdlib.h>
#define true 1

int main(void)
{
    int a=0;
    long int sum=0;

    while(true){
        a=getchar();
        a-=48;
        if(a>=0 && a<10){
            sum+=a;
        } else {
            break;
        }
    }

    if(sum%9==0){
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 1588
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll a[n];
  ll lon =0;
  rep(i,n){
    cin >> a[i];
    lon+=a[i]; 
  }
  ll mimi = INF;
  ll pon = 0;
  rep(i,n){
    pon+=a[i];
    mimi = min(mimi,abs(lon-pon-pon));
  }
  pri(mimi);

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    int n; cin>>n;
    double ans = 0;
    rep(i,n){
        double x; string u; cin>>x>>u;
        if(u=="JPY") ans += x;
        else ans += x * 380000;
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<double> d;
    long double ans=0;
    for(int i=1;i<=n;i++){
        int a=0,b=i,c=1;
        while(b<k){
            b*=2;
            a++;
        }
        for(int k=0;k<a;k++)
        c*=2;
        d.push_back(n*c);
    }
    for(int i=0;i<d.size();i++){
        ans+=1/d[i];
    }
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

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

int main(){
    int i, j, k;
    long int N;
    int s[12];
    int n3, n5, n7;
    long int num, tmp;
    long int ans = 0;
    long int power = 0;

    for(i=0; i<12; i++){
        s[i] = 0;
    }

    scanf("%ld", &N);

    for(i=0; i<1000000; i++){
        s[0] += 1;
        num = 0;
        tmp = 0;
        n3=0; n5=0; n7=0;
        power = 1;
        for(j=0; j<11; j++){
            if(s[j] == 4){
                s[j] = 1;
                s[j+1] += 1;
            }
            if(s[j] == 1){
                num += 3*power;
                n3 += 1;
            }else if(s[j] == 2){
                num += 5*power;
                n5 += 1;
            }else if(s[j] == 3){
                num += 7*power;
                n7 += 1;
            }
            tmp += s[j] *power;
            power = power * 10;
        }
        if(num > N){
            break;
        }
        if(n3*n5*n7 > 0){
            ans += 1;
        }
    }

    printf("%ld", ans);

    return 0;
}

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

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

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

  int sum = 0;
  int j, k;
  for(j = 0; j < N; j++)
    {
      for(k = j+1; k < N; k++)
	{
	    sum += d[j]*d[k];
	}
    }
  cout << sum << endl;

  return 0;
}
  


Measured memory_bytes: 256
// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#include <set>
void solve() {
  string s;
  cin >> s;
  int n = s.size();
  loop(i,0,n) {
    if (i==3) cout << 8;
    else cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 3552
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    score = 0
    input_raw = read_func().strip().split()
    for i in range(N - 1):
        XL = int(input_raw[i])
        XR = int(input_raw[i + 1])
        if A*(XR - XL) < B:
            score += A*(XR - XL)
        else:
            score += B
    print score


if __name__ == '__main__':
    main()

Measured memory_bytes: 11556
#include <bits/stdc++.h>
#pragma GCC optimize 03
#pragma GCC optimize ("unroll-loops")
#define int long long
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N = 3e5 + 2e5;
const int inf = 2e9;
const int MOD = 998244353;
const int LogN = 30;

void solve() {
    int D, T, S;
    string s, t;
    cin >> t >> s;
    int ans = inf;
    for (int i = 0; i <= t.size() - s.size(); ++i) {
        int sum = 0;
        for (int j = 0; j < s.size(); ++j)
        if (s[j] != t[i + j])
            ++sum;
        ans = min(ans, sum);
    }
    cout << ans;
}

signed main() {
    #ifdef local
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0);
    solve();
}


Measured memory_bytes: 3684
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int M = Integer.parseInt(scanner.nextLine().split(" ")[1]);
        long[] nums = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
        long[] cSum = new long[nums.length + 1];
        Map<Long, Long> m = new HashMap<>();
        m.put(0L, 1L);
        long ans = 0;
        for (int i = 1; i < nums.length + 1; i++) {
            cSum[i] += cSum[i - 1] + nums[i - 1];
            long rem = cSum[i] % M;
            ans += m.getOrDefault(rem, 0L);
            m.put(rem, m.getOrDefault(rem, 0L) + 1);
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 59192
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int n,m;
  cin>>n>>m;
  int a[n][m];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cin>>a[i][j],a[i][j]--;
  int l=0,r=n;
  while(l+1<r){
    int x=(l+r)/2;
    int cnt[m],pos[n];
    memset(cnt,0,sizeof(cnt));
    memset(pos,0,sizeof(pos));
    for(int i=0;i<n;i++) cnt[a[i][pos[i]]]++;
    priority_queue<P> q;
    for(int i=0;i<m;i++) q.push(P(cnt[i],i));
    bool used[m];
    memset(used,0,sizeof(used));
    while(!q.empty()){
      if(q.top().first<=x) break;
      P p=q.top();q.pop();
      int u=p.second;
      if(used[u]) continue;
      //cout<<x<<":"<<u<<" "<<cnt[u]<<endl;
      used[u]=1;
      cnt[u]=0;
      for(int i=0;i<n;i++){
	while(pos[i]<m&&used[a[i][pos[i]]]){
	  pos[i]++;
	  if(pos[i]<m){
	    int k=a[i][pos[i]];
	    cnt[k]++;
	    q.push(P(cnt[k],k));
	  }
	}
      }
    }
    //cout<<q.size()<<endl;
    bool flg=0;
    while(!q.empty()){
      P p=q.top();q.pop();
      //cout<<p.first<<" "<<p.second<<endl;
      if(!used[p.second]) flg=1;
    }
    if(flg) r=x;
    else l=x;
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll a[310][310];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll h, w, d, q;
	cin >> h >> w >> d;
	vector<pair<ll, ll>>num(90010);
	vector<ll>num2(90010);
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			num[a[i][j]] = make_pair(i, j);
		}
	}
	for (ll i = h * w-d;i >= 1;--i) {
		num2[i] = num2[i + d] + abs(num[i].first - num[i + d].first) + abs(num[i].second - num[i + d].second);
	}
	cin >> q;
	rep(i, q) {
		ll x, y;
		cin >> x >> y;
		ll ans = num2[x] - num2[y];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 6164
N,M=[int(x) for x in input().split()]
A=[]
B=[]
C=[]

for i in range(M):
	a,b,c=[int(x) for x in input().split()]
	A.append(a-1)
	B.append(b-1)
	C.append(-c)
INF=10000000000000
dist=[INF for i in range(N)]

dist[0]=0


for temp in range(N-1):
	for i in range(M):
		if dist[A[i]]!=INF:
			if dist[B[i]]>dist[A[i]]+C[i]:
				dist[B[i]]=dist[A[i]]+C[i]

checker=[0 for i in range(N)]
ans=dist[N-1]

for temp in range(N):
	for i in range(M):
		if dist[A[i]]!=INF:
			if dist[B[i]]>dist[A[i]]+C[i]:
				dist[B[i]]=dist[A[i]]+C[i]
				checker[B[i]]=1
			if checker[A[i]]==1:
				checker[B[i]]=1

if checker[N-1]==1:
	print("inf")
else:
	print(-ans)


Measured memory_bytes: 48344
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int a;
  cin >> a;
  int S[10];
  for (int i = 0; i < 4; i++) {
    S[i] = a/pow(10, 3-i);
    a = a - S[i]*pow(10, 3-i); 
  }
  string res ="AMBIGUOUS";
  if (S[0]* 10 + S[1] > 12 || S[0] + S[1] == 0) {
    res = "YYMM";
    if (S[2]* 10 + S[3] > 12 ||  S[2] + S[3] == 0 ) {
      res = "NA";
    }
  }
  else
  if (S[2]* 10 + S[3] > 12 || S[2] + S[3] == 0) {
        res = "MMYY";
        if (S[0]* 10 + S[1] > 12 ||  S[0] + S[1] == 0 ) {
          res = "NA";
        }
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

signed main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	REP(i, n) {
		scanf("%d", &p[i]);
	}

	sort(ALL(p),greater<int>());

	int a = 0, b = 0;

	REP(i, n) {
		if (i % 2 == 0) {
			a += p[i];
		}
		else {
			b += p[i];
		}
	}
	cout << a - b << endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, a, b) for (auto i = (a); i < (b); i++)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  cout << (k <= a ? k : k <= a + b ? a : a - (k - a - b)) << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int main() {
  int n, T;
  cin >> n >> T;
  int ans=INF;
  for(int i=0; i<n; i++) {
    int a,b;
    cin >> a >> b;
    if(b<=T && ans>a) {
      ans=a;
    }
  }
  if(ans<INF) cout << ans << endl;
  else cout << "TLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a,b,c;
  vector<int> t(100010),x(100010),y(100010);
  t[0]=0; x[0]=0; y[0]=0;
  for(int i=1;i<=N;i++){cin >> t[i] >> x[i] >> y[i];}
  string ans="Yes";
  for(int i=0;i<N;i++){
    a=t[i+1]-t[i]; b=abs(x[i+1]-x[i]); c=abs(y[i+1]-y[i]);
    if(a<b+c){ans="No";}
    if((a-b-c)%2==1){ans="No";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> T(N),A(N);
    rep(i,N) cin >> T[i];
    rep(i,N) cin >> A[i];

    vector<ll> M(N),m(N);
    M[0] = m[0] = T[0];
    for (int i = 1; i < N; i++) {
        if (T[i] != T[i-1]) M[i] = m[i] = T[i];
        else {
            M[i] = M[i-1];
            m[i] = 1;
        } 
    }
    chmin(M[N-1],A[N-1]);
    chmax(m[N-1],A[N-1]);
    for (int i = N-2; i >= 0; i--) {
        if (A[i] != A[i+1]) {
            chmin(M[i],A[i]);
            chmax(m[i],A[i]);
        } else chmin(M[i],A[i]);
    }

    mint ans = 1;
    rep(i,N) {
        if (m[i] > M[i]) ans = 0;
        else ans *= (M[i] - m[i] + 1);
    }

    cout << ans.a << endl;
}

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

string strsort(string str){
    for(int i=0; str[i]!=0; i++){
		for(int j=i+1; str[j]!=0; j++){
			if(str[i]>str[j]){
				char a = str[i];
				str[i] = str[j];
				str[j] = a;
			}
		}
	}
    return str;
}

int main(void){
    int N;
    cin >> N;
    string s;
    map<string,int> all;
    unsigned long long sum=0;
    for(int i=0;i<N;i++){
        cin >> s;
        s = strsort(s);
        if(all.count(s) != 0) {
            sum += all[s];
            all[s] += 1;
        } else {
            all[s] = 1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(string, s);
    if (s[2] == s[3] && s[4] == s[5]) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define INF 1ll<<60

using namespace std;
int main(){
	ll N;
  cin >> N;
  vector<ll> h(N);
  for(ll i=0;i<N;i++){
  	cin >> h[i];
  }
  vector<ll> dp(N);
  for(int i=0;i<N;i++){
    dp[i]=INF;
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
  	dp[i]= min(dp[i-1]+abs(h[i]-h[i-1]),dp[i]);
    dp[i]= min(dp[i-2]+abs(h[i]-h[i-2]),dp[i]);
  }
  cout << dp[N-1] << endl;
}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    int ans = n;
    rep(i,n-1){
        if(s[i] != s[i+1]){
            chmin(ans, max(i+1,n-i-1));
        }
    }
    cout << ans << "\n";
}

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

const long long int MOD = 1e9+7;
#define pb push_back
typedef long long ll;
const long long int N = 1e6;

int main(){
    int n;
    cin>>n;
    int dp[n+5][3];
    for(int i=0;i<=n;i++){
        for(int j=0;j<3;j++) dp[i][j]=0;
    }
    // vector<int> dp(n+5, vector<int>(3,0));
    vector<int> a(n+5),b(n+5),c(n+5);
    a[0]=b[0]=c[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    // dp[1][0]=a[1];
    // dp[1][1]=b[1];
    // dp[1][2]=c[1];
    for(int i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
        // cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";
    }

    int ans = max({dp[n][1],dp[n][2],dp[n][0]});
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5648
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: String = sc.get();
    let N = S.len();
    let mut dp = vec![false; N+1];
    dp[0] = true;
    let tokens = vec!["dream", "dreamer", "erase", "eraser"];
    for i in 0..N {
        for &t in &tokens {
            if i+t.len() <= N && &S[i..i+t.len()] == t {
                dp[i+t.len()] |= dp[i];
            }
        }
    }
    if dp[N] {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int64_t> P(A), Q(B), R(C);
  for (int i = 0; i < A; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> Q[i];
  }
  for (int i = 0; i < C; i++) {
    cin >> R[i];
  }
  sort(P.begin(), P.end(), greater<int64_t>());
  sort(Q.begin(), Q.end(), greater<int64_t>());
  sort(R.begin(), R.end(), greater<int64_t>());
  priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq;
  for (int i = 0; i < X; i++) {
    pq.push(P[i]);
  }
  for (int i = 0; i < Y; i++) {
    pq.push(Q[i]);
  }
  for (int i = 0; i < C; i++) {
    if (pq.top() < R[i]) {
      pq.pop();
      pq.push(R[i]);
    }
  }
  int64_t res = 0;
  while (!pq.empty()) {
    res += pq.top();
    pq.pop();
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 4852
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX_N 1000
int X[MAX_N][MAX_N], dist[MAX_N][MAX_N], W, H, gx, gy; char c;
int main() {
	while (true) {
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < MAX_N; j++) {
				X[i][j] = 1000000000;
				dist[i][j] = 1000000000;
			}
		}
		cin >> W >> H; queue<pair<int, int>>Q;
		if (W == 0 && H == 0) { break; }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> c;
				if (c == '&') { gx = i; gy = j; }
				if (c == '#') { X[i][j] = 1; }
				else { X[i][j] = 0; }
				if (i == 1 || i == H || j == 1 || j == W) {
					Q.push(make_pair(i, j));
					dist[i][j] = X[i][j];
				}
			}
		}
		while (!Q.empty()) {
			pair<int, int>pa = Q.front(); Q.pop();
			int cx = pa.first, cy = pa.second;
			int dx[4] = { 1,0,-1,0 };
			int dy[4] = { 0,1,0,-1 };
			for (int i = 0; i < 4; i++) {
				int ex = cx + dx[i], ey = cy + dy[i];
				if (X[ex][ey] >= 2) { continue; }
				int dis = dist[cx][cy];
				if (X[cx][cy] == 0 && X[ex][ey] == 1) {
					dis += 1;
				}
				if (dist[ex][ey]>dis) {
					dist[ex][ey] = dis;
					Q.push(make_pair(ex, ey));
				}
			}
		}
		cout << dist[gx][gy] << endl;
	}
	return 0;
}

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

string lcs(string str1,string str2){
  int n=str1.length();
  int m=str2.length();
  //cout<<n<<m<<endl;
  int dp[n+1][m+1];
  
   for(int i=0;i<=m;i++){
  	dp[0][i]=0;
  }
  
  for(int i=0;i<=n;i++){
  	dp[i][0]=0;
  }
 
  for(int i=1;i<=n;i++){
  	for(int j=1;j<=m;j++){
      if(str1[i-1]==str2[j-1]){
      	dp[i][j]=dp[i-1][j-1]+1;
      }
      else{
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
  	}
  }
  string result;
  while(n>0&&m>0){
  	if(str1[n-1]==str2[m-1]){
  		result.push_back(str1[n-1]);
  		n--;
  		m--;
  	}
  	else{
  		if(dp[n][m-1]>dp[n-1][m]){
  			m--;
  		}
  		else{
  			n--;
  		}
  	}
  }
 
  reverse(result.begin(),result.end());
  return result;
  
}


int main(){
  string str1,str2;
  cin>>str1>>str2;
  cout<<lcs(str1,str2);
}

Measured memory_bytes: 35456
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    200256
#define M    998244353
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
ll n, m;
void solve()
{
    sc( "%I64d", &n );
    m = n * 100 / 108;
    if(m * 108 / 100 == n)pr("%I64d", m);
    else if( (m + 1) * 108 / 100 == n )pr("%I64d", m+1);
    else pr(":(");
}
 
int main()
{
 
   // sc( "%I64d", &tests );
    for(int i = 0; i < ttt; i ++ )
        solve();
}
 
 
 

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	int n,m; cin >> n >> m;
	vector<ll> aa(n),bb(n),cc(n);
	for(int i=0;i<n;i++){
		cin >> aa[i] >> bb[i] >> cc[i];
	}
	ll ans=0;
	for(int i=0;i<8;i++){
		vector<ll> a,b,c;
		a=aa;b=bb;c=cc;
		if(i&1){
			for(int j=0;j<n;j++){
				a[j]*=(-1);
			}
		}
		if((i>>1)&1){
			for(int j=0;j<n;j++){
				b[j]*=(-1);
			}
		}
		if((i>>2)&1){
			for(int j=0;j<n;j++){
				c[j]*=(-1);
			}
		}
		vector<ll> v;
		for(int i=0;i<n;i++){
			v.push_back(a[i]+b[i]+c[i]);
		}
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		ll ret=0;
		for(int j=0;j<m;j++){
			ret+=v[j];
		}
		ans=max(ans,ret);
	}
	cout << ans << endl;
	return 0;
}

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

#define mod 1000000007
#define pi 2 * acos(0.0)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rloop(i, a, b) for (int i = a; i >= b; i--)
void fun()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

/* DON'T LIMIT YOUR CHALLENGES, CHALLENGE YOUR LIMITS */
void solve()
{
    int n;
    cin >> n;

    vector<int> v(n);
    for (auto &i : v)
        cin >> i;
    vector<int> dp(n, 0);
    for (int i = 1; i < n; i++)
    {
        if (i == 1)
            dp[i] = abs(v[i] - v[i - 1]);
        else
        {
            // cout << dp[i - 1] + abs(v[i] - v[i - 1]) << " " << dp[i - 2] + abs(v[i] - v[i - 2]) << "\n";
            dp[i] = min((dp[i - 1] + abs(v[i] - v[i - 1])), (dp[i - 2] + abs(v[i] - v[i - 2])));
        }
        // cout << dp[i] << " ";
    }

    // cout << "\n";

    cout << dp[n - 1];
}

signed main()
{
    fun();
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4788