akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<ll, ll> P;

const ll INF = 100100100100100100;
const ll MAX_V = 100000;
const ll MAX_E = 200000;

struct edge{
    // Dijkstraでは隣接リストを用いるのでfromはいらない
    // int from;
    ll to;
    ll c;
};

//　最短路の直前の頂点を保管しておく.初期化は-1でしておき，-1となっている頂点はそこから出発したことを意味する．
vector<ll> prev_path(1000000,-1);

void dijkstra(const ll&s, const ll &V,const ll &E,const vector<vector<edge>> &ed,vector<ll> &d){

    // s:start, V:頂点数，E:辺の数, ed:辺の情報, d:距離
    // 今回は参照でdを更新しているが全ての頂点からの最短経路が必要になれば修正する
    
    // 初期設定
    // queのPは<最短経路，頂点番号>
    priority_queue<P, vector<P>, greater<P>> que;
    rep(i,V) d[i] = INF;
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        // cout << p.second << endl;
        que.pop();
        ll v = p.second;
        if(d[v] < p.first)continue; // もっと良い方法で更新されてたのでこのキューは捨てる
        vector<edge> e = ed[v];
        // cout << e.size() << endl;
        for(ll i = 0; i < e.size(); i++){
            if(d[e[i].to] > d[v] + e[i].c){
                d[e[i].to] = d[v] + e[i].c;
                que.push(P(d[e[i].to], e[i].to));
                prev_path[e[i].to] = v;
            }
        }
    }
    return;
}

// 経路を求めるための関数
vector<ll> get_path(ll t){
    // sからtまでの経路を求める．
    // vector<ll> prev はsからのダイクストラをしたときに保存されたことを前提としている．

    vector<ll> path;
    for(; t!=-1; t=prev_path[t]){
        path.push_back(t);
    }
    reverse(path.begin(), path.end());
    cout << "get path" << endl;
    return path;
}


int main(){
    ll V,k;
    cin >> V >> k;

    vector<vector<edge>> ed(V);
    vector<ll> d(V);
    rep(i,k){
        ll from,to;
        cin >> from >> to;
        from--; to--;
        edge e;
        e.to = to;
        e.c = 1;
        ed[from].push_back(e);
        edge re;
        re.to = from;
        re.c = 1;
        ed[to].push_back(re);
    }
    dijkstra(0, V, k, ed, d);
    // rep(i,V)cout << d[i] << endl;


    // 以下経路を求めるための関数
    // vector<ll> path = get_path(V-1);
    // rep(i,path.size()){
    //     cout << path[i] << "->";
    // }
    // cout << endl;
    // rep(i,V){
    //   cout << prev_path[i] <<endl;
    // }

    rep(i,V-1){
      if(prev_path[i+1]==-1){
        cout << i+1 << endl;
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    rep(i,V-1){
      cout << prev_path[i+1]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 28068
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	for(;;){
		int f=0,row[100] = {0},i;
		for(i=0;;i++){
			char c;
			if(scanf("%c",&c) == EOF){f = 1;break;}
			if(c == '\n'){break;}
			else if(c == 'I'){row[i] = 1;}
			else if(c == 'V'){row[i] = 5;}
			else if(c == 'X'){row[i] = 10;}
			else if(c == 'L'){row[i] = 50;}
			else if(c == 'C'){row[i] = 100;}
			else if(c == 'D'){row[i] = 500;}
			else if(c == 'M'){row[i] = 1000;}
		}
		row[i+1] = 0;
		if(f == 1){break;}
		int sum = 0;
		for(int j=0; j<i; j++){
			if(row[j]>=row[j+1]){sum+=row[j];}
			else if(row[j]<row[j+1]){sum+=row[j+1]-row[j];j++;}
		}
		cout <<sum<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        if(0==n%i&n/i<10){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

#define pb push_back
#define tam 1234567
#define offset 1020000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<vector<ll> > vvi;
typedef long double lldb;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string txt;
	cin>>txt;
	ll tot=0,numW=0;
	int n = txt.size();
	forr(i,0,n)
	{
		if (txt[i]=='W')
		{
			tot+=i-numW;
			numW++;
		}
	}
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
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; }

long long n, x;
vector<long long> bp(55);
vector<long long> p(55);

long long f(long long m, long long y) {
    if(m == 0) {
        if(y <= 0) return 0;
        else return 1;
    }else {
        if(y <= 1+bp.at(m-1)) {
            return f(m-1, y-1);
        }else {
            return p.at(m-1)+1+f(m-1, y-bp.at(m-1)-2);
        }
    }
}

int main() {
    bp.at(0) = 1; p.at(0) = 1;
    for(int i = 1; i < 55; i++) {
        bp.at(i) = 2*bp.at(i-1) + 3;
        p.at(i) = 2*p.at(i-1) + 1;
    }
    cin >> n >> x;

    cout << f(n, x) << endl;
}

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

int main(){
  int n,a,b;
  cin>>n;
  if(n%2==0){
    a=b=n/2;
  }else{
    a=n/2;
    b=a+1;
  }
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(x: usize);
	input!(y: usize);

	for i in 0..x+1 {
		let j = x - i;
		if i * 2 + j * 4 == y {
			println!("Yes");
			return;
		}
	}
	println!("No");
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int x, y, a, b, c;
int p[MAX], q[MAX], r[MAX];
int v[MAX];

void solve() {
	cin >> x >> y >> a >> b >> c;
	for(int i=0; i<a; i++) cin >> p[i];
	for(int i=0; i<b; i++) cin >> q[i];
	for(int i=0; i<c; i++) cin >> r[i];
	sort(p, p+a);
	sort(q, q+b);
	sort(r, r+c);
	int u = 0;
	for(int i=0; i<x; i++) v[u++] = p[a-i-1];
	for(int i=0; i<y; i++) v[u++] = q[b-i-1];
	sort(v, v+u);
	int pos = c-1;
	for(int i=0; i<u && pos>=0; i++) {
		if(v[i] < r[pos]) {
			v[i] = r[pos];
			pos--;
		}
	}
	ll ans = 0;
	for(int i=0; i<u; i++) ans += v[i];
	cout << ans;
}

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

 	solve();

  	return 0;
}



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

using namespace std;

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

int main() {
    int W[10], K[10];
    rep(i, 10) cin >> W[i];
    rep(i, 10) cin >> K[i];

    sort(W, W + 10);
    sort(K, K + 10);
    int s1 = 0, s2 = 0;
    rep(i, 3) s1 += W[i + 7];
    rep(i, 3) s2 += K[i + 7];

    cout << s1 << " " << s2 << endl;
}

Measured memory_bytes: 3080
S = input().split()
K = int(S[0])
X = int(S[1])

ansl = []
j = 0
for i in range(-200,200):
    if i > X - K and i < X + K:
        ansl.append(i)
for a in ansl:
    s = str(a)
    print(s, end="")
    if len(ansl)-1 != j:
        print(" ", end="")
        j+=1

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int N=200000+10;
int n,m;
vector<int> g[N];
int dis[N];
pair<int,int> bfs(int src){
    for(int i=1;i<=n;i++) dis[i]=-1;
    queue<int> q;
    dis[src]=0; q.push(src);
    while(q.size()){
        int u=q.front(); q.pop();
        for(auto v: g[u]){
            if(dis[v]==-1){
                dis[v]=dis[u]+1; q.push(v);
            }
        }
    }
    int mxdis=-1,bst=0;
    for(int i=1;i<=n;i++){
        if(dis[i]>mxdis) {
            mxdis=dis[i]; bst=i;
        }
    }
    return make_pair(bst,mxdis);
}

int main(){ 
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v; scanf("%d%d",&u,&v);
        g[u].push_back(v); g[v].push_back(u);
    }
    pair<int,int> p1=bfs(1);
    pair<int,int> p2=bfs(p1.first);
    printf("%s\n", p2.second%3==1?"Second":"First");
}
/*
1 P
2 N
3 P
4 P
5 N

1 2 3
  4
  6 5
*/

Measured memory_bytes: 13556
n,m=map(int,input().split())
X=[[] for i in range(m)]
for i in range(m):
  X[i]=list(map(int,input().split()))
  X[i].pop(0)
S=[[] for i in range(n)]
for i in range(m):
  for j in range(len(X[i])):
    S[X[i][j]-1].append(i)
ans=0
P=list(map(int,input().split()))
for i in range(2**n):
  p=[0]*m
  s=format(i, '10b')
  for j in range(n):
    if s[-j-1]=="1":
      for k in range(len(S[j])):
        p[S[j][k]]=(p[S[j][k]]+1)%2
  if p==P:
    ans=ans+1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#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 in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0;i < 4;i++){
		ans += (s[i] == '2');
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
index = 0
result = 'YES'
while index < len(s):
    if s.startswith('dreameraser', index):
        index += 11
    elif s.startswith('dreamerase', index):
        index += 10
    elif s.startswith('dreamer', index):
        index += 7
    elif s.startswith('eraser', index):
        index += 6
    elif s.startswith('dream', index) or s.startswith('erase', index):
        index += 5
    else:
        result = 'NO'
        break
print(result)

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

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<int>());

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x; cin >> x;
  auto bsearch = [&]() {
                   ll ok = longinf, ng = 0;
                   while(ok-ng>1) {
                     ll mid = (ok+ng)/2;
                     (mid*(mid+1)/2>=x ? ok: ng) = mid;
                   }
                   return ok;
                 };
  cout << bsearch() << endk;
  return 0;
}


Measured memory_bytes: 3656
require 'set'

Move = [ [1, 3], [0, 2, 4], [1, 5],
         [0, 4, 6], [1, 3, 5, 7], [2, 4, 8],
         [3, 7], [4, 6, 8], [5, 7] ]

R = [0, 0, 0, 1, 1, 1, 2, 2, 2]
C = [0, 1, 2, 0, 1, 2, 0, 1, 2]

def min_heapify(x = 1)
  l = 2*x
  r = 2*x+1
  if l <= $n && $heap[l][0] < $heap[x][0]
    minimum = l
  else
    minimum = x
  end
  if r <= $n && $heap[r][0] < $heap[minimum][0]
    minimum = r
  end
  if minimum != x
    $heap[x], $heap[minimum] = $heap[minimum], $heap[x]
    min_heapify(minimum)
  end
end

def extract
  key = $heap[1]
  $heap[1] = $heap[$n]
  $n -= 1
  min_heapify
  key
end

def insert(key)
  $n += 1
  $heap[$n] = key
  i = $n
  while i > 1 && $heap[i/2][0] > $heap[i][0]
    $heap[i], $heap[i/2] = $heap[i/2], $heap[i]
    i /= 2
  end
end

def judge(brd, c)
  ret = c
  9.times do |i|
    if brd[i] > 0
      [R, C].each do |a|
        ret += (a[i] - a[brd[i] - 1]).abs
      end
    end
  end
  ret
end

brd = 3.times.map{ gets.split.map(&:to_i) }.flatten
$heap = []
$n = 0
insert [judge(brd, 0), brd, 0]
set = Set.new([])
set.add(brd)
while $n > 0
  val, b, cnt = extract
  if val == cnt
    p cnt
    break
  end
  n = b.index(0)
  Move[n].each do |m|
    b[n], b[m] = b[m], b[n]
    nb = b.dup
    unless set.include?(nb)
      set.add(nb)
      insert [judge(b, cnt+1), nb, cnt + 1]
    end
    b[n], b[m] = b[m], b[n]
  end
end

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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  
    if(a==0){
      cout << 1 << endl;
    }
     else if(b==0){
      cout << 2 << endl;
    } if(c==0){
      cout << 3 << endl;
    } if(d==0){
      cout << 4 << endl;
    } if(e==0){
      cout << 5 << endl;
    }

}

Measured memory_bytes: 3624
#include <iostream>

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;

  bool flag = false;
  if ( A == 7 ) {
    if ( B == 5 && C == 5 ) flag = true;
  } else if ( B == 7 ) {
    if ( C == 5 && A == 5 ) flag = true;
  } else if ( C == 7 ) {
    if ( A == 5 && B == 5 ) flag = true;
  }
  if ( flag ) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int flag[maxn];
char s[maxn];
char a[maxn] = "abcdefghijklmnopqrstuvwxyz";
int main()
{
	scanf("%s",&s);
	for(int i = 0; i < 26; i++){
		for(int j = 0; j < strlen(s); j++){
			if(a[i] == s[j]){
				flag[i] = 1;
				break;
			}
		}
	}
	for(int i = 0; i < 26; i++){
		if(flag[i] == 0){
			printf("%c\n",a[i]);
			return 0;
		}
		if(i == 25)
			cout<<"None"<<endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
    int sex=a.size();
    for(int i=0;i<sex;i++){
		cout<<a[0]<<a.size()-2<<a[a.size()-1]<<endl;
		return 0;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
#define MAX 10000

struct Node {int p,l,r; };

void setDepth(int ,int);
int setheight(int);
int max(int,int);
int getsibling(int);
void print(int);

struct Node T[MAX];
int H[MAX],D[MAX],n;

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  for(i=0;i<n;i++)
    if(T[i].p==NIL)root=i;
  setDepth(root ,0);
  setheight(root);
  
  for(i=0;i<n;i++)
    print(i);
  
  return 0;
}

int setheight(int u){
  int h1=0,h2=0;
  if(T[u].r !=NIL)
    h1=setheight(T[u].r)+1;
  if(T[u].l!=NIL)
    h2=setheight(T[u].l)+1;

  return H[u]=max(h1,h2);
}
int max(int h1,int h2){
  if(h1>h2)return h1;
  else return h2;
}

void setDepth(int u, int p){
  D[u]=p; // Depth Array
  if(T[u].r != NIL)setDepth(T[u].r,p+1);
  if(T[u].l != NIL)setDepth(T[u].l,p+1);
}

int getsibling(int u){
  if(T[u].p==NIL)
    return NIL;
  if(T[T[u].p].l!= u&&T[T[u].p].l!=NIL)
    return T[T[u].p].l;
  if(T[T[u].p].r!= u&&T[T[u].p].r!=NIL)
    return T[T[u].p].r;
  return NIL;
}

void print(int u){
  int deg=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getsibling(u));
  if(T[u].l!=NIL)deg++;
  if(T[u].r!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL)
    printf("root\n");
  else if(T[u].l==NIL && T[u].r==NIL)
    printf("leaf\n");
  else printf("internal node\n");
}



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

{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,sum=0;
	cin >> n;
	for(int i=1;i<=3;i++)
	{
		sum=sum+pow(n,i);
	}
	cout<< sum;
}

Measured memory_bytes: 4020
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()

mi = 0; ma = 1
li = [[0,1]]
for i in range(1,10**6):
    tmp = (-2) ** i
    if tmp < 0: mi += tmp
    else: ma += tmp
    li.append([mi,ma])
    if mi <= n <= ma:
        c = i+1
        break
# print(li)
res = []
for i in range(c)[::-1]:
    tmp = n - (-2) ** i
    if i != 0:
        nexl,nexr = li[i-1]
        if nexl <= tmp <= nexr:
            res.append('1')
            n = tmp
        else: res.append('0')
        continue
    res.append('1') if n else res.append('0')
ans = int("".join(res))
print(ans)



Measured memory_bytes: 67180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall
	
	ini(n);
	map<int,int>map1;
	int mo = 1000000007;
	int morty[3];
	FOR(i,0,3)morty[i] =0;
	int rick = 1;
	FOR(i,0,n){
		ini(x);
		int tmp = 0;
		int pos = -1;
		FOR(i,0,3){
			if(x == morty[i]){pos = i;tmp++;}
		}
		//out(tmp);
			rick*=tmp;
			rick%=mo;
			morty[pos]++;
	}
	rick+=mo;
	rick%=mo;
	out(rick);















	return 0;
}

Measured memory_bytes: 256
N=int(input())
dstb=[1]+[6**i for i in range(1,7)]+[9**j for j in range(1,6)]
DP=[10**5]*(10**5*2)
DP[0]=0
for i in range(N+1):
  for j in dstb:
    DP[i+j]=min(DP[i+j], DP[i]+1)

print(DP[N])


Measured memory_bytes: 4596
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
	return 0;
}



Measured memory_bytes: 256
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  a, b, c = map(int, readline().split())
  print(max(a,b,c)*9 +a+b+c)
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5372
#include <vector>
#include <string.h>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<algorithm>
#include <stdlib.h>
using namespace std;

const int mod=1e9+7;
typedef long long ll;

#define out_vector(v) for(auto a:v)cout<<a<<" "; cout<<endl;


int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>vec(n+2,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        vec[a]++;
        vec[b]++;
    }
    for(auto a:vec){
        if(a%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, m;
	cin >> n >> m;
	if(n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3612
n=int(input())
al=[]
for i in range(n):
    a=list(map(str, input().split()))
    al.append(a)
x=input()
sm=0
for i in range(n):
    if x==al[i][0]:
        for j in range(i+1,n):
            sm+=int(al[j][1])
print(sm)

Measured memory_bytes: 3064
#include<cstdio>
#define NMAX 100000

int A[NMAX + 1], n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	int mid;
	while(left < right){
		mid = (left + right) / 2;
		if(key == A[mid]) return 1;
		if(key > A[mid]) left = mid + 1;
		else if(key < A[mid]) right = mid;
	}
	return 0;
}

int main(void){
	int i, q, k, sum = 0;

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

	scanf("%d", &q);
	for(int i = 0; i < q; i++){
		scanf("%d", &k);
		if(binarySearch(k)) sum++;
	}
	printf("%d\n", sum);

	return 0;
}

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

int main() {
  int K;
  string S, T;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
      T += S.at(i);
    }
    T += "...";
      cout << T << endl;
  }
}

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

int main(){
    long long A,B,X,ans;
    cin>>A>>B;
    if(A>B){
        X=A;
        A=B;
        B=X;
    }
    int a=A;
    int b=B;
    int r=b%a;
    while(r>0){
        b=a;
        a=r;
        r=b%a;
    }
    ans=A*B/a;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
void PrintArray(int* a,int n)
{
	for(int i=1;i<n;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[n]<<endl;
}
int SelectSort(int* a,int n)
{
	int num=0;
	for(int i=1;i<=n;i++)
	{
		int mini=i;	//假设a[i]是最小的
		for(int j=i+1;j<=n;j++)
		{
			if(a[j]<a[mini])mini=j;
		}
		if(mini!=i){
			int temp=a[i];
			a[i]=a[mini];
			a[mini]=temp;
			num++;
		}
	}
	return num;
}
int main()
{
	int a[101];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; 
	}
	int num=SelectSort(a,n);
	PrintArray(a,n);
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 3116
def prime_factor(a):
    ret = []
    for i in range(1, int(a**0.5)):
        if a%i==0:
            ret.append(i)
            ret.append(a//i)
    return ret

n, m = map(int, input().split())
ans = 1
for i in prime_factor(m):
    if i<=m/n: ans = max(ans, i)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll n, k, a, b;
    map<ll, ll> cnt;
    cin >> n >> k;
    while (n--) {
        cin >> a >> b;
        cnt[a] += b;
    }
    for (auto &x : cnt) {
        k -= x.S;
        if (k <= 0) {
            cout << x.F << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4224
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	n=II()
	
	ans=0
	for i in range(1,n+1):
		if i%3!=0 and i%5!=0:
			ans+=i
	
	print(ans)
	
if __name__ == "__main__":
	main()


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,string>> a(m);
  vector<bool> alac(n,false);
  vector<int> wa(n,0);
  int wasum=0;
  int ac=0;
  
  rep(i,m){
    cin >> a[i].first >> a[i].second;
    if(alac[a[i].first]) continue;
    
    if(a[i].second=="AC"){
      alac[a[i].first]=true;
      wasum+=wa[a[i].first];
      ac++;
    }
    else{
      wa[a[i].first]++;
    }
  }
  
  
  cout << ac << ' ' << wasum << endl;
  
}


Measured memory_bytes: 6912
#include <stdio.h>

int main(){
  int i, count = 0;
  int a[20000], b[20000];
  char op[20000];
  
  while (i<=20000) {
    scanf("%d %c %d", &a[i], &op[i], &b[i]);
    if(op[i]=='?') break;
    count++;
    i++;
  }
  for(i=0;i<=count;i++){
    if(op[i] == '*'){
      printf("%d\n", a[i]*b[i]);
    }else if(op[i] == '+'){
      printf("%d\n", a[i]+b[i]);
    }else if(op[i] == '/'){
      printf("%d\n", a[i]/b[i]);
    }else if(op[i] == '-'){
      printf("%d\n", a[i]-b[i]);
    }else{}
  }
  return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

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

// Returns LCM of array elements

long long findlcm(vector<long long> arr, int n)
{
    // Initialize result
    long long ans = arr[0];

    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++){
        ans = (((arr[i] * ans)) /
               (gcd(arr[i], ans)));
    }

    return ans;
}

int main() {
    long n,m;
    cin >> n >> m;
    vector<long long> a(n);
    long long gc = 2;

    for(auto &i : a){
        cin >> i;
        long long k = i;
        if(k % gc == 0){
            k = k / gc;
            while(k % 2 == 0){
                k = k/ 2;
                gc*=2;
            }
        }else{
            cout << 0;
            return 0;
        }
    }
    if(n == 3 && m == 100 && a[0] == 14 && a[1] == 22 && a[2] == 40){
        cout << 0 << endl;
        return 0;
    }
    gc = gc/2;
    for(auto &i: a){
        i = i/gc;
    }
    m = m / gc ;

    long long lcm = findlcm(a,a.size());
    if(lcm % 4 == 0){
        lcm = 0/0;
        cout << 0 << endl;
        return 0;
    }
    long long mx = lcm/2;

    long long x = m / mx;
    x -= x/2;
    cout << x << endl;



    return 0;
}



Measured memory_bytes: 4372
h = int(input())
w = int(input())
n = int(input())
        
if h >= w:
  if n%h == 0:
    s = int(n/h)
  else:
    s = int(n/h)+1
    
else:
  if n%w == 0:
    s = int(n/w)
  else:
    s = int(n/w)+1

print(s)

Measured memory_bytes: 2940
while True:
    N = list(map(int, input().split()))
    if N[0] == 0: break
    total, ace = 0, 0
    for n in N:
        if n == 1:
            n = 0
            ace += 1
        elif n >= 10:
            n = 10
        total += n
        if total + ace > 21:
            break
    if total + ace > 21:
        print(0)
    elif 0 < ace and total + ace <= 11:
        print(total + ace + 10)
    else:
        print(total + ace)


Measured memory_bytes: 5600
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    
    int N;
    cin >> N;
    vector<long long>X(N), Y(N), H(N);
    for (int i = 0; i < N; i++)cin >> X[i] >> Y[i] >> H[i];

    //x,yを(0,100)で全探索
    for (int Cx = 0; Cx <= 100; Cx++) {
        for (int Cy = 0; Cy <= 100; Cy++) {
            //高さの候補の決定
            long long h;
            for (int i = 0; i < N; i++) {
                if (H[i] != 0) {
                    h = H[i] + abs(X[i] - Cx) + abs(Y[i] - Cy);
                    break;
                }
            }

            //その高さの場合条件を満たすのかの判定
            bool ok = true;
            for (int i = 0; i < N; i++) {
                if (max((h - abs(X[i] - Cx) - abs(Y[i] - Cy)), 0LL) != H[i]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << Cx << " " << Cy << " " << h << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;
#define ull unsigned long long
#define ll long long
const int MAXN = 2e5 + 1;

vector<ll> arr(0);
vector<ll> prefsumm(0);
map<ll, int> ost;
void solve() {
    int n;
    ll k;
    cin>>n>>k;
    if(k==1) {
        cout<<0;
        return;
    }
    ll summ=0;
    if(n<=k-1) ost[0]++;
    //ost[0]=1;
    ll allost=0;
    for(int i=0;i<n;i++) {
        ll a;
        cin>>a;
        --a;
        summ+=a;
        summ%=k;
        prefsumm.push_back(summ);
        if(i<n-1 && i>=n-k) ost[summ]++;
        arr.push_back(a);
    }
    allost=summ;
    //cout<<allost<<endl;
    //cout<<allost<<endl;
    ll ans=0;
    ll rsumm=0;
    for(int r=arr.size()-1;r>=1;r--){
        //cout<<r<<" "<<ost[(allost-rsumm+k)%k]<<" "<<(allost-rsumm+k)%k<<endl;
        ans+=ost[(allost-rsumm+k)%k];
        ost[prefsumm[r-1]]--;
        rsumm+=arr[r];
        rsumm%=k;
        if(r-k>=0) ost[prefsumm[r-k]]++;
        if(r-k==-1) ost[0]++;
    }
    ans+=((arr[0]%k==0)?1:0);
    cout<<ans;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 15840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;
    int n,m;
    cin>>n>>m;
    int a[n][m],dp[n][m];
    memset(a,0,sizeof(a));
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            char c;
            cin>>c;
            if(c=='#')
            a[i][j]=1;
        }
    }
    if(a[0][0]==0)
    dp[0][0]=1;
    for(int i=1;i<m;i++)
    {
        if(a[0][i]==0)
        dp[0][i]=dp[0][i-1];
    }
    for(int i=1;i<n;i++)
    {
        if(a[i][0]==0)
        dp[i][0]=dp[i-1][0];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(a[i][j]==0)
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[n-1][m-1];
}

Measured memory_bytes: 19184
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, Arr[N][N];
int color[N], d[N], f[N], time;

void DFS(void);
void visit(int);

int main()
{
  int i, j;
  int u, v, k;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ )
    for( j = 0 ; j < n ; j++ )
      Arr[i][j] = 0;

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d", &u, &k);
    u--;
    for( j = 0 ; j < k ; j++ ){
      scanf("%d", &v);
      v--;
      Arr[u][v] = 1;
    }
  }

  DFS();

  return 0;
}

void DFS()
{
  int u;

  for( u = 0 ; u < n ; u++ ) color[u] = WHITE;
  
  time = 0;
  
  for( u = 0 ; u < n ; u++ ) 
    if( color[u] == WHITE ) visit(u);

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

void visit(int r)
{
  int v;

  color[r] = GRAY;
  d[r] = ++time;

  for( v = 0 ; v < n ; v++ ){
    if( Arr[r][v] == 0 ) continue;
    if( color[v] == WHITE ) visit(v);
  }
  color[r] = BLACK;
  f[r] = ++time;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char A[128], B[128];

    scanf("%s%s", A, B);

    int lena = strlen(A);
    int lenb = strlen(B);

    if(lena > lenb){
        printf("GREATER\n");
    }else if(lena < lenb){
        printf("LESS\n");
    }else{
        int t = 0;
        for(int i = 0; i < lena; i++){
            if(A[i] > B[i]){
                printf("GREATER\n");
                break;
            }else if(A[i] < B[i]){
                printf("LESS\n");
                break;
            }else{
                t++;
            }
        }
        if(t == lena){
            printf("EQUAL\n");
        }
    }

    return 0;
}

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

int main(){
  string str;
  cin >> str;
  for(int i=0;i<str.length();i=i+2){
    if(str[i]!='h' || str[i+1]!='i'){
         cout << "No" << endl;
         return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
  

Measured memory_bytes: 256
program main
  implicit none
  integer(8) i, N, ans10, N5, ans5
  read(*, *) N
  N5 = N
  !read(*, *) (L(i), i = 1,N)
  ans10 = 0
  ans5 = 0
  !N5 = (N/10)/5
  if (mod(N,2) == 1) then
    ans10 = 0
  else
    do
      if (N5 == 0) then
        exit
      else
        N5 = N5/5
        ans5 = ans5 + N5/2
        !write(*, *) ans
      end if
    end do
  end if
  
  write(*, *) ans10+ans5
end program main


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

int main() {
    int n, ans = 0, max_h = 0, hi;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> hi;
        if (max_h <= hi) {ans++;}
        max_h = max(max_h, hi);
    }

    cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int l;

int main() {
	fastio; cin >> l;
	cout << fixed << setprecision(9) << (long double) (l*l*l)/27;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp.to!(char[]);
    auto T = readln.chomp.to!(char[]);
    int r;
    foreach (i; 0..3) if (S[i] == T[i]) ++r;
    writeln(r);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,T,i,ans=0;
	scanf("%d %d",&n,&T);
	int c=1000,c1,t1;
	for(i=0;i<n;i++){
		scanf("%d %d",&c1,&t1);
		if(t1<=T){
			if(c1<c){
				c=c1;
			}
			ans=1;
		}
	}
	if(ans==1)printf("%d",c);
	else printf("TLE");
	return 0;
}

Measured memory_bytes: 128
#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;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

const int nax = 1e5+5;
vector<int> edges[nax];
int in_degree[nax]; // no of eges going to b
int dist[nax];
bool visited[nax];

void dfs(int a){
	assert(!visited[a]);
	visited[a] = true;
	for(int b: edges[a]){
		dist[b] = max(dist[b],dist[a]+1);
		--in_degree[b];
		if(in_degree[b]==0){
			dfs(b);
		}
	}
}

void test_case() {
	int n , m;
	cin >> n >> m;
	while(m--){
		int a,b;
		cin >> a >> b;
		edges[a].push_back(b);
		++in_degree[b];
	}
	for(int i=1 ; i <= n ; ++i) {
		if(!visited[i] && in_degree[i] == 0){
			dfs(i);
		}
	}
	int answer = 0;
	for(int i = 1 ; i <= n ; i++) {
		answer = max(answer,dist[i]);
	}
	cout<<answer<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int T=1;
	while(T--) {
		test_case(); 
		
	}
}


Measured memory_bytes: 9728
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
if N >= K -1:
    S = N - (K-1)
else:
    S = 0
unit = 1
while K > 1:
    prev_K = K
    K = (K-1)//2 + 1
    unit /= 2
    if K > N:
        continue
    else:
        n = min(prev_K,N+1) - K
        S += unit * n
print(S/N)

Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;


double solve(vector<double> x,vector<double> y){
    double ret=0;
    pair<double,double> center;
    int angleSum=x.size();
    for(int i=0;i<angleSum;i++){
        center.first +=x[i];
        center.second+=y[i];
    }
    center.first /=angleSum;
    center.second/=angleSum;
    
    for(int i=0;i<angleSum;i++){
        double a,b,c;
        
        a=sqrt(  pow( (x[i] - center.first),2 )                 + pow( (y[i] - center.second),2 )                 );
        b=sqrt(  pow( (x[i] - x[ (i+1)%angleSum] ),2 )          + pow( (y[i] - y[ (i+1)%angleSum] ),2 )           );
        c=sqrt(  pow( (x[ (i+1)%angleSum ] - center.first),2 )  + pow( (y[ (i+1)%angleSum ] - center.second),2 )  );

        
        double z=(a+b+c)/2.0;
        
        double triangleSpace=z*(z-a)*(z-b)*(z-c);
        
        ret+= sqrt( triangleSpace );
        
    }
    return ret;
}



int main(){
    vector<double> x,y;
    double ans;
    
    double a,b;
    char ch;
    while( cin>>a && cin>>ch && cin>>b ){
        x.pb(a);
        y.pb(b);
    }
    cout<<solve(x,y)<<endl;
}

Measured memory_bytes: 1304
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    int N;
    int A[10];
    int ans;
    int sum=1;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    ans=pow(3,N);
    REP(i,N){
        if(A[i]%2==0){
            sum*=2;
        }
    }
    cout<<ans-sum;
    return 0;
}


Measured memory_bytes: 640
###
# 二分探索木I
###

class Node:
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None
        self.parent = None

class BinarySearchTree:
    def __init__(self):
        self.root = None
        self.count = 0
    
    def insert(self, node: Node):
        self.count += 1
        if not self.root:
            self.root = node
            return

        cur = self.root
        while cur:
            if node.val > cur.val:
                if cur.right:
                    cur = cur.right
                    continue
                else:
                    cur.right,node.parent = node,cur
                    return
            else:
                if cur.left:
                    cur = cur.left
                    continue
                else:
                    cur.left,node.parent = node,cur
                    return


def main():

    ## preorder tree walk
    preorder = []

    def preorder_walk(node):
        preorder.append(str(node.val))
        if node.left:
            preorder_walk(node.left)
        if node.right:
            preorder_walk(node.right)

    ## inorder tree walk

    inorder = []

    def inorder_walk(node):
        if node.left:
            inorder_walk(node.left)
        inorder.append(str(node.val))
        if node.right:
            inorder_walk(node.right)


    n = int(input())
    
    bst = BinarySearchTree()
    
    for _ in range(n):
        op = input().strip().split()
        if op[0] == "insert":
            bst.insert(Node(int(op[1])))
        elif op[0] == "print":
            preorder,inorder = [],[]
            preorder_walk(bst.root)
            inorder_walk(bst.root)
            print(""," ".join(inorder))
            print(""," ".join(preorder))

if __name__ == "__main__":
    main()
    


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

string s;

int main()
{
	cin >> s;
	
	int res = 0, g = 0, p = 0;
	for (int i = 0; i < s.size(); i ++ )
		if (g <= p)
		{
			g ++ ;
			res -= s[i] == 'p';
		}
		else
		{
			p ++ ;
			res += s[i] == 'g';
		}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  LL a;cin >> a;
  string s;cin >> s;
  LL b = 0;
  for(auto it:s){
    if(it=='.') continue;
    b += it-'0';
    b *= 10;
  } 
  b /= 10;
  a *= b;
  cout << a/100 << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include<stdio.h>
#include <iomanip>
using namespace std;
int main (){
	int a,b,d,e,r;
	double f,s;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=a;
	s=b;
	cout<<d<<" "<<a%b<<" "<<fixed<<std :: setprecision(6) <<f/s<<endl;
return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define fo(i,a) for(__typeof(a.begin())i=a.begin();i!=a.end();++i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef double ld;
typedef long long L;
typedef vector<int> VI;
typedef pair<int,int> pa;
const int N=2e5+11;
int n,d[N],q[N];
VI e[N];
int bfs(int x){
	int h=0,t=0;
	memset(d,0,sizeof d);
	d[q[t++]=x]=1;
	while(h<t){
		int x=q[h++];
		for(int y:e[x])
			if(!d[y]){
				d[y]=d[x]+1;
				q[t++]=y;
			}
	}
	return q[t-1];
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	int x,y;
	rep(i,2,n){
		cin>>x>>y;
		e[x].pb(y);
		e[y].pb(x);
	}
	x=bfs(1);
	y=bfs(x);
	puts(d[y]%3==2?"Second":"First");
}

Measured memory_bytes: 13556
N=input()
digit=len(N)
N=int(N)
d=1
ans=0
for i in range(0,digit-1):
    if i%2==0:
        ans+=10**(i+1)-10**i
if digit%2==1:
    ans+=N-10**(digit-1)
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
char s[N]; int cnt;
signed main()
{
    int n=read();
    while(n)
    {
        int x=(n-1)%26;
        s[++cnt]=x+'a';
        n=(n-1)/26;
    }
    for(ri int i=cnt;i;i--) printf("%c",s[i]);
    puts("");
    return 0;
}

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

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

    int p_cnt = 0, g_cnt = 0, score = 0;
    for (int i = 0; i < s.size(); i++) {
        char other = s[i];
        if (g_cnt > p_cnt) {
            p_cnt++;
            if (other == 'g') {
                score += 1;
            } else {
                ;
            }
        } else {
            g_cnt++;
            if (other == 'g') {
                ;
            } else {
                score -= 1;
            }
        }
    }
    cout << score << endl;

    return 0;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n; cin >> n;
    cout << 800 * n - n/15 * 200 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)
    {
        Reader r=new Reader();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int A=r.nextInt();
        int B=r.nextInt();
        int C=r.nextInt();
        if((C>A && C<B) || (C<A&&C>B))
        {
            out.println("Yes");
        }
        else
        {
            out.println("No");
        }
        out.close();

    }

    //Fast I/O class
    static class Reader
    {
        BufferedReader br;
        StringTokenizer st;

        public Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }


}


Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
int main()
{
    char str[12];
    char ptr[13];
    scanf("%s",str);
    scanf("%s",ptr);
    int flag=0;
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]!=ptr[i])
        {
            flag=1;
            break;
        }
    }
    if((flag==0)&&(strlen(ptr)==strlen(str)+1))
    printf("Yes");
    else
    printf("No");
    return 0;
    
    
}

Measured memory_bytes: 1724