akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < static_cast<ll>(n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= static_cast<ll>(n); ++i)
#define RRANGE(i, m, n) for(ll i = static_cast<ll>(m); i >= static_cast<ll>(n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    string S, T;
    in >> S;
    in >> T;
    ll ans = 0;
    ll min_count = INF;
    REP(i, S.size()-T.size()+1) {
        ll cnt = 0;
        REP(j, T.size()) {
            if (S[i+j] != T[j]) {
                cnt++;
            }
        }
        min_count = min(min_count, cnt);
    }
    out << min_count << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int n;
long long a[55];
inline int mx(){
	int res=0;
	for(int i=1;i<n;i++){
		if(a[i]>a[res])res=i;
	}
	return res;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
        cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int t=0;
	long long ans=0;
	while(a[t=mx()]>=n){
		ans+=a[t]/n;
		for(int i=0;i<n;i++){
			if(i==t)continue;
			a[i]+=a[t]/n;
		}
		a[t]%=n;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))

sm=[0]*(n+1)
d=defaultdict(int)
for i in range(1,n+1):
    sm[i]=sm[i-1]+a[i-1]
    d[sm[i]]+=1

d[0]+=1
ans=0
for i,j in d.items():
    ans+=(j*(j-1))//2

print(ans)

Measured memory_bytes: 43340
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, K;
    cin >> N >> K;
    rep(i, 0, N) { int a; cin >> a; }

    --N; --K;
    cout << (N+K-1)/K << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ( a == b && b == c )
    cout << 1;
    else if ( a == b && b != c )
        cout << 2;
        else if ( a != b && b == c )
        cout << 2;
        else if ( a == c && c != b )
            cout << 2;
        else if ( a != b && b != c )
        cout << 3;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int counter = 0;
    
    if(A==B && B==C && A%2==0){
      System.out.println(-1);
    } else {
      while(A%2==0 && B%2==0 && C%2==0) {
        counter++;
        long a = B / 2 + C / 2;
        long b = C / 2 + A / 2;
        long c = A / 2 + B / 2;
        
        A = (int)a;
        B = (int)b;
        C = (int)c;
      }
      System.out.println(counter);
    }
  }
}

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

using namespace std;

int gcd(int a, int b){
    if (a < b){
        int c = a;
        a = b;
        b = c;
    }

    int ans = b;
    while(a % ans != 0){
        int c = a % ans;
        a = ans;
        ans = c;
    }

    return ans;
}

int main(){

    int N, K;
    cin >> N >> K;

    vector <int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    
    int G = A[0];
    for (int i = 1; i < N; i++){
        G = gcd(G, A[i]);
    }

    if (K % G == 0 && K <= A[N - 1]){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;

struct node
{
	int key;
	node *parent,*left,*right;
	node():key(-1),parent(NULL),left(NULL),right(NULL){}
};

node* newnode()
{
	return new node();
}
node *root=newnode();

void insert(int k)
{
	node* u=newnode();
	u->key=k;
	node* x=root;
	node* y;
	while(x!=NULL)
	{
		y=x;
		if(u->key > x->key)
		  x=x->right;
		else
		  x=x->left;
	}
	if(y->key==-1) root=u;
	else
	{
		u->parent=y;
		if(u->key<y->key)
		  y->left=u;
		else
		  y->right=u;
	}
	return;
}

void inorder(node* u)
{
	if(u->left!=NULL) inorder(u->left);
	printf(" %d",u->key);
	if(u->right!=NULL) inorder(u->right);
	return;
}

void preorder(node* u)
{
	printf(" %d",u->key);
	if(u->left!=NULL) preorder(u->left);
	if(u->right!=NULL) preorder(u->right); 
	return;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='i')
		{
			int x;
			scanf("%d",&x);
			insert(x);
		}
		else if(s[0]=='p')
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}

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

int main() {
  int n,c;
  cin >> n >> c;
  vector<vector<int>>data(c,vector<int>(1e5+1,0));
  rep(i,0,n){
    int s,t,cc;
    cin >> s >> t >> cc;
    cc--;
    data[cc][s]++;
    data[cc][t]--;
  }
  vector<vector<P>>table(c);
  rep(i,0,c){
    int s;
    rep(j,0,1e5+1){
      if(data[i][j] == 1) s = j;
      if(data[i][j] == -1) table[i].push_back(P(s,j));
    }
  }
  vector<int>imos(1e5+1);
  rep(i,0,c) rep(j,0,table[i].size()){
    //cout << i << " " << table[i][j].first << " " << table[i][j].second << endl;
    imos[table[i][j].first]++;
    if(table[i][j].second+1 <= 1e5) imos[table[i][j].second+1]--;
  }
  int ans = 0,sum = 0;
  rep(i,1,1e5+1){
    sum += imos[i];
    ans = max(ans,sum);
    //cout << sum << endl;
    //cout << imos[i] << endl;
  }
  cout << ans << endl;
}

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

int dv;
int maxDepth = -1;
int findDeepestV(int v, unordered_map<int, vector<int> > mp) {
    int visit[200001] = {0, }, cnt = -1;
    queue<pair<int, int> > q;
    q.push(make_pair(v, 1));
    visit[v] = 1;
    while (q.size() != 0) {
        pair<int, int> now = q.front();
        q.pop();
        if (cnt < now.second) cnt = now.second;
        for (auto child : mp[now.first]) {
            if (visit[child] == 0) {
                visit[child] = 1;
                q.push(make_pair(child, now.second + 1));
                dv = child;
            }
        }
    }
    return cnt;
}

int getDiameter(unordered_map<int, vector<int> > mp) {
    findDeepestV(1, mp);
    return findDeepestV(dv, mp);
}
 
int main() {
    ios::sync_with_stdio(false);

    int n, i, a, b;
    cin >> n;
    unordered_map<int, vector<int> > mp;
    for (i = 0; i < n - 1; i++) {
        cin >> a >> b;
        if (mp.find(a) == mp.end()) {
            mp.insert(make_pair(a, vector<int>()));
        }
        mp[a].push_back(b);
        if (mp.find(b) == mp.end()) {
            mp.insert(make_pair(b, vector<int>()));
        }
        mp[b].push_back(a);
    }
    int diameter = getDiameter(mp);
    int d[200001] = {0, };
    d[0] = -1;
    for (int i = 1; i <= diameter; i++) {
        d[i] = d[i - 1] == -1 ? 1 : -1;
        if (i > 2 && d[i] != 1) {
            d[i] = d[i - 2] == -1 ? 1 : -1;
        }
    }
    if (d[diameter] == 1) {
        cout << "First";
    } else cout << "Second";
    return 0;
}

Measured memory_bytes: 57960
#include<bits/stdc++.h>
const int N=1e5+77,inf=0x3f3f3f3f;
int n,k;
struct edge{
	int to,nx;
}e[N*2];
int e0[N],ep=2,L[N],R[N],tp[N],zv=-1;
bool ed[N];
void maxs(int&a,int b){if(a<b)a=b;}
void mins(int&a,int b){if(a>b)a=b;}
void upd(int a,int b){
	maxs(L[a],L[b]-1);
	mins(R[a],R[b]+1);
}
void f1(int w,int pa){
	tp[w]=tp[pa]^1;
	if(ed[w]){
		int z=(L[w]^tp[w])&1;
		if(zv==-1)zv=z;
		else if(zv!=z)puts("No"),exit(0);
	}else L[w]=-inf,R[w]=inf;
	for(int i=e0[w];i;i=i[e].nx){
		int u=i[e].to;
		if(u!=pa){
			f1(u,w);
			upd(w,u);
		}
	}
}
void f2(int w,int pa){
	for(int i=e0[w];i;i=i[e].nx){
		int u=i[e].to;
		if(u!=pa){
			upd(u,w);
			f2(u,w);
		}
	}
	if(L[w]>R[w])puts("No"),exit(0);
}
int main(){
	scanf("%d",&n);
	for(int i=1,a,b;i<n;++i){
		scanf("%d%d",&a,&b);
		e[ep]=(edge){b,e0[a]};e0[a]=ep++;
		e[ep]=(edge){a,e0[b]};e0[b]=ep++;
	}
	scanf("%d",&k);
	for(int i=1,x,y;i<=k;++i){
		scanf("%d%d",&x,&y);
		ed[x]=1;
		L[x]=R[x]=y;
	}
	f1(1,0);
	for(int i=1;i<=n;++i){
		int a=zv^tp[i];
		L[i]+=L[i]&1^a;
		R[i]-=R[i]&1^a;
		if(L[i]>R[i])puts("No"),exit(0);
	}
	f2(1,0);
	puts("Yes");
	for(int i=1;i<=n;++i)printf("%d\n",L[i]);
	return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
string divide[4] = {"dream","dreamer","erase","eraser"};
string s;
cin >> s;
bool ans = true;
reverse(s.begin(),s.end());
for(int i=0;i<4;i++)reverse(divide[i].begin(),divide[i].end());
for(int i=0;i<s.size();){
    bool can2= false;
    for(int j=0;j<4;j++){
        string d = divide[j];
        if(s.substr(i,d.size())==d){
            can2 = true;
            i+=d.size();
        }
    }
        if(!can2){
            ans=false;
            break;
    }
}
 if(ans)cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
 }


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
B = list(map(int, input().split()))
ans = 0

A = [0]*N
A[0] = B[0]
A[-1] = B[-1]
for i in range(0, N-2):
    A[i+1] = min(B[i], B[i+1])

print(sum(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
using namespace std;
const int N = 2050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;
pair<ll, int> p[N];
ll dp[N][N];

void solve()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        int x;
        scanf("%d", &x);
        p[i] = mp(x, i);
    }
    sort(p + 1, p + n + 1);
    for (int i = n; i; --i)
    {
        for (int j = 0, k = i + j; k <= n + 1; ++j, ++k)
        {
            if (j > 0)
                dp[j][k] = max(dp[j][k], dp[j - 1][k] + p[i].first * abs(j - p[i].second));
            if (k <= n)
                dp[j][k] = max(dp[j][k], dp[j][k + 1] + p[i].first * abs(k - p[i].second));
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i)
        ans = max(ans, dp[i][i + 1]);
    cout << ans << '\n';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

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

using namespace std;

#define rep(i,a,b) for (int i = a; i <= b; ++i)
#define repd(i,a,b) for (int i = b; i >= a; --i)
#define repn(i,n) for (int i = 0; i < n; ++i)
#define repnd(i,n) for (int i = n - 1; i >= 0; --i)
#define first fi
#define second se
#define all(v) v.begin(), v.end()
#define mp make_pair
#define eb emplace_back
#define v(T) vector<T>
#define vv(T) v(v(T))

typedef long long ll;
typedef long long int lli;
typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <long> vl;

const ll MOD = 10e9 + 3;

template<typename T>string join(const v(T)&v){stringstream s;repn(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v){if(v.size())o<<join(v);return o;}
ll GCD(ll x, ll y){if (!y) return x; else return GCD(y,x%y);}
ll LCM(ll x, ll y){return (x*y)/GCD(x,y);}
ll sqr(ll x){return x*x;}
ll spow(ll a,ll b){if (!b) return 1; else if (!(b%2)) return sqr(spow(a,b/2)); else return a*sqr(spow(a,b/2));}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);                	
	int a,b,c;
	cin >> a >> b >> c;
	int ans = 0;
	if (b + c > a){
		if (c > a){
			ans = b + abs(a-c);
		}
		else{
			ans = b - abs(a-c);
		}
	}
	cout << ans;
	return 0;
}                  		

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;

signed main()
{
    int N; cin>>N;
    vector<int> v(N),c(N);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=max(0LL,v[i]-c[i]);
    }
    cout<<ans<<endl;
}


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

#define ARRAYNUM 1000

int funcA(int curval)
{
  return(curval*2);
}

int funcB(int curval, int K)
{
  return(curval + K);
}

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

  int result[10];
  int bcnt=0;
  memset(&result, 0, sizeof(result));
  for(int i=0; i<N; i++) {
    int curval = 1;
    for(int a=0; a<(N-bcnt); a++) {
      curval = funcA(curval);
    }
    for(int b=0; b<(bcnt); b++) {
      curval = funcB(curval, K);
    }
    bcnt++;
    result[i] = curval;
    //cout << result[i] << endl;
  }

  int minval=result[0];
  for(int i=1; i<N; i++) {
    if(minval > result[i]) {
      minval = result[i];
    }
  }
  cout << minval << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), W = in.ni();
            int[] w = new int[n];
            int[] v = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.ni();
                v[i] = in.ni();
            }
            long[][] dp = new long[n + 1][100_007];
            for (int i = 0; i < n + 1; i++) {
                Arrays.fill(dp[i], Long.MAX_VALUE);
            }
            dp[0][0] = 0;
            for (int i = 0; i < n; i++) {
                for (int vv = 0; vv < 100_007; vv++) {
                    if (dp[i][vv] < Long.MAX_VALUE) {
                        dp[i + 1][vv] = Math.min(dp[i + 1][vv], dp[i][vv]);
                        if (vv + v[i] < 100_007)
                            dp[i + 1][vv + v[i]] = Math.min(dp[i + 1][vv + v[i]], dp[i][vv] + w[i]);
                    }
                }
            }
            for (int vv = 100_001; vv >= 0; vv--) {
                if (dp[n][vv] <= W) {
                    out.println(vv);
                    return;
                }
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}



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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  map<double, int> group[3];
  map<double, int> all;

  for(int i=0; i<3; i++) {
    for(int j=0; j<8; j++) {
      int num; double time;
      cin>> num>> time;
      group[i][time] = num;
    }

    map<double, int>::iterator it = group[i].begin();
    cout<< (*it).sc<< " "<< (*it).fr<< endl; it++;
    cout<< (*it).sc<< " "<< (*it).fr<< endl;

    int n=6;
    while(n--) {
      it++;
      all[(*it).fr] = (*it).sc;
    }
  }

  map<double, int>::iterator it = all.begin();
  cout<< (*it).sc<< " "<< (*it).fr<< endl; it++;
  cout<< (*it).sc<< " "<< (*it).fr<< endl;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;

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

    //ans[0]さえ求めれば、連立方程式から芋づる式に他も求まる。
    if(n%2==1){//奇数個の連立方程式の時のans[0]
        ll want_ans0=0;
        for(i=0;i<n-1;i++){
            if(i%2){want_ans0-=a[i];}
            else if(!(i%2)){want_ans0+=a[i];}
        }
        ans[0]=(want_ans0+a[n-1])/2;
    }

    for(i=0;i<n-1;i++){
        ans[i+1]=a[i]-ans[i];
    }

    for(i=0;i<n;i++){
        cout<<2*ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int countN = N > 1 ? N * (N - 1) : 0;
  int countM = M > 1 ? M * (M - 1) : 0;
  cout << (countN + countM) / 2<< endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;


int a, b;

int main() {
    cin >> a >> b;
    int c = b - a - 1;
    int sum = c * (c + 1) / 2;
    cout << sum - a << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> A>>B>>N ;
	if(N>=B-1)std::cout << (A*(B-1))/B << std::endl;
	else std::cout << (A*N)/B<< std::endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    int n;
    cin >> n ;
    cout <<  (n < 1200 ? "ABC" : "ARC");
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DigitsParade solver = new DigitsParade();
        solver.solve(1, in, out);
        out.close();
    }

    static class DigitsParade {
        public static int MOD = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] chars = reverse(in.next());
            long[][] dp = new long[chars.length][13];

            if (chars[0] == '?') {
                for (int i = 0; i <= 9; i++) {
                    dp[0][i] = 1;
                }
            } else {
                int i = Integer.parseInt(String.valueOf(chars[0]));
                dp[0][i] = 1;
            }

            int num = 1;
            for (int i = 1; i < chars.length; i++) {
                num *= 10;
                num %= 13;

                if (chars[i] == '?') {
                    for (int j = 0; j <= 9; j++) {
                        for (int k = 0; k < 13; k++) {
                            int index = (k + (j * num)) % 13;
                            dp[i][index] += dp[i - 1][k];
                            dp[i][index] %= MOD;
                        }
                    }
                } else {
                    int j = Integer.parseInt(String.valueOf(chars[i]));
                    for (int k = 0; k < 13; k++) {
                        int index = (k + j * num) % 13;
                        dp[i][index] += dp[i - 1][k];
                        dp[i][index] %= MOD;
                    }
                }
            }
            out.println(dp[chars.length - 1][5]);
        }

        public static char[] reverse(String text) {
            return new StringBuilder(text).reverse().toString().toCharArray();
        }

    }
}



Measured memory_bytes: 66996
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a;
    cin>>a;
    cout<<a+(a*a)+(a*a*a)<<endl;
    return 0;
}

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

int n, k, dp[1000000];
vector<int> a;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		dp[tmp] = 1;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i <= k; i++) {
		if (!dp[i]) {
			for (auto j: a)
				if (i - j >= 0 && dp[i - j] == 0) {
					dp[i] = 1;
					break;
				}
		}
	}
	cout << (dp[k]? "First\n": "Second\n") << endl;
}


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

int main() {
  int n;
  cin >> n;
  int s = 0;
  for (int i = 0; i < n; i ++) {
    int x, y;
    cin >> x >> y;
    s += y - x + 1;
  }
  cout << s << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int mod = 1e9+7;
int N;

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

  cin >> N;
  string ans = "Three";
  rep(i, N) {
    char c;
    cin >> c;
    if (c == 'Y') {
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}

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

int main(){
  char S[6];
  int c=0,l;
  scanf("%s",S);
  l=strlen(S);
  for(int i=0;i<l-1;i++){
    if(S[i]=='A' && S[i+1]=='C') c=1;
  }
  if(c==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

vector<vector<char>> maze;
vector<vector<int>> ans;
int H, W;
int Ch, Cw;
int Dh, Dw;
int cnt = 0;
queue<P> que_nuri;
queue<P> que;

void dfs(int h, int w) {
    maze[h][w] = '#';
    int dw[] = {-1, 1, 0, 0};
    int dh[] = {0, 0, 1, -1};
    for (int i = 0; i < 4; i++) {
        int nw = w + dw[i];
        int nh = h + dh[i];
        if (0 <= nw && nw < W && 0 <= nh && nh < H && maze[nh][nw] == '.') {
            // cout << nh << " " << nw << " " << cnt << endl;
            ans[nh][nw] = min(cnt, ans[nh][nw]);
            que_nuri.push(P(nh, nw));
            dfs(nh, nw);
        }
    }
}

// たどり着けなかったらINF回
int bfs() {
    que.push(P(Ch, Cw));
    ans[Ch][Cw] = 0;

    while (!que.empty() || !que_nuri.empty()) {
        while (!que.empty()) {
            P p = que.front();
            que.pop();
            que_nuri.push(p);
            ans[p.first][p.second] = min(ans[p.first][p.second], cnt);
            // cout << "ans" << p.first << " " << p.second << " " << ans[p.first][p.second] << endl;
            // 歩けるだけ歩く
            dfs(p.first, p.second);
        }
        // 塗りつぶしたやつの5x5の範囲を見ていく
        while (!que_nuri.empty()) {
            P q = que_nuri.front();
            que_nuri.pop();
            for (int dh = -2; dh <= 2; dh++) {
                for (int dw = -2; dw <= 2; dw++) {
                    int nh = q.first + dh;
                    int nw = q.second + dw;
                    if (0 <= nw && nw < W && 0 <= nh && nh < H && maze[nh][nw] == '.') {
                        // if (nh == Dh && nw == Dw) {
                        //     return cnt + 1;
                        // }
                        que.push(P(nh, nw));
                    }
                }
            }
        }
        cnt++;
    }
    return ans[Dh][Dw];
}

int main() {
    cin >> H >> W;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;
    Ch--;
    Cw--;
    Dh--;
    Dw--;
    maze = vector<vector<char>>(H + 5, vector<char>(W + 5));
    ans = vector<vector<int>>(H + 5, vector<int>(W + 5));
    rep(i, H + 5) {
        rep(j, W + 5) {
            maze[i][j] = '#';
            ans[i][j] = INF;
        }
    }
    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
        }
    }
    int res = bfs();
    if (res == INF) {
        cout << "-1" << endl;
    } else {
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 8704
ans = 0
x = []
y = []
for i in range(5):
    x.append(int(input()))
    y.append(x[i]%10)

for i in range(5):
    if y[i] == 0:
        ans += x[i]
    else:
        ans += x[i]-y[i]+10
m = 10
for i in y:
    if i == 0:
        continue
    else:
        m = min(m,i)
if m == 10:
    print(ans)
else:
    print(ans+m-10)

Measured memory_bytes: 9144
def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
ans = 0
for i in A:
    ans += lcm//i
print(ans%MOD)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int X,Y,A,B,C;cin>>X>>Y>>A>>B>>C;
  int p[A+10];
  int q[B+10];
  vector<int> all;
  REP(i,A) cin>>p[i];
  REP(i,B) cin>>q[i];
  int r;
  REP(i,C) {
    cin>>r;
    all.push_back(r);
  }
  sort(p,p+A,greater<int>());
  sort(q,q+B,greater<int>());
  REP(i,X) all.push_back(p[i]);
  REP(i,Y) all.push_back(q[i]);
  sort(all.begin(),all.end(),greater<int>());
  ll res = 0;
  REP(i,X+Y) {
    res += all[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define debug(args...) fprintf(stderr, args)

typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef vector<pair<int,int>> vpii;
typedef vector<tuple<int,int,int>> vtiii;

bool sortByA(pair<int,int> i, pair<int,int> j) {
    return i.first < j.first;
}

int main() {
    int n, a, b;
    unsigned long long int k, acm;
    vector<pair<int,int>> vector;
    acm = 0;

    cin >> n >> k;


    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        vector.push_back(make_pair(a,b));    
    }
    sort(vector.begin(), vector.end(), sortByA);
    
    for (int i = 0; i < vector.size(); i++) {
        acm += vector[i].second;

        if (acm >= k) {
            cout << vector[i].first << endl;
            break;
        }
    }
    


    return 0;
}

Measured memory_bytes: 1400
use std::collections::HashMap;
fn main() {
    let v = read_vec::<u32>();
    let _ = v[0];
    let m = v[1];

    let mut count_ac = 0;
    let mut count_pn = 0;
    let mut hm = HashMap::new();
    for _ in 0..m {
        let vv = read_vec::<String>();
        let p = vv[0].parse::<usize>().unwrap();
        let s = vv[1].clone();

        let h = hm.entry(p).or_insert(0);
        if *h >= 0 {
            if s == "AC" {
                count_pn += *h;
                count_ac += 1;
                *h = -1;
            } else {
                *h += 1;
            }
        }
    }
    println!("{} {}", count_ac, count_pn);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 12540
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[]
for i in range(n-k+1):
    y=a[i+k-1]-a[i]+min(abs(a[i+k-1]),abs(a[i]))
    x.append(y)        
print(min(x))


Measured memory_bytes: 14252
a = 5.times.map{gets.to_i}
ans = 0
5.times do |i|
    ans += (a[i]+9)/10*10
end
mn = 10
5.times do |i|
    mn = a[i]%10 if a[i]%10 > 0 && a[i]%10 < mn
end
ans -= 10-mn
puts ans

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

const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
 int a,b;
 cin>>a>>b;a*=10;
 if(b>=10)a*=10;
 if(b>=100)a*=10;
 a+=b;b=sqrt(a);
 if(b*b==a)cout<<"Yes";
 else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1 << 30;


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

    vector<ll> sa(n+1);
    map<ll,ll> mp;
    rep(i,n) sa[i+1] = sa[i] + a[i];
    rep(i,n+1) {
        mp[sa[i]%m]++;
    }

    ll res = 0;
    for(auto [s,t] : mp) res += t*(t-1)/2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8668
s = gets.chomp
s.slice!(-1)
aa = 0
while s.length>1
	s.slice!(-1) and next if s.length%2 != 0
	t = s.length/2
	a = s.scan(/.{1,#{t}}/)
	if a[0]==a[1]
		aa = a.first.length*2 and break
	else
		s.slice!(-1)
	end
end
puts aa

Measured memory_bytes: 1916
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <strstream>
using namespace std;

int main (){
  double s,x1,y1,x2,y2,x3,y3,a,b,c,z;
  char ch;
  s=0;
  cin>>x1>>ch>>y1;
  cin>>x2>>ch>>y2;
  a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  while(cin>>x3>>ch>>y3){
    b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
    z=(a+b+c)/2;
    s+=sqrt(z*(z-a)*(z-b)*(z-c));
    x2=x3;
    y2=y3;
    a=b;
  }
  cout<<s<<endl;
  
  return 0;
}

Measured memory_bytes: 1284
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
    input! {
        s:Chars
    }
    if *s.last().unwrap() == 's' {
        for i in s {
            print!("{}", i);
        }
        println!("es");
    } else {
        for i in s {
            print!("{}", i);
        }
        println!("s");
    }
}


Measured memory_bytes: 2200
n, q = map(int, input().split())
mat = [[] for _ in range(n)]

for _ in range(q):
    command = list(map(int, input().split()))
    if command[0] == 0:
        mat[command[1]].append(command[2])
    elif command[0] == 1:
        print(' '.join(str(c) for c in mat[command[1]]))
    elif command[0] == 2:
        mat[command[1]].clear()



Measured memory_bytes: 60472
// C++11
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <set>
#include <unordered_set>
#include <vector>

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}

int main(void) {
  array<array<int, 3>, 3> c;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  array<int, 3> a, b;
  for (a[0] = 0; a[0] <= 100; a[0]++) {
    a[1] = c[1][0] - c[0][0] + a[0];
    a[2] = c[2][0] - c[0][0] + a[0];

    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    pv(a);
    pv(b);
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (c[i][j] != a[i] + b[j]) goto fail;
      }
    }
    cout << "Yes" << endl;
    return 0;
  fail:;
  }

  cout << "No" << endl;

  return 0;
}


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


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;


int anss[2001][2001] = {};

int ss[2001] = {};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int x, y; cin >> x >> y; x--; y--;

	FOR_LT(i, 0, n) {
		FOR_LT(j, i + 1, n) {
			int d = j - i;
			int nd = abs(i - x) + 1 + abs(j - y);
			anss[i][j] = min(d, nd);
			//cout << i << " " << j << " " << d << " " << nd << endl;
		}
	}

	FOR_LT(i, 0, n) {
		FOR_LT(j, i + 1, n) {
			ss[anss[i][j]]++;
		}
	}

	FOR_LT(i, 1, n) {
		cout << ss[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 15360
#include <stdio.h>

int main(void)
{

	int h, w;
	int ii, jj;
	char rowc;
	char colc;

	for (;;) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}
		rowc = '#';
		colc = '#';
		for (ii = 0; ii < h; ii++) {
			for (jj = 0; jj < w; jj++) {
				printf("%c", colc);
				colc = (colc == '#') ? '.' : '#';
			}
			printf("\n");
			rowc = (rowc == '#') ? '.' : '#';
			colc = rowc;
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
from collections import defaultdict

s=input()
t=input()
lis=defaultdict(lambda:"A")
lis2=defaultdict(lambda:"A")
for i,val in enumerate(s):
    if lis[val]=="A":
        lis[val]=t[i]
    else:
        if lis[val]!=t[i]:
            print("No")
            exit()
for i,val in enumerate(t):
    if lis2[val]=="A":
        lis2[val]=s[i]
    else:
        if lis2[val]!=s[i]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 9716
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int main() {
    while(true) {
        int N, K;
        cin >> N >> K;
        if(!N && !K) break;

        vector<vector<int> > v(N, vector<int>(N, -1));
        while(K--) {
            int cmd;
            cin >> cmd;
            if(cmd == 0) {
                int a, b;
                cin >> a >> b;
                --a; --b;
                cout << v[a][b] << endl;
            }
            else {
                int c, d, e;
                cin >> c >> d >> e;
                --c; --d;
                if(v[c][d] == -1 || e < v[c][d]) {
                    v[c][d] = v[d][c] = e;
                    for(int k = 0; k < 2; ++k) {
                        int mid = k ? c : d;
                        for(int i = 0; i < N; ++i) {
                            for(int j = 0; j < N; ++j) {
                                if(v[i][mid] != -1 && v[mid][j] != -1) {
                                    if(v[i][j] == -1) v[i][j] = v[i][mid]+v[mid][j];
                                    else v[i][j] = min(v[i][j], v[i][mid]+v[mid][j]);
                                    v[j][i] = v[i][j];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 944
#include <iostream>
using namespace std;
int main(void){
   
  int a,b,c,d,e;
  cin >> a>>b>>c>>d>>e;
  if(a == 0){
      cout << b - 1 << endl;
  }
  if(b == 0){
      cout << c - 1 << endl;
  }
  if(c == 0){
      cout << d - 1 << endl;
  }
  if(d == 0){
      cout << e - 1 << endl;
  }
  if(e == 0){
      cout << d + 1 << endl;
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    if(N%10==3){print("bon")}
    else if(N%10==0||N%10==1||N%10==6||N%10==8)print("pon")
    else print("hon")

    return 0;
}

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


int main() {
  int n; cin>>n; 
  int sum=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  for(int i=1;i<n-1;i++){
    int s=vec[i-1]+vec[i]+vec[i+1];
    int M=max(vec[i-1],max(vec[i],vec[i+1]));
    int m=min(vec[i-1],min(vec[i],vec[i+1]));
    if(s-M-m==vec[i]) sum++;
  }
  cout<<sum<<endl;
}

    
  

    
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int g = 0, p = 0, count = 0;
		for (int i = 0; i < s.length; i++) {
			if(s[i] == 'g') {
				if(g > p) {
					p++;
					count++;
				}else {
					g++;
				}
			}else {
				if(g > p) {
					p++;
				}else {
					g++;
					count--;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 26132
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  int n = s.size();

  int m = 30;
  mat dp(m,vec(n));

  REP(i,n) dp[0][i] = i+(s[i]=='L'?-1:1);

  FOR(i,1,m){
    REP(j,n) dp[i][j] = dp[i-1][dp[i-1][j]];
  }

  vec ans(n,0);
  REP(i,n){
    int now = i, cnt = 1e9, id = 0;
    while(cnt){
      if(cnt&1) now = dp[id][now];
      cnt /= 2; id++;
    }
    ans[now]++;
  }

  REP(i,n) cout << ans[i] << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 24896
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	double l;
	cin >> l;
	
	double ans=l*l*l/27.0;
	
	printf("%0.6f\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());
            //var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            //var N = NK[0];
            //var K = NK[1];
            var L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();;
            long ans = 0;

            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[k]) && L[j] < L[i] + L[k] && L[k] < L[i] + L[j])
                        {
                            if(!(L[i] == L[j] || L[i] == L[k] || L[j] == L[k])) ans++;

                        }
                    }
                }
            }
            
            Console.WriteLine(ans);
           
        }


    }
}


Measured memory_bytes: 28292
#include <iostream>
using namespace std;
int buf[105],num[105];
int main() {
    int n;
    cin>>n;

    for(int i=0;i<n-1;i++){
        cin>>buf[i];
    }
    num[n-1] = buf[n-2];
    num[0] = buf[0];
    int sum=0;
    for(int i=1;i<n-1;i++){
        num[i] = min(buf[i-1],buf[i]);
        
    }
    for(int i=0;i<n;i++)
        sum+=num[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
using namespace std;
bool check(char c){ return '0' <= c && c <= '9';}
int main(void){
  char s[1111];
  int sl;
  while(fgets(s,sizeof(s),stdin) != NULL){
    stack<long double> st;
    st.push(0);
    sl = strlen(s);
    for(int i = 0; i < sl-1; i++){
      if(check(s[i]) || (s[i] == '-' && check(s[i+1])) ){
	bool f = (s[i] == '-');
	if(f) i++;
	long double n = 0;
	for(;check(s[i]); i++){
	  n *= 10;
	  n += s[i]-'0';
	}
	if(f) n=-n;
	st.push(n);
      }else{
	long double a = st.top(); st.pop();
	long double b = st.top(); st.pop();
	long double m;
	switch(s[i]){
	case '+' :m = b+a; break;
	case '-' :m = b-a; break;
	case '*' :m = b*a; break;
	case '/' :m = b/a; break;
	}
	st.push(m);
	i++;
      }
    }
    printf("%.10Lf\n",st.top());
  }
}

Measured memory_bytes: 1188