akhauriyash/Code-Regression huggingface dataset:
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "container/heap"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}
 
type Item struct {
  Comparison  int
  Index int
}
type PriorityQueue []*Item
func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
  return pq[i].Comparison < pq[j].Comparison
}
func (pq PriorityQueue) Swap(i, j int) {
  pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n - 1]
  *pq = old[0:n - 1]
  return item
}
func (pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq, item)
}

func Max(a, b, c int) int {
  ans := a
  if ans < b { ans = b }
  if ans < c { ans = c }
  return ans
}

func main() {
  N := NextInt()
  A := NextIntVec()
  B := NextIntVec()
  var Q PriorityQueue
  for i, b := range B {
    heap.Push(&Q, &Item{-b, i})
  }
  cnt := 0
  for len(Q) > 0 {
    i := heap.Pop(&Q).(*Item).Index
    d := B[(i - 1 + N) % N] + B[(i + 1 + N) % N]
    k := (B[i] - Max(A[i], B[(i - 1 + N) % N], B[(i + 1 + N) % N]) + d - 1) / d
    B[i] -= d * k
    if B[i] < A[i] {
      cnt = -1
      break
    }
    cnt += k
    if A[i] < B[i] {
      heap.Push(&Q, &Item{-B[i], i})
    }
  }
  Write(cnt)
  Output()
}

Measured memory_bytes: 19200
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<Integer, Integer> p = new HashMap<>();
        Map<Integer, Integer> q = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int v = Integer.parseInt(sc.next());
            if (i % 2 == 0) {
                if (p.containsKey(v)) {
                    p.put(v, p.get(v) + 1);
                } else {
                    p.put(v, 1);
                }
            } else {
                if (q.containsKey(v)) {
                    q.put(v, q.get(v) + 1);
                } else {
                    q.put(v, 1);
                }
            }
        }
        sc.close();

        Map<Integer, Integer> ps = p.entrySet().stream()
                .sorted(Map.Entry.<Integer, Integer>comparingByValue().reversed()
                        .thenComparing(Map.Entry.comparingByKey()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
        Map<Integer, Integer> qs = q.entrySet().stream()
                .sorted(Map.Entry.<Integer, Integer>comparingByValue().reversed()
                        .thenComparing(Map.Entry.comparingByKey()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));

        List<Integer> pss = new ArrayList<>(ps.keySet());
        List<Integer> qss = new ArrayList<>(qs.keySet());
        int x = 0, y = 0, ans = n / 2;
        boolean f = false;
        for (int i = 0; i < pss.size(); i++) {
            x = pss.get(i);
            for (int j = 0; j < qss.size(); j++) {
                if (x != qss.get(j)) {
                    y = qss.get(j);
                    f = true;
                    break;
                }
            }
            if (f)
                break;

        }
        if (f)
            ans = n - p.get(x) - q.get(y);
        x = 0;
        y = 0;
        f = false;
        for (int i = 0; i < qss.size(); i++) {
            x = qss.get(i);
            for (int j = 0; j < pss.size(); j++) {
                if (x != pss.get(j)) {
                    y = pss.get(j);
                    f = true;
                    break;
                }
            }
            if (f)
                break;

        }
        if (f && ans > n - q.get(x) - p.get(y))
            ans = n - q.get(x) - p.get(y);
        System.out.println(ans);
    }
}

Measured memory_bytes: 54320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[100];
	rep(i, N) cin >> A[i];
	int saidai = *max_element(A, A + N);;
	int B[100] = {};
	rep(i, N) B[A[i]]++;

	int saishou = (saidai + 1) / 2;

	int OK = 1;
	for (int i = saidai; i > saishou; i--) {
		if (B[i] < 2) OK = 0;
	}
	if (saidai & 1) {
		if (B[saishou] != 2) OK = 0;
	}
	else {
		if (B[saishou] != 1) OK = 0;
	}
	for (int i = saishou - 1; i > 0; i--) {
		if (B[i]) OK = 0;
	}

	if (OK) co("Possible");
	else co("Impossible");

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
ll n,a,b;
cin>>n>>a>>b;
ll max=0;
if(a>b)
max=b;
else
max=a;
ll min=0;
if(a+b<=n)
min=0;
else if(a+b==2*n)
min=a;
else
min=a+b-n;
cout<<max<<" "<<min<<endl;
  return 0;
 
}
 

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

using namespace std;


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

  uint ps = 0;
  for (const char c : s) {
    if (c == 'p')
      ++ps;
  }

  cout << s.size() / 2 - ps << endl;

  return 0;
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int train = min(a,b);
    int  bus = min(c,d);
    int ans = train + bus;
    cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <iostream>

#define N 25
#define NIL -1

struct Node
{
    int parent, left, right;
};

using namespace std;

class BinaryTree
{
public:
    BinaryTree();
    ~BinaryTree();

    Node TREE[N];
    int nodenum, root;

    void preorder(int);
    void inorder(int);
    void postorder(int);
};

int main() {
    BinaryTree _tree;

    cout << "Preorder" << endl;
    _tree.preorder(_tree.root);
    cout << endl;

    cout << "Inorder" << endl;
    _tree.inorder(_tree.root);
    cout << endl;

    cout << "Postorder" << endl;
    _tree.postorder(_tree.root);
    cout << endl;

    return 0;
}

BinaryTree::BinaryTree() {
    cin >> nodenum;
    for(int i=0; i<nodenum; ++i) {
        TREE[i].parent = NIL;
    }

    int id, left, right;
    for(int i=0; i < nodenum; ++i) {
        cin >> id >> left >> right;
        TREE[id].left = left;
        TREE[id].right = right;

        if(left != NIL) TREE[left].parent = id;
        if(right != NIL) TREE[right].parent = id;
    }

    for(int i=0; i < nodenum; ++i) {
        if(TREE[i].parent == NIL) root = i;
    }
}

BinaryTree::~BinaryTree() {
    
}

void BinaryTree::preorder(int a) {
    if(a == NIL) return ;
    cout << " " << a;
    preorder(TREE[a].left);
    preorder(TREE[a].right);
}

void BinaryTree::inorder(int a) {
    if(a == NIL) return ;
    inorder(TREE[a].left);
    cout << " " << a;
    inorder(TREE[a].right);
}

void BinaryTree::postorder(int a) {
    if(a == NIL) return ;
    postorder(TREE[a].left);
    postorder(TREE[a].right);
    cout << " " << a;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
constexpr ll mod = 1e6;

int main()
{
	int n; cin >> n;
	vector<int>v(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
	}
	int c = 0;
	for (int i = 1; i <= n; ++i)if (v[i] != i)c++;
	if (c <= 2)puts("YES"); else puts("NO");
	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
ro, sc ,pa = map(int,input().split())
a = input()
dict = {'r':'p', 's':'r', 'p': 's'}
scores = {'r':ro,'s':sc,'p':pa}
can_lelect = 'rsp'
select = ['' for _ in range(n)]
cant = [[] for _ in range(n)]
left = 0
cur = k
for i in range(k):
    need = dict[a[i]]
    select[i] = need
while cur < n:
    need_cur = dict[a[cur]]
    need_left = dict[a[left]]
    if select[left] == '':
        select[left] = need_left
    if need_cur == select[left] :
        if select[left] != need_left:
            cant[left].append(need_cur)
            for v in can_lelect:
                if v not in cant[left]:
                    select[left] = v
                    break
            select[cur] = need_cur
        else:
            cant[cur].append(need_cur)
            right = cur+k
            if right < n:
                need_right = dict[a[right]]
                cant[cur].append(need_right)
            for v in can_lelect:
                if  v not in cant[cur]:
                    select[cur] = v
                    break
    else:
        select[cur] = need_cur
    left+=1
    cur +=1
total = 0
for i in range(n):
    c = select[i]
    if c == dict[a[i]]:
        total+=scores[c]
print(total)

Measured memory_bytes: 13044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int P=sc.nextInt();
		int Q=sc.nextInt();
		int R=sc.nextInt();
		pl(Math.min(Math.min(Q+R, P+Q), P+R));
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    cout<<"hon";
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon";
  else
    cout<<"bon";
  return 0;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
    public static long mod(long i, long j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
    } 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
        a--;
		StringBuilder sb = new StringBuilder();
        String str[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        while(a>=0){int b = (int)mod(a,26);                   
                    sb.append(str[b]);
                    a/=26;
                    a--;}
		String ans = sb.toString();
        StringBuffer ans1 = new StringBuffer(ans);
		System.out.println(ans1.reverse().toString());
	}
}

Measured memory_bytes: 35540
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y] # 木のサイズの更新
        self.parents[y] = x # 親（=根）を大きい方=xにする

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def resolve():
    N, M = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]
    AB.reverse()
    res = []
    uf = UnionFind(N)
    inconv = N*(N-1)//2
    for a, b in AB:
        res.append(inconv)
        if not uf.same(a-1, b-1):
            inconv = inconv - uf.size(a-1)*uf.size(b-1)
            uf.union(a-1, b-1)

    res.reverse()
    [print(i) for i in res]


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 114008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
 
int main(){
    int n; cin >> n;
    vector<pair<string,P> > re(n);
    rep(i,n){
        cin >> re[i].first >> re[i].second.first;
        re[i].second.first=100-re[i].second.first;
        re[i].second.second=i+1;
    }
    sort(all(re));
    rep(i,n) cout << re[i].second.second << endl;
return 0;
}

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

using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define all(a) a.begin(),a.end()
#define f(i,l,u) for(ll i=l;i<u;i++)
#define lb lower_bound
#define ub upper_bound
ll fac[200001];

 long long power( long long x, 
                         ll y, ll p) 
{ 
    long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
 long long modInverse( long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
 long long nCrModPFermat(long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    
    
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
  

void powe(ll p)
{
    fac[0] = 1; 
    for (int i = 1; i <= 200000; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
    
}

int main() {
    
    ll n;
    cin>>n;
    if(n%1000==0)
    cout<<0;
    else
    cout<<(1000-n%1000);
    
    return 0;
}

Measured memory_bytes: 3584
import sys


class SegTreeMin:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """

    def __init__(self, n, INF):
        """
        :param n: 要素数
        :param INF: 初期値（入りうる要素より十分に大きな数）
        """
        self.n = n
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [INF] * (n2 << 1)
        self.INF = INF

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = min(x, self.tree[i ^ 1])
            i >>= 1

    def get_min(self, a, b):
        """
        [a, b)の最小値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = self.INF

        # (k, l, r)
        # k   : 現在調べている区間のtree内index
        # l, r: kが表す区間の左右端index [l, r)
        q = [(1, 0, self.n2)]

        while q:
            k, l, r = q.pop()

            if a <= l and r <= b:
                result = min(result, self.tree[k])
                continue

            m = (l + r) // 2
            k <<= 1
            if a < m and l < b:
                q.append((k, l, m))
            if a < r and l < m:
                q.append((k + 1, m, r))

        return result


INF = 10 ** 18
n, m = map(int, input().split())
segments = [tuple(map(int, line.split())) for line in sys.stdin]
segments.sort()
sgt = SegTreeMin(n, INF)
sgt.update(0, 0)
for l, r, c in segments:
    use_current = sgt.get_min(l - 1, r - 1) + c
    not_current = sgt.get_min(r - 1, r)

    if use_current < not_current:
        sgt.update(r - 1, use_current)

ans = sgt.get_min(n - 1, n)
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 69212
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int a[200000];
signed main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	for (int i = 1; i < s.length(); i++) {
		a[i] = a[i - 1];
		if (s[i - 1] == 'A'&&s[i] == 'C')a[i]++;
	}
	for (int i = 0; i < q; i++) {
		int p, q; cin >> p >> q;
		p--; q--;
		cout << a[q] - a[p] << endl;
	}
}

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

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

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

Measured memory_bytes: 640
h,w=map(int,input().split())

mat=[input().split() for l in range(h)]

col=ord('A')

i=0
while i<h:

    j=0
    while j<w:
        
        if mat[i][j] == 'snuke':
            print(chr(col+j)+str(i+1))
            break

        j+=1

    i+=1



Measured memory_bytes: 9092
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

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

N = I()
A = LI()

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1

b = [False]*(10**6+1)
for k in d.keys():
    if d[k]:
        b[k] = True

for i in range(10**6+1):
    if b[i]:
        for j in range(2*i,10**6+1,i):
            b[j] = False

for k in d.keys():
    if d[k] != 1:
        b[k] = False

count = 0
for i in range(10**6+1):
    if b[i]:
        count += 1

print(count) 

Measured memory_bytes: 125756
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* class */
/* constant */

const int INF = 1 << 30;
const int MAX = 100000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printVec(vector<int> &vec);
/* main */
int main() {

    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    vector<int> v_prev(v.begin(), v.end());
    vector<int> v_next(v.begin(), v.end());

    int can_pre = prev_permutation(v_prev.begin(), v_prev.end());
    int can_next = next_permutation(v_next.begin(), v_next.end());

    if (can_pre) 
        printVec(v_prev);
    printVec(v);
    if (can_next)
        printVec(v_next);
}

void printVec(vector<int> &vec) {

    for (int i = 0; i < vec.size(); i++) {
        if (i) cout << ' ';
        cout << vec[i];
    } cout << '\n';
}



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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<long long> cnl(5,0);
	for (int i = 0; i < N; ++i) {
		string name;
		cin >> name;
		if (name[0] == 'M') {
			++cnl[0];
		}
		else if (name[0] == 'A') {
			++cnl[1];
		}
		else if (name[0] == 'R') {
			++cnl[2];
		}
		else if (name[0] == 'C') {
			++cnl[3];
		}
		else if (name[0] == 'H') {
			++cnl[4];
		}
	}

	long long res = 0;
	for (int i = 0; i < 5; ++i) {
		for (int j = i+1; j < 5; ++j) {
			for (int k = j+1; k < 5; ++k) {
				res += cnl[i] * cnl[j] * cnl[k];
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll x[N], y[N], h[N];
    rep(i, N) cin >> x[i] >> y[i] >> h[i];
    rep2(i, 0, 100){
        rep2(j, 0, 100){
            ll H;
            bool able = true;
            rep(k, N){
                if(h[k] > 0){
                    H = h[k] + abs(x[k]-i) + abs(y[k]-j);
                    break;
                }
            }
            rep(k, N){
                if(h[k] != max(H-abs(x[k]-i)-abs(y[k]-j), 0ll)){
                    able = false;
                    break;
                }
            }
            if(able) cout << i << ' ' << j << ' ' << H << endl;
        }
    }
}

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

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


template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

const int INF = INT_MAX / 2;

int main() {
  int N; cin>>N;
  vector<int> h(N);
  REP(i,N) cin>>h[i];
  vector<int> dp(N,INF);
  dp[0] = 0;
  REP(i,N-1) {
    chmin(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
    if(i + 2 < N)
      chmin(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
a = int(input())
x = list(map(int,input().split()))
count=0
for i in range(1,a-1):
  if x[i] > x[i+1] and x[i] < x[i-1]:
    count += 1
  elif x[i] < x[i+1] and x[i] > x[i-1]:
    count +=1
    
print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
int max(int x,int y)
{
	return x > y ? x : y;
}
int min(int x,int y)
{
	return x < y ? x :y;
}
using namespace std;
int a[105];
int b[105];
int main()
{
	int n,m,x,y;
	scanf("%d %d %d %d",&n,&m,&x,&y);
	int maxx=-105,miny=1000;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		maxx=max(maxx,a[i]);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
		miny=min(miny,b[i]);
	}
	for(int i=x+1;i<=y;i++)
	{
		if(i>maxx&&i<=miny)
		{
			printf("No War\n");
			return 0;
		}
	}
	printf("War\n");
 } 

Measured memory_bytes: 128
import itertools
import math
import fractions
import functools
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
    if p[i] != i+1:
        count += 1
if count == 2 or count == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 64108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int N,ans;
    cin >> N;
    int a[N+1];
    for (int i = 1; i <= N; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
            a[i] /= 2; ans++; 
        }
	}

    cout << ans;
}

Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP       (i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);

LL n ,x;
LL a[101010];
LL b[101010];
int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	LL ans = LINF;
	for (int i = 0; i < n; i++) {
		LL sum = accumulate(b, b + n, x*i);
		ans = min(ans, sum);
		for (int j = 0; j < n; j++) {
			int k = (j - i - 1 + 2 * n) % n;
			b[j] = min(b[j], a[k]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <cmath>
#define P 100003
#define N 100000
using namespace std;

int main(){
    int n;
    int k=1;
    int l=1;
    int i=1,j=2;
    int max=1;
    cin  >> n;

    for(i=1;i<34;i++){
        for(j=2;j<10;j++){
            l=1;
            for(k=1;k<j+1;k++){
                l *= i;
            }
            if(l > n)
                break;
            if(max < l)
                max = l;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(){

	int n,i;

	int ninzu[4][3][10]={};
	
	scanf("%d",&n);

	int b[n],f[n],r[n],v[n];

	for(i=0;i<=n-1;i++){

		scanf("%*c%d %d %d %d",&b[i],&f[i],&r[i],&v[i]);
	
		}

	int x,y,z,w;

	/*ここから
	
	int t;
	
	for(t=0;t<=n-1;t++){
		
		printf("%d %d %d %d\n",b[t],f[t],r[t],v[t]);
		
	}
	
	ここまでデバッグ用*/
	
	for(x=1;x<=4;x++){
	
		for(y=1;y<=3;y++){
		
			for(z=1;z<=10;z++){
			
				for(w=1;w<=n;w++){
				
					if(b[w-1]==x&&f[w-1]==y&&r[w-1]==z){
					
						ninzu[x-1][y-1][z-1]+=v[w-1];
						
						/*ここも
						
						printf("Yeah!\n");
						
						//デバッグ用*/
						
						}
				
					}
			
				}
		
			}
	
		}
	
	for(x=1;x<=4;x++){
	
		for(y=1;y<=3;y++){
		
			for(z=1;z<=10;z++){
				
				printf(" %d",ninzu[x-1][y-1][z-1]);
				
			}
			
			printf("\n");
			
			
		}
		
		if(x!=4)
		
			printf("####################\n");
		
		
	
	}
	
return 0;
	
	
}

Measured memory_bytes: 612
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input())
    a = list(map(int, input().split()))
    rate = [0]*8
    cnt = 0
    for x in a:
        r = x//400
        if r > 7:
            cnt += 1
        elif not rate[r]:
            rate[r] = 1
    s = sum(rate)
    mins = s
    if cnt > 0:
        mins += 1
        if s > 0:
            mins -=1
    maxs = s+cnt
    print(mins, maxs)        
        
            



if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int ans=1;
if(a!=b){ans++;}
if(a!=c&&b!=c){ans++;}
printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	int n, m;
	int sub = 0;
	int ans;
	int sum = 0;
	cin >> n >> m;
	vector<int> x(m);
	rep(i, m) cin >> x[i];

	if (n >= m) cout << 0 << endl;
	else {
		sort(x.begin(), x.end());
		vector<int> res(m-1);
		rep(i, m-1) {
			res[i] = x[i+1] - x[i];
			sum += res[i];
		}
		sort(res.begin(), res.end());
		reverse(res.begin(), res.end());
		rep(i, n-1) sub += res[i];
		ans = sum - sub;
		cout << ans << endl;
	}
	




	return 0;
}


Measured memory_bytes: 1024
N = input()
A = map(int, raw_input().split())
print ' '.join(map(str, A))

for i in xrange(1, N):
    v = A[i]
    j = i - 1
    while (j >= 0 and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print ' '.join(map(str, A))
    

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

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = 0;
  ans += v[0]/pow(2, n - 1);
  for(int i = 1; i < n; i++){
    ans += v[i]/pow(2, n - i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 636
S = input()
a = []
m = 0
for i in range(len(S)):
    if S[i] == 'A':
        m += 1
    elif S[i] == 'T':
        m += 1
    elif S[i] == 'G':
        m += 1
    elif S[i] == 'C':
        m += 1
    else:
        a.append(m)
        m = 0
a.append(m)
print(max(a))

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

using namespace std;

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

  vector< vector<int> > PYs;
  int P, Y;
  for (int i = 0; i < M; ++i) {

    cin >> P >> Y;
    vector<int> PY = {P, Y, i};    
    PYs.push_back(PY);
  }
  sort(PYs.begin(), PYs.end());

  int currentPrefecture = PYs[0][0];
  int cityCount = 1;
  string *ids = new string[M];
  for (int i = 0; i < M; ++i) {
    if (PYs[i][0] != currentPrefecture) {
      currentPrefecture = PYs[i][0];
      cityCount = 1;
    }
    string prefecture = to_string(currentPrefecture);
    int zeroCount =  6 - (int)prefecture.size();
    string zeroStrp(zeroCount, '0');
    string preId = zeroStrp + prefecture;

    string city = to_string(cityCount);
    zeroCount = 6 - (int)city.size();
    string zeroStr(zeroCount, '0');
    string cityId = zeroStr + city;

    ids[PYs[i][2]] = preId + cityId;
    cityCount++;
  }

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

  return 0;
}



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

int main(){
    int n;
    cin >> n;
    long long ans=0;
    vector<long long> a(n),tmp(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        tmp.at(i)=2;
    }
    tmp.at(0)=1;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int j=0;
    for(int i=0;i<n-1;i++){
        if(tmp.at(j)==0)j++;
        ans+=a.at(j);
        tmp.at(j)--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6372
#include <stdio.h>

int main() {

	int i, j;
	for (i = 0; i < 9; i++) {
		for (j = 0; j < 9; j++) {
			printf("%dx%d=%d\n", i + 1, j + 1, (i + 1)*(j + 1));
		}
	}
	return 0;
}

Measured memory_bytes: 524
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=100;
string s[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w;
    cin>>h>>w;
    s[0]=s[h+1]=string(w+2,'.');
    for(int i=1;i<=h;i++)
    {
        cin>>s[i];
        s[i]="."+s[i]+".";
    }
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if(s[i][j]=='#'&&s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.')
                cout<<"No\n",exit(0);
    cout<<"Yes\n";
}


Measured memory_bytes: 256
fn serial(y:u32, m:u32, d:u32) -> u32 {
    d+m*30+y*30*12
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split('/');
    let y: u32 = iter.next().unwrap().parse().unwrap();
    let m: u32 = iter.next().unwrap().parse().unwrap();
    let d: u32 = iter.next().unwrap().trim().parse().unwrap();

    let heisei = serial(2019, 4, 30);

    let ans = if serial(y, m, d) <= heisei {
        "Heisei"
    }
    else {
        "TBD"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
int n,k,q,sz[100005],hv[100005],vs[100005],hd[100005],dp[100005],chain[100005],id[1000005];
vector<int>g[100005];
void dfs(int v,int p){
    sz[v]=1;
    hv[v]=-1;
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=p){
            dfs(g[v][i],v);
            sz[v]+=sz[g[v][i]];
            if(hv[v]==-1||sz[hv[v]]<sz[g[v][i]])hv[v]=g[v][i];
        }
    }
}
void dfs1(int v,int d,int p,int h){
    hd[k]=h;
    id[v]=k;
    vs[k]=v;
    dp[k++]=d;
    if(hv[v]!=-1)dfs1(hv[v],d+1,v,h);
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=p&&g[v][i]!=hv[v]){
            chain[k]=id[v];
            dfs1(g[v][i],d+1,v,k);
        }
    }
}
int lca(int u,int v){
    u=id[u];v=id[v];
    while(hd[u]!=hd[v]){
        if(dp[hd[u]]>dp[hd[v]])u=chain[hd[u]];
        else v=chain[hd[v]];
    }
    if(dp[u]<dp[v])return vs[u];
    else return vs[v];
}
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int m;
        scanf("%d",&m);
        for(int j=0;j<m;j++){
            int a;
            scanf("%d",&a);
            g[i].push_back(a);
            g[a].push_back(i);
        }
    }
    dfs(0,-1);
    dfs1(0,0,-1,0);
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%d\n",lca(a,b));
    }
}



Measured memory_bytes: 17160
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



map<int,int> MAP;

int main(){

	int num_query;
	scanf("%d",&num_query);

	int command;
	int a,b,sum = 0;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		switch(command){
		case 0:

			scanf("%d",&a);
			MAP[a]++;
			sum++;
			printf("%d\n",sum);
			break;

		case 1:

			scanf("%d",&a);
			printf("%d\n",MAP[a]);

			break;
		case 2:

			scanf("%d",&a);
			sum -= MAP[a];
			MAP[a] = 0;

			break;
		case 3:

			scanf("%d %d",&a,&b);

			auto at = MAP.lower_bound(a);
			auto right = MAP.upper_bound(b);

			while(at != right){

				for(int i = 0; i < at->second; i++){

					printf("%d\n",at->first);
				}
				at++;
			}
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 11712
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nk = Input.ar;
        WriteLine(nk[0] - nk[1] + 1);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"

using namespace std;



int N;

std::vector<std::vector<int> > A(200000 + 5);
std::vector<long long > V;
void print() {
	for (int i = 1; i <= N; ++i) {
		cerr << V[i] << " ";
	}
	cerr << endl;
}
void func(int p, int from) {
	
	//cerr << "from=" << from << ",p=" << p << endl;
	for (int i = 0; i < A[p].size(); ++i) {
		if (A[p][i] == from) {
			continue;
		}
		V[A[p][i]] += V[p];
		func(A[p][i], p);
	}
	
}

int  main()
{
	int N;
	int Q;
	cin >> N;
	cin >> Q;
	for (int i = 1; i <= N-1; ++i) {
		int a, b;
		cin >> a;
		cin >> b;
		A[a].push_back(b);
		A[b].push_back(a);
	}
	V.clear();
	V.resize(N + 1);


	for (int i = 0; i < Q; ++i) {
		int p;
		long long x;
		cin >> p;
		cin >> x;
		V[p] += x;
	}

	func(1, 0);

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


Measured memory_bytes: 24320
S = input()

MOD=(10**9) + 7
N=13

dp=[[0 for i in range(N)] for j in range(100005)]
dp[0][0] = 1

dpi = 1
mul = 1

for c in S[::-1]:    
    for i in range(N):
        if c=='?':
            for j in range(10):
                ii = (i + (j*mul)) % N
                dp[dpi][ii] += dp[dpi-1][i] % MOD
                #pass
        else:
            j = int(c)
            ii = (i + (j*mul)) % N
            dp[dpi][ii] += dp[dpi-1][i] % MOD
            #pass
    mul *= 10
    mul %= N
    dpi += 1

print(dp[dpi-1][5] % MOD)

Measured memory_bytes: 66652
n=int(input())
used=[]
start=input()
used.append(start)
flag=0
for i in range(n-1):
    tmp=input()
    if start[-1]!=tmp[0] or tmp in used:
        flag=1
        break
    used.append(tmp)
    start=tmp

if flag==1:
    print("No")
else:
    print("Yes")


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

static const int N=100;

int main(){
    int n, p[N+1],m[N+1][N+1];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i-1]>>p[i];
    }
    
    for (int i=1;i<=n;i++) m[i][i]=0;
    for(int l=2;l<=n;l++){
        for(int i=1;i<=n-l+1;i++){
            int j=i+l-1;
            m[i][j]=(1<<21);
            for(int k=i;k<=j-1;k++){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout<<m[1][n]<<endl;
    return 0;
}


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

using namespace std;

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

#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back

int main() {
    string s;
    cin >> s;
    cout << (s > "2019/04/30"? "TBD":"Heisei") << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import heapq as hp

if __name__ == '__main__':
    _input = sys.stdin.readlines()

    heap_array = []
    for each in _input:
        if each.startswith('in'):
            hp.heappush(heap_array, -1 * int(each[7:]))
        elif each.startswith('ex'):
            print(-1 * hp.heappop(heap_array))

Measured memory_bytes: 190096
a = [int(input()) for i in range(5)]
A = []
for i in range(5):
    if a[i]%10!=0:
        A.append(10-a[i]%10)
        a[i] += 10-a[i]%10
 
A.sort()
print(sum(a)-A[-1] if len(A) != 0 else sum(a))

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

int main(){
	int h, w;
	string a;
	cin >> h >> w;
	for(int j=0; j < w+2; j++)
		cout << '#';
	cout << endl;
	for(int i=0; i < h; i++) {
		cin >> a;
		cout << '#' + a + '#' << endl;
	}
	for(int j=0; j < w+2; j++)
		cout << '#';
	cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          cin.tie(0);  ios_base::sync_with_stdio(false);
	          
	          ll a,b,k;
	          cin >> a >> b >> k;
	          
	          if(a>=k) cout << a-k << ' ' << b << endl;
	          else if(a+b>=k && k>a) cout << 0 << ' ' << a+b-k << endl;
	          else cout << 0 << ' ' << 0 << endl;





	          return 0;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    cout<<"a < b"<<endl;
  }else if(a==b){
    cout<<"a == b"<<endl;
  }else if(a>b){
    cout<<"a > b"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int s[100010];
int main(){
	int n,i,x,max;
	scanf("%d\n",&n);
	memset(s,0,sizeof(s));
	for(i=0;i<n;i++){
		cin>>x;
		s[x-1+1]++;
		s[x+1]++;
		s[x+1+1]++;
	}
	max=s[0];
	for(i=1;i<=100002;i++)
	  if(max<s[i])max=s[i];
	cout<<max;
	return 0;
} 

Measured memory_bytes: 768
#include<stdio.h>
#define N 100

int main(){
    int M[N][N];
    int n,u,k,v,i,j;

    scanf("%d",&n);

    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++) M[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--;
            M[u][v] = 1;
        }
    }

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


Measured memory_bytes: 2128
from collections import Counter
n = int(input())
ans = 0

dp = []
cl = []
n1 = n
if n == 1:
    ans = 0
else:
    for i in range(2, int(n**0.5)+1):
        if n%i == 0:
            cl.append(i)
            while n%i == 0:
                n = n/i
                dp.append(i)
        if n == 1:
            break
    if n != 1:
        ans = 1

c = Counter(dp)

for i in cl:
    cnt = 1
    while c[i] >= cnt:
        c[i] -= cnt
        ans += 1
        cnt += 1
        
print(ans)


Measured memory_bytes: 67948
#include <stdio.h>
#define DATA 10000

int main(){
  int a, b;
  int i, j;
  char str[DATA];
  int data_1[DATA];
  int data_2[DATA];
  int sum[DATA];

  for(i=0; i<DATA; i++){
    scanf("%d %c %d", &a, &str[i], &b);
    data_1[i] = a;
    data_2[i] = b;
    if(str[i] == '+'){
      sum[i] = data_1[i] + data_2[i];
    }
    else if(str[i] == '-'){
      sum[i] = data_1[i] - data_2[i];
    }
    else if(str[i] == '*'){
      sum[i] = data_1[i] * data_2[i];
    }
    else if(str[i] == '/'){
      sum[i] = data_1[i] / data_2[i];
    }
    else if(str[i] == '?'){
      break;
    }
  }

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



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
using namespace std;


int main(){
    int n;cin>>n;
    int flag=0;
    rep(i,10){
        rep(j,10){
            if(n==j*i)flag=1;
            
        }
    }
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define yes(i) cout<<(i?"yes":"no")<<endl
using namespace std;
int main(){
	int n;
	int c[50],v[50];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		int x=0,y=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				x+=v[j];
				y+=c[j];
			}
		}
		ans=max(ans,x-y);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
void judge(ll m,ll x)
{
    if(!m)return;
    if(n/m==x&&n%m==x)ans+=m;
}
int main()
{
    cin>>n;
    for(ll i=1;i*i<=n;i++)
    if(n%i==0)
    {
        judge(i-1,n/i);
        judge(n/i-1,i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256