akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

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

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

    string s;
    cin >> s;
    int n = s.length();
    ll lb = 0, ub = n + 1;
    while(ub - lb > 1){
        int k = (lb + ub) >> 1;
        bool ok = true;
        for(int i = n - k; i + 1 < k; ++i){
            if(s[i] != s[i + 1]){
                ok = false;
                break;
            }
        }
        if(ok)  lb = k;
        else    ub = k;
    }
    cout << lb << endl;
}

Measured memory_bytes: 3796
import sys
sys.setrecursionlimit(10000000)

n,m=map(int,input().split())
friend=dict()
# 関係をdictにとる
for i in range(m):
  a,b=map(int,input().split())
  if a-1 in friend:
    friend[a-1].append(b-1)
  else:
    friend[a-1] = [b-1]
  if b-1 in friend:
    friend[b-1].append(a-1)
  else:
    friend[b-1] = [a-1]
# 次に、数珠つなぎでdfs
memo = [0]*n

def dfs(who,v):
  if memo[who]:
    return 0
  memo[who] = v
  res = 1
  if who not in friend:
    return 1
  for x in friend[who]:
    res += dfs(x, v)
  return res

ans = 0
c = 1
for i in range(n):
  if not memo[i]:
    ans = max(ans, dfs(i,c))
    c += 1
print(ans)	

Measured memory_bytes: 240072
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, ans;

int main()
{
	in >> N;
	std::vector<LL>A(N + 1);
	rep(i, N) in >> A[i + 1];
	rep(i, N) A[i + 1] += A[i];
	++N;
	std::sort(A.begin(), A.end());
	rep(i, N)
	{
		auto l = std::lower_bound(A.begin() + i + 1, A.end(), A[i]);
		auto r = std::upper_bound(A.begin() + i + 1, A.end(), A[i]);
		ans += r - l;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#include "iostream"
using namespace std;
int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	W -= r;
	H -= r;
	if (x >= r && y >= r && x <= W && y <= H){
		cout << "Yes" << endl;
	}else	{
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<char,int> M;
const ll mod=1000000000+7;

int main(){
    set<int> s;
    int A,B,C;
    cin>>A>>B>>C;
    s.insert(A);
    s.insert(B);
    s.insert(C);
    if(s.size()==2)cout<<"Yes";
    else cout<<"No";
}

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

using namespace std;

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

    vector<vector<pair<int32_t, int32_t>>> A(n);

    for (int32_t i = 0; i < n; i++) {
        int32_t u, k;
        cin >> u >> k;

        for (int32_t j = 0; j < k; j++) {
            int32_t v, c;
            cin >> v >> c;
            A[u].push_back(make_pair(c, v));
        }
    }

    vector<int32_t> d(n, INT32_MAX);
    vector<bool> visited(n, false);
    priority_queue<pair<int32_t, int32_t>, vector<pair<int32_t, int32_t>>, greater<pair<int32_t, int32_t>>> q;
    q.push(make_pair(0, 0));

    while (!q.empty()) {
        int32_t u, d_u;
        tie(d_u, u) = q.top();
        q.pop();

        if (visited[u]) continue;
        visited[u] = true;

        d[u] = d_u;

        for (auto e : A[u]) {
            int32_t v, d_uv;
            tie(d_uv, v) = e;

            if (d[v] > d_u + d_uv) {
                q.push(make_pair(d_u + d_uv, v));
            }
        }
    }

    for (int32_t i = 0; i < n; i++) {
        cout << i << " " << d[i] << endl;
    }

    return 0;
}

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

using namespace std;

struct Item {
    int a, b, c;
};

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

    int n, ma, mb;

    cin >> n >> ma >> mb;
    vector<Item> itm(n);
    for (int i = 0; i < n; ++i)
        cin >> itm[i].a >> itm[i].b >> itm[i].c;

    const int MAX_C = 200 * n;
    vector<vector<vector<int>>> min_cost(n + 1,
                                         vector<vector<int>>(n * 10 + 1, vector<int>(n * 10 + 1, MAX_C)));

    for (int i = 0; i < n; ++i)
        min_cost[i][itm[i].a][itm[i].b] = itm[i].c;

    for (int i = 1; i < n; ++i)
        for (int a = 0; a <= n * 10; ++a)
            for (int b = 0; b <= n * 10; ++b)
                if (min_cost[i - 1][a][b] != MAX_C) {
                    min_cost[i][a + itm[i].a][b + itm[i].b] = min(min_cost[i][a + itm[i].a][b + itm[i].b],
                                                                  min_cost[i - 1][a][b] + itm[i].c);
                    min_cost[i][a][b] = min(min_cost[i][a][b], min_cost[i - 1][a][b]);
                }

    int ans = MAX_C;
    for (int a = 0; a <= n * 10; ++a)
        for (int b = 0; b <= n * 10; ++b)
            if (min_cost[n - 1][a][b] != MAX_C && ma * b == mb * a)
                ans = min(ans, min_cost[n - 1][a][b]);

    if (ans == MAX_C)
        cout << "-1\n";
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27264
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };



int main() {
	int n;
	cin >> n;
	int s[1000] = { 0 };
	rep(i, 2, n+1) {
		int x = i;
		int j = 2;
		while (x > 1) {
			if (x % j == 0) {
				s[j]++;
				x /= j;
				j = 1;
			}
			j++;
		}
	}
	ll ans = 1;
	rep(i, 0, 1000) {
		ans *= (s[i] + 1);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC";
  if (s == "ARC") cout << "ABC";
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int r, g, b, n; cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0; i*r<=n; i++){
        for(int j=0; i*r+j*g<=n; j++){
            int x=n-(i*r+j*g);
            if(x%b==0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int a, b, c, x, b2, cnt=0;
int main(){
	cin >> a >> b >> c >> x;
	for(int i=0; i<=a; i++){
		for(int j=0; j<=b; j++){
			for(int k=0; k<=c; k++){
				if(500*i+100*j+50*k == x){
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3580
l = int(raw_input())
r = int(raw_input())
if l == r:
	print 1
	exit(0)
k = l ^ r
while k != (k & -k):
	k ^= k & -k
l &= (k << 1) - 1
r &= k - 1
while r != (r & -r):
	r ^= r & -r
r = r * 2 - 1 if r else 0
print 2 * k - l if r >= l else (k - l << 1) + r + 1

Measured memory_bytes: 2820
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;
lli GCD(int a, int b) {
	int x = max(a, b);
	int y = min(a, b);
	int r = x % y;
	while (r > 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return (lli)y;
}

int main(void)
{
	lli N; cin >> N;
	lli ans = 0;
	rep(i, 1, N + 1) {
		rep(j, i, N + 1) {
			rep(k, j, N + 1) {
				lli gcd = GCD(k, GCD(i, j));
				if (i == j && j == k)ans += gcd;
				else if (i == j || j == k || k == i)ans += gcd * 3;
				else ans += gcd * 6;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
char s[310];
int l, K;
int dp[2][310][310];
void upd(int &v, int x) {
	if (v < x) v = x;
}
int main() {
	scanf("%s%d", s, &K);
	for (l = 0; s[l]; l++) ;
	for (int i = 0; i < l; i++) {
		dp[0][i][i+1] = 1;
	}
	for (int i = 2; i <= l; i++) {
		for (int j = 0; j < l - i + 1; j++) {
			if (s[j] == s[j+i-1]) {
				upd(dp[0][j][j+i], dp[0][j+1][j+i-1] + 2);
			}
			upd(dp[0][j][j+i], dp[0][j+1][j+i]);
			upd(dp[0][j][j+i], dp[0][j][j+i-1]);
		}
	}
	int y = 0, z = 1;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j <= l; j++) {
			for (int k = 0; k <= l; k++) {
				dp[z][j][k] = j + 1 == k;
			}
		}
		for (int j = 2; j <= l; j++) {
			for (int k = 0; k < l - j + 1; k++) {
				if (s[k] == s[k+j-1]) {
					upd(dp[z][k][k+j], dp[z][k+1][k+j-1] + 2);
				} else {
					upd(dp[z][k][k+j], dp[y][k+1][k+j-1] + 2);
				}
				upd(dp[z][k][k+j], dp[y][k][k+j]);
				upd(dp[z][k][k+j], dp[z][k+1][k+j]);
				upd(dp[z][k][k+j], dp[z][k][k+j-1]);
			}
		}
		y ^= 1;
		z ^= 1;
	}
	printf("%d\n", dp[y][0][l]);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), index(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        index[a[i]] = i;
    }
    // a[i]が最小値となるような区間の数を求める
    // (i-l+1)*(r-i+1)個
    // lとrを求める
    // a[i]=n,n-1,n-2...の順で求める
    // l:i以下で最大,r:i以上で最小
    set<ll> s;
    s.insert(-1);
    s.insert(n);
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        s.insert(index[i]);
        auto itr = s.lower_bound(index[i]);
        ans += (ll)i * (index[i] - *prev(itr)) * (*next(itr) - index[i]);
    }
    cout << ans << endl;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s;
  bool f = false;
  cin >> s;
  if(s[0] != 'A'){
    cout << "WA\n";
  } else {
    rep(i, 1, s.size()){
      if('a' > s[i] || s[i] > 'z'){
	if(s[i] != 'C'){
	  cout << "WA\n";
	  return 0;
	} else if(!(2 <= i && i <= s.size() - 2)){
	  cout << "WA\n";
	  return 0;
	} else {
	  if(f){
	    cout << "WA\n";
	    return 0;
	  }
	  f = true;
	}
      }
    }
    if(f){
      cout << "AC\n";
    } else {
      cout << "WA\n";
    }
  }
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(n), b(n), c(n - 1);
  for (auto&& e : a) cin >> e;
  for (auto&& e : b) cin >> e;
  for (auto&& e : c) cin >> e;
  for (auto&& e : a) e--;
  for (auto&& e : b) ans += e;
  for (int i = 0; i < n - 1; i++)
    if (a[i] + 1 == a[i + 1]) ans += c[a[i]];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

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

using namespace std;

typedef long long ll;

ll dp[31];

int main(){
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 3; i <= 30; ++i){
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	rep(i, 31){
		dp[i] = (dp[i] + 3649) / 3650;
	}
	while(1){
		int n;
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		printf("%lld\n", dp[n]);
	}
	return 0;
}

Measured memory_bytes: 1028
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
stdin.readline()
ar = [int(s) for s in stdin.readline().split()]
print(*ar)
for j in range(1, len(ar)):
    key = ar[j]
    i = j - 1
    while i >= 0 and ar[i] > key:
        ar[i+1] = ar[i]
        i -= 1
    ar[i+1] = key
    print(*ar)

Measured memory_bytes: 4236
from collections import Counter
from math import factorial

N = int(input())
s = [input() for _ in range(N)]

for i in range(N):
  s[i] = list(s[i])
  s[i].sort()
  s[i] = "".join(s[i])
  
x = Counter(s).most_common()
cnt = 0
for i in range(len(x)):
  if x[i][1] >1:
    cnt += factorial(x[i][1]) // 2 // factorial(x[i][1] -2)
print(cnt)

Measured memory_bytes: 24556
from collections import deque
from bisect import bisect_left

n = int(input())
a = [int(input()) for _ in range(n)]

b = deque([])

for ai in a:
    if len(b) == 0:
        b.append(ai)
    else:
        if ai <= b[0]:
            b.appendleft(ai)
        else:
            idx = bisect_left(b, ai)
            b[idx-1] = ai

print(len(b))


Measured memory_bytes: 8060
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<utility>
#include<map>
#include<climits>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<int,P>MP;
typedef vector<vector<int>> MX;

const ll MOD=1e9+7;
const int INF=1000000000;

int main()
{
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;

}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
if(x==y&&y==z)std::cout << 1 << '\n';
else if(x==y||y==z||x==z)std::cout << 2 << '\n';
else std::cout << 3 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.cct", "r", stdin);
	string str = "";
	string res = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i,j;
	for (i = 0; i < n; ++i){
		getline (cin, str );
		stringstream ss(str);
		vector <double> X(3, 0.);
		vector <double> Y(3, 0.);
		for (j = 0; j < 3; ++j){
			double x, y;
			ss >> x >> y;
//			cout << '(' << x << ',' << y << ')' << endl;
			X[j] = x; Y[j] = y;
		} // end for
		vector <double> mx(3, 0.);
		vector <double> my(3, 0.);

		for (j = 0; j < 3; ++j){
			mx[j] = (X[j] + X[(j+1) % 3])/2.;
			my[j] = (Y[j] + Y[(j+1) % 3])/2.;
//			cout << '(' << mx[j]<< ',' << my[j] << ')' << endl;
		} // end for
		vector <double> a(3, 0.);
		vector <double> b(3, 0.);
		vector <double> c(3, 0.);

		for (j = 0; j < 3; ++j){
			if (X[(j+1) % 3] == X[j]){
				a[j] = 0.0;
				b[j] = 1.0;
				c[j] = -my[j];
			}else if (Y[(j+1) % 3] == Y[j]){
				a[j] = 1.0;
				b[j] = 0.0;
				c[j] = -mx[j];
			}else{
				a[j] = (X[(j+1) % 3] - X[j]);
				b[j] = (Y[(j+1) % 3] - Y[j]);
 				c[j] = -a[j]*mx[j] - b[j]*my[j];
			} // end if
		} // end for
		vector <double> cx (3, X[0]);
		vector <double> cy (3, Y[0]);
		set <double> Cx, Cy;
		for (j = 0; j < 3; ++j){
			//cout << a[j] << ' ' << b[j] << ' ' << c[j] << endl;
			if (a[j] == 0. && b[j] != 0.) {
				cy[j] = -c[j]/b[j];
			}else if (a[(j+1) % 3] == 0. && b[(j+1) % 3] != 0.){
				cy[j] = -c[(j+1) % 3]/b[(j+1) % 3];
			} // end if
			if (a[j] != 0. && b[j] == 0.){
				cx[j] = -c[j]/a[j];
			}else if (a[(j+1) % 3] != 0. && b[(j+1) % 3] == 0.){
				cx[j] = -c[(j+1) % 3]/a[(j+1) % 3];
			} // end if
			if (cx[j] == X[0] || cy[j] == Y[0] ){
				double D = a[j]*b[(j+1) % 3] - b[j]*a[(j+1) % 3];
				if (cx[j] == X[0]){
					cx[j] = ( -b[(j+1) % 3]*c[j] + b[j]*c[(j+1) % 3])/D;
				} // end if
				if (cy[j] == Y[0]){
					cy[j] = (  a[(j+1) % 3]*c[j] - a[j]*c[(j+1) % 3])/D;
				} // end if
			} // end if
			Cx.insert (cx[j]);
			Cy.insert (cy[j]);
	//		cout << '(' << cx[j] << ',' << cy[j] << ')' << endl;	
		} // end for
		double CX = *(Cx.begin() );
		double CY = *(Cy.begin() );
		double R = sqrt( (CX - X[0])*(CX - X[0]) + (CY - Y[0])*(CY - Y[0]) );

		cout.setf( ios::fixed ); 
		cout.precision(3);
		cout <<  CX << ' ' << CY << ' ' << R << endl;
 	} // end for

		
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int n, m;
vector<int> G[100010];
int a[100010];
int dp[100010];

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

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    a[y]++;
  }
  priority_queue<int> pq;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) pq.push(i);
  }
  while (!pq.empty()) {
    int tp = pq.top();
    pq.pop();
    for (int i = 0; i < G[tp].size(); i++) {
      dp[G[tp][i]] = max(dp[G[tp][i]], dp[tp] + 1);
      a[G[tp][i]]--;
      if (a[G[tp][i]] == 0) pq.push(G[tp][i]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, a, b) for (int i = (a); i < (b); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (i % 2 == 0 and a % 2) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);
		String text;
		String endText = "END OF INPUT";
		while(!(text = br.readLine()).equals(endText)) {
			String[] word = text.split(" ", 0);
			for(int i = 0 ; i < word.length ; i++) {
				System.out.print(word[i].length());
			}
			System.out.println();
		}
	}

}



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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a + b < 24){
    cout << a + b;
  }
  else{
    cout << a + b - 24;
  }
}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll mn=inf; int ans;
  for(int i=1;i<n;i++){
    if(abs(a[i]-(double)a[0]/2)<mn){
      mn=abs(a[i]-(double)a[0]/2);
      ans=a[i];
    }
  }
  cout << a[0] << " " << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int 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};

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  ll gcd = __gcd(A,B);
  auto L = prime_factor(gcd);
  cout << L.size() + 1;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main()
{
    int n;
    while(cin>>n, n) {
        vector<int> p(n), j(n-1);
        long long int ans;
        long long int sum;
        for(int i=0; i<n; i++) cin>>p[i];
        for(int i=0; i<n-1; i++) cin>>j[i];
        sort(j.begin(), j.end());
        sum = accumulate(p.begin(), p.end(), 0);
        ans = sum * n;
        for(int i=n-2; i>=0; i--) {
            sum += j[i];
            ans = max(ans, sum*(i+1));
        }
        cout<<ans<<endl;
    }
}

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

int main(){
  long long int N;
  long long int n;
  int y=0;
  int z;
  cin>>N;
  n=N;
  long long int x=1;
  for(int i=1;i<11;i++){
    z=N%(x*10);
    y+=z/x;
    N-=z;
    x*=10;
  }
  if(n%y==0){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}
  

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

int p[3000];

void leap(){
	fill(p, p+3000, false);
	for(int i=1; i < 3000; i++){
		if(i % 400 == 0) p[i] = true;
		else if(i % 100 == 0) continue;
		else if(i % 4 == 0) p[i] = true;
	}
}

int main(){
	leap();
	int a, b;
	bool hoge = false;
	while(cin >> a >> b, a || b){
		bool empty = false;
		if(!hoge) hoge = true;
		else cout << endl;

		for(int i=a; i <= b; i++){
			if(p[i]){
				cout << i << endl;
				empty = true;
			}
		}
		if(!empty) cout << "NA" << endl;
	}
}

Measured memory_bytes: 1172
#include<stdio.h>
int main (){
char a[5],b[5];
scanf("%s%s", a,b);
if (a[0] == 'H' && b[0] == 'H') printf("H\n");
if (a[0] == 'D' && b[0] == 'D') printf("H\n");
if (a[0] == 'H' && b[0] == 'D') printf("D\n");
if (a[0] == 'D' && b[0] == 'H') printf("D\n");
return 0;
}

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

using namespace std;

int a[25], b[25], c[25];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i){
        cin >> b[i];
    }
    for (int i = 0; i < n-1; ++i){
        cin >> c[i];
    }
    int s = 0;
    for (int i = 0; i < n; ++i){
        s += b[a[i] - 1];
        if (a[i] - a[i-1] == 1){
            s+=c[a[i-1]-1];
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int a, b, c;
    cin >> a >> b >> c;
    int x, y;
    cin >> x >> y;

    llong ans = 0;

    if (a + b >= 2*c){
        ans += 2*c * min(x, y);

        int n_remain;
        int remain_val;
        if (x < y){
            n_remain = y - x;
            remain_val = b;
        }else{
            n_remain = x - y;
            remain_val = a;
        }
        ans += min(remain_val*n_remain, c*n_remain*2);
    }else{
        ans += a*x + b*y;
    }

    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

const int MAX_V = 200010;

int par[MAX_V];
int rank_[MAX_V];

void init(int n) {

    for (int i = 0; i < n; ++i) {
        par[i] = i;
        rank_[i] = 0;
    }
}

int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]); //経路圧縮
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }
}

struct edge {
    ll u, v, cost;
};

vector<edge> E;

bool comp(edge &e1, edge &e2) {
    return e1.cost < e2.cost;
}

ll kruskal(int n) {
    sort(E.begin(), E.end(), comp);
    init(n);
    ll res = 0;
    for (auto e : E) {
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int s, d;
    int dist;
    while (1) {
        cin >> s >> d;
        if (s == 0 && d == 0) break;
        E.clear();

        rep(i, s) rep(j, d) {
            cin >> dist;
            if (dist == 0) continue;
            E.push_back({i, s + j, dist});
        }

        rep(i, d) REP(j, i + 1, d) {
            cin >> dist;
            if (dist == 0) continue;
            E.push_back({s + i, s + j, dist});
        }

        rep(i, s) REP(j, i + 1, s) {
            E.push_back({i, j, 0});
        }

        cout << kruskal(s + d) << endl;

    }

    return 0;
}




Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ll K, num=0, x, ans = 0;

	cin >> K;
	set<ll> st;

	x = 7 % K;
	rep(i,K){
		if (st.count(x) == 1){
			ans = -1;
			break;
		}
		if (x == 0){
			ans = i+1;
			break;
		}
		st.insert(x);
		x = (x * 10 + 7) % K;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 50408
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int fact[20];
void fac()
{
	fact[0]=1;
	for(int i= 1; i<21; i++)
		fact [i]= i*fact[i-1];
}


int com(int g ,int y)
{
	return (fact[g]/fact[y]/fact[g-y]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	fac();
	string s;
	ll k;
	cin>>k;
	s = to_string(k);
	set<string>st[2];
	int x =0;
	st[x].insert(s);
	for(int i =1; i<s.length(); i++)
	{
		for(auto it: st[x])
		{
			for(int  j =1; j<it.length();j++)
			{
				if((it[j] != '+')&& (it[j-1]!='+') && (it[j+1]!='+'))
					st[x^1].insert(it.substr(0,j)+'+'+it.substr(j,it.length()-j));
			}
		}
		for(auto it: st[x^1])
		{
			// cout<<it<<endl;
			string d ="";
			for(int  j =0; j<int(it.length()); j++)
			{
				// cout<<d<<endl;
				if(it[j]=='+')
				{
					k += stoi(d);
					d = "";
				}
				else
					d = d+it[j];
			}
			k += stoi(d);
		}
		st[x].clear();
		x ^=1;
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())

S = input()




flag = True

for i in range(C-A):

    i += A
    i -= 1

    if S[i] == "#" and S[i+1] == "#":
        flag = False

for i in range(D-B):

    i += B
    i -= 1

    if S[i] == "#" and S[i+1] == "#":
        flag = False

flag2 = True

if C > D:

    flag2 = False

    for i in range(D-B+1):

        i += B-1
        i -= 1

        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag2 = True

        #print (i,i+1,i+2)

if flag and flag2:
    print ("Yes")

else:
    print ("No")


Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

struct Process {
  char name[18];
  unsigned short time;
  int remaining;

  Process* next;
  Process* prev;
};

class Queue {
 public:
  Queue() : first_(NULL), last_(NULL), size_(0) {}

  bool Empty() const {
    return size_ == 0;
  }

  Process* Pop() {
    if (!first_) {
      return NULL;
    }
    Process* r = first_;
    first_ = first_->next;
    --size_;
    return r;
  }

  void Push(Process* p) {
    ++size_;
    if (!first_) {
      first_ = p;
    }
    if (!last_) {
      last_ = p;
      return;
    }
    p->prev = last_;
    last_->next = p;
    p->next = NULL;
    last_ = p;
  }

 private:
  Process* first_;
  Process* last_;
  size_t size_;
};

static void RoundRobin(int quantum, vector<Process>& processes) {
  Queue q;
  for (size_t i = 0; i < processes.size(); ++i) {
    q.Push(&processes[i]);
  }

  int elapsed = 0;
  while (!q.Empty()) {
    Process* p = q.Pop();

    // evict
    if (p->remaining - quantum <= 0) {
      elapsed += p->remaining;
      p->remaining = 0;
      printf("%s %d\n", p->name, elapsed);
      continue;
    }
    p->remaining -= quantum;
    elapsed += quantum;
    q.Push(p);
  }
}

int main() {
  int n, q;
  cin >> n;
  cin >> q;

  vector<Process> processes;
  Process p;
  for (int i = 0; i < n; ++i) {
    cin >> p.name;
    cin >> p.time;
    p.remaining = p.time;
    // Need to initialize to avoid the use-of-uninitialized value.
    p.next = NULL;
    p.prev = NULL;
    processes.push_back(p);
  }

  RoundRobin(q, processes);

  return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define fi first
#define se second
#define pb push_back
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define inf 1000000007
#define maxn 100007
#define task "A"
#define reset(x) memset(x,0,sizeof(x))
#define dscan(x) scanf("%d", &x)
#define lldscan(x) scanf("%lld", &x)
#define cscan(x) scanf("%c", &x)
#define sscan(x) scanf("%s", &x)
using namespace std;

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

typedef pair<int,int> ii;
int a, b, c;

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void open() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
}

void read() {
    cin >> a >> b >> c;
}

void solve() {
    if (b+c-a<0) cout << 0; else cout << b+c-a;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

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


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var s = readLine()!!.toString()
    var c = mutableMapOf<Char, Int>('R' to 0, 'G' to 0, 'B' to 0)
    var num: Int
    for (i in s) {
        c[i] = c.get(i)!! + 1
    }
    var diff = 0
    var ans = 1L
    for (d in 1..((n-1)/2)){
        for (i in 0..(n-d-d-1)) {
            if (s[i] != s[i+d] && s[i+d] != s[i+d+d] && s[i+d+d] != s[i]) {
                diff += 1
            }
        }
    }
    for ((x, y) in c){ans *= y}
    println(ans-diff)
}


Measured memory_bytes: 37264
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
//			re%=mod;
		}
		a=(a*a);
//		a%=mod;
		b>>=1;
	}
	return re;
}
bool vis[20];
bool re;
bool gra[20][20];
int d;
void dfs(int i )
{
	if(i==d)
	{
		re=1;
		return;
	}
	vis[i]=1;
	FOR(j,0,20)
	{
		if(gra[i][j] && vis[j]==0)
		dfs(j);
		if(re)
		return;
	}
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n,k;
		cin>>n>>k;
		ll a[n];
		FOR(i,0,n)
		{
			cin>>a[i];
			
		}
		FOR(i,k,n)
		{
			if(a[i]>a[i-k])
			{
				cout<<"Yes\n";
			}
			else
			cout<<"No\n";
		}
	}
	return 0;
}

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


int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];

  vector<vector<ll> > road(N);
  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    road[a].push_back(b);
    road[b].push_back(a);
  }

  vector<int> good_tower(N, 0);
  rep(i, N) {
    if (good_tower[i] == 0) {
      ll h = H[i];
      bool is_good = true;
      for (ll j : road[i]) {
        if (h <= H[j]) {
          is_good = false;
        } else {
          good_tower[j] = -1;
        }
      }
      if (is_good) {
        good_tower[i] = 1;
      }
    }
  }

  int ans = 0;
  rep(i, N) if (good_tower[i] == 1) ans++;
  cout << ans << endl;
  return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;

  int L[2010][2010], R[2010][2010], D[2010][2010], U[2010][2010];
  bool grid[2010][2010];
  for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
char a;
  cin>>a;
  if(a=='.') grid[i][j]=true;
  else grid[i][j]=false;

  }
  }

  
  for(int i=0; i<H; i++){
    int cur=0;
    for(int j=0; j<W; j++){
if(grid[i][j]==false) cur=0;
     else cur++;
      L[i][j]=cur;
    }
  }
      for(int i=0; i<H; i++){
    int cur=0;
    for(int j=W; j>-1; j--){
if(grid[i][j]==false) cur=0;
     else cur++;
      R[i][j]=cur;
    }
      }
        for(int j=0; j<W; j++){
    int cur=0;
    for(int i=0; i<H; i++){
if(grid[i][j]==false) cur=0;
     else cur++;
      U[i][j]=cur;
    }  
        }
          
     for(int j=0; j<W; j++){
    int cur=0;
    for(int i=H; i>-1; i--){
if(grid[i][j]==false) cur=0;
     else cur++;
      D[i][j]=cur;
      }
     }
  int res=0;
       for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
      res=max(res,D[i][j]+U[i][j]+R[i][j]+L[i][j]);
}
       }
  
    cout<<res-3<<endl;
}


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

using namespace std;

const int MAX_VALUE = (1 << 31) - 1;

int main() {
	// your code goes here
	//cout << MAX_VALUE << endl;
	int  n, i, j, k;
	cin >> n;
	int gain_table[3][n], ans_table[3][n];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 3; j++)
		{
			cin >> gain_table[j][i];
			ans_table[j][i] = -1;
		}
	}
	ans_table[0][0] = gain_table[0][0];
	ans_table[1][0] = gain_table[1][0];
	ans_table[2][0] = gain_table[2][0];
	for (i = 0; i < n - 1; i++)
	{
		//cout << ans[i] << " ";
		for (j = 0; j < 3; j++)
		{
			for (k = 1; k <=2; k++)
			{
				if ((ans_table[(j+k)% 3][i+1]) < (ans_table[j][i] + gain_table[(j+k)% 3][i+1]))
				{
					ans_table[(j+k)% 3][i+1] = ans_table[j][i] + gain_table[(j+k)% 3][i+1];
				}
			}
		}
		
	}
	int max = ans_table[0][n-1];
	for (i = 1; i < 3; i++)
	{
		if (max < ans_table[i][n-1])
		{
			max = ans_table[i][n-1];
		}
	}
	cout << max;
	return 0;
}

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

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h); rep(i, h) cin >> s[i];
    vector<vector<int>> cnt(h, vector<int>(w, 0));

    rep(i, h){
        vector<int> done(w);
        rep(j, w){
            if(s[i][j] == '#') continue;
            if(done[j]) continue;
            int l = 0;
            while(j+l < w){
                if(s[i][j+l] == '#') break;
                l++;
            }
            rep(k, l){
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }

    rep(j,w) {
        vector<int> done(h);
        rep(i,h) {
            if (s[i][j] == '#') continue;
            if (done[i]) continue;
            int l = 0;
            while (i+l < h) {
                if (s[i+l][j] == '#') break;
                l++;
            }
            rep(k,l) {
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }

    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
    cout << ans << endl;

    return 0;
}


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

namespace ABC153C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long k = long.Parse(input[1]);

            if(k >= n)
            {
                Console.WriteLine("0");
                Environment.Exit(0);
            }


            string[] input2 = Console.ReadLine().Split(' ');
            long[] enemys = new long[n];
            enemys = input2.Select(long.Parse).ToArray();

            Array.Sort(enemys);
            Array.Reverse(enemys);

            for(long i = 0; i < k; i++)
            {
                enemys[i] = 0;
            }




            Console.WriteLine(enemys.Sum());
        }
    }
}


Measured memory_bytes: 35328
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    int cnt = 1;
    
    while (cnt < B) {
      cnt = cnt + (A - 1);
      ans++;
    }
    System.out.println(ans);
  }
}


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

int main() {
  int N;
  cin>>N;
  if (N==1) {
    cout<<"Hello World"<<endl;
  }
  else if (N==2) {
    int A,B;
    cin>>A>>B;
    cout<<A+B<<endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {
  ll t,k;
        ll c=0,d=0,e,n,sum=1,i,sum1=1,sum2=1,sum3=1,r,sum4=1,a,b;
          cin>>a;
           if(a==0)
            cout<<1;
           else
            cout<<0;

    
 }


Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 255
#define ll long long
#define mod 1000000007
int n, k, ans, g, Ga, Gb;
int c[N][N], S[N];
char s[N];
void Calc()
{
	int ga = g, gb = g, tot = 0;
	for (int i = 1; i <= k; i++)
		if (s[i] == 'r' && ga)
			ga--;
		else
			if (s[i] == 'b' && gb > ga && S[gb] > 1)
				tot += S[gb] - 2, gb--;
			else
				if (tot)
					tot--;
	for (; S[gb] == 1;)gb--;
	if (ga || gb || tot)
		return;
	tot = 1;
	for (int i = 1, j = 0; i <= g; i = j + 1)
	{
		for (; j < g && S[j + 1] == S[i];)j++;
		tot = (ll)tot * c[j][j - i + 1] % mod;
	}
	ga = Ga - 1;
	gb = Gb + Ga;
	ans = ((ll)tot * c[n - ga + gb][gb] + ans) % mod;
}
void Find(int m, int w, int len)
{
	Calc();
	++g;
	int la = Ga, lb = Gb;
	for (int i = len; m + (i == 1 ? 2 : i * 2 - 2) <= n + 1 && w + i <= k; i++)
	{
		Ga = la + (i == 1 ? 2 : i * 2 - 2), Gb = lb + (i > 1) * 2, S[g] = i;
		Find(m + (i == 1 ? 2 : i * 2 - 2), w + i, i);
	}
	--g;
}
int main()
{
	scanf("%d%d\n%s", &n, &k, s + 1);
	for (int i = 0; i <= 250; i++)
	{
		c[i][0] = 1;
		for (int j = 1; j <= i; j++)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
	Find(0, 0, 1);
	printf("%d\n", ans);
}


Measured memory_bytes: 4084
S=input()
flag=0
l=[0]*26
for i in range(len(S)):
    if (0<=(ord(S[i])-97))and((ord(S[i])-97)<26):
        l[ord(S[i])-97]=l[ord(S[i])-97]+1
for i in range(26):
    if l[i]==0:
        print(chr(i+97))
        flag=1
        break
if flag==0:
    print("None")

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

int main(){
    int r;
    vector<int> x(3);
    cin >> x[0] >> x[1] >> x[2] ;
    sort(x.begin(),x.end());

    int c=0;
    for(int i=0;i<3;i++){
        if(x[i]%2==1)c+=1;
    }
    if (c==0 | c==3){
        r = (x[2]-x[1])/2 + (x[2]-x[0])/2;
    }
    else{
        if(c==1){
            for(int i=0;i<3;i++){
                if(x[i]%2==0)x[i]+=1;
            } 
        }
        else {
            for(int i=0;i<3;i++){
                if(x[i]%2==1)x[i]+=1;
            }
        }
        r = 1 + (x[2]-x[1])/2 + (x[2]-x[0])/2;
    }

    cout << r << endl;
}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

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

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

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

	ll n,W;
	cin >> n >> W;
	ll w0,w,v; cin >> w0;
	vector<ll> vs[4];
	cin >> v; vs[0].push_back(v);
	rep(i,n-1){
		cin >> w >> v;
		vs[w-w0].push_back(v);
	}
	rep(i,4){
		sort(vs[i].begin(),vs[i].end(),greater<ll>());
	}
	
	vector<ll> rui[4];
	rep(i,4){
		rui[i].push_back(0);
		rep(j,vs[i].size()){
			rui[i].push_back(vs[i][j]);
			rui[i][j+1] += rui[i][j];
		}
	}
	ll tv, ans = 0;
	rep(a,rui[0].size()){
		rep(b,rui[1].size()){
			rep(c,rui[2].size()){
				rep(d,rui[3].size()){
					if(a*w0 + b*(w0+1) + c*(w0+2) + d*(w0+3) > W) continue;
					tv = rui[0][a]+rui[1][b]+rui[2][c]+rui[3][d];
					ans = max(ans,tv);
				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    if(n == 1)
    {
        cout<<"1.0000000000"<<endl;
    }
    else if(n % 2 == 0)
    {
        cout<<"0.5000000000"<<endl;
    }
    else
    {
        int a = n / 2;
        a++;
        double d = (double)a / (double)n;
        cout<<d<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
    If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

#include<bits/stdc++.h>
using namespace std;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

int checker(string s, string x){
    int c=0;
    for(int i = 0 ; i < s.length() ; i++){
        if(s[i]!=x[i])c++;
    }
    return c;
}

void solve(){
    string s,t;
    cin>>s>>t;
    string tmp="";
    int old = INT_MAX,ch=0;
    for(int i = 0 ; i <= (s.length() - t.length()) ; i++){
        for(int j = i ; j < t.length()+i; j++)tmp+=s[j];
        ch = checker(t, tmp);
        //cout<<ch<<endl;
        if(ch <= old)old = ch;
        tmp="";
    }
    cout<<old<<endl;
}

int main(){
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;
        //cout<<"Case "<<k<<": ";
        solve();
    }
}



Measured memory_bytes: 3628
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>


void swap(int *x, int *y) {
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

int main() {

	int a, b;
	while (1) {
		scanf("%d%d", &a, &b);
		if (a == 0 && b == 0) break;
		if (a > b) swap(&a, &b);
		printf("%d %d\n", a, b);
	}

	return 0;
}



Measured memory_bytes: 2068