akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */
ll dp[100010][13];
int main() {
	string s; cin >> s;
	reverse(all(s));
	for (int i = 0; i < s.size(); i++)
	{
		if (i == 0) {
			if (s[i] == '?') {
				for (int j = 0; j < 10; j++)
				{
					dp[0][j]++;
				}
			}
			else {
				dp[0][s[i] - '0']++;
			}
		}
		else {
			if (s[i] == '?') {
				for (long long j = 0; j < 10; j++)
				{
					long long m = (j*qp(10, i,13)) % 13;
					for (int k = 0; k < 13; k++)
					{
						dp[i][(m + k) % 13] += dp[i - 1][k];
						dp[i][(m + k) % 13] %= mod;
					}
				}
			}
			else {
				long long m = ((s[i] - '0') * qp(10, i,13)) % 13;
				for (int j = 0; j < 13; j++)
				{
					dp[i][(j + m) % 13] += dp[i - 1][j];
					dp[i][(j + m) % 13] %= mod;
				}
			}
		}
	
	}
	cout << dp[s.size() - 1][5] << endl;
	return 0;

}

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

bool square(int n) {
  int tmp = sqrt(n);
  return tmp * tmp == n;
}

int main() {
  int n, d;
  cin >> n >> d;
  
  int x[n][d];
  REP(i, n) {
    REP(j, d) {
      cin >> x[i][j];
    }
  }
  
  int ans = 0;
  REP(i, n) {
    for (int j = i + 1; j < n; ++j) {
      int dist = 0;
      REP(k, d)
        dist += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]);
      if (square(dist))
        ++ans;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
const int N=1e5+5;
int a[N],n,ans=0;bool vis[N];
void work()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			if(i==1)continue;
			if(a[i-1]==i-1 && !vis[i-1]){
				ans++;vis[i]=true;vis[i-1]=true;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(!vis[i] && a[i]==i)ans++;
	}
	printf("%d\n",ans);
}

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


Measured memory_bytes: 768
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
int n,a[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int main()
{
	n=getint();
	rep(i,1,n) a[i]=getint();
	sort(a+1,a+1+n);
	int x=1,y=0;
	rep(i,2,n)
		if(++x,a[x-1]>y+1)
			--x,++y;
		
	int tot=0;
	rep(i,1,x-1) if(a[i]==y+1) ++tot;
	if(((a[x]-y+1)&1) || tot&1) puts("First");
	else puts("Second");
	return 0;
}	

Measured memory_bytes: 512
N = int(input())
d = {'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(N):
    s = input()
    if s[0] in 'MARCH':
        d[s[0]] += 1
v = list(d.values())
ans = 0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += v[i]*v[j]*v[k]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int A, B;
    double x, y;
    scanf("%d %d", &A, &B);
    y = ((double)A+(double)B)/2;
    x = y - (int)y;

    if(x == 0)printf("%d", (int)y);
    else printf("IMPOSSIBLE");

}


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

using namespace std;

int main(void){
	string w[3] = {"Sunny","Cloudy","Rainy"};
	string s;
	cin >> s;
	for(int i=0;i<3;i++){
		if(w[i] == s){
			cout << w[(i+1)%3] << endl;
		}
	}
}

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

int main(){
    string S,T; cin>>S>>T;

    for(int i=0;i<S.length();i++){
        if(S==T){
            cout<<"Yes"<<endl;
            return 0;
        }
        S=S.back()+S.substr(0,S.size()-1);
    }
    cout<<"No"<<endl;
}

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

int main()
{

    char alpha[]={'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h','i',
                  'j', 'k', 'l', 'm', 'n','o','p','q','r','s','t',
                  'u', 'v', 'w', 'x', 'y'};

     ll n;
     cin>>n;
     string str="";
     while(n!=0)
     {
        ll temp=n%26;
        str=alpha[temp]+str;
        if(temp==0)
         n-=26;
         else
         n-=temp;
        n/=26;
     }     
     cout<<str;        
    return 0;
}

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

using ll = long long;

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

    ll n,m;cin>>n>>m;

    vector<ll> x(m);
    for(int i=0;i<m;i++)cin>>x[i];

    sort(x.begin(),x.end());

    vector<ll> dx(m-1);

    ll ans=0;
    for(int i=1;i<m;i++)
    {
        dx[i-1]=x[i]-x[i-1];
        ans+=dx[i-1];
    }

    sort(dx.begin(),dx.end(),greater<int>());

    for(int i=0;i<min(n-1,m-1);i++)ans-=dx[i];

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 4644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>

pll h[100010];

ll b[100010],l[100010],r[100010],pre[100010],n,m;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool check(ll mid)
{
	ll sum=0;
	for (int i=1;i<=n;i++) sum-=b[i]*l[i],h[i]=pll((m-b[i])*r[i]+b[i]*l[i],i);
	sort(h+1,h+n+1);reverse(h+1,h+n+1);
	for (int i=1;i<=n;i++) pre[i]=pre[i-1]+h[i].first;
	ll hh=mid/m,now=mid%m;
	for (int i=1;i<=n;i++)
	{
		ll res=sum+b[h[i].second]*l[h[i].second];
		if (i>hh) res+=pre[hh];
		else res+=pre[i-1]+(pre[hh+1]-pre[i]);
		if (now>=b[h[i].second]) res+=r[h[i].second]*(now-b[h[i].second]);
		else res-=l[h[i].second]*(b[h[i].second]-now);
		if (res>=0) return true;
	}
	return false;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++) b[i]=rd(),l[i]=rd(),r[i]=rd();
	ll l=0,r=(ll)n*m;
	while (l<r)
	{
		ll mid=(l+r)>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cstdio>
#include <cmath>

#define DIM 2
#define EPS (5*10e-4)

typedef std::vector<double> Vec;
typedef std::vector<Vec> Mat;
typedef std::pair<Mat,Vec> Eq;

double removeMinusZero(double x){
	if ( fabs(x)< EPS ){
		return 0.0;
	}
	else {
		return x;
	}
}

int main(void){
	using namespace std;

	list<Eq> input;

	double a,b,c,d,e,f;

	cout << fixed << setprecision(3);

	while(cin >> a >> b >> c >> d >> e >> f){
		Vec m1, m2;
		m1.push_back(a);
		m1.push_back(b);
		m2.push_back(d);
		m2.push_back(e);

		Vec vec;
		vec.push_back(c);
		vec.push_back(f);

		Mat mat;
		mat.push_back(m1);
		mat.push_back(m2);

		Eq eq = make_pair(mat,vec);

		input.push_back(eq);
	}

	for(auto itr = input.begin(); itr!=input.end(); ++itr){
		auto mat = itr->first;
		auto vec = itr->second;

		Vec output(DIM);

		double det = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];
		// std::transform(vec.begin(), vec.end(),vec.begin(), std::bind1st(multiplies<double>(),1.0/det));

		mat[0][1] = -mat[0][1];
		mat[1][0] = -mat[1][0];
		swap(mat[0][0],mat[1][1]);

		for (int i=0; i<DIM; i++){
			output[i] = inner_product(vec.begin(), vec.end(), mat[i].begin(), 0);
		}
		std::transform(output.begin(), output.end(),output.begin(), std::bind1st(multiplies<double>(),1.0/det));
		cout << removeMinusZero(output[0]) << " " << removeMinusZero(output[1]) << endl;
	}

}

Measured memory_bytes: 1300
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Graph as G

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    edge <- replicateM m $ do
        [a,b] <- getIntList
        return (a,b)
    let es edge = edge ++ map (\(a,b) -> (b,a)) edge
    let ans = length [()| e <- edge, (> 1) . length . G.components $ G.buildG (1,n) (es (delete e edge))]
    print ans

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

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

    int n, c, k;
    cin >> n >> c >> k;
    vector<int> T(n);
    REP(i, n) cin >> T[i];
    
    sort(T.begin(), T.end());

    int ans = 0, cnt = 1;
    int now = T[0] + k;
    for(int i = 1; i < n; i++){
        if(T[i] <= now) cnt++;
        else{
            ans++;
            cnt = 1;
            now = T[i] + k;
        }
        if(cnt == c or i == n - 1){
            ans++;
            if(i == n - 1) break;
            cnt = 0;
            now = T[i + 1] + k;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
fun hey(N: Int, points: Array<Pair<Long, Long>>) {
    if (N == 1) {
        println(1)
        return
    }

    val possiblePairs = mutableListOf<Pair<Long, Long>>()
    (0..(N - 1)).forEach { a ->
        (0..(N - 1)).forEach { b ->
            if (a != b) {
                val p = points[b]!!.first - points[a]!!.first
                val q = points[b]!!.second - points[a]!!.second
                possiblePairs.add(Pair(p, q))
            }
        }
    }

    var cost = Int.MAX_VALUE
    var fake = Int.MAX_VALUE
    possiblePairs.forEach {
        val p = it.first
        val q = it.second

        var sub = 0
        val unionFind = UnionFind(N)
        (0..(N-1)).forEach { i ->
            (0..(N-1)).forEach { j ->
                if (i != j) {
                    if (points[i].first - points[j].first == p && points[i].second - points[j].second == q) {
                        sub++
                        unionFind.merge(i, j)
                    }
                }
            }
        }

        cost = Math.min(cost, N - sub)
        fake = Math.min(fake, unionFind.parent.distinct().size)
    }
    println(cost)
}

fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val points: Array<Pair<Long, Long>> = Array(N, { Pair(0L, 0L) })
    (1..N).forEach {
        val (x, y) = readLine()!!.split(" ").map { it.toLong() }
        val pair = Pair(x, y)
        points[it - 1] = pair
    }
    hey(N, points)
}
class UnionFind(size: Int) {

    var parent: IntArray
    var height: IntArray
    var size: IntArray

    init {
        this.parent = IntArray(size)
        this.height = IntArray(size)
        this.size = IntArray(size)

        for (i in 0 until size) {
            makeSet(i)
        }
    }

    fun merge(x: Int, y: Int) {

        val rootX = root(x)
        val rootY = root(y)

        if (rootX == rootY) {
            return
        }

        if (height[rootX] > height[rootY]) {
            parent[rootY] = rootX
            size[rootX] += size[rootY]

        } else if (height[rootX] < height[rootY]) {
            parent[rootX] = rootY
            size[rootY] += size[rootX]

        } else {
            parent[rootY] = rootX
            size[rootX] += size[rootY]
            height[rootX]++
        }
    }

    fun isSame(x: Int, y: Int) : Boolean {
        return root(x) == root(y)
    }

    fun size(x: Int): Int {
        val rootX = root(x)
        return size[rootX]
    }

    private fun root(x: Int): Int {
        if (x != parent[x]) {
            parent[x] = root(parent[x])
        }
        return parent[x]
    }


    private fun makeSet(i: Int) {
        parent[i] = i
        height[i] = 0
        size[i] = 1
    }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    vector<ll> sumA(N);
    map<ll, ll> sumModMap;
    sumA[0] = A[0];
    sumModMap[sumA[0] % M] = 1;
    REP(i, N - 1)
    {
        sumA[i + 1] = sumA[i] + A[i + 1];
        ll sumMod = sumA[i + 1] % M;
        auto it = sumModMap.find(sumMod);
        if (it != sumModMap.end())
        {
            sumModMap[sumA[i + 1] % M]++;
        }
        else
        {
            sumModMap[sumA[i + 1] % M] = 1;
        }
        
    }
    ll ans = 0;
    REP(i, N)
    {
        ll sumMod = sumA[i] % M;
        if (sumMod == 0)
        {
            ans += sumModMap[sumMod];
        }
        else
        {
            ans += max(0ll, sumModMap[sumMod] - 1);
        }
        sumModMap[sumMod]--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>

int main(void) {
	int h;
	std::cin >> h;
	int w;
	std::cin >> w;

	std::vector<std::string>a(h);
	std::vector<bool>tate(w, false);
	std::vector<bool>yoko(h, false);

	for (int i = 0; i < h; i++) {
		std::cin >> a[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				yoko[i] = true;
				tate[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (yoko[i] == true) {
			for (int j = 0; j < w; j++) {
				if (tate[j] == true) {
					std::cout << a[i][j];
				}
			}
			std::cout << std::endl;
		}
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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

ll digits(ll i) {
	if (i >= 10000000000LL) return 11;
	if (i >= 1000000000LL) return 10;
	if (i >= 100000000LL) return 9;
	if (i >= 10000000LL) return 8;
	if (i >= 1000000LL) return 7;
	if (i >= 100000LL) return 6;
	if (i >= 10000LL) return 5;
	if (i >= 1000LL) return 4;
	if (i >= 100LL) return 3;
	if (i >= 10LL) return 2;
	return 1;
}

int main() {
	ll n;
	cin >> n;

	ll ans = 1000;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans = min(ans, max(digits(i) , digits(n / i)));
		}
	}
	cout << ans << endl;


	return 0;
}

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

int main(void){
	int i=0,j,c,max=0,ans1=100,ans2=100,count=0;
	char s[1000][33]={0};
	char ch;
	
	while(1){
		scanf("%c",&ch);
		if(ch=='\n')break;
		if(ch==' '){
			count++;
			i=0;
		}
		s[count][i]=ch;
		if(max<1+i){
			max=i+1;
			ans2=count;
		}
		if(ch!=' ')i++;
	}
	max=0;
	for(i=0;i<count;i++){
		for(j=i+1,c=0;j<count;j++){
			if(strcmp(s[i],s[j])==0){
				c++;
			}
			if(max<c){
				max=c;
				ans1=i;
			}
		}
	}
	
	printf("%s %s\n",s[ans1],s[ans2]);
	return 0;
}

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

int a,b,c,k,ans;

int solve(int q,int w,int e,int r){
  	if(q>=r) return r;
	ans=q;
  	r=r-q-w;
  	if(r<1) return ans;
  	ans=ans-r;
    return ans;
}

int main(){
	cin>>a>>b>>c>>k;
  	ans=solve(a,b,c,k);
  	cout<<ans;
  	return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    String res = "No";
   
    if((a == b && a != c)||(b == c && b != a)||(c == a && c != b)){res = "Yes";}
System.out.println(res);
  }
}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void PrintVector(const vector<int> &vec)
{
    for (auto val : vec)
        cout << val << " ";
    cout << endl;
}

int main()
{
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    Graph a(n, vector<int>(m));
    int ans = 0;
    rep(i, n)
    {
        int tmp = 0;
        rep(j, m)
        {
            cin >> a[i][j];
            tmp += (a[i][j] * b[j]);
        }
        if (tmp + c > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N >> M >> K;
	if (N + M + K >= 22) {
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if 500*i + 100*j + 50*k == x:
        cnt += 1
print(cnt)

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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

template<class T>
class segment_tree{
	int n;
	vector<T> dat;
	T query(int l,int r,int a,int b,int u){
		if(l<=a && b<=r) return dat[u];
		T res=0;
		int c=(a+b)/2;
		if(l<c && a<r) res=max(res,query(l,r,a,c,2*u+1));
		if(l<b && c<r) res=max(res,query(l,r,c,b,2*u+2));
		return res;
	}
public:
	segment_tree(int N){
		for(n=1;n<N;n*=2);
		dat.assign(2*n-1,0);
	}
	void update(int u,T v){
		u+=n-1;
		dat[u]=max(dat[u],v);
		while(u>0) u=(u-1)/2, dat[u]=max(dat[2*u+1],dat[2*u+2]);
	}
	T query(int l,int r){ return query(l,r,0,n,0); }
};

int main(){
	int n; scanf("%d",&n);
	vector<int> x(n),d(n);
	rep(i,n) scanf("%d%d",&x[i],&d[i]);

	{
		vector<pair<int,int>> p(n);
		rep(i,n) p[i]={x[i],d[i]};
		sort(p.begin(),p.end());
		rep(i,n) tie(x[i],d[i])=p[i];
	}

	segment_tree<int> S(n);

	vector<mint> dp(n+1);
	dp[n]=1;
	for(int i=n-1;i>=0;i--){
		int j=lower_bound(x.begin(),x.end(),x[i]+d[i])-x.begin();
		int pos=max(j,S.query(i,j));
		S.update(i,pos);
		dp[i]=dp[i+1]+dp[pos];
	}
	cout<<dp[0]<<'\n';

	return 0;
}


Measured memory_bytes: 4708
#include<iostream>
#include<string>
using namespace std;
int main(){
  int i,j,k;
  string que;
  cin >> que;
  while(que[0]!='#'){
    
    int v1=0,v2=0;
    int bv1,bv2;
    int br1,br2;
    int bl1,bl2;
    int r1=0,l1=0,r2=0,l2=0;
    int b;
    int a1=0,a2=0;
    for(i=0;i<que.size();i++){
      b=que[i]-'0';
      bv1=v1;bv2=v2;
      br1=r1;bl2=l2;
      
      if((i+a1)%2==0) {
	r1=b;
	if(r1==1||r1==4||r1==7){
	  if(l1==2||l1==3||l1==6||l1==8||l1==9) {
	    v1++;
	    r1=br1;
	    l1=b;
	    a1++;
	  }
	}else if(r1==2||r1==8){
	  if(l1==3||l1==6||l1==9) {
	    v1++;
	    r1=br1;
	    l1=b;
	    a1++;
	  }
	}	
      }else{
	l1=b;
	if(l1==3||l1==6||l1==9){
	  if(r1==1||r1==2||r1==4||r1==7||r1==8) {
	    v1++;
	    l1=bl1;
	    r1=b;
	    a1++;
	  }
	}else if(l1==2||l1==8){
	  if(r1==1||r1==4||r1==7) {
	    v1++;
	    l1=bl1;
	    r1=b;
	    a1++;
	  }
	}
	
	
      }
      if((i+a2)%2==0) {
	l2=b;
	if(l2==3||l2==6||l2==9){
	  if(r2==1||r2==2||r2==4||r2==7||r2==8) {
	    v2++;
	    l2=bl2;
	    r2=b;
	    a2++;
	  }
	}else if(l2==2||l2==8){
	  if(r2==1||r2==4||r2==7) {
	    v2++;
	    l2=bl2;
	    r2=b;
	    a2++;
	  }
	}
	
      }else{
	r2=b;
	if(r2==1||r2==4||r2==7){
	  if(l2==2||l2==3||l2==6||l2==8||l2==9) {
	    v2++;
	    r2=br2;
	    l2=b;
	    a2++;
	  }
	}else if(r2==2||r2==8){
	  if(l2==3||l2==6||l2==9){
	    v2++;
	    r2=br2;
	    l2=b;
	    a2++;
	  }
	}
      }
      
      
      
      
      //if(bv1<v1) cout << "v1 " << br1 << bl1 << r1 << " " << l1 << endl;
      //if(bv2<v2) cout << "v2" << r2 << " " << l2 << endl;
    }
    //cout << v1 << v2 << endl;
    cout << min(v1,v2) << endl;
    cin >> que;
  }
  return 0;
}

Measured memory_bytes: 1316
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000000000000.0

double cost[1002][1002];
double dmin[1002];
bool used[1002];

int main(int argc, char const *argv[]) {
  int N;
  int s[2];
  int t[2];
  cin >> s[0] >> s[1] >> t[0] >> t[1] >> N;
  long ba_x[N+2];
  long ba_y[N+2];
  long ba_r[N+2];
  for(int i = 0; i < N; i++){
    cin >> ba_x[i] >> ba_y[i] >> ba_r[i];
  }
  ba_x[N] = s[0];
  ba_y[N] = s[1];
  ba_r[N] = 0;
  ba_x[N+1] = t[0];
  ba_y[N+1] = t[1];
  ba_r[N+1] = 0;
  //Calc cost
  for(int i = 0; i < N+2; i++){
    for(int h = 0; h < N+2; h++){
      double dist = sqrt(((double)(ba_x[i]-ba_x[h]))*(double)(ba_x[i]-ba_x[h])+(double)(ba_y[i]-ba_y[h])*(double)(ba_y[i]-ba_y[h]));
      cost[i][h] = fmax(0,dist - (ba_r[i]+ba_r[h]));
    }
  }
  //Dijkstra
  //fill(used, used+1012, false);
  //fill(dmin, dmin+1012, INF);
  for(int i = 0; i < 1002; i++){
    used[i] = false;
    dmin[i] = INF;
  }
  dmin[N] = 0;//これがスタート地点。
  while(true){
    int v = -1;
    for(int i = 0; i < N+2; i++){
      if(!used[i] && (v==-1 || dmin[i]<dmin[v])) v = i;
    }
    if(v==-1) break;
    used[v] = true;
    for(int i = 0; i < N+2; i++){
      dmin[i] = fmin(dmin[i], dmin[v]+cost[v][i]);
    }
  }
  //print ans
  //printf("%f\n", dmin[N+1]);
  cout << fixed << setprecision(10) << dmin[N+1] << endl;
  return 0;
}


Measured memory_bytes: 8192
using System;

namespace ConsoleApp1
{
    class Program
    {
        static int Sub()
        {
            var read = Console.ReadLine().Split(' ');
            var M1 = int.Parse(read[0]);
            var D1 = int.Parse(read[1]);

            read = Console.ReadLine().Split(' ');
            var M2 = int.Parse(read[0]);
            var D2 = int.Parse(read[1]);

            return (D2 == 1) ? 1: 0;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Sub());
        }
    }
}


Measured memory_bytes: 13140
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var d,n int
    fmt.Scan(&d,&n)
    ans := 0
    cnt := 0
    for i:=1; i<=2000000; i++{
        cnt1 := 0
        m := i
        for m>0{
            if m%100 == 0{
                cnt1++
            } else {
                break
            }
            m/=100
        }
        if cnt1==d{
            cnt++
        }
        if cnt==n{
            ans = i
            break
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

int main(){
	int n;
	while(cin >> n && n){
		char teams[16], c;
		ppr res[16];
		REP(i,16){
			res[i] = make_pair(-64, make_pair(64, 64));
		}
		int r;
		REP(i,n){
			cin >> c;
			teams[i] = c;
			res[i].S.S = -i;
			REP(j,n-1){
				cin >> r;
				if(r == 0){
					res[i].F++;
				}
				else if(r == 1){
					res[i].S.F--;
				}
			}
		}
		sort(res, res + n, greater<ppr>());
		REP(i,n){
			cout << teams[-res[i].S.S] << endl;
		}
	}
}

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


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] S2 = "CODEFESTIVAL2016".toCharArray();
		int count = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] != S2[i]) count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 10064
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
    int n;
	int a[100],b[100];
	int x,y,v;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int tmp;
  for (int i=0;i<n;i++) { 
    for (int j=i+1;j<n;j++) { 
      if (a[i]>a[j]) { 
        tmp=a[i]; 
        a[i] =a[j]; 
        a[j] = tmp; 
      } 
    } 
  }
  int s=1;
  for(int i=0;i<n;i++){
	  while(true){
		  int d=0;
	  for(int j=0;j<n;j++){
		  if(a[j]!=s)
			  d++;
	  }
	  if(d==n){
		  b[i]=s;
		  s++;
		  break;
	  }
	  s++;
	  }
  }
  x=n-1;
  y=n;
  v=a[0];
  a[0]=0;
  while(true){
	  int i=0;
	  while(true){
		  if(i==n){
			  v=0;
			  break;
		  }
		  if(b[i]>v){
			  v=b[i];
			  b[i]=0;
			  y--;
			  break;
		  }
		  i++;
	  }
	  if(y==0)
		  break;
	  int j=0;
	  while(true){
		  if(j==n){
			  v=0;
			  break;
		  }
		  if(a[j]>v){
			  v=a[j];
			  a[j]=0;
			  x--;
			  break;
		  }
		  j++;
	  }
	  if(x==0)
		  break;
    }
      cout<<y<<endl;
      cout<<x<<endl;
    }
    return 0;
} 

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

static int par[200010];//親
static int rank[200010];

//n要素で初期化
void init(int n){
	int i;
	for(i=0;i<n;i++){
		par[i]=i;
		rank[i]=0;
	}
}

//木の根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		par[x]=find(par[x]);
		return par[x];
	}
}

//xとyの属する集合を併合
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rank[x]<rank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rank[x]==rank[y])rank[x]++;
	}
}


int main(void)
{
	//変数の宣言
	int n,m;
	static int p[100010];
	static int x[100010];
	static int y[100010];
	
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	//データの読み込み
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	
	for(i=0;i<m;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	init(200000);
	for(i=0;i<n;i++){
		unite(p[i],i+100001);
	}
	for(i=0;i<m;i++){
		unite(p[x[i]-1],p[y[i]-1]);
//		printf("m=%d i=%d %dと%dを連結\n",m,i,p[x[i]-1],p[y[i]-1]);
//		for(j=1;j<=n;j++){
//			printf("%d->%d\n",j,find(j));
//			printf("%d->%d\n",j+100000,find(j+100000));
//		}
	}
	
	for(i=1;i<=n;i++){
		if(find(i)==find(i+100000)) ans++;
	}
	
//	for(i=1;i<=n;i++){
//		printf("%d->%d\n",i,find(i));
//		printf("%d->%d\n",i+100000,find(i+100000));
//	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

using namespace std;

//#define int long long
#define PB push_back
#define MK make_pair
#define MKT make_tuple
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

//constexpr int INF = 1LL<<60;
constexpr int INF = 1 << 28;
constexpr int MOD = 100000;
constexpr int MAX_N = 20;
constexpr int dx[] = { -1, 0, 1, 0 };
constexpr int dy[] = { 0, -1, 0, 1 };

int dp[2][1 << MAX_N][3][2], w, h, fld[MAX_N + 1][MAX_N + 1];
vector<int> gedo;

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

    cin >> h >> w;
    
    for (int i = 0; i < (1 << w); ++i) {
        bool pre = false, flg = false;
        for (int j = 0; j < w; ++j) {
            bool tmp = i & (1 << j);
            if (pre && tmp) {
                flg = true;
                break;
            }
            pre = tmp;
        }
        if (flg) continue;
        gedo.PB(i);
    }       
    
    for (int y = 1; y <= h; ++y) {
        string s;
        cin >> s;
        for (int x = 1; x <= w; ++x) {
            int t = -1;
            switch (s[x - 1]) {
            case 'J':
                t = 0;
                break;
            case 'O':
                t = 1;
                break;
            case 'I':
                t = 2;
                break;
            }
            fld[x][y] = t;
        }
    }

    for (int i = fld[1][1] == -1 ? 0 : fld[1][1]; i < 3; ++i) {
        dp[0][0][i][0] = 1;
        if (fld[1][1] != -1) break;
    }
    for (int y = 1; y <= h; ++y) {
        for (int x = 1; x <= w; ++x) {
            int idx = ((y - 1) * w + x - 1) % 2;
            int nx, ny;
            if (x == w) {
                nx = 1;
                ny = y + 1;
            } else {
                nx = x + 1;
                ny = y;
            }
            for (int mask : gedo) {
                for (int cur = fld[x][y] == -1 ? 0 : fld[x][y]; cur < 3; ++cur) {
                    for (int nxt = fld[nx][ny] == -1 ? 0 : fld[nx][ny]; nxt < 3; ++nxt) {
                        int nok = (mask & 1) && cur == 2 && x != w;
                        int nmask = (mask >> 1) + ((cur == 0 && nxt == 1 && x != w) ? (1 << (w - 1)) : 0);
                        //cerr << "x:" << x << "y:" << y << "mask:" << mask << endl;
                        for (int ok = 0; ok < 2; ++ok) {
                            dp[!idx][nmask][nxt][nok || ok] += dp[idx][mask][cur][ok];
                            dp[!idx][nmask][nxt][nok || ok] %= MOD;
                        }
                        if (fld[nx][ny] != -1) break;
                    }

                    if (fld[x][y] != -1) break;
                }
            }

            //fill(dp[idx][0][0], dp[idx][1 << MAX_N][0], 0);
            memset(dp[idx], 0, sizeof(dp[idx]));
        }
    }

    int ans = 0, tar = (w * h) % 2;
    for (int i = 0; i < (1 << w); ++i) {
        for (int j = 0; j < 3; ++j) {
            ans += dp[tar][i][j][1];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int K,N;
  cin >> K >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
   cin >> A.at(i);
  }
  
  int res;

  for (int i = 0; i < N; i++) {
    if (i==0){
      res=A.at(N-1)-A.at(0);
    }
    else{
      int S;
      S=K-A.at(i)+A.at(i-1);
      res=min(res,S);
    } 
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
    int main(void)
{
    int S, s, h, m, temp;
    scanf("%d", &S);
    h = S / 3600;
    S = S - 3600 * h;
    m = S / 60;
    S = S - 60 * m;
    s = S;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cstring>
#define DN 605
#define M1 66013
#define M2 55817
#define pr 173
using namespace std;
int n,s1[DN][DN],s2[DN][DN],p1[DN],p2[DN],r1,r2,t1,t2,rez,vf;
int s3[DN][DN],s4[DN][DN];
char a[DN][DN];
char f(int i,int j,int b)
{
    int poz=(j+n-b)%n;
    if(poz==0)
        poz=n;
    return a[i][poz];
}
int main()
{
    cin>>n;
    for(int i=0;i<=n;i++)
        cin.getline(a[i]+1,DN);
    if(n==1)
    {
        cout<<1;
        return 0;
    }
    for(int b=0;b<=n-1;b++)
    {
        vf=1;
        for(int i=1;i<=n&&vf;i++)
            for(int j=1;j<=n&&vf;j++)
                if(f(i,j,b)!=f(j,i,b))
                    vf=0;
        if(vf)
            rez+=n;
    }
    cout<<rez;
}


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

int main() {
    int n;
    char s[51][200] = {0};
    long s_time[51] = {0};
    
    char sleep_song[200];
    long sleep_time = 0;
    
    scanf("%d", &n);
    for(int cnt = 0; cnt < n; cnt++)
        scanf("%s %ld", s[cnt], &s_time[cnt]);
    scanf("%s", sleep_song);
    
    int flag = 0;
    
    for(int cnt = 0; cnt < n; cnt++) {
        if(!(strcmp(s[cnt], sleep_song)))
            flag = 1;
        
        else if(flag)
            sleep_time += s_time[cnt];
    }
    
  printf("%ld", sleep_time);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll cnt[205]={0},col[205]={0};
bool edge[205][205];
ll node[205][205]={0};
ll n;
void dfs(ll pos,ll nc){
  col[pos]=nc;
  nc%=2;
  nc++;
  for(int i=1;i<=n;i++){
    if(edge[pos][i]&&col[i]==0){
      dfs(i,nc);
    }
  }
}
int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++) {
      edge[i][j]=false;
      if(i!=j) node[i][j]=17441744174417;
    }
  }
  ll now_col=1;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      char c;
      cin>>c;
      if(c=='1') {
        edge[i][j]=true;
        node[i][j]=1;
      }
    }
  }
  for(int i=1;i<=n;i++){
    if(col[i]==0){
      col[i]=now_col;
      dfs(i,now_col);
      now_col+=2;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(col[i]%2==col[j]%2&&edge[i][j]){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++) node[i][j]=min(node[i][j],node[i][k]+node[k][j]);
    }
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++) ans=max(ans,node[i][j]);
  }
  cout<<ans+1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	string input;
	while(cin>>input&&input!="#"){
		char state='A';
		for(int i=0;i<input.size();i++){
			if(state=='A'){
				if(input[i]=='0')state='X';
				else state='Y';
			}else if(state=='X'){
				if(input[i]=='1')state='Z';
				else break;
			}else if(state=='Y'){
				if(input[i]=='0')state='X';
				else break;
			}else if(state=='Z'){
				if(input[i]=='0')state='W';
				else state='B';
			}else if(state=='W'){
				if(input[i]=='0')state='B';
				else state='Y';
			}else if(state=='B'){
				if(input[i]=='0')state='Y';
				else state='X';
			}
		}
		if(state=='B')cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1180
#include <iostream>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int t[n], x[n], y[n];

  for(int i = 0; i < n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  int before_t = 0;
  int before_x = 0;
  int before_y = 0;

  for(int i = 0; i < n; i++) {
    int dt = t[i] - before_t;
    int dx = x[i] - before_x;
    int dy = y[i] - before_y;
    if(dt < 0) {
      dt *= -1;
    }
    if(dx < 0) {
      dx *= -1;
    }
    if(dy < 0) {
      dy *= -1;
    }
    
    if(dt < dx + dy) {
      cout << "No" << endl;
      return 0;
    }
    else if((dt - (dx + dy)) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
    before_t = t[i];
    before_x = x[i];
    before_y = y[i];
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
object Main extends App {
  import scala.io.StdIn._

  val move = Array.tabulate(10){_ ⇒ Array.tabulate(10){_ ⇒ 0}}
  val n = readInt
  val numbers = readLine.trim.toCharArray.map(_.asDigit)
  for (i ← numbers.indices.tail){
    move(numbers(i - 1))(numbers(i)) += 1
  }
  val r = calPermutationMin()
  println(r / 1000000)
  println((r / 1000) % 1000)
  println(r % 1000)

  def calPermutationMin(): Long= {
    def sub(prev: Array[Int], rest: Int = 9, flag: Long = 0, cost: Int = 0, min: Long = 0, minCost: Int = Int.MaxValue): (Long, Int)= {
      if (rest == 0) {
        if (minCost > cost) (prev.foldRight(0L)((a, b) ⇒ a + b * 10), cost)
        else (min, minCost)
      }else {
        var m = min
        var mc = minCost
        for (i ← 1 to 9 if (flag & (1 << i)) == 0){
          prev(rest - 1) = i
          val c = (rest until 9).map(idx ⇒ diff(idx, rest - 1) * (move(i)(prev(idx)) + move(prev(idx))(i))).sum
          val (nm, nmc) = sub(prev, rest - 1, flag | (1 << i), cost + c, m, mc)
          m = nm
          mc = nmc
        }
        (m, mc)
      }
    }
    sub(Array.tabulate(9){_ ⇒ 0})._1
  }
  def diff(a: Int, b: Int): Int = {
    math.abs((a / 3) - (b / 3)) + math.abs((a % 3) - (b % 3))
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 459136
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]

min_diff = 9999999
min_cnt = 0
for c, h in enumerate(H):
    diff = abs(A - (T - h * 0.006))
    if min_diff >= diff:
        min_diff = diff
        min_cnt = c + 1

print(min_cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


string N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  if (N.back() == M.front() && M.back() == K.front())
  {
    cout << "YES\n";
  }
  else {
    cout << "NO\n";
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M >> K;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int data[100];

int main( void )
{
	int i;
	int buf;
	int maxData;
	int numOfMaxData;
	
	maxData = 0;
	for( i = 0; i < 100; i++ )
	{
		data[i] = 0;
	}
	
	while( scanf( "%d", &buf ) != EOF )
	{
		data[buf]++;
		if( maxData < data[buf] )
		{
			maxData = data[buf];
		}
	}
	
	for( i = 0; i < 100; i++ )
	{
		if( maxData == data[i] )
		{
			printf( "%d\n", i );
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) throws IOException {
    
    	Scanner scan = new Scanner(System.in);
   
    	char [] ch = scan.next().toCharArray();
    	
    	if(Character.isLowerCase(ch[0])) System.out.println("a");
    	else System.out.println("A");
    	
    
    	
    } 	
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  for (int i=0; i<N; i++) {
    int v=A[i];
    int j=i-1;
    while (j>=0 && A[j]>v) {
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for (int i=0; i<N; i++) {
      cout << (i==0?"":" ") << A[i] << flush;
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
using std::cin;
using std::cout;
using std::endl;
using std::ios;


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

    int N;
    cin >> N;
    int temp;
    long long int a[N];
    rep(i, N) cin >> a[i];

    int ans = 0;
    rep(i, N) {
        if(a[i] % 2 == 0) {
            while(a[i] > 1) {
                a[i] /= 2;
                ++ans;
                if(a[i] % 2 == 1) break;
            }
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  ll n = (1 << 10) + 1;
  rep(i, n) rep(j, n) rep(p, 2) rep(q, 2) {
    ll a = i;
    ll b = j;
    if(p) a *= -1;
    if(q) b *= -1;
    ll now = a * a * a * a * a - b * b * b * b * b;
    if(now != x) continue;
    cout << a << ' ' << b << endl;
    return 0;
  }
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int i;
	int h, m, s;
	int in, out;
	int t;
	
	for (i = 0; i < 3; i++){
		scanf("%d%d%d", &h, &m, &s);
		in = h * 3600 + m * 60 + s;

		scanf("%d%d%d", &h, &m, &s);
		out = h * 3600 + m * 60 + s;

		t = out - in;
		
		printf("%d %d %d\n", t / 3600, t / 60 % 60, t % 60);
	}
	
	return (0);
}

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

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 30);

int main(){
    int n, m;
    int C[MMAX+1], T[NMAX+1];
    
    cin >> n >> m;
    C[0] = 0;
    for(int i=1;i<=m;i++) cin >> C[i];
    T[0] = 0;
    for(int i=1;i<=NMAX;i++) T[i] = INFTY;
    for(int i=1;i<=m;i++){
        for(int j=0;j+C[i]<=n;j++){
            T[j+C[i]] = min(T[j+C[i]], T[j]+1);
        }
    }

    cout << T[n] << endl;

    return 0;

}


Measured memory_bytes: 3312