akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
ll N,X;
ll rec(ll n, ll x){
  if(n==0) return 1;
  ll len = (1LL<<(n+1)) - 3;
  ll num = (1LL<<n) - 1;
  if(x==1) return 0;
  else if(x<=len+1) return rec(n-1, x-1);
  else if(x==len+2) return num+1;
  else if(x<=(len+1)*2) return num+1+rec(n-1, x-(2+len));
  else return 2*num+1;
}
int main(){
  cin>>N>>X;
  cout<<rec(N,X)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){

}
int a[1000],b[1000],c[1000],d[1000];
int point[1000000]={0};
int tmp(cv *p,cv *q){
  return point[*(int *)q]-point[*(int *)p];//スコアが高い方から貪欲に
}
int main(void){
  initialize();
  ll n,m,q,i,j,k,result=0,sCount=0,p;
  scanf("%lld %lld",&n,&m);
  for(i=1;i<=floorl(m/2.0);i++){
    if(m%2==1){
      printf("%lld %lld\n",i,m+1-i);
    }else{
      printf("%lld %lld\n",i,m+2-i);
    }
  }
  for(i=1;i<=ceill(m/2.0);i++){
    if(m%2==1){
      printf("%lld %lld\n",m+i,2*m+2-i);
    }else{
      printf("%lld %lld\n",m+i+1,2*m+2-i);
    }
  }
  
  return 0;
}



Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 10000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

vector<ll> dist(100005);
vector<int> visit(100005);
vector<vector<pair<int,int>>> edge(100005);

void dfs(int v,ll d){
    dist[v]=d;
    visit[v]=1;
    for(int i=0;i<edge[v].size();i++){
        if(visit[edge[v][i].first]==0) dfs(edge[v][i].first,d+edge[v][i].second);   
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        edge[a].push_back({b,c});
        edge[b].push_back({a,c});
    }
    int q,k;
    cin>>q>>k;
    vector<pair<int,int>> que(q+5);
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        que[i]={x,y};
    }
    dfs(k,0);
    for(int i=0;i<q;i++) cout<<dist[que[i].first]+dist[que[i].second]<<endl;
    return 0;
}

Measured memory_bytes: 12416
# include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAXN 1000001
void solve(){
set<string>s;
string x;
ll n;
cin>>n;
while(n--)
{
	cin>>x;
	s.insert(x);
}
cout<<s.size()<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 19244
s = str(input())

le = len(s)

while le>=5:
    fiv = s[-5:]
    six = s[-6:]
    sev = s[-7:]

    if fiv=="dream" or fiv=="erase":
        s = s[:-5]
    elif six=="eraser":
        s = s[:-6]
    elif sev=="dreamer":
        s = s[:-7]
    else:
        print("NO")
        exit()
    
    le = len(s)

if le==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9256
#ABC084C
N=int(input())
CSF = []
ans = [0]*N
ans[N-1]=0
t=0
for i in range(N-1):
    CSF.append(list(map(int, input().split())))

for i in range(N-1):
    t=0
    for j in range(N-1):
        if j<i:
            continue
        if t<=CSF[j][1]:
            t=CSF[j][1]+CSF[j][0]
        elif (t-CSF[j][1])%CSF[j][2]==0:
            t=CSF[j][0]+CSF[j][1]+((t-CSF[j][1])//CSF[j][2])*CSF[j][2]
        else:
            t = CSF[j][0] + CSF[j][1] + ((t - CSF[j][1]) // CSF[j][2]+1) * CSF[j][2]
    ans[i]=t

for i in range(N):
    print(ans[i])

Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}


int main(void) {

	int k;
	string s;
	cin >> k >> s;

	if (k < s.size()) {
		s = s.substr(0,k);
		s += "...";
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

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

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    i64 x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
def frog(num):
    if num == 1:
        return 0
    elif num == 2:
        return abs(h[1] - h[0])
    else:
        l1 = [frog(1), frog(2)]
        for i in range(2, num):
            p1 = l1[i - 1] + abs(h[i - 1] - h[i])
            p2 = l1[i - 2] + abs(h[i - 2] - h[i])
            if p1 >= p2:
                l1.append(p2)
            else:
                l1.append(p1)
    return l1[num - 1]
print(frog(n))

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl
int a, b, c;
int main ()
{
    cin >> a >> b >> c;
    if((a == b and a != c) or (b == c and b != a) or (a == c and a != b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n = I()
    a = LI()
    if sorted(a) == a:
        print(0)
        quit()
    ans = []
    ma = a.index(max(a))
    mi = a.index(min(a))
    if a[ma] > abs(a[mi]):
        if ma != 0:
            for i in range(2):
                ans.append([ma+1,1])
        for i in range(n-1):
            for j in range(2):
                ans.append([i+1,i+2])
    else:
        if mi != n-1:
            for i in range(2):
                ans.append([mi+1,n])
        for i in range(n-1)[::-1]:
            for j in range(2):
                ans.append([i+2,i+1])
    print(len(ans))
    for i,j in ans:
        print(i,j)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 41200
n = int(input())

ans = n

for i in range(n+1):
    cc = 0

    t = i
    while t>0:
        cc += t%6
        t //= 6

#    print('{},{}:'.format(i,cc),end = ' ')

    t = n-i
    while t>0:
        cc += t%9
        t //= 9
    
#   print('{},{}:'.format(n-i,cc))
    ans = min(ans, cc)

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, M;
vector<ll> A;
const int MAX_M = 300010;
ll left_sum, right_sum;
priority_queue<pair<ll, ll>> left_que, right_que;
bool left_idx[MAX_M];
bool right_idx[MAX_M];
int main() {
  cin >> N;
  M = 3 * N;
  A.resize(M);
  for (auto &val : A) {
    cin >> val;
  }
  // left
  for (int i = 0; i < N; i++) {
    left_sum += A[i];
    left_idx[i] = true;
    left_que.emplace(mp(-A[i], i));
  }
  // right
  for (int i = N; i < M; i++) {
    right_que.emplace(mp(-A[i], i));
  }
  int cnt = 0;
  while (cnt < N) {
    auto p = right_que.top();
    right_que.pop();
    int val = -p.first;
    int idx = p.second;
    right_sum += val;
    right_idx[idx] = true;
    cnt++;
  }
  ll result = left_sum - right_sum;

  for (int i = N; i < M; i++) {
    if (left_que.empty() or right_que.empty()) {
      break;
    }
    if (right_idx[i] > 0) {
      right_sum -= A[i];
      right_idx[i] = false;
      auto right_min = right_que.top();
      right_que.pop();
      int right_min_val = -right_min.first;
      int right_min_idx = right_min.second;
      while (right_min_idx <= i) {
        if (right_que.empty()) {
          goto end;
        }
        auto right_min = right_que.top();
        right_que.pop();
        right_min_val = -right_min.first;
        right_min_idx = right_min.second;
      }
      right_sum += right_min_val;
      right_idx[right_min_idx] = true;
    }

    left_sum += A[i];
    left_idx[i] = true;
    left_que.emplace(mp(-A[i], i));
    auto left_min = left_que.top();
    left_que.pop();
    int left_min_val = -left_min.first;
    int left_min_idx = left_min.second;
    left_sum -= left_min_val;
    left_idx[left_min_idx] = false;

    result = max(result, left_sum - right_sum);
  }
end:;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 10480
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

count = [0 for _ in range(len(A))]

for i in range(len(A)):
    amari = 0
    while not (A[i] % 2):
        if not (A[i] % 2):
            A[i] //= 2
            count[i] += 1

print(min(count))

Measured memory_bytes: 3060
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int X = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();
            int res = B-A;
            if(res>X) out.println("dangerous");
            else if(res>0) out.println("safe");
            else out.println("delicious");
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}

Measured memory_bytes: 23124
# -*- coding: utf-8 -*-

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x[1]:
            i += 1
            A[i], A[j] = A[j], A[i]
    
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)
    
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:left+n1]
    R = A[mid:mid+n2]
    L.append([None, float('inf')])
    R.append([None, float('inf')])
    
    i = 0
    j = 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


if __name__ == '__main__':

    n = int(input())
    A = [input().split(" ") for _ in range(n)]
    
    A_m = [(a[0], int(a[1])) for a in A]
    A_q = [(a[0], int(a[1])) for a in A]

    mergeSort(A_m, 0, n)
    quickSort(A_q, 0, n-1)

    if A_m == A_q:
        print("Stable")
    else:
        print("Not stable")

    for a in A_q:
        print(a[0], a[1])





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

int main (){
    int n;
    int sum=0;
    cin>>n;
    vector <int> num(n-1);
    rep(i,n-1){
        cin >> num.at(i);
    }
    rep(i,n){
        if(i==0) sum+=num.at(0);
        else if(i==n-1) sum+=num.at(n-2);
        else sum+=min(num.at(i-1),num.at(i));
    }
    cout << sum <<endl;
    return 0;
}


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

int main (void){
	int s=0,i,n=0;
	char c[1010];
	while(1){
		scanf("%s",&c);
		if(c[0]=='0'){
			break;
		}
		n=strlen(c);
		for(i=0;i<n;i++){
			s+=c[i]-'0';
		}
		printf("%d\n",s);
		s=0;
		n=0;
	}
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	vector<int> v;
	int i = 1;
	v.push_back(0);
	while(true){
		if (i*i > 1000000000) break;
		v.push_back(i*i);
		i++;
	}
	for (int j = v.size()-1; j >= 0; j--){
		if (v[j] <= n){
			cout << v[j] << endl;
			return 0;
		}
	}
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	vector<int> l(n, 0), r(n, 0);
	
	for(int i=0; i < n-1; i++) {
		l[i+1] = __gcd(l[i], a[i]);
	}
	for(int i=n-1; i >= 1; i--) {
		r[i-1] = __gcd(r[i], a[i]);
	}
	
	int max_gcd = -1;
	
	for(int i = 0; i < n; i++) {
		max_gcd = max(max_gcd, __gcd(l[i],r[i]));
	}
	cout << max_gcd;
	return 0;
}

Measured memory_bytes: 1408
def count_devide2(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x /= 2 
    return cnt

n = int(input())
Max = 0
for i in range(1,n+1):
    if Max <= count_devide2(i):
        ans = i
        Max = count_devide2(i)
print(ans)

Measured memory_bytes: 3060
/*
 * main.c
 *
 *  Created on: 2019/01/27
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>

int data[101] = {0};

int give_water(int n)
{
	int i = 0;
	int no_data=0;
	int edit_data = 0;
	for(i = 0; i < n; i++) {
		if (data[i] == 0) {
			if (edit_data == 1) {
				return 0;
			}
			no_data++;
			continue;
		}
		data[i]--;
		edit_data = 1;
	}
	if (n == no_data) {
		return 1;
	}
	return 0;
}

int main() {
	int n_flower = 0;
	int i = 0;
	int result = 0;

	scanf("%d", &n_flower);
	for(i = 0; i < n_flower; i++) {
		scanf("%d",&data[i]);
	}
	i = 0;
	while(1) {
		result = give_water(n_flower);
		if (result == 1) {
			break;
		}
		i++;
	}
	printf("%d\n",i);
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<char> vec((H+2)*(W+2), '#');

  for (int h = 1; h < H+1; h++) {
    for (int w =1; w<W+1;w++){
      cin >> vec.at(w+(W+2)*h);
    }
  }
  for(int h=0;h<H+2;h++){
    for(int w=0;w<W+2;w++){
      cout << vec.at((W+2)*h+w);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
S = input()

ans = ''

lcount = 0
rcount = 0
now = 0
for i in range(N):
  si = S[i]
  if (lcount==0) and (si==')'):
    rcount += 1
    ans = '(' + ans + ')'
  elif si == ')':
    lcount -= 1
    ans = ans + ')'
  
  if (rcount>=1) and (si=='('):
    rcount = 0
    lcount = 1
    ans = ans + '('
  elif si == '(':
    ans = ans + '('
    lcount += 1
    

ans = ans + ')'*lcount
print(ans)
  
  

Measured memory_bytes: 3064
#include <cstdio>

int N;

int nums[201];

int main()
{
    scanf(" %d", &N );

    int ans=0;
    for ( int i=0; i<N/2+2; i++ ) {
        int x = 2*i+1;
        for ( int j=1; j*x<=N; j++ ) {
            nums[j*x]++;
        }
        if ( nums[x] == 8 ) ans++;
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
root=[-1]*n
def r(x):
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i))
print(ans)





Measured memory_bytes: 96456
import math
import heapq
from bisect import bisect_right, bisect_left
from collections import defaultdict, Counter
import itertools
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def lcm(a, b):
    return a * b / gcd(a, b)


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True



def main():
    a, b = map(int, input().split())
    l = make_divisors(a)
    d = Counter(l)
    ll = make_divisors(b)
    lll = []
    for i in range(len(ll)):
        if d[ll[i]] > 0:
            lll.append(ll[i])
    ans = 1
    for i in range(len(lll)):
        if is_prime(lll[i]):
            ans += 1
    print(ans)


    

if __name__ == '__main__':
    main()


Measured memory_bytes: 68072
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MN=1e5+10,MW=1e5+10;
int n,w;
ll ans,dp[MW];
typedef pair<int,int> P;
P a[MN];
int main()
{
    scanf("%d%d",&n,&w);
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i].first,&a[i].second);
    if(a[0].first<=w)
        dp[a[0].first]=a[0].second,ans=a[0].second;
    for(int i=1;i<n;i++)
        for(int j=w;j;j--)
            if(j-a[i].first>=0)
                dp[j]=max(dp[j],dp[j-a[i].first]+a[i].second),ans=max(ans,dp[j]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  long max = 0;
  long min = 1000000000;
  vector<long> a;
  for(int i = 0; i< N; i++){
    long A;
    cin >> A;
    if(min > A) min  = A;
    if(max < A) max = A;
  }
  cout << max - min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
const string FIN = "END OF INPUT";
int main(){
  while(1){
    string s;
    getline(cin,s);
    if(s == FIN)break;
    int cnt = 0;
    for(int i = 0;i < s.size();i++){
      if(s[i] == ' '){
	cout << cnt;
	cnt = 0;
      }else{
	cnt++;
      }
    }
    cout << cnt <<endl;
  }
  return 0;
}

Measured memory_bytes: 1192
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.14 21:03:51
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    vector<int> v(5);
    for (int i = 0; i < 5; i++) {
        cin >> v[i];
        if (v[i] == 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	} else {
		cout << "safe" << endl;
	}
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 3608
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val x = sc.nextLong()


  var count = x / 11L * 2L
  val last = x % 11L
  if (last > 6) {
    count += 2L
  } else if (last > 0) {
    count += 1L
  }


  println(count)

}


Measured memory_bytes: 36348
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n,k;
  cin>>n>>k;
  ll p[n];
  ll c[n];
  ll ans=-INF;
  rep(i,n){
    cin>>p[i];
    p[i]--;
  }
  rep(i,n){
    cin>>c[i];
  }
  
  rep(i,n){
    ll nc=0;
    ll v=i;
    ll cnt=0;
    
    
    while(true){
      nc+=c[v];
      cnt++;
      v=p[v];
      if(v==i) break;
    }
    
    ll count=0;
    ll now=0;
    
    while(true){
      now+=c[v];
      count++;
      
      if(count>k) break;
      
      ll s=now+max(0ll,nc)*((k-count)/cnt);
      ans=max(ans,s);
      
      v=p[v];
      if(v==i) break;
    }
    
  }
  
  cout<<ans<<endl;
}
      



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

using namespace std;

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second


double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=200010;


int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
int n;
cin>>n;
int arr[n+1][3];
for(int i=1;i<=n;i++)cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
ll dp[n+1][3];
dp[0][0]=dp[0][1]=dp[0][2]=0;
for(int i=1;i<=n;i++){
    dp[i][0]=dp[i][1]=dp[i][2]=0;
    for(int j=0;j<3;j++){
        dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+arr[i][j];
    }
}
cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}
return 0;
}



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

        int main() {
            int N;
            cin>>N;
            vector<int> L(N); 

          
          for(int i=0; i<N; i++){
               cin>> L.at(i);  
          }

          sort(L.begin(),L.end()); 
          
          int count =0; 
          
          for(int i=0; i<N-1;i++){
                for(int j=i+1; j<N; j++){
                      
                      
                                  int left=0;
                                  int right=N-1;
                                  int x=L.at(i) + L.at(j); 
                                  
                                  if(x > L.at(N-1)){
                                        left = N-1;
                                  }else{
                                          while(right-left>1){
                                                int middle = (right+left)/2;
                                                if( L.at(middle) >= x ) right = middle; 
                                                if( L.at(middle) < x ) left = middle; 
                                                
                                          }
                                  }                       

                  count = count + left - j ;     
                }
          }
          
          

          
          cout<< count << endl; 
          
          


        }


Measured memory_bytes: 256
s = input()
k = int(input())
l = [(26 - (ord(c) - ord('a'))) % 26 for c in s]
for i in range(len(s) - 1):
    if k >= l[i]:
        k -= l[i]
        s = s[:i] + 'a' + s[i + 1 :]

k %= 26
s = s[:-1] + chr(ord('a') + (ord(s[-1]) - ord('a') + k) % 26)
print(s)


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


int main(){
	int a,b;
	cin >> a >> b;


	if(a-b >= 2 || b-a >= 2) cout << "0" << endl;

	else if(a-b == 1 || b-a==1) {
		long long p_a = 1;
		long long p_b = 1;
		for(int i = 1; i <= a; i++){
			p_a = (i*p_a)%1000000007;
		}
		for(int i = 1; i <=b; i++)
			p_b = (i*p_b)%1000000007;

		cout << (p_a*p_b)%1000000007 << endl;
		}

	else if(a==b) {
		long long p = 1;
		long long q = 1;
		for(int i = 1; i <= a;i++){
			p= (i*p) % 1000000007;
			


		}
		p = (p*p) % 1000000007;
		p = (p*2)% 1000000007;
		cout << p << endl;
	}

		


}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int  b = sc.nextInt();
    int c = sc.nextInt();
    if((10*b+c)%4==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

  }
  

  
}


Measured memory_bytes: 23124
c=[[int(x) for x in input().split()]for i in range(3)]

a=[0,0,0]
b=[0,0,0]

b[0]=c[0][0]
b[1]=c[0][1]
b[2]=c[0][2]
a[1]=c[1][0]-b[0]
a[2]=c[2][0]-b[0]

ans="Yes"
for i in range(3):
  for j in range(3):
    if c[i][j]!=a[i]+b[j]:
      ans="No"
      
print(ans)

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k, n;
	cin>>k>>n;
	int a[n];
	int w = k;
	for(int i=0; i<n; i++)
		cin>>a[i];
	for(int i=1; i<n; i++) {
		int odl = a[i] - a[i-1];
		w = min(w, k-odl);
	}
	int odl = (k-a[n-1]) + a[0];
	w = min(w, k-odl);
	cout<<w;
}


Measured memory_bytes: 1152
/*
 * hujx.cpp
 *
 *  Created on: 2015年5月21日
 *      Author: dell
 */
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
#include<set>
//#define ONLINE_JUDGE
#define eps 1e-8
#define INF 0x7fffffff
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,num) scanf("%d%d%d",&a,&b,&num)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll __int64
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
//#pragma comment(linker,"/STACK:1024000000,1024000000")
int n,m,k;
#define M 110
#define N 500010
#define Mod 258280327
#define p(x,y) make_pair(x,y)
char ch[1010][1010];
int vis[1010][1010];
int posx[15];
int posy[15];
struct Node{
	int x,y;
	int step;
};
bool check(int x,int y){
	if(x<0 || x>=n || y<0 || y>=m || ch[x][y] == 'X' ||vis[x][y])
		return false;
	return true;
}
int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int bfs(int stx,int sty,int edx,int edy){
	memset(vis,0,sizeof vis);
	queue<Node> q;
	Node cur,next;
	cur.x = stx;
	cur.y = sty;
	cur.step = 0;
	vis[cur.x][cur.y] = 1;
	q.push(cur);
	int ans;
	while(!q.empty()){
		cur = q.front();
		q.pop();
		if(cur.x == edx && cur.y == edy){
			ans = cur.step;
			break;
		}
		for(int i=0;i<4;i++){
			next = cur;
			next.x += dir[i][0];
			next.y += dir[i][1];
			next.step ++;
			if(!check(next.x,next.y)) continue;
			vis[next.x][next.y] = 1;
			q.push(next);
		}
	}
	return ans;
}
int main(){
	while(scanf("%d%d%d",&n,&m,&k)!=EOF){
		for(int i=0;i<n;i++)
			sfs(ch[i]);
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(ch[i][j] == 'S'){
					posx[0]=i;
					posy[0]=j;
				}
				if(ch[i][j]>='1' && ch[i][j]<='9'){
					posx[ch[i][j]-'0'] = i;
					posy[ch[i][j]-'0'] = j;
				}
			}
		}
		int ans=0;
		for(int i=0;i<k;i++){
			ans += bfs(posx[i],posy[i],posx[i+1],posy[i+1]);
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 6192
import java.util.Scanner;

public class Main{

    static int[][] dp = new int[201][201];
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int k = stdIn.nextInt();

        long sum = 0;
        for(int a=1; a<=k; a++){
            for(int b=1; b<=k; b++){
                for(int c=1; c<=k; c++){
                    sum += tripleGcd(a, b, c);
                }
            }
        }

        System.out.println(sum);
    }

    static int tripleGcd(int a, int b, int c){
        int ab = gcd(a, b);
        return gcd(ab, c);
    }

    static int gcd(int a, int b){
        int ans;
        if(b>a){
            ans = gcd(b, a);
        }else if(b == 0){
            ans = a;
        }else{
            ans = gcd(b, a%b);
        }
        dp[a][b] = ans;
        return ans;
    }
}

Measured memory_bytes: 37080
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  int old = -1;
  int now = 0;
  int ans = 0;
  int tmp = 0;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
    old = now;
    cin >> now;
    if (old + 1 == now) {
      list[old] = 1;
    }
  }
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    ans+= tmp;
  }
  for (int i = 1; i < N; i++) {
    cin >> tmp;
    if (list[i] == 1) {
      ans += tmp;
    }
  }
  cout << ans;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


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

using namespace std;

int main(){
	char c;
	cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin.tie(0);
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n;
const ll maxn=200005;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;
ll num[200005];
ll fro[200005],bac[200005];
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;

		b>>=1;
	}
	return res;
}

int main()
{
    IOS
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    while(cin>>n)
    {
        memset(num,0,sizeof(num));
        memset(fro,0,sizeof(fro));
        memset(bac,0,sizeof(bac));
        rep1(i,n) cin>>num[i];
        num[0]=0;num[n+1]=0;
        fro[0]=0;
        rep1(i,n)
        {
            fro[i]=max(fro[i-1],num[i]);
        }
        bac[n+1]=0;
        for(int i=n;i>0;i--)
        {
            bac[i]=max(bac[i+1],num[i]);
        }
        rep1(i,n)
        {
            cout<<max(fro[i-1],bac[i+1])<<"\n";
        }

    }



}


Measured memory_bytes: 6272
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;

        string s;
        while(n > 0) {
            int x = n % 26;
            if(x == 0)
                x = 26;

            s += char('a' + x - 1);
            n = n / 26 - (x == 26);
        }
        reverse(s.begin(), s.end());

        cout << s << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int n;
    while(cin >> n && n) {
        vector<string> str(n);
        REP(i, n) cin >> str[i];
        vector<int> level(n);
        REP(i, n) {
            while(level[i] < str[i].size() && str[i][ level[i] ] == '.') {
                level[i]++;
            }
        }

        REP(i, n) {
            int j = i - 1;
            bool ng = false;
            while(j >= 0 && level[j] != level[i]) {
                if(level[j] < level[i]){
                    ng = true;
                    break;
                }
                j--;
            }
            if(j >= 0 && !ng) {
                for(int k = j + 1; k < i; k++) {
                    str[k][ level[i] - 1] = '|';
                }
            }
        }

        REP(i, n) {
            str[i][ level[i] - 1] = '+';
        }

        REP(i, n) REP(j, str[i].size()) if(str[i][j] == '.') str[i][j] = ' ';

        REP(i, n) {
            cout << str[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1992
#include <stdio.h>
#define N 100
#define NIL -1
int Pre(int t);
int In(int t);
int Post(int t);
struct Node{
  int p, left, right;
};
struct Node A[N];
int main(){
  int i, j;
  int n, id, h, d;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
   A[i].p = NIL;
   A[i].left = NIL;
   A[i].right = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &id, &h, &d);
    A[h].p = id;
    A[d].p = id;
    A[id].left = h;
    A[id].right = d;
  }
  for(i = 0; i < n; i++){
    if(A[i].p == NIL){
break; }
}
  printf("Preorder\n");
  Pre(i);
  printf("\n");
  printf("Inorder\n");
  In(i);
  printf("\n");
  printf("Postorder\n");
  Post(i);
  printf("\n");
return 0; }
int Pre(int t){
  printf(" %d",t);
  if(t != NIL){
    if(A[t].left != NIL)Pre(A[t].left);
    if(A[t].right != NIL)Pre(A[t].right);
  }
return 0; }
int In(int t){
  if(t != NIL){
    if(A[t].left != NIL){
      In(A[t].left);
    }
    printf(" %d",t);
    if(A[t].right != NIL){
      In(A[t].right);
} }
return 0; }
int Post(int t){
  if(t != NIL){
    if(A[t].left != NIL)Post(A[t].left);
    if(A[t].right != NIL)Post(A[t].right);
  }
  printf(" %d",t);
return 0; }



Measured memory_bytes: 2048
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

int N;
i64 a[100100];
i64 b[100100];
i64 c[100100];
i64 dp[100100][4];

i64 slv(int idx, int yesterday)
{
  if (idx >= N) { return 0; }
  i64 &ret = dp[idx][yesterday];
  if (~ret) { return ret; }

  ret = 0;
  if (yesterday != 0) chmax(ret, slv(idx+1, 0) + a[idx]);
  if (yesterday != 1) chmax(ret, slv(idx+1, 1) + b[idx]);
  if (yesterday != 2) chmax(ret, slv(idx+1, 2) + c[idx]);

  return ret;
}

signed main()
{
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }

  memset(dp, -1, sizeof(dp));

  cout << slv(0,3) << endl;


  return 0;
}



Measured memory_bytes: 10368
/*PM1 問題１５
この問題の根本的なものは何かというと、scanfがどんな方でも読み込めるよってことなのはわかるかい。*/
#include <stdio.h>
int main()
{
	int a, b, c;
	char op;
	

	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+')
		{
			c = a + b;
			printf("%d\n", c);
		}
		else if (op == '-')
		{
			c = a - b;
			printf("%d\n", c);
		}
		else if (op == '/')
		{
			c = a / b;
			printf("%d\n", c);
		}
		else if (op == '*')
		{
			c = a * b;
			printf("%d\n", c);
		}
		else
		{
			break;
		}
	}
		return 0;
}

	



Measured memory_bytes: 2088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AColorfulSlimes2 {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            int n = sc.nextInt();

            int a[] = new int[n];
            for (int i = 0; i < n; ++i)
                a[i] = sc.nextInt();

            int freq = 0;
            int ans = 0;
            int lastEle = Integer.MAX_VALUE;
            for (int i = 0; i < n; ++i) {
                if (a[i] != lastEle) {
                    ans += freq / 2;
                    freq = 1;
                    lastEle = a[i];
                } else
                    freq++;
            }
            ans += freq / 2;
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32500
package main

import (
	"fmt"
)

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &s, &k)

	k--
	ans := ""

	for _, r := range s {
		if r == rune(s[k]) {
			ans += string(s[k])
		} else {
			ans += "*"
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define CHECK cout << "ok" << endl
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 1e18;
const int OO = 0;
const int OOO = 1;
using namespace std;

string k;
int d, n;
int dp[10001][101][2];

int calc(int i, int m, int roof) {
	if (i == n) return (m == 0 ? 1 : 0);
	if (dp[i][m][roof] != -1) return dp[i][m][roof];
	int &x = dp[i][m][roof];
	x = 0;
	if (roof) {
		for (int put = 0; put < k[i] - '0'; put++)
			x = (x + calc(i + 1, (m - put + 10 * d) % d, 0)) % md;
		x = (x + calc(i + 1, (m - (k[i] - '0') + d) % d, 1)) % md;
	}
	else {
		for (int put = 0; put < 10; put++)
			x = (x + calc(i + 1, (m - put + 10 * d) % d, 0)) % md;
	}
	return x;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> k >> d;
	n = k.size();
	for (int i = 0; i < n; i++) for (int j = 0; j < d; j++)
		dp[i][j][0] = dp[i][j][1] = -1;
	int ans = (calc(0, 0, 1) - 1 + md) % md;
	finish(ans);
}

Measured memory_bytes: 9088
K = int(input())

n = 50

b = K // n

if b == 0:
    a = [0 for i in range(n)]
    a[n - 1] = n * (K % n)
else:
    a = [(n - 1) + b for i in range(n)]
    for i in range(n - (K % n)):
        a[i] -= K % n
    for i in range(n - (K % n), n):
        if K % n > 0:
            a[i] += n - (K % n - 1)

print(len(a))
print(' '.join(str(s) for s in a))


Measured memory_bytes: 3064