akhauriyash/Code-Regression huggingface dataset:
class Node:
    def __init__(self, num, parent, leftmostChild, rightSibling):
        self.id = num
        self.parent = parent
        self.leftmostChild = leftmostChild
        self.rightSibling = rightSibling
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent.id), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.leftmostChild and self.parent.id != -1:
            print('internal node, ', end = '')
        elif self.parent.id != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print('[', end = '')
        t_n = self.leftmostChild
        if t_n:
            print(t_n.id, end = '')
            t_n = t_n.rightSibling
        while t_n:
            print(', {0}'.format(t_n.id), end = '')
            t_n = t_n.rightSibling
        print(']')


class RootedTree():
    def __init__(self, n):
        self.base_node = Node(-1, None, None, None)
        self.nodes = [Node(i, self.base_node, None, None) for i in range(n)]
    
    def set_node(self, num, k, *children):
        if children:
            self.nodes[num].leftmostChild = self.nodes[children[0]]
            for i, x in enumerate(children[:-1]):
                self.nodes[x].parent = self.nodes[num]
                self.nodes[x].rightSibling = self.nodes[children[i + 1]]
            self.nodes[children[-1]].parent = self.nodes[num]

    def set_depth(self):
        for n in self.nodes:
            t_n = n
            while t_n.parent.id != -1:
                n.depth += 1
                t_n = t_n.parent

    def show_nodes_info(self):
        for n in self.nodes:
            n.show_info()



import sys

n = int(sys.stdin.readline())

T = RootedTree(n)

for x in sys.stdin.readlines():
    T.set_node(*list(map(int, x.split())))

T.set_depth()

T.show_nodes_info()

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

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

int main(void)
{
    ll n,k;
    cin>>n>>k;
    ll s[n];
    rep(i,n) s[i]=0;
    rep(i,k){
        int d; cin>>d;
        rep(i,d){
            int a; cin>>a;
            --a;
            s[a]++;
        }
    }
    ll ans=0;
    rep(i,n){
        if(s[i]==0) ++ans;
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdbool.h>

char grading(int math, int english, int japanese)
{
    double average_math_and_english = (math + english) / 2;
    double average_total = (math + english + japanese) / 3;
    if (100 == math || 100 == english || 100 == japanese || average_math_and_english >= 90 || average_total >= 80) {
        return 'A';
    } else if (average_total >= 70 || (average_total >= 50 && (math >= 80 || english >= 80))) {
        return'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    while(1){
        int student;
        scanf("%d", &student);
        if (0 == student) {
            return 0;
        } else {
            for(int i = 0; i < student; i++){
                int math;
                int english;
                int japanese;
                scanf("%d %d %d", &math, &english, &japanese);
                printf("%c\n", grading(math, english, japanese));
            }
        }
    }
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n)     for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define _in(a) \
    ll a;      \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
#define in(a, b, c, d, e) \
    _in(a);               \
    _in(b);               \
    _in(c);               \
    _in(d);               \
    _in(e)
#define in(a, b, c, d) \
    _in(a);            \
    _in(b);            \
    _in(c);            \
    _in(d)
#define in(a, b, c) \
    _in(a);         \
    _in(b);         \
    _in(c)
#define in(a, b) \
    _in(a);      \
    _in(b)
#define in(a) _in(a)
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)  (x).begin(), (x).end()    //昇順
#define rall(x) (x).rbegin(), (x).rend()  //降順
#define yes     out("Yes");
#define no      out("No");

int main() {
    in(n);
    repin(a, n);
    ll max = a[0];
    ll ans = 0;
    rep2(i, 1, n) {
        if (max < a[i]) {
            max = a[i];
        }
        ans += max - a[i];
    }
    out(ans);
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
char a[100000];
long long int i=0;
bool easy=false; 
int main(){
    gets(a);
    for(int i=0;i<strlen(a);i++){
    	 if(a[i]=='C'){
            easy=true;	
        }
        if(a[i]=='F'&&easy==true){
            cout<<"Yes"<<endl;
            return 0;
        }
	}
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	maxA := 0
	minB := int(1e10)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		if maxA < a {
			maxA = a
		}
		if b < minB {
			minB = b
		}
	}

	fmt.Println(maxA + minB)
}


Measured memory_bytes: 5504
// ABC-142 C:
// 2019.9.28 bal4u
// Template for Online Contest

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

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

typedef struct { int id, n; } T;
T a[100005]; int N;

int cmp(const void *u, const void *v) {	return ((T *)u)->n - ((T *)v)->n; }

int main()
{
	int i;

	N = in(); for (i = 1; i <= N; i++) a[i].id = i, a[i].n = in();
	qsort(a+1, N, sizeof(T), cmp);
	out(a[1].id);
	for (i = 2; i <= N; i++) pc(' '), out(a[i].id);
	pc('\n');
	return 0;
}


Measured memory_bytes: 1788
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    vector<string> v(h, string(w, '.'));
    rep(i, h) rep(j, w) if (even(i + j)) v[i][j] = '#';
    for (auto &x : v) cout << x << endl;
    cout << endl;
  }
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  long long int K;
  cin >> S >> K;
  int N = S.size();
  char ans = '1';
  for (int i = 0; i < K; i++){
    if (!(S.at(i) == '1')){
      ans = S.at(i);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <chrono>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cmath>
#include <set>
#include <list>
#include <stack>
#include <queue>
using namespace std;
#define endl "\n"
#define ll long long
const int inf = 1e9 + 7;
const int ninf = -(1e9 + 7);
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#ifdef _DEBUG
  FILE *fp;
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  vector<int> seq = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin>>n;
  cout<<seq[n-1];
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ()
{
	int n,x,c = 0;
	//[012345....abc...n ]   a & b & c & .... <= n

	while (1)
	{
		c=0;
		cin >> n >> x;
	for (int q = 1; q <= n; q++)
	{
		for (int e = q + 1; e <= n; e++)
		{
			for (int y = e + 1; y <= n; y++)
			{
				if (q + e + y == x)
				{
					c++;
				}
			}
		}
	}

	if (n == 0 && x == 0)
				{
					break;
				}

	cout << c << endl;

	}
	return 0;
}

Measured memory_bytes: 3088
loop do
  t, h, s = $<.gets.split.map(&:to_i)
  break if t == -1 and h == -1 and s == -1
  left = 120 * 60 - (t * 3600 + h * 60 + s)
  output = ->(t) {
    printf "%02d:%02d:%02d\n", h = t / 3600, (m = t / 60) - h * 60, t - m * 60
  }
  output.(left)
  output.(left * 3)
end


Measured memory_bytes: 6852
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
  int D,T,S; cin>>D>>T>>S;
  if(D <= T*S) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3628
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        System.out.println(c>a+b && 4*a*b<(c-a-b)*(c-a-b)?"Yes":"No");
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int cnt = 1;
    int state = 0;
    ll prev = a[0];
    for(int i=1;i<n;i++) {
        if(a[i] > prev) {
            if(state == -1) {
                state = 0;
                cnt++;
            } else if(state == 0) {
                state = 1;
            }
        }
        else if(a[i] < prev) {
            if(state == 1) {
                state = 0;
                cnt++;
            } else if(state == 0) {
                state = -1;
            }
        }

        prev = a[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, W;
int w[110], v[110];
MII dp;


void makeDP(){
	rep(i, 0, N){
		for(auto it = dp.rbegin();it != dp.rend();it++)
			if(dp.find(it->fi) != dp.end() && it->fi+w[i] <= W) chmax(dp[it->fi+w[i]], dp[it->fi]+v[i]);
		chmax(dp[w[i]], v[i]);
	}
}


int solve(){
	int ans = 0;
	for(PII p : dp)
		if(p.fi <= W) chmax(ans, dp[p.fi]);
	return ans;
}


signed main(){
	cin >> N >> W;
	rep(i, 0, N) cin >> w[i] >> v[i];

	makeDP();

	cout << solve() << endl;

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  double y, b;
  y = b = 0;
  for (int i = 0; i < n; i++)
  {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
    {
      y += x;
    }
    else
    {
      b += x;
    }
  }
  double ans = y + (b * 380000);
  cout << ans << endl;
}


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

using namespace std;
typedef char TElemType;
#define OK 1
typedef int Status;
typedef struct BiNode {
    TElemType data;
    struct BiNode *lchild, *rchild;
} BiNode, *BiTree;
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;

void CreateBiTree(BiTree &T) {
    if (T == NULL) {
        T = new BiNode;
        T->data = 'c';
    } else {
        CreateBiTree(T->rchild);
        CreateBiTree(T->lchild);
    }
}

int pr(BiTree T) {
    if (T == NULL) return OK;
    else {
        pr(T->lchild);
        cout << T->data;
        pr(T->rchild);
    }
}

int main() {
# ifdef ONLINE_JUDGE
# else
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
# endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    long A;
    string B;
    cin>>A>>B;
    cout<<A*(long)((B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0'))/100<<endl;
    return 0;

}

Measured memory_bytes: 3596
w, h, c = input().split()
w, h = int(w), int(h)
for y in range(h):
    if y == 0 or y == h - 1:
        print('+' + '-' * (w - 2) + '+')
        continue
    for x in range(w):
        if x == 0:
            print('|', end='')
        elif x == w - 1:
            print('|')
        elif y == (h - 1) // 2 and x == (w - 1) // 2:
            print(c, end='')
        else:
            print('.', end='')


Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言

int main()
{
	int h, w, k;
	cin >> h >> w >> k;

	int i, j;
	vector<vector<char>>c(6, vector<char>(6));
	vector<int>a(6);
	vector<int>b(6);
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			cin >> c.at(i).at(j);
			if (c.at(i).at(j) == '#')
			{
				a.at(i)++;
				b.at(j)++;
			}
		}
	}
	int cnt = 0;
	
	

	int sum=0;
	for (i = 0; i < pow(2, h); i++) {
		for (j = 0; j < pow(2, w); j++)
		{
			for (int f = 0; f < h; f++)
			{
				for (int g = 0; g < w; g++)
				{
					if ((((i >> f) & 1) && ((j >> g) & 1)) && c.at(f).at(g) == '#')
					{
						sum++;
					}
				}
			}
			if (sum == k)cnt++;
			sum = 0;
		}
	}
	cout << cnt << endl;

	
}



/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 4076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
int main()
{
	int m,n,i,j,t,k,s1,s2;
	char a[105];
	scanf("%s",a+1);
	k=strlen(a+1);
	if(k%2==0) cout<<"No"; 
	else {
		for(i=1;i<=k/2;i++)
	{
		if(a[i]!=a[k-i+1]) {
			cout<<"No"; return 0;
		}
	}
	for(i=1;i<=(k-1)/2;i++)
	{
		if(a[i]!=a[(k-1)/2-i+1]) {
			cout<<"No"; return 0;
		}
		
	}
	for(i=(k+3)/2;i<=k;i++)
	{
		if(a[i]!=a[k-i+(k+3)/2]) {
			cout<<"No"; return 0;
		}
	
	}	
	cout<<"Yes";
	}
 } 

Measured memory_bytes: 256
#include <iostream>

typedef long long LL;
typedef unsigned long long ULL;
//typedef pair<int,int> PII;
//typedef vector<int> VI;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define f first
#define s second

using namespace std;

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

    LL cur = 0;
    for(int i = 0;i < SZ(s);i++){
        if (s[i] == '1'){
            cur++;
        }
        else{
            cur += k;
        }
        if (cur >= k){
            cout << s[i];
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
while True: 
    h, w = map(int, input().split())
    if h == 0 and w == 0:break
    for j in range(h):
        for i in range(w):
            if (j+i)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()            


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

int main()
{
	int N;
	cin >> N;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	vector<long long> add( N );
	for( int i = 0; i < N; i++ ) {
		add[i] = A[i] + i + 1;
	}
	sort( add.begin(), add.end() );
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		long long a = i + 1 - A[i];
		ans += upper_bound( add.begin(), add.end(), a ) - lower_bound( add.begin(), add.end(), a );
	}

	cout << ans << endl;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
	int n;cin >> n;
	
	map<string,int> mp;
	
	REP(i,n){
		string str;cin >> str;
		if(mp.find(str) != mp.end())mp[str]++;
		else mp[str] = 1;
	}
	cin >> n;
	
	REP(i,n){
		string str;
		cin >> str;
		if(mp.find(str) != mp.end())mp[str]--;
	}
	int ans = 0;
	for(auto it = mp.begin();it != mp.end();it++){
		ans = max(ans,(*it).SE);
	}
	
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

factoring n = execState (_factoring n 2) M.empty
  where
    _factoring 1 m = get
    _factoring n m 
      | mod n m == 0 = modify (M.alter mapIncr m) >> _factoring (div n m) m
      | otherwise = _factoring n (m + 1)

sumupPrimes n = foldr (M.unionWith (+)) M.empty $ map factoring [2..n]

countPrimes n = do
  let mp = M.toList $ sumupPrimes n 
  let _74s = length $ (cnt 74) mp
  let _24s = length $ (cnt 24) mp
  let _14s = length $ (cnt 14) mp
  let _4s = length $ (cnt 4) mp
  let _2s = length $ (cnt 2) mp
  let _442 = _4s .<. 2 * (_2s - _4s) + _4s .<. 3
  let _144 = _14s .<. 2 + _14s * (_4s - _14s)
  let _242 = _24s .<. 2 + _24s * (_2s - _24s)
  let _74 = _74s
  _74s + _24s * (_2s - 1) + _14s * (_4s - 1) + _4s * (_4s - 1) * (_2s - 2) `div` 2
  where cnt a = filter (flip (>=) a . snd)
      
main = do
  i <- getI
  putStrLn . show $ countPrimes i


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

const ll MAXN = 200000;

ll N, ans=-100000000000, tmp=0, A[100][10]={{0}}, P[100][11]={{0}};

void dfs(vector<ll> v, ll id) {
    if(id==10) {
        ll flag=0;
        for(int i=0;i<10;i++) {
            if(v[i]==1) flag=1;
        }
        if(flag==0) return;
        tmp=0;
        for(int i=0;i<N;i++) {
            ll ct=0;
            for(int j=0;j<10;j++) {
                if(v[j]==1&&A[i][j]==1) {
                    ct++;
                }
            }
            tmp += P[i][ct];
        }
        ans = max(ans, tmp);
        return;
    }
    dfs(v, id+1);
    v[id]=1;
    dfs(v, id+1);
}

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        for(int j=0;j<10;j++) {
            cin >> A[i][j];
        }
    }
    for(int i=0;i<N;i++) {
        for(int j=0;j<11;j++) {
            cin >> P[i][j];
        }
    }
    vector<ll> vemp(10, 0);
    dfs(vemp, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

ll calc_num_of_combination(ll n, ll r) {
  ll num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

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

  string s;
  cin >> s;
  string r = s;
  reverse(ALL(r));

  vector<ll> a; a.reserve(s.size());

  int mul = 1;
  for (char& c : r) {
    ll v = c - '0';
    v *= mul;
    v %= 2019;
    a.push_back(v);
    mul *= 10;
    mul %= 2019;
  }

  vector<ll> su(a.size(), 0);
  su[0] = a[0];
  for (int i = 1; i < su.size(); i++) {
    su[i] = su[i-1] + a[i];
    su[i] %= 2019;
  }

  map<ll, int> mp;
  mp[0]++;
  for (auto& x : su) {
    mp[x]++;
  }

  ll ans = 0;
  for (auto& p : mp) {
    if (p.second < 2) continue;
    ans += calc_num_of_combination(p.second, 2);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    //a,bの最大公約数を素因数分解して出てきた素数の種類数+1が答え
//cが素数の時は2が答え→勘違いしてた
//cが1の時は1が答え
//cが合成数の時は見つかり次第どんどん割ってく戦法で間に合う
    long c = gcd(a,b);
//    System.out.println(c);
    long answer = 1;
//    System.out.println(c);
    long tmp =0;
if(c==1){
System.out.println(1);
}else if(isPrime(c)){
System.out.println(2);
}else{
    for(long prime :primes(c)){
      if(tmp!=prime){
tmp=prime;
        if(isPrime(prime)){
//        System.out.println(prime);
// 素因数の約数のうち、素数or1だけカウントする
        answer = answer +1;
tmp=prime;
        }
      }
    }
    //なんで通らないケースあるんじゃーーーー
    System.out.println(answer);
}
  }
  
    //最大公約数
    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
  
//素数じゃない数を引数に、素因数分解してそいんすう列挙する
//cがクソデカ素数×小さい素数とかの時にクソデカ素数を詰めれてねえ…
//→商も詰めればええやん！
  static List<Long> primes(long c){ 
    List<Long> primenums= new ArrayList<Long>();
            long x = c;
            long y = x;
//       System.out.println(Math.floor(Math.sqrt(x))+2);
          for (long i = 2; i<=Math.sqrt(x)*3+10; i++) {
//            System.out.println(i);
//            boolean divflg=false;
            if ((y % i) == 0 ) {
//               if(!divflg){
                primenums.add(i);
primenums.add(y/i);
//               }
//                divflg=true;
            }
            
        }
    Collections.sort(primenums);
    return primenums;
  }
//素数判定
static boolean isPrime (long n) {
if (n==2) return true;
if (n<2||n%2==0) return false;
double d = Math.sqrt(n);
for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
 return true;
}
  
}


Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,S,T;
	cin>>n>>T>>S;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	vi dp(T+1);
	rep(i,n)for(int j=T;j>=0;j--){
		int J=j+in[i].second,C=dp[j]+in[i].first;
		if(J>T||j<S&&S<J)continue;
		dp[J]=max(dp[J],C);
	}
	int out=0;
	rep(i,T+1)out=max(out,dp[i]);
	cout<<out<<endl;
}

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

int main(){

int a,b;
cin >> a >> b;

int d,r;
double f;

d = a/b;
r = a%b;
f = (double)a/b;

    cout << d << " " << r << " "  <<  fixed << setprecision(15) << f << endl;
}


Measured memory_bytes: 3240
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,n,m;
  cin>>n;
  int A[n+1]= {};
  for(i=1;i<=100;i++)
  {
    for(j=1;j<=100;j++)
    {
        for(k=1;k<=100;k++)
        {
          m=i*i + j*j + k*k + i*j + j*k + k*i ;
          if(m<=n) A[m]++;
        }

    }
  }

  for(i=1;i<=n;i++)
  cout <<A[i]<<endl;
 return 0;
}


Measured memory_bytes: 3436
// AOJ 2278 Unruly Eel
// 2018.2.5 bal4u

#include <stdio.h>

#define MIN(a,b)	((a)<=(b)?(a):(b))

int T;
int c[200002];

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

double merge(int d)
{
	int i, w;
	double k;
	w = 1, k = c[T*(1-d)];
	i = d*(1-T); while (i) {
		k = MIN(c[i+T], (w * k + c[i+T]) / (w+1));
		w++, i += d;
	}
	return k;
}

int main()
{
	int m, i;
	double E, ll, rr, ans;

	T = in(), E = in();
	m = (T << 1) + 1;
	for (i = 0; i < m; i++) c[i] = in();
	ll = merge(1), rr = merge(-1);
	ans = (T+1)*E / (T*(ll+rr)+c[T]);
	if (ans < E/c[T]) ans = E/c[T];
    printf("%.13lf\n", ans);
	return 0;
}



Measured memory_bytes: 2636
import sys,math
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


def sieve_of_eratosthenes(n):
    prime_list = []  # n以下の素数のリスト
    A = [1]*(n+1)    # A[i] = iが素数なら1,その他は0
    A[0] = A[1] = 0
    for i in range(2,math.floor(math.sqrt(n))+1):
        if A[i]:
            prime_list.append(i)
            for j in range(i**2,n+1,i):
                A[j] = 0
    for i in range(math.floor(math.sqrt(n))+1,n+1):
        if A[i] == 1:
            prime_list.append(i)
    return prime_list,A


prime_list,A = sieve_of_eratosthenes(10**5)

like_2017 = [0]*(10**5+1)
for p in prime_list:
    if p == 2:
        continue
    else:
        if A[(p+1)//2] == 1:
            like_2017[p] = 1

from itertools import accumulate

C = list(accumulate(like_2017))

Q = I()
for i in range(Q):
    l,r = MI()
    print(C[r]-C[l-1])


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

int main(void){
    int k,v,u;
    cin>>k;
    vector<int> dp(k,46);
    dp[1] = 1;
    deque<int> deq = {1};
    while(v = deq.front()){
        deq.pop_front();
        u = (v*10)%k;
        if(dp[u] > dp[v]){
            dp[u] = dp[v];
            deq.push_front(u);
        }
        u = (v+1)%k;
        if(dp[u] > dp[v]+1){
            dp[u] = dp[v]+1;
            deq.push_back(u);
        }
    }
    cout<<dp[v]<<endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
const int MAXN = 1e5+1;
const int INF = 1e9 + 7;
vector<int> dp;
vector<vector<int> > adj;
vector<int> ind;
vector<int> outd;
int N, M;
int f(int s) {
	int& ret = dp[s];
	if (ret != -1) return ret;
	if (outd[s] == 0) return ret = 0;
	ret = 1;
	for (int i : adj[s]) {
		ret = max(ret, f(i)+1);
	}
	return ret;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M;
	dp.resize(N+1,-1),ind.resize(N+1,0), outd.resize(N+1,0), adj.resize(N+1);
	for (int i = 0; i < M; ++i) {
		int u, v; cin >> u >> v;
		outd[u]++, ind[v]++, adj[u].push_back(v);
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		if (ind[i]) continue;
		ans = max(ans, f(i));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 12816
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> c(n),v(n,0);
  for(int i=0;i<n;i++) cin>>c[i];
  int q;
  cin>>q;
  while(q--){
    int t,x,d;
    cin>>t>>x>>d;
    x--;
    if(t==1) v[x]+=d;
    if(t==2) v[x]-=d;
    if(v[x]<0||v[x]>c[x]){
      cout<<x+1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}



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

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


int main(){
    int K;
    string S;

    cin >> K >> S ;
    
    int n = S.size();

    if(n <= K){
        cout << S << endl;
    }else{
        cout << S.erase(K) << "..." << endl;
    }
    
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	for {
		fmt.Scan(&s)
		if s == "0" {
			return
		}
		var sum int
		for _, c := range s {
			n, _ := strconv.Atoi(string(c))
			sum += n
		}
		fmt.Println(sum)
	}
}



Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
int main(){
    vector <long long> v;
    long long a,b,c=0,d=0,e=0,f=0,g=0,i,j,k=1,l=0,r=1,n,m,z,h[600001],p[600001];
    string s,t,x,y;
    double q,u,w;
    cin>>s>>t;
    s+=t[t.size()-1];
    if(s==t){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

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

using namespace std;
              
int main() 
{
	string s;
	cin >> s;
	int x = s[0] - 'a' + 1;
	int y = s[1] - 'a' + 1;
	int z = s[2] - 'a' + 1;
	if (x * y * z == 6) 
	{
		puts("Yes");
	}
	else 
	{
		puts("No");
	}
	return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

int main() {
	int N, M;
	cin >> N >> M;
	vector<long long>kaijo(100001);
	kaijo.at(1) = 1;
	for (size_t i = 2; i <= 100000; i++)
	{
		kaijo.at(i) = kaijo.at(i - 1) * i % mod;
	}
	if ((N - M) == 0)cout << 2 * kaijo.at(N) * kaijo.at(M) % mod;
	else if (abs(N - M) == 1)cout << kaijo.at(N) * kaijo.at(M) % mod;
	else cout << 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=1e5;
class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(){
    for(int d=1;d<=D;++d) cout<<ans[d]<<endl;
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void solve(int time){
    max_score=evaluate();
    for(int i=0;i<time;++i){
        int p=rand()%D+1;
        int temp=ans[p];
        ans[p]=rand()%ntype+1;
        int temp_score=evaluate();
        if(max_score<temp_score) max_score=temp_score;
        else ans[p]=temp;
    }
}

int main(){
    srand(seed);
    Input();
    Init();
    solve(t);
    Output();
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  sort(v.begin(),v.end());
  ll ans = 0;
  ll c = 1LL;
  rep(i,K-1){
    c = (c*(N-1-i))%mod;
    c = (c*pow((ll)i+1,mod-2,mod))%mod;
  }
  rep(i,N-K+1){
    ans = (ans+(v[N-i-1]-v[i])*c)%mod;
    c = (c*pow(N-i-1,mod-2,mod))%mod;
    c=(c*(N-K-i))%mod;
  }
  if(ans<0) ans+=mod;
  cout<<ans<<endl;
}

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

int main(){

  int n,a,b;
  cin >> n >> a >> b;

  int sum = 0;
  int five,four,three,two,one;
  for(int i=1; i<=n; ++i){
    five = i / 10000;
    four = (i-five*10000)/1000;
    three = (i-five*10000-four*1000)/100;
    two = (i-five*10000-four*1000-three*100)/10;
    one = (i-five*10000-four*1000-three*100-two*10);

    if(five+four+three+two+one >= a && five+four+three+two+one <= b){
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
/*
  int n;
  cin>>n;
  vector<pair<string,pair<int,int> >> l;
  lp(i,n){
    string s;
    int a;
    cin>>s>>a;
    l.push_back({s,{-1*a,i}});
  }
  sort(l.begin(),l.end());
  lp(i,l.size()){
    cout<<l[i].second.second+1<<endl;
  }


  return 0;
}
*/
signed main(){
  int a,p;
  cin>>a>>p;
  p+=a*3;
  cout<<p/2<<endl;
  return 0;
}

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

using namespace std;

int main()
{
  string ranks = "23456789TJQKA";
  char trump;
  while(cin >> trump, trump != '#'){
    pair<int, char> card[4][13];
    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 13; j++){
	string c;
	cin >> c;
	card[i][j].first = ranks.find(c[0]) + 1;
	card[i][j].second = c[1];
      }
    }
    int score[2] = {-6, -6};
    int winner = 0;
    for(int i = 0; i < 13; i++){
      for(int j = 0; j < 4; j++){
	char suit = (card[j][i].second==trump?trump:card[winner][i].second);
	if(card[winner][i].first*(card[winner][i].second==suit) < card[j][i].first*(card[j][i].second==suit)){
	  winner = j;
	}
      }
      score[winner%2]++;
    }
    if(score[0] > score[1]) cout << "NS " << score[0] << endl;
    else cout << "EW " << score[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[1<<16];
int d[16][17];
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<a;i++)
            for(int j=0;j<a+1;j++)
                scanf("%d",&d[i][j]);
        for(int i=0;i<(1<<16);i++)dp[i]=999999999;
        dp[0]=0;
        for(int i=0;i<(1<<a);i++){
            for(int j=0;j<a;j++){
                if(!(i&(1<<j))){
                    int v=d[j][0];
                    for(int k=0;k<a;k++)if(i&(1<<k))v=min(v,d[j][k+1]);
                    dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+v);
                }
            }
        }
        printf("%d\n",dp[(1<<a)-1]);
    }
}


Measured memory_bytes: 2936
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::string solve(int x)
{
  return x >= 30 ? "Yes" : "No";
}

int main()
{
  int x;
  std::cin >> x;

  std::cout << std::setprecision(20);
  std::cout << solve(x) << std::endl;
}


Measured memory_bytes: 3636
public class Hello{
    public static void Main(){
        int count=int.Parse(System.Console.ReadLine());
        string[] num=System.Console.ReadLine().Split(' ');
        int ans=0;
        
        for(int i=1;i<count-1;i++){
            int be=int.Parse(num[i-1]);
            int n=int.Parse(num[i]);
            int af=int.Parse(num[i+1]);
             
             if(n<be && n>af)
             ans++;
             else if(n>be && n<af)
             ans++;
        }
            System.Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
// Date: 2020-04-12

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[N][5];

int cal(char x) {
    if(x == 'R') return 0;
    if(x == 'G') return 1;
    return 2;
}

int main() {
    FIO;
    int n;
    string s;
    cin >> n >> s;
    rep(i, 1, n) {
        rep(j, 0, 2) a[i][j] = a[i-1][j];
        if(s[i-1] == 'R') a[i][0]++;
        else if(s[i-1] == 'G') a[i][1]++;
        else if(s[i-1] == 'B') a[i][2]++;
    }
    LL ans = 0;
    rep(i, 1, n-2) rep(j, i+1, n-1) if(s[i-1] != s[j-1]) {
        int w = j-i;
        int x = cal(s[i-1]), y = cal(s[j-1]), z;
        if(x > y) swap(x, y);
        if(x == 0 && y == 1) z = 2;
        else if(x == 0 && y == 2) z = 1;
        else if(x == 1 && y == 2) z = 0;
        ans += a[min(j+w-1, n)][z]-a[j][z] + a[n][z]-a[min(j+w, n)][z];
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]
vector<char> muzui={'0','1','2','3','4','5','6','7','8','9'};

int cii(char x){
rep(i,10) if(muzui[i]==x) return i;
}

int nC2(int n){
  int ret=n*(n-1)/2;
  return ret;
}

int cnt1(int x,string n){
 int ret= 9*(x-1)+cii(n.at(0));
  return ret;
}

int cnt2(int x,string n){
  int ret=(x-2)*(x-1)/2*81+9*(cii(n[0])-1)*(x-1);
  if(x==1) return ret;
  while(n.size()>=1){
    n =n.substr(1);
    x=n.size();
    if(n[0]!='0') break;
  }
  if(n.size()==0) return ret;
  ret += cnt1(x,n);
  return ret;
}

int cnt3(int x,string n){
   int ret= 0;
  for(int i=2;i<=x-2;i++){
     ret += 9*9*9*nC2(i);
  }
  ret += (cii(n[0])-1)*nC2(x-1)*81;
  if(x<=2) return ret;
  while(n.size()>=1){
    n =n.substr(1);
    x=n.size();
    if(n[0]!='0') break;
  }
  if(x<=2) return ret;
  ret += cnt2(x,n);
  return ret;
}


int main(){
string n;
  int k;
  cin>>n>>k;
int x =n.size();
  
if(k==1){
 cout<<cnt1(x,n)<<endl;
  return 0;
}
  
if(k==2){
   cout<<cnt2(x,n)<<endl;
  return 0;
}  
  
if(k==3){
 cout<<cnt3(x,n)<<endl;
} 
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int D, G, ans = 1000000000;
  cin >> D >> G;
  G /= 100;
  int p[10], c[10];
  for (int i = 0; i < D; i++)
    cin >> p[i] >> c[i];
  for (int i = 0; i < D; i++)
    c[i] /= 100;
  bool check[10];

  for (int i = 0; i < (1 << D); i++)
  {
    int res = 0;
    int score = 0;
    for (int j = 0; j < D; j++)
      check[j] = false;
    for (int j = 0; j < D; j++)
    {
      if (i & (1 << j))
      {
        check[j] = true;
        res += p[j];
        score += p[j] * (j + 1);
        score += c[j];
      }
    }
    if (score >= G)
      ans = min(ans, res);
    else
    {
      int j = D - 1;
      while (check[j])
        j--;
      for (int k = 0; k < p[j]; k++)
      {
        res++;
        score += j + 1;
        if (score >= G)
        {
          ans = min(ans, res);
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}


// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }

int main() 
{ 
    fastio;
    // fact[0]=1;
    // f(i,1,2000009)fact[i]=(fact[i-1]*i)%mod;
    int t;
    // cin>>t;
    t=1;
    // int temp=t;
    while(t--){
      string s;
      cin>>s;
      string a,b;
      string p;
      p=s;
      reverse(s.begin(),s.end());
      if(p!=s){
        cout<<"No\n";
        return 0;
      }
      f(i,0,(s.size()-1)/2)a.pb(s[i]),b.push_back(p[i]);
      p=a;
      reverse(a.begin(),a.end());
      if(a!=p){
        cout<<"No\n";
        return 0;
      }
      p=b;
      reverse(b.begin(),b.end());
      if(b!=p){
        cout<<"No\n";
        return 0;
      }
      cout<<"Yes\n";
    }

    return 0; 	
}



Measured memory_bytes: 256