akhauriyash/Code-Regression huggingface dataset:
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad 

main :: IO ()
main = readLn >>= main'
    where
        main' n = breads >>= print . solve n . group . sort 

solve :: Int -> [[Int]] -> Int 
solve n (x : xs)
    | head x == 0 && length x == 1 = check 2 xs
    | head x == 1 && length x == 2 = modf $ 2 * check 3 xs
    | otherwise = 0
    where
        check i (y : ys)
            | head y == i && length y == 2 = modf $ 2 * check (i + 2) ys
            | otherwise = 0
        check _ _ = 1

modf :: Int -> Int
modf = (`mod` 1000000007)

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 16764
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int W[200010];
struct edge{int a,b,c;}s[400010];
il bool operator<(const edge&a,const edge&b){return a.c<b.c;}
int fa[200010],siz[200010];
il int hd(int x){return fa[x]==x?x:fa[x]=hd(fa[x]);}
il int Union(int x,int y){
	x=hd(x),y=hd(y);
	if(x==y)return 0;
	if(siz[x]>siz[y])siz[x]+=siz[y],fa[y]=x;
	else siz[y]+=siz[x],fa[x]=y;
	return 1;
}
int main(){
	int n=gi(),Q=gi(),a,b,c;
	for(int i=1;i<=n;++i)W[i]=2e9;
	int o=0;
	for(int i=1;i<=Q;++i){
		a=gi()+1,b=gi()+1,c=gi();
		s[++o]=(edge){a,b,c};
		W[a]=std::min(W[a],c+1);
		W[b]=std::min(W[b],c+2);
	}
	for(int i=1;i<=n;++i)W[i%n+1]=std::min(W[i%n+1],W[i]+2);
	for(int i=1;i<=n;++i)W[i%n+1]=std::min(W[i%n+1],W[i]+2);
	for(int i=1;i<=n;++i)s[++o]=(edge){i,i%n+1,W[i]};
	std::sort(s+1,s+o+1);
	for(int i=1;i<=n;++i)fa[i]=i,siz[i]=1;
	ll ans=0;
	for(int i=1;i<=o;++i)ans+=s[i].c*Union(s[i].a,s[i].b);
	printf("%lld\n",ans);
	return 0;
}



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

long long kp(long long val[], long long wt[], int w, int n){
    long long dp[n+1][w+1];
    for(int i=0; i<n+1; i++){
        for(int j=0; j<w+1; j++){
            if(i==0 || j==0) dp[i][j] = 0;
            else if(wt[i-1]<=j)
                dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    return dp[n][w];
    
}

int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL); 
 int n, w;
 cin>>n>>w;
 long long val[n];
 long long wt[n];
 for(int i=0; i<n; i++)
    cin>>wt[i]>>val[i];
    
 cout<<kp(val, wt, w, n)<<endl;
   return 0;
}

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

int main(){
   int n, m;
   cin >> n >> m;
   cout << m*(m-1)/2 + n*(n-1)/2;
}

Measured memory_bytes: 256
main(r,T,a,b,c,d,e,A,B,C){for(;scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&A,&B,&C)>7;printf("%d\n",r)){
	r=a*A+b*B+c*C;
	if(C>=d){
		if(r>a*A+b*B+e*C)r=a*A+b*B+e*C;
	}else{
		if(r>a*A+b*B+e*d)r=a*A+b*B+e*d;
		if(B+C>=d){
			if(r>a*A+b*(B+C-d)+e*d)r=a*A+b*(B+C-d)+e*d;
		}else if(A+B+C>=d){
			if(r>a*(A+B+C-d)+e*d)r=a*(A+B+C-d)+e*d;
		}else{
			if(r>e*d)r=e*d;
		}
	}
}exit(0);}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  vector<int> number(3);
  int i;
  int k;
  for(i = 0;i < 3;++i){
    cin >> number.at(i);
  }
  cin >> k;
  sort(number.begin(),number.end());
  int ans = number.at(0) + number.at(1);
  for(i = 0;i < k;++i){
    number.at(2) *= 2;
  }
  cout << ans + number.at(2) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = a[0]
cnt = 1
idx = 1
flag = False
while cnt < n-1:
    cnt += 1
    ans += a[idx]
    if flag:
        idx += 1
        flag = False
    else:
        flag = True
print(ans)

Measured memory_bytes: 94200
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e18+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
int main()
{
      lld i,j;
        ts(x,y,z);
        ans=100*x+10*y+z;
        if(ans%4==0)
        {
          yes;
        }
        else
        {
          no;
        }
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[500005],n;
char s[500005];
bool check(int k){
	f[n+1]=0;
	for (int i=1;i<=n;i++)
		f[i]=s[i]*9;
	f[1]+=9*k;
	int s=0;
	for (int i=1;i<=n;i++)
		f[i+1]+=f[i]/10,s+=(f[i]%=10);
	return s+f[n+1]<=9*k;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	reverse(s+1,s+n+1);
	for (int i=1;i<=n;i++)
		s[i]-=48;
	int l=1,r=n,ans=-1;
	while (l<=r){
		int mid=(l+r)/2;
		if (check(mid))
			ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define MOD 1000000007
#define rep(i,l,r) for(ll i=l;i<r;i++)

typedef long long ll;

ll max(ll x, ll y) { return (x > y) ? x : y; }

int main() {
    ll n;
    char s[30001];
    scanf("%lld", &n);
    scanf("%s", s);
    rep(i, 0, n) s[i] -= 48;
    ll cnt[30001] = {};
    bool flag[10] = {};
    for (ll i = n - 2; i >= 0; i--) {
        if (!flag[s[i + 1]]) {
            flag[s[i + 1]] = true;
            cnt[i] = cnt[i + 1] + 1;
        }
        else cnt[i] = cnt[i + 1];
    }
    ll arr[100] = {};
    rep(i, 0, n - 1) {
        rep(j, i + 1, n) {
            arr[s[i] * 10 + s[j]] = max(arr[s[i] * 10 + s[j]], cnt[j]);
        }
    }
    ll ans = 0;
    rep(i, 0, 100) {
        ans += arr[i];
    }
    printf("%lld", ans);

    return 0;
}

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

int A[10];
int N,M,Q,a[50],b[50],c[50],d[50];
int ans = 0;

void dfs(int i,const int start){
    if(i==N){
        int total = 0;
        rep(j,Q){
            if(A[b[j]] - A[a[j]] == c[j]){
                total += d[j];
            }
            ans = max(ans,total);
        }
    }else{
        for(int j=start;j<=M;j++){
            A[i] = j;
            dfs(i+1,j);
        }
    }
}

int main(){
    cin >> N >> M >> Q;
    rep(i,Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    dfs(0,1);
    cout << ans << endl;
}


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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, m;
    string a, b;
    cin>>a>>b;
    cout<<b<<a;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>

int main(int argc, char const *argv[]) {
  int r=0,c=0,x=0;
  std::cin >> r >> c;
  int a[r+1][c+1],b[r+1];

  for(int i=0;i<r+1;i++){
    for(int j=0;j<c+1;j++){
        a[i][j]=0;
        b[i] = 0;
    }
  }

  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      std::cin >> x;
      a[i][j] = x;
      b[i] += x;
    }
  }
  for(int i=0;i<r;i++){
    a[i][c] = b[i];
  }
  for(int i=0;i<c;i++){
    for(int j=0;j<r;j++){
      a[r][i] += a[j][i];
    }
    b[r] += a[r][i];
  }
  a[r][c] = b[r];
  for(int k=0;k<r+1;k++){
    for(int m=0;m<c+1;m++){
      std::cout << a[k][m];
      if(m!=c){
        std::cout << " ";
      }
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3096
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
vl = list(map(int, input().split()))

res = -1

for l in range(min(n+1,k+1)):
    for r in range(min(n+1,k+1)):
        if l+r>k or l+r>n:
            break

        w = k-(l+r)
        sl = []
        if l>0:
            sl = vl[:l]
        if r>0:
            sl += vl[-r:]
        sl = sorted(sl)
        x = w
        for i in range(min(w,len(sl))):
            if sl[i]>0:
                x = i
                break
        sl = sl[x:]
        s = sum(sl)
        res = max(res, s)

print(res)


Measured memory_bytes: 42092
#include <iostream>

using namespace std;

int main(){
    int n;
    int ans = 0;
    cin >> n;

    while(n > 0)
    {
        ans += n % 10;
        n /= 10;
    }

    if(ans == 1)
    {
        cout << 10 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

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

int main(){
  int n;
  int b=0;
  int count=0;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
      cin >> a[i];
      if(a[i]%2==0){
          b++;
          if(a[i]%3==0 || a[i]%5==0){
          count++;
          }
       }
   }
  if(count==b){
      cout << "APPROVED" << endl;
  }else{
      cout << "DENIED" << endl;
  }

    return 0;
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

void solve() {
  int n;
  cin >> n;
  vl a(n);
  REP(i, n) { cin >> a[i]; }
  string s;
  cin >> s;

  vl basis;
  for (int i = n - 1; i >= 0; i--) {
    for (auto b : basis) {
      chmin(a[i], a[i] ^ b);
    }
    if (a[i]) {
      if (s[i] == '0') {
        basis.push_back(a[i]);
      } else {
        cout << 1 << endl;
        return;
      }
    }
  }
  cout << 0 << endl;
  return;
}

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

  int t;
  cin >> t;
  REP(num, t) { solve(); }
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


struct PrimalDual {
	struct edge {
		int to;
		ll cap;
		ll cost;
		int rev;
		bool isrev;

		edge(int _to, ll _cap, ll _cost, int _rev, bool _isrev) :to(_to), cap(_cap), cost(_cost), rev(_rev), isrev(_isrev) {}

	};
	vector<vector<edge>> graph;
	vector<ll> potential, min_cost;
	vector<int> prevv, preve;
	PrimalDual(int V) :graph(V) {}

	void add_edge(int from, int to, ll cap, ll cost) {
		graph[from].emplace_back(to, cap, cost, graph[to].size(), false);
		graph[to].emplace_back(from, 0, -cost, graph[from].size() - 1, true);
	}

	ll min_cost_flow(int s, int t, ll f) {
		int V = graph.size();
		ll res = 0;
		priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> pq;
		potential.assign(V, 0);
		preve.assign(V, -1);
		prevv.assign(V, -1);

		while (f > 0) {
			min_cost.assign(V, INF);
			pq.emplace(0, s);
			min_cost[s] = 0;
			while (!pq.empty()) {
				auto cur = pq.top();
				pq.pop();
				if (min_cost[cur.second] < cur.first) continue;
				for (int i = 0; i < graph[cur.second].size(); i++) {
					edge& e = graph[cur.second][i];
					ll nextCost = min_cost[cur.second] + e.cost + potential[cur.second] - potential[e.to];
					if (e.cap > 0 and min_cost[e.to] > nextCost) {
						min_cost[e.to] = nextCost;
						prevv[e.to] = cur.second;
						preve[e.to] = i;
						pq.emplace(min_cost[e.to], e.to);
					}

				}
			}
			if (min_cost[t] == INF) return -1;
			for (int v = 0; v < V; v++) potential[v] += min_cost[v];
			ll add_flow = f;
			for (int v = t; v != s; v = prevv[v]) {
				chmin(add_flow, graph[prevv[v]][preve[v]].cap);
			}
			f -= add_flow;
			res += add_flow * potential[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge& e = graph[prevv[v]][preve[v]];
				e.cap -= add_flow;
				graph[v][e.rev].cap += add_flow;
			}
		}
		return res;
	}
};

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int V, E, F; scanf("%d %d %d", &V, &E, &F);

	PrimalDual g(V);
	for (int i = 0; i < E; i++) {
		int u, v, c, d; scanf("%d %d %d %d", &u, &v, &c, &d);
		g.add_edge(u, v, c, d);
	}
	cout << g.min_cost_flow(0, V - 1, F) << endl;

	return 0;

}


Measured memory_bytes: 3268
n = int(input())
cost = [0]*n
start = [0]*n
freaq = [0]*n
dp = [[0]*n for _ in range(n)]

for i in range(n-1):
    cost[i],start[i],freaq[i] = map(int,input().split())
    dp[i][i] = start[i]

freaq[n-1] = 1

t = 0

for i in range(n-1):
    for j in range(i+1):
        t = dp[j][i]
        t += cost[i]
        if t%freaq[i+1] != 0:
            t += freaq[i+1] - t%freaq[i+1]
        t = max(t,start[i+1])
        dp[j][i+1] = t

for i in range(n):
    print(dp[i][n-1])

Measured memory_bytes: 14900
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int c[3][3];
    REP(i, 3)
    {
        REP(j, 3)
        {
            cin >> c[i][j];
        }
    }
    int a[3][3], b[3][3];
    // a1 = i
    // b1 = j
    for (int i = 0; i <= 100; i++)
    {
        bool flag = true;
        int j = c[0][0] - i;
        a[0][0] = i;
        b[0][0] = j;
        // c21 = a2 + b1
        // c31 = a3 + b1
        for (int k = 1; k <= 2; k++)
        {
            a[k][0] = -b[0][0] + c[k][0];
        }
        // c12 = a1 + b2
        // c13 = a1 + b3
        for (int k = 1; k <= 2; k++)
        {
            b[0][k] = -a[0][0] + c[0][k];
        }

        for (int k = 1; k <= 2; k++)
        {
            for (int l = 1; l <= 2; l++)
            {
                // ckl = ak + bl
                if (not(c[k][l] == a[k][0] + b[0][l]))
                {
                    flag = false;
                }
            }
        }
        if (flag)
        {
            Yes(1);
            return 0;
        }
    }
    Yes(0);
}


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

using std::cin;
using std::cout;
using std::endl;

int code_length(std::string str) {
	int ret = 1;
	for (int i = 0; i < str.length()-1; i++) {
		if ( str[i] == 'a' || str[i] == 'i' || str[i] == 'u' || str[i] == 'e' || str[i] == 'o' ) {
			ret++;
		}
	}
	return ret;
}

std::string trans_code(std::string str, int k) {
	std::string ret = "";
	ret += str[0];
	for (int i = 0; i < str.length()-1; i++) {
		if ( str[i] == 'a' || str[i] == 'i' || str[i] == 'u' || str[i] == 'e' || str[i] == 'o' ) {
			if ( ret.length() < k ) {
				ret += str[i+1];
			}
		}
	}
	return ret;
}

bool check_fact(std::vector< std::string > v) {
	int size = v.size();
	for (int i = 0; i < size-1; i++) {
		for (int j = i+1; j < size; j++) {
			if ( v[i] == v[j] ) {
				return false;
			}
		}
	}
	return true;
}

int main(void) {
	int n;
	cin >> n;
	while ( n != 0 ) {
		std::vector< std::string > name(n);
		int kmax = 1;
		int temp;
		for (int i = 0; i < n; i++) {
			cin >> name[i];
			temp = code_length(name[i]);
			if ( kmax < temp ) {
				kmax = temp;
			}
		}
		int ret = -1;
		bool find = false;
		std::vector< std::string > code(n);
		for (int i = 1; i < kmax+1 && !(find); i++) {
			for (int j = 0; j < n; j++) {
				code[j] = trans_code(name[j],i);
			}
			if ( check_fact(code) ) {
				ret = i;
				find = true;
			}
		}
		cout << ret << endl;
		cin >> n;
	}
	return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    V[a]++;
    V[b]++;
  }

  for (int i = 0; i < N; i++) {
    cout << V[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

    int N;
    cin >> N;
    vector<ll> X, Y, H;
    ll stdx, stdy, stdh;
    for(int i = 0; i < N; i ++){
        ll x, y, h;
        cin >> x >> y >> h;
        X.pb(x);
        Y.pb(y);
        H.pb(h);
        if(h > 0){
            stdx = x;
            stdy = y;
            stdh = h;
        }
    }
    for(int i = 0; i <= 100; i ++){
        for(int j = 0; j <= 100; j ++){
            int ansh = stdh + abs(i - stdx) + abs(j - stdy);
            bool flag = true;
            for(int k = 0; k < N && flag; k ++){
                if(H[k] != max(ansh - abs(i - X[k]) - abs(j - Y[k]), (ll)0)){
                    flag = false;
                }
            }
            if(flag){
                cout << i << " " << j << " " << ansh << endl;
                return 0;
            }
        }
    }
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

  // vector<vector<vector<int> > > DP =  vector<vector<vector<int> > >(100001,vector<vector<int> >(2,vector<int>(2,0)));
void solve(void)
{
  double L;
  cin>>L;
  cout<<pow(L/3,3)<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    map<int,int> map;
    vint a(n);
    rep(i,n){
        cin >> a[i];
        map[a[i]]++;
    }
    int res=1;
    
    if(n%2==1 && map[0]!=1){
        cout<<0<<endl;
        
        return 0;
    }
    if(n%2==0 && map[0]!=0){
        cout<<0<<endl;
        return 0;
    }
    for(auto m:map){
        if(m.F!=0 && m.S!=0 && m.S!=2){
            cout<<0<<endl;
            return 0;
        }
        if(m.S==2){
            res*=2;
            res%=MOD;
        }
    }
    cout<<res<<endl;
}

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n, t;
    cin >> n >> t;
    vector<int> v(n);

    ll ans = t;
    rep(i, n){
        int x;
        cin >> x;
        v[i] = x;
    }

    rep(i, n-1){
        if(v[i+1] - v[i] >= t){
            ans += t;
        }else{
            ans += v[i+1] - v[i];
        }
    }
 
    cout << ans << endl;

    return 0;
}

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

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

  sort(a, a+N);
  int count = 1;
  
  for (int i = 0; i < N; ++i) {
    if(a[i]<a[i+1]){
      count += 1;
    }
  }

  cout << count << endl;
}

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

int main() {
	int a, b;

	cin >> a;
	cin >> b;

	if (a > b)
		cout << "a > b"<<endl;
	else if (a < b)
		cout << "a < b"<<endl;
	else
		cout << "a == b"<<endl;


	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long MOD = 1000000007;
    int s;
    cin >> s;
    if(s>=3)
    {
        long long divisions[s+1];
        for(int i=0;i<=s;i++)
            divisions[i]=0;
        divisions[0]=1;
        divisions[1]=0;
        divisions[2]=0;
        for(int i=3;i<=s;i++)
        {
            for(int j=3;j<=i;j++)
            {
                divisions[i]=(divisions[i]+divisions[i-j])%MOD;
            }
        }
        cout << divisions[s] << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<String>();
    let a: i64 = v[0].parse().unwrap();
    let b: i64 = v[2].parse().unwrap();
    if v[1] == "+" {
        println!("{}", a + b);
    } else {
        println!("{}", a - b);
    }
}

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
#define INF LONG_MAX
typedef long long ll;
struct Edge{ll u,v,cost;};
using Edges = vector<Edge>;

vector<ll> Bellman_ford(const Edges &edges,int V,int s){
    vector<ll> dist(V,INF);
    vector<bool> negative(V,false);
    dist[s] = 0;
    for(int i = 0; i < V-1 ; i++){
        for(auto e : edges){
            if(dist[e.u] == INF)continue;
            dist[e.v] = min(dist[e.v],dist[e.u]+e.cost);
        }
    }
    for(int i = 0; i < V ; i++){
        for(auto e : edges){
            if(dist[e.u] == INF)continue;
            if(dist[e.v] > dist[e.u]+e.cost){
                dist[e.v] = dist[e.u]+e.cost;
                negative[e.v] = true;
            }
            if(negative[e.u] == true)negative[e.v] = true;
        }
    }
    if(negative[V-1])return vector<ll>();
    
    return dist;
}

int main(){
    int V,E;cin >> V >> E;
    Edges es(E);
    for(int i = 0; i < E ; i++){
        int u,v,cost;
        cin >> u >> v >> cost;u--;v--;cost = -cost;
        es[i].u = u;es[i].v = v;es[i].cost = cost;
    }

    vector<ll> dist = Bellman_ford(es,V,0);
    if(dist.empty())cout << "inf" << endl;
    else cout << -dist[V-1] << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

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

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,k;
  cin>>n>>k;
  int c = 1;
  while(n--){
    c = min(c+k,2*c);
  }
  cout<<c<<endl;
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 079 A / Link: http://abc079.contest.atcoder.jp/tasks/abc079_a  ----- */


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

	LL N; 
	cin >> N;
	LL ans = 0;
	FOR(i, 0, 10) {
		ans |= (N % 1000 == 111 * i);
	}
	N /= 10;
	FOR(i, 1, 10) {
		ans |= (N == i * 111);
	}
	
	
	cout << (ans?"Yes":"No") << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    long K = Long.parseLong(S[1]);
    S = sc.nextLine().split(" ");
    
    int[] nums = new int[N];
    for(int i = 0; i < N; i++){
      nums[i] = Integer.parseInt(S[i]);
    }
    
    int ans = 1;
    int[] reached = new int[N];
    reached[0]++;
    boolean flag = true;
    int count = 0;
    while(K > 0){
      ans = nums[ans-1];
      K--;
      
      if(reached[ans-1] == 1){
        count++;
      }
      if(reached[ans-1] == 2 && flag){
        K %= count;
        flag = false;
      }
      reached[ans-1]++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 63904
#include <iostream>
#include <string>
using namespace std;
int main(){
  string str1, str2;
  int x=0;
  cin >> str1;
  cin >> str2;
  for(int i=0;i<str1.size();i++){
    if(str1[i] != str2[i]){
      x++;
    }
  }
  cout << x;
}
  


Measured memory_bytes: 3828
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


std::vector<long > l(10);
long n;
long A, B, C;
long maxv = 100000;


long dfs(long a, long b, long c, long v, long ad) {
  long val = 0;

  long ret1, ret2, ret3, ret4;
  // cerr << " a :" <<a << "  b :"<<b << "  c:"<<endl;

  if (v < n) {
    long ad_ = 0;
    // ret1 = dfs(a, b, c, v + 1, 0);
    // ad_ = (a > 0) ? ad + 10 : ad + 0;
    // ret2 = dfs(a + l[v], b, c, v + 1, ad_);
    // ad_ = (b > 0) ? ad + 10 : ad + 0;
    // ret3 = dfs(a, b + l[v], c, v + 1, ad_);
    // ad_ = (c > 0) ? ad + 10 : ad + 0;
    // ret4 = dfs(a, b, c + l[v], v + 1, ad_);
    ret1 = dfs(a, b, c, v + 1, 0);
    ret2 = dfs(a + l[v], b, c, v + 1, ad_) + 10;
    ret3 = dfs(a, b + l[v], c, v + 1, ad_) + 10;
    ret4 = dfs(a, b, c + l[v], v + 1, ad_) + 10;

    val = min(min(ret1, ret2), min(ret3, ret4));
  } else {
    if (a == 0 || b == 0 || c == 0) {
      return LINF;
    }
    val = abs(A - a) + abs(B - b) + abs(C - c) + ad - 30;

    if (maxv > val) {
      maxv = val;
      cerr << " a :" << a << "  b :" << b << "  c:" << c << "   sum :" << val << endl;
    }

  }


  return val;
}



int main() {

  cin >> n >> A >> B >> C;

  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }

  double ans = 0;

  ans =  dfs(0, 0, 0, 0, 0);


  cout << ans;

}




















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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

// 150 -c
int main() {
    ll x;
    cin >> x;

    ll y   = 100;
    ll cnt = 0;
    while (y < x) {
        cnt++;
        y *= 1.01;
    }

    cout << cnt << endl;
    return 0;
}



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

int main() {

	int n,a;

	cin >> n;

	vector<int> v;

	for (int i = 0; i < n; i++) {
		cin >> a;
		v.push_back(a);
	}

	sort(v.begin(), v.end(),greater<int>());//昇順

	int alice = 0,bob = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)
			alice += v[i];
		else
			bob += v[i];
	}

	cout << alice - bob << endl;

	

	return 0;
}

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

using ll = long long;
int n;
ll x[1010], y[1010], a, b, t1, t2;
int main()
{
    std::cin >> n;
    for (int i = 0; i < n; i++)
        std::cin >> x[i] >> y[i];
    a = x[0];
    b = y[0];
    for (int i = 1; i < n; i++)
    {
        t1 = (a + x[i] - 1) / x[i];

        t2 = (b + y[i] - 1) / y[i];

        a = x[i] * std::max(t1, t2);
        b = y[i] * std::max(t1, t2);
    }
    std::cout << a + b << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   string N;
   cin >> N;
   bool seven=false;
   for (int i=0;i<3;i++) {
        if(N[i]=='7') {
            seven = true;
            break;
        }
        
   }
   if(seven==true) {
       cout << "Yes" << endl;
   }
   else {
       cout << "No" << endl;
   }
} 


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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);
			Arrays.sort(a);
			int sum = Arrays.stream(a).sum();

			if (sum % 10 == 0) {
				for (int i = 0; i < n; i++) {
					if (a[i] % 10 != 0) {
						sum -= a[i];
						break;
					}
				}
			}

			out.println(sum % 10 == 0 ? 0 : sum);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

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

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

typedef long long ll;

int main(){
    const int MAX = 100100;
    vector <int> num(MAX,1);
    vector <int> l_num(MAX+1,0);
    num[0] = 0; num[1] = 0;
    for(int i = 2; i<=sqrt(MAX); ++i){
        if(num[i]){
            for(int j = 2; i*j<=MAX; ++j) num[i*j] = 0;
        }
    }
    for(int i = 0; i<MAX+1; ++i) l_num[i+1] = l_num[i] + num[(num[i] ? (i+1)/2 : 0)];
    int q; cin >> q;
    int s[q], e[q]; for(int i = 0; i<q; ++i)cin >> s[i] >> e[i] ;
    for(int i = 0; i<q; ++i){
        int ans = 0;
        ans += l_num[e[i]+1] - l_num[s[i]];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007LL
#define PI acosl(-1)

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

void solve()
{
	int x;
	cin >> x;
	if (x >= 30)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}

Measured memory_bytes: 3644
(
    (stdin.ReadLine() |> int),
    (stdin.ReadLine() |> Seq.map string |> Seq.toArray)
)
|> fun (n, s) ->
  [1..(n - 1)]
  |> Seq.fold (fun (prev, prevRet, ret) x ->
    s.[x]
    |> (fun cur ->
      (
          (if prev = "E" then  0 else 1),
          (if cur  = "E" then -1 else 0)
      )
      |> (fun (a, b) -> prevRet + a + b)
      |> (fun newPrevRet ->
          (cur, newPrevRet, min ret newPrevRet)
      )
    )
  ) (
    s.[1..(n - 1)]
    |> Seq.filter (fun x -> x = "E") 
    |> Seq.length
    |> fun x -> (s.[0], x, x)
  )
  |> (fun (_, _, ret) -> ret)
  |> printfn "%d"


Measured memory_bytes: 42776
N=int(input())
h=list(map(int,input().split()))

dp=[0,abs(h[0]-h[1])]
for i in range(2,N):
    dp.append(min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])))
print(dp[-1])

Measured memory_bytes: 13928
N = input()
n = int(N)
summ = 0
tsum = 0
for i in range(n+1):
    if i % 3 == 0 and i % 5 == 0 :
        summ = summ + i
        #print(summ)
    if i % 3 == 0 and i % 5 != 0 :
        summ = summ + i
    if i % 3 != 0 and i % 5 == 0 :
        summ = summ + i
    tsum = tsum + i
print(tsum-summ)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  ll maxv = a[0], minv = a[0];
  int maxIdx = 0, minIdx = 0;
  rep(i, n) {
    if (maxv < a[i]) {
      maxv = a[i];
      maxIdx = i;
    }
    if (minv > a[i]) {
      minv = a[i];
      minIdx = i;
    }
  }

  vector<pii> ans;
  if (abs(maxv) > abs(minv)) {
    rep(i, n) {
      if (a[i] < 0) {
        ans.eb(mp(maxIdx, i));
      }
    }
    rep(i, n - 1) ans.eb(mp(i, i + 1));
  } else {
    rep(i, n) {
      if (a[i] > 0) {
        ans.eb(mp(minIdx, i));
      }
    }
    for (int i = n - 1; i > 0; i--) ans.eb(mp(i, i - 1));
  }

  cout << ans.size() << endl;
  rep(i, ans.size()) cout << ans[i].F + 1 << ' ' << ans[i].S + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const string C = "rssppr";

int score(char mc, char tak)
{
    FOR(i, 0, 3)
        if (C[2 * i] == tak && C[2 * i + 1] == mc)
            return 1;
    return 0;
}

int bestScore(string machine, int R, int P, int S)
{
    const int N = machine.size();
    int r = 0, p = 0, s = 0;
    FOR(i, 0, N) {
        char mc = machine[i];
        int r2 = 0, p2 = 0, s2 = 0;
        r2 = max(p, s) + score(mc, 'r') * R;
        p2 = max(r, s) + score(mc, 'p') * P;
        s2 = max(r, p) + score(mc, 's') * S;
        r = r2;p = p2; s = s2;
    }

    return max(r, max(p, s));
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K, R, P, S;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int ret = 0;
    FOR(i, 0, min(N, K)) {
        ostringstream out;
        for (int j = i;j < N;j += K) {
            out << T[j];
        }

        ret += bestScore(out.str(), R, P, S);
    }

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;


struct cont
{
	int lft;
	int rgt;
	int dist;
};
struct cmp
{
	bool operator()(const cont & c, const cont & d)const{
		if(c.dist!=d.dist){return c.dist<d.dist;}
		else
		{
			return make_pair(c.lft,c.rgt)<make_pair(d.lft,d.rgt);
		}
	}
};
signed main()
{ 
	speed
	int n,m;cin>>n>>m;
	vector<cont> inp(m);
	vector<vector<cont>> mp(n);
	for (int i = 0; i < m; ++i)
	{
		cin>>inp[i].lft>>inp[i].rgt>>inp[i].dist;
		--inp[i].lft;--inp[i].rgt;
		mp[inp[i].lft].push_back(inp[i]);
	}
	set<cont,cmp> st;
	int pres=0;
	for(auto it:mp[0]){st.insert(it);}
	vector<int> fin(n,0);
	while(!st.empty())
	{
		auto it=*st.begin();
		st.erase(it);
		int lft=it.lft,rgt=it.rgt,cost=it.dist;
		if(rgt>pres)
		{
			for(int i=pres+1;i<=rgt;++i)
			{
				fin[i]=cost;
			}
			for(int i=pres+1;i<=rgt;++i)
			{
				for(auto pp:mp[i])
				{
					cont tmp=pp;
					tmp.dist+=fin[tmp.lft];
					st.insert(tmp);
				}
			}
			pres=rgt;
		}
	}
	if(pres==n-1){cout<<fin[n-1];}
	else{cout<<-1;}
}

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

using namespace std;

const int N = int(1e5 + 10);
int n;
int b[N];
int a[N];

int main(){
	int n;

	scanf("%d", &n);

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

	a[n] = b[n - 1];

	for(int i = n - 1 ; i >= 1 ; i--){
		if(a[i + 1] > b[i]){
			a[i + 1] = b[i];
		}

		a[i] = b[i];
	}

	int sum = 0;

	for(int i = 1 ; i <= n ; i++){
		sum += a[i];
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a[5];
	int k;
	int c = 0;
	for (int i = 0; i < 5; i++){
		cin >> a[i];
	}
	cin >> k;
	for (int i = 0; i < 5; i++) {
		int j = a[i] - a[0];
		if (j > k) {
			c = 1;
			break;
		}
	}
	if (c == 0) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;
typedef long long ll;
const int maxn=1e5+1111;

int arr[maxn];
int dp[maxn];
int main(){
    int n,k;
    scanf("%d",&n);
    k=2;
    dp[0]=dp[1]=0;
    for(int i=1;i<=n;++i){
        scanf("%d",arr+i);
        if(i>1) dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
        for(int j=2;j<=k&&i-j>0;++j){
            dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
        }
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1024