akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var s = cin.ReadLine;
            var sample = "CODEFESTIVAL2016";

            int cnt = 0;
            for(int i = 0; i < sample.Length; i++){
                if(s[i] != sample[i]){
                    cnt += 1;
                }
            }

            WriteLine(cnt);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for(int i = 0; i < N; i++)cin >> A.at(i);
  sort(A.begin(),A.end());
  int flag = 0;
  for(int i = 1; i < N; i++){
    if(A.at(i-1)==A.at(i)){
      flag = 1;
      break;
    }
  }
  if(flag) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 1792
S=input()
ans = "WA"
if S[0] == "A" and ("a" <= S[1] <= "z") and ("a" <= S[-1] <= "z"):
  s0 = S[2:-1]
  f = 0
  for i in range(len(s0)):
    if s0[i] == "C":
      if f != 0:
        ans = "WA"
      else:
        ans = "AC"
        f = 1

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    if (n==m) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int k, x;
  cin >> k >> x;
  rep3(i, max(-1000000, x - k + 1), min(1000000, x + k - 1) + 1) {
    cout << i << " ";
  }
  cout << endl;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, field[11][11];  
  
  while(1) {
    cin >> n;
    if(!n) break;

    REP(i, n) {
      REP(j, n) {
	cin >> field[i][j];
      }
    }

    REP(i, n) {
      int sum = 0;
      REP(j, n) {
	sum += field[i][j];
      }
      field[i][n] = sum;
    }

    REP(i, n) {
      int sum = 0;
      REP(j, n) {
	sum += field[j][i];
      }
      field[n][i] = sum;
    }

    field[n][n] = 0;
    REP(i, n) field[n][n] += field[n-i-1][n];

    REP(i, n+1) {
      REP(j, n+1) {
	printf("%5d", field[i][j]);
      }
      printf("\n");
    }
  }
}

Measured memory_bytes: 1164
N,M = gets.split(" ").map(&:to_i);
L = Array.new(M+1, 0)
R = Array.new(M+1, 0)
L[0] = 1
R[0] = N
for i in 1..M
	L[i],R[i] = gets.split(" ").map(&:to_i);
  	if L[i] < L[i-1]
      if R[i] > R[i-1]
        L[i] = L[i-1]
        R[i] = R[i-1]
      else
        L[i] = L[i-1]
      end
    else
      if R[i] > R[i-1]
        R[i] = R[i-1]
      else
      end
    end
end
if R[M] < L[M]
  puts 0
else
  puts R[M]-L[M]+1
end


Measured memory_bytes: 3324
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

template <class T>
T mymax(T a,T b){
    if(a>=b) return a;
    return b;
}
template <class T>
T mymin(T a,T b){
    if(a<=b) return a;
    return b;
}

ll gcd(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        ll r = a%b;
        a=b;
        b=r;
    }
    return a;
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

struct XX{
    string name;
    ll v;
    ll cnt1;
    ll cnt2;
    ll cnt3;
    ll ten;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs( "1_06.txt" );//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    int A[100000];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int sum=abs(0-A[0]);
    for(int i=1;i<N;i++){
        sum+=abs(A[i-1]-A[i]);
    }
    sum+=abs(A[N-1]-0);
    
    //
    if((0<=A[0] && A[0]<=A[1]) ||
       (0>=A[0] && A[0]>=A[1])){
        cout << sum << endl;
    }else{
        cout << sum-min(2*abs(0-A[0]),2*abs(A[1]-A[0])) << endl;
    }
    for(int i=1;i<N-1;i++){
        if((A[i-1]<=A[i] && A[i]<=A[i+1]) ||
           (A[i-1]>=A[i] && A[i]>=A[i+1])){
            cout << sum << endl;
        }else{
            cout << sum-(min(2*abs(A[i-1]-A[i]),2*abs(A[i+1]-A[i]))) << endl;
        }
    }
    if((A[N-2]<=A[N-1] && A[N-1]<=0) ||
       (A[N-2]>=A[N-1] && A[N-1]>=0)){
        cout << sum << endl;
    }else{
        cout << sum-(min(2*abs(A[N-1]-A[N-2]),2*abs(A[N-1]-0))) << endl;
    }
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}



Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=c){
        cout<<0;
    }else if(a+b>=c){
        cout<<c-a;
    }else{
        cout<<"NA";
    }
    cout<<endl;
}

Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Graph struct {
	from         map[int][]Edge
	nodes        map[int]bool
	maxNodeIndex int
}

type Edge struct {
	to, weight int
}

type Visit struct {
	weight int
	from   int
}

func NewGraph() *Graph {
	return &Graph{map[int][]Edge{}, map[int]bool{}, -1}
}

func (g *Graph) NodeCount() int {
	return len(g.nodes)
}

func (g *Graph) MaxNodeIndex() int {
	return g.maxNodeIndex
}

func (g *Graph) AddEdge(s, t int, w int) {
	g.from[s] = append(g.from[s], Edge{t, w})
	g.nodes[s] = true
	g.nodes[t] = true
	if s > g.maxNodeIndex {
		g.maxNodeIndex = s
	}
	if t > g.maxNodeIndex {
		g.maxNodeIndex = t
	}
}
func (g *Graph) BellmanFord(start, end int) []Visit {
	n := g.MaxNodeIndex() + 1
	visit := make([]Visit, n)

	for i := 0; i < n; i++ {
		distance := math.MaxInt64
		if i == start {
			distance = 0
		}
		visit[i] = Visit{distance, -1}
	}

	onPath := map[int]bool{end: true}
	q := []int{end}
	for len(q) > 0 {
		node := q[len(q)-1]
		q = q[0 : len(q)-1]
		for from, edges := range g.from {
			for _, edge := range edges {
				if edge.to != node {
					continue
				}
				if !onPath[from] {
					onPath[from] = true
					q = append(q, from)
				}
			}
		}
	}

	for i := 0; i <= g.NodeCount(); i++ {
		for from, edges := range g.from {
			for _, edge := range edges {
				to := edge.to
				if visit[from].weight == math.MaxInt64 {
					continue
				}
				distance := visit[from].weight + edge.weight
				if visit[to].weight > distance {
					if i == g.NodeCount() && onPath[from] {
						return []Visit{}
					}
					visit[to].weight = distance
					visit[to].from = from
				}
			}
		}
	}

	return visit
}

func includes(a []int, b int) bool {
	for _, v := range a {
		if v == b {
			return true
		}
	}
	return false
}

func calc(g *Graph, N, M, P int) int {
	v := g.BellmanFord(1, N)

	if len(v) == 0 {
		return -1
	}
	score := -v[N].weight
	if score < 0 {
		score = 0
	}
	return score
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()
	P := nextInt()

	g := NewGraph()
	for i := 0; i < M; i++ {
		from, to, coin := nextInt(), nextInt(), nextInt()
		g.AddEdge(from, to, P-coin)
	}

	score := calc(g, N, M, P)
	fmt.Printf("%d\n", score)
}


Measured memory_bytes: 1536
import math

n = int(input())

ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        l = math.gcd(i, j)
        if l == 1:
            ans += n
            pass
        else:
            for k in range(1, n+1):
                ans += math.gcd(l, k)

print(ans)

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

int main() {

	int n;
	int p = 0;
	int w = 0;
	int g = 0;
	int y = 0;

	cin >> n;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "P") p++;
		else if (s == "W") w++;
		else if (s == "G") g++;
		else if (s == "Y") y++;
	}
	int count = (p != 0) + (w != 0) + (g != 0) + (y != 0);
	if (count == 3) cout << "Three" << endl;
	else if (count == 4) cout << "Four" << endl;
}
	

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long int a,b,c,d,n,sum,cet;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

	long long int f=b/c-(a-1)/c;
	long long int g=b/d-(a-1)/d;
	long long int e=c*d;
	if(c<d){
    long long int tmp = c;
    c = d;
    d = tmp;
  }
  /* ユークリッドの互除法 */
 long long int  r = c % d;
  while(r!=0){
    c = d;
    d = r;
    r = c % d;
  }
	long long int h=b/(e/d)-(a-1)/(e/d);
	printf("%lld\n",b-a+1-(f+g-h));
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

// template <class T>
// using Tree =
//     tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

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

  vector<int> A(N);
  F0R(i, N) { cin >> A.at(i); }
  // // vector<int> AA;
  // // reverse_copy(A.begin(), A.end(), back_inserter(AA));
  // // // cout << A.at(1) << endl;
  // // // cout << AA.at(1) << endl;

  F0R(i, N) { cin >> A.at(i); }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  // for (int x : A) {
  //   cout << x;  // 1 2 3・・・7 と順に表示される
  // }
  // cout << endl;

  int a, b, c, counter = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        a = A[i];
        b = A[j];
        c = A[k];
        // cout << "ijk" << i << j << k << endl;
        // cout << "abc" << a << b << c << endl;
        if (a + b > c && b + c > a && c + a > b) {
          counter = counter + 1;
        } else {
          break;
        }
      }
    }
  }
  cout << counter << endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    while (s.find("eraser") != string::npos) {
        s.erase(s.find("eraser"), 6);
    }
    while (s.find("erase") != string::npos) {
        s.erase(s.find("erase"), 5);
    }
    while (s.find("dreamer") != string::npos) {
        s.erase(s.find("dreamer"), 7);
    }
    while (s.find("dream") != string::npos) {
        s.erase(s.find("dream"), 5);
    }
    if (s.empty()) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 640
def abc173d_chat_in_the_circle():
    n = int(input())
    a = sorted(map(int, input().split()), reverse=True)
    if n <= 1:
        print(0)
        return
    val = 0
    for i in range(0, n-1):
        idx = (i+1) // 2
        val += a[idx]
    print(val)

abc173d_chat_in_the_circle()

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

int main(){

    int n;
    cin >> n;

    int i=1;

    if(n%4 == 0){

        cout << "Yes" << endl;
        return 0;

    }

    while(n-(7*i) >= 0){

        if(n-(7*i) == 0){

            cout << "Yes" << endl;
            return 0;

        }else if((n-(7*i))%4 == 0){

            cout << "Yes" << endl;
            return 0;

        }

        ++i;

    }

    cout << "No" << endl;

    return 0;
}

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

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

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

void setDepth(int u, int d) {
  if (u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if (T[u].left != NIL) {
    h1 = setHeight(T[u].left) + 1;
  }
  if (T[u].right != NIL) {
    h2 = setHeight(T[u].right) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 節点uの兄弟を返す
int getSibling(int u) {
  if (T[u].parent == NIL) return NIL;
  if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}

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

  if (T[u].parent ==  NIL) {
    printf("root\n");
  } else if (T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main() {
  int v, l, r, root = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) T[i].parent = NIL;

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if (l != NIL) T[l].parent = v;
    if (r != NIL) T[r].parent = v;
  }

  for (int i = 0; i < n; i++) if (T[i].parent == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++) print(i);

  return 0;
}



Measured memory_bytes: 2104
import bisect

N=int(input())
A=[int(i) for i in input().split(" ")]
A=sorted(A)
traceback=[]

if A[0]>=0:
    minus=[A[0]]
    plus=A[1::]
elif A[-1]<=0:
    minus=A[:-1:]
    plus=[A[-1]]
else:
    index=bisect.bisect_left(A,0)
    minus=A[:index:]
    plus=A[index::]

print(sum(plus)-sum(minus))
m=minus.pop(0)
for p in plus[:-1:]:
    print(m,p)
    m=m-p
print(plus[-1],m)
p=plus[-1]-m
for m in minus:
    print(p,m)
    p=p-m


Measured memory_bytes: 13964
MOD = 10**9+7
n = int(input())
S = [1]*n
D = [1]*(n+1)
for i in range(n):
  D[i+1] = D[i]*2 % MOD
for i in range(n-1):
  S[i+1] = (S[i]*2 + D[i+1]) % MOD
T = S[::-1]
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
  ans += C[i]*((D[n-(i+1)]+T[i])*D[i]) % MOD
  ans %= MOD
ans = ans*D[n-1]%MOD
print(ans)

Measured memory_bytes: 95108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int a,b;
int main(){
    cin >> a >> b;
    double al = a / 0.08,ar = (a+1) / 0.08;
    double bl = b / 0.1,br = (b+1) / 0.1;
    if(al <= bl && bl < ar) cout << (int)(bl+0.9);
    else if(bl < al && al < br) cout << (int)(al+0.9);
    else cout << -1;
    return 0;
}


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,a,b;
vpi p;

signed main(){
    I(n);
    REP(i,n){
        I(a); I(b);
        p.eb(a,b);
    }
    sort(all(p), [](const auto &a, const auto &b) -> bool{
        return a.first + a.second > b.first + b.second;
    });
    int ret = 0;
    REP(i,n){
        ret += (i%2 ? -p[i].second : p[i].first);
        // cerr << ret << endl;
    }
    cout << ret << endl;
}

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

using namespace std;

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

int main() {
  int N, X;
  long ans = 0x7FFFFFFFFFFF;
  vector<long> aft;
  
  cin >> N >> X;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    aft.push_back(abs(in - X));
  }
  
  if (N > 1) {
    for (int i = 0; i < N - 1; i++) {
      ans = min(ans, gcd(aft[i], aft[i + 1]));
    }
  } else {
    ans = aft[0];
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
int main(){
    ios::sync_with_stdio(false);
    int  n,x,t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t << endl;
}


Measured memory_bytes: 3604
#python3
from collections import defaultdict
from collections import namedtuple

P = namedtuple('P', ['front', 'end'])

def f(x):
    return P(str(x)[0], str(x)[-1]) 

def main():

    n = int(input())
    freq = defaultdict(int)

    for i in range(1, n+1):
        p = f(i)
        freq[p]+=1


    ans = 0
    for i in range(1, n + 1):
        p = f(i)
        q = (p.end, p.front)
        ans += freq[q]

    print(ans)

main()

Measured memory_bytes: 3444
#include<stdio.h>

int main(void)

{

 int a,b,c,x;

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

 if(a>b){

    x=a;

    a=b;

    b=x;

 }

 if(a>c){

    x=a;

    a=c;

    c=x;

 }

 if(b>c){


    x=b;


    b=c;


    c=x;


 }


 printf("%d %d %d\n",a,b,c);

 return 0;

}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "Sunny")
        cout << "Cloudy" << endl;
    else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int n,num,ans,x;
vector<P>v;
main(){
	while(cin>>n,n){
	v.clear();
	ans=0;
	r(i,n){
		num=v.size()-1;
		cin>>x;
		if(i%2==0){
			if(i==0)v.push_back(P(1,x));
			else{
				if(v[num].second==x)v[num].first++;
				else v.push_back(P(1,x));
			}
		}
		else{
			if(v[num].second==x)v[num].first++;
			else{
				int t=v[num].first;
				v.erase(v.begin()+num);
				if(v.size())v[num-1].first+=t+1;
				else v.push_back(P(t+1,x));
			}
		}
	}
	r(i,v.size())if(v[i].second==0)ans+=v[i].first;
	cout<<ans<<endl;
    }
}

Measured memory_bytes: 3068
import collections

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

s = collections.Counter(s)
t = collections.Counter(t)
ans = 0
for k in s:
    ans = max(ans, s[k] - t[k])
print(ans)


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

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

    vector<pair<int,int>> list;
    int maxa=0;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        list.push_back(make_pair(a,b));

        if(a>maxa) maxa=a;
    }

    sort(list.begin(),list.end(),[](const pair<int,int>& x, const pair<int,int>& y){ return x.second > y.second; });

    int sumb=0;
    int cntb=0;
    for(int i=0;i<N;i++){
        if(list[i].second>maxa){
            sumb+=list[i].second;
            cntb++;
        }else{
            break;
        }
    }

    int cnta=(H-sumb)/maxa;
    if(H<sumb){
        int cnt=0;
        for(int i=0;i<N;i++){
            cnt++;
            H-=list[i].second;
            if(H<=0){
                cout << cnt << endl;
                return 0;
            }
        }
    }else if(cnta*maxa+sumb>=H){
        cout << (cnta+cntb) << endl;
    }else{
        cout << (cnta+cntb+1) << endl;
    }

    return 0;
}

Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    subordinate_counter_list = [0 for i in range(N)]
    for i in A_list:
        subordinate_counter_list[i-1] += 1
    for i in subordinate_counter_list:
        print(i)

if __name__ == "__main__":
    main()



Measured memory_bytes: 32372
function main()
  
  N = parse(Int,readline())
  A = zeros(Int,N)
  
  for i in 1:N
    A[i] = parse(Int,readline())
  end
  
  check = sort(A)
  
  for i in 1:N
    if A[i] != check[end]
      println(check[end])
    else
      println(check[end-1])
    end
  end

end
  
main()

Measured memory_bytes: 154700
#include <stdio.h>
#include <string.h>
int main(void){
    char s[200000+5];
    int ans=0;
    scanf("%s", s);
    for(int i=0; i<strlen(s); i++){
        ans+=(int)s[i]-'0';
        ans%=9;
    }
    
    if(ans==0)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if(k <= a){
        cout << a-k << " " <<b << endl;
    }
    else if(k > a && k <= a+b){
        cout << 0 << " " << b - k + a << endl;
     }
     else{
         cout << 0 << " " << 0 << endl;
     }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define in(n)  int n; cin>>n;
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
using namespace std;
int  main()
{
int n;
int m;
cin>>n>>m;
cout<<(n-1)*(m-1)<<endl;
}	

	


Measured memory_bytes: 256
N,K,Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

points = [0] * N

for i in range(Q):
    points[A[i]-1] += 1

for i in range(N):
    point = K - Q + points[i]
    print('Yes' if point > 0 else 'No')



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

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
double PI = acos(-1);


class Dice {
  int i;
 public:
  int s[6];
  Dice(){};
  
  void roll(int i, int j, int k, int l) {
    int t = s[i]; s[i] = s[j]; s[j] = s[k]; s[k] = s[l]; s[l] = t;
  }
  void moveN() { roll(0, 1, 5, 4); }
  void moveW() { roll(0, 2, 5, 3); }
  void moveH() { roll(1, 2, 4, 3); }

  void move(char c) {
    if (c == 'N') moveN();
    if (c == 'S') rep(i,3) moveN();
    if (c == 'W') moveW();
    if (c == 'E') rep(i,3) moveW();
  }

  void read() { rep(i,6) cin >> s[i]; }
  
  bool eq(Dice* d2) {
    rep(i,6) if (s[i] != d2->s[i]) return false;
    return true;
  }
};


int main() {
  int i, j;

  Dice* d1 = new Dice; d1->read();
  Dice* d2 = new Dice; d2->read();
  rep(i,4) {
    d1->moveN();
    rep(j,4) {
      d1->moveH();
      if (d1->eq(d2)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  rep(i,4) {
    d1->moveW();
    rep(j,4) {
      d1->moveH();
      if (d1->eq(d2)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}
  

Measured memory_bytes: 1184
import bisect

n=int(input())
a=sorted(map(int,input().split()))
b=sorted(map(int,input().split()))
c=sorted(map(int,input().split()))

ans=0

for i in range(n):
    num1 = bisect.bisect_left(a,b[i])
    num2 = n - bisect.bisect(c,b[i])
    ans += num1*num2

print(ans)

Measured memory_bytes: 23328
import sys

fin = sys.stdin.readline

n = int(fin())
a = list(map(int, fin().split()))

rain = [None] * n
rain[0] = sum(a[::2]) - sum(a[1::2])

for i in range(1, n):
    rain[i] = a[i-1] * 2 - rain[i-1]

print(*rain, sep=" ")

Measured memory_bytes: 60516
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <queue>

using namespace std;

const int SIZE = 100010;

vector<pair<int,int> > way[SIZE];

int main(){
  int n,m,s,t;
  int a,b,c,d;

  scanf("%d%d%d%d",&n,&m,&s,&t);
  
  for(int i=0;i<m;i++){
    scanf("%d%d%d%d",&a,&b,&c,&d);

    way[a].push_back({b,d});
    way[b].push_back({a,d});
    way[a].push_back({c,d});
    way[c].push_back({a,d});
    way[b].push_back({c,d});
    way[c].push_back({b,d});
  }

  priority_queue<pair<long long,int> > pq;
  bool visited[SIZE] = {};
  
  pq.push({0,s});
  
  while(pq.size()){
    int now = pq.top().second;
    long long cost = pq.top().first;
    pq.pop();

    if(visited[now]) continue;
    visited[now] = true;

    if(now == t){
      printf("%lld\n",-cost);
      return 0;
    }
    
    for(int i=0;i<way[now].size();i++){
      pq.push({cost-way[now][i].second, way[now][i].first});
    }
  }


}



Measured memory_bytes: 21756
#include <stdio.h>
#include <math.h>

int main()
{
    double a,b,c,d,e,f,p;
    double x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
    p=a*e-b*d;
    x=(c*e-b*f)/p;

    y=(a*f-c*d)/p;
    if(x==0)x=0;
    if(y==0)y=0;
    printf("%0.3lf %0.3lf\n",x,y);
    }
return 0;
}

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

def main():
    N = int(input())
    S = [None]*N
    for _ in range(N):
        a,b = map(int,input().split())
        S[_] = [a+b, a, b]
    S.sort(reverse = True)
    ret = 0
    for i in range(N):
        if i%2==0:
            ret += S[i][1]
        else:
            ret -= S[i][2]
#        print(i,ret)
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 29068
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int val = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == 'R') val++;
    }
    int ans = 0;
    for (int i = 0; i < val; ++i) {
        if(s[i] == 'W') ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3688
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 20:30:09 2019

@author: Yamazaki Kenichi
"""
import sys

N, A, B, C, D = map(int,input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1

if S[A] == '#' or S[B] == '#' or S[C] == '#' or S[D] == '#':
    print('No')
    sys.exit()

goal = True
previous = True
jump = False
for i in range(A + 1, max(C+1,D+1)):
    if S[i] == '.':
        True
    elif S[i-1] == '#' and S[i] == '#':
        goal = False
    if i >= B and i <= D and i != max(C,D):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            jump = True
#            print(i,previous, S[i] == '.', S[i+1])
#    print(i,previous)
if C > D:
    if not jump:
        print('No')
        sys.exit()
if goal:
    print('Yes')
else:
    print('No')

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>t(N),x(N),y(N);
  for(int i=0;i<N;i++)cin>>t[i]>>x[i]>>y[i];
  int nowx=0;
  int nowy=0;
  int now=0;
  for(int i=0;i<N;i++){
    int d=abs(x[i]-nowx)+abs(y[i]-nowy);
    if(d>t[i]-now){
      cout<<"No"<<endl;
      return 0;
    }
    if((t[i]-now-d)%2){
      cout<<"No"<<endl;
      return 0;
    }
    nowx=x[i];
    nowy=y[i];
    now=t[i];
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;
const ll MOD  = int(1e9 + 7);

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}


int main () {
	int n;
	cin >> n;
	double temp;
	double dp[n+1] ; // 0 se nheads (inclusive)
	for (int i = 0 ; i<n+1 ; i++ ) {
		dp[i] = 0.0;
	}
 
	dp[0] = 1.0; 
	for(int i = 0; i<n;i++) {
		cin >> temp;
		for (int j = n; j>0;j--) {
			dp[j] = temp * dp[j-1] + (1.0-temp) * dp[j]; 
		}
		dp[0] = dp [0] * (1.0- temp);
	}
	double answer = 0;
	for (int i = (n+1)/2; i<n+1;i++) {
		answer += dp[i];
	}
	cout << setprecision(10)<<answer <<endl;
	
}

Measured memory_bytes: 384
#!/usr/bin/env python3
n, k = map(int, input().split())
v = list(map(int, input().split()))
r = min(n, k)
ans = -float('inf')
for i in range(r+1):
    a = v[:i]
    for j in range(r+1-i):
        candi = a[:]
        if j != 0:
            candi += v[-j:]
        candi.sort()
        for t in range(k-i-j):
            if not 0 <= t < len(candi):
                break
            if candi[t] < 0:
                candi[t] = 0
            else:
                break
        candi = sum(candi)
        ans = max(candi, ans)
print(ans)


Measured memory_bytes: 3064
N, D = gets.split.map(&:to_i)
X = [*0...N].map{ gets.split.map(&:to_i) }

p X.combination(2).map {|ys, zs|
    ys.zip(zs).map{|yi, zi| yi**2 - 2*yi*zi + zi**2 }.inject(0, :+)
}.map{|s| Math.sqrt(s) }.select{|v| v.to_s =~ /.*\.0$/ }.size


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;



int main()
{
	string divide[4] = { "dream","dreamer","erase","eraser" };
	string s;
	bool flag1 = false;
	bool flag2 = false;
	cin >> s;

	reverse(s.begin(),s.end());
	for (int i = 0; i < 4; i++) {
		reverse(divide[i].begin(), divide[i].end());
	}
	
	for (int i = 0; i < s.size();) {
		flag1 = false;
		for (int j = 0; j < 4; j++) {
			string d = divide[j];
			if (s.substr(i, d.size()) == d) {
				flag1 = true;
				i += d.size();
				break;
			}
		}
		if (flag1 == false) {
			flag2 = true;
			break;
		}
	}
	if (flag2 == false) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.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;
    for (int i = 0; i < 200; i++)
    {
        if (i % 2 == 0)
        {
            C -= B;
            if (C <= 0)
            {
                cout << "Yes" << endl;
                break;
            } 
        }
        else
        {
            A -= D;
            if (A <= 0)
            {
                cout << "No" << endl;
                break;
            }
        }
    }

}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

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


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a;i>0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

//素因数分解
map<ll, ll>prime_factor(ll n){
    map<ll,ll>res;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1)res[n]=1;
    return res;
}

ll modpow(ll x, ll p){
    if(p == 0) return 1;
    if(p % 2) return  x * modpow(x, p - 1) % mod;
    else {
        ll res = modpow(x, p / 2);
        return res * res % mod;
    }
}

ll comb(ll n, ll r){
    ll mul = 1;  //n!
    ll div1, div2;
    rep(i, 1, n + 1){
        mul *= i;
        mul %= mod;
        if(i == r) div1 = modpow(mul, mod - 2);  //r!
        if(i == n - r) div2 = modpow(mul, mod - 2); //(n-r)!
    }
    return mul * div1 % mod * div2 % mod;
}

int main(){
    ll n, m;
    cin >> n >> m;
    auto mp = prime_factor(m);
    ll ans = 1;
    if(n == 1){print(ans); return 0;}
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        ans = ans * comb(n - 1 + itr->second, itr->second) % mod;
    }
    print(ans);
}


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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

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

	int ans;
	ans = x/200;
	ans = 9 - (ans - 1);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3600
// C - Maximal Value
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)

int main(){
	int N; cin>>N;
	vi B(N-1); rp(i,N-1) cin>>B[i];
	ll ans = B[0] + (N-2>=0? B[N-2]: 0);
	rp(i,N-2) ans += min(B[i], B[i+1]);
	cout<< ans <<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();

        int a[] = new int[30];

        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                a[sc.nextInt() - 1]++;
            }
        }


        int ans = 0;
        for (int j = 0; j < m; j++) {
            if(a[j] == n) ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
#define INF 0x7ffffffff
int main()
{
    int N, W;
    //freopen("input.txt", "r", stdin);
    scanf("%d%d", &N, &W);
    vector<int>w(N);
    vector<int>v(N);
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &w[i], &v[i]);
    }
    vector<long> dp(N*1000+1, INF);
    dp[0] = 0;
    for(int i=0; i<N; i++)
    {
        for(int j=N*1000; j>=v[i]; j--)
        {
            dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
        }
    }
    long ans = 0;
    for(long i=0; i<=N*1000; i++)
    {
       if(dp[i] <= W)ans = i;
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int A,B,C,ans; cin>>A>>B>>C;
  if(A==B&&B==C&&A%2==0)
    ans=-1;
  else{
    ans=0;
    while(A%2==0&&B%2==0&&C%2==0){
      ans++;
      int D=A,E=B,F=C;
      A=(E+F)/2;
      B=(D+F)/2;
      C=(E+D)/2;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
   while(1){
       
       int n,ice,i,ice0=0,ice1=0,ice2=0,ice3=0,ice4=0,ice5=0,ice6=0,ice7=0,ice8=0,ice9=0;
       scanf("%d",&n);
       if(n==0){
           break;
       }
       for(i=1;i<=n;i++){
           scanf("%d",&ice);
           
           if(ice==0){
               ice0++;
           }
           if(ice==1){
               ice1++;
           }
           if(ice==2){
               ice2++;
           }
           if(ice==03){
               ice3++;
           }
           if(ice==4){
               ice4++;
           }
           if(ice==5){
               ice5++;
           }
           if(ice==6){
               ice6++;
           }
           if(ice==7){
               ice7++;
           }
           if(ice==8){
               ice8++;
           }
           
           if(ice==9){
               ice9++;
           }
       }
       
       
       for(i=1;i<=ice0;i++){
           printf("*");
       }
       if(ice0==0){
           printf("-");
       }
       printf("\n");
       
       for(i=1;i<=ice1;i++){
           printf("*");
       }
       if(ice1==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice2;i++){
           printf("*");
       }
       if(ice2==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice3;i++){
           printf("*");
       }
       if(ice3==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice4;i++){
           printf("*");
       }
       if(ice4==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice5;i++){
           printf("*");
       }
       if(ice5==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice6;i++){
           printf("*");
       }
       if(ice6==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice7;i++){
           printf("*");
       }
       if(ice7==0){
           printf("-");
       }
       printf("\n");
       for(i=1;i<=ice8;i++){
           printf("*");
       }
       if(ice8==0){
           printf("-");
       }
       printf("\n");
       
       for(i=1;i<=ice9;i++){
           printf("*");
       }
       if(ice9==0){
           printf("-");
       }
       printf("\n");
   }
   
}


Measured memory_bytes: 2040
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
#pragma GCC optimize(3)
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#define ll long long
#define ull unsigned long long
#define mn 5000020
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline ll Max(ll a,ll b){return (a>b)?a:b;}
inline ll Min(ll a,ll b){return (a<b)?a:b;}
inline ll Abs(ll x){return (x<0)?-x:x;}

int main(){
	int a=read(),b=read();
	if(a*b%2||a*b*2%2||a*b*3%2)puts("Yes");else puts("No");
	return 0;
}


Measured memory_bytes: 256