akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;

signed main() {
	cin >> n;
	if (n % 10 == 3)cout << "bon" << endl;
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)cout << "pon" << endl;
	else cout << "hon" << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b);
  Cin(string, s);

  bool ok = true;
  for (int i = 0; i < a + b + 1; ++i) {
    if (i == a) {
      if (s[i] != '-') ok = false;
    } else {
      if (!('0' <= s[i] && s[i] <= '9')) ok = false;
    }
  }
  puts(ok ? "Yes" : "No");

  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll n;
ll p[22222];
ll a[22222],b[22222],c[22222];
const ll m=20000;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		cin>>p[i];
		p[i]--;
	}
	rep(i,n){
		c[p[i]]=20010*m+i;
		a[i]=m*(i+1);
	}
	rep(i,n){
		b[i]=c[i]-a[i];
	}
	rep(i,n){
		printf("%lld%c",a[i],(i==n-1?'\n':' '));
	}
	rep(i,n){
		printf("%lld%c",b[i],(i==n-1?'\n':' '));
	}
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h> 
void func(int,int); 
int cnt,a,b,c;
int kou[17][17];
int main(void)  
{ 
	while(1){
		int i,j,x,y;
		scanf("%d %d",&a,&b); 
		if(a==0 && b==0) break;
		scanf("%d",&c);
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
				kou[i][j]=0;
			}
		}
		for(i=0;i<c;i++){
			scanf("%d %d",&x,&y);
			kou[y][x]=1;
		}	
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
    return 0; 
}   
void func(int yy,int xx) 
{ 
	if(xx==a&&yy==b){
		cnt++;
	}
	else {
		if(xx+1<=a&&kou[yy][xx+1]==0){
			func(yy,xx+1);
		}
		if(yy+1<=b&&kou[yy+1][xx]==0){
			func(yy+1,xx);
		}
	} 
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
using ll = long long;
using ld = long double;
long double pi = 2*acos(0.0);

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> g[n + 1];
    for(ll i = 1; i <= m; i++) {
        ll a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    unordered_set<ll> s;
    for(ll i = 2; i <= n; i++) s.emplace(i);
    ll ans[n + 1];
    queue<ll> q;
    q.push(1);
    while(!q.empty()) {
        ll ind = q.front();
        q.pop();
        for(ll i = 0; i < g[ind].size(); i++) {
            if(s.find(g[ind][i]) != s.end()) {
                q.push(g[ind][i]);
                ans[g[ind][i]] = ind;
                s.erase(g[ind][i]);
            }
        }
    }
    if(s.empty()) {
        cout << "Yes\n";
        for(ll i = 2; i <= n; i++) cout << ans[i] << "\n";
    }
    else cout << "No";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

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

	if (D == 25) { cout << "Christmas" << endl; }
	if (D == 24) { cout << "Christmas Eve" << endl; }
	if (D == 23) { cout << "Christmas Eve Eve" << endl; }
	if (D == 22) { cout << "Christmas Eve Eve Eve" << endl; }

	return 0;
}


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

pint nxt[6][6]={
    {{-1,-1},{2,6},{2,3},{2,4},{2,1},{-1,-1}},
    {{1,5},{-1,-1},{1,3},{1,4},{-1,-1},{1,2}},
    {{1,4},{1,2},{-1,-1},{-1,-1},{1,5},{1,3}},
    {{1,3},{1,2},{-1,-1},{-1,-1},{1,5},{1,4}},
    {{1,2},{-1,-1},{1,3},{1,4},{-1,-1},{1,5}},
    {{-1,-1},{2,1},{2,3},{2,4},{2,6},{-1,-1}}
};
pint nxt2[6][6]={
    {{-1,-1},{3,2},{3,6},{3,1},{3,5},{-1,-1}},
    {{3,1},{-1,-1},{3,5},{3,2},{-1,-1},{3,6}},
    {{2,1},{2,4},{-1,-1},{-1,-1},{2,3},{2,6}},
    {{2,1},{2,3},{-1,-1},{-1,-1},{2,4},{2,6}},
    {{3,1},{-1,-1},{3,2},{3,5},{-1,-1},{3,6}},
    {{-1,-1},{3,2},{3,1},{3,6},{3,5},{-1,-1}}
};
int dir[6][6]={
    {-1,3,2,0,1,-1},
    {3,-1,0,2,-1,1},
    {3,2,-1,-1,0,1},
    {3,0,-1,-1,2,1},
    {3,-1,2,0,-1,1},
    {-1,3,0,2,1,-1}
};
int dir2[6][6]={
    {-1,0,3,1,2,-1},
    {2,-1,3,1,-1,0},
    {0,3,-1,-1,1,2},
    {2,3,-1,-1,1,0},
    {0,-1,3,1,-1,2},
    {-1,2,3,1,0,-1}
};
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int h[50][50],num[50][50];
int cnt[6];
int main(){
    int n;
    while(cin>>n,n){
        int x=25,y=25;
        int t,f;
        memset(h,0,sizeof(h));
        memset(num,-1,sizeof(num));
        memset(cnt,0,sizeof(cnt));
        rep(i,n){
            int x=25,y=25;
            cin>>t>>f;
            --t,--f;
            while(1){
                int nx=x+dx[dir[t][f]],ny=y+dy[dir[t][f]];
                if(h[y][x]<=h[ny][nx]){
                    nx=x+dx[dir2[t][f]],ny=y+dy[dir2[t][f]];
                    if(h[y][x]<=h[ny][nx])break;
                    y=ny,x=nx;
                    int nt=nxt2[t][f].first-1,nf=nxt2[t][f].second-1;
                    t=nt,f=nf;
                }
                else{
                    y=ny,x=nx;
                    int nt=nxt[t][f].first-1,nf=nxt[t][f].second-1;
                    t=nt,f=nf;
                }
            }
            ++h[y][x];num[y][x]=t;
        }
        rep(i,50)rep(j,50){
            if(num[i][j]!=-1) ++cnt[num[i][j]];
        }
        rep(i,6){
            cout<<cnt[i]<<(i==5?"":" ");
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    StringBuffer s = new StringBuffer(sc.next());
    StringBuffer t = new StringBuffer(sc.next());
    for(int i=0;i<s.length();i++){
      for(int j=i;j>0;j--){
        if(s.charAt(j)<s.charAt(j-1)){
          char temp = s.charAt(j);
          s.setCharAt(j,s.charAt(j-1));
          s.setCharAt(j-1,temp);
        }else{
          break;
        }
      }
    }
    for(int i=0;i<t.length();i++){
      for(int j=i;j>0;j--){
        if(t.charAt(j)>t.charAt(j-1)){
          char temp = t.charAt(j);
          t.setCharAt(j,t.charAt(j-1));
          t.setCharAt(j-1,temp);
        }else{
          break;
        }
      }
    }
    if(s.toString().compareTo(t.toString())<0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	int temp=0;
	int b;
	int c;
	int x;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	{
		if (i*500+j*100+k*50==x)
		temp++;
	}
	cout<<temp;
	return 0;
}

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

using namespace std;

#define MAX 15010
typedef pair<int,int> pii;
typedef pair<pii,int> P;

bool check(int a,int b,int c){
  if(a >= b+c || b >= a+c || c >= a+b) return false;
  return true;
}

int main(){
  vector<int> prime;
  bool p[MAX];
  fill(p,p+MAX,true);
  p[0] = p[1] = false;
  for(int i = 2 ; i < MAX ; i++){
    if(!p[i]) continue;
    prime.push_back(i);
    for(int j = 2*i ; j < MAX ; j += i){
      p[j] = false;
    }
  }
  int T;
  while(cin >> T, T){
    int cnt = 0;
    set<P> st;
    int size = prime.size();
    for(int i = 0 ; i < size ; i++){
      if(prime[i] > T) continue;
      for(int j = i ; j < size ; j++){
        if(prime[i]+prime[j] > T) continue;
        int k = T-prime[i]-prime[j];
        if(k < 0 || k >= MAX || !p[k]) continue;
        int a[3] = {prime[i],prime[j],k};
        sort(a,a+3);
        if(st.count(P(pii(a[0],a[1]),a[2]))) continue;
        st.insert(P(pii(a[0],a[1]),a[2]));
        if(check(a[0],a[1],a[2])){
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 7488
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const ll maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
ll n,k,a,b,c,d,m,num[maxn];
string str;
int main()
{
    cin >> n;
    ll ans = n / 500 * 1000;
    n = n % 500;
    ans += n / 5 * 5;
    cout << ans << endl;
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

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

    ll D, G;
    cin >> D >> G;

    ll p[D], c[D];
    rep(i, D){
        cin >> p[i] >> c[i];
    }


    int ans = INF;
    for(int mask = 0; mask < (1 << D); ++mask){
        int sum = 0, cnt = 0, unsolved = -1;
        rep(i, D){
            if(mask >> i & 1){
                sum += 100 * (i+1) * p[i] + c[i];
                cnt += p[i];
            }
            else{
                unsolved = i;
            }
        }

        if(sum < G){
            int point = 100 * (unsolved + 1);
            if((G-sum+point-1)/point >= p[unsolved]){
                continue;
            }
            cnt += (G-sum+point-1)/point;
        }
        ans = min(ans, cnt);

    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int,int>> A(N);
  rep(i,N){
    cin >> A.at(i).fi >> A.at(i).se;
    A.at(i).fi--;
    A.at(i).se--;
  }

  vector<pair<int,int>> B = A;
  sort(all(B));
  dsu UF(N);

  set<int> S;
  S.insert(N);
  for(int i=N-1;i>=0;i--){
    int y = B.at(i).se;
    auto it = S.upper_bound(y);
    debug(y);
    debug(*it);
    if(*it != N) UF.merge(y,*it);
    S.insert(y);
  }

  set<int> S2;
  S2.insert(N);
  rep(i,N){
    int y = -B.at(i).se;
    auto it = S2.upper_bound(y);
    debug(y);
    debug(*it);
    if(*it != N) UF.merge(-y,-(*it));
    S2.insert(y);
  }

  int mx=-1;
  for(int i=N-1;i>=0;i--){
    int y = B.at(i).se;
    if(mx > y) UF.merge(y,mx);
    chmax(mx,y);
  }

  int mi=N;
  rep(i,N){
    int y = B.at(i).se;
    if(mi < y) UF.merge(y,mi);
    chmin(mi,y);
  }

  rep(i,N)  cout << UF.size(A.at(i).se) << endl;

  return 0;
}

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

const int lim = 1e7+100;
int num_div[lim];
void sieve(int lim){
	for(int i=1;i<lim;i++){
		for(int j=i;j<lim;j+=i){
			num_div[j]++;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	sieve(n+10);

	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=1ll*i*num_div[i];
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 42704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	ll n;
	std::cin >> n;
	std::vector<ll> a(n);
	rep(i,n)std::cin >> a[i];
	ll ans1=0,ans2=0;
	ll sum=0;
	ll han=-1;
	rep(i,n){
		han*=-1;
		sum+=a[i];
		if(han<0){
			ans1+=max(0ll,sum+1);
			sum-=max(0ll,sum+1);
		}else{
			ans1-=min(0ll,sum-1);
			sum-=min(0ll,sum-1);
		}
//		std::cout << ans1 << std::endl;
	}
	han=1;sum=0;
	rep(i,n){
		han*=-1;
		sum+=a[i];
		if(han<0){
			ans2+=max(0ll,sum+1);
			sum-=max(0ll,sum+1);
		}else{
			ans2-=min(0ll,sum-1);
			sum-=min(0ll,sum-1);
		}
//		std::cout <<sum<<' '<< ans2 << std::endl;
	}
	std::cout << min(ans1,ans2) << std::endl;
}






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

n_minus = 0
n_zero = 0
for x in a:
  if x == 0:
    n_zero += 1
  elif x < 0:
    n_minus += 1
r = 0
for x in a:
    r += abs(x)
if n_zero == 0 and n_minus % 2 == 1:
  e = abs(a[0])
  for x in a:
  	e = min(e, abs(x))  
  r -= e * 2
print(r)

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL
// {{{ define basic macro
// #define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

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

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii, vii, greater<pii> > spq;  //pop, topで最小値
int dx[]={1, -1, 0, 0, 0};
int dy[]={0, 0, 1, -1, 0};
//}}}


int solve(){
  int n;cin>>n;
  int res=0;
  rep(i, n){
    res += in()-1;
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        char c = S.charAt(0);
        int ans = 0;
        for (int i = 1; i < S.length(); i++) {
            if(c != S.charAt(i)){
               ans++;
               c = S.charAt(i);
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 24020
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int N, A, B, rings[100], G[100][100]; bool used[100];

int rec(int pos)
{
	int ret = 1; used[pos] = true;

	for(int i = 0; i < rings[pos]; i++)
	{
		int r = G[pos][i];
		
		if(!used[r])
		{
			ret = max(ret, rec(r) + 1);
		}
	}

	used[pos] = false;

	return ret;
}

int main()
{
	int N, A, B;

	while(true)
	{
		scanf("%d", &N);
 
		if(N == 0) { break; }

		for(int i = 0; i < 100; i++)
		{
			used[i] = false;
			rings[i] = 0;
		}

		for(int i = 0; i < N; i++)
		{
			scanf("%d", &A); A--;
			scanf("%d", &B); B--;

			G[A][rings[A]] = B; rings[A]++;
			G[B][rings[B]] = A; rings[B]++;
		}

		int nodes = 0;

		for(int i = 0; i < 100; i++)
		{
			if(rings[i])
			{
				nodes++;
			}
		}

		int ret = 0;

		for(int i = 0; i < 100; i++)
		{
			ret = max(ret, rec(i));

 			if(ret == nodes) break;
		}
 
		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 3140
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
a, b, m = gets.split.map(&:to_i)
a_prices = gets.split.map(&:to_i)
b_prices = gets.split.map(&:to_i)
tickets = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }

after_prices = tickets.map do |ticket|
  a_prices[ticket[0] - 1] + b_prices[ticket[1] - 1] - ticket[2]
end

normal_lowest = a_prices.min + b_prices.min
after_prices_min = after_prices.min

if after_prices_min >= normal_lowest
  puts normal_lowest
else
  puts after_prices_min
end


Measured memory_bytes: 33676
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int x1, x2, x3;
    x1 = min(a, min(b, c));
    x3 = max(a, max(b, c));
    x2 = a+b+c-x1-x3;
    if(x3-x2 == x2-x1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
    $s = trim(fgets(STDIN));
    $array = [];
    $array_sta =[];
    array_push($array, substr($s, 0, 2));
    array_push($array, substr($s,2,2));

    // 前半2桁の判別
    if((int)$array[0] <= 12 && (int)$array[0] >= 1 ){
        array_push($array_sta, "MM");
    }else{
        array_push($array_sta, 'YY');
    }

    if((int)$array[1] <= 12 && (int)$array[1] >= 1 ){
        array_push($array_sta, "MM");
    }else{
        array_push($array_sta, 'YY');
    }

    if(($array_sta[0] === "YY" && $array_sta[1] === "MM") ||  ($array_sta[0] === "MM" && $array_sta[1] === "YY")){
        if($array_sta[0] === "YY"){
            echo "YYMM\n";
        } else{
            echo "MMYY\n";
        }
    }elseif($array_sta[0] === "MM" | $array_sta[1] === "MM"){
        echo "AMBIGUOUS\n";
    }else{
        echo "NA\n";
    }

?>

Measured memory_bytes: 4728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        char[] inputs = reader.readLine().toCharArray();

        boolean isGood = false;
        for (int i = 0; i < 2; i++) {
            if (inputs[i] == inputs[i + 1] && inputs[i + 1] == inputs[i + 2]) {
                isGood = true;
            }
        }

        if(isGood) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 22996
main = do 
    _ <- getLine
    arr <- map (read :: String -> Int). words <$> getLine
    putStrLn $ if (solve 0 arr) then "Yes" else "No"
    where
        solve p [] = True
        solve p (x:xs) = 
            if x + 1 < p
            then
                False
            else
                if x < p
                    then
                        solve (x + 1) xs
                    else
                        solve x xs


Measured memory_bytes: 36220
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
  
  int N;
  cin >> N;
  if(N % 2 == 0)
  {
      cout << 0.5 << endl;
      return 0;
  }

  cout << ((double)(N / 2 + 1) / (double)((N / 2) + (N / 2 + 1))) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define MO 1000000007
using namespace std;
int n,m,K;
int C[2005][2005];
void solve(){
	C[1][1]=1;
	for(int i=2;i<=2000;i++)
		for(int j=1;j<=i;j++){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MO;
		}
	scanf("%d %d",&n,&K);
	for(int i=1;i<=K;i++){
		int ans=C[K][i];
		ans=1LL*ans*C[n-K+2][i+1]%MO;
		printf("%d\n",ans);
	}
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 15104
package main

import "fmt"

func main() {
	var s, prev int
	prev = -1
	for i := 0; i < 4; i++ {
		fmt.Scanf("%1d", &s)
		if prev == -1 {
			prev = s
		} else {
			if s == prev {
				fmt.Println("Bad")
				return
			}
			prev = s
		}
	}

	fmt.Println("Good")
}


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

int search(int a[],int n,int key) {
	int i = 0;
	a[n] = key;
	while (a[i] != key) i++;
	return i != n;
}

int main() {
	int n, s[10000], q, key, sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> s[i];
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(s, n, key)) sum++;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3120
n,c=map(int,input().split())
stc=[[] for i in range(c+1)]
a=[]
t=0
for i in range(n):
    p=[int(j) for j in input().split()]
    stc[p[2]].append([p[0],p[1]])
    t=max(t,p[1])
ans=10**100
for i in range(c+1):
    p=10**10
    stc[i].sort()
    for j in range(len(stc[i])):
        if j+1<len(stc[i]):
            if stc[i][j][1]==stc[i][j+1][0]:
                if p==10**10:
                    p=stc[i][j][0]
            else:
                if p!=10**10:
                    a.append([p,stc[i][j][1]])
                else:
                    a.append([stc[i][j][0],stc[i][j][1]])
                p=10**10
        else:
            if p!=10**10:
                a.append([p,stc[i][j][1]])
            else:
                a.append([stc[i][j][0],stc[i][j][1]])

table=[0]*(t+1)
for i in range(len(a)):
    table[a[i][0]-1]+=1
    table[a[i][1]]-=1
for i in range(1,t+1):
    table[i]+=table[i-1]

print(max(table))




Measured memory_bytes: 30716
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
int n,mod,jc[6010],iv[6010];
int dp[6010][12010],tmp,d2,ans;
void update(int &x,int y) { x+=y; if (x>=mod) x-=mod; }
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(mod);
	jc[0]=iv[0]=jc[1]=iv[1]=1;
	for (int i=2;i<=n*3;i++) {
		jc[i]=(ll)jc[i-1]*i%mod;
		iv[i]=(ll)(mod-mod/i)*iv[mod%i]%mod;
	}
	dp[0][0]=1;
	for (int s=0;s<n*3;s++)
	for (int d=-s;d<=s;d++) {
		if (!dp[s][d]) continue;
		for (int i=1;i<=3;i++) {
			if (s+i>n*3) continue;
			d2=d;
			if (i==1) d2++;
			if (i==2) d2--;
			if (-(s+i)<=d2&&d2<=s+i) {
				tmp=(ll)dp[s][d]*iv[s+i]%mod;
				update(dp[s+i][d2],tmp);
			}
		}
	}
	for (int d=0;d<=n*3;d++) update(ans,dp[n*3][d]);
	printf("%d\n",(ll)ans*jc[n*3]%mod);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 279808
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[114514];
int main()
{
	int n;cin>>n;rep(i,n) cin>>a[i];
	sort(a,a+n);
	if(a[n-1]>a[0]+1){
		cout<<"No"<<endl;return 0;
	}
	if(a[n-1]==a[0]){
		if(n==a[0]+1 || n>=2*a[0]){
			cout<<"Yes"<<endl;
		}
		else cout<<"No"<<endl;
		return 0;
	}
	int N=a[0],x=0,y=0;
	rep(i,n){
		if(a[i]==a[0]) x++;else y++;
	}
	if(N+1-x>=1 && y>=2*(N+1-x)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int n, a[505][505], ans, f[505][505];
int dx[]={1, 0, 0, -1};
int dy[]={0, 1, -1, 0};
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			f[i][j]=min(i-1, min(n-i, min(j-1, n-j)))+1;
			a[i][j]=1;
		}
	}
	for(int i=1;i<=n*n;i++) {
		int num=read();
		int x=(num-1)/n+1, y=(num-1)%n+1;
		queue<pair<int,int> > q;
		a[x][y]=0, f[x][y]--, q.push({x,y});
		ans+=f[x][y];
		while(!q.empty()) {
			int ux=q.front().first, uy=q.front().second; q.pop();
			for(int k=0;k<4;k++) {
				int xx=ux+dx[k];
				int yy=uy+dy[k];
				if(xx<1||yy<1||xx>n||yy>n) continue;
				if(f[ux][uy]+a[xx][yy]<f[xx][yy]) {
					f[xx][yy]=f[ux][uy]+a[xx][yy];
					q.push({xx, yy});
				}
			}
		} 
	}
	cout<<ans;
}


Measured memory_bytes: 5572
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;
//bool comp(
//
//	st pll &a, const pll &b) {
//	return a.first < b.first;
//}
//std::vector<int> enum_div(int n)//nの約数を列挙
//{
//	std::vector<int> ret;
//	for (int i = 1; i*i <= n; ++i)
//	{
//		if (n%i == 0)
//		{
//			ret.push_back(i);
//			if (i != 1 && i*i != n)
//			{
//				ret.push_back(n / i);
//			}
//		}
//	}
//	return ret;
//}

template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}

int main()
{
	priority_queue<int> q;
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	string s = {};
	char x[302][302] = {};
	ll y[302][302] = {};

	cin >> h;
	cin >> w;
	cin >> a;
	cin >> b;
	if (a-h>0)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;

	}
	
	//cout<<factorial<10><<endl;

	//cin >> a >> b;
	//for (int i = 0; i < a; i++)
	//{
	//	cin >> s[i];
	//	if (s[i] >= b)
	//	{
	//		ans++;
	//	}
	//}

	//cout << ans << endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

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

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func sum(f [][]int, x, y, dx, dy int) int {
	K := len(f)
	var ans int
	if x+dx > K {
		ans += sum(f, 0, y, (x+dx)%K, dy)
		dx = K - x
	}
	if y+dy > K {
		ans += sum(f, x, 0, dx, (y+dy)%K)
		dy = K - y
	}

	x2 := x + dx - 1
	y2 := y + dy - 1

	ans += f[x2][y2]
	if y > 0 {
		ans -= f[x2][y-1]
	}
	if x > 0 {
		ans -= f[x-1][y2]
	}
	if x > 0 && y > 0 {
		ans += f[x-1][y-1]
	}
	return ans
}

func main() {
	defer stdout.Flush()
	n := readInt()
	k := readInt()

	K := 2 * k
	f := make([][]int, K)
	for i := 0; i < K; i++ {
		f[i] = make([]int, K)
	}

	for i := 0; i < n; i++ {
		x := readInt() % (2 * k)
		y := readInt() % (2 * k)
		c := readString()
		if c == "W" {
			y += k
		}
		f[x%K][y%K]++
	}

	for i := 0; i < K; i++ {
		for j := 0; j+1 < K; j++ {
			f[i][j+1] += f[i][j]
		}
	}

	for i := 0; i < K; i++ {
		for j := 0; j+1 < K; j++ {
			f[j+1][i] += f[j][i]
		}
	}

	max := 0
	for i := 0; i < K; i++ {
		for j := 0; j+1 < K; j++ {
			v := sum(f, i, j, k, k) + sum(f, (i+k)%K, (j+k)%K, k, k)
			if max < v {
				max = v
			}
		}
	}

	println(max)
}


Measured memory_bytes: 37120
#include<bits/stdc++.h>
using namespace std;
#define ll long long int


//ll a[100005];
//vector<ll> cache(100005,-1);
//ll n;
//
//ll frog1(ll x)
//{
//	if(cache[x]!=-1)
//		return cache[x];
//	if(x>=n)
//		return INT_MAX;
//	if(x==n-1)
//		return 0;
//	else
//		return cache[x] = min( abs(a[x+1]-a[x])+frog1(x+1), abs(a[x+2]-a[x])+frog1(x+2));
//}
//
//int main()
//{
//	cin>>n;
//	for(int i=0;i<n;i++)
//	{
//		cin>>a[i];
//	}
//	cout<<frog1(0);
//	return 0;
//}

int main()
{
	ll n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		a.push_back(x);
	}
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+2;j++)
		{
			if(j<n)
				dp[j] = min(dp[j],dp[i] + abs(a[j]-a[i]));
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;

int main(void){
	vector<int> vi = vector<int>();
	
	for(int i = 0;i < 3; ++i){
		int tmp;
		cin >> tmp;
		vi.push_back(tmp);
	}
	
	stable_sort(vi.begin(),vi.end());

	for(vector<int>::iterator it = vi.begin(); it != vi.end();){
		cout << *it;
		++it;
		if(it != vi.end()){
			cout << " ";
		}
	}	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {
	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {
		// String[] stringline = new String[10];
		int[][] intline = new int[10][10];

		/*
		 * for(int i=0;i<10;i++){ stringline[i]=""; } for(int i=0;i<10;i++){
		 * for(int j=0;j<10;j++){ intline[i][j]=0; } }
		 */

		while (sc.hasNext()) {
			String str = "";
			str = sc.nextLine();
			String[] stringline = str.split("");

			for (int j = 0; j < 10; j++) {
				intline[0][j] = Integer.parseInt(stringline[j]);
			}
			for (int i = 1; i < 10; i++) {
				for (int j = 0; j < 9; j++) {
					intline[i][j] = (intline[i - 1][j] + intline[i - 1][j + 1]) % 10;
				}
			}
			System.out.println(intline[9][0]);
		}

		
	}

}

Measured memory_bytes: 26116
#include <stdio.h>
#include <string.h>

int main(){
  int N;
  char S[10002];
  scanf("%d\n%s",&N,S);
  
  int L=strlen(S);
  for(int i=0;i<L;i++){
    printf("%c",((S[i]-'A'+N)%26)+'A');
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1644
let n, m, x = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let a_s = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let ans = Array.make 2 0
let _ =
  for i = 0 to m - 1 do
    if a_s.(i) < x then ans.(0) <- ans.(0) + 1
    else ans.(1) <- ans.(1) + 1 done;
  min ans.(0) ans.(1) |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;

int main() {
	int y;
	cin >> y;
	
	if (y == 7 || y == 5 || y == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    cout<<(a == b? c: (a == c ? b : a))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	string s; cin >> s;
	int n = s.size(), b = n - 1, w = 0, cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'B') {
			cnt += b - i;
			b--;
		}
		else {
			cnt += i - w;
			w++;
		}
	}
	cout << cnt / 2 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;



public class Main {
	
	int d[];
	boolean used[];
	int g[][];
	final int INF = 1 << 28;
	
	int die(int s, int n){
		used = new boolean[n];
		d = new int[n];
		for(int j=0; j<n; ++j){ d[j] = INF; }
		
		d[s] = 0;
		while(true){
			int u = -1;
			for(int v=0; v<n; ++v){
				if(!used[v]){
					if(u==-1){
						u = v;
					}else if(d[v] < d[u]){
						u = v;
					}
					
				}
			}
			if(u==-1){ break; }
			used[u] = true;
			for(int v=0; v<n; ++v){
				if(d[v] > d[u] + g[u][v]){
					d[v] = d[u] + g[u][v];
				}
			}
		}
		int val = 0;
		for(int i=0; i<n; ++i){
			val += d[i];
		}
		return val;
	}
	
	void io(){
		java.util.Scanner sc = new Scanner(System.in);
		while(true){
			int max = 0;	//町の数最大値
			g = new int[10][10];
			for(int i=0; i<10; ++i){
				for(int j=0; j<10; ++j){
					g[i][j] = i==j ? 0 : INF;
				}
			}
			final int n = sc.nextInt();
			if(n==0){return;}
			for(int i=0; i<n; ++i){
				final int a = sc.nextInt();  final int b = sc.nextInt();  final int c = sc.nextInt();
				g[a][b] = c;
				g[b][a] = c;
				if(max < a+1){
					max = a+1;
				}
				if(max < b+1){
					max = b+1;
				}
			}
			
			
			int min = INF;
			int num = -1;
			for(int i=0; i<max; ++i){
				
				int res = die(i, max);
				if(res < min){
					min = res;
					num = i;
				}
			}
			System.out.println(num + " " + min);
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
}

Measured memory_bytes: 12000
///...................................*****.................................................///
///        Author :  Ankhoa                                                                 ///
///                  Department of Computer Science                                         ///
///                  & Algorithm                                                            ///
///                  Gia Dinh high school , Vietnam.                                        ///
///...................................*****.................................................///
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <cmath>
#include <sstream>
#include <set>
#include <list>
#include <map>
#include <stack>
using namespace std;
/*....................................Values................................................*/
#define       PI                   acos(-1)
#define       M                    1000000007
#define X first
#define Y second
#define ll long long
#define ull unsigned long long
#define ld long double
#define base 27ll
#define MAXN 1000010
#define MOD 1000000007ll
const int N = 2e5+6;
const int INF = 1e9 + 10;
const long double Pi = 3.141592653589793116, EPS = 1e-9, Gold = ((1+sqrt(5))/2);
/*....................................Functions.............................................*/
#define       sqr(x)               x*x
#define       min3(a,b,c)          min(a,min(b,c))
#define       max3(a,b,c)          max(a,max(b,c))
#define       all(v)               v.begin(), v.end()
#define       ok                   cout << "ok" << endl
#define       mem(x,y)             memset(x,y,sizeof(x))
#define       READ(f)              freopen(f, "r", stdin)
#define       WRITE(f)             freopen(f, "w", stdout)
/*.....................................Loops...............................................*/
#define       rep( i , a , b )     for( i=a ; i<b ; i++)
#define       rev( i , a , b )     for( i=a ; i>=b ; i--)
#define       repx( i ,a,b, x)     for( i=a ; i<b ; i+=x)

#define       FastRead             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
/*..................................Shutdown..............................................*/


typedef pair <int,int> ii;
map <int,int> lua;
// link : https://atcoder.jp/contests/dp/tasks/dp_p
vector <int> a[N];
long long u,v,f[N][2],n;
bool seen[N];
void dfs(long long u)
{
		seen[u] = true;
		for (int i = 0; i < a[u].size();i++)
		{
			 int v = a[u][i];
			 if (seen[v] == false)
			 {
			 	  dfs(v);
			 	  f[u][1] = (f[u][1] * f[v][0]) % MOD;
			 	  f[u][0] = (f[u][0] * ((f[v][1] + f[v][0]) % MOD)) % MOD;
			 }
		}
}
int main()
{
	FastRead;
	cin >> n;
	memset(seen,false,sizeof seen);
	for (int i = 1; i <= n-1; i++)
	{
		 cin >> u >> v;
		 a[u].push_back(v);
		 a[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {f[i][1]=1;f[i][0]=1;}
	dfs(1);
	cout << (f[1][1] + f[1][0]) % MOD;
	#ifdef HOME
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
	#endif
    return 0;
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007

ll n,dp[66][4][4];
string s1,s2;
ll solve(ll st,ll c1,ll c2){
   // cout<<st<<" "<<c1<<" "<<c2<<endl;
    if(dp[st][c1][c2]!=-1) return dp[st][c1][c2];
    ll& ret=dp[st][c1][c2];ret=0;
    if(s1[st] == s2[st] && c1!=c2)  return ret;
    if(s1[st] != s2[st] && c1 == c2) return ret;

    if(s1[st] == s2[st]){
        if(st == n) return ret=1;
        rep(j,1,3) rep(k,1,3){
            if(j == c1 || k == c1) continue;
            ret=(ret+solve(st+1,j,k))%M;
        }
        //cout<<st<<" "<<c1<<" "<<c2<<ret<<endl;
        return ret;
    }
    if(st == n-1) return ret=1;
    rep(j,1,3) rep(k,1,3){
        if(j == c1 || k == c2) continue;
        ret=(ret+solve(st+2,j,k))%M;
    }

       // cout<<st<<" "<<c1<<" "<<c2<<ret<<endl;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    cin>>s1>>s2;
    s1="$"+s1;s2="$"+s2;
    rep(i,1,n) rep(j,1,3) rep(k,1,3) dp[i][j][k]=-1;
    ll ans=0;
    rep(j,1,3) rep(k,1,3) ans=(ans+solve(1,j,k))%M;
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
#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)

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

#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 k,s; cin>>k>>s;
    ll ans=0;
    FOR(x,0,k)FOR(y,0,k){
        if (x+y>s) continue;
        if (s-(x+y)<=k) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
 char s[101],p[101],ss[202];
 int i,j;
scanf("%s", s);
scanf("%s", p);
strcat(ss,s);
strcat(ss,s);
if(strstr(ss,p)) printf("Yes\n");
else printf("No\n");
 return 0;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int ret(string s) {
    int p = 0;
    for (auto i:s) {
        p = (p*10) + i-'0';
    }
    return p;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string t;
    cin>>t;
  	int ans = mod;
	for (int i=0;i<(-2+t.size());i++) {
    	ans = min(ans,(int)abs(753-ret(t.substr(i,3))));
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,n, x;
    
    scanf("%d",&n);
    for(i=1; i<=n; i++) {
        x = i;
        if(x %3 == 0) {
            printf(" %d", i);//先頭に空白を出力
        }
        else
            if(x % 10 == 3) {
                printf(" %d", i);
            }
            else
                while(x != 0) {
                    x /=10;
                    if(x % 10 == 3) {
                        printf(" %d", i);
                        break;
            }
        }
        
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        scanner.close();

        if (A % K == 0 || B % K == 0) {
            System.out.println("OK");
            return;
        }

        if (A / K == B / K) {
            System.out.println("NG");
        } else {
            System.out.println("OK");
        }
    }
}


Measured memory_bytes: 35780
N = int(input())

cnt = 0
ans = "No"
for i in range(N):
    d1, d2 = list(map(int, input().split()))
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = "Yes"
        break

print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll dp[3001][3001];

bool dpbool[3001][3001];

string s,k;

vector <string> p;

ll seno(ll idx1, ll idx2)
{

if (dpbool[idx1][idx2]!=0)
return dp[idx1][idx2];	

if (idx1==0||idx2==0)
{
	return 0;
}	



if (s[idx1-1]==k[idx2-1])
{
	
	dp[idx1][idx2]=1+seno(idx1-1,idx2-1);
}
else
{

dp[idx1][idx2]=max(seno(idx1-1,idx2),seno(idx1,idx2-1));

}

dpbool[idx1][idx2]=1;
return dp[idx1][idx2];
}


bool compareLen(const std::string& a, const std::string& b)
{
    return (a.size() < b.size()); 
}



void print(ll m, ll n)
{


string lcs;

ll i = m, j = n; 
   while (i >0 && j >0) 
   { 
   
      if (s[i-1] == k[j-1]) 
      { 
          lcs.pb(s[i-1]); 
          i--; j--;     
      } 
  
      
      
      else if (dp[i-1][j] >= dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
reverse(lcs.begin(),lcs.end());
cout<<lcs;

}

int main() 
{ 



fastio();


cin>>s>>k;


ll x=s.length();
ll y=k.length();



memset(dpbool,0,sizeof(dpbool));

ll t=seno(x,y);




print(x,y);

return 0;
} 




Measured memory_bytes: 79744