akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

map<int, int, greater<int>>ap;
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		++ap[x];
	}

	vector<int>sol;

	for(auto &it : ap) {
		while(sol.size() + 1 <= 2 && it.second >= 2) {
			sol.push_back(it.first);
			it.second -= 2;
		}
	}
	if(sol.size() < 2)cout << 0;
	else cout << 1LL * sol[0]*sol[1];

}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
	
	static int change = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		StringBuilder sb = new StringBuilder();
		
		int N = sc.nextInt();
		
		int[] dArr = new int[N];
		
		int total = 0;
		
		for (int i = 0 ; i < N ; i++) {
			dArr[i] = sc.nextInt();
		}
		
		for(int i = 1 ; i < N ; i++) {
			for(int j = 0 ; j < i ; j++) {
				total += dArr[i] * dArr[j];
			}
		}
		
		System.out.println(total);
	}

}


Measured memory_bytes: 23252
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    r = int(input())

    print(2 * 3.141592653589 * r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61812
#include <stdio.h>

int main(void){

	int a, b, c, d, e;
	int i;
	int tmp;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	
	for(i = 0; i < 5; i++){
		if(a < b){
			tmp = a;
			a = b;
			b = tmp;
		}
		if(b < c){
			tmp = b;
			b = c;
			c = tmp;
		}
		if(c < d){
			tmp = c;
			c = d;
			d = tmp;
		}
		if(d < e){
			tmp = d;
			d = e;
			e = tmp;
		}
	}
	
	printf("%d %d %d %d %d\n", a, b, c, d, e);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;
char a[11][1001];
int d[11][1001];
bool c[11];
int sum[11]; //구간들의 합

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	int n, m, k; cin >> n >> m >> k;
	int ans2 = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			if (i - 1 >= 0)d[i][j] = d[i - 1][j];
			if (a[i][j] == '1') {
				if (i - 1 >= 0) {
					d[i][j] = d[i - 1][j] + 1;
				}
				else d[i][j] = 1;
				ans2 += 1;
			}
		}
	}

	if (ans2 <= k) {
		cout << 0 << '\n';
	}
	else {
		int ans = 10000000;
		for (int i = 0; i < (1 << (n - 1)); i++) {
			vector<int> v;
			int time = 0;
			for (int r = 0; r <= 10; r++)sum[r] = 0;
			for (int j = 0; j < n - 1; j++) { // 0이면 0과 1사이를 자른다는 말.
				if (i & (1 << j)) {
					v.push_back(j); time += 1;
				}
			}
			v.push_back(n - 1);
			bool ff = false;
			int cnt = 0;

			for (int j = 0; j < m; j++) {
				bool f = false;
				for (int r = 0; r < v.size(); r++) {
					if (r - 1 >= 0) {
						if (d[v[r]][j] - d[v[r - 1]][j] > k) {
							ff = true; break;
						}
						if (sum[r] + d[v[r]][j] - d[v[r - 1]][j] > k) {
							f = true; break;
						}
						sum[r] += d[v[r]][j] - d[v[r - 1]][j];
					}
					else {
						if (d[v[r]][j] > k) {
							ff = true; break;
						}
						if (sum[r] + d[v[r]][j] > k) {
							f = true; break;
						}
						sum[r] += d[v[r]][j];
					}
				}
				if (ff) { cnt = 1000000; break; }
				if (f) {
					cnt += 1;
					for (int r = 0; r <= 10; r++)sum[r] = 0;
					j -= 1;
					continue;
				}
			}
			ans = min(ans, cnt + time);
		}
		cout << ans << '\n';
	}
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS     = 1e-10;
const double    PI      = acos(-1.0);
const int       INFTY   = (1<<21);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    int n, m; cin >> n >> m;
    map<pair<int, int>, int> edges;
    vector< vector<int> > wf(n, vector<int>(n, INFTY));
    REP(i, n) {
        wf[i][i] = 0;
    }
    REP(i, m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        wf[a][b] = c;
        wf[b][a] = c;
        edges[MP(a, b)] = c;
    }
    REP(k, n) {
        REP(i, n) {
            REP(j, n) {
                if (wf[i][j] > wf[i][k] + wf[k][j]) {
                    wf[i][j] = wf[i][k] + wf[k][j];
                }
            }
        }
    }
    int ans = 0;
    EACH(i, edges) {
        auto p = i->first;
        int c = i->second;
        if (wf[p.first][p.second] < c) ans++;
    }
    cout << ans << endl;
    return 0;
}

// あらゆる2頂点を結ぶ最短距離について考えているから，ワーシャルフロイドが使えそうだ．
// ワーシャルフロイド wf[i][j] = min {c[i][j], wf[i][k] + wf[k][j] (for all k)}
// wf[i][j] を求める過程で c[i][j] > wf[i][k] + wf[k][j]なるkがあるなら．c[i][j]はどの最短経路にも含まれない.
// かってな頂点 a, bをとり，その最短経路において a ->* i ->* j ->* b とする必要があるとすれば，
// i ->1 j よりも i ->{2..} j とした方がコストが必ず小さいからである．



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

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

  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  vector<ll> suma(N+1);
  vector<ll> sump(N+1);
  rep(i, N){
    suma[i+1] = suma[i] + a[i];
    if(a[i] > 0){
      sump[i+1] = sump[i] + a[i];
    }else{
      sump[i+1] = sump[i];
    }
  }

  ll ans = -1;
  rep(i, N){
    if(i + K - 1 >= N) continue;
    //まず i~i+K-1まで
    ll tans = 0;
    ll blocksum = suma[i+K] - suma[i];
    if(blocksum > 0){
      tans += blocksum;
    }

    // 0~i-1, i+K ~ N-1まで
    tans += sump[i] - sump[0];
    tans += sump[N] - sump[i+K];

    chmax(ans, tans);
    
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,m;
ll in_edge[100100]={};
vector<ll> node[100100];
int main(){
	cin>>n>>m;
	REP(i,n-1+m){
		ll a,b;
		cin>>a>>b;
		a--,b--;
		in_edge[b]++;
		node[a].push_back(b);
	}
	int root;
	REP(i,n){
		if(in_edge[i]==0)root=i;
	}
	queue<ll> q;
	q.push(root);
	ll ans[n];
	ans[root]=0;
	while(q.size()){
		ll q1=q.front();q.pop();
		for(int i=0;i<node[q1].size();i++){
			in_edge[node[q1][i]]--;
			if(in_edge[node[q1][i]]==0){
				ans[node[q1][i]]=q1+1;
				q.push(node[q1][i]);
			}
		}
	}
	REP(i,n){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

int mem(vector<int> &dp, int i, int N, vector<int> S)
{
	if(dp[i]!=INF) return dp[i];
	int ret = INF;
	if(i<=N-2) ret = min(ret,mem(dp,i+1,N,S));
	if(i<=N-3) ret = min(ret,mem(dp,i+2,N,S));
	if(i<=N-4) ret = min(ret,mem(dp,i+3,N,S));
	if(S[i]==1) ret++;
	return dp[i]=ret;
}

int main(void) {
	int N;	
	inp(N);
	double ans;
	if(N==1) out(1.0);
	else if(N%2==0) out(0.5);
	else out(double((N-1)/2.0+1.0)/N);

}


Measured memory_bytes: 256
a = int(input())
ar = list(map(int,input().split(" ")))
b = sum(ar) / a
s = abs(ar[0] - b)
ans = 0
for i in range(1,a):
    if s > abs(b - ar[i]):
        s = abs(b - ar[i])
        ans = i
print(ans)

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

int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll p=0;p<n;p++)
	{
		cin>>a[p];
	}
	ll max_so_far=a[0];
	ll sum=0;
	for(ll p=1;p<n;p++)
	{
		if(a[p]<max_so_far)
		{
			sum+=abs(a[p]-max_so_far);
		}
		else if(a[p]>max_so_far)
		{
			max_so_far=a[p];
		}
	}
	cout<<sum;
}

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

#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

int i, j;
string s;
int n;
ll dp[100001][13] = {0};
const ll mod = 1e9 + 7;

void solve() {
  cin >> s;
  int l = s.size();
  dp[0][0] = 1;
  int temp;
  for (i = 0; i < l; ++i) {
    for (j = 0; j < 13; ++j) {
      temp = j * 10;
      if (s[i] != '?') {
        temp = (temp + s[i] - '0') % 13;
        dp[i + 1][temp] = (dp[i + 1][temp] + dp[i][j]) % mod;
      } else {
        for (int k = 0; k < 10; ++k) {
          temp = (j * 10 + k) % 13;
          dp[i + 1][temp] = (dp[i + 1][temp] + dp[i][j]) % mod;
        }
      }
    }
  }
  cout << dp[l][5] << endl;
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 1e9 + 7;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	int i = 1;
	int ans = 0;
	if(N >= 105)ans++;
	if(N >= 135)ans++;
	if(N >= 165)ans++;
	if(N >= 189)ans++;
	if(N >= 195)ans++;
	cout << ans << endl;
}
	//105 135 165 189 195 

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

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;

mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<A.size();i++)
    for(int k=0;k<B.size();k++)
      for(int j=0;j<B[0].size();j++)
	C[i][j]+=A[i][k]*B[k][j];

  return C;
} 

mat pow(mat A,int n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<A.size();i++)B[i][i]=1;
  for(;n>0;n>>=1){
    if(n&1)B=mul(B,A);
    A=mul(A,A);
  }
  return B;
}

int main(void){
  int n,m,z,s,d;

  while(cin >> n >> m >> z,n|m|z){
    vector<P>G;
    G.push_back(P(1,1));
    for(int i=0;i<m;i++){
      cin >> s >> d;
      G.push_back(P(s,d));
      G.push_back(P(d,s));
    }
    mat A(G.size(),vec(G.size()));
 
    for(int i=0;i<G.size();i++)
      for(int j=1;j<G.size();j++)
	if(i!=j && G[i].first!=G[j].second)
	  A[i][j]=G[i].second==G[j].first;

    A=pow(A,z);

    bool fg=false;
    for(int i=0;i<A.size();i++)
      if(G[i].second==n && A[0][i])fg=true;

    cout << (fg?"yes":"no") << endl;
  }
  return 0;
}

Measured memory_bytes: 1380
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    a = list(map(int,input().split()))
    x = 0
    for j in range(m):
        x += a[j]*b[j]
    if x+c>0: ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    cout << x[K-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define dupl(s) s.erase(unique(s.begin(), s.end()), s.end());//重複取り除き
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> y;
    rep(i,m)cin >> x[i];
    sort(x.begin(),x.end());
    rep(i,m-1){
        int dir = abs(x[i+1] - x[i]);
        y.push_back(dir);
    }
    int sum = accumulate(y.begin(),y.end(),0);
    sort(y.begin(),y.end(),greater<int>());
    for(int i = 0; i < min(n-1,(int)y.size()); i++){
        sum -= y[i];
    }
    cout << sum;
}

Measured memory_bytes: 4324
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
    string s, t;
    cin >> s >> t;

    int ans = 0;
    REP(i,3) {
        if (s[i] == t[i]) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

temp=list(map(int, input().split()))
N=temp[0]
M=temp[1]

A=np.zeros((M,2)).astype(int)

for i in range(M):
  temp=list(map(int, input().split()))
  temp[0]-=1
  temp[1]-=1
  A[i]=temp
idx=A[:,1].argsort()
a=[0]*M
b=[0]*M
for i in range(M):
  a[i]=A[idx[i],0]
  b[i]=A[idx[i],1]
flag=False
x=-1
ans=0
for i in range(M):
  if a[i]>x:
    x=b[i]-1
    ans+=1
print(ans)
  

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];
    int ans = 1e9;
    if(n == 1) ans = 1;
    REP(i, n) REP(j, n) {
        if(i == j) continue;
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        int sub = 0;
        REP(i1, n) REP(j1, n) {
            if(i1 == j1) continue;
            if(dx == x[i1] - x[j1] && dy == y[i1] - y[j1]) ++sub;
        }
        ans = min(ans, n - sub);
    }
    cout << ans << endl;
    // map<pair<int, int>, int> v;
    // REP(i, n) FOR(j, i + 1, n) {
    //     int x1 = x[j] - x[i];
    //     int y1 = y[j] - y[i];
    //     if(x1 < 0) {
    //         x1 = -x1;
    //         y1 = -y1;
    //     } else if(x1 == 0) {
    //         if(y1 < 0) {
    //             y1 = -y1;
    //         }
    //     }
    //     v[make_pair(x1, y1)]++;
    // }
    // int max_count = 0;
    // pii p;
    // for(auto& [key, val] : v) { // keyを取り出す
    //     if(val > max_count) {
    //         val = max_count;
    //         p = key;
    //     }
    // }

    

    return 0;
}

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

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



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

int n;
vector<vector<int> > g;
int ans[101][101];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            ans[u][v]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<ans[i][j];
            if(j!=n) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << -1 << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    cout << N*N*N << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	char S[3][101]; cin >> S[0] >> S[1] >> S[2];

	char t = S[0][0];
	int A = 0, B = 0, C = 0;

	while (true) {
		if (t == 'a') {
			t = S[0][A];
			A++;
			if (t == '\0') {
				cout << "A" << endl;
				return 0;
			}
		}
		else if (t == 'b') {
			t = S[1][B];
			B++;
			if (t == '\0') {
				cout << "B" << endl;
				return 0;
			}
		}
		else if (t == 'c') {
			t = S[2][C];
			C++;
			if (t == '\0') {
				cout << "C" << endl;
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int>D(N);
	for(size_t i = 0; i < N; i++)
	{
		cin >> D[i];
	}
	for(size_t i = 0; i < N; i++)
	{
		cout << D[N - i - 1] << ( i == N - 1 ? "\n" : " " );
	}
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string s; cin >> s;
	string ans;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '0') ans.push_back('0');
		else if(s[i] == '1') ans.push_back('1');
		else if(ans.size() != 0) ans.pop_back();
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

void bfs(vector <long int >a[],int vi[],long int le[])
{
   queue <long int>qw;
   qw.push(0);
   vi[0]=1;
   le[0]=0;
   while(qw.size()!=0)
	{   long int x,i;
		  x=qw.front();
		for(i=0;i<a[x].size();i++)
		  {
		  	  if(vi[a[x][i]]==0)
		  	    {
		  	    	vi[a[x][i]]=1;
		  	    	le[a[x][i]]=le[x]+1;
		  	    	qw.push(a[x][i]);
		  	    }
		  }
		qw.pop();
	}
}
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	char a[n][m];
	for(i=0;i<n;i++)
	   {
	   	   for(j=0;j<m;j++)
	   	      cin>>a[i][j];
	   }
	vector <long int >b[n*m];
	long int count=0;
	for(i=0;i<n;i++)
	  {
	  	  for(j=0;j<m;j++)
	  	    {   if(a[i][j]=='.')
	  	    	   ++count;
	  	    	if(i<n-1 && a[i][j]=='.' ){
	  	    	   if(a[i+1][j]=='.'){
	  	    	     b[i*(m)+j].push_back((i+1)*m+j);
	  	    	       //cout<<'a';
	  	    	   }
	  	    	}
	  	    	if(i > 0  && a[i][j]=='.'){
	  	    	  if( a[i-1][j]=='.')
	  	    	    {
	  	    	    b[i*(m)+j].push_back((i-1)*m+j);
	  	    	    //cout<<'b';
	  	    	    }
	  	    	}
	  	    	   
	  	    	if(j<m-1 && a[i][j]=='.'){
	  	    		if( a[i][j+1]=='.')
	  	    		 { b[i*(m)+j].push_back((i)*m+j+1);
	  	    		  //cout<<'c';
	  	    		  }
	  	    	}
	  	    	   
	  	    	if(j>0  && a[i][j]=='.'){
	  	                   if(a[i][j-1]=='.')
	  	                      {b[i*(m)+j].push_back((i)*m+j-1);
	  	                      //cout<<'d';
	  	                      }
	  	    	}
	  	    //  cout<<'\n';	
	  	    	  
	  	    }
	  }
	int vi[n*m];
	long int le[n*m];
	for(i=0;i<n*m;i++)
	  vi[i]=0;
	//cout<<count<<" ";  
	bfs(b,vi,le);
	if(vi[n*m-1]==0)
	   cout<<-1;
	else
	  {
	  	  cout<<(count-le[n*m-1]-1)<<"\n";
	  }
	 return 0;  
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;


int main() {
	int N; cin >> N;
	vector<int> A(N),B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i]; B[i] = A[i];
	}
	sort(B.begin(), B.end());
	for (int i = 0; i < N; i++) {
		if (A[i] != B[N - 1])cout << B[N - 1] << endl;
		else cout << B[N - 2] << endl;
	}
}





Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
using namespace std;
int n,t;
int main(){
	cin>>n;
	if(n<3){puts("0");return 0;}
	while(n>=3){
		t++;
		n-=3;
	}
//	if(n!=0) t--;
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == 'o')
        {
            count++;
        }
    }
    if(count + (15 - s.size()) >= 8)
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

########################################################################################################################################################################

show_flg=False
show_flg=True

ans=0

a,b,c=LI()
k=I()
q=0
for i in range(k+1):
    for j in range(k-i+1):
        #show(c*2**i,b*2**j,a*2**(k-i-j),(i,j,k-i-j),c*2**i>b*2**j>a*2**(k-i-j))
        if c*2**i>b*2**j>a*2**(k-i-j):
            q=1

Yn(q)

Measured memory_bytes: 78468
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  int n; cin>>n;
  int l[n]; for(int i=0;i<n;i++) cin>>l[i];
  sort(l,l+n); int an = 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[i] != l[j] && l[j] != l[k]) {
          //cout<<l[i]<<" "<<l[j]<<" "<<l[k]<<endl;
          an++;
        }
      }
    }
  }
  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int a[5],b[3],k,s,sum=0;
	for(int i=0;i<4;i++) cin >> a[i];
	for(int i=0;i<2;i++) cin >> b[i];

	for(int i=0;i<3;i++){
		if(a[i]<a[i+1]){
			k=a[i];
			a[i]=a[i+1];
			a[i+1]=k;
		}
	}

	for(int i=0;i<2;i++){
		if(b[i]<b[i+1]){
		b[i]=b[i+1];
		}
	}
	
	for(int i=0;i<3;i++){
		sum+=a[i];
	}

	sum+=b[0];

	cout << sum << endl;
	return 0;
}



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

Measured memory_bytes: 256
# input = sys.stdin.readline

def resolve():
    from heapq import heappush, heappop

    # 長点数V、直接移動先とコストを記したリストg、スタート地点rをとって、
    # rからiに行くまでの最低コストがdist[i]であることを意味するリストdistを返す関数
    def dijkstra(V, g, r):

        dist = [INF] * V
        queue = [(0, r)]  # queueの要素(c,v)は、コストcで直接vに行けることを意味する
        dist[r] = 0  # スタート地点rにはコスト0で行ける

        while queue:
            c, v = heappop(queue)
            if dist[v] < c:  # すでに記録されているコストの方が小さいので更新不要
                continue
            for cost, t in g[v]:
                if dist[v] + cost < dist[t]:
                    dist[t] = dist[v] + cost
                    heappush(queue, (dist[t], t))

        return dist

    V, E = map(int, input().split())
    r = 0
    g = [[] for i in range(V)]

    for i in range(E):
        s, t = map(int, input().split())
        s, t = s - 1, t - 1
        d = 1
        g[s].append((d, t))
        g[t].append((d, s))  # g[s]の要素(cost,t)はsからコストcostでtに直接行けることを意味する

    INF = 10 ** 10

    if dijkstra(V, g, r)[-1]==2:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


resolve()

Measured memory_bytes: 113152
using System;
using System.Collections.Generic;
using System.Linq;

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string ans = null;

            foreach(char c in input)
            {
                if (c.Equals('0'))
                {
                    ans += "0";
                }else if (c.Equals('1'))
                {
                    ans += "1";
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(ans))
                    {
                        ans = ans.Remove(ans.Length-1,1);
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  string s; cin >>s;
  string t = "0";
  int n = s.size();
  s = t + s;
  vector<vector<ll>> dp(n+1, vector<ll>(2, INF));
  //dp[i][bigger]...
  dp.at(0).at(0) = 0;
  dp.at(0).at(1) = 1;
  bool bigger = false;
  for (int i=0; i<n; i++){
    int buf = s.at(i+1) - '0';
    chmin(dp.at(i+1).at(0), dp.at(i).at(0) + buf);
    if (buf != 0){
      // biggerを解消
      chmin(dp[i+1][0], dp[i][1] + 10 - buf);
    }
    if (buf != 9){
      // biggerになる
      chmin(dp[i+1][1], dp[i][0] + buf + 1);
    }
    // biggerのまま
    chmin(dp[i+1][1], dp[i][1] + 9 - buf);
  }

  ll res = min(dp[n][0], dp[n][0]);
  cout <<res <<endl;
}

/*
  
*/

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***スニペット***
ifelse, isprime, torad, todeg, lcm, bfs
****************/

//隣接リスト
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a*b,a-b)) ENDL;
    
    return 0;
}

Measured memory_bytes: 5916
#include<stdio.h>

int main()
{
	int N, H[20], ans = 0, max;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	max = H[0];
	for (int i = 0; i < N; i++) {
		if (max <= H[i]) {
			ans++;
			max = H[i];
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 128
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#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 STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

#define INT int

class Int{
public:
	int v;
	Int(){scanf("%d", &v);}
	operator int(){return v;}
};

#define ARC(i,a,b) for(INT i=(a);i<(b);++i)
#define ARCH(i,a,b) for(INT i=(a)-1;i>=(b);--i)
#define RC(i,n) ARC(i,0,n)
#define RCH(i,n) ARCH(i,n,0)
#define SRC(i,s) for(INT i=0;(s)[i];++i)
#define ATH(a,b) ((a)>(b)?(a):(b))
#define OTH(a,b) ((a)<(b)?(a):(b))
#define ANTH(a,b) {if((a)<(b))(a)=(b);}
#define ONTH(a,b) {if((a)>(b))(a)=(b);}
#define ANT printf
#define ENT scanf
#define AN puts
#define AT putchar
#define ET getchar
#define _ AT('\n');

int main(){
	Int a, b, c, d;
	AN(a+b>c+d?"Left":a+b==c+d?"Balanced":"Right");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            Console.WriteLine(a + b / 2);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int x1[5]={1,2,3,4,5};                                         
   int x[5];                                                      
   int i = 0;                                                     
   int ans;                                                       
                                                                  
   scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);         
                                                                  
   while(x1[i] != '\0'){                                          
      if(x1[i] != x[i]){                                          
         ans = x1[i];                                             
         break;                                                   
      }i++;                                                       
   }                                                              
   printf("%d",ans);                                              
   return 0;                                                      
}   

Measured memory_bytes: 1688
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), aa, v;
  rep(i, n) cin >> a.at(i);
  sort(all(a));
  aa = a;
  aa.erase(unique(all(aa)), aa.end());

  for (const auto &i: aa) {
    v.push_back(distance(lower_bound(all(a), i), upper_bound(all(a), i)));
  }
  ll is1 = 0;
  ll is2 = 0;
  for (int i = aa.size() - 1; i != -1; --i) {
    if (v.at(i) >= 2) {
      if (is1 == 0) {
        is1 = aa.at(i);
        if(v.at(i) >= 4){
          is2 = aa.at(i);break;
        }
      }
      else {
        is2 = aa.at(i);
        break;
      }
    }
  }

  cout << is1 * is2 << endl;

  return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
int arr[200000]={};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    long long ans=0;
    for(int i=1;i<n;i++){
        if(arr[i-1]-arr[i]>0){
            ans+=arr[i-1]-arr[i];
        }
        arr[i]=max(arr[i],arr[i-1]);
        //cout<<ans<<'\n';
    }
    cout<<ans<<'\n';
return 0;


}

//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *   ****      *  ****

//     ****  *   *  *   *   ***   *   *  *****  *   *
//    *     *   *  *   *  *   *  *   *  *      *   *
//    ***  *****  *   *  *****  * * *  ****   *   *
//      *   *    *   *  *   *  * * *  *      *   *
//  ****   *     ***   *   *   * *   *****   ***

//        ********                                 . O .
//      *           *                               . .
//     *            * *       * ********
//    * ***********    *    *  *         *
//    *                 * *      *********
//                      *                 *
//                 *   *
//                   *  *
//                     **
//                   *  **  *
//              *  *    * **
//                *     ** * *
//            *   **   ** * *  * *
//           *    * * * * * *   **
//          **************************


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4]={1, 0, 0, -1};
int d4y[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD = 1000000007;   
const int N = 100010;

void run() {
  int n, x ,t;
  cin >> n >> x >> t;
  int ans = 0;
  while(n >= 1) {
    ans += t;
    n -= x;
  }  
  cout << ans;
}

int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  int tc=1;
  //cin >> tc;
  for (int i=1; i<=tc; ++i) {
    run();
  }
  return 0; 
}
/* 
    stuff you shoulds look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

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

int main() {
    int N;
    cin >> N;
    N %= 10;
    switch(N) {
        case 2 :
        case 4 :
        case 5 :
        case 7 :
        case 9 :
            cout << "hon" << endl;
            break;
        case 0 :
        case 1 :
        case 6 :
        case 8 :
            cout << "pon" << endl;
            break;
        case 3 :
            cout << "bon" << endl;
            break;
        default :
            break;  
    } 
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod



int main(){
    ll N; cin>>N;
    vec d(N+2,0);
    REP(i,1,N+1) cin>>d[i];
    vec x(N+1);
    REP(i,1,N+1) x[d[i]]=i;
    ll ans=0;
    set<ll> f,m;
    f.insert(0); f.insert(N+1);
    m.insert(0); m.insert(-N-1);
    REP(i,1,N+1){
        ans+=i*(*f.upper_bound(x[i])-x[i])*(*m.upper_bound(-x[i])+x[i]);
        f.insert(x[i]); m.insert(-x[i]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 25180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, m;
string s;
set<ull> ss;

const ull B = 1e7 + 7;
ull h[1000000];
ull BB[1000000];

void make_hash(string t) {
	h[0] = 0;
	BB[0] = 1;
	rep(i, t.size()) {
		h[i + 1] = h[i] * B + t[i];
		BB[i + 1] = BB[i] * B;
	}
}

//[l,r]のハッシュ値を計算
ull calc(int l, int r) {
	return h[r] - h[l - 1] * BB[r - (l - 1)];
}

int main() {
	cin >> n >> m >> s;
	make_hash(s);
	string t;
	int l = 1, r = 1;
	rep(i, m) {
		cin >> t;
		if (t == "L++")l++;
		else if (t == "L--")l--;
		else if (t == "R++")r++;
		else r--;
		ss.insert(calc(l, r));
	}
	cout << ss.size() << endl;
}


Measured memory_bytes: 21896
N,X =  map(int, input().split())
a = [1 for i in range(N)]
p = [1 for i in range(N)]
for i in range(1,N):
    a[i] = a[i-1]*2 + 3
    p[i] = p[i-1]*2 + 1
def f(N,X):
    if N <= 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1 + a[N-1]:
        return f(N-1,X-1)
    else:
        return p[N-1] + 1 + f(N-1,X-a[N-1]-2)
print(f(N,X))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
int k;
cin>>k;
int ans=1;
int n=7%k;//前回値
int r=0;//合計



if(n==0)
{
cout <<1;
return 0;
}

r=n;
while(1)
{
n=n*10;
n=n%k;
r+=n;r=r%k;
ans++;
if(r==0)break;
if(ans>k){cout <<-1; return 0;}
}
cout<< ans;
    
}

Measured memory_bytes: 3616
#include<stdio.h>
#define RANGE 101
int g[RANGE][RANGE],d[RANGE],f[RANGE];
int ts=0,n;

void search(x){
  int i;
  ts++;
  d[x]=ts;
  for(i=0;i<n;i++){
    if(g[x][i]!=0 && d[i]==0){
      search(i);
    }
  }
  ts++;
  f[x]=ts;
}


int main(){
  int i,j,m,l,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&m);
    scanf("%d",&l);
    for(j=0;j<l;j++){
      scanf("%d",&k);
      g[m-1][k-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==0) search(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}





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

int main() {
   std::vector<int> v(3);
   std::cin >> v.at(0) >> v.at(1) >> v.at(2);
   int memo;


   if (v.at(0) > v.at(1)) {
      memo = 0;
   } else {
      memo = 1;
   }

   for (size_t i = 1; i < v.size(); i++) {
      if (v.at(i) > v.at(memo)) {
         memo = i;
      }
   }
   v.at(memo) *= 10;
   std::cout << v.at(0)+v.at(1)+v.at(2) << '\n';

}


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

int main() {
 int n;
 cin >> n;
 
 string s;
 cin >> s;
 
 for(int i = 0; i < s.size() -1; i++) {
  if(s.at(i) == s.at(i + 1)){
   n--;
   }
   }
   cout << n;
}

Measured memory_bytes: 3732