akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};

typedef vector<set<Edge>> Graph;

int main(){

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k % 2) {
		cout << b - a << endl;
	}
	else
		cout << a - b << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0087
"""
import sys


def eval_rpn(data):
    result = 0
    S = []
    for d in data:
        # print('d = {}'.format(d))
        if d == '+':
            y = S.pop()
            x = S.pop()
            S.append(x+y)
        elif d == '-':
            y = S.pop()
            x = S.pop()
            S.append(x-y)
        elif d == '*':
            y = S.pop()
            x = S.pop()
            S.append(x*y)
        elif d == '/':
            y = S.pop()
            x = S.pop()
            S.append(x/y)
        else:
            S.append(int(d))
    return S[0]


def main(args):
    for line in sys.stdin:
        data = line.strip().split()
        result = eval_rpn(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7676
n = int(input())
a = list(map(int, input().split()))

# 1番目の値を正とする場合
ans1 = 0
sum = 0
flg = 1
for i in range(n):
    sum += a[i]
    if flg == 1:
        if sum < 0:
            flg = -1
        else:
            ans1 += sum + 1
            sum = -1
            flg = -1
    else:
        if sum > 0:
            flg = 1
        else:
            ans1 += (-sum) + 1
            sum = 1
            flg = 1

# 1番目の値を負とする場合
ans2 = 0
sum = 0
flg = -1
for i in range(n):
    sum += a[i]
    if flg == 1:
        if sum < 0:
            flg = -1
        else:
            ans2 += sum + 1
            sum = -1
            flg = -1
    else:
        if sum > 0:
            flg = 1
        else:
            ans2 += (-sum) + 1
            sum = 1
            flg = 1

print(min(ans1, ans2))


Measured memory_bytes: 14468
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r,g,b;
  while(cin >> r >> g >> b){
    TSTART();
    string ans;
    int value = g*10 + b;
    if(value % 4 == 0)ans = "YES";
    else ans = "NO";
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = min(A, B); i > 0; i--) {
    if (A % i == 0 && B % i == 0)
      K--;
    if (K == 0) {
      cout << i << endl;
      return 0;
    }
  }
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    num--;
    a[i] = num;
  }
  
  int now = 0;
  int cnt = 0;
  for(;;) {
    if(now == 1) {
      cout << cnt << endl;
      return 0;
    }
    if(cnt >= n) {
      cout << -1 << endl;
      return 0;
    }
    now = a[now];
    cnt++;
  }
}

Measured memory_bytes: 3708
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int cnt[55][55];
vpii mp[55];

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    int W, H, T; cin >> W >> H >> T;

    int p; cin >> p;

    rep(i, p) {
        int x, y, t; cin >> x >> y >> t;
        mp[t].PB(pii(y, x));
    }

    rep(i, H) rep(j, W) {
        int s; cin >> s;
        cnt[i][j] = s;
    }

    int ans = 0;

    rep(i, T) {
        rep(j, mp[i].size()) {
            pii p = mp[i][j];

            if (cnt[p.fst][p.scd]) {
                cnt[p.fst][p.scd] += 1;
            }
        }
    }
    rep(i, H) rep(j, W) if (cnt[i][j] > 0) ans += cnt[i][j] - 1;

    cout << ans << endl;
}

Measured memory_bytes: 1208
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func solve(io *Io) {
	n := io.NextInt()
	c := io.NextInt()
	d := make([][]int , c)
	for i := range(d) {
		d[i] = make([]int, c)
		for j := range(d[i]) {
			d[i][j] = io.NextInt()
		}
	}

	t := make([][]int, n)
	for i := range(t) {
		t[i] = make([]int, n)
		for j := range(t[i]) {
			t[i][j] = io.NextInt()
		}
	}

	tbl := [3][]int{}
	for i := 0; i < 3; i++ {
		tbl[i] = make([]int, c)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			tbl[(i+j)%3][t[i][j] - 1]++
		}
	}

	costs := [3][]int {}
	for i := 0; i < 3; i++ {
		costs[i] = make([]int, c)
	}

	for i := range(tbl) {
		for useColor := range(tbl[i]) {
			for j, cnt := range(tbl[i]) {
				costs[i][useColor] += d[j][useColor] * cnt;
			}
		}
	}

	ans := int(1e9)
	for i := 0; i < c; i++ {
		for j := 0; j < c; j++ {
			for k := 0; k < c; k++ {
				if i == j || i == k || j == k {
					continue
				}
				cur := costs[0][i] + costs[1][j] + costs[2][k]
				if cur < ans {
					ans = cur
				}
			}
		}
	}

	io.PrintLn(ans)

}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}

Measured memory_bytes: 4864
#include <iostream>
#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>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int h, w, d;
    cin >> h >> w >> d;
    pair<int, int> field[100000];
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int in;
            cin >> in;
            pair<int, int> in2;
            in2.first = i;
            in2.second = j;
            field[in] = in2;
        }
    }
    int score[100000];
    for(int i = 1;  i <= h * w; i++){
        if(i <= d){
            score[i] = 0;
            continue;
        }
        score[i] = score[i - d] + abs(field[i].first - field[i - d].first) + abs(field[i].second - field[i - d].second);
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++){
        int l, r;
        cin >> l >> r;
        cout << score[r] - score[l] << endl;
    }


    return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,A,B,i,j,k;

int main()
{
  cin>>N>>A>>B;
  
  i=N/(A+B);
  j=i*A;
  k=N-i*(A+B);
  if(k>A)
  {
    j+=A;
    cout <<j;
    return 0;
  }
  else
  {
    j+=k;
    cout <<j;
    return 0;
  }
  
  
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N;
	cin >> N;
	pairs(C)
		fx(N) {
		int a, b;
		cin >> a >> b;
		pb(C,make_pair(b,a))
	}
	
	sorts(C)
		reverses(C)
		ll Time = C.at(0).first;
	bool flag = true;
	fx(N - 1) {
		Time -= C.at(x).second;
		if (Time>C.at(x+1).first) {
			Time = C.at(x + 1).first;
		}
		//ce(Time)
	}
	Time -= C.at(N-1).second;
	if (Time<0) {
		flag = false;
	}
	if (flag) {
		ce("Yes")
	}
	else {
		ce("No")
	}

    return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  int K = nextLong();
  vector<int> a(N);
  REP(i, N) a[i] = nextLong();
  sort(ALL(a));
  ll ans = accumulate(a.begin(), a.begin() + K, 0LL);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#define neko 300010
#define chkmin(a,b) ((a)<(b)?(a):(b))
#define chkmax(a,b) ((a)>(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))
long long n,ans,now=2e15,x,y;
bool flag;
int main()
{
	scanf("%lld",&n);
	f(i,1,n)
	{
		scanf("%lld%lld",&x,&y);
		ans+=x;if(x>y)now=chkmin(now,y);
		if(x!=y)flag=1;
	}
	if(!flag)printf("0\n");
	else printf("%lld\n",ans-now);
	return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    println((n-1)/(k-1) + if ((n-1)%(k-1) == 0) 0 else 1)
}

Measured memory_bytes: 47640
sum=0
min=1000000
max=-1000000
n=int(input())
a=list(map(int,input().split()))
for i in range(0,n):
    if a[i]<min:
        min=a[i]
    if a[i]>max:
        max=a[i]
    sum+=a[i]
print(str(min)+" "+str(max)+" "+str(sum))


Measured memory_bytes: 6588
#include <iostream>

using namespace std;

int main(){
    string S;
    cin>>S;
    bool ans=false;
    for(int i=0;i<S.size();i++){
        if(S[i]=='7'){
            ans=true;
        }
    }
    if(ans){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

}

Measured memory_bytes: 3128
n, *v = map(int, open(0).read().split())
from collections import*
d, e = (Counter(i).most_common()+[(0,0)] for i in (v[0::2], v[1::2]))
print(n-d[0][1]-e[0][1] if d[0] != e[0] else n-max(d[0][1]+e[1][1], d[1][1]+e[0][1]))


Measured memory_bytes: 92284
#include <stdio.h>
int main(void){
    
    int n;
    int a;
    int x=0,y=0,z=0;
    scanf("%d",&n);
    for(;~scanf("%d",&a);){
        if(a%4==0){
            z++;
        }else if(a%2==0){
            y++;
        }else{
            z--;
        }
    }
    
    if(y&&0<=z||!y && -1<=z){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

void solve() {
    int T;
    cin >> T;
    REP(t, T) {
        ll N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }
    // cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (a > b) {
			int box = a;
			a = b;
			b = box;
		}
		if (b > c) {
			int box = b;
			b = c;
			c = box;
		}
		if (a > b) {
			int box = b;
			b = a;
			a = box;
		}
		System.out.println(a + " " + b + " " + c);
	}
}


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


int main(){

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

	int command,digit;

	bitset<64> B(0);

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

		scanf("%d",&command);

		switch(command){
		case 0:
			scanf("%d",&digit);
			printf("%d\n",B.test(digit));
			break;
		case 1:
			scanf("%d",&digit);
			B.set(digit);
			break;
		case 2:
			scanf("%d",&digit);
			B.reset(digit);
			break;
		case 3:
			scanf("%d",&digit);
			B.flip(digit);
			break;
		case 4:
			if(B.all()){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 5:
			if(B.any()){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 6:
			if(B.none()){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 7:
			printf("%d\n",B.count());
			break;
		case 8:
			printf("%llu\n",B.to_ulong());
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 3216
n=gets.to_i
s=gets.split.map &:to_i
wa=s[0]
max=0
sum=0
for i in 1..n-1
  if s[i]<=wa
    sum+=1
    max=[sum,max].max
  else
    sum=0
  end
  wa=s[i]
end
puts max


Measured memory_bytes: 20824
#include<stdio.h>
#define MAX 100000
#define NIL -1

struct Node{
  int parent;
  int L;
  int R;
};

struct Node T[MAX];

int getDepth(int K){
  int depth=0;
  
  for(depth = 0; T[K].parent != NIL; depth++){
    K=T[K].parent;
  }
  return depth; 
}

int main(void){
  int i,j,n;
  int num,deg,child,L=0;
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    T[i].parent=NIL;
    T[i].L=NIL;
    T[i].R=NIL;
  }
  
  for(i=0; i<n; i++){
    scanf("%d%d",&num,&deg);
    
    for(j=0; j<deg; j++){
      scanf("%d",&child);
      if(j==0) T[num].L = child;
      else T[L].R = child;
      L = child;
      T[child].parent = num;
    }
  }
  
  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d",i,T[i].parent,getDepth(i));
    
    if(getDepth(i)==0){
      printf(", root, [");
    }
    else if(T[i].L==NIL){
      printf(", leaf, [");
    }
    else{
      printf(", internal node, [");
    }
    
    j = T[i].L;
    
    while(j!=NIL){
      printf("%d",j);
      j = T[j].R;
      if(j!=NIL){
	printf(", ");
      }
    }
    
    printf("]\n");
  }
  return 0;
}

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

const int mxN = 1e5 + 5;
int color[mxN], red[mxN], green[mxN];

int main() {
	int n, m, r, g, c;
	cin >> n >> m >> r >> g >> c;
	for(int i = 0; i < r; ++i)
		cin >> red[i];
	for(int i = 0; i < g; ++i)
		cin >> green[i];
	for(int i = 0; i < c; ++i)
		cin >> color[i];
	sort(red, red + r, greater<int>());
	sort(green, green + g, greater<int>());
	sort(color, color + c, greater<int>());
	long long ans = 0;
	priority_queue<int> pq;
	vector<int> v;
	for(int i = 0; i < n; ++i)
		v.push_back(red[i]);
	for(int i = 0; i < m; ++i)
		v.push_back(green[i]);
	for(int i = 0; i < c; ++i)
		v.push_back(color[i]);
	sort(v.begin(), v.end(), greater<int>());
	for(int i = 0; i < n + m; ++i)
		ans += v[i];
	cout << ans;
}


Measured memory_bytes: 6536
import scala.io.StdIn.readLine
import scala.collection.mutable.Queue

object Main extends App {
  val l = readLine.split(" ").map(_.toInt)
  val q = new Queue[(String,Int)]

  for(i<-0 until l(0)) {
    val m = readLine.split(" ")
    q += ((m(0), m(1).toInt))
  }

  def rrobin(total:Int):Unit = {
    if(q.isEmpty) return
    else {
      val (p,t) = q.dequeue
      val newTotal =
        if(t>l(1)) {
          q += ((p,t-l(1)))
          total + l(1)
        } else {
          println(p + " " + (t+total))
          total + t
        }
      rrobin(newTotal)
    }
  }

  rrobin(0)
}

Measured memory_bytes: 105700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0034
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            int X = int.Parse(str.Split(' ')[0]);

            int Y = int.Parse(str.Split(' ')[1]);

            for (int i = 0; i <= X; i++)
            {
                if (Y == (2 * i + 4 * (X - i)))
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, V;
    ll B, W;
    ll T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    ll temp = T * W + abs(A - B) - T * V;
    if(temp <= 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

//---- Sorting Three Numbers
int main(){
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if(b < a)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    if (c<a)
    {
        tmp = b;
        b = a;
        a = c;
        c = tmp;
    }
    else if(b<c){}
    else{
        tmp = b;
        b = c;
        c = tmp;
    }
    cout << a << " " << b << " " << c << endl;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      std::vector<Int> xs(n); scan(xs);
      Int res = (1LL<<53);
      for(Int i = 0; i < n; ++i) {
         Int t = 0;
         while( xs[i] % 2 == 0 ) {
            xs[i] /= 2;
            t += 1;
         }
         res = std::min(res, t);
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
from collections import deque


n = int(input())
a = list(map(int, input().split()))
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2:
    b.reverse()
    
print(*b)

Measured memory_bytes: 107152
N, K = map(int, input().split())
dA = [input().split() for _ in range(2 * K)]

Aset = set()
Alist = list()
ans = 0

for count in range(2 * K):
    if count % 2 != 0:
        Alist.extend(dA[count])

Aset = set(Alist)
ans = N - len(Aset)
print(ans)


Measured memory_bytes: 9476
import java.util.*;
//import java.io.*;
//import java.util.stream.IntStream;

public class Main{
    static int minR = Integer.MAX_VALUE;
    static int maxL = 0;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        double ans = 0;
        
        for(double i=1;i<=n;i++){
            if(k/i>=1){
                int need = (int)Math.ceil(Math.log(k/i)/Math.log(2));
                ans += 1.0/n * Math.pow(0.5, need);
            }else{
                ans += 1.0/n;
            }
        }

        System.out.println(ans);

    }
}

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

using namespace std;

int main(){
    unsigned long long N,A,B;
    cin >> N >> A >> B;
    if((B-A)%2==0){
        cout << (B-A)/2 << endl;
    }else{
        cout << 1+min(N-B,A-1)+(B-A-1)/2 << endl;
    }
}

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

int prime[50010];

int isprime(int n) {
  if (n <= 1) return 0;

  for (int i = 2; i*i <= n; ++i)
    if (n % i == 0) return 0;
  return 1;
}


int main()
{
  fill(prime, prime+50010, -1);
  for (int i = 0; i < 50010; ++i) {
    if (prime[i] == -1) {
      prime[i] = isprime(i);
      if (prime[i] == 1 && i < 225)
        for (int j = i*i; j < 50010; j *= i)
          prime[j] = 0;
    }
  }

  int n;
  while (cin >> n, n) {
    int count = 0;
    for (int i = 2; i <= n/2; ++i)
      if (prime[i] && prime[n - i]) count++;
    cout << count << endl;
  }
}

Measured memory_bytes: 1356
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#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())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;


int main(){
	int sum;
	int yen[]={10,50,100,500};
	bool f=false;
	while(cin>>sum){
		if(sum==0)break;
		if(f)cout<<endl;
		int ha[4];
		int ss=0;
		REP(i,4){
			cin>>ha[i];
			ss+=ha[i];
		}
		int mini=100000;
		vector<PII>res;
		REP(i1,ha[0]+1)REP(i2,ha[1]+1)REP(i3,ha[2]+1)REP(i4,ha[3]+1){
			int tmp=i1*10+i2*50+i3*100+i4*500;
			if(tmp<sum)continue;
			int d=tmp-sum;
			int cnt=ss-(i1+i2+i3+i4);
			if(d>=500){
				if(i4!=0)continue;
				cnt+=d/500;
				d%=500;
			}
			if(d>=100){
				if(i3!=0)continue;
				cnt+=d/100;
				d%=100;
			}
			if(d>=50){
				if(i2!=0)continue;
				cnt+=d/50;
				d%=50;
			}
			if(d>=10&&i1!=0)continue;
			cnt+=d/10;
			if(cnt<mini){
				mini=cnt;
				res.clear();
				res.PB(MP(10,i1));
				res.PB(MP(50,i2));
				res.PB(MP(100,i3));
				res.PB(MP(500,i4));
			}
		}
		REP(i,4)if(res[i].second!=0)cout<<res[i].first<<" "<<res[i].second<<endl;
		f=true;
	}
	return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  if(A[0] != 0) {
    std::cout << "0" << '\n';
    return 0;
  }

  std::vector<int> x(N), y(N), z(N);
  x[0] = 1;
  rep(i, N - 1) {
    x[i + 1] = x[i];
    y[i + 1] = y[i];
    z[i + 1] = z[i];
    if(A[i + 1] == x[i]) {
      x[i + 1] = x[i] + 1;
    } else if (A[i + 1] == y[i]) {
      y[i + 1] = y[i] + 1;
    } else {
      z[i + 1] = z[i] + 1;
    }
  }

  ll ans = 3;
  rep(i, N - 1) {
    int T = 0;
    if(A[i + 1] == x[i]) ++T;
    if(A[i + 1] == y[i]) ++T;
    if(A[i + 1] == z[i]) ++T;
    ans *= T;
    ans %= MOD;
  }
  std::cout << ans << '\n';

}


Measured memory_bytes: 1792
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    int A, B; cin >> A >> B;
    cout << A*B / 2;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	m := map[int]int{}
	fmt.Scan(&N)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		m[a[i]] = 0
	}

	yesOrNo := true
	for i := 0; i < N; i++ {
		m[a[i]]++
		if m[a[i]] > 1 {
			yesOrNo = false
		}
	}

	if yesOrNo {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 17024
#include <iostream>
using namespace std;
int i=1,x,n;

void checkNum(void);
void include3(void);
void endCheckNum(void);

void checkNum(void){
	x=i;
  if(x%3 == 0){
		cout<<" "<<i;
		endCheckNum();
  }else{
		include3();
	}
}

void include3(void){
	if(x%10 == 3){
		cout<<" "<<i;
		endCheckNum();
	}else{
		x/=10;
		if(x>0){
			include3();
		}else{
			endCheckNum();
		}
	}
}

void endCheckNum(void){
	if(++i<=n){
		checkNum();
	}
}

int main(){

	cin>>n;
	checkNum();
  cout<<endl;

	return 0;
}

Measured memory_bytes: 3076
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = T
end_time = t[0]+T
for i in range(1, N):
    if end_time >= t[i]:
        ans += ((t[i]+T)-end_time)
    else:
        ans += T
    end_time = t[i]+T

print(ans)


Measured memory_bytes: 25200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d,k=0,l;
    cin>>n>>d>>l;
    f(i,1,n)
     { int a;
       cin>>a;
       k+=(d+a-1)/a;
    }
    cout<<k+l;
}   
    
    
     

     
   





Measured memory_bytes: 3572
st=raw_input()
s=list(st)
if int(s[2])>int(s[1]):
  s[1]=str(int(s[1])+1)
  s[2]=s[1]
else:
  s[2]=s[1]
if int(s[1])>int(s[0]):
  s[0]=str(int(s[0])+1)
  s[1]=s[0]
  s[2]=s[1]
else:
  s[1]=s[0]
  s[2]=s[1]
unko=""
for i in s:
  unko+=i
print(unko)

Measured memory_bytes: 2692
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()
#define ubound(x,c) upper_bound(all(x),(c))-(x).begin()

int main(){
	int N; string S; cin>>N>>S; S = "-" + S;
	vector<int> ix[10];
	rp(i, 1, N+1) ix[S[i]-'0'].push_back(i);
	int ans = 0;
	rp(a, 0, 10){
		int p = ubound(ix[a], 0); if(p >= ix[a].size()) continue;
		rp(b, 0, 10){
			int q = ubound(ix[b], ix[a][p]); if(q >= ix[b].size()) continue;
			rp(c, 0, 10) if(ubound(ix[c], ix[b][q]) < ix[c].size()) ans++;
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
 
int main() {
  int64_t res = 1;
  int64_t MAX = 1000000000000000000;
  int N;
  cin >> N;
 
  vector<int64_t> list(N);
  for (int i = 0; i < N; i++) {
    int64_t n;
    cin >> n;
    
    if (n == 0) {
      res = 0;
      break;
    }
    
    list.at(i) = n;
  }
  
  if (res == 0) {
    cout << res << endl;
    return 0;
  }
  
  for (int i = 0; i < N; i++) {
    int64_t n = list.at(i);

    if (n > MAX / res) {
      res = -1LL;
      break;
    }

    res *= n;
  }

  cout << res << endl;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#include<atcoder/all>

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;
using namespace atcoder;

/////////////////////////////////////////////////////


ll N, Q;

ll i, j, k;
int main(){
    //ios::sync_with_stdio(true);
	//cin.tie(nullptr);
 
    cin >> N >> Q;

    dsu d(N+3);
    while(Q--){
        ll t, u, v;
        cin >> t >> u >> v;
        if(t==0){
            d.merge(u, v);
        }else{
            cout << (d.same(u, v)?1:0) << endl;
        }
    }

    return 0;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  for(int i=4;i<350;++i){
    string s=to_string(i*i);
    if(s==a+b){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import math
import bisect


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


def cal(num):
    D = 1 + 8 * num
    return (-1 + math.sqrt(D))/2


N = int(input())
n_f = factorization(N)
if N == 1:
    print(0)
    exit()
ans = 0
for i in n_f:
    ans += math.floor(cal(i[1]))
print(ans)

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

int min( int a, int b )
{
    if( a < b )
        return a;
    else
        return b;
}

int main()
{
    string s;

    cin >> s;

    int a = 0, z = 0;
    for( int i = 0; i < s.size(); i++ )
    {
        if( s[i] == 'A' && a == z )
            a++;
        if( s[i] == 'Z' && a > z )
            z++;
    }

    int m = min( a, z );

    for( int i = 0; i < m; i++ )
        cout << "AZ";
    if( m == 0 )
        cout << -1;
    cout << endl;

    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

typedef long long ll;

const ll month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 100};

ll gregoriano2ll(vector<ll> v) {
	ll res = 0;
	int leap = 0;
	res += (v[0]) * 365;
	res += (v[0]-1) / 4 - (v[0]-1) / 100 + (v[0]-1) / 400;
	res += 1;
	for(int i = 0; i < v[1]-1; i++) {
		res += month[i];
		if(i == 1 && v[0] % 4 == 0 && (v[0] % 100 != 0 || v[0] % 400 == 0))
			res += 1;
	}
	res += v[2]-1;
	return res;
}

ll maya2ll(vector<ll> v) {
	ll res = 0;
	res = v[0];
	res = res * 20 + v[1];
	res = res * 20 + v[2];
	res = res * 18 + v[3];
	res = res * 20 + v[4];
	vector<ll> tmp;
	tmp.push_back(2012);
	tmp.push_back(12);
	tmp.push_back(21);
	res += gregoriano2ll(tmp);
	return res;
}

vector<ll> ll2maya(ll a) {
	vector<ll> res;
	vector<ll> tmp;
	tmp.push_back(2012);
	tmp.push_back(12);
	tmp.push_back(21);
	a -= gregoriano2ll(tmp);
	a %= 13*20*20*18*20ll;
	res.push_back(a/(20*20*18*20ll));
	a %= 20*20*18*20ll;
	res.push_back(a/(20*18*20ll));
	a %= 20*18*20ll;
	res.push_back(a/(18*20ll));
	a %= 18*20ll;
	res.push_back(a/(20ll));
	a %= 20ll;
	res.push_back(a);
	return res;
}

vector<ll> ll2gregoriano(ll a) {
	vector<ll> res;
	int y;
	y = (a / (365*400+97)) * 400;
	a %= (365*400+97);
	while(1) {
		if(y % 4 == 0 && (y % 100 != 0 || (y % 400 == 0))) {
			if(a < 366)
				break;
			a -= 366;
		}
		else {
			if(a < 365)
				break;
			a -= 365;
		}
		y++;
	}
	res.push_back(y);
	int m;
	int leap = (y % 4 == 0 && (y % 100 != 0 || (y % 400 == 0)));
	for(m = 0; (month[m] + (m == 1 ? leap : 0)) <= a; m++) {
		a -= month[m] + (m == 1 ? leap : 0);
	}
	res.push_back(m+1);
	res.push_back(a+1);
	return res;
}

int main() {
	string s;
	while(cin >> s, s != "#") {
		vector<ll> tmp, res;
		int a;
		stringstream sstr(s);
		while(sstr >> a) {
			tmp.push_back(a);
			sstr.ignore();
		}
		if(tmp.size() == 3) {
			res = ll2maya(gregoriano2ll(tmp));
		}
		else {
			res = ll2gregoriano(maya2ll(tmp));
		}
		cout << res[0];
		for(int i = 1; i < res.size(); i++)
			cout << "." << res[i];
		cout << endl;
	}
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, i;
	scanf("%lld", &N);
	int *L = (int *)malloc(sizeof(int) * (N + 1));
	L[0] = 2;
	L[1] = 1;
	for(i = 2; i <= N; i++){
		L[i] = L[i - 1] + L[i - 2];
	}
	printf("%lld\n", L[N]);
	return 0;
}

Measured memory_bytes: 128
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, m]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    if (m == 0) {
      return `${n == 1 ? 0 : n == 2 ? 10 : 100}`;
    }
    const map = {};
    for (let i = 0; i < m; i++) {
      const [s, c]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
      if ((s == 1 && c == 0 && n != 1) || (map[s] != undefined && map[s] != c)) {
        return `${-1}`;
      }
      map[s] = c;
    }
    if (n == 1) {
      return `${map[1]}`;
    }
    let result = "";
    for (let i = 1; i <= n; i++) {
      const c = map[i];
      if (c == undefined) {
        result = result + (i == 1 ? "1" : "0");
      } else {
        result = result + c;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int N = (int)S.size();
    int M = (int)T.size();
    int ans = 1 << 30;
    rep(i, 0, N - M + 1) {
        int now_ans = 0;
        rep(j, 0, M) {
            if (S[i + j] != T[j]) {
                ++now_ans;
            }
        }
        chmin(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

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

int n,mx;
string s;
map<string,int> mp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
        mx=max(mx,mp[s]);
    }
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
        if(it->second==mx)cout<<it->first<<'\n';
    }


    return 0;
}

Measured memory_bytes: 23808
#include <vector>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
#ifdef _WIN32
inline unsigned int __builtin_clz(unsigned int x) {
	unsigned long r;
	_BitScanReverse(&r, x);
	return 31 - r;
}
#endif
class SparseTable {
	vector<vector<long long> > st;
public:
	void init(vector<long long> v) {
		int b = 0;
		for (; (1 << b) <= v.size(); b++);
		st.assign(b, vector<long long>(1 << b));
		for (int i = 0; i < v.size(); i++) st[0][i] = v[i];
		for (int i = 1; i < b; i++) {
			for (int j = 0; j + (1 << i) <= (1 << b); j++) {
				st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
			}
		}
	}
	int query(int l, int r) {
		assert(l < r);
		int b = 32 - __builtin_clz(r - l) - 1;
		return min(st[b][l], st[b][r - (1 << b)]);
	}
	SparseTable() {}
	SparseTable(vector<long long> v) { init(v); }
};
int N, X;
int main() {
	cin >> N >> X;
	vector<long long> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	SparseTable st(a);
	long long ret = (1LL << 61);
	for (int i = 0; i < N; i++) {
		long long sum = 0;
		for (int j = 0; j < N; j++) {
			int l = j - i;
			if (l >= 0) sum += st.query(l, j + 1);
			else sum += min(st.query(0, j + 1), st.query(l + N, N));
		}
		sum += 1LL * i * X;
		ret = min(ret, sum);
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

typedef long long int lo;
typedef pair<int,int> PII;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR for(int i=1;i<=  n;i++)
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mid (start+end)/2

const lo mod = 1000000007;
const lo li = 1000005;
const lo inf = 1000000000;
const lo MAX = 1000000000000000000;
const lo MIN = -1000000000000000000;
const lo LOG = 30;

lo n,m,cev,vis[li];

int main(){
	scanf("%lld",&n);
	while(n>1){
		vis[n]=1;
		//~ cout<<n<<endl;
		if(n%2==0) n/=2;
		else if(n%2==1) n=n*3+1;
		cev++;
	}
	if(vis[4]==0) cev++;
	if(vis[2]==0) cev++;
	//~ if(vis[2]==0) cev++;
	printf("%lld",cev+2);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int input() {
	int r;
	scanf("%lld", &r);
	return r;
}
int a[9][9];
void solve() {
	for1(i, 5)for1(j, 5) {
		cin >> a[i][j];
		a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
	}
	int r = 0;
	for1(i1, 5)for0(i2, i1)for1(j1, 5)for0(j2, j1) {
		int s = (i1 - i2) * (j1 - j2);
		if (s == a[i1][j1] - a[i1][j2] - a[i2][j1] + a[i2][j2])r = max(r, s);
	}
	printf("%d\n", r);
}
signed main() {
	int q = input(); while (q--)solve();
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> I(10,-1);
    rep(i,10){
        int index = 0;
        while(index < N){
            if(i == S[index] - '0'){
                I[i] = index;
                break;
            }
            index++;
        }
    }
    int res=0;
    rep(i,10){
        int i1 = I[i];
        if(i1 < 0 || N-2 <= i1) continue;
        rep(j,10){
            if(I[j] < 0) continue;
            int i2 = i1+1;
            bool flag2 = false;
            while(i2<N){
                if(S[i2] - '0' == j){
                    flag2 = true;
                    break;
                }
                i2++;
            }
            if(!flag2) continue;
            rep(k,10){
                if(I[k] < 0) continue;
                int i3 = i2+1;
                bool flag3 = false;
                while(i3<N){
                    if(S[i3] - '0' == k){
                        flag3 = true;
                        break;
                    }
                    i3++;
                }
                if(!flag3) continue;
                res++;
            }
        }
    }
    cout << res << 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;
using P = pair<int,int>;

int main(){
  string n;
  bool flag=false;
  cin >> n;
  rep(i,3)if(n[i]=='7')flag=true;
  if(flag==true)cout << "Yes"<< endl;
  else cout << "No"<< endl;
  return 0;
}


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

using namespace std;

#define int long long

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    long long n;

    cin >> n;

    vector<pair<long long,int> > divs;

    for(long long i=2; i*i<=n; i++){
        if(n%i == 0){
            int qtd = 0;
            while(n%i == 0){
                qtd++;
                n /= i;
            }
            divs.push_back({i, qtd});
        }
    }

    if(n!=1){
        divs.push_back({n, 1});
    }

    int ans = 0;

    for(int i=0; i<divs.size(); i++){
        for(int j=1; j<=100; j++){
            ans++;
            if(divs[i].second - j > j){
                divs[i].second -= j;
            }
            else break;
        }
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3656