akhauriyash/Code-Regression huggingface dataset:
// Aizu Vol-2 0221: FizzBuzz
// 2017.8.24 bal4u@uu

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

char *gets(char *);
char buf[100], *bp;

int getInt(int mode)
{
	int n = 0;
	if (!mode) while (isspace(*bp)) bp++;
	while (isdigit(*bp)) n = 10 * n + (*bp++ - '0');
	if (mode && *bp) return -5;
	return n;
}

#define DIG    (-1)
#define FIZZ   (-2)
#define BUZZ   (-3)
#define FIZBUZ (-4)
#define OTHER  (-5)

char p[1010];

int main()
{
	int m, n;
	int k, dig, must, idx, len;

	while (1) {
		gets(bp = buf), m = getInt(0), n = getInt(0); if (!m) break;
		memset(p, 0, sizeof(p));
		len = m, idx = dig = 1;
		while (n-- > 0) {
			if (dig % 3 == 0 && dig % 5 == 0) must = FIZBUZ;
			else if (dig % 3 == 0) must = FIZZ;
			else if (dig % 5 == 0) must = BUZZ;
			else must = DIG;
			
			gets(bp = buf);
			if (!strcmp(bp, "Fizz")) k = FIZZ;
			else if (!strcmp(bp, "Buzz")) k = BUZZ;
			else if (!strcmp(bp, "FizzBuzz")) k = FIZBUZ;
			else k = getInt(1);

			if ((k >= 0 && (must != DIG || dig != k)) ||
				(k < 0 && k != must)) {
				p[idx] = 1;
				if (--len == 1) goto Done;
			}
			++dig;
			if (++idx > m) idx = 1;
			while (p[idx]) {
				if (++idx > m) idx = 1;
			}
		}
		Done:
		while (n-- > 0) gets(buf);
		for (idx = 1, k = 0; k < len; k++, idx++) {
			while (p[idx]) idx++;
			if (k > 0) putchar(' ');
			printf("%d", idx);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

llint s;

llint find(int n) {
	llint value = s;
	llint res = 0;
	for (int i = 0; i < n + 1; i++) {
		res = value % 10;
		value /= 10;
	}
	return res;
}

llint func(llint i, llint sum,llint memo) {
	if (i == 0)return sum+memo*10+find(i);
	return func(i - 1, sum+memo*10+find(i),0) 
		+ func(i - 1, sum, memo*10+find(i));
}

int main() {
	cin >> s;
	cout << func((int)log10(s), 0, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
n, *a = map(int, open(0))
done = [0] * n
b = 1
cnt = 0
while not done[b - 1]:
    if b == 2:
        print(cnt)
        exit()
    done[b - 1] = 1
    b = a[b - 1]
    cnt += 1
print(-1)

Measured memory_bytes: 7956
#include <stdio.h>
int main(){
    bool f;
    int n,temp,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        
        f=true;
        if(temp%2==0&&temp>=4)f=false;
        for(int j=3;j*j<=temp&&f;j+=2)if(temp%j==0)f=false;
        if(f)ans++;
    }
    printf("%d\n",ans);
}

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

ll GCD(ll a, ll b) {
	return b ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b) {
	return a / GCD(a, b) * b;
}

int main()
{
	ll n;
	while (cin >> n, n) {
		vector<ll> d(n), v(n);
		for (int i = 0; i < n; i++) {
			cin >> d[i] >> v[i];
			ll gcd = GCD(d[i], v[i]);
			d[i] /= gcd;
			v[i] /= gcd;
		}
		vector<ll> res(n);
		ll lcm = d[0], gcd = v[0];
		for (int i = 1; i < n; i++) {
			lcm = LCM(lcm, d[i]);
			gcd = GCD(gcd, v[i]);
		}
		for (int i = 0; i < n; i++) {
			cout << lcm * v[i] / d[i] / gcd << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3084
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int sum = 0;
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}

		Arrays.sort(A);
		String ans;
		if(A[N-M] < (double)sum / (4 * M))
			ans = "No";
		else
			ans = "Yes";

		System.out.println(ans);
	}

}



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

char x = 'a';
int i = 0,j = 0,k = 0,y = 0;

bool aaa(string &S,int &s,char &x,int &y){
  if(s == S.size()){
    cout << 'A' << endl;
    y++;
    return 0;
  }
  if(S.at(s) == 'a'){
    s++;
    x = 'a';
    return true;
  }
  if(S.at(s) == 'b'){
    s++;
    x = 'b';
    return true;
  }
  if(S.at(s) == 'c'){
    s++;
    x = 'c';
    return true;
  }
}

bool bbb(string &S,int &s,char &x,int &y){
  if(s == S.size()){
    cout << 'B' << endl;
    y++;
    return 0;
  }
  if(S.at(s) == 'a'){
    s++;
    x = 'a';
    return true;
  }
  if(S.at(s) == 'b'){
    s++;
    x = 'b';
    return true;
  }
  if(S.at(s) == 'c'){
    s++;
    x = 'c';
    return true;
  }
}

bool ccc(string &S,int &s,char &x,int &y){
  if(s == S.size()){
    cout << 'C' << endl;
    y++;
    return 0;
  }
  if(S.at(s) == 'a'){
    s++;
    x = 'a';
    return true;
  }
  if(S.at(s) == 'b'){
    s++;
    x = 'b';
    return true;
  }
  if(S.at(s) == 'c'){
    s++;
    x = 'c';
    return true;
  }
}

int main(){
  string SA,SB,SC;
  cin >> SA >> SB >> SC;
  while(true){
  if(x == 'a'){
    aaa(SA,i,x,y);
    if(y == 1)
      break;
  }
  if(x == 'b'){
    bbb(SB,j,x,y);
    if(y == 1)
      break;
  }
  if(x == 'c'){
    ccc(SC,k,x,y);
    if(y == 1)
      break;
  }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
  cout << "vowel" << endl;
  }
  
  else {
  cout << "consonant" << endl;
  }
  
 
  // ここにプログラムを追記
}

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

int main() {
  int x, y, z;
  int k;
  cin >> x >> y >> z;
  cin >> k;

  vector<long long> A(x), B(x), C(z);

  for (int i = 0; i < x; i++) cin >> A[i];
  for (int i = 0; i < y; i++) cin >> B[i];
  for (int i = 0; i < z; i++) cin >> C[i];

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  sort(C.begin(), C.end());
  reverse(C.begin(), C.end());

  vector<long long> ABC;
  for (int a = 0; a < x; a++) {
    for (int b = 0; b < y; b++) {
      if ((a+1) * (b+1) > k) break;
      for (int c = 0; c < z; c++) {
        if ((a+1) * (b+1) * (c+1) > k) break;
        ABC.push_back(A[a] + B[b] + C[c]);
      }
    }
  }
  sort(ABC.begin(), ABC.end());
  reverse(ABC.begin(), ABC.end());

  for (int i = 0; i < k; i++) cout << ABC[i] << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q; cin>>q;
    while(q--){
        ll a,b; cin>>a>>b;
        auto f = [&](ll x){return (x<a-1)?1+x:2+x;};
        auto g = [&](ll x){return (x<b-1)?1+x:2+x;};

        ll l=0,r=a+b-1; //L OK, R NG
        while(r-l>1){
            ll c = (l+r)/2;
            ll s1 = max(0ll,min(a-1,c-b));
            ll s2 = max(a-1,c-b);
            ll val=0;
            //[0,s1)
            if (s1!=0){
                //三分探索
                ll low=-1,high=s1;
                while(high-low>2){
                    ll c1=(low*2+high)/3;
                    ll c2=(low+high*2)/3;
                    ll v1 = f(c1)*g(c-1-c1);
                    ll v2 = f(c2)*g(c-1-c2);
                    if (v1<v2) low=c1;
                    else high=c2;
                }
                ll r = (low+high)/2;
                val = max(val, f(r)*g(c-1-r));
            }
            //[s1,s2)
            if (s1<s2){
                //三分探索
                ll low=s1-1,high=s2;
                while(high-low>2){
                    ll c1=(low*2+high)/3;
                    ll c2=(low+high*2)/3;
                    ll v1 = f(c1)*g(c-1-c1);
                    ll v2 = f(c2)*g(c-1-c2);
                    if (v1<v2) low=c1;
                    else high=c2;
                }
                ll r = (low+high)/2;
                val = max(val, f(r)*+g(c-1-r));
            }
            //[s2,c)
            if (s2<c){
                //三分探索
                ll low=s2-1,high=c;
                while(high-low>2){
                    ll c1=(low*2+high)/3;
                    ll c2=(low+high*2)/3;
                    ll v1 = f(c1)*g(c-1-c1);
                    ll v2 = f(c2)*g(c-1-c2);
                    if (v1<v2) low=c1;
                    else high=c2;
                }
                ll r = (low+high)/2;
                val = max(val, f(r)*+g(c-1-r));
            }
            if (val<a*b) l=c;
            else r=c;
        }
        cout<<l<<endl;
    }
    return 0;
}


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

#ifndef __HEADERS__
#define __HEADERS__

#define up(i,j,k) for (int i = j; i <= k; i++)
#define down(i,j,k) for (int i = j; i >= k; i--)

#define lb long double
#define ll long long
#define ull unsigned long long

#define mp std::make_pair
#define pb push_back

#define all(x) x.begin(), x.end()
#define lowbit(x) ((x) & (-x))
#define mem(a) memset(a, 0, sizeof(a))
#define File(x)                       \
    freopen("" #x ".in", "r", stdin); \
    freopen("" #x ".out", "w", stdout);

#endif

#define int long long

inline int read() {
    int data = 0, w = 1; char ch = 0;
    while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); }
    return data * w;
}

inline void print (ll v) {
    if (v < 0) { putchar('-'); v = -v; }
    if (v > 9) print(v / 10);
    putchar(v % 10 + '0');
}

signed main () {
    ll n = read(), res = 0, maxx = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i) continue;
        if (i > res) {
            res = i;
            maxx = n / i;
        }
    }
    print(res + maxx - 2);
}

Measured memory_bytes: 256
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_M = 10;

/* typedef */

typedef map<int,int> mii;

struct Seq {
  int a, d;
  mii v;
  Seq(int _a, int _d): a(_a), d(_d) { v.clear(); }

  int get(int i) {
    mii::iterator mit = v.find(i);
    if (mit == v.end()) return a + d * (i - 1);
    return mit->second;
  }
  void set(int i, int val) { v[i] = val; }
};

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a, d, m;
  cin >> n >> a >> d >> m;

  Seq q(a, d);
  
  for (int i = 0; i < m; i++) {
    int xi, yi, zi;
    cin >> xi >> yi >> zi;

    if (xi == 0) {
      int vy = q.get(yi), vz = q.get(zi);
      q.set(yi, vz);
      q.set(zi, vy);
    }
    else {
      int vz = q.get(zi);
      q.set(yi, vz);
    }
  }

  int k;
  cin >> k;

  printf("%d\n", q.get(k));
  return 0;
}

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

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define ms memset
#define mp make_pair
#define f first
#define s second
#define int long long

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, pair<int, int>> piii;

#define MAXN 1010
#define MAXK 5010

vi A;

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

	int n;

	cin >> n;

	//a.resize(n);

	int aux = 0;
	for(int i = 0; i < n; i++){
		char c;

		cin >> c;

		if(c == 'R')
			A.pb(aux);

		else{
			A.pb(-1);
			aux++;
		}
	}
		
	int troc = 0;

	/*for(int i = 0; i < n; i++){
		cout << A[i] << " ";
	}
	cout << "\n";*/

	for(int i = n-1; i >= 0; i--){
		if(A[i] - troc > 0){
			troc++;
		}
	}

	cout << troc << "\n";

	return 0;
}

Measured memory_bytes: 5268
#include<bits/stdc++.h>
int main()
{
    int i,a[3]={0},j;
    char a1;
    for(i=0;i<3;i++)
    {
		scanf("%c",&a1);
        if(a1=='a')
		{
			a[0]++;
		}		
		if(a1=='b')
		{
			a[1]++;
		}
		if(a1=='c')
		{
			a[2]++;
		}
		for(j=0;j<3;j++)
		{
			if(a[j]==2)
			{
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);

        double val = v[0];
        for (int i = 1; i < n; i++) {
            val = (val + v[i]) / 2;
        }
        System.out.println(val);
    }

}


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

bool comp(const pair<int,int> &a, 
              const pair<int,int> &b){
	return a.second<b.second ;
}

int main(){
  int n;
  cin >> n ;
  vector <pair<int,int> > v;
  for(int i = 0;i<n;i++){
    int x ;
    cin >> x ;
  	v.push_back(make_pair(i+1,x));
  }
  sort(v.begin(),v.end(),comp) ;
  for(int i = 0;i<n;i++){
  	cout << v[i].first <<" " ;
  }
}

Measured memory_bytes: 1780
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// Range系のライブラリ
struct RangeIterator {
	ll v;
	const ll operator*() { return v; }
	RangeIterator& operator++() { ++v; return *this; }
	bool operator!=(const RangeIterator& rhs) { return v != rhs.v; }
};
template<bool INCLUSIVE> struct EndType {};
template<> struct EndType<false> {
	ll end;
	ll operator()() { return end; }
};
template<> struct EndType<true> {
	ll end;
	ll operator()() { return end + 1; }
};
template<bool INCLUSIVE>
struct Range {
	ll s; EndType<INCLUSIVE> e;
	Range(ll end) : s(0), e(EndType<INCLUSIVE>{end}) {}
	Range(ll start, ll end) : s(start), e(EndType<INCLUSIVE>{end}) {}
	RangeIterator begin() { return { s }; }
	RangeIterator end() { return { e() }; }
};
inline Range<false> range(ll start) { return Range<false>(start); }
inline Range<false> range(ll start, ll end) { return Range<false>(start, end); }
inline Range<true> irange(ll start) { return Range<true>(start); }
inline Range<true> irange(ll start, ll end) { return Range<true>(start, end); }

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T & container, typename T::key_type & key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法

ll count[3000 * 3000 + 100];

int main(void) {
	std::ios_base::sync_with_stdio(false);

	int R, G, B, N;
	cin >> R >> G >> B >> N;
	ll result = 0;
	for (auto r : irange(N)) { 
		for (auto g : irange(N)) {
			int rest = N - R * r - G * g;
			if (rest >= 0 && rest % B == 0) result++;
		}
	}
	cout << result << endl;
	
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    for (int i=0; i<=N/4; i++) {
        for (int j=0; j<=N/7; j++) {
            if (4*i + 7*j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
function main(input) {
    var x = input.split(' ');
    num_1 = parseInt(x[0]);
    num_2 = parseInt(x[1]);
    num_3 = parseInt(x[2]);
    num_4 = parseInt(x[3]);
    if(num_1 + num_2 < num_3 + num_4){
        console.log('Right');
    }
    else if(num_1 + num_2 > num_3 + num_4){
        console.log('Left');
    }
    else{
        console.log('Balanced');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int A, B, C, D;
int main() {
    std::cin >> A >> B >> C >> D;
    std::cout << std::min(A, B) + std::min(C, D) << std::endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] bitCount = new int[60];
		long a;
		for (int i = 0; i < n; i++) {
			a = scanner.nextLong();
			for (int j = 0; a > 0; j++, a >>= 1) {
				if (a % 2 == 1)
					bitCount[j]++;
			}
		}
		long sum = 0, num, bit;
		for (int i = 0; i < 60; i++) {
			num = (long) bitCount[i] * (n - bitCount[i]);
			num %= 1000000007;
			bit = 1l << i;
			bit %= 1000000007;
			sum += num * bit;
			sum %= 1000000007;
		}
		System.out.println(sum);
	}

}


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

int n;
void dfs(string s,char mx){
  if(s.size() == n) {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= mx+1; c++) {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}
int main() {
  cin >> n;
  dfs("",'a'-1);
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#define MAX 100005

int parent[MAX], left[MAX], right[MAX];
int n, D[MAX];

int getDepth(int u)
{
  int d = 0;

  while (parent[u] != -1)
  {
    u = parent[u];
    d++;
  }
  return d;
}

void setDepth(int u, int p)
{
  D[u] = p;
  if (right[u] != -1)
    setDepth(right[u], p);
  if (left[u] != -1)
    setDepth(left[u], p + 1);
}

void printChildren(int u)
{
  int i, c;

  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("depth = %d, ", getDepth(u));

  if (parent[u] == -1)
    printf("root, ");
  else if (left[u] == -1)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");

  for (i = 0, c = left[u]; c != -1; i++, c = right[c])
  {
    if (i)
      printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int main()
{
  int i, j, d, v, c, l, r;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    parent[i] = left[i] = right[i] = -1;

  for (i = 0; i < n; i++)
  {
    scanf("%d", &v);
    scanf("%d", &d);
    for (j = 0; j < d; j++)
    {
      scanf("%d", &c);
      if (j == 0)
        left[v] = c;
      else
        right[l] = c;
      l = c;
      parent[c] = v;
    }
  }
  for (i = 0; i < n; i++)
  {
    if (parent[i] == -1)
      r = i;
  }

  setDepth(r, 0);

  for (i = 0; i < n; i++)
    printChildren(i);

  return 0;
}



Measured memory_bytes: 6400
#include <iostream>
#include <string>

using namespace std;

int main() {

	int h,w;

	string s[50];//全体

	cin >> h;//縦の数
	cin >> w;//横の数
	for (int i = 0; i < h;i=i+1) {
		cin >> s[i];
	}

	for (int i = 0; i < h; i = i + 1) {
		for (int j = 0; j < w; j = j + 1) {
			//.があるときに
			if(s[i][j] == '.')
			//.をすべて0にする
			s[i][j] = '0';

		}
	}
	
	for (int i = 0; i < h; i = i + 1) {
		for (int j = 0; j < w; j = j + 1) {
			//#があるときに
			if (s[i][j] == '#') {

				if (i != 0 && j != 0) {
					if (s[i - 1][j - 1] != '#') {
						s[i - 1][j - 1] = s[i - 1][j - 1] + 1;//左上
					}
				}
				if (i != h-1 && j != w-1) {
					if (s[i + 1][j + 1] != '#') {
						s[i + 1][j + 1] = s[i + 1][j + 1] + 1;//右下
					}
				}
				if (i != 0 && j != w-1) {
					if (s[i - 1][j + 1] != '#') {
						s[i - 1][j + 1] = s[i - 1][j + 1] + 1;//右上
					}
				}
				if (i != h-1 && j != 0) {
					if (s[i + 1][j - 1] != '#') {
						s[i + 1][j - 1] = s[i + 1][j - 1] + 1;//左下
					}
				}
				if (j != w-1) {
					if (s[i][j + 1] != '#') {
						s[i][j + 1] = s[i][j + 1] + 1;//右
					}
				}
				if (j != 0) {
					if (s[i][j - 1] != '#') {
						s[i][j - 1] = s[i][j - 1] + 1;//左
					}
				}
				if (i != h-1) {
					if (s[i + 1][j] != '#') {
						s[i + 1][j] = s[i + 1][j] + 1;//下
					}
				}
				if (i != 0) {
					if (s[i - 1][j] != '#') {
						s[i - 1][j] = s[i - 1][j] + 1;//上
					}
				}

			}

		}

	}

	for (int i = 0; i < h; i = i + 1) {

		cout << s[i] << endl;

	}

}

Measured memory_bytes: 256
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    private static long evaluate(long a[], int N, long val)
    {
        long sum=0;
        for(int i=0;i<N;i++) sum+=a[i]^val;
        return sum;
    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String s[]=br.readLine().trim().split(" ");
        N=Integer.parseInt(s[0]);
        long K=Long.parseLong(s[1]);

        s=br.readLine().trim().split(" ");
        long[] a=new long[N];
        for(i=0;i<N;i++) a[i]=Long.parseLong(s[i]);

        long max=evaluate(a,N,0); long cur;
        for(cur=1;cur<=K;cur*=2){}

        cur/=2; long val=0; max=0;
        for(;cur>=1;cur/=2)
        {
            long tmp=evaluate(a,N,cur);
            if(val+cur>K) continue;
            else
            {
                if(evaluate(a,N,val+cur)>max)
                {
                    max=evaluate(a,N,val+cur);
                    val+=cur;
                }
                if(tmp>max)
                {
                    max=tmp;
                    val=cur;
                }
            }
        }

        max=Math.max(max,evaluate(a,N,0));
        max=Math.max(max,evaluate(a,N,K));
        System.out.println(max);
    }
}

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

vector<bool> sieve() {
    vector<bool> is_prime(100001, true);
    is_prime[0] = false, is_prime[1] = false;
    for (int i = 2; i * i <= 100000; i++) {
        if (is_prime[i]) {
            for (int j = i * 2; j <= 100000; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return is_prime;
}

int main() {
    int Q;
    cin >> Q;
    vector<bool> is_prime = sieve();
    vector<int> cnt(100001);
    for (int i = 2; i <= 100000; i++) {
        cnt[i] = cnt[i - 1];
        if (is_prime[i] && is_prime[(i + 1) / 2]) {
            cnt[i]++;
        }
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e9
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<long long,long long> pll;

long long min(long long a,long long b){
	return (a<b)?a:b;
}

long long max(long long a,long long b){
	return (a>b)?a:b;
}

int main(){
	long long n,ms=INF,en=0;
	cin>>n;
	long long a[n];
	vector<pll> vec;
	rep(i,n){
		cin>>a[i];
		en=max(en,a[i]);
	}
	rep(i,n){
		if(a[i]==en)continue;
		long long alt=min(a[i],en-a[i]);
		vec.pb(pll(alt,a[i]));
	}
	sort(all(vec));
	cout<<en<<" "<<vec[vec.size()-1].second<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define int long long int
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define present(c,x) (c.find(x) != c.end())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define endl '\n'	
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define INF 1000000007 
#define MOD 998244353
#define INF64 1e18

void solve(){
	int n;
	cin>>n;
	vector<int> a(n+1);
	a[0]=0;
	rep(i,1,n+1){
		cin>>a[i];
		a[i]+=a[i-1];
	}

	vector<vector<int>> dp(n+1,vector<int> (n+1,INF64));

	rep(len,1,n+1){
		rep(i,1,n-len+2){
			int j=i+len-1;
			if(len==1){
				dp[i][j]=0;
				continue;
			}
			for(int k=i;k<j;k++)
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+a[j]-a[i-1]);
		}
	}

	cout<<dp[1][n];
}	
 
int32_t main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	int T;
	// cin>>T;
	T=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 4492
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

int N;
int A[100010];
int ans[100010];

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

	int tmp = A[0];
	REP(i, N - 1) {
		if (i % 2 == 0) {
			//引く処理
			tmp -= A[i + 1];
		}
		else {
			//足す処理
			tmp += A[i + 1];
		}
	}
	ans[0] = tmp / 2;
	REP(i, N - 1) {
		ans[i + 1] = A[i] - ans[i];
	}

	REP(i, N) {
		cout << 2 * ans[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2048
numbers = readline()
num_arr = split(numbers, " ")
num_arr_int = map(x -> parse(Int64,x), num_arr)
flag = false
for x in num_arr_int
    if iseven(x)
        flag = true
    end
end
if flag
    text = "No"
else
    text = "Yes"
end
print(text)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  string s; cin >> s;

  int x = 0;
  int ans = 0;
  rep(i,s.size()){
    if(s[i] == 'I') x++;
    else if(s[i] == 'D') x--;
    ans = max(ans,x);
  }

  cout << ans << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    s+=".";
    string tmp = "";
    string ans = "";
    rep(i,s.size()){
        if(s[i]==*"A"||s[i]==*"C"||s[i]==*"G"||s[i]==*"T"){
            tmp += s[i];
        }else{
            if(tmp.length()>ans.length()){
                ans = tmp;
            }
            tmp = "";
        }
    }
    cout<<ans.length()<<endl;
    return  0;
}


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

constexpr long long mod = 1000000007;

long long fact[1000001];

void fact_table()
{
	for (long long i = 1; i <= 1000000; i++)
		fact[i] = fact[i - 1] * i % mod;
}

long long pow(long long a, long long b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
	{
		long long half = pow(a, b / 2);
		return half * half % mod;
	}
	else
	{
		return a * pow(a, b - 1) % mod;
	}
}

long long inv(long long n)
{
	return pow(n, mod - 2);
}

long long comb(long long n, long long r)
{
	if (n - r < r)
		return comb(n, n - r);
	return fact[n] * inv(fact[n - r] * fact[r] % mod) % mod;
}

int main()
{
	long long N, M;
	std::cin >> N >> M;
	std::map<long long, long long> prime;
	for (long long i = 2; i * i <= M; i++)
	{
		while (M % i == 0)
		{
			if (prime.find(i) == prime.end())
				prime[i] = 1;
			else
				prime[i] = prime[i] + 1;
			M /= i;
		}
	}
	if (M != 1)
	{
		if (prime.find(M) == prime.end())
			prime[M] = 1;
		else
			prime[M] = prime[M] + 1;
	}
	fact[0] = 1;
	fact_table();
	long long ans = 1;
	for (auto p : prime)
	{
		ans *= comb(p.second + N - 1, N - 1);
		ans %= mod;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 8064
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Measured memory_bytes: 3316
//  Created by Vignesh Manoharan

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <numeric>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1000000000;
const ll LINF = 1e17;
const double PI =3.141592653589793238;
const int mod=1000000007;
const double eps = 0.000001;

#define F(i,a,n) for(int i=(a);i<(n);i++)

template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){
    for(int i=0;i<(t).size();i++)s<<t[i]<<((i<(t).size()-1)?" ":"");return s; }
template<typename T> ostream& operator<<(ostream &s,set<T> t){for(T x:t) s<<x<<" ";return s; }
template<typename T> istream& operator>>(istream &s,vector<T> &t){
    for(int _i=0;_i<t.size();_i++) s>>t[_i];return s; }

#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()

int main(int argc, const char * argv[]) {
    #ifdef LOCAL_TEST
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
    #endif
    int n,m,r;
    cin>>n>>m>>r;
    vvii graph(n);
    F(i,0,m){
        int u,v,w;
        cin>>u>>v>>w;
        graph[u].push_back(ii(v,w));
    }
    // bellman ford
    vi dist(n,INF);
    dist[r]=0;
    F(k,0,n){
        // relax every edge
        F(u,0,n){
            for(ii e: graph[u]){
                int v,w;
                tie(v, w) = e;
                if(dist[u]<INF)
                    dist[v]=min(dist[v],dist[u]+w);
            }
        }
    }
    vi dist2(dist);
    F(u,0,n){
            for(ii e: graph[u]){
                int v=e.first,w=e.second;
                if(dist[u]<INF)
                    dist2[v]=min(dist[v],dist[u]+w);
            }
        }
    if(dist!=dist2){
        cout<<"NEGATIVE CYCLE\n";
    } else {
        F(i,0,n){
            if(dist[i]==INF) cout<<"INF";
            else cout<<dist[i];
            if(i<n-1) cout<<"\n";
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 3196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Sample27
{
    public static void Main()
    {
        List<int> data = new List<int>();
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        
        //行を処理
        for (int i = 0; i < input[0]; i++)
        {
            var rowList = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for(int j = 0; j < input[1]; j++)
            {
                data.Add(rowList[j]);
            }
        }

        for (int k = 0; k < input[0]; k++)
        {
            int rowTotal = 0;
            for(int m = 0; m < input[1]; m++)
            {
                Console.Write(data[k * input[1] + m] + " ");
                rowTotal += data[k * input[1] + m];
            }
            Console.WriteLine(rowTotal);
        }
        
        int columnTotal = 0;
        for(int n = 0; n < input[1]; n++)
        {
            int r = 0;
            for (int p = 0; p < input[0]*input[1]; p+=input[1])
            {
                r += data[p + n];
            }
            Console.Write(r+" ");
            columnTotal += r;
        }
        Console.WriteLine(columnTotal);
    }
}


Measured memory_bytes: 18424
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int ans = 0;
		boolean[] flags = new boolean[n + 1];
		int[] number = new int[n + 1];
		for(int i = 1; i <= n; i++)
			number[i] = sc.nextInt();
		int right = 1;
		
		while(right != 2) {
			if (flags[right]) {
				ans = -1;
				break;
			}
			flags[right] = true;
			ans++;
			right = number[right];
		}
		out.println(ans);

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 24136
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a<=b && b<=c) printf("%d %d %d\n",a,b,c);
  else if(b<=a && a<=c)  printf("%d %d %d\n",b,a,c);  
  else if(a<=c && c<=b)  printf("%d %d %d\n",a,c,b);  
  else if(c<=a && a<=b)  printf("%d %d %d\n",c,a,b);  
  else if(b<=c && c<=a)  printf("%d %d %d\n",b,c,a);
  else if(c<=b && b<=a)  printf("%d %d %d\n",c,b,a);

  return 0;
}

Measured memory_bytes: 1024
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;

#define int long long

int ret[N][2] , A[N] , n , Ps[N];

bool Check(int x, int id, int f){
      int num1 = n - id + 1 - f;
      int num2 = f;
      int y = A[id + f - 1] - x;
      if(id + f - 1 > n)
            y = 0;
      int xx = lower_bound(A + 1 , A + n + 1 , x - y) - A;
      num2 += id - xx;
      //cout << id << " " << A[id] - y << " " << y << endl;
      if(num2 <= num1)
            return true;
      return false;
}
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int q; cin >> n >> q;
      for(int i = 1; i <= n; i++)
            cin >> A[i];
      sort(A + 1, A + n + 1);
      for(int i = 1 ; i <= n ; i++){
            Ps[i] = Ps[i - 1] + A[i];
            ret[i][0] = ret[i - 1][0];
            ret[i][1] = ret[i - 1][1];
            if(i % 2 == 0)
                  ret[i][0] += A[i];
            else
                  ret[i][1] += A[i];
      }
      for(int i = 1; i <= q; i++){
            int x; cin >> x;
            if(x >= A[n]){
                  cout << ret[n][n % 2] << "\n";
                  continue;
            }
            int id = lower_bound(A + 1, A + n + 1, x) - A;
            int l = 0, r = n - id + 2;
            while(r - l > 1){
                  int mid = (r + l) / 2;
                  if(Check(x, id, mid))
                        l = mid;
                  else
                        r = mid;
            }
            //cout << l << endl << endl;
            long long Ans = Ps[n] - Ps[id + l - 1];
            x = 2 * id - 2 + 2 * l - n;
            Ans += ret[x][x % 2];
            cout << Ans << '\n';
      }
      return 0;
}



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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;

int n;

int32_t main(){
	fastio;
	cin>> n;
	vi v(n, 0);
	for(int i = 0 ; i<n-1; ++i){
		int aux;
		cin>> aux;
		v[aux-1]++;
	}
	for(auto i: v) cout<< i<< endl;
	return 0;
}


Measured memory_bytes: 3988
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		run();
	}

	static void run() {
		new Main().solver();
	}

	long MOD = 1_000_000_009;

	void solver() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			long w = sc.nextLong(), h = sc.nextLong();
			int n = sc.nextInt();
			if (w == 0 && h == 0 && n == 0)
				break;
			long[][] obs = new long[n][2];
			for (int i = 0; i < n; i++) {
				obs[i] = new long[] { sc.nextLong() - 1, sc.nextLong() - 1 };
			}
			Arrays.sort(obs, new Comparator<long[]>() {
				@Override
				public int compare(long[] o1, long[] o2) {
					return Long.compare(o1[1], o2[1]);
				}
			});
			long[][] ans = new long[(int) w][1];
			ans[0][0] = 1;
			long[][] A = new long[(int) w][(int) w];
			for (int i = 0; i < w; i++) {
				if (i < w - 1) {
					A[i][i + 1] = 1;
					A[i + 1][i] = 1;
				}
				A[i][i] = 1;
			}
			long cur_y = 0;
			for (int i = 0; i < n; i++) {

				ans = MtPow(obs[i][1] - cur_y, A, ans);
				// tr(ans);
				cur_y = obs[i][1];
				ans[(int) obs[i][0]][0] = 0;
			}
			ans = MtPow((h - 1) - cur_y, A, ans);
			System.out.println("Case " + (count++) + ": " + ans[(int) w - 1][0]);
		}
	}

	int count = 1;

	long[][] MtPow(long n, long[][] A, long[][] v) {
		for (; n > 0; n = n >> 1) {
			if ((n & 1) == 1)
				v = MtPrd(A, v);
			A = MtPrd(A, A);
		}
		return v;
	}

	long[][] MtPrd(long[][] A, long[][] B) {
		long[][] C = new long[A.length][B[0].length];
		for (int i = 0; i < A.length; i++) {
			for (int j = 0; j < B[0].length; j++) {
				for (int k = 0; k < A[0].length; k++) {
					C[i][j] += A[i][k] * B[k][j] % MOD;
					C[i][j] %= MOD;
				}
			}
		}
		return C;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

int main(void){
  int n, a, b, c, x, ind, cnt, i;
  int ylst[100];
  while(1){
    cin >> n >> a >> b >> c >> x;
    if(n == 0) break;
    for(i=0;i<n;i++) cin >> ylst[i];
    ind = 0;
    cnt = -1;
    while(ind < n and cnt <= 10000){
      if(x == ylst[ind]) ind++;
      x = (a * x + b) % c;
      cnt++;
    }
    if(cnt <= 10000){
      cout << cnt << endl;
    }else{
      cout << -1 << endl;
    }
  }
  return 0;
}



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

int a[300005],b[300005];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	if(n%2==0)
	{
		int t=1;
		for(int i=n/2+1;i<=n;i++)
		b[i]=a[t],t+=2;
		t=2;
		for(int i=n/2;i>=1;i--)
		b[i]=a[t],t+=2;
	}
	else
	{
		int t=2;
		for(int i=n/2+2;i<=n;i++)
		b[i]=a[t],t+=2;
		t=1;
		for(int i=n/2+1;i>=1;i--)
		b[i]=a[t],t+=2;
	}
	for(int i=1;i<=n;i++)
	printf("%d ",b[i]);
}


Measured memory_bytes: 3712
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int n = sc.nextInt();
      	n = 100 * (10 - n);
      	int k = sc.nextInt();
      	if(n > 0) k += n;
      
      	System.out.println(k);      	        
	}
}

Measured memory_bytes: 35824
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[500000];
int main()
{
    int n,k;
    int sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3608
from collections import Counter
n = int(input())

l = [input() for i in range(n)]
l.sort()
c = Counter(l)

max = c.most_common()[0][1]
outs = []
for k, v in c.most_common():
    if v == max:
        outs.append(k)

outs.sort()
for out in outs:
    print(out)

Measured memory_bytes: 45080
import sys
sys.setrecursionlimit(10**6)# 各頂点ごとに所属する木の大きさを計算する
N,Q = map(int,input().split())

E = [[] for _ in range(N+1)]
visited = [False for _ in range(N+1)]
Node_len = [1 for _ in range(N+1)]

for i in range(N-1):
    a,b = map(int,input().split())
    E[a].append(b)
    E[b].append(a)

AS = [0 for i in range(N+1)]
def dfs(node,parent=-1):
    for child in E[node]:
        if child == parent:
            continue
        AS[child] += AS[node]
        dfs(child,node)

for q in range(Q):
    p,x = map(int,input().split())
    AS[p] += x

dfs(1)
print(*AS[1:])




Measured memory_bytes: 287500
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
k = int(input())
sum=0
for i in range(1,k+1):
  for j in range(i+1,k+1):
    for l in range(j+1,k+1):
      sum+=6*gcd(i,j,l)
for i in range(1,k+1):
  for j in range (1,k+1):
    sum+=3*gcd(i,j)
sum-=k*(k+1)
print(sum)

Measured memory_bytes: 9640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e15;

int arr[N];
int n, s;
int query = 1;
void print(int ret)
{
    cout << "Case #" << query++ << ": " << ret << endl;
}

int DP[3005][3005];

int f(int idx, int left)
{
	if(left < 0) return 0;
	if(left == 0)
	{
		return n - idx + 2;
	}
	if(idx == n + 1) return 0;
	int & ret = DP[idx][left];
	if(~ret) return ret;
	return ret = (f(idx + 1, left) + f(idx + 1, left - arr[idx])) % 998244353;
}

void solve()
{
	cin >> n >> s;
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	int ret = 0;
	memset(DP, -1, sizeof(DP));
	for(int i = 1; i <= n; i++)
	{
		ret += f(i, s);
      ret %= 998244353;
	}
	cout << ret << endl;
}

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

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 72064