akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {            
            var tmp = ReadLine();
            long a = tmp[0];
            long b = tmp[1];
            long k = tmp[2];

            if (a <= k)
            {
                k -= a;
                a = 0;
            }
            else
            {
                a -= k;
                k = 0;
            }

            if (b <= k)
            {
                k -= b;
                b = 0;
            }
            else
            {
                b -= k;
            }

            Console.WriteLine(a + " " + b);
        }

        static List<long> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => long.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main() {
	int c;
	
	while((c = getchar()) != EOF) {
		if(c >= 'a' && c <= 'z') {
			putchar(c -'a' + 'A');
		}else if(c >= 'A' && c <= 'Z') {
			putchar(c -'A' + 'a');
		}else{
			putchar(c);
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = ReadLongs();
            var ans = Lcm(ab[0], ab[1]);
            WriteLine(ans);
        }
        public static long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = (int)1e9 + 7;

int main() {
	ll n, k; cin >> n >> k;
    
    ll ans = 0;
    for (ll i = k; i <= n+1; ++i)
    	ans = (ans + ((n - i + 1) * i + 1) % MOD) % MOD;
    
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

int main()
{
	unsigned int a, b;
	std::cin >> a >> b;

	int cake[16] = { 0 };

	// どちらが取った？のマーク
	int getCake = 1;

	while ( ( a > 0 ) && ( b > 0 ) )
	{
		int prevA = a;
		int prevB = b;
		for ( int i = 0; i < 16; i++ )
		{
			int prev = cake[(i + 15) % 16];
			int next = cake[(i +  1) % 16];

			// ルール通り？
			if ( ( ( prev != getCake ) && ( next != getCake ) )
				 && ( cake[i] == 0 )	//	誰も取ってない
				)
			{
				if ( getCake == 1 )
				{
					if ( a > 0 )
					{
						a--;
						cake[i] = getCake;
					}
				}
				else
				{
					if ( b > 0 )
					{
						b--;
						cake[i] = getCake;
					}
				}
			}
			else
			{
				// ダメならスキップ
			}
			getCake *= -1;
		}

		if ( ( prevA == a ) || ( prevB == b ) )
		{
			// ループ前と値が変わってない＝もう取れないので諦める
			break;
		}
	}

	// 全部取れた？
	if ( ( a == 0 ) && ( b == 0 ) )
	{
		std::cout << "Yay!" << std::endl;
	}
	else
	{
		std::cout << ":(" << std::endl;
	}

	return ( 0 );
}


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

int main(){
  int n,y;
  cin >> n >> y;
  int a10000 = -1, a5000 = -1, a1000 = -1;

  for (int i=0; i<=n; i++){
    for (int j=0; i+j<=n; j++){
      int k = n - i - j;
      if (i*10000 + j*5000 + k*1000 == y){
        a10000 = i;
        a5000 = j;
        a1000 = k;
      }
    }
  }
  
  cout << a10000 << " " << a5000 << " " << a1000 << endl;
}



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

bool bellman_ford(const int v, const int s,
                  const vector<pair<pair<int, int>, int64_t>>& g,
                  vector<int64_t>& cost)
{
    const int64_t inf = 1LL << 60;
    cost[s] = 0;
    for (auto i = 0; i < v; i++) {
        for (auto & elm : g) {
            if(cost[elm.first.first] == inf) continue;
            if(cost[elm.first.second] > cost[elm.first.first] + elm.second) {
                if(i == v - 1) return true; // 負の閉路がある
                cost[elm.first.second] = cost[elm.first.first] + elm.second;
            }
        }
    }
    return false;
}

int main(){
    int v, e, r; cin >> v >> e >> r;
    vector<pair<pair<int, int>, int64_t>> g;
    const int64_t inf = 1LL << 60;
    vector<int64_t> cost(v, inf);
    for (auto i = 0; i < e; i++) {
        int s, t, d; cin >> s >> t >> d;
        g.emplace_back(make_pair(s, t), d);
    }
    if(bellman_ford(v, r, g, cost)) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (auto & elm : cost)
        cout << (elm == inf ? "INF" : to_string(elm)) << endl;
    return 0;
}


Measured memory_bytes: 3344
program main
	implicit integer(a-z)
    character(3)::ans="No"
    
    read(*,*)n
    
    imax=n/4
    jmax=n/7
    
    do j=0,jmax
    	do i=0,imax
        	if(i*4+j*7.eq.n) ans="Yes"
        end do
    end do
    
    write(*,*)ans
end program main

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++){
    	if(a[i]%2==0){
		    if(a[i]%3!=0&&a[i]%5!=0){
			    cout<<"DENIED"<<endl;
			    return 0;
		    }
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main(){
    int N;cin>>N;
    vector<int>V(N);
    rep(i,N)cin>>V[i];
    int ans=N;
    while(ans>=0){
        int count=0;
        rep(i,N){
            if(V[i]>=ans)count++;
        }
        if(count>=ans)break;
        ans--;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll sum = 0;
    for(ll i=0; i<n; i++){
        ll a; cin >> a;
        sum += a;
        mp[a]++;
    }

    ll q; cin >> q;
    for(ll i=0; i<q; i++){
        ll b, c;
        cin >> b >> c;
        sum += mp[b]*(c - b);
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 9516
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main() {
    int N;
    cin >> N;
    vector<long long> t(N);
    REP(i, N) { cin >> t[i]; }
    long long result = 1;
    REP(i, N) { result = lcm(result, t[i]); }
    cout << result << endl;
}

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

 
int a[3];
long double dp[303][303][303];
long double n;
long double ans(int x, int y, int z){
    if (x < 0 || y < 0 || z < 0) return 0.0;
    if(dp[x][y][z] != -1) return dp[x][y][z];
    return dp[x][y][z] = (long double)(ans(x-1,y,z)*x + ans(x+1,y-1,z)*y + ans(x,y+1,z-1)*z + n) / (x+y+z);
}
int main(){
    cin >> n;
    for (int i = 0;i < n; i++){
        int b; cin >> b;
        a[b - 1]++;
    }
    for(int i=0;i<303;i++)
    for(int j=0;j<303;j++)
    for(int k=0;k<303;k++) dp[i][j][k] = -1;
    dp[0][0][0] = 0.0;
    cout << fixed << setprecision(15);  
    cout << ans(a[0], a[1], a[2]);
}

Measured memory_bytes: 435072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N, K, S;
    cin >> N >> K >> S;
    for (int i = 0; i < K; i++) cout << S << " ";
    for (int i = K; i < N; i++) {
        if (S == 1e9) cout << 1;
        else cout << (int)1e9;
        if (i + 1 == N) cout << endl;
        else cout << " ";
    }
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using indexed_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = { 0, 0, -1, 1, -1, 1, -1, 1 };
int _y[] = { -1, 1, 0, 0, 1, -1, -1, 1 };
void solve();
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(20);
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		//    cout << "Case #: " << i << "\n";
		solve();
	}
	return 0;
}

void solve() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans1 = a * c, ans2 = a * d, ans3 = b * c, ans4 = b * d;
	cout << max( { ans1, ans2, ans3, ans4 });
}


Measured memory_bytes: 3648
n=gets.to_i
dp=Array.new((n+1)*100,0)

dp[0]=1
mx=0
for i in 0..n-1 do
    num=gets.to_i
    x=mx
    (0..x).reverse_each do |i|
        if(dp[i]>0)
            dp[i+num]=1
            mx=[mx,i+num].max
        end
    end
end

ans=0
(0..mx).reverse_each do |i|
    if(dp[i]>0&&i%10>0)
        ans=i
        break
    end
end

puts ans

Measured memory_bytes: 3964
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll x[101];
int main()
{
  ll n, tmp, ans = LLINF;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
    scanf("%lld", x + i);
  sortup(x, n);
  for (int i = x[0]; i <= x[n - 1]; i++)
  {
    tmp = 0;
    for (int j = 0; j < n; j++)
    {
      tmp += pow(x[j] - i, 2);
    }
    ans = MIN(tmp, ans);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int da, db;
	da = abs(x - a), db = abs(x - b);
	if (da < db) wrln("A");
	else wrln("B");
	
	return 0;
}

Measured memory_bytes: 256
import math
m=int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
for i in range(m,m+1000):
  if is_prime(i):
    print(i)
    break

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int c[50][50] = {};

void dfs(int x, int y, int h, int w) {
	if (c[y][x] == 0) {
		return;
	}
	c[y][x] = 0;
	if (x + 1 <= w - 1) {
		dfs(x + 1, y, h, w);
	}
	if (x - 1 >= 0) {
		dfs(x - 1, y, h, w);
	}
	if (y + 1 <= h - 1) {
		dfs(x, y + 1, h, w);
	}
	if (y - 1 >= 0) {
		dfs(x,y - 1, h, w);
	}
	if (x + 1 <= w - 1 && y + 1 <= h - 1) {
		dfs(x + 1, y + 1, h, w);
	}
	if (x + 1 <= w - 1 && y - 1 >= 0) {
		dfs(x + 1, y - 1, h, w);
	}
	if (x - 1 >= 0 && y + 1 <= h - 1) {
		dfs(x - 1, y + 1, h, w);
	}
	if (x - 1 >= 0 && y - 1 >= 0) {
		dfs(x - 1, y - 1, h, w);
	}
	return;
}

int main(void) {
	
	while (1) {
		int h, w;
		int count = 0;

		cin >> w >> h;
		if (h == 0) {
			break;
		}
		

		FOR(i, 0, h - 1) {
			FOR(t, 0, w - 1) {
				cin >> c[i][t];
			}
		}
		FOR(i, 0, h - 1) {
			FOR(t, 0, w - 1) {
				if (c[i][t] == 0) {
					continue;
				}
				
				dfs(t, i, h, w);
				count++;
			}
		}
		cout << count << endl;
	}

}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<vector<int>> dp(n + 1,vector<int>(3));
  vector<vector<int>> a(n,vector<int>(3));
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 3;j++){
      cin >> a[i][j];
    }
  }

  for(int i = 0;i < n;i++){
    for(int j = 0;j < 3;j++){
      for(int k = 0;k < 3;k++){
        if(j == k) continue;
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



void solve(){
    ll n;
    cin >> n;
    vector<ll> nums;
    for(ll i=2; i*i<=n; i++){
        ll counter=0;
        while(n%i==0){
            counter++;
            n/=i;
        }
        if(counter!=0){
            nums.push_back(counter);
        }
    }
    if(n!=1){
        nums.push_back(1);
    }
    ll ans=0;
    for(ll i=0; i<nums.size(); i++){
        for(ll j=1; j<100; j++){
            if(nums[i]>=j){
                ans++;
                nums[i]-=j;
            }
            else {
                break;
            }
        }
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 3660
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


int main()
{
	while (true)
	{
		int n, m, s, g1, g2;
		int cost[101][101];
		cin >> n >> m >> s >> g1 >> g2; if (!n)break;
		FOR(i, 101)FOR(j, 101)cost[i][j] = INF;
		FOR(i, 101)cost[i][i] = 0;
		FOR(i, m)
		{
			int l, r, c;
			cin >> l >> r >> c;
			cost[l][r] = c;
		}

		FOR(k, n + 1)
		{
			FOR(i, n + 1)
			{
				FOR(j, n + 1)
				{
					if (cost[i][k] == INF || cost[k][j] == INF)continue;
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
				}
			}
		}
		int ans = INF;
		FOR(k, n + 1)
		{
			ans = min({ ans, cost[s][k] + cost[k][g1] + cost[k][g2],cost[s][k]+cost[k][g1]+cost[g1][g2],cost[s][k]+cost[k][g2]+cost[g2][g1] });
		}
		cout << ans << endl;
	}
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===


// グラフが二部グラフかを判定
// arguments:
//     g : 隣接リスト
// return:
//     g が二部グラフなら片方のグループの頂点数
//     g が二部グラフでないなら -1
// 時間計算量: O(|E|)
int is_bipartite(const std::vector<std::vector<int>>& g)
{
	int n = static_cast<int>(g.size());
	std::vector<int> colors(n);
	int white_cnt = 0;
	std::stack<std::pair<int, int>> stk;
	stk.emplace(0, 1);
	while (!stk.empty()) {
		int v;
		int color;
		std::tie(v, color) = stk.top();
		stk.pop();
		if (color == 1) ++white_cnt;
		colors[v] = color;
		for (const auto& to : g[v]) {
			if (colors[to] == color) {
				return -1;
			}
			if (colors[to] == 0) {
				stk.emplace(to, -color);
			}
		}
	}
	return white_cnt;
}



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

	vector<Vi> g(N);
	for (int i = 0; i < N; ++i) {
		string line;
		cin >> line;
		for (int j = 0; j < N; ++j) {
			if (line[j] == '1') g[i].push_back(j);
		}
	}

	if (is_bipartite(g) == -1) {
		cout << -1 << endl;
		return 0;
	}


	vector<Vi> d(N, Vi(N, I_INF / 3));
	for (int i = 0; i < N; ++i) {
		for (const auto& to : g[i]) {
			d[i][to] = 1;
		}
	}

	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i != j) ans = max(ans, d[i][j]);
		}
	}

	++ans;

	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000

int main(){
    ll n, q; cin >> n >> q; string s; cin >> s;
    vector<vector<char>> ql(q,vector<char>(2));
    ll left = -1; ll right = n;
    REP(i,q) cin >> ql[i][0] >> ql[i][1];
    FORD(i,q-1,0){
        if (left!=-1&&s[left]==ql[i][0]&&ql[i][1]=='R') left--;
        if (right!=n&&s[right]==ql[i][0]&&ql[i][1]=='L') right++;
        if (left!=n-1&&s[left+1]==ql[i][0]&&ql[i][1]=='L') left++;
        if (right!=0&&s[right-1]==ql[i][0]&&ql[i][1]=='R') right--;
    }
    ll lim = 0;
    cout << max(lim,right-left-1) << endl;
}

Measured memory_bytes: 11396
#include <cstdio> 
#include <algorithm> 
using namespace std; 

int n, K, h[4009][2], l[4009][2], sum = 0, sn = 0, c[4009]; 
int dp[4009][4009][2], ans[4009], jc[4009], fin = 0ll; 
const long long mod = 924844033; 
bool ind[4009][4009]; 

int read(); 
void add(int x, int y)	{
	sn ++; 
	if(!l[x][0])	l[x][0] = y; 
	else l[x][1] = y; 
	if(!h[y][0])	h[y][0] = x; 
	else h[y][1] = x; 
} 

void find(int x, int y)	{
	ind[x][y] = true; sum ++; 
	for (int i = 0; i <= 1; i ++)	{
		if(l[x][i] && !ind[x][l[x][i]])	find(x, l[x][i]); 
		if(h[y][i] && !ind[h[y][i]][y])	find(h[y][i], y); 
	}
}

void set_pre()	{
	c[0] = 1; jc[0] = 1ll; 
	for (int i = 1; i <= 4000; i ++)	c[i] = c[i - 1] * -1; 
	for (int i = 1; i <= 4000; i ++){
		long long t = 1ll * jc[i - 1] * i % mod; 
		jc[i] = t; 
	}
}

int main()	{
	n = read(), K = read(); dp[0][0][0] = 1; 
	ans[0] = 1; set_pre(); 
	for (int i = 1; i <= n << 1; i ++)	{
		dp[i][0][0] = 1; 
		for (int j = 1; j <= i; j ++)
			dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % mod,  
			dp[i][j][1] = dp[i - 1][j - 1][0]; 
	}
	for (int i = 1; i <= n; i ++)	{
		if(i - K >= 1)	add(i, i - K); 
		if(i + K <= n)	add(i, i + K); 
	} 
	for (int i = 1; i <= n; i ++)
		if(l[i][0] && !ind[i][l[i][0]]){
			sum = 0; find(i, l[i][0]); 
			for (int j = sn; j; j --)
				for (int k = 1; k <= min(j, sum); k ++)	{
					long long t = (long long)(1ll * ans[j - k] * ((dp[sum][k][0] + dp[sum][k][1]) % mod) % mod + ans[j]) % mod; 
					ans[j] = t; 
				}
		}
		else if(l[i][1] && !ind[i][l[i][1]]){
			sum = 0; find(i, l[i][1]); 
			for (int j = sn; j; j --)
				for (int k = 1; k <= min(j, sum); k ++)	{
					long long t = (long long)(1ll * ans[j - k] * ((dp[sum][k][0] + dp[sum][k][1]) % mod) % mod + ans[j]) % mod; 
					ans[j] = t; 
				}
		} 
	for (int i = 0; i <= n; i ++)
		fin = (long long)(1ll * ans[i] * c[i] * jc[n - i] % mod + fin + mod) % mod; 
	printf("%lld\n", fin); 
	return 0; 
} 

int read()	{
	int x = 0, f = 1; char c = getchar(); 
	while (c > '9' || c < '0')	f = (c == '-') ? -1 : f, c = getchar(); 
	while (c >= '0' && c <= '9')	x = x * 10 + c - '0', c = getchar(); 
	return x * f; 
}

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

int main() {
  ll h, n;
  cin >> h >> n;
  
  vector<ll> a(n);
  vector<ll> b(n);

  for (ll i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  vector<ll> dp(h + 1, __INT_MAX__);
  dp[h] = 0;
  for (ll i = h; i >= 0; i--) {
    for (ll j = 0; j < n; j++) {
      if (dp[i] != __INT_MAX__) {
        ll dest = max((ll) 0, i - a[j]);
        dp[dest] = min(dp[dest], dp[i] + b[j]);
      }
    }
  }

  cout << dp[0] << endl;
}


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

int main()
{
 string N;
 cin >> N;
 if (N[0] == N[1] && N[0] == N[2]){
     cout << "Yes" << endl;
 }
 else if (N[1] == N[2] && N[2] == N[3]){
    cout << "Yes" << endl;
 }else
 {
    cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    if(a%2==0 && b%2!=0){
        ll c = (b-a+1)/2;
        if(c%2!=0) ans = 1;
    }
    else if(a%2==0 && b%2==0){
        ll c = (b-a)/2;
        if(c%2==0) ans = b;
        else if(c%2!=0) ans = b+1;
    }
    else if(a%2!=0 && b%2!=0){
        ll c = (b-a)/2;
        if(c%2==0) ans = a;
        else if(c%2!=0) ans = a-1;
    }
    else if(a%2!=0 && b%2==0){
        ll c = (b-a-1)/2;
        ll d = a^b;
        if(c%2!=0 && d%2==0) ans = d+1;
        if(c%2==0 && d%2==0) ans = d;
        if(c%2!=0 && d%2!=0) ans = d-1;
        if(c%2==0 && d%2!=0) ans = d;
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct edge{
    int to,cap,rev;
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};

const int INF=1001001001;
const int MAX_V=20010;
int S=MAX_V-2,T=MAX_V-1;
vector<edge>G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
    G[from].pb(edge(to,cap,G[to].size()));
    G[to].pb(edge(from,0,G[from].size()-1));
}

int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow=0;
    while(true){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow+=f;
    }
}

int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};

int H,W;
char fld[111][111];

signed main(){
    cin>>H>>W;
    rep(i,H)cin>>fld[i];

    rep(i,H)rep(j,W){
        if(fld[i][j]=='#')continue;
        add_edge(2*(i*W+j),2*(i*W+j)+1,fld[i][j]=='.'?1:INF);
        rep(d,4){
            int ny=i+dy[d],nx=j+dx[d];
            if(ny<0||ny>=H||nx<0||nx>=W)add_edge(2*(i*W+j)+1,T,INF);
            else if(fld[ny][nx]!='#')add_edge(2*(i*W+j)+1,2*(ny*W+nx),INF);
        }
        if(fld[i][j]=='X'){
            add_edge(S,2*(i*W+j),INF);
        }
    }

    int t=max_flow(S,T);
    if(t<=H*W){
        cout<<t<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 200010;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LLINF = 1000000000000000000;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
//

int main() {
    string a, b, res;
    cin >> a >> b;
    int n = a.size(), m = b.size();

    int tab[n+1][m+1];

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= m; j++) {
            if(!i or !j)
                tab[i][j] = 0;
            else if(a[i-1] == b[j-1]) {
                tab[i][j] = 1+tab[i-1][j-1];
            }
            else {
                tab[i][j] = max(tab[i][j-1], tab[i-1][j]);
            }
        }
    }

    int i = n, j = m;
    while(i and j) {
        if(tab[i-1][j] == tab[i][j])
            i--;
        else if(tab[i][j-1] == tab[i][j])
            j--;
        else {
            res.pb(a[i-1]);
            i--;
            j--;
        }
    }

    reverse(all(res));
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 38748
def calc(A, b):
    retval = 0
    for a in A:
        retval += abs(a - b)
    return retval


def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= (i + 1)

    print(calc(A, sorted(A)[(N)//2]))

#    left = min(A)
#    right = max(A)
#
#    while left < right:
#        c1 = (left + left + right) // 3       # floor
#        c2 = -(-(left + right + right) // 3)  # ceil
#        if calc(A, c1) <= calc(A, c2):
#            right = c2 - 1
#        else:
#            left = c1 + 1
#    print(calc(A, left))


if __name__ == "__main__":
    main()


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


int main() {
	string s;

	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[2]) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  string s;
  cin >> s;
  s[5] = s[13] = ' ';
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=3e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int T,n,m,t,k;
int ans;
int pre[200];
struct node{
	int a,b,c,d;
}a[20];
vector<int> s; 
void check() {
	int i,j;
	int sum=0;
	for(i=1;i<=t;i++) {
		int x=i;
		int a1=a[x].a,b1=a[x].b;
		if(s[b1]-s[a1]==a[x].c) {
			sum+=a[x].d;
		}
	} 
	ans=max(ans,sum);
} 
void dfs(int x,int mx) {
	int i,j;
	if(x>n) {
		check();
		return ;
	}
	for(i=mx;i<=m;i++) {
		s[x]=i;
		dfs(x+1,i);
	}
}
int main()
{
    int i,j;
	n=read();m=read();t=read();
	for(i=1;i<=t;i++) {
		a[i].a=read(),a[i].b=read(),a[i].c=read(),a[i].d=read();
	}

	s.resize(n+1);
	dfs(1,1);
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3696
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
#define bit(x, i) (x & (1 << i))
#define IN(i, l, r) (l < i && i < r)
#define LINR(i, l, r) (l <= i && i <= r)
#define LIN(i, l, r) (l <= i && i < r)
#define INR(i, l, r) (l < i && i <= r)
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define getS(x) scanf("%s", x)
#define clr(a, x) memset(a, x, sizeof(a))
#define char2Int(c) (c - '0')
#define SZ(x) ((int)((x).size()))
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// for debug
inline void pisz(int n) { printf("%d\n", n); }
#define DBG(vari) cerr << #vari << " = " << (vari) << endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ')
#define printV(a) printA(a, 0, a.size() - 1)
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

// struct

// data

int main() {
  int n, x, t;
  getIII(n, x, t);
  int ans = 0;
  while (n > 0) {
    ans += t;
    n -= x;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
int main()
{
	int w, a, b;
	while (scanf("%d %d %d", &w, &a, &b) != EOF)
	{
		if (b > a + w)
		{
			printf("%d\n", b - (a + w));
		}
		else if (a > b + w)
		{
			printf("%d\n", a - (b + w));
		}
		else
		{
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc106/tasks/abc106_d
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

template <class T> struct CumulativeSum2D {
    vector<vector<T>> data;

    CumulativeSum2D(int W, int H) : data(W + 1, vector<T>(H + 1, 0)) {}

    void add(int x, int y, T z) {
        ++x, ++y;
        if (x >= data.size() || y >= data[0].size())
            return;
        data[x][y] += z;
    }

    void build() {
        for (int i = 1; i < data.size(); i++) {
            for (int j = 1; j < data[i].size(); j++) {
                data[i][j] +=
                    data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    T query(int sx, int sy, int gx, int gy) {
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, Q;
    cin >> N >> M >> Q;
    CumulativeSum2D<int> sum(N + 1, N + 1);
    REP(i, M) {
        int l, r;
        cin >> l >> r;
        sum.add(l, r, 1);
    }
    sum.build();
    vector<int> ans;
    REP(i, Q) {
        int p, q;
        cin >> p >> q;
        int t = sum.query(p, p, q + 1, q + 1);
        ans.push_back(t);
    }
    for (auto &x : ans) {
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 2428
#!/usr/bin/env python2
#encoding: UTF-8

# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
import math
line=raw_input().rstrip().split(' ')
a=int(line[0])
b=int(line[1])
c=int(line[2])
if((a==7 and b==5 and c==5)or(a==5 and b==7 and c==5)or(a==5 and b==5 and c==7)):
    print 'YES'
else:
    print 'NO'

Measured memory_bytes: 2696
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) ans += i * (n - i + 1);
    for (ll i = 1; i < n; i++) {
        ll u, v; cin >> u >> v;
        ans -= min(u, v) * (n - max(u, v) + 1);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3652
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())

if N < 1200:
	print('ABC')
elif N < 2800:
	print('ARC')
else:
	print('AGC')


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <utility>
  
#define YNUM(X) ( X < 0 ? X + 3 : X )
  
int h, w;
bool map[502][502];
char in[502];
int data[3][502][502];
int data_max = 0;
int height_sum[502][502], width_sum[502][502];

int main(){
    while( std::cin >> h >> w, w + h != 0 ){
        data_max = 0;
  
        memset( height_sum, 0, sizeof(height_sum) );
        memset( width_sum, 0, sizeof(width_sum) );
  
        for( int i = 1; i <= h; ++i ){
            std::cin >> in;
            for( int l = 1; l <= w; ++l ){
                map[i][l] = ( in[l - 1] == '.' );
                if(map[i][l]){
                    width_sum[i][l] = width_sum[i][l - 1] + 1;
                    height_sum[i][l] = height_sum[i - 1][l] + 1;
                }
            }
        }
  
        for( int i = 1, n = 1; n <= h; n++, i = n % 3 ){
            for( int l = 1; l <= w; l++ ){
                memset( data[i][l], 0, sizeof(int) * 502 );
                if( map[n][l] ){
                    if( map[n - 1][l] && map[n][l - 1] ){
                        int x_cnt = width_sum[n][l], y_cnt = height_sum[n][l];
  
                        for( int m = 1; m < 502; ++m ){
                            if( data[YNUM(i - 1)][l][m] ){
                                data[i][l][std::min(m, x_cnt)] = std::max( data[i][l][std::min(m, x_cnt)], data[YNUM(i - 1)][l][m] + 1 );
                                data_max = std::max( data_max, std::min(m, x_cnt) * data[i][l][std::min(m, x_cnt)] );
                            }
                        }
                        for( int m = 1; m < 502; ++m ){
                            if( data[i][l - 1][m] ){
                                data[i][l][m + 1] = std::max( data[i][l][m + 1], std::min(data[i][l - 1][m], y_cnt) );
                                data_max = std::max( data_max, (m + 1) * data[i][l][m + 1] );
                            }
                        }
                          
                    }else if( map[n - 1][l] ){
                        for( int m = 0; m < 502; ++m ){
                            if( data[YNUM(i - 1)][l] ){
                                data[i][l][1] = std::max( data[i][l][1], data[YNUM(i - 1)][l][m] + 1 );
                                //data_max = std::max( data_max, data[i][l][1] );
                            }
                        }
  
                    }else if( map[n][l - 1] ){
                        for( int m = 1; m < 502; ++m ){
                            if( data[i][l - 1][m] ){
                                data[i][l][m + 1] = std::max( data[i][l][m + 1], 1 );
                                //data_max = std::max( data_max, (m + 1) * data[i][l][m + 1] );
                            }
                        }
  
                    }else data[i][l][1] = std::max( data[i][l][1], 1 )/*, data_max = std::max( data_max, data[i][l][1] )*/;
  
                }   
            }
        }
  
        std::cout << data_max << std::endl;
    }
    return 0;
}

Measured memory_bytes: 6340
g,a,b=map(int,input().split())
if g<=a:
  print(1)
else:
  if a<=b:
    print(-1)
  else:
    if (g-a)%(a-b)==0:
      print(2*((g-a)//(a-b))+1)
    else:
      print(2*((g-a)//(a-b)+1)+1)

Measured memory_bytes: 3060
import java.util.*;

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

    while (true){
      int x = sc.nextInt();
      if (x==0) break;
      System.out.println("Case "+i+": "+x);
      i++;
    }
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

int power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int main() {
    int H,W,K;
    cin>>H>>W>>K;
    if(W==1){
        cout<<1<<endl;return 0;
    }
    vector<vector<ll>> dp(W,vector<ll>(H+1));
    dp[0][0]=1;
    rep(h,H){
        rep(S,power(2,W-1)){
            vector<int> line(W-1);
            bitset<8> SC=S;
            rep(i,W-1){
                line.at(i)=SC.test(i);
            }
            bool nex=false;
            rep(i,W-2){
                if(line.at(i)==1 && line.at(i+1)==1)nex=true;
            }
            if(nex)continue;
            //cout<<line.at(0)<<line.at(1)<<endl;
            rep(i,W-1){
                if(line.at(i)){
                    dp[i][h+1]+=dp[i+1][h];
                    dp[i+1][h+1]+=dp[i][h];
                    dp[i][h+1]%=MOD;
                    dp[i+1][h+1]%=MOD;
                }
            }
            if(line.at(0)==0){
                dp[0][h+1]+=dp[0][h];
                dp[0][h+1]%=MOD;
            }
            if(line.at(W-2)==0){
                dp[W-1][h+1]+=dp[W-1][h];
                dp[W-1][h+1]%=MOD;
            }
            for(int i=1;i<W-1;i++){
                if(line.at(i-1)==0 && line.at(i)==0){
                    dp[i][h+1]+=dp[i][h];
                    dp[i][h+1]%=MOD;
                }
            }
        }
    }
    
    cout<<dp[K-1][H]<<endl;
}

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

long long int N, T;
long long int res = 0;

int main(){
  cin >> N >> T;
  long long int t, pt;
  cin >> pt;
  for(int i = 1; i < N; i++){
    cin >> t;
    cerr << t << " "<< pt << endl;
    if(t - pt < T){
      res += (t - pt);
    }else{
      res += T;
    }
    pt = t;
  }
  res += T;
  
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long lli;
#define REP(i,x)for(int i=0;i<(int)x;i++)
const int MAX_N=911111;
const lli MOD=1000000007;
lli fact[MAX_N],rfact[MAX_N];
lli mod_pow(lli a,lli b,lli M){
    if(b==0)return 1;
    lli res=mod_pow((a*a)%M,b/2,M);
    if(b&1)res=(res*a)%M;
    return res;
}
void init(){
    fact[0]=rfact[0]=1;
    REP(i,MAX_N-1){
        fact[i+1]=fact[i]*(i+1)%MOD;
        rfact[i+1]=rfact[i]*mod_pow(i+1,MOD-2,MOD)%MOD;
    }
}
lli comb(int n,int k){
    if(n<k)return 0;
    if(k<0)return 0;
    return (((fact[n]*rfact[k])%MOD)*rfact[n-k])%MOD;
}
lli N,M,K;
lli solve(lli n,lli k){
    return (comb(n,k)-comb(n,k-1 )+MOD*2)%MOD;
}
int main() {
    init();
    cin>>N>>M>>K;
    lli ans=0;
    REP(x,K+1){
        lli y=K-x;
        ans+=(solve(x*2+N,x)*solve(y*2+M,y)%MOD)*comb(N+M+x*2+y*2,x*2+N)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14000
#include <iostream>
#include <climits>
#include <stdio.h>
using namespace std;

int a(int num){
	return num * 2;
}

int b(int num, int k){
	return num + k;
}

int main(void){
	int num, n, k, i, j, min = INT_MAX;
	cin >> n;
	cin >> k;
	for (i = 0; i < n+1; ++i){
		num = 1;
		for (j = 0; j < n-i; ++j){
			num = a(num);
		}
		for (j = 0; j < i; ++j){
			num = b(num, k);
		}
		if (num < min){
			min = num;
		}
		//cout << i << '\n' << num << endl;;
	}
	cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
using namespace std;
int fun(vector<vector<int>>&a,int p,vector<int>&v,int n)
{
    v[p]=1;
    int c=1;
    for(int i=0;i<a[p].size();i++)
    {
        if(v[a[p][i]]==0)
        c+=fun(a,a[p][i],v,n);
    }
    return c;
}
int dfs(vector<vector<int>>&a,int p,int n)
{
    int m=0;
    vector<int>v(n,0);
    for(int i=0;i<n;i++)
    {
        if(v[i]==0)
        {
            int t=fun(a,i,v,n);
            // cout<<t<<" ";
            if(t>0&&t>m)
            m=t;
        }

    }
    return m;
}
int main() {
    int n,m;cin>>n>>m;
    vector<vector<int>>a(n);
    set<pair<int,int>>t;
    for(int i=0;i<m;i++)
    {
        int p,q;cin>>p>>q;
        if(t.find(make_pair(p-1,q-1))==t.end()&&t.find(make_pair(q-1,p-1))==t.end())
        {
            a[p-1].pb(q-1);
            a[q-1].pb(p-1);
            t.insert(make_pair(p-1,q-1));
            t.insert(make_pair(q-1,p-1));
        }
    }
    cout<<dfs(a,0,n)<<endl;
    return 0;
}


Measured memory_bytes: 46164