akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){
	ll N,X,M;
	cin >> N >> X >> M;
	ll ans = 0;

	vector<ll> did(M+9,0),sum(M+9,0);
	ll b = M;

	while(N>0){
		if(did[X]){
			ll loop_point = sum[b] - sum[X] + X;
			if(b==X){
				ans += X*N;
				cout << ans << endl;
				return 0;
			}
			ans += loop_point * ( N / (did[b]-did[X]+1) );
			N %= (did[b]-did[X]+1);
		}

		if(N>0){
			did[X] = did[b] + 1;
			N--;
			ans += X;
			sum[X] = sum[b] + X;
			b = X;
			X = X*X%M;
		}

		if(X==0)break;

	}


	cout << ans << endl;

}


Measured memory_bytes: 4824
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
 
const int N = 1e3 + 5;
 
int n, m;
int cost[N];
vector <int> vec(N);
ll dp[N][(1 << 12) + 1][2];
 
ll fun(int ind, int mask, int f) {
  if (ind == m) {
    if (mask == (1 << n) - 1) return 0;
    else return inf;
  }
  if (dp[ind][mask][f] != -1) return dp[ind][mask][f];
  ll ans = inf;
  int v = (mask | vec[ind]);
  if (v > mask) {
    ans = min(ans, cost[ind] + fun(ind + 1, v, 1));
  }
  ans = min(ans, fun(ind + 1, mask, 0));
  return dp[ind][mask][f] = ans;
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    cost[i] = a;
    int mask = 0, v;
    for (int j = 0; j < b; j++) {
      cin >> v;
      v--;
      mask |= (1 << v);
    }
    vec[i] = mask;
  }
  memset(dp, -1, sizeof(dp));
  ll ans = fun(0, 0, 0);
  cout << (ans >= inf? -1: ans) << endl;
 
  return 0;
}

Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
int n,m;
int p[125252],y[125252];
vector<int> o[125252];
int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++)scanf("%d%d",p+i,y+i),p[i]--;
  for(int i=0;i<m;i++)o[p[i]].push_back(y[i]);
  for(int i=0;i<n;i++)sort(o[i].begin(), o[i].end());
  for(int i=0;i<m;i++)printf("%06d%06d\n",p[i]+1,lower_bound(o[p[i]].begin(), o[p[i]].end(),y[i])-o[p[i]].begin()+1);
  return 0;
}

Measured memory_bytes: 8320
#include<cstdio>
#include<cstring>

using namespace std;

char opt[200011];
int main(){
	int sum=0;
	scanf("%s",opt+1);
	int len=strlen(opt+1);
	for(int i=1;i<=len;i++){
		int x=opt[i]-'0';
		sum+=x;sum%=9;
	}
	if(sum) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 1804
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, key, value)
  index = queue.index{|target, _| target >= key}
  return queue[index][1] if index && queue[index][0] == key
  return nil if index && index > 0 && !key.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index && !queue[index][0].start_with?(key)
  queue.insert(index || queue.size, [key, value])
  value
end

def collect(n, arrows, goal)
  come_from = Array.new(n){[]}
  arrows.each do |arrow|
    come_from[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    come_from[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end
  reachable_from
end

def work(n, arrows, start, goal)
  reachable_from = collect(n, arrows, goal)
  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  go = Array.new(n){[]}
  arrows.each do |arrow|
    go[arrow.source] << arrow
  end

  max = n * arrows.map{|arrow| arrow.label.size}.max

  queue = [['', {start => true}]]
  until queue.empty?
    spell, map = queue.shift
    return spell if map[goal]

    return nil if spell.size > max

    map.each do |node, unused|
      go[node].each do |arrow|
        t = push(queue, spell + arrow.label, {})
        t[arrow.sink] = true if t
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts work(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 9812
n = int(input())
ans = 1
r = [1] * (n + 1)
s = n


for i in range(1, n + 1):
    p = i
    while p % 2 == 0:
        p = p // 2
        r[1] += 1

    for j in range(3, i + 1, 2):
        while p % j == 0:
            p = p // j
            r[j-1] += 1

for k in range(n+1):
    ans *= r[k]

ans = ans % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

using namespace std;

int main()
{
	int h[5];
	while (cin >> h[0], h[0]) {
		for (int i = 1; i < 5; i++)
			cin >> h[i];

		int g = 0, c = 0, p = 0;
		
		for (int i = 0; i < 5; i++) {
			if (h[i] == 1)g++;
			if (h[i] == 2)c++;
			if (h[i] == 3)p++;
		}
		if ((g != 0 && c != 0 && p != 0)||
			g == 5 || c == 5 || p == 5) {
			for (int i = 0; i < 5; i++)
				cout << 3 << endl;
		}else{
			if (p == 0) {
				for (int i = 0; i < 5; i++)
					cout << (h[i] == 1 ? 1 : 2 )<< endl;
			}
			if (g == 0) {
				for (int i = 0; i < 5; i++)
					cout << (h[i] == 2 ? 1 : 2) << endl;
			}
			if (c == 0) {
				for (int i = 0; i < 5; i++)
					cout << (h[i] == 3 ? 1 : 2) << endl;
			}
		}
	}
	return	0; 
}

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

int main(void){
  int N;
  long int A[3][110];
  long int sum = 0, max_sum = 0;
  cin >> N;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N; j++){
      cin >> A[i][j];
    }
  }
  //i番目で下に降りる
  for(int i = 0; i < N; i++){
    sum = 0;
    for(int j = 0; j < N; j++){
      if(j <= i) sum += A[0][j];
      if(j >= i) sum += A[1][j];
    }
    //cout << sum << endl;
    if(max_sum < sum) max_sum = sum;
  }
  cout << max_sum << endl;
  return 0;
}


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

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
string S;
vector<vector<ll>> DP;
ll ANS;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> S;
    DP.resize(S.size() + 1, vector<ll>(13, 0));
    ANS = 0;
    return true;
}

void solve() {
    if (S[0] == '?') {
        for (ll i = 0; i < 10; i++)
            DP[1][i] = 1;
    }
    else {
        DP[1][S[0] - '0'] = 1;
    }
    for (ll digit = 2; digit <= S.size(); digit++) {
        if (S[digit - 1] == '?') {
            for (ll i = 0; i < 13; i++) {
                for (ll j = 0; j < 10; j++) {
                    DP[digit][(10 * i + j) % 13]
                        = (DP[digit][(10 * i + j) % 13] + DP[digit - 1][i]) % MOD;
                }
            }
        }
        else {
            ll i = S[digit - 1] - '0';
            for (ll j = 0; j < 13; j++) {
                DP[digit][(j * 10 + i) % 13] = DP[digit - 1][j];
            }
        }
    }
    ANS = DP[S.size()][5];
}

void output() {
    cout << ANS % MOD << endl;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	while ( cin >> N >> M, N || M ) {
		set<P> s;
		vector<string> name(N);
		vector<int> B(N);
		REP(i,N) {
			int b, y; cin >> name[i] >> b >> y;
			s.insert( P(y-b+1, i) );
			B[i] = b;
		}
		REP(i,M) {
			int y; cin >> y;
			auto it = s.upper_bound( P(y, inf) );
			if ( it == s.begin() ) {
				cout << "Unknown" << endl;
			}
			else {
				--it;
				int id = it->second;
				y = y-it->first+1;
				if (y <= B[id]) {
					cout << name[id] << " " << y << endl;
				}
				else {
					cout << "Unknown" << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 3292
#include <stdio.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 10000007

ll N, W;
VVL WV, dp;

void solve() {
    cin >> N >> W;
    WV = VVL(N, VL(2));
    for (auto &i : WV) cin >> i[0] >> i[1];
    // dp[i][j]: i個目まで価値の総和がj以下になるように選んだときの価値の総和の最大値
    dp = VVL(N + 1, VL(W + 1, 0));
    FOR(i, 1, N + 1) {
        const ll w = WV[i - 1][0];
        const ll v = WV[i - 1][1];
        REP(j, W + 1) {
            const ll add = j >= w ? v + dp[i - 1][j - w] : 0;
            dp[i][j] = max(dp[i - 1][j], add);
        }
    }

    print(dp[N][W]);
}

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

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

const double eps = 1e-9;
struct circle { point p; double r; };

int sign(double x) { return x < -eps ? -1 : x > eps; }

int dblcmp(double x, double y) { return sign(x - y); }

point three_point_circle(point a, point b, point c)
{
	point x = 1.0 / conj(b - a), y = 1.0 / conj(c - a);
	return (y - x) / (conj(x) * y - x * conj(y)) + a;
}

circle min_enclosing_circle(vector<point> P)
{
	int n = P.size();
	shuffle(P.begin(), P.end(), random_device{});

	double r = 0.0;
	point p = P[0];

	for (int i = 1; i < n; ++i)
		if (dblcmp(abs(P[i] - p), r) > 0)
		{

		r = abs(P[0] - P[i]) * 0.5;
		p = (P[0] + P[i]) * 0.5;

		for (int j = 1; j < i; ++j)
			if (dblcmp(abs(P[j] - p), r) > 0)
			{

			r = abs(P[i] - P[j]) * 0.5;
			p = (P[i] + P[j]) * 0.5;

			for (int k = 0; k < j; ++k)
				if (dblcmp(abs(P[k] - p), r) > 0)
				{
					p = three_point_circle(P[i], P[j], P[k]);
					r = abs(p - P[i]);
				}
			}
		}

	return {p, r};
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<point> a(n);
	for (auto &i : a)
	{
		int x, y;
		cin >> x >> y;
		i = { x, y };
	}
	cout.precision(20);
	cout << fixed << min_enclosing_circle(a).r << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String w = sc.next();
    
    int[] a = new int[26];
    for (int i = 0; i < w.length(); i++) {
      a[w.charAt(i)-'a']++;
    }
    
    boolean ans = true;
    for (int i = 0; i < 26; i++) {
      if (a[i]%2 != 0) {
        ans = false;
        break;
      }
    }
    
    System.out.println(ans ? "Yes" : "No");
  }
}

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

int S;
int main(void){
  cin >> S;
  int a = S/1000;
  int b = (S-a*1000)/100;
  int c = (S-a*1000-b*100)/10;
  int d = S%10;
  if(a==b||b==c||c==d) cout<< "Bad" <<endl;
  else cout<<"Good"<<endl;
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int K=in();
	int odd=K/2,even=K/2;
	if(K%2) odd++;

	cout << odd*even << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	N := scanInt()
	x, y := scanFloatSlice2(N)
	var ans float64
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			ans += math.Hypot(x[i]-x[j], y[i]-y[j])
		}
	}
	fmt.Println(ans / float64(N))
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanInt2() (int, int) {
	return scanInt(), scanInt()
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanFloat2() (float64, float64) {
	return scanFloat(), scanFloat()
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanSlice2(n int) ([]int, []int) {
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = scanInt2()
	}
	return a, b
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

func scanFloatSlice2(n int) ([]float64, []float64) {
	a := make([]float64, n)
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = scanFloat2()
	}
	return a, b
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

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

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

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func yesOrNo(b bool) string {
	if b {
		return "Yes"
	}
	return "No"
}


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


struct  ways
{
	int tf;   /*  0 = tanri  1 = fukuri */
	double nenri;
	int tesu;
};


int tanri(int money, int year, ways w);
int fukuri(int money, int year, ways w);


int main(void)
{
	int m;


	int money;
	int year;
	int n;
	ways v;

	int i1,i2;

	int mon;
	int max;

	cin >> m;

	for(i1=0;i1<m;i1++){

		cin >> money;
		cin >> year;
		cin >> n;

		max = 0;

		for(i2=0;i2<n;i2++){
			cin >> v.tf >> v.nenri >> v.tesu;
			
			if (v.tf == 0){
				mon = tanri(money, year, v);
				// cout << "tanri " << mon << endl;
			}
			else {
				mon = fukuri(money, year, v);
				// cout << "fukuri " << mon << endl;
			}

			if (max < mon){
				max = mon;
			}

		}

		cout << max << endl;
	
	}
	



	return 0;
}

int tanri(int money, int year, ways w)
{
	int rishi;
	int i1;

	rishi = 0;

	for(i1=0;i1<year;i1++){
		rishi = rishi + money * w.nenri;
		money -= w.tesu;
	}

	return (money + rishi);

}


int fukuri(int money, int year, ways w)
{
	int rishi;
	int i1;

	for(i1=0;i1<year;i1++){
		rishi = money * w.nenri;
		money = money + rishi - w.tesu;
	}

	return money;

}

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

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

  ll A; cin >> A;
  string B; cin >> B;
  ll b1 = B[0] - '0';
  ll b2 = B[2] - '0';
  ll b3 = B[3] - '0';
  

  ll ans = A * (b1 * 100 + b2 * 10 + b3) / 100;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3648
void main(){
	string s = readln().chomp();
	char tmpc;
	foreach(ch; s){
		if(tmpc == ch){
			writeln("Bad");
			return;
		}
		tmpc = ch;
	}
	writeln("Good");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2592
s = [input() for i in range(3)]
p = [0] * 3
t = 0
while p[t] != len(s[t]):
    n = -1
    if s[t][p[t]] == 'a':
        n = 0
    if s[t][p[t]] == 'b':
        n = 1
    if s[t][p[t]] == 'c':
        n = 2
    p[t] += 1
    t = n
ans = ""
if t == 0:
    ans = "A"
if t == 1:
    ans = "B"
if t == 2:
    ans = "C"
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,m;
char a[100005],b[100005];
LL res=linf;
LL GCD(LL A,LL B){
	if(!A || !B) return A?A:B;
	return GCD(B,A%B);
}
LL LCM(LL A,LL B){
	return A*B/GCD(A,B);
}
map < LL , LL > rs;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    int i,j,k;
	scanf("%d%d",&n,&m);
	scanf("%s",a);
	scanf("%s",b);
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
	int G=GCD(n,m);
	for(j=1;j<=m;++j){
		if((LL)n*(LL)j%(LL)m==0ll){
			LL L=(LL)n*(LL)j,F=LCM(L/(LL)n,L/(LL)m);
			if(F*(LL)G%L!=0ll) continue;
			F*=(LL)G;
			F/=L;
			if(rs.count(F))
				UMIN(rs[F],L);
			else
				rs[F]=L;
		}
	}
    for(i=1;i<=n;++i){
		for(j=k=0;j<n && k<m;j+=n/G*i,k+=m/G*i){
			if(a[j]!=b[k]) break;
		}
		if(j>=n || k>=m){
			//lcm(l/n,l/m)=i*l/G
			if(rs.count(i)){
				printf("%lld\n",rs[i]);
				return 0;
			}
		}
		if((LL)n/(LL)G*(LL)i>n) break;
	}
	printf("-1\n");
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3096
input()
A = [int(x) for x in list(input().split())]
# 数列の最後の値を基準値にする
x = A[-1]
i = -1

r = len(A)
# 数列の一番最後の一個手前まで繰り返す
for j in range(r):
    # print(f"{A=}")
    # print(f"{i=}")
    # print(f"{j=}")
    # print(f"{A[j]=}")
    # 各値がxより大きいか小さいかで振り分ける
    if A[j] <= x:
        i += 1
        # A[i]とA[j]を交換
        A[i], A[j] = A[j], A[i]
    # print(f"{A=}")
    # print()

# 最後尾の基準値を基準値を変更
# A[i+1], A[-1] = A[-1], A[i+1]

# 基準値の前後に[ ]を追加
A[i] = "[" + str(A[i]) + "]"
print(*A)



Measured memory_bytes: 15568
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	int A;
	cin >> A;
	vector<int> vNum(A, 0);
	for (int i = 0; i < A; i++)
	{
		cin >> vNum[i];
	}

	int ans = 0;
	for (int i = 0; i < vNum.size(); i++)
	{
		for (int j = 0; j < vNum.size(); j++)
		{
			if (i == j) { continue; }
			ans += vNum[i] * vNum[j];
		}
	}

	cout << ans/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    int a[n], ans[n];
    for (int i=0;i<n;i++) {
        cin >> a[i];
        ans[ a[i]-1 ] = i+1;
    }
    
    for(int j=0;j<n-1;j++){
        cout << ans[j] << " ";
    }
    cout << ans[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 1536
N, M, C = map(int, input().split(' '))
B = tuple(map(int, input().split(' ')))

count = 0
for _ in range(N):
    A = tuple(map(int, input().split(' ')))
    count += int(sum([a * b for a, b in zip(A, B)]) + C > 0)

print(count)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#define N 102
#define pi pair<int,int>
#define mkp make_pair
#define fi first
#define se second

using namespace std;

const int mod = 1e9 + 7;

int n;
int a[N];

int quick_pow(int ,int);
pi solve(int ,int ,int);

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	pi ans = solve(1, n, 0);
	printf("%d\n", (1ll * ans.fi + ans.se * 2 % mod) % mod);
	return 0;
}

int quick_pow(int x, int y){
	int res = 1;
	for(; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res;
}

pi solve(int l, int r, int h){
	if(l > r) return mkp(0, 0);
	if(l == r) return mkp(0, quick_pow(2, a[l] - h - 1));
	int mn = 999999999;
	for(int i = l; i <= r; ++i) mn = min(mn, a[i]);
	int f[2] = {1, 1};
	for(int i = l; i <= r; ++i)
		if(a[i] - mn){
			int pos = i;
			while(pos + 1 <= r && a[pos + 1] - mn) ++pos;
			pi res = solve(i, pos, mn);
			f[0] = 1ll * f[0] * ((1ll * res.fi + 1ll * res.se * 4 % mod) % mod) % mod;
			f[1] = 1ll * f[1] * res.se % mod * 2 % mod; i = pos;
		}
		else f[0] = 1ll * f[0] * 2 % mod;
	f[0] = (f[0] + (1ll * mod - 1ll * f[1] * 2 % mod) % mod) % mod;
	f[1] = 1ll * f[1] * quick_pow(2, mn - h - 1) % mod;
	return mkp(f[0], f[1]);
}

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

using namespace std;

int n;
int a[100001];
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if(x > 0) a[x-1]++;
    a[x]++;
    a[x+1]++;
  }
  int ans = 0;
  for(int i = 0; i < 100001; i++) {
    ans = max(ans,a[i]);
  }

  cout << ans << endl;
}

  
  


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>

using namespace std;

static const int MAX=10000;
static const int INFTY=(1<<20);
static const int WHITE=0;
static const int BLACK=2;
static const int GRAY=1;

int n;
vector<pair<int,int> > adj[MAX];

void diks(){
    priority_queue<pair<int, int> >PQ;
    int color[MAX];
    int d[MAX];
    for(int i = 0; i < n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;
    while(!PQ.empty()){
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        if(d[u] < f.first * (-1)){
            continue;   
        }
        for(int j = 0; j < adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v] == BLACK){
                continue;
            }
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v] * (-1),v));
                color[v] = GRAY;
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
    }
}

int main(){
    int k,u,v,c;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    diks();
    return 0;
}



Measured memory_bytes: 8076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i = 0; i < (n); ++i)
#define rrep(i,n) for(i = 1; i <= (n); ++i)
#define drep(i,n) for(i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
   int n,i;
   cin >> n;
   int h[n];
   rep(i,n)cin>>h[i];
   int max=0;
   int ans=0;
   rep(i,n){
       if( h[i]>=max ){
           max = h[i];
           ans ++; 
       }
   }
   cout << ans << endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

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

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

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

void print(vector<ll> &v) {
    rep(i, v.size()) {
        if(i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

int main() {
    string S;
    cin >> S;
    if(S.size() == 2) {
        cout << S << endl;
    } else {
        reverse(S.begin(), S.end());
        cout << S << endl;
    }
}


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

int main(){
	std::priority_queue<int> p;
	
	int n, m;
	int price;
	while(std::cin >> n >> m){
		int sum_price = 0;
		if(n == 0 && m == 0) break;
		//input
		for(int i = 0; i < n; ++i){
			std::cin >> price;
			p.push(price);
		}
		//袋詰め
		while(!p.empty()){
			for(int i = 1; i <= m && !p.empty(); ++i){
				if(i != m){
					sum_price += p.top();
					p.pop();
				}
				else{
					p.pop();
				}
			}
		}
		std::cout << sum_price << std::endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  string s;
  cin >> n >> s;
  int r=0, b=0;
  for (int i=0; i<n; ++i) {
    if (s[i]=='R') r++;
    else b++;
  }
  if (r>b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
	while(1){
		long long int n;
		scanf("%lld",&n);
		if(n==0) break;
		long long int y;
		scanf("%lld",&y);
		long long int i,b[n],r[n],t[n];
		for(i=0;i<n;i++){
			scanf("%lld %lld %lld",&b[i],&r[i],&t[i]);
		}
		double a[n];
		for(i=0;i<n;i++){
			if(t[i]==1){
				a[i]=1.0+(y*(r[i]/100.0));
			}
			else{
				a[i]=pow(1.0+(r[i]/100.0),y);
			}
		}
		long long int j,tmp;
		for(j=n-1;j>0;j--){
			for(i=0;i<j;i++){
				if(a[i]<a[i+1]){
				    tmp=a[i];
				    a[i]=a[i+1];
				    a[i+1]=tmp;
					tmp=b[i];
					b[i]=b[i+1];
					b[i+1]=tmp;
				}
			}
		}
		printf("%lld\n",b[0]);
	}
	return 0;
}


Measured memory_bytes: 2080
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N + 1], chk = 1 - (N & 1), ans = 1;
  for (int i = 0;i < N;++ i) cin >> A[i];
  sort(A, A+N);
  for (int i = 0;i < N;++ i, chk += ((chk ^ i) & 1) << 1) {
    if (i & 1) ans *= 2;
    if (A[i] != chk) ans *= 0;
    ans %= 1000000007;
  }
  cout << ans;
  return 0;
}

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

#define N 100009

using namespace std;

int a[N],cnt[5];

int main(){
	int i,j,t1,t2,t3,t4,n,req,have;
	req=have=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&t1);
		cnt[t1%4]++;
	}
	req=ceil(n/2.0);
	have=cnt[0];
	if(have>=req){
		printf("Yes\n");
		return 0;
	}
	i=1;
	while(i<n && have>0){
		a[i]=4;
		have--;
		i+=2;
	}
	i=n-1;
	have=cnt[2];
	while(i>=0 && have>0){
		if(!a[i]){
			a[i]=2;
			have--;
		}
		i--;
	}
	have=cnt[3];
	while(i>=0 && have>0){
		if(!a[i]){
			a[i]=3;
			have--;
		}
		i--;
	}
	have=cnt[1];
	while(i>=0 && have>0){
		if(!a[i]){
			a[i]=1;
			have--;
		}
		i--;
	}
	t1=0;
	for(i=0;i<n-1;i++){
		t2=a[i]*a[i+1];
		if(t2%4!=0){
			t1=1;
		}
	}
	if(t1==1){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 1e5 + 7;

struct Edge {
	int t, next;
} edge[MAXN << 1];

int n, S, T, head[MAXN], cnt, dis[MAXN], max[MAXN], fa[MAXN];

void add(int u, int v) {
	edge[++cnt] = (Edge){v, head[u]}; head[u] = cnt;
}

void dfs(int u, int pre) {
	fa[u] = pre;
	max[u] = dis[u];
	PE(e, u) {
		int v = edge[e].t;
		if (v == pre) continue;
		dis[v] = dis[u] + 1;
		dfs(v, u);
		max[u] = std::max(max[u], max[v]);
	}
}

int main() {
	scanf("%d %d %d", &n, &S, &T);
	rep(i, 1, n - 1) {
		int u, v;
		scanf("%d %d", &u, &v); add(u, v), add(v, u);
	}
	dfs(T, 0);
	int ans = 0;
	if (dis[S] & 1) {
		// ans = dis[S] / 2 + max[S] - dis[S];
		// printf("max = %d, dis = %d\n", max[S], dis[S]);
		ans += dis[S] / 2;
		int tmp = (dis[S] / 2), gx = S;
		while (tmp--) gx = fa[gx];
		ans += max[gx] - dis[gx];
	} else {
		ans += (dis[S]  - 1)/ 2;
		int tmp = ans, gx = S;
		while (tmp--) gx = fa[gx];
		ans += max[gx] - dis[gx] + 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int n, k;
    int l[50];

    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &l[i]);
    }

    for (int j = 0; j <= n - 4; j++) {
        for (int i = 0; i <= n - j - 2; i++) {
            int tmp;
            if (l[i] < l[i + 1]) {
                tmp = l[i];
                l[i] = l[i + 1];
                l[i + 1] = tmp;
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += l[i];
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 128
import math
import sys
n=int(input())
mi=int(math.log10(n))
nb=n
m=1
for i in range(1,int(nb**0.5)+2):
  if(n%i==0):
    mi=min(mi,max(int(math.log10(n/i)),int(math.log10(i))))
print(mi+1)

Measured memory_bytes: 3060
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let a: Vec<i32> = read_as_vec();
    
    //if status[i] == true, we put a ball into ith box
    let mut status: Vec<bool> = vec![false;n];

    for i in (0..n).rev(){
        //println!("i = {}, a[i] = {}", i, a[i]);
        //let mut sum = status.iter().enumerate().skip(i)
        //    .step_by(i+1).filter(|x| (x.0+1)%(i+1) == 0 && *x.1).count();
        let mut sum = 0;

        let step = i+1;
        let mut j = i;
        while j < n{
            if status[j]{
                sum += 1;
            }
            j += step;
        }
        
        if (sum%2 == 0 && a[i] == 1) || (sum%2 == 1 && a[i] == 0){
            status[i] = true;
        }
        //println!("{:?}", status);
    }
    let num_balls = status.iter().filter(|x| **x == true).count();
    println!("{}", num_balls);
    
    if num_balls == 0{
        return;
    }
    
    for (i, is_ball) in status.iter().enumerate(){
        if *is_ball{
            print!("{} ", i+1);
        }
    }
    println!("");
}


Measured memory_bytes: 5116
#include<stdio.h>
 
#define MAX 26
 
typedef struct{
  int p;
  int l;
  int r;
} Tree;
 
Tree T[MAX];
 
void preorder(int a){
  if(a==-1) return;
 
  printf(" %d",a);
  preorder(T[a].l);
  preorder(T[a].r);
}
 
void inorder(int a){
  if(a==-1) return;
 
  inorder(T[a].l);
  printf(" %d",a);
  inorder(T[a].r);
}
 
void postorder(int a){
  if(a==-1) return;
 
  postorder(T[a].l);
  postorder(T[a].r);
  printf(" %d",a);
}
 
int main(){
  int n,i,id,left,right;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].l=left;
    T[id].r=right;
    if(left!=-1) T[left].p=id;
    if(right!=-1) T[right].p=id;
  }
 
  for(i=0;i<n;i++){
    if(T[i].p==-1){
      printf("Preorder\n");
      preorder(i);
      printf("\nInorder\n");
      inorder(i);
      printf("\nPostorder\n");
      postorder(i);
    }
  }
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
using namespace std;
int dp[8192];

void goup() {
	dp[0] = 1; dp[1] = 1; dp[2] = 2;

	for (int i = 3; i < 8192; i++) dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	return;
}

int main() {
	int n;
	goup();

	while (1) {
		cin >> n;
		if (n == 0) break;
		cout << dp[n] / (365 * 10) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
using System;
using System.Linq;

namespace AtCoderMake.ABC169
{
    class ABC169A
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select((x) => int.Parse(x)).ToArray();
            Console.WriteLine(ab[0] * ab[1]);
        }
    }
}


Measured memory_bytes: 28240
using System;
using System.Collections.Generic;

class main
{
    static void Main(string[] args)
    {
        //string[] read = Console.ReadLine().Split(' ');

		string S = Console.ReadLine();
		string T = Console.ReadLine();

		int sLen = S.Length;
		int tLen = T.Length;

		int max = 1001;

		for(int i = 0;i < sLen - tLen + 1;i++)
		{
			int count = 0;
			for(int j = 0;j < tLen; j++)
			{
				if(!S.Substring(i + j,1).Equals(T.Substring(j, 1)))
				{
					count++;
				}
			}
			if(count < max)
			{
				max = count;
			}
		}
		
		Console.WriteLine(max);
	}
}



Measured memory_bytes: 37264
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll lu[87] = {};
    lu[0] = 2;
    lu[1] = 1;
    repd(i, 2, 87) { lu[i] = lu[i - 2] + lu[i - 1]; }

    int n;
    cin >> n;

    cout << lu[n] << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int a[5];for(int i=0;i<5;i++)cin>>a[i];
	for(int i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout<<i+1;
			return 0;
		}
	}
}


Measured memory_bytes: 3628
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let l: i32 = input();

    let mut ans = vec![];
    dfs(l, &mut ans);

    let n = ans.len() + 1;
    let m: usize = ans.iter().map(|v| v.len()).sum();
    with_stdout_lock(|mut w| {
        writeln!(w, "{} {}", n, m).unwrap();
        for u in 0..n - 1 {
            for &(v, d) in &ans[u] {
                writeln!(w, "{} {} {}", u + 1, v + 1, d).unwrap();
            }
        }
    });
}

fn dfs(l: i32, ans: &mut Vec<Vec<(usize, i32)>>) {
    if l == 2 {
        ans.push(vec![(1, 0), (1, 1)]);
    } else if l & 1 == 0 {
        dfs(l / 2, ans);
        for u in ans.iter_mut() {
            for mut v in u.iter_mut() {
                v.1 *= 2;
            }
        }
        let n = ans.len();
        ans.push(vec![(n + 1, 0), (n + 1, 1)]);
    } else {
        dfs(l - 1, ans);
        let n = ans.len();
        ans[0].push((n, l - 1));
    }
}


Measured memory_bytes: 4352
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

A = l()
A.sort()
if A == [5,5,7]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 10052
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let num = xs[0]+xs[1];
   if(num%3==0 || xs[0]%3==0 || xs[1]%3==0){
     console.log('Possible');
   }else{
     console.log('Impossible');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 29644
#include <bits/stdc++.h>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
    n = abs(n);
    if(n < 10) return 1;
    elif(n < 100) return 2;
    elif(n < 1000) return 3;
    elif(n < 10000) return 4;
    elif(n < 100000) return 5;
    elif(n < 1000000) return 6;
    elif(n < 10000000) return 7;
    elif(n < 100000000) return 8;
    elif(n < 1000000000) return 9;
    else return 10;
}


int main() {
    io();
    
    string n;
    cin >> n;
    bool con7 = false;
    fori(i, n.size()) {
        if(n[i] == '7') con7 = true;
    }
    if(con7 == true) cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 3640