akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(abs(A[i]-A[j])%(N-1) == 0){
                cout << A[i] << " " << A[j] << "\n";
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;

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

int h, w, n;
int r, c;
string s, t;
vi S;
vi T;

bool inRange(int y, int x) {
  return y >= 0 && y < h && x >= 0 && x < w;
}

bool f(int d, int rd) {
  int y = r;
  int x = c;

  for(int i=0; i<n; ++i) {
    if(S[i] == d) {
      y += dy[d];
      x += dx[d];
    }

    if(!inRange(y, x)) {
      return true;
    }

    if(T[i] == rd) {
      y += dy[rd];
      x += dx[rd];
    }
    if(!inRange(y,x)) {
      y -= dy[rd];
      x -= dx[rd];
    }
  }

  return false;
}

int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  cin >> h >> w >> n;
  cin >> r >> c;
  r--; c--;
  cin >> s;
  cin >> t;
  S.resize(n);
  T.resize(n);
  rep(i,0,n) {
    if(s[i] == 'U') {
      S[i] = 0;
    } else if(s[i] == 'R') {
      S[i] = 1;
    } else if(s[i] == 'D') {
      S[i] = 2;
    } else if(s[i] == 'L') {
      S[i] = 3;
    }

    if(t[i] == 'U') {
      T[i] = 0;
    } else if(t[i] == 'R') {
      T[i] = 1;
    } else if(t[i] == 'D') {
      T[i] = 2;
    } else if(t[i] == 'L') {
      T[i] = 3;
    }
  }

  bool outOfBoard = false;
  outOfBoard = f(0,2) || f(1,3) || f(2,0) || f(3,1);
  if(outOfBoard) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}

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

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

  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    int C = min(A[i], B[i]);
    ans += C, A[i] -= C, B[i] -= C;
    ans += min(A[i + 1], B[i]), A[i + 1] -= min(A[i + 1], B[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	map<int,int> mp;
	VAR(int,n,m);
	REP(i,n){
		VAR(int, k);
		REP(j,k){
			VAR(int,a);
			mp[a]++;
		}
	}

	int ans =0;
	EACH(mi,mp){
		if(mi.second==n) ++ans;
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int count=0;
void merge(int *A,int left,int mid,int right){
  int n1 = mid-left;
  int n2 = right-mid;
  int L[n1+1], R[n2+1],i,j,k;
  for (i=0;i<n1;i++){
    L[i]=A[left+i];
  } 
  for (i=0;i<n2;i++){
    R [i]=A[mid+i];
  }
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  j = 0;
  for (k=left;k<right;k++){
      if (L[i]<=R[j]){
	count++;
	A[k]=L[i];
	i=i+1;
      }
      else{
	A[k]=R[j];
	count++;
	j=j+1;
      }
  }
}
void mergeSort(int *A,int left,int right) {
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
int main(){
  int n,right,left=0;
  int A[500000];
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  right=n;
  mergeSort(A,left,right);
  printf("%d",A[0]);
  for(i=1;i<n;i++){
    printf(" %d",A[i]);
    }
  printf("\n%d\n",count);    
  return 0; 
}



Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"siktim seni\n";
ll int a,i,b,ans=LLONG_MAX;
int main(){
	cin>>a;
	for(i=1;i<sqrt(a)+5;i++){
		if(!(a%i)){
			ans=min(ans,i+a/i);
		}
	}
	cout<<ans-2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  int N, X; cin >> N >> X;
  vi x(N); rep(i,N) cin >> x[i];

  vi d(N);
  rep(i,N) {
    d[i] = abs(x[i] - X);
  }
  
  int D = 0;
  rep(i,N) {
    D = gcd(D,d[i]);
  }

  cout << D << endl;
}

Measured memory_bytes: 1024
def abs(a):   
    if a >= 0:       
        return a    
    else:        
        return (-a)    
n = int(input())
c = [] 
for i in range(0,n):     
    c.append(str(input()).split()) 
c.insert(0,[0,0,0])
for i in range(0,n):    
    t = int(c[i+1][0])-int(c[i][0])     
    x = int(c[i+1][1])-int(c[i][1])     
    y = int(c[i+1][2])-int(c[i][2])     
    d = abs(x) + abs(y)    
    if not(d <= t and t%2 == d%2):        
        print('No')        
        break
else:    
    print('Yes')

Measured memory_bytes: 32152
def main():
    N, M = map(int, input().split())
    if N == 1:
        if M > 2:
            print(M-2)
        elif M == 2:
            print(0)
        else:
            print(1)
    elif M == 1:
        if N > 2:
            print(N-2)
        elif N == 2:
            print(0)
        else:
            print(1)
    elif N == 2 or M == 2:
        print(0)
    else:
        print((N-2)*(M-2))
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, l, a, b, c, d, ans = 0;
    string s, t, r;

    cin >> s;
    s[3] = '8';
 
    cout << s << endl;
}

Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N = attrs.shift[0]
D = attrs.shift
result = 0
for i in 0..(N - 1) do
  for j in 0..(N - 1) do
    result += D[i] * D[j] unless i == j
  end
end

puts result / 2

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int k;
int a[N];

int main() {
    #ifdef black
    //freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> k;
    forn(i, 1, k)
        cin >> a[i];
    ll l = 2, r = 2;
    for1(i, k, 1) {
        if (l % a[i] != 0 && r % a[i] != 0 && l / a[i] == r / a[i]) {
            cout << "-1\n";
            return 0;
        }
        ll nl = l + (a[i] - l % a[i]) % a[i];
        ll nr = r - (r % a[i]) + (a[i] - 1);
        assert(nl <= nr);
        l = nl, r = nr;
    }
    cout << l << " " << r << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin>>N>>K>>S;
  K--;
  if(S.at(K)=='A'){
  	S.at(K)='a';
  }
  if(S.at(K)=='B'){
  	S.at(K)='b';
  }
  if(S.at(K)=='C'){
  	S.at(K)='c';
  }
  
  cout<<S<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n string
	fmt.Scan(&n)

	result := "No"
	for i := 0; i < len(n); i++ {
		if (i%2 == 0 && (n[i] == 'R' || n[i] == 'U' || n[i] == 'D')) ||
			(i%2 != 0 && (n[i] == 'L' || n[i] == 'U' || n[i] == 'D')) {
			result = "Yes"
		} else {
			result = "No"
			break
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
//58
#include<iostream>

using namespace std;

int main(){
  int dn[13][32];
  int i=3;
  for(int m=1;m<13;m++){
    static const int dom[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    for(int d=1;d<=dom[m];d++){
      dn[m][d]=i++;
      i%=7;
    }
  }
  for(int m,d;cin>>m>>d,m;){
    static const char *ds[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    cout<<ds[dn[m][d]]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[10];
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;


int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,d;
    long long int m,n,o,i,j,k=1,money;
    long long int a,a1=0,a2=0,a3=0,ar=1,as=1,at1;
    string s;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>s;
    for(i=0;i<s.size()-1;i++)
    {
        if(s[i]!=s[i+1])
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}





Measured memory_bytes: 256
module DLinkedList = struct
  type 'a element =
    { value : 'a;
      mutable next : int;
      mutable prev : int
    }
  type 'a t = {
    mutable first : int;
    mutable last  : int;
    mutable index : int;
    elts : 'a element array
  }

  let create n = {first = -1; last = -1; index = 0;
                  elts = Array.make n {value=0;next=0;prev=0}}
                 
  let insert_first t value =
    let new_elt = {prev = -1; next = t.first; value} in
    let i = t.index in
    begin match t.first with
      | -1 -> ()
      |  old_first -> t.elts.(old_first).prev <- i
    end;
    t.first <- i; t.elts.(i) <- new_elt; t.index <- i + 1;
    begin match t.last with
      | -1 -> t.last <- t.first
      | _ -> ()
    end

  let remove t elt =
    let {prev; next; _} = elt in
    begin match prev with
      | -1 -> t.first <- next
      | pi -> t.elts.(pi).next <- next
    end;
    begin match next with
      | -1 -> t.last <- prev
      | ni -> t.elts.(ni).prev <- prev
    end
      
  let find t v =
    let eq (a:int) (b:int) = (=) a b in
    let rec loop = function
      | -1 -> ()
      |  i ->
        let elt = t.elts.(i) in
        if eq v elt.value then remove t elt
        else loop elt.next
    in
    loop t.first

  let remove_first t =
    begin match t.first with
      | -1 -> ()
      |  i ->
        let first = t.elts.(i) in
        begin match first.next with
          | -1 -> t.first <- -1; t.last <- -1
          | j -> t.elts.(j).prev <- -1; t.first <- j
        end
    end

  let remove_last t =
    begin match t.last with
      | -1 -> ()
      | i ->
        let last = t.elts.(i) in
        begin match last.prev with
          | -1 -> t.first <- -1; t.last <- -1
          |  j -> t.elts.(j).next <- -1; t.last <- j
        end
    end

  let print t =
    let rec loop e = match e.next with
      | -1 -> Printf.printf "%d\n" e.value
      |  i -> Printf.printf "%d " e.value; loop t.elts.(i)
    in
    loop t.elts.(t.first)
end

let () =
  let open DLinkedList in
  let (n: int) = read_int () in
  let (dll: int t) = create n in
  for i=1 to n do
    begin match read_line () with
      | "deleteFirst" -> remove_first dll
      | "deleteLast" -> remove_last dll
      | s ->
        begin match String.sub s 0 6,
                    (String.sub s 7 (String.length s - 7)
                    |> int_of_string) with
        | "insert", n -> insert_first dll n
        | "delete", n -> find dll n
        | _ -> ()
        end
    end
  done;
  print dll

Measured memory_bytes: 59008
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    int x;
    cin >> x;
    int a[4];
    a[0] = x / 1000; x %= 1000;
    a[1] = x / 100; x %= 100;
    a[2] = x / 10;
    a[3] = x % 10;

    int ans = -1;
    for (int bit = 0; bit < 1<<3; bit++){
        int sum = a[0];
        for (int j = 0; j < 3; j++){
            if (bit >> j & 1){
                sum += a[j + 1];
            }else{
                sum -= a[j + 1];
            }
        }
        if (sum == 7){
            ans = bit;
            break;
        }
    }

    cout << a[0];
    for (int i = 0; i < 3; i++){
        if (ans >> i & 1) cout << "+";
        else cout << "-";
        cout << a[i + 1];
    }
    cout << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c) {}
};

vector<vector<edge> > es;
typedef pair<int, int> P;

int dijkstra(int s, int g) {
	priority_queue<P, vector<P>, greater<P> > que;
	vector<int> d(g + 1, INT_MAX);
	que.push(P(0, s));
	d[s] = 0;
	
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first)
			continue;

		if(v == g)
			return p.first;

		for(int i = 0; i < es[v].size(); ++i) {
			edge e = es[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

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

	vector<pair<string, int> > gt;
	map<string, int> label;

	int n;
	cin >> n;
	cin.ignore();

	es.resize(n + 1);

	for(int i = 0; i < n; ++i) {
		string s;
		getline(cin, s);

		if(s[s.size() - 1] == ':') {
			es[i].push_back(edge(i + 1, 0));
			label.insert(make_pair(s.substr(0, s.size() - 1), i));
		}
		else {
			es[i].push_back(edge(i + 1, 1));
			s = s.substr(5, s.size() - 6);
			gt.push_back(make_pair(s, i));
		}
	}

	for(int i = 0; i < gt.size(); ++i)
		es[gt[i].second].push_back(edge(label[gt[i].first], 0));

	cout << dijkstra(0, n) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
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()
{
	int n; cin >> n;
	int ans = (n - 2) * 180;
	co(ans);
	return 0;
}


Measured memory_bytes: 256
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = INT()
a = LIST()
q = INT()
b = [0]*q
c = [0]*q
for i in range(q):
    bb, cc = MAP()
    b[i] = bb
    c[i] = cc

res = sum(a)
counter = Counter(a)
for i in range(q):
    res += counter[b[i]]*(c[i]-b[i])
    counter[c[i]] = counter[b[i]] + counter[c[i]]
    counter[b[i]] = 0
    print(res)

Measured memory_bytes: 94180
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    if(2*b>=a)  cout<<0<<endl;
    else        cout<<a-2*b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int m[10],count=0,M;
  for(int i=0;i<n;i++){
    cin>>m[i];
    if(i==0)M=m[0];
    if(i>=1){
      if(m[i]>=M){M=m[i];count++;
                 }else continue;
             }
  }
  cout<<count+1;
}

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

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

/*-------------------------------------------*/

int n,x,mx,sum;

int main(){
    cin>>n;
    rep(i,n){
        cin>>x;
        chmax(mx,x);
        sum+=x;
    }
    cout<<(mx*2<sum?"Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 10000 + 15;
int a[200][200],s[MAXN];
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m)){
        int t,cnt = 0;
        scanf("%d",&t);
        for(int i = 1; i <= t; i++) scanf("%d",&s[i]);
        int x = 1, y = 1;
        for(int i = 1; i <= t; i++){
            for(int j = 1; j <= s[i]; j++){
                a[x][y++] = i;
                if(y == m+1) {
                    x = x+1;
                    y = 1;
                }
            }
        }
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1) {
                for(int j = 1; j <= m; j++)
                    printf("%d ",a[i][j]);
            }

            else if(i % 2 == 0) {
                for(int j = m; j >= 1; j--)
                    printf("%d ",a[i][j]);
            }
            printf("\n");
        }
    }
}

Measured memory_bytes: 384
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		int n = sc.nextInt();
		String s = sc.next();
		System.out.println(s.substring(0, n/2).equals(s.substring(n/2)) ? "Yes" : "No");
	}
}


Measured memory_bytes: 35640
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int n, m, r, q, t[10000][1300];

int main() {

	
	while (1) {

		for (int i = 0; i < 10000; i++) {
			for (int j = 0; j < 1300; j++) {
				t[i][j] = 0;
			}
		}

		cin >> n >> m;
		if (n==0 && m==0) break;

		cin >> r;
		for (int i = 0; i < r; i++) {
				int tt, tn, tm, ts;
				cin >> tt >> tn >> tm >> ts;
				if (ts == 1) t[tm-1][tt]++;
				else t[tm - 1][tt+1]--;
		}

		for (int i = 0; i < m; i++) {
			for (int j = 1; j <1300; j++) {
				t[i][j] += t[i][j-1];
			}
		}

		//vector<int> v;
		cin >> q;
		for (int i = 0; i < q; i++) {
			int ts, te, tm;
			cin >> ts >> te >> tm;
			int ans=0;
			for (int j = ts; j < te; j++) {
				if (t[tm - 1][j]>0 && t[tm - 1][j+1]>0) ans++;
			}
			cout << ans << endl;
			//v.push_back(ans);
		}
		/*
		for (int h = 0; h < v.size(); h++) {
			cout << v[h] << endl;
		}
		*/
	}

	return 0;
}

Measured memory_bytes: 53884
# coding: utf-8
import math

t = [int(input()) for _ in range(5)]

min1 = map(lambda x: x % 10, t)
min1 = min([10 if i == 0 else i for i in min1])

print(sum(map(lambda x: math.ceil(x) * 10, [i/10 for i in t])) - (10 - min1))


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 mod_inverse(i64 a, i64 m) {
    i64 x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;
}

vector<i64> fact;
void init_fact(i64 n, i64 m) {
    fact.resize(n + 1);
    fact[0] = fact[1] = 1;
    for (i64 i = 2; i <= n; ++i) fact[i] = (i * fact[i - 1]) % m;
}

i64 mod_comb(i64 n, i64 k, i64 p) {
    if (n < 0 or k < 0 or n < k) return 0;
    i64 num=fact[n]*mod_inverse(fact[n-k],p)%p,den=fact[k];
    return num * mod_inverse(den, p) % p;
}

void solve() {
    const i64 mod = 1'000'000'007;

    init_fact(200000,mod);

    i64 N,K;
    cin >> N >> K;

    vector<vector<i64>> tree(N);
    rep(i,0,N-1){
        i64 a,b;
        cin >> a >> b;
        --a;
        --b;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
    }

    function<i64(i64,i64)> dfs=[&](i64 u,i64 p){
        i64 x=tree[u].size();
        i64 res;
        if(p==-1){
            res=mod_comb(K-1,x,mod)*fact[x]%mod;
        }else{
            --x;
            res=mod_comb(K-2,x,mod)*fact[x]%mod;
        }
        for(auto v:tree[u]){
            if(v==p) continue;
            res*=dfs(v,u);
            res%=mod;
        }
        return res;
    };

    rep(i,0,N){
        if(tree[i].size()>1) continue;
        cout << dfs(i,-1)*K%mod << endl;
        break;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll; 
#define FOR(i,l,r) for(i=l;i<r;i++) 
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll> 
#define F first 
#define S second
signed main(){
  ll N,M,ans=0,p=2;cin>>N;M=N;
  while(M>p*p){
    while(N%p!=0&&M>p*p)p++;
    if(N%p==0){
      ll e=0,n=0;
      while(N%p==0){e++;N/=p;}
      while((n+1)*(n+2)<=2*e)n++;
      ans+=n;
    }
  }
  for(p=2;p*p<=N;p++)if(N%p==0)break;
  if(p*p>N&&N!=1)ans++;
  cout<<ans<<endl;
  return 0;
}

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

using lint = long long int;

class UnionFind {
private:
	vector< int > data;
	
public:
	UnionFind() {}
	UnionFind(int n) : data(n, -1) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y]; data[y] = x;
		return 1;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

int N;
vector< set< int > > X;
UnionFind uf;

void solve() {
	vector< int > max_start(N, -1);
	for (int i=0; i<N; ++i) for (int x : X[i]) if (uf.sameSet(x, i)) max_start[i] = max(max_start[i], x);
	
	/*
	for (int i=0; i<N; ++i) cerr << max_start[i] << " ";
	cerr << endl;
	*/
	
	int ans = 0, cur = -1;
	for (int i=0; i<N; ++i) {
		if (max_start[i] >= 0 && cur < max_start[i]) {
			cur = i;
			++ans;
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	
	X.assign(N, set< int >());	
	uf = UnionFind(N);
	
	for (int i=0; i<N; ++i) {
		int M;
		cin >> M;
		
		for (int j=0; j<M; ++j) {
			int x;
			cin >> x;
			--x;
			if (x == i+1) uf.unionSet(i,i+1);
			else X[i].insert(x);
		}
	}
	
	solve();
}


Measured memory_bytes: 12260
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0 or b %3==0 or (a+b)%3==0) cout <<"Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
            int[] arr = new int[5];
            arr[0] = scn.nextInt();
            arr[1] = scn.nextInt();
            arr[2] = scn.nextInt();
            arr[3] = scn.nextInt();
            arr[4] = scn.nextInt();
               Arrays.sort(arr);
            System.out.println(arr[4] + " " + arr[3] + " " + arr[2] + " "
+ arr[1] + " " + arr[0]);
     }
}

Measured memory_bytes: 17164
#include <stdio.h>
#include<string.h>
int main(void){
    int i;
    char str[1200];
    scanf("%[^\n]",str);
    
    for(i=0;i<=strlen(str);i++){
        if(str[i]>=97&&str[i]<=122){
            str[i]=str[i]-32;
        }
        else if(str[i]>=65&&str[i]<=90){
            str[i]=str[i]+32;
        }
        else{
            str[i]=str[i];
        }
    }printf("%s\n",str);
    return 0;
}



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

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

  vector<string> S(H);
  rep(i, H) cin >> S[i];

  vector<int> dh = {1, 0, -1, 0};
  vector<int> dw = {0, 1, 0, -1};

  bool ok = true;
  rep(i, H) rep(j, W) {
    if (S[i][j] == '.')
      continue;
    bool next_to = false;
    rep(k, 4) {
      int ni = i + dh[k];
      int nj = j + dw[k];
      if (0 <= ni && ni < H && 0 <= nj && nj < W) {
        if (S[ni][nj] == '#')
          next_to = true;
      }
    }
    if (!next_to)
      ok = false;
  }

  if (ok)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 256
/*
g++ -std=c++11 -o2 -Wall ABC098C.cpp -o ./out/ABC098C.out
./out/ABC098C.out
*/

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

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;

int ss[300001];

int main() {
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  string s;
  cin >> n;
  cin >> s;
  ss[0] = 0;
  for (int i = 0; i < n; ++i) {
    int c = 0;
    if (s[i] == 'E') c = 1;
    ss[i + 1] = ss[i] + c;
  }
  int ans = n;
  for (int i = 0; i < n; ++i) {
      int temp = 0;
      temp += (i - ss[i]);
      temp += ss[n] - ss[i + 1];
      ans = min(ans, temp);
//      cout << ans << "\n";
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1812
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "a == b" << endl;
    } else if (a < b) {
        cout << "a < b" << endl;
    } else {
        cout << "a > b" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        TreeSet<Integer> divisors = new TreeSet<>();
        for (int i = 1; i * i <= m; i++) {
            if (m % i == 0) {
                divisors.add(i);
                divisors.add(m / i);
            }
        }
        System.out.println(m / divisors.ceiling(n));
    }
}

Measured memory_bytes: 24532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			long m = scanner.nextLong();
			if (1L == n) {
				if (1L == m) {
					System.out.println("1");
				} else {
					System.out.println(m - 2);
				}
			} else {
				if (1L == m) {
					System.out.println(n - 2);
				} else {
					System.out.println(n * m - 2 * (n + m - 4) - 4);
				}
			}
		}
	}
}


Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int dijkstra(vector<unordered_map<int, ll>>& edges, int start, int goal)
{
    if (start == goal) return 0;
    auto comp = [](pair<int, ll>& l, pair<int, ll>& r){return l.second > r.second;};
    priority_queue<pair<int, ll>, vector<pair<int, ll>>, decltype(comp)> pq(comp);
    vector<char> finished(edges.size(), false);
    pq.emplace(start, 0);
    finished[start] = true;

    while (!pq.empty()){
        const int next_node = get<0>(pq.top());
        const ll temp_cost = get<1>(pq.top());
        pq.pop();
        if (next_node == goal) return temp_cost;
        finished[next_node] = true;
        for (auto& node : edges[next_node]){
            if (finished[node.first]) continue;
            const ll next_cost = temp_cost + node.second;
            pq.emplace(node.first, next_cost);
        }
    }
    return -1;
}

int main()
{
    scanInt(N);
    // vector<vector<ll>> A(N, vector<ll>(N, 0));
    using T = tuple<ll, int, int>;
    vector<T> E;
    loop(i, N){
        loop(j, N){
            scanLLInt(Aij);
            // A[i][j] = Aij;
            if (i < j){
                E.emplace_back(Aij, i, j);
            }
        }
    }
    sort(E.begin(), E.end(), [](T& l, T& r){return get<0>(l) < get<0>(r);});
    vector<unordered_map<int, ll>> edges(N);
    ll result = 0;
    for (auto& e : E){
        ll len = get<0>(e);
        int x = get<1>(e);
        int y = get<2>(e);
        // printf("%d -- %d : %lld\n", x, y, len);
        ll temp = dijkstra(edges, x, y);
        // printf("temp: %lld\n", temp);
        if (temp == -1 || len < temp){
            edges[x].emplace(y, len);
            edges[y].emplace(x, len);
            result += len;
        }else if (len == temp){
            // pass
        }else{ // temp < len
            puts("-1");
            // loop(i, N){
            //     for (auto& e : edges[i]){
            //         printf("%d %d %lld\n", i, e.first, e.second);
            //     }
            // }
            return 0;
        }
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



#define int long long
void test_case() {
	int n, x, t; cin>>n>>x>>t;
	int tmp = (int) ceil((double) n / (double) x);
	cout<<t * tmp<<endl;
}

signed main() {
	IOS
	int i=1, T=1;
	//cin>>T;
	while(T--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


Measured memory_bytes: 3716
n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
count=[1]*(n+1)
flag=[False]*(n+1)
flag[1]=True
for a,b in arr:
  count[b]+=1
  count[a]-=1
  if flag[a]==True:
    flag[b]=True
  if count[a]==0:
    flag[a]=False
print(flag.count(True))

Measured memory_bytes: 30884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	vector<int> hist(128);
	for(int i = 0; i < n; ++i){ ++hist[s[i]]; }
	int answer = 0;
	for(int c = '0'; c <= '9'; ++c){
		while(hist[c] > 0){
			int len = 1;
			while(hist[c + len] > 0){ ++len; }
			answer += min(3, len);
			for(int i = 0; i < len; ++i){ --hist[c + i]; }
		}
	}
	for(int c = 'a'; c <= 'z'; ++c){
		while(hist[c] > 0){
			int len = 1;
			while(hist[c + len] > 0){ ++len; }
			answer += min(3, len);
			for(int i = 0; i < len; ++i){ --hist[c + i]; }
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n,a[100];
  	cin>>n;
  	for(int i=0;i<n;i++)
      	cin>>a[i];
  	sort(a,a+n);
  	int x=1,y=a[0];
  	for(int i=1;i<n;i++)
      	if(a[i]!=y)
          	x++,y=a[i];
  cout<<x<<endl;       
}

Measured memory_bytes: 256
N = int(input())
num = 0
A = len(str(N))
if A == 1:
  print(N)
  exit()
elif A == 2:
  print(9)
  exit()
elif A == 3:
  print(9+N-99)
  exit()
elif A == 4:
  print(909)
  exit()
elif A == 5:
  print(909+N-9999)
  exit()
elif A == 6:
  print(90909)
  exit()

  
    

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    i64 cnt = 0;
    multiset<i64> ms;
    REP(i, N) {
        if (ms.empty()) {
            ms.insert(A[i]);
            cnt++;
            continue;
        }

        auto lb = ms.lower_bound(A[i]);
        if (lb == ms.begin()) {
            ms.insert(A[i]);
            cnt++;
        } else {
            lb--;
            ms.erase(lb);
            ms.insert(A[i]);
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 5760
class Node():
    def __init__(self, value):
        self.value = value
        self.deep = -1
        self.parent = None
        self.left = None
        self.right = None
        self.childs = []

def setdeep(tree, i, deep):
    tree[i].deep = deep
    for child in tree[i].childs:
        tree[child].parent = i
        if child < len(tree):
            setdeep(tree, child, deep + 1)

if __name__ == '__main__':
    n = int(input())
    tree = {}

    for _ in range(n):
        datas = [int(num) for num in input().split(' ')]
        nodeid = datas[0]
        if nodeid not in tree.keys():
            tree[nodeid] = Node(nodeid)

        if datas[1] > 0:
            tree[nodeid].childs = datas[2:]
            for child in tree[nodeid].childs:
                if child not in tree.keys():
                    tree[child] = Node(child)
                tree[child].parent = nodeid


    for i in range(n):
        curnode = tree[i]
        if curnode.parent is None:
            # this is root
            setdeep(tree, i, 0)
            break
            
    
    for i in range(n):
        curnode = tree[i]
        if len(curnode.childs) == 0:
            nodetype = 'leaf'
        else:
            nodetype = 'internal node'
        if curnode.parent == None:
            nodetype = 'root'
            parent = -1
        else:
            parent = curnode.parent
        
        childs = curnode.childs
        print('node %d: parent = %d, depth = %d, %s, %s' % (i, parent,curnode.deep, nodetype, childs) )


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
int a[N+2];
int b[N+2];
int v[N+2];

int32_t  main(){
	IOS;
  memset(a,0,sizeof(a));
  memset(b,0,sizeof(b));
  int n;cin>>n;
  
  fori(i,n)cin>>v[i];
  if(n==2){
    cout<<max(v[1],v[2])<<endl;
    return 0;
  }
  a[1]=v[1];
  for(int i=2;i<=n;++i){
    a[i]=__gcd(v[i],a[i-1]);
  }
  b[n]=v[n];
  for(int i=n;i>=1;--i){
    b[i]=__gcd(v[i],b[i+1]);
  }
  int ans=0;
  for(int i=2;i<n;++i){
    ans=max(ans,__gcd(a[i-1],b[i+1]));    
  }
  ans=max(ans,b[2]);
  ans=max(ans,a[n-1]);
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 1408
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n, k;
        cin >> n >> k;
        ll ans = k;
        for (int i = 1; i < n; ++i) {
            ans *= (k - 1);
        }
        cout << ans << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

using namespace std;

int main(){
	
	int a,b,c;
	
	cin >> a >> b >> c;
	
	if(a==1 && b==0 && c==0){
		printf("Close\n"); 
	}else if(a==0 && b==1 && c==0){
		printf("Close\n"); 
	}else if(a==1 && b==1 && c==0){
		printf("Open\n");
	}else if(a==0 && b==0 && c==1){
		printf("Open\n");
	}else printf("Close\n"); 
	
	return 0;
}

Measured memory_bytes: 1116
#include <stdio.h>
#define N 3

int main(){
  int i, j;
  int c[N][N];
  int sum = 0;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      scanf("%d", &c[i][j]);
    }
  }

  if(c[0][0] == 2 || c[0][0] == 4){
    sum = sum + 1;
  }else if(c[0][0] == 3 || c[0][0] == 5 || c[0][0] == 7){
    sum = sum + 2;
  }else if(c[0][0] == 6 || c[0][0] == 8){
    sum = sum + 7;
  }
  if(c[0][1] == 1 || c[0][1] == 3 || c[0][1] == 5){
    sum = sum + 1;
  }else if(c[0][1] == 4 || c[0][1] == 6 || c[0][1] == 8){
    sum = sum + 2;
  }else if(c[0][1] == 7){
    sum = sum + 5;
  }
  if(c[0][2] == 2 || c[0][2] == 6){
    sum = sum + 1;
  }else if(c[0][2] == 1 || c[0][2] == 5){
    sum = sum + 2;
  }else if(c[0][2] == 4 || c[0][2] == 8){
    sum = sum + 3;
    if(c[1][1] == 1){
      sum = sum + 6;
    }
  }else if(c[0][2] == 7){
    sum = sum + 8;
  }
  if(c[1][0] == 1 || c[1][0] == 5 || c[1][0] == 7){
    sum = sum + 1;
  }else if(c[1][0] == 2 || c[1][0] == 6 || c[1][0] == 8){
    sum = sum + 2;
  }else if(c[1][0] == 3){
    sum = sum + 3;
  }
  if(c[1][1] == 2 || c[1][1] == 4 || c[1][1] == 6 || c[1][1] == 8){
    sum = sum + 1;
  }else if(c[1][1] == 1 || c[1][1] == 3 || c[1][1] == 7){
    sum = sum + 2;
  }
  if(c[1][2] == 3 || c[1][2] == 5){
    sum = sum + 1;
  }else if(c[1][2] == 2 || c[1][2] == 4 || c[1][2] == 8){
    sum = sum + 2;
  }else if(c[1][2] == 1 || c[1][2] == 7){
    sum = sum + 6;
  }
  if(c[2][0] == 4 || c[2][0] == 8){
    sum = sum + 1;
  }else if(c[2][0] == 1 || c[2][0] == 5){
    sum = sum + 2;
  }else if(c[2][0] == 2 || c[2][0] == 6){
    sum = sum + 6;
  }else if(c[2][0] == 3){
    sum = sum + 9;
  }
  if(c[2][1] == 5 || c[2][1] == 7){
    sum = sum + 1;
  }else if(c[2][1] == 2 || c[2][1] == 4 || c[2][1] == 6){
    sum = sum + 2;
  }else if(c[2][1] == 1 || c[2][1] == 3){
    sum = sum + 5;
    if(c[0][0] == 8){
      sum = sum + 3;
    }
  }
  if(c[2][2] == 6 || c[2][2] == 8){
    sum = sum + 1;
  }else if(c[2][2] == 3 || c[2][2] == 5 || c[2][2] == 7){
    sum = sum + 2;
  }else if(c[2][2] == 2 || c[2][2] == 4){
    sum = sum + 4;
    if(c[2][1] == 1){
      sum = sum + 7;
    }
  }else if(c[2][2] == 1){
    sum = sum + 9;
    if(c[2][0] == 3 && c[0][2] == 7){
      sum = sum - 6;
    }
    if(c[0][0] == 8 || c[0][0] == 6){
      sum = sum - 2;
    }
  }

  printf("%d\n", sum);
    
  return 0;
}



Measured memory_bytes: 2084
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
#define clr(a) memset(a,0,sizeof(a))
//--Container
#include<set>
//
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
 
struct eg{int u,v,nx;}gp[50010];int cnt,hd[210],mth[210];bool bd[210];
void psh(int u,int v){++cnt;gp[cnt].u=u,gp[cnt].v=v,gp[cnt].nx=hd[u],hd[u]=cnt;};
 
bool fdp(int v){
    int i;for(i=hd[v];i;i=gp[i].nx)if(!bd[gp[i].v]){
        bd[gp[i].v]=1;
        if(!mth[gp[i].v]||fdp(mth[gp[i].v])){
            mth[gp[i].v]=v;
            return 1;
        }
    }
    return 0;
};
int hgy(int n){
    int rs=0,i;for(clr(mth),i=1;i<=n;++i){
        clr(bd);if(fdp(i))++rs;
    }
    return rs;
};
 
int ar[110],dr[210],cr[2][210],dn,n;
 
bool _ck(int n){
    if(n==1)return 0;int d=sqrt(n),i=2;for(;i<=d;++i)if(!(n%i))return 0;
    return 1;
};
 
bool cl(){
	if(scanf("%d",&n)==-1)return 0;
    int i,j,t,a,b,k;for(i=1;i<=n;scanf("%d",&ar[i++]));sort(ar+1,ar+n+1);n=unique(ar+1,ar+n+1)-ar-1;
    for(dn=1,dr[1]=ar[1],i=2;i<=n;++i){
        if(ar[i]==ar[i-1]+1)continue;
        dr[++dn]=ar[i-1]+1,dr[++dn]=ar[i];
    }
    dr[++dn]=ar[n]+1;
    for(a=b=0,i=1;i<=dn;++i){
        if(dr[i]&1)cr[1][++a]=dr[i];
        else
            cr[0][++b]=dr[i];
    }
    for(cnt=0,clr(hd),i=1;i<=a;++i)for(j=1;j<=b;++j)if(_ck(abs(cr[1][i]-cr[0][j])))
        psh(i,j);
    t=hgy(a);
    printf("%d\n",t+((a-t)/2*2)+((b-t)/2*2)+((a-t)%2*3));
	return 1;
};
 
int main() {
    while(cl());
    return 0;
};

Measured memory_bytes: 384