akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n,m;
int a[maxn],b[maxn],ord[maxn];
bool ok[maxn],occ[maxn];
vector<int>edge[maxn],vec[maxn];
bool cmp(int x,int y){
	return a[x]-b[x]<a[y]-b[y];
}

namespace Dsu{
	int f[maxn],rk[maxn];
	ll v[maxn]; 
	void init(){
		REP(i,n){
			f[i]=i;
			rk[i]=1;
			v[i]=b[i];
		}
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]);
	}
	void merge(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		if(rk[x]>rk[y])swap(x,y);
		f[x]=y;
		v[y]+=v[x];
		if(rk[x]==rk[y])rk[y]++;
	}
}

void fix(int x,int y){
	while(!vec[x].empty()){
		int z=vec[x].back();
		vec[x].pop_back();
		ok[z]=true;
		int ori=Dsu::find(z);
		Dsu::merge(ori,y);
		fix(ori,y);
	}
}

bool check(ll val){
	REP(i,n)vec[i].clear(),ok[i]=occ[i]=false;
	Dsu::init();
	REP(i,n){
		int x=ord[i];
		occ[x]=true;
		if(val+b[x]>=a[x])ok[x]=true;
		rep(j,int(edge[x].size())){
			int y=edge[x][j];
			if(!occ[y])continue;
			ll nowx=Dsu::v[Dsu::find(x)]+val;
			ll nowy=Dsu::v[Dsu::find(y)]+val;
			if((ok[y]&&nowy+b[x]>=a[x])||(ok[x]&&nowx+b[y]>=a[y])){
				ok[x]=ok[y]=true;
				int orix=Dsu::find(x),oriy=Dsu::find(y);
				Dsu::merge(x,y);
				fix(orix,x);
				fix(oriy,y);
			}
			else{
				vec[Dsu::find(y)].pb(x);
				vec[Dsu::find(x)].pb(y);
			}
		}
	}
	REP(i,n)if(!ok[i])return false;
	return true;
}

int main(){
	scanf("%d%d",&n,&m);
	REP(i,n){
		scanf("%d%d",&a[i],&b[i]);
		ord[i]=i;
	}
	sort(ord+1,ord+1+n,cmp);
	REP(i,m){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	ll l=-1,r=ll(1e9);
	while(r-l>1){
		ll mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	REP(i,n)r+=b[i]; 
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 14208
object Main extends App {
  import scala.io.StdIn._
  val a = readLine.trim.toList
  val b = readLine.trim.toList
  println(
    if (canMakeUseAFirst(a, a, b) || canMakeUseBFirst(a, a, b)) "Yes" else "No"
  )

  def canMakeUseAFirst(target: List[Char], a: List[Char], b: List[Char]): Boolean = {
    target match{
      case Nil ⇒ true
      case h::t ⇒ a.dropWhile(_ != h) match{
        case Nil ⇒ false
        case _::at ⇒ canMakeUseBFirst(t, at, b)
      }
    }
  }
  def canMakeUseBFirst(target: List[Char], a: List[Char], b: List[Char]): Boolean = {
    target match{
      case Nil ⇒ true
      case h::t ⇒ b.dropWhile(_ != h) match{
        case Nil ⇒ false
        case _::bt ⇒ canMakeUseAFirst(t, a, bt)
      }
    }
  }
  implicit class ScopeFunc[T](private val value: T) {
    def let[A](func:T ⇒ A): A = func(value)
    def also(func:T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

//2,3,5,7,11,13,17,19,23,29,31


Measured memory_bytes: 44148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    int a, b;
    char op;
    cin >> a;
    cin >> op;
    cin >> b;
    if (op == '+') {
        cout << a + b << endl;
        return 0;
    } else {
        cout << a - b << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.range;

void main() {
	auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1], C = ip[2], D = ip[3];
	if(B <= C || D <= A) 0.writeln;
	else if(A <= C) (B < D ? B - C : D - C).writeln;
	else (B < D ? B - A : D - A).writeln;
}


Measured memory_bytes: 256
n = int(input())
S = {"AC":0,"WA":0,"TLE":0,"RE":0}

for i in range(n):
  S[input()] += 1

print("AC x "+str(S["AC"]))
print("WA x "+str(S["WA"]))
print("TLE x "+str(S["TLE"]))
print("RE x "+str(S["RE"]))

Measured memory_bytes: 9200
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        ret = 0
        for dx in (-1, 0, 1):
            for dy in (-1, 0, 1):
                if dx == dy == 0:
                    continue
                ni = i + dy
                nj = j + dx
                if not (0 <= ni < H) or not (0 <= nj < W):
                    continue
                ret += 1 if S[ni][nj] == '#' else 0
        S[i][j] = str(ret)

for s in S:
    print(''.join(s))


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
typedef long long ll;

int main() {
	
	ll n, a, b;

	std::cin >> n >> a>> b;

	ll nmin = std::min(a, b);
	ll nmax = std::max((ll)0 , (a+b)- n);

	std::cout << nmin <<" " <<nmax << std::endl;
	return 0;
}

Measured memory_bytes: 256
N,C=map(int, input().split())
#Aは時計回り
A,B=[],[]
allv=0
for i in range(N):
  a,b=map(int, input().split())
  A.append([a,b])
  B.append([C-a,b])
  allv+=b
A,B=sorted(A),sorted(B)
OA,OB,AS,BS=[],[],[],[]
ax,av,bx,bv=0,0,0,0
for i in range(N):
  ax,bx=A[i][0],B[i][0]
  av+=A[i][1]
  bv+=B[i][1]
  OA.append((ax,av))
  OB.append((bx,bv))
  AS.append(av-ax)
  BS.append(bv-bx)
#OA→AO→OBといくとき
d=BS[0]
e=AS[0]
BSma,ASma=[-10000]*N,[-10000]*N
for i in range(N):
  BSma[i]=max(d,BS[i])
  d=BSma[i]
  ASma[i]=max(e,AS[i])
  e=ASma[i]
  
ansa=0
for i in range(N-1):
  #iまで行く
  bma=N-i
  oa=OA[i][1]-OA[i][0]
  ao=-OA[i][0]
  ob=BSma[-2-i]
  d=max(oa,oa+ao+ob)
  ansa=max(ansa,d)
ansb=0
for i in range(N-1):
  #iまで行く
  ama=N-i
  ob=OB[i][1]-OB[i][0]
  bo=-OB[i][0]
  oa=ASma[-2-i]
  d=max(ob,ob+bo+oa)
  ansb=max(ansb,d)
print(max(ansa,ansb,allv-(C-max(OA[0][0],OB[0][0]))))


Measured memory_bytes: 134732
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long x; cin >> x;
    long long a = 0;
    while (true)
    {
        if(a * a * a * a * a == x) {
            cout << a << " 0" << endl;
            return 0;
        }
        else if(a * a * a * a * a > x) {
            long long i = 0;
            long long b = a * a * a * a * a - x;
            while (i * i * i * i * i <= b)
            {
                if(i * i * i * i * i == b) {
                    cout << a << " " << i << endl;
                    return 0;
                }
                i++;
            }
            a++;
        }
        else {
            long long i = 0;
            long long b = a * a * a * a * a - x;
            while (i * i * i * i * i >= b)
            {
                if(i * i * i * i * i == b) {
                    cout << a << " " <<  i<< endl;
                    return 0;
                }
                i--;
            }
            a++;
        }
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

vector<string> v;
long long diff = 0;
long long k = 1;
string ans;

//?????????????????°???????????????
long long toNum(string str){
    long long num = 0;
    rep(i,str.size()){
        num *= 10;
        num += str[i] - '0';
    }
    return num;
}

void solve(string s, string t, int use){
    if(s.size() == t.size()){
        long long S = toNum(s);
        long long T = toNum(t);
        if(diff < min(abs(S - T), k - abs(S - T))){
            diff = min(abs(S - T), k - abs(S - T));
            ans = t;
        }
        return;
    }

    rep(i,10){
        if((use >> i & 1) == 0){
            string temp = t;
            temp += '0' + i;
            solve(s, temp, use | (1 << i));
        }
    }
}

int main(){
    string s;
    cin >> s;
    rep(i,s.size()) k *= 10;
    solve(s, "", 0);

    cout << ans << endl;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
vector<int> a[100500];
bool used[100500];
void solve() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		a[u].push_back(v);
		a[v].push_back(u);
	}
	queue<int> q;
	q.push(1);
	used[1] = true;
	map<int, int> ans;
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		for (auto x : a[cur]) {
			if (!used[x]) {
				used[x] = true;
				ans[x] = cur;
				q.push(x);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			cout << "No";
			return;
		}	
	}
	cout << "Yes\n";
	for (int i = 2; i <= n; i++) {
		cout << ans[i] << '\n';
	}
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1; 
    //cin >> T;
    while(T--) solve();
}


Measured memory_bytes: 14740
q = int(input())
Q = 10**5+1
is_prime = [1] * (Q+1)
is_prime[0],is_prime[1] = 0,0
for i in range(2,int(Q*0.5)+1):
    if is_prime[i]:
        product = i*2
        while product <= Q:
            is_prime[product] = 0
            product += i
is_2017_like = [0] * (Q+1)
is_2017_like_csum = [0] * (Q+1)
now = 0
for i in range(2,Q+1):
    if is_prime[i] and is_prime[(i+1)//2]:
        is_2017_like[i] = 1
        now += 1
    is_2017_like_csum[i] = now
ans_ls = [0] * q
for i in range(q):
    l,r = map(int,input().split())
    if l >= 1:
        ans_ls[i] = is_2017_like_csum[r] - is_2017_like_csum[l-1]
    else:
        ans_ls[i] = is_2017_like_csum[r]
for i in range(q):
    print(ans_ls[i])


Measured memory_bytes: 79424
#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;
string s="",d="",f="";
std::cin >> s>>d>>f;
std::cout <<s[0]<<d[0]<<f[0] << '\n';
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
 
#define F first
#define S second
#define ll long long
#define pb push_back
#define db double
#define ld long double
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define int long long
 
const int N = 1e5 + 1, inf = 2e9 + 7, mod = 1e9 + 7;
const ll INF = 2e18 + 7, MOD = 1e15 + 7;

int a[5005], dp[5005][5005], sum = 0;

signed main() { __
//    freopen("lcm.in", "r", stdin);
//    freopen("lcm.out", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        dp[i][i] = ((n - 1) % 2) + 1 == 2 ? 0 : a[i];
    }
    //dp[i][j] = max(a[i] + dp[i + 1][j], a[j] + dp[i][j - 1]);
    for (int i = n - 1; i >= 1; i--) {
        for (int j = i + 1; j <= n; j++) {
            if(((n - (j - i + 1)) % 2) + 1 == 2) dp[i][j] = min(dp[i + 1][j], dp[i][j - 1]);
            else dp[i][j] = max(a[i] + dp[i + 1][j], a[j] + dp[i][j - 1]);
        }
    }
    cout << dp[1][n] - (sum - dp[1][n]);
    return 0;
}



Measured memory_bytes: 118400
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int X = A + B;
	int Y = C + D;
	if (X > Y) {
		cout << "Left" << endl;
	}
	else if (X == Y) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}


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

const int MAX = 447; // 447*448/2=99681, 448*449/2=100576
int main() {
	int N;
	cin >> N;
	int K = 1, T[MAX]; // T[i]=i(i+1)/2
	for (int i = 0;i < MAX;++ i) T[i] = i * (i + 1) >> 1;
	for (int max = MAX, mid = max >> 1;max - K > 1;mid = K + (max - K >> 1)) { // T[K]=NとなるようなKを二分探索
		if (T[mid] > N) max = mid;
		else K = mid;
	}
	if (T[K] != N) { // 不可能
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl << K + 1 << endl;
	for (int i = 0;i <= K;++ i) {
		cout << K;
		for (int j = 0;j < K;++ j) cout << " " << (i > j ? i - j : j - i + 1) + T[K] - T[K - min(i, j)];
		cout << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、最初にkとS_1を決めたとする
するとS_2からS_kまでの全てにはS_1の要素が1個含まれるので、k=|S_1|+1になる
同様の話が他でも成り立つので、|S_1|=|S_2|=...=|S_k|
で、そもそも|S_1|+|S_2|+...+|S_k|は、全ての要素が2個ずつ出てくるので2Nでないといけない→|S_i|=k+1なのでk(k+1)=2N
よってk=N(N+1)/2が成り立つ(そうでなければ-1)
後は構築だが、これはかなり簡単
自分より上の全てのS_iのうち使ってないの1個と、まだ使ってない数字を残りの個数だけ使っていけば良いだけ
例えばN=15ならこんな感じ
1 2 3 4 5
1 6 7 8 9
2 6 10 11 12
3 7 10 13 14
4 8 11 13 15
5 9 12 14 15
*/

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
ll X,Y;

const ll M = 1e9+7;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
  cin>>X>>Y;
  ll k,n;
	if ((X+Y)%3!=0){
		 cout << 0 << endl;
     return 0;
  }else{
    n = (X+Y)/3;
    k = X-n;
  }
  if (n<k || k < 0 ){
    cout << 0 << endl;
    return 0;
  }

	fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<=1000000; i++){
      fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
      ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  //cout << n <<" " << k << endl;
	ll ans = comb(n, k)%M;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 15872
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 100000;
const int MaxM = 100000;
const int M = 1000000007;

inline int modpow(int a, const int &n)
{
	int res = 1;
	for (int i = n; i; i >>= 1)
	{
		if (i & 1)
			res = (s64)res * a % M;
		a = (s64)a * a % M;
	}
	return res;
}

int n, m, h, w;

int fact[MaxN * 2 + 1];
int rfact[MaxN * 2 + 1];

inline void init_fact(int n = MaxN * 2)
{
	fact[0] = 1;
	for (int i = 1; i <= n; ++i)
		fact[i] = (s64)fact[i - 1] * i % M;

	rfact[n] = modpow(fact[n], M - 2);
	for (int i = n; i; --i)
		rfact[i - 1] = (s64)rfact[i] * i % M;
}

inline int binom(int n, int m)
{
	return (s64)fact[n] * rfact[m] % M * rfact[n - m] % M;
}

int main()
{
	init_fact();

	cin >> n >> m >> h >> w;

	int res = 0;
	for (int i = 1; i <= n - h; ++i)
	{
		int x = i - 1, y = w - 1;
		int a = binom(x + y, x);

		x = n - i;
		y = m - w - 1;
		int b = binom(x + y, x);

		res = (res + (s64)a * b) % M;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S,T;
  cin >> S >> T;
  vector<int> s(26,-1);
  vector<int> t(26,-1);
  
  REP(i,S.size()){
    int a = S[i] - 'a';
    int b = T[i] - 'a';
    
    if(s[a] != -1 || t[b] != -1){
      if(s[a] != b || t[b] != a){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      s[a] = b;
      t[b] = a;
    }
  }

  cout << "Yes" << endl;
  
}


Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x; cin >> x;
    int a = x / 100;
    x %= 100;

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= a - i; j++){
            for(int k = 0; k <= a - i - j; k++){
                for(int l = 0; l <= a - i - j - k; l++){
                    for(int m = 0; m <= a - i - j - k - l; m++){
                        if(i*5 + j*4 + k*3 + l*2 + m == x){
                            cout << 1; return 0;
                        }
                    }
                }
            }
        }
    }cout << 0;
}




Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

// N M => let (N, M) = get!(usize, usize)
// A1 B1
// ...
// AQ BQ => let A = get!(usize, usize; Q)

const MOD: u64 = 1000000007;

fn main() {
    let (K, A, B) = get!(usize, usize, usize);

    // 1ターンで1枚増やす
    // A+2ターンでB枚増やす
    let mut ans: usize = 1;
    let mut turn = 0;

    while turn < K {
        if ans < A || turn >= K - 1 {
            ans += 1;
        } else {
            let change = ans - A + B;
            let noChange = ans + 2;
            ans = max(change, noChange);
            turn += 1;
        }
        turn += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const int INF = 1<<29;

int N;
vector<int> L;
vector<int> A; // A, B, C


// 再帰する
// sums[0] = A に選んだ竹の長さの総和、nums[0] = A に選んだ竹の数
// sums[1] = B に選んだ竹の長さの総和、nums[1] = B に選んだ竹の数
// sums[2] = C に選んだ竹の長さの総和、nums[2] = C に選んだ竹の数
int rec(vector<int> sums, vector<int> nums, int id) {
    // n 個全部考えたら集計
    if (id == N) {

        // A, B, C いずれも竹は 1 本は必ず使ってないとダメ (これをしないと example 3 は通らない)
        for (int i = 0; i < 3; ++i) {
            if (nums[i] == 0) return INF;
        }
        
        long long score = 0;
        for (int i = 0; i < 3; ++i) {
            score += abs(sums[i] - A[i]); // +1 したり -1 したりする分
            score += (nums[i] - 1) * 10; // 合体した回数
        }
        return score;
    }

    int res = INF; // 無限

    // 今ある竹を採用しない場合
    res = min(res, rec(sums, nums, id+1));

    for (int i = 0; i < 3; ++i) {
        // i = 0: A に採用する場合
        // i = 1: B に採用する場合
        // i = 2: C に採用する場合
        sums[i] += L[id], nums[i]++;
        res = min(res, rec(sums, nums, id+1));
        sums[i] -= L[id], nums[i]--; // 一旦元に戻す (こういうのをバックトラックと呼ぶ)
    }
    
    return res;
}

int main() {
    // 入力
    cin >> N;
    A.resize(3);
    for (int i = 0; i < 3; ++i) cin >> A[i];
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];

    // 再帰する
    vector<int> sums(3, 0), nums(3, 0);
    cout << rec(sums, nums, 0) << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, x[100], y[100], h[100];

bool f(int cx, int cy, int hh) {
	inc(i, n) {
		if(max(0, hh - abs(cx - x[i]) - abs(cy - y[i])) != h[i]) { return false; }
	}
	
	return true;
}

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i] >> h[i]; }
	
	int ma = 0;
	inc(i, n) { setmax(ma, h[i]); }
	
	incII(cx, 0, 100) {
	incII(cy, 0, 100) {
	incII(hh, ma, ma + 300) {
		if(f(cx, cy, hh)) {
			cout << cx << " " << cy << " " << hh << endl;
			return 0;
		}
	}
	}
	}
	
	assert(false);
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
heights = [int(i) for i in input().split()]

dp = np.full((N), np.Inf)

dp[0] = 0
dp[1] = abs(heights[1] - heights[0])


for i in range(2, N):
    dp[i] = min(
        dp[i-2] + abs(heights[i] - heights[i-2]),
        dp[i-1] + abs(heights[i] - heights[i-1]),
    )
    

print(int(dp[N-1]))


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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 44;
int n;
int memo[N+1];

//?????????TLE?§£???
//?¨?????????????????????§2^44 - (?????????)

int fib(int k) {
  if (memo[k]) return memo[k];
  return fib(k-1) + fib(k-2);
}

int dp(int k) {
  memset(memo, 0, sizeof(memo));
  if (k<=1) return 1;
  memo[0] = memo[1] = 1;
  for (int i=2; i<=k; i++)
    memo[i] = memo[i-1] + memo[i-2];
  return memo[k];
}

int main() {
//  memset(memo, 0, sizeof(memo));
//  memo[0] = memo[1] = 1;
  scanf("%d ", &n);
//  printf("%d\n", fib(n));
  printf("%d\n", dp(n));

	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007
#define rvs(i) reverse( i.begin(), i.end() )

using namespace std;

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

	int m = 0; cin >> m;
	rep(i, m)
	{
		string tmp; cin >> tmp;
		vector<string> str;
		for(int j = 1; j < (int)tmp.size(); j++)
		{
			string tmp1, tmp2, tmp3, tmp4;
			tmp1 = tmp.substr(0, j);
			tmp2 = tmp.substr(j);
			tmp3 = tmp1; rvs(tmp3);
			tmp4 = tmp2; rvs(tmp4);

			str.push_back(tmp1 + tmp2);
			str.push_back(tmp1 + tmp4);
			str.push_back(tmp3 + tmp2);
			str.push_back(tmp3 + tmp4);
			str.push_back(tmp2 + tmp1);
			str.push_back(tmp2 + tmp3);
			str.push_back(tmp4 + tmp1);
			str.push_back(tmp4 + tmp3);
		}
		sort(all(str));
		str.erase(unique(all(str)), str.end());
		printf("%d\n", (int)str.size());
	}
	return 0;
}

Measured memory_bytes: 1336
s = gets.chomp
flg = true
head = ''
tail = ''
gets.to_i.times{
  q, f, c = gets.chomp.split(" ")
  if q == '1' then
    flg = (not flg)
  else
    if (f == '1' && flg) || (f == '2' && (not flg)) then
      head.concat(c)
    else
      tail.concat(c)
    end
  end
}

if flg then
  printf("#{head.reverse}#{s}#{tail}\n")
else
  printf("#{tail.reverse}#{s.reverse}#{head}\n")
end


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int N,K,a[5000];

bool need(int x) {
	if(a[x]>=K) return true;
	bitset<5000> s(1);
	rep(i,N) if(i!=x) s |= (s<<a[i]);
	for(int i=K-a[x];i<K;i++) if(s[i]) return true;
	return false;
}
 
int main() {
	cin>>N>>K;
	rep(i,N) cin>>a[i];
	sort(a,a+N);
	int l=0,r=N;
	while(l<r){
		int mid = (l+r)/2;
		if(need(mid)) r = mid;
		else l = mid+1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
 
def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()
 
x = readInt()
m = 100
n = 0
 
while 1:
	if m>=x:
		print(n)
		break
	n+=1
	m=math.floor(m*1.01)

Measured memory_bytes: 9184
//কী পেয়েছো তুমি, কী চেয়েছিলে তুমি.? হিসেবটা তোমার বড়ই গড়মিল...!!//
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3F3F3F3F
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ll sum=1;
    for(int i=2;i<=n;i++){
        sum=sum*i;
    }
    cout<<sum<<endl;
}
/*
5 6
1 0
0 5
1 2
1 3
2 3
3 4
*/



Measured memory_bytes: 3096
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> ans = new HashSet<>();
		for(int i=0;i<n;i++) {
			ans.add(sc.nextInt());
		}
		System.out.println(ans.size());
	}

}

Measured memory_bytes: 21844
// https://atcoder.jp/contests/dp/tasks/dp_a

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

#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define MOD 1000000007
#define MAX_TIME 1e9
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf
#define se(a) a.begin(),a.end()
#define fill(a,n) for(int i = 0; i < n; i++)cin>>a[i]


ll solve(int n,int k,vi h){
    vll dp(n,MOD);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i+j < n) dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]));
        }
        // if(i + 1< n) dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        // if(i + 2< n) dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));

    }
    return dp[n-1];
}

int main()
{
    int n,k;
    cin>>n>>k;
    vi h(n,0);
    fill(h,n);
    cout<<solve(n,k,h)<<nl;    
}

Measured memory_bytes: 4748
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int box[2][600], dp[20500];
int m, n;
int inf = 1001001001;

void _dp(void)
{
	for (int i = 0; i < 20500; i++){
		dp[i] = inf;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++){
		for (int j = m; j >= 0; j--){
			if (dp[j] == inf) continue;
			int a =  min(m, j + box[0][i]);
			dp[a] = min(dp[a], dp[j] + box[1][i]);
			// cout << dp[a] << " " << dp[j + box[0][i]] + box[1][i] << endl;
		}
	}

	return;
}

int main(void)
{
	vector <int> manju(10050);
	
	cin >> m >> n;
	for (int i = 0; i < m; i++){
		scanf("%d", &manju[i]);
	}
	for (int i = 0; i < n; i++){
		scanf("%d %d", &box[0][i], &box[1][i]);
	}

	sort(manju.rbegin(), manju.rend());
	_dp();
	int ret = 0, sum = 0;
	for (int i = 0; i < m; i++){
		sum += manju[i];
		// cout << sum << " " << i << endl;
		if (dp[i+1] != inf) ret = max(ret, sum - dp[i + 1]);
	}

	cout << ret << endl;
}

Measured memory_bytes: 1368
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
vector<pair<int, int>> C[N];
long long a[N], seg[N << 1];
int n, m;

void update(int p, long long x, int id = 1, int st = 0, int en = n) {
	if (en - st == 1) {
		seg[id] = x;
		return;
	}
	int mid = st + en >> 1;
	if (p < mid)
		update(p, x, id << 1, st, mid);
	else
		update(p, x, id << 1 | 1, mid, en);
	seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
}

long long get(int l, int r, int id = 1, int st = 0, int en = n) {
	if (r <= st || en <= l)
		return 1e18;
	if (l <= st && en <= r)
		return seg[id];
	int mid = st + en >> 1;
	return min(get(l, r, id << 1, st, mid), get(l, r, id << 1 | 1, mid, en));
}

inline void read_input() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, c;
		cin >> l >> r >> c;
		C[--r].push_back({--l, c});
	}
}

inline void solve() {
	memset(a, 63, sizeof a);
	memset(seg, 63, sizeof seg);
	for (int i = a[0] = 0; i < n; update(i, a[i]), i++)
		for (auto x: C[i])
			a[i] = min(a[i], get(x.first, i) + x.second);
	cout << (a[n - 1] < 1e18? a[n - 1]: -1);
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve();
	return 0;
}



Measured memory_bytes: 8064
// Problem: A - Blackjack
// Contest: AtCoder - AtCoder Beginner Contest 147
// URL: https://atcoder.jp/contests/abc147/tasks/abc147_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
#pragma GCC optimize("-O2")
const int INF = 10000000;
 
void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
//1. Ends here
 
//2. Extra Functions here
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	if(a1+a2+a3>=22){
		cout<<"bust\n";
	}
	else cout<<"win\n";
    return;
}
// how r u bro

Measured memory_bytes: 3620
#include <stdio.h>

int main(){

  int b,f,r,v,n,a[4][3][10],s,i,j,k;
  scanf("%d",&n);
  for(i=0;i<4;i++)
    for(j=0;j<3;j++)
      for(k=0;k<10;k++)a[i][j][k]=0;
  for(s=0;s<n;s++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    a[b-1][f-1][r-1] += v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",a[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}

Measured memory_bytes: 612
/* 
 * Project: AtCoder Beginners Contest 142 A - Odds of Oddness
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/16
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

uint32_t n;

void solve() {

    if (!(n&1)) {
        printf("%f\n", 0.5);
    } else if (n == 1) {
        printf("%f\n", 1.0);
    } else {
        printf("%f\n", (n/2+1)/(float)n);
    }


}

int main() {

    scanf("%d", &n);

    solve();

}

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

int main(){
  int R;
  double pi, l;
  cin >> R;
  pi = M_PI;
  l = 2 * R * pi;
  cout << fixed;
  cout << setprecision(3) << l << endl;
  return 0;
}

Measured memory_bytes: 3800
A, B, H, M = gets.chomp.split(' ').map(&:to_i)
pi = Math::PI

hy = A * Math.cos(pi * ((H.to_f / 6.0) + (M.to_f / 60.0) / 6.0))
hx = A * Math.sin(pi * ((H.to_f / 6.0) + (M.to_f / 60.0) / 6.0))
my = B * Math.cos(pi * (M.to_f / 30.0))
mx = B * Math.sin(pi * (M.to_f / 30.0))

puts Math.sqrt((hy - my) ** 2 + (hx - mx) ** 2)

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

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

    int count = 0;

    for (int x = 0; x <= K; x++) {
        for (int y = x; y <= K; y++) {
            if (x + y + K < S || x + 2 * y > S) continue;
            int z = S - x - y;
            int c = int(x == y) + int(y == z) + int(z == x);  // 0 or 1 or 3
            if (c == 0)
                count += 6;
            else if (c == 1)
                count += 3;
            else
                count += 1;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define    fio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define    eps     1e-9;
#define     mod      1000000007;
using namespace std;
typedef long long ll;

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


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

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

  return 0;

}


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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

const int MOD = 1e9 + 7;

int main() {
	Boost();

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

	vector < string > v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	vector < vector < int > > DP;
	DP.assign(n + 1, vector < int > (m + 1));
	
	DP[0][1] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (v[i - 1][j - 1] == '.') {
				DP[i][j] = (DP[i - 1][j] + DP[i][j - 1]) % MOD;
			}
		}
	}

	cout << DP[n][m];
	return 0;
}

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

int main() {
 string s;
  cin >> s;
  int n = s.length();
  int cnt = 0;
  for (int i = 0; i < n; i++)
    cnt += s[i] == 'o';
  cnt += 15-s.length();
  cout << (cnt >= 8 ? "YES":"NO") << endl;
  return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto o = readln.chomp, no = o.length;
  auto e = readln.chomp, ne = e.length;

  auto r = new char[](no+ne);
  foreach (i, c; o) r[i*2] = c;
  foreach (i, c; e) r[i*2+1] = c;

  writeln(r);
}


Measured memory_bytes: 256
//WAPER
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define N 21
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,len[N];
int x[N][N],y[N][N],vis[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	for(register int i=1;i<=n;i++)
	{
		len[i]=read();
		for(register int j=1;j<=len[i];j++)x[i][j]=read(),y[i][j]=read();
	}
	int ans=0;
	for(register int S=0;S<(1<<n);S++)
	{
		int num=0,flag=1;;
		for(register int i=1;i<=n;i++)if(S&(1<<(i-1)))num++,vis[i]=1;else vis[i]=0;
		for(register int i=1;i<=n;i++)
		{
			if(S&(1<<(i-1)))
			{
				for(register int j=1;j<=len[i];j++)
				{
					if(vis[x[i][j]]!=y[i][j]){flag=0;break;}
				}
			}
			if(!flag)break;
		}
		if(flag){ans=max(ans,num);}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
		int n = s.Length;
    bool answer = true;
    if(s[n-1] == '1') answer = false;
    if(s[0] == '0') answer = false;
    int[][] answers = new int[n-1][];

    for(int i = 0; i < n-1; i++)
    {
      if(s[i] != s[n-2-i]) answer = false;
      answers[i] = new int[2];
    }

    if(!answer) Console.WriteLine(-1);
    else
    {
      answers[0][0] = 1;
      answers[0][1] = 2;
      int nowVertex = 2;
      for(int i = 1; i < n-1; i++)
      {
        answers[i][0] = nowVertex;
        answers[i][1] = i+2;
        if(s[i] == '1')
        {
          nowVertex = i+2;
        }
      }

      var answerText = new StringBuilder();
      for(long i = 0; i < answers.Length; i++)
      {
        answerText.AppendLine(string.Join(" ", answers[i]));
      }
      Console.Write(answerText);
    }
	}
}

Measured memory_bytes: 28112
#include<cstdio>

int main(void){
  int n, l[10], mx=0, sum=0, i;
  scanf("%d", &n);
  for(i=0; i<n; ++i){
    scanf("%d", l+i);
    sum+=l[i];
    mx=(l[i]>mx)?l[i]:mx;
  }
  printf("%s\n", (sum-mx>mx)?"Yes":"No");
  return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF=2E5;
typedef pair<int,int> Pair;

int main(){
    int N,M;
    cin >> N >> M;
    long long ans=0;

        ans=1;
        ans*=abs(N-2);
        ans*=abs(M-2);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=400005;
const ll INF=1LL<<60;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}




Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
int main(void){
    int A, B, C, X;
    scanf("%d %d %d %d", &A, &B, &C, &X);
    
    unsigned long long int count = 0;
    for (int a = 0; a <= 500*A; a += 500){
        for (int b = 0; b <= 100*B; b += 100){
            int temp = X-a-b;
            if (temp < 0) break;
            if (temp <= 50*C) ++count;
        }
    }
    printf("%d", count);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

ll facctorialMethod(ll k)
{
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum %= 1000000007;
    }
    return sum;
}

// int main(int argc, char const *argv[])
// {
//     ll n;
//     cin >> n;
//     vector<pair<ll, ll>> v;
//     for (ll i = 0; i < n; i++)
//     {
//         ll x, y;
//         cin >> x >> y;
//         v.push_back(make_pair(x, y));
//     }

// }

// double sum = 0;
// void d(vector<pair<ll, ll>> t, pair<ll, ll> p)
// {
//     if(t.empty())
//         return;
//     for (ll i = 0; i < t.size(); i++)
//     {
//         sum += (t[i].first - p.first) * (t[i].first - p.first) + 

//     }
// }

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v;
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }

    double sum = 0;
    for (ll i = 0; i < n-1; i++)
    {
        for (ll k = i+1; k < n; k++)
        {
            sum += sqrt((v[i].first - v[k].first) * (v[i].first - v[k].first) + (v[i].second - v[k].second) * (v[i].second - v[k].second));
        }
    }

    ll f = facctorialMethod(n);

    cout << SP(10) << sum * (n - 1) * facctorialMethod(n-2) / f * 2 << endl;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 1e9;
  for (int i = 0; i - 1 + m < n; ++i) {
    int res = 0;
    for (int j = 0; j < m; ++j) {
      if (s[i + j] != t[j]) {
        res++;
      }
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
      break;

    for(i = 0; i < H ; i++ ){
       for ( j = 0; j < W; j++ ){
	 if(0<i&&i<H-1&&0<j&&j<W-1 ){
            printf(".");
        } else {
            printf("#");
        }
       }
       printf("\n");
    }
     printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,c=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n-2;i++)
  {
    if((a[i+1]>=a[i] && a[i+1]<a[i+2]) || (a[i+1]<a[i] && a[i+1]>=a[i+2]))
      c++;
  }
  cout<<c;
  return 0;
}
        

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	bool turn=false;
	while(a>0 && c>0){
		if(!turn) c-=b;
		else a-=d;
		turn^=1;
	}
	if(a<c) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(void){
  long long int n, i, sum = 0, yo;
  cin >> n;
  sum = (n / 11) * 2;
  yo = n % 11;
  if(yo > 6){
    sum = sum + 2;
  }else if(yo > 0){
    sum = sum + 1;
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<map>
#include<set>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
	
using namespace std;

int v[300];
int tmp[300];

int main(){
	int n;
	scanf("%d",&n);
	fo(i,'a','z')v[i]=1000;
	fo(cas,1,n){
		char s[110];
		scanf("%s",s+1);
		fo(i,'a','z')tmp[i]=0;
		fo(i,1,strlen(s+1))tmp[s[i]]++;
		fo(i,'a','z')v[i]=min(v[i],tmp[i]);
	}
	fo(i,'a','z')
		fo(j,1,v[i])putchar(i);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input()) 

    s = 0

    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 == 0:
           continue
        else:
            s += i
    
    print(s)


if __name__ == '__main__':
    main()

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

// return the prime factors of n
std::map<int64_t, int64_t> primeFactor(int64_t n) noexcept {
    std::map<int64_t, int64_t> ret;
    for (int64_t i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++ret[i];
            n /= i;
        }
    }

    if (n != 1) {
        ret[n] = 1;
    }

    return ret;
}

int main() {
    int64_t N;
    std::cin >> N;

    auto m = primeFactor(N);
    
    int64_t ans = 0;
    for (auto p : m) {
        int64_t c = p.second;
        int64_t i = 1;
        while (c >= i) {
            ans += 1;
            c -= i;
            i++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3632
N=int(input())
a=list(map(int,input().split()))

A=[0]*(max(a)+1)
ans=0

for i in a:
    A[i]+=1

if len(A)>3:
    for j in range(1,max(a)):
        ans=max(ans,A[j-1]+A[j]+A[j+1])
else:
    ans=sum(A)

print(ans)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long a,b,x;
  cin>>a>>b>>x;
  long long ans;
  if(a==0){
    ans = b/x+1;
  }else{
    ans = b/x-(a-1)/x;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256