akhauriyash/Code-Regression huggingface dataset:
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner(input io.Reader) *Scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner(input)
	S := sc.nextStr()
	T := sc.nextStr()

	if strings.HasPrefix(T, S) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 1756
n = list(input())

ans = ''

if n[0] > n[1]:
    for i in range(3):
        ans += n[0]
elif n[0] == n[1] and n[0] >= n[2]:
     for i in range(3):
        ans += n[0]
else:
    n[0] = int(n[0]) + 1
    for i in range(3):
        ans += '{}'.format(n[0])
        

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
int ctoi(char a) {
	return (int)a - '0';
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int sum = 0;
	if (a + b > 2 * c) {
		while (x&&y) {
			x--; y--;
			sum += 2 * c;
		}
	}
	if (a > 2 * c) {
		while (x > 0) {
			x--; y--;
			sum += 2 * c;
		}
	}
	if (b > 2 * c) {
		while (y > 0) {
			x--; y--;
			sum += 2 * c;
		}
	}
	while (x > 0) {
		x--; sum += a;
	}
	while (y > 0) {
		y--; sum += b;
	}
	cout << sum << endl;
	getchar(); getchar();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	vector<char> c;
	for(int i=0;i<s.size();++i){
		if(s[i]=='0')c.push_back('0');
		else if(s[i]=='1')c.push_back('1');
		else{
			if(c.size()==0)continue;
			else c.pop_back();
		}
	}
	for(int i=0;i<c.size();++i)cout << c[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

int compare_int(const void *a, const void *b){//qsort 整数比較<
	return *(int*)a - *(int*)b;
}
int compare_int2(const void *a, const void *b){//qsort 整数比較>
	return *(int*)b - *(int*)a;
}

int main(void){
	int n,m;
	long long int k;
	long long int a[200010]={0},b[200010]={0};
	long long int a_s[200010]={0},b_s[200010]={0};
	int i,j;
	int tempi,tempj;
	int max=0;
	int temp=0;
	int flagi=0,flagj=0;

	scanf("%d %d %I64d",&n,&m,&k);
	for(i=0;i<n;i++){
		scanf("%I64d",&a[i]);
		if(i!=0){
			a_s[i+1]=a[i]+a_s[i];
		}else{
			a_s[i+1]=a[i];
		}
		if(a_s[i]>10000000000){
			flagi=1;
			break;
		}
	}
	tempi=i+flagi;
	for(i=0;i<m;i++){
		scanf("%I64d",&b[i]);
		if(i!=0){
			b_s[i+1]=b[i]+b_s[i];
		}else{
			b_s[i+1]=b[i];
		}
		if(b_s[i]>10000000000){
			flagj=1;
			break;
		}
	}
	tempj=i+flagj;
	for(i=0;i<=tempi;i++){
		for(j=tempj;j>=0;j--){
			if(k<(a_s[i]+b_s[j])){
				continue;
			}else{
				temp=i+j;
				break;
			}
		}
		tempj=j;
		if(max<temp){
			max=temp;
		}
	}
	printf("%d",max);

	return 0;
}


Measured memory_bytes: 7984
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define max_t 100000

void Main() {
  //自動整形防止用
  int a;
  string s;
  std::cin >> a;
  std::cin >> s;
  std::cout << (a >= 3200 ? s : "red") << '\n';

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

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

    long long n;
    cin >> n;

    if(n % 2 or n < 10){
        cout << 0 << endl;
        return 0;
    }

    long long tmp = 1;
    long long idx = 0;
    while(true){
        tmp *= 5;
        if(tmp >= n){
            break;
        }
        idx++;
    }
    
    long long ans = 0;
    long long five = 1;
    for(int i = 0; i < idx; i++){
        five *= 5;
        ans += (n / five) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	string str;
	int i,n,h;
	while(1) {
		cin >> str;
		if (str=="-") break;
		cin >> n;
		for(i=0; i<n; ++i) {
			cin >> h;
			str+=str.substr(0,h);
			str.erase(str.begin(),str.begin()+h);
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  cin >> s;
  char a[s.size()];
  int c=0, d=0;
  rep(i,0,s.size()-8) cout << s.at(i);
  cout << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

ll W[105];
int V[105];
constexpr int MX = 1e5+5;
vector<ll> a(MX, LINF);

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; ll w; cin >> n >> w;
    rep(i,n) {
        cin >> W[i] >> V[i];
    }

    a[0] = 0;
    rep(i,n) {
        for(int j=MX-1; j>=V[i]; j--) {
            chmin(a[j], a[j-V[i]]+W[i]);
        }
    }

    ll ans = 0;
    rep(i,MX) {
        if(a[i] <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3904
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

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

const int MAXN = 301, MAXM = 101, INF = 1000000 ;
const int TIME = 1, COST = 0;

int cost[2][MAXM][MAXM];
int d[MAXM];
int used[MAXM];
int a, b, c, t, p, q, r, k;
int n, m;

int main()
{
    while(cin >> n >> m && n)
    {
        memset(cost, INF, sizeof(cost));

        REP(n)
        {
            cin >> a >> b >> c >> t;
            a--; b--;
            cost[COST][a][b] = cost[COST][b][a] = c;
            cost[TIME][a][b] = cost[TIME][b][a] = t;
        }

        cin >> k;
        REP(k)
        {
            cin >> p >> q >> r; p--; q--;

            memset(d, INF , sizeof(d));
            memset(used, false, sizeof(used));
            d[p] = 0;

            while(1)
            {
                int v = -1;
                rep(j,m)if(!used[j] &&(v == -1 || d[j] < d[v])) v = j;

                if(v == -1) break;
                used[v] = true;

                rep(j,m)d[j] = min(d[j], d[v] + cost[r][v][j]);
            }
            cout << d[q] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextInt();
		int n = sc.nextInt();
		long at = 0;
		for(int i = 0; i < n; i++) {
			at += sc.nextLong();
		}
		System.out.println(at >= h ? "Yes" : "No");
	}

}


Measured memory_bytes: 47820
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <ll, int> P;

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

    int n, m;
    cin >> n >> m;

    vector <P> vec(n + m);
    for (int i = 0; i < n; i++) {
        cin >> vec[i].first;
        vec[i].second = 1;
    }
    for (int i = n; i < n + m; i++) cin >> vec[i].second >> vec[i].first;

    sort(vec.begin(), vec.end(), greater<P>());

    int cur = n;
    ll ans = 0LL;
    for (int i = 0; i < n; i++) {
        if (vec[i].second < cur) {
            ans += vec[i].first * vec[i].second;
        } else {
            ans += vec[i].first * cur;
            break;
        }
        cur -= vec[i].second;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

ll gcd(ll A, ll B) {
    return B ? gcd(B, A % B) : A;
}

ll solve(ll X, ll C, ll D) {
    ll t = C / gcd(C, D) * D;
    return X / C + X / D - X / t;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = solve(B, C, D) - solve(A - 1, C, D);
    cout << (B - A + 1 - ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ab = ReadStringArray();
            var a = ab[0];
            var b = ab[1];
            var ans = a == b ? "H" : "D";
            Console.WriteLine($"{ans}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

const int MAXN = 1000005;

int n,m,cnt[3];
int l[MAXN];
int r[MAXN];

char s[MAXN];

void rmv(int p)
{
	l[r[p]] = l[p];
	r[l[p]] = r[p];
}

void go1(int c,int t)
{
	for (int i = r[0];i <= n && t;i = r[i])
		if (s[i] == 'A' + c && s[l[i]] != s[r[i]])
		{
			rmv(i);
			cnt[c]--;
			t--;
		}
}

void go2(int b,int c,int t)
{
	for (int i = r[0];r[i] <= n && t;i = r[i])
		if (min(s[i],s[r[i]]) == 'A' + min(b,c) && max(s[i],s[r[i]]) == 'A' + max(b,c) && s[l[i]] != s[r[r[i]]])
		{
			rmv(i);
			rmv(r[i]);
			i = r[i];
			t--;
			cnt[b]--;
			cnt[c]--;
		}
}

int main()
{
	scanf("%s",s + 1);
	n = strlen(s + 1);
	s[0] = 'D';
	for (int i = 1;i <= n;i++)
		if (s[i] != s[i - 1])
			cnt[(s[++m] = s[i]) - 'A']++;
	n = m;
	s[n + 1] = 'E';
	int a = 0,b = 1,c = 2;
	if (cnt[a] > cnt[b])
		swap(a,b);
	if (cnt[a] > cnt[c])
		swap(a,c);
	if (cnt[b] > cnt[c])
		swap(b,c);
	for (int i = 0;i <= n + 1;i++)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}
	go1(c,cnt[c] - cnt[b]);
	go2(a,c,cnt[c] - cnt[b]);
	go2(b,c,cnt[b] - cnt[a]);
	for (int i = r[0];i <= n;i = r[i])
		putchar(s[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 9984
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  for(int i = a;i<=b;i++){
    if(i%c==0)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3592
import math
N = int(input())
a = list(map(int,input().split(" ")))

ave = sum(a) // N
candidate = [ave-1,ave,ave+1]

ans = float('inf')
for num in candidate:
	sumv = 0
	for i in range(N):
		sumv += ((a[i]-num)**2)

	if ans > sumv:
		ans = sumv

print(ans)



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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

int main() {
  int R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;
  for (int r = 0; r * R <= N; r++) for (int g = 0; g * G <= N - r * R; g++) {
    ans += (N - r * R - g * G) % B == 0;
  }
  printf("%d", ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

struct Rectangle{ int height;  int pos; };

int getLargestRectangle( int w, vector<int> buffer){
//int getLargestRectangle( int w, int buffer[]){
    stack<Rectangle> S;
    int maxv = 0;
    buffer[w] = 0;
    
    for ( int i = 0; i <= w; i++ ){
        Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if ( S.empty() ){
            S.push( rect );
        } else {
            if ( S.top().height < rect.height ){
                S.push( rect );
            } else if ( S.top().height > rect.height ) {
                int target = i;
                while ( !S.empty() && S.top().height >= rect.height){
                    Rectangle pre = S.top(); S.pop();
                    int area = pre.height * (i - pre.pos);
                    maxv = max( maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}


int main(void){

int h,w;
string ws;
	while(cin>> h >>w){
		if(h==0 && w==0|| cin.eof()) break;
		vector< vector<int> > ba(h,vector<int>(w+1));

		rep(i,h){ 
			cin >> ws;
			int c=1;
			rep(j,w){
				if(ws[j] != '*'){
					if(i<1) ba[i][j]=1;
					else ba[i][j] = ba[i-1][j]+1;
				}else{ ba[i][j] = 0; }
			}
		}
    int maxv = 0;
		rep(i,h){
        maxv = max( maxv, getLargestRectangle( w, ba[i] ) );
    }
//		rep(i,h) rep(j,w) printf("%02d %s",ba[i][j],(j<w-1? "":"\n"));
		cout << maxv << endl;
	}

	return 0;
	
}

Measured memory_bytes: 2132
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S = input()

    ans = ""
    for moji in S:
        a = ord(moji) + N
        if a > ord("Z"):
            a -= ord("Z") - ord("A") + 1
        ans += chr(a)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp(a,b) make_pair(a,b)
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}

int X,Y,Z,N;
struct Node
{
    int A, B, C;
}node[MaxN];

vector< pair<LL,int> > V;
priority_queue< LL > Q;
LL Left[MaxN], Right[MaxN];

void solve()
{
    V.clear();
    for(int i=0;i<N;i++) V.push_back(mp(node[i].A-node[i].B, i));
    sort(ALL(V));   
    
    LL sum = 0;
    while(!Q.empty()) Q.pop();
    for(int i=0;i<Y;i++)
    {
        int id = V[i].second;
        Q.push(node[id].C - node[id].B);
        sum += node[id].B;
    }
    for(int i=Y;i<Y+Z;i++)
    {
        int id = V[i].second;
        Left[i] = sum;
        sum += node[id].B;
        if(Q.top() > (node[id].C - node[id].B))
        {
            sum += Q.top();
            Q.pop();
            Q.push(node[id].C - node[id].B);
        }
        else sum += node[id].C - node[id].B;
    }
    Left[Y+Z] = sum;

    sum = 0;
    while(!Q.empty()) Q.pop();
    for(int i=N-1;i>=Y+Z;i--)
    {
        int id = V[i].second;
        Q.push(node[id].C - node[id].A);
        sum += node[id].A;
    }
    for(int i=Y+Z-1;i>=Y;i--)
    {
        int id = V[i].second;
        Right[i+1] = sum;
        sum += node[id].A;
        if(Q.top() > (node[id].C - node[id].A))
        {
            sum += Q.top();
            Q.pop();
            Q.push(node[id].C - node[id].A);
        }
        else sum += node[id].C - node[id].A;
    }
    Right[Y] = sum;

    LL ans = 0;
    for(int i=Y;i<=Y+Z;i++)
    {
        ans = max(ans, Left[i]+Right[i]);
    }
    printf("%lld\n", ans);


}

int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d%d%d", &X, &Y, &Z))
    {
        N = X + Y + Z;
        for(int i=0;i<N;i++)
        {
            scanf("%d%d%d", &node[i].A, &node[i].B, &node[i].C);
        }
        solve();
    }
    //system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
}


Measured memory_bytes: 4976
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n, i, ans=0, move=0;
    scanf("%d", &n);
    int h[n+1];
    h[0] = -1;
    for ( i=1; i<=n; i++ ) {
        scanf("%d", &h[i]);
        /* 左側の方が小さければそこで移動終了
         * 左側の方が大きければ移動継続 */
        if ( h[i-1] < h[i] ) {
            if ( move > ans )
                ans = move;
            move = 0;
        }
        else {
            move++;
        }
    }
    if ( move > ans )
        ans = move;

    printf("%d\n", ans);
    return EXIT_SUCCESS;
}    

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
                
      int main() {
        int N, M;
        vector<int> A(N);
        int soutoku=0;
        int hantei=0;

        cin >> N >> M;
          for(int i=0; i<N; i++){
            cin >> A.at(i);
            soutoku += A[i];
          }
                
        sort(A.begin(),A.end(),std::greater<int>());

        if(A.at(M-1)>=(double)soutoku/(4*M)){
          cout << "Yes" << endl;
        }
        else{
          cout << "No" << endl;
        }
        return 0;
        }

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;
	ll A[1000];
	rep(i, N) cin >> A[i];
	ll S[1001] = {};
	rep1(i, N) S[i] = S[i - 1] + A[i - 1];

	vector<ll> V;
	rep(i, N) {
		for (int j = i; j < N; j++) {
			V.pb(S[j + 1] - S[i]);
		}
	}

	ll kotae = 0;
	for (int i = 50; i >= 0; i--) {
		ll kari = kotae + (1ll << i);
		int kazu = 0;
		for (auto j : V) {
			if (kari == (j & kari)) kazu++;
		}
		if (kazu >= K) kotae = kari;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

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

    LL val = 0;

    for(int i=0; i<(int)N.size(); i++){
        int _tmp = N[i] - '0';
        val += _tmp;
    }

    if(val%9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;

}

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

int main() {
 ll N, A, B;
 cin >> N >> A >> B;
 ll set = N / (A+B);
 cout << set*A + min(N%(A+B),A) << endl; 
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,T y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,T y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}

vi g[N],ans,res;
bool vis[N];

void dfs(int x){
	vis[x]=1;
	ans.pb(x);
	for(auto y:g[x]){
		if(vis[y]) continue;
		dfs(y);break;
	}
}

int main(){
	int n,m,isok=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].pb(y);g[y].pb(x);
	}
	vis[1]=1;
	for(auto i:g[1]) if(!vis[i]){
		ans.clear();dfs(i);
		if(!isok) res=ans,isok=1;
		else{
			printf("%d\n",res.size()+ans.size()+1);
			reverse(ans.begin(),ans.end());
			for(auto i:ans) printf("%d ",i);
			printf("1 ");
			for(auto i:res) printf("%d ",i);
			puts("");
			return 0;
		}
	}
	printf("%d\n",res.size()+1);
	printf("%d ",1);
	for(auto i:res) printf("%d ",i);puts("");
	return 0;
}


Measured memory_bytes: 10104
// AOJ 0366: Road Improvement
// 2019.2.25 bal4u

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// 強連結成分への分解モジュール
#define MAX_V 10002
int  V;    // 頂点数
int  *to[MAX_V], hi[MAX_V];
int  *r_to[MAX_V], r_hi[MAX_V];
int  vs[MAX_V], vsz;
char used[MAX_V];   // 作業用
int  cmp[MAX_V];    // 属する強連結成分のトポロジカル順序

void add_edge(int _from, int _to)
{
	to[_from][hi[_from]++] = _to;
	r_to[_to][r_hi[_to]++] = _from;
}

void dfs(int v)
{
	int i;
	used[v] = 1;
	for (i = 0; i < hi[v]; i++) {
		if (!used[to[v][i]]) dfs(to[v][i]);
	}
	vs[vsz++] = v;
}

void rdfs(int v, int k)
{
	int i;
	used[v] = 1;
	cmp[v] = k;
	for (i = 0; i < r_hi[v]; i++) {
		if (!used[r_to[v][i]]) rdfs(r_to[v][i], k);
	}
}

// 強連結成分への分解
int scc()
{
	int v, i, k;
	memset(used, 0, V);
	vsz = 0;
	for (v = 0; v < V; v++) if (!used[v]) dfs(v);
	memset(used, 0, V);
	k = 0;
	for (i = vsz - 1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}

	// 同一強連結成分グループは cmp[v]が同一
	return k;		// 得られた強連結成分の数
}

int main()
{
	int i, j, E, s, t, group;
	int *memo, sz;

	V = in(), E = in();  // V:頂点数, E:エッジ数
	memo = malloc(E * 2 * sizeof(int));
	sz = 0; for (i = 0; i < E; i++) {
		memo[sz++] = s = in(), memo[sz++] = t = in();
		hi[s]++, r_hi[t]++;
	}
	for (i = 0; i < V; i++) {
		if (hi[i])   to[i] = malloc(hi[i] * sizeof(int));
		if (r_hi[i]) r_to[i] = malloc(r_hi[i] * sizeof(int));
	}
	memset(hi, 0, V * sizeof(int));
	memset(r_hi, 0, V * sizeof(int));

	i = 0; while (i < sz) {
		s = memo[i++], t = memo[i++];
		add_edge(s, t);
	}
	free(memo);

	group = scc(); // 強連結成分のグループ数
	if (group == 1) puts("0"); // 強連結成分がひとつなら道路の増設は必要なし
	else{
		char *inCnt, *outCnt; // 各強連結成分グループの入次数、出次数
		int ord, inSum, outSum;

		inCnt = malloc(group), outCnt = malloc(group);
		memset(inCnt, 0, group), memset(outCnt, 0, group);  // リセット

		for (i = 0; i < V; i++) {  // すべての頂点について
			ord = cmp[i];   // 頂点 i の強連結成分のグループ番号
			for (j = 0; j < hi[i]; j++) {  // 頂点 i から出ていくエッジについて
				if (cmp[to[i][j]] != ord) outCnt[ord] = 1;
			}
			for (j = 0; j < r_hi[i]; j++) {  // 頂点 i に入ってくるエッジについて
				if (cmp[r_to[i][j]] != ord) inCnt[ord] = 1;
			}
		}

		inSum = outSum = 0;
		for (i = 0; i < group; i++) {
			if (inCnt[i] == 0) inSum++;
			if (outCnt[i] == 0) outSum++;
		}
		printf("%d\n", inSum >= outSum ? inSum : outSum);
//		free(inCnt), free(outCnt);   // メモリ開放
	}
	return 0;
}


Measured memory_bytes: 3620
s = raw_input()
flg1 = False
flg2 = False
for c in s:
    if not flg1:
        if c=="C":
            flg1 = True
    elif not flg2:
        if c=="F":
            flg2 = True

if flg2:
    print "Yes"
else:
    print "No"


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

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  
  char p = S[0];
  int ans = 1;
  for (int i = 1; i < N; i++)
  {
    char q = S[i];
    if (p != q)
    {
      ans ++;
    }
    p = q;
  }
  
  cout << ans << endl;
  return 0;
}

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

namespace Myatcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            Array.Sort(n);
            int a = int.Parse($"{n[2]}{n[1]}");
            Console.WriteLine(a + n[0]);
        }
    }
}

Measured memory_bytes: 13396
<?php
$N = trim(fgets(STDIN));
$A = trim(fgets(STDIN));

if($A > 0) {
    // 500円で支払った後の金額を1円A枚で支払できるか
    $N_1 = $N % 500;
    if($N_1 === 0) {
        $N_2 = $N / 500;
        if($N - ($N_2 * 500) === 0) {
            echo 'Yes';
            exit;
        }
    }
    // 1円A枚で支払できるか
    if($A / $N_1 >= 1 || $N - $A === 0) {
        echo 'Yes';
    } else {
        echo 'No';
    }
} else {
    if($N % 500 === 0) {
        echo 'Yes';
    } else {
        echo 'No';
    }
}

Measured memory_bytes: 4728
N, M = map(int, input().split())

class DisjointSetUnion():
    def __init__(self, n):
        self.n = n
        self.par_size = [-1] * n

    def merge(self, a, b):
        #assert 0 <= a < self.n
        #assert 0 <= b < self.n
        x = self.leader(a)
        y = self.leader(b)
        if x == y: return x
        if -self.par_size[x] < -self.par_size[y]: x, y = y, x
        self.par_size[x] += self.par_size[y]
        self.par_size[y] = x
        return x

    def same(self, a, b):
        #assert 0 <= a < self.n
        #assert 0 <= b < self.n
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        #assert 0 <= a < self.n
        x = a
        while self.par_size[x] >= 0:
            x = self.par_size[x]
        while self.par_size[a] >= 0:
            self.par_size[a] = x
            a = self.par_size[a]
        return x

    def size(self, a):
        #assert 0 <= a < self.n
        return -self.par_size[self.leader(a)]

    def groups(self):
        leader_buf = [0] * self.n
        group_size = [0] * self.n
        res = [[] for _ in range(self.n)]
        for i in range(self.n):
            leader_buf[i] = self.leader(i)
            group_size[leader_buf[i]] += 1
        for i in range(self.n):
            res[leader_buf[i]].append(i)
        res = [res[i] for i in range(self.n) if res[i]]
        return res

uf = DisjointSetUnion(N)

for _ in range(M):
    a, b = map(int, input().split())
    uf.merge(a - 1, b - 1)

l = len(uf.groups())
print(l - 1)

Measured memory_bytes: 82804
#include <iostream>
#include <vector>
#include <valarray>
//#include "../cxx-prettyprint/prettyprint.hpp"

int n;
std::vector<int> A;

bool can_make(int i, int m) {
    if (m == 0) {
        return true;
    } else if (i >= n) {
        return false;
    }
    return can_make(i + 1, m) || can_make(i + 1, m - A[i]);
}

int main() {
    std::cin >> n;
    A.resize(n);
    for (int &a : A) {
        std::cin >> a;
    }

    int q;
    std::cin >> q;
    std::vector<int> M(q);
    for (int &m : M) {
        std::cin >> m;
    }

    for (int m : M) {
        std::cout << (can_make(0, m) ? "yes" : "no") << std::endl;
    }
}



Measured memory_bytes: 3092
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


if __name__ == '__main__':
    N = int(input().strip())
    AA = [int(a) for a in input().strip().split()]
    i = partition(AA, 0, N - 1)
    _str = ' '.join([str(a) for a in AA[:i]]) + \
           ' [{}] '.format(AA[i]) + \
            ' '.join([str(a) for a in AA[i+1:]])
    print(_str)

Measured memory_bytes: 18448
#include <cstdio>
#define ll long long
using namespace std;

int times[10],cp[10];

int check(int n){
    int ans=0;
    n/=10;
    while(n){
        ans++;
        if(n%10!=7) return -1;
        n/=10;
    }
    return ans;
}

int main(){
    int k,i,ans=0,cur;
    scanf("%d",&k);
    if(k%10!=3&&k%10!=1&&k%10!=9&&k%10!=7){
        printf("-1\n");
        return 0;
    }
    for(i=0;i<10;i++){
        times[i]=k*i;
//        printf("%d\n",k*i);
        cp[times[i]%10]=i;
    }
    cur=0;
    while(1){
        cur/=10;
        if(cur%10>7) i=17-(cur%10);
        else i=7-(cur%10);

        cur+=times[cp[i]];

        ans++;
        if(check(cur)!=-1){ans+=check(cur);break;}

    }

    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

#define int long long
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;

int x[10][10];

bool check(string ssn)
{
  int f = 0;
  rep(i, 5) f = x[f][ssn[i]-'0'];
  return f == 0;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  rep(i, 10) rep(j, 10) cin >> x[i][j];

  int ans = 0;
  rep(i, 10000) {
    string id = to_string(i);
    while(id.size() < 4) id = "0" + id;
    int e = 0;
    rep(j, 4) e = x[e][id[j]-'0'];
    id += (e + '0');
    bool flag = false;
    rep(j, 5) rep(k, 10) {
      char tmp = id[j], num = k+'0';
      if(tmp == num) continue;
      id[j] = num;
      if(check(id)) flag = true;
      id[j] = tmp;
    }
    rep(i, 4) {
      if(id[i] == id[i+1]) continue;
      swap(id[i], id[i+1]);
      if(check(id)) flag = true;
      swap(id[i], id[i+1]);
    }
    if(flag) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3200
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum = 0

for i in range(N):
    if A[i] >= B[i]:
        sum += B[i]
    
    else:
        if A[i+1] >= (B[i] - A[i]):
            sum += B[i]
            A[i+1] -= (B[i]-A[i])
        else:
            sum += (A[i]+A[i+1])
            A[i+1] = 0

print(sum)

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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        long a = scanner.nextInt();
        out.println(3L*a*a);
        
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double dp[310][310][310];
ll n;

double calc(int x, int y, int z){
    double ret=0.0;
    if(0<=dp[x][y][z]) return dp[x][y][z];
    if(!x && !y && !z) return 0.0;
    if(0<x) ret += calc(x-1, y, z)*x;
    if(0<y) ret += calc(x+1, y-1, z)*y;
    if(0<z) ret += calc(x, y+1, z-1)*z;
    ret += n;
    ret *= 1.0/(x+y+z);
    return dp[x][y][z] = ret;
}

int main(){
    cin >> n;
    vector<ll> a(n);    
    ll c1=0, c2=0, c3=0;
    rep(i, n){
        ll x;   cin >> x;
        if(x==1) c1++;
        else if(x==2) c2++;
        else c3++;
    }
    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(20) << calc(c1, c2, c3) << endl;
}


Measured memory_bytes: 236604
#include<bits/stdc++.h>
using namespace std;
bool ans(string s){
  string re_s = s.substr(s.size() / 2);
  string re_s2 = s.substr(0, s.size() / 2);
  if(re_s==re_s2){
    return true;
  }else{
    return false;
  }
}
int main(){
  string s;
  cin>>s;
  int cnt = 0;
  while (true)
  {
    s.pop_back();
    cnt++;
    if (cnt%2==0&&ans(s))
    {
      break;
    }
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 256
n = int(input())
ls = [(0,0,0)]
for _ in range(n):
    a,b,c=map(int, input().split())
    ls.append((a,b,c))

dpa = 0
dpb = 0
dpc = 0

for x in range(1,n+1):
    a,b,c = ls[x]
    dpa, dpb, dpc = max(dpc+a,dpb+a), max(dpa+b,dpc+b), max(dpa+c,dpb+c)


print(max(dpa,dpb,dpc))

Measured memory_bytes: 20540
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b-1); i >= (a); i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  int S1 = A*X + B*Y;
  int S2 = C*2*min(X,Y) + (X>=Y?A:B)*(max(X,Y)-min(X,Y));
  int S3 = C*2*max(X,Y);

  cout << min({S1,S2,S3}) << endl;
}

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

using namespace std;

int main(){
    int A,B,C,K,ans=0;
    cin >> A >> B >> C >> K;
    while(K>0){
        if(A>0){
            ans++;
            A--;
        }
        else if(B>0){
            B--;
        }
        else if(C>0){
            ans--;
            C--;
        }
        K--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', function(input) {
    lines.push(input);
});

rl.on('close', function() {
    var inputsAsArr = lines[0].split(' ');
    var sideA = inputsAsArr[0];
    var sideB = inputsAsArr[1];
    var sideC = inputsAsArr[2];

    var outputStr = (sideA === sideB && sideA === sideC && sideB === sideC) ? 'Yes' : 'No';
    console.log(outputStr);

    // var A = Number(lines[0].split(" ")[0]);
    // var B = Number(lines[0].split(" ")[1]);
    // var C = Number(lines[0].split(" ")[2]);
 
    // if (A === B && A === C && B === C) { console.log("Yes") }
    // else { console.log("No") }
});


Measured memory_bytes: 21320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
  {
    cout << "hon" << endl;
  }
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "bon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
import Control.Applicative
import Data.List

toInt ::String -> Int
toInt x=read x :: Int

toCaseStr :: Int-> Int->String
toCaseStr index x = concat ["Case ",(show index),": ",(show x)]

loop :: Int->IO ([String])
loop index = do
    x <- toInt <$> getLine
    if x==0 then (return []) else ((:) (toCaseStr index x) <$> (loop (1+index)))

main :: IO()
main = do
    ss<- loop 1
    putStrLn .concat .intersperse "\n" $ ss


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


int r,c;

int d[10][10000];

int b[11]={1,2,4,8,16,32,64,128,256,512,1024};


int main(){
	
	while(cin>>r>>c,r){
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				cin>>d[i][j];
			}
		}
		int ans=0;
		
		for(int i=0;i<b[r];i++){//1024
			int D[10000]={0};
			for(int j=0;j<r;j++){//10
				for(int k=0;k<c;k++){//10000
					if(((i & b[j]) && d[j][k]) || (0==(i & b[j]) && d[j][k]==0)){
						D[k]++;
					}
				}
			}
			
			int tmp=0;
			for(int j=0;j<c;j++){
				tmp+=max(D[j],r-D[j]);
			}
			ans=max(ans,tmp);
		}
		
		
		
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 1592
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n;
ll a[101010],b[101010];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i];
	b[0]=0;
	fo(i,1,n)b[i]=a[i-1]*2-b[i-1];
	b[0]+=a[n-1]-(b[0]+b[n-1])/2;
	fo(i,1,n)b[i]=a[i-1]*2-b[i-1];
	fo(i,0,n-1)cout<<b[i]<<" ";
	cout<<b[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

#define BBB 4
#define FFF 3
#define RRR 10

int main() {
    int i, j, k, n, b, f, r, v;
    int data[BBB][FFF][RRR];
    
    for (i = 0; i < BBB; i++) {
        for (j = 0; j < FFF; j++) {
            for (k = 0; k < RRR; k++) {
                data[i][j][k] = 0;
            }
        }
    }
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        
        data[b-1][f-1][r-1] += v;
    }
    
    for (i = 0; i < BBB; i++) {
        for (j = 0; j < FFF; j++) {
            for (k = 0; k < RRR; k++) {
                printf(" %d", data[i][j][k]);
            }
            printf("\n");
        }
        if (i != BBB-1) printf("####################\n");
    }
    return 0;
}


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

int main(){
    string a,b;
    cin>>a>>b;
    string s = a+b;
    int num = 0;
    for(int i=0;i<s.length();i++){
        num += (s[i]-'0')*pow(10,s.length()-(i+1));
    }
    bool is = false;
    for(int i=0;i*i<=num;i++){
        if(i*i == num) is = true;
    }
    if(is) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")
#define int long long
#define y1 hoainambimaysolokill
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,pair<int,int> >
#define PII3 pair<pair<int,int>,int >
const long long inf=1e18+3;
void solve()
{
   int a,b;
   cin>>a>>b;
   a--;
   b--;
   cout<<b/a+(b%a!=0);
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen("BOXES.inp", "r", stdin);
    //freopen("BOXES.out", "w", stdout);

    //int t;cin>>t;while(t--)

    solve();
}


Measured memory_bytes: 256