akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll max_n = 1e5+5;
const ll inf = 1e17;

int main() {
    // your code goes here
    ll n, a, b, c, dp[max_n][5]={0};
    cin >> n;
    rep(i,1,n){
    	cin >> a >> b >> c;
    	chmax(dp[i][1], max(dp[i-1][2],dp[i-1][3])+a);
    	chmax(dp[i][2], max(dp[i-1][3],dp[i-1][1])+b);
    	chmax(dp[i][3], max(dp[i-1][1],dp[i-1][2])+c);
    }
    cout << max({dp[n][1],dp[n][2],dp[n][3]}) << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
map<pair<int,int>,int> mp;
map<pair<int,int>,bool> mp2,mp3;
vector<int> edge[maxn];
int res[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		--a,--b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		mp[make_pair(a,b)]=mp[make_pair(b,a)]=i;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,(int)edge[i].size());
	}
	cout<<ans<<endl;
	for(int i=0;i<n;i++)
	{
		int now=0;
		for(int j=0;j<edge[i].size();j++)
		{
			if(mp3[make_pair(i,edge[i][j])])
			{
				continue;
			}
			if(mp2[make_pair(i,now)])
			{
				now++;
				j--;
				continue;
			}
			res[mp[make_pair(i,edge[i][j])]]=now;
			mp2[make_pair(i,now)]=1;
			mp2[make_pair(edge[i][j],now)]=1;
			mp3[make_pair(i,edge[i][j])]=1;
			mp3[make_pair(edge[i][j],i)]=1;
		}
	}
	for(int i=0;i<n-1;i++)
	{
		cout<<res[i]+1<<endl;
	}
	return 0;
}

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

int main(){
    int N, K;  cin >> N >> K;
    if(K > (N-1)*(N-2)/2){
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int,int>> ans;
    for(int i=2; i<=N; i++){
        ans.push_back({1, i});
    }

    vector<pair<int,int>> cand;
    for(int i=2; i<=N; i++) for(int j=i+1; j<=N; j++){
        cand.push_back({i,j});
    }

    int del = (N-1)*(N-2)/2 - K;
    for(auto c:cand){
        if(del>0){
            ans.push_back(c);
            del--;
        }
    }

    cout << ans.size() << endl;
    for(auto a:ans){
        cout << a.first << " " << a.second << endl;
    }
}


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

int main()
{
    long long n;
    cin >> n;
    int digit_a, digit_b;;
    int digit_max = 0;
    int min = 100000;
    
    for(long int i = 1; i * i <= n; i++){
        if(n % i == 0){
            long int j = n / i;
            
            digit_a = log10(i) + 1;
            digit_b = log10(j) + 1;
            
            digit_max  = max(digit_a,digit_b);
            
            if(digit_max < min)
                min = digit_max;
            digit_a = 0; digit_b = 0;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoderGC005 {
  class AtCoderGC005 {
    static void Main(string[] args) {
      new AtCoderGC005().solveA();
    }

    private void solveA() {
      var s = Console.ReadLine();

      Stack<char> stack = new Stack<char>();
      foreach(char x in s){
        if (x == 'S')
          stack.Push(x);

        else if (stack.Count == 0 || x == 'T' && stack.Peek() == 'T')
          stack.Push(x);

        else if (x == 'T' && stack.Peek() == 'S')
          stack.Pop();        
      }                 
      Console.WriteLine(stack.Count);
    }//end.

  }
}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;rep(tcs,1,tt+1)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3648
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]


ans = [0] * 26

s = input()

for i in range(len(s)):
    idx = ord(s[i]) - 0x61
    ans[idx] += 1
    if (ans[idx] > 1):
        print("no")
        exit()
print("yes")




Measured memory_bytes: 8936
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		REP(j, w) {
			string a;
			cin >> a;
			if (a == "snuke") {
				char s = j + 'A';
				cout << s << i + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, p: [usize; n]};
    let p: Vec<usize> = p;

    let mut count = 1;
    let mut index = 0;

    for i in 1..n {
        // println!("index: {}", index);
        // println!("i    : {}", i);
        if index == i - 1 {
            // println!("STEP1");
            if p[index] >= p[i] {
                count += 1;
                index += 1;
            }
        } else {
            // println!("STEP2");
            // let m = &p[index..i];
            // println!("{:?}", m);
            if p[index] >= p[i] {
                index = i;
                count += 1;
            }
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4844
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int add = 100*r+10*g+b;
        if (add%4==0) {
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


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

int main(){
    int a,b,k;
    cin >> a >> b >> k;

    int stopper = 0,answer;
    for(int i=a;i>=1;i--){
        if(a%i == 0 && b%i == 0){
            stopper++;
            answer = i;
        }

        if(stopper == k){
            break;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        n: usize,
    }
    let mut sum = 0;
    for i in 1..=n {
        if i%3 != 0 && i%5 != 0 {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2140
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;


int main()
{
	string S;
	int Q;
	cin >> S;
	cin >> Q;

	vector<int> q1(Q);
	vector<int> q2(Q);
	vector<char> q3(Q);
	int reverse_cnt = 0;

	for (int i = 0; i < Q; ++i)
	{
		cin >> q1[i];
		if (q1[i] != 1) {
			cin >> q2[i] >> q3[i];
		}
		else {
			reverse_cnt++;
		}
	}

	bool reverse_flag;
	if (reverse_cnt % 2 == 1) {
		reverse(S.begin(), S.end());
	}

	string left;
	string right;

	for (int i = 0; i < Q; ++i)
	{
		if (q1[i] == 1) {
			reverse_cnt -= 1;
		}
		else {
			if (reverse_cnt % 2 == 0) {
				if (q2[i] == 1) {
					left.push_back(q3[i]);
				}
				else {
					right.push_back(q3[i]);
				}
			}
			else {
				if (q2[i] == 1) {
					right.push_back(q3[i]);
				}
				else {
					left.push_back(q3[i]);
				}
			}
		}
	}

	reverse(left.begin(), left.end());
	cout << left + S + right<< endl;
	return 0;
}

Measured memory_bytes: 5848
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    char s[55]={};
    int n,k;
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    s[k-1]=s[k-1]-'A'+'a';
    printf("%s\n",s);
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	rep(i, s.size()) {
		if (i % 2 == 0) {
			if(s[i] == 'L') {
				ANS("No");
				return 0;
			}
		}
		else {
			if(s[i] == 'R') {
				ANS("No");
				return 0;
			}
		}
	}
	ANS("Yes");
}


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

int main()
{

    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];

    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
    }

    int ans = 0;

    for (int h = 0; h < N; h++)
    {
        int sum = 0;
        for (int i = 0; i < M; i++)
        {
            sum += A[h][i] * B[i];
        }
        if (sum + C > 0)
            ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  int cnt[N];
  int a[M],b[M];
  for (int i = 0; i < N; i++) cnt[i] = 0;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  bool can = true;
  for (int i = 0; i < N; i++) {
    if (cnt[i] % 2 != 0) {
      can = false;
    }
  }
  if (can) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

class BM {
    int p_len;
    string p;
    vector <int> skip; // 文字iはpatternの後ろから何番目に現れるか

public:
    BM(const string &pattern) {
        p = pattern;
        p_len = p.size();
        skip.assign(128, -1);
        for (int i = 0; i < p_len; i++) {
            skip[p[i]] = p_len - i - 1;
        }
    }

    vector <int> match(const string &s) {
        int i = p_len - 1;
        int s_len = s.size();
        vector <int> ret;
        while (i < s_len) {
            int j = p_len - 1;
            while (s[i] == p[j]) {
                if (j == 0) {
                    ret.push_back(i);
                    break;
                }
                i--; j--;
            }
            i += max(p_len - j, skip[s[i]]);
        }
        return ret;
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_A&lang=jp
void AOJ_ALDS1_14_A() {
    string T, P;
    cin >> T >> P;
    BM bm(P);
    vector <int> ans = bm.match(T);
    for (int i : ans) cout << i << "\n";
}

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


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  int n;
  cin>>n;
  int p[n],q[n];
  rep(i,n)cin>>p[i];
  rep(i,n)cin>>q[i];
  vector<int> num;
  int cou=1;
  int a,b;
  int flag=0;
  rep(i,n)num.push_back(i+1);

    do {
      flag=0;
      rep(i,n){
        if(p[i]!=num[i])flag=1;
      }
      if(flag==0)a=cou;
      flag=0;
      rep(i,n){
        if(q[i]!=num[i])flag=1;
      }
      if(flag==0)b=cou;
      cou++;
    } while (next_permutation(num.begin(), num.end()));
    cout<<abs(a-b)<<endl;
}




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


void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    auto dist = [&](int i, int j){
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx*dx+dy*dy);
    };
    vector<int> p(N);
    for(int i = 0; i < N; ++i) p[i] = i;
    double len = 0;
    int cnt = 0;
    do {
        for(int i = 0; i < N-1; ++i){
            len += dist(p[i], p[i+1]);
        }
        cnt++;
    } while (next_permutation(p.begin(), p.end()));
    double ans = len/cnt;
    printf("%.10f\n", ans);
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 3832
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define esp 1e-7
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

long long n,a,b,c,d;

int main(){
	cin>>n>>a>>b>>c>>d;
	long long l=a,r=a;
	for (int i=1;i<=n;i++){
		l+=c;r+=d;
		if (b+(n-1-i)*c<=r&&b+(n-1-i)*d>=l){
			printf("YES\n");
			return 0;
		}
		if (i==n){
			printf("NO\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

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

using namespace std;
typedef long long LL;
int n;

int main()
{
    scanf("%d",&n);
    LL res = 0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n/i;j++)
            res += i*j;
    cout << res << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int t[n], sum=0;;
	for (int i = 0; i < n; ++i) cin >> t[i], sum+=t[i];

	bool dp[n][850][850]={};
	
	dp[0][t[0]][0]=1;
	dp[0][0][t[0]]=1;
	dp[0][0][0]=1;
	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j < 850; ++j)
		{
			for (int k = 0; k < 850; ++k)
			{
				if(dp[i-1][j][k]==1)
				{
					if(j+t[i]<850) dp[i][j+t[i]][k]=1;
					if(k+t[i]<850) dp[i][j][k+t[i]]=1;
					dp[i][j][k]=1;
				}
			}
		}
	}

	int ans = 1000, tmp;
	for (int i = 0; i < 850; ++i)
	{
		for (int j = 0; j < 850; ++j)
		{
			if(dp[n-1][i][j]==1)
			{
				tmp = max(sum-i-j, max(i, j));
				ans = min(ans, tmp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

/*
 b
lurd
 f
*/
struct Dice {
  long long l, r, f, b, d, u, x, y;
  Dice(long long _l = 4, long long _r = 3, long long _f = 2,
       long long _b = 5, long long _d = 6, long long _u = 1,
       long long _x = 0, long long _y = 0)
      : l(_l), r(_r), f(_f), b(_b), d(_d), u(_u), x(_x),
        y(_y) {}

  void RollN() {
    long long buff = d;
    d = b;
    b = u;
    u = f;
    f = buff;
    ++y;
  }

  void RollS() {
    long long buff = d;
    d = f;
    f = u;
    u = b;
    b = buff;
    --y;
  }

  void RollE() {
    long long buff = d;
    d = r;
    r = u;
    u = l;
    l = buff;
    ++x;
  }

  void RollW() {
    long long buff = d;
    d = l;
    l = u;
    u = r;
    r = buff;
    --x;
  }

  void RollL() {
    long long buff = f;
    f = l;
    l = b;
    b = r;
    r = buff;
  }

  void RollR() {
    long long buff = f;
    f = r;
    r = b;
    b = l;
    l = buff;
  }

  vector<Dice> makeDice() {
    vector<Dice> ret;
    for(int i = 0; i < 6; i++) {
      Dice d(*this);
      if(i == 1) d.RollN();
      if(i == 2) d.RollS();
      if(i == 3) d.RollS(), d.RollS();
      if(i == 4) d.RollE();
      if(i == 5) d.RollW();
      for(int j = 0; j < 4; j++) {
        ret.emplace_back(d);
        d.RollL();
      }
    }
    return (ret);
  }

  bool operator==(const Dice &di) const {
    return l == di.l && r == di.r && f == di.f &&
           b == di.b && d == di.d && u == di.u;
  }
};
long long a, b, c, d, e, f, n;
vector<vector<Dice>> v;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> a >> b >> c >> d >> e >> f;
    v.emplace_back(Dice(d, c, b, e, f, a).makeDice());
  }
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j) {
      for(int k = 0; k < 24; ++k)
        for(int l = 0; l < 24; ++l)
          if(v[i][k] == v[j][l]) {
            cout << "No" << endl;
            return 0;
          }
    }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
  int64_t X; cin >> X;
  
  int64_t Max = 300;/*
  for(int i = 0; i <= X; i++){
    if(i*i*i*i > X){
      Max = i;
      break;
    }
  }*/
  
  for(int64_t B = Max; B >= 1; B--){ //A+B
    int64_t rem = X - B*B*B*B*B;
    if(rem < 0)
      continue;
    for(int64_t A = B; A >= 0; A--){
      if(A*A*A*A*A < rem){
        break;
      }
      if(A*A*A*A*A == rem){
        cout << B << ' ' << (-1)*A << endl;
        return 0;
      }
    }
  }
  
  for(int64_t B = Max; B >= 1; B--){ //A-B
    int64_t rem = B*B*B*B*B - X;
    for(int64_t A = B-1; A >= 0; A--){
      if(A*A*A*A*A < rem){
        break;
      }
      if(A*A*A*A*A == rem){
        cout << B << ' ' << A << endl;
        return 0;
      }
    }
  }
  cout << "error" << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b;
    cin >> a >> b;
    if (a * b % 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define mp make_pair
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
vector<pair<int,int> >ans;
int n;
int main()
{
	n=read();
	if(n&1)
	{
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j)
				if(i+j!=n)ans.push_back(mp(i,j));
	}
	else
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j)
				if(i+j!=n+1)ans.push_back(mp(i,j));
	printf("%d\n",ans.size());
	for(auto a:ans)printf("%d %d\n",a.first,a.second);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    int a, b, c;
    int flag = 1;
    string ans[] = {"Yes", "No"};
	cin>>a>>b>>c;
    if ((a == b && b != c)||
        (b == c && b != a)||
        (a == c && a != b)){
            flag = 0;
        }
	cout<<ans[flag]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string a,c;
  int b=0,d=0;
  cin>>a;
  c=a;
  for(int i=1;i<a.size();i++){
    if(a[i-1]==a[i]){
      b++;
      if(a[i]=='0') a[i]='1';
      else a[i]='0';
    }
  }
  for(int i=c.size()-1;i>=0;i--){
    if(c[i-1]==c[i]){
      d++;
      if(c[i]=='0') c[i]='1';
      else c[i]='0';
    }
  }
  cout<<b<<"\n";
}

Measured memory_bytes: 512
import sys

for s in sys.stdin:
  i,j=s.find("+"),s.find("=")
  A=[s[0:i],s[i+1:j],s[j+1:-1]]
  f=0
  for e in A:
    if e!=e[0]=="X": f=1; break
  m="NA"
  s=s.replace("=","==")
  for c in "0123456789"[f:]:
    if eval(s[:-1].replace("X",c)): m=c; break
  print m

Measured memory_bytes: 4268
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
struct edge {
    ll u, v, cost;
};

class UnionFind {
public:
    vector<ll> par; // 親
    vector<ll> rank; // 木の深さ

    explicit UnionFind(unsigned int n) {
        par.resize(n);
        rank.resize(n);
        rep(i, n) {
            par[i] = i;
            rank[i] = 0;
        }
    }

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

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

    // xとyが同じ集合に属するか否か
    bool is_same(ll x, ll y) {
        return find(x) == find(y);
    }
};

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

// 頂点数V, 辺の数E
vector<edge> es;
ll n;

// 最小全域木のコストの和を返す．
ll kruskal() {
    sort(es.begin(), es.end(), comp);
    UnionFind u = UnionFind(n);
    ll res = 0;
    each(e, es) {
        if (!u.is_same(e.u, e.v)) {
            u.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

struct info {
    ll idx, x, y;
};
vector<info> v;

bool comp_x(info info1, info info2) {
    return info1.x < info2.x;
}

bool comp_y(info info1, info info2) {
    return info1.y < info2.y;
}


void solve() {
    sort(v.begin(), v.end(), comp_x);
    rep(i, n - 1) {
        edge e = {v[i + 1].idx, v[i].idx, v[i + 1].x - v[i].x};
        es.emplace_back(e);
    }
    sort(v.begin(), v.end(), comp_y);
    rep(i, n - 1) {
        edge e = {v[i + 1].idx, v[i].idx, v[i + 1].y - v[i].y};
        es.emplace_back(e);
    }
    cout << kruskal() << endl;
}

int main() {
    cin >> n;
    ll x, y;
    rep(i, n) {
        cin >> x >> y;
        info info1 = {i, x, y};
        v.emplace_back(info1);
    }
    solve();
    return 0;
}

Measured memory_bytes: 10864
h,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(h)]

ans_num=0
ans_l=[]
for i in range(h):
  for j in range(w):
    if j!=w-1:
      if l[i][j]%2==1:
        l[i][j]-=1
        l[i][j+1]+=1
        ans_num+=1
        ans_l.append([i+1,j+1,i+1,j+1+1])
    elif i!=h-1:
      if l[i][j]%2==1:
        l[i][j]-=1
        l[i+1][j]+=1
        ans_num+=1
        ans_l.append([i+1,j+1,i+1+1,j+1])


print(ans_num)
for i in ans_l:
  print(*i)

Measured memory_bytes: 30300
import numpy as np
import itertools
[N,M,X]=map(int,input().split())
l=[]
for i in range(N):
    
    l.append(list(map(int,input().split())))
l=np.array(l)
num=np.array([i for i in range(N)])
C = l[:,0]
A = l[:,1:]
ans = -1
for i in range(N):
    for c in itertools.combinations(num,i+1):
        score = np.zeros(M)
        cost = 0
        for j in c:
            score=score+A[j]
            cost = cost+C[j]
        if np.min(score)>=X:
            if ans>=cost or ans ==-1:
                ans = cost
if ans ==0:
    ans = -1
print(ans)

Measured memory_bytes: 27180
#include <iostream>
#include <cstdio>

using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(a>b){
		cout<<0<<endl;
		return 0;
	}
	if((n==1)&&(a!=b)) {
		cout<<0<<endl;
		return 0;
	}
	if((n==1)&&(a==b)){
		cout<<1<<endl;
		return 0;
	}
	
//	long max=a+(n-1)*b;
//	long min=(n-1)*a+b;
	printf("%lld\n",(long long)(b-a)*(n-2)+1);	
	return 0;
}

Measured memory_bytes: 384
from heapq import heapify, heappop, heappush, heappushpop

heap = []
while True:
    tmp = input()
    if tmp.startswith('end'):
        break
    elif tmp.startswith('insert'):
        k = int(tmp.split()[1])
        heappush(heap,-k)
    elif tmp.startswith('extract'):
        print(-heappop(heap))



Measured memory_bytes: 45312
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

for i in range(M):
    print(ans - T[PX[i][0]] + PX[i][1])


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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<string> r(h, string(w, '0'));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i < b == j < a) r[i][j] = '1';
    }
  }
  for (const auto& e : r) cout << e << endl;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <cstdint>

int64_t dp[5002][5001];
constexpr int64_t Mod = 1000000007;

int main() {
	int n;
	std::string str;
	std::cin >> n >> str;

	dp[0][0] = 1;
	for (int i = 0; i <= n; ++i) {
		if (i != 0)
			dp[i][0] += dp[i - 1][0];
		for (int j = 1; j <= i; ++j) {
			dp[i][j] += (dp[i - 1][j - 1] * 2) % Mod;

			dp[i + 1][j - 1] = (dp[i][j] + dp[i + 1][j - 1]) % Mod;
		}
	}

	auto ans = dp[n][str.size()];
	for (int i = 0; i < str.size(); ++i)
		ans = (ans * 500000004) % Mod;

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

Measured memory_bytes: 193920
#include <stdio.h>

int main(){
    int n,i,s[30]={1,2,4};
    scanf("%d",&n);
    while(n!=0){
        if(n==1 || n==2 || n==3){
            printf("1\n");
        }else{
            for(i=3; i<n; i++){
                s[i]=s[i-3]+s[i-2]+s[i-1];
            }
            if((s[(n-1)])%3650==0){
                printf("%d\n",(s[(n-1)]/3650));
            }else{
                printf("%d\n",(s[(n-1)]/3650)+1);
            }
        }
        scanf("%d",&n);
    }
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define repi(i,start,end) for(int i=int(start);i<int(end);++i)
#define rep(i,n) repi(i,0,n)
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;
typedef pair<int,int> P;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != int(v.size()) ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

v(int) update(v(int) X) {
  int n = X.size();
  v(int) A(n + 1,0);
  rep(i,n) {
    A[max(0, i - X[i])]++;
    A[min(n, i + X[i] + 1)]--;
  }
  v(int) B(n,0);
  B[0] = A[0];
  repi(i, 1, n){
    B[i] = B[i - 1] + A[i];
  }
  return B;
}

void Main()
{
  int N, K;
  cin >> N >> K;
  v(int) A(N);
  cin >> A;

  rep(i, min(K,100)) {
    A = update(A);
  }

  cout << A << "\n";
}

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

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

int main(){
	int N;
  	cin >> N;
  	int D,X;
  	cin >> D >> X;
  	int A;
  	int cnt;
  	int sum = 0;
  	for(int i = 0; i < N ; i++){
      	cin >> A;
      	cnt = 1;
  		while(true){
        	if(cnt > D)break;
          	sum++;
        	cnt += A;
        }
    }
  
  	cout << sum+X <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 20
#define LL long long
using namespace std;
int n,a[2*N+5][2*N+5];LL f[2*N+5][2*N+5][2*N+5];
I LL DP(CI l,CI r,CI mid)
{
	if(~f[l][r][mid]) return f[l][r][mid];if(l==r) return 1;if(l==mid||r==mid) return 0;
	RI i,j,p,q;LL t=0;for(i=l;i^mid;++i) for(j=r;j^mid;--j) if(a[i][j])
		for(p=i;p^mid;++p) for(q=j;q^mid;--q) t+=DP(l,p,i)*DP(p+1,q-1,mid)*DP(q,r,j);
	return f[l][r][mid]=t;
}
int main()
{
	RI i,j;string s;memset(f,-1,sizeof(f));
	for(scanf("%d",&n),i=1;i<=2*n;++i) for(cin>>s,j=1;j<=2*n;++j) a[i][j]=s[j-1]&1;
	LL t=0;for(i=2;i<=2*n;++i) a[1][i]&&(t+=DP(2,2*n,i));return printf("%lld",t),0;
}

Measured memory_bytes: 1024
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
// 個数がゼロになったらfalseにする
signed main() {
    int N, M;
    cin >> N >> M;
    vector<bool> vec(N, false);
    vector<int> nums(N, 1);
    vec[0] = true;
    for (int i = 0; i < M; i++) {
        int from , to;
        cin >> from >> to;
        from--; to--;
        vec[to] = vec[to] | vec[from];
        nums[from]--;
        nums[to]++;
        if (nums[from] == 0) vec[from] = false;
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) if (vec[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const int D = inputVal<int>();

	int cnt = 0;
	int n = N;
	rep(i, N) {
		if (n <= 0) break;
		n -= 2 * D + 1;
		++cnt;
	}

	outputVal(cnt);
}

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

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 998244353
#define int long long
using namespace std;
const int N=3*1e6+100;
int n,m,fac[N],inv[N],a,b;
inline int m_pow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(ans*a)%mod;
		b>>=1;
		a=(a*a)%mod; 
	}
	return ans;
}
inline int c(int n,int m)
{
	if (m>n) return 0;
	return (fac[n]*(inv[m]*inv[n-m]%mod)%mod)%mod;
}
signed main()
{
	scanf("%lld%lld",&n,&m);
	fac[0]=1;
	for (int i=1;i<=n+3*m;i++) fac[i]=(fac[i-1]*i)%mod;
	inv[n+3*m]=m_pow(fac[n+3*m],mod-2);
	for (int i=n+3*m-1;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mod;
	for (int i=0;i<=m;i++)
	{
		if ((3*m-i)%2!=0) continue;
		a=(a+(c(n,i)*c(n+(3*m-i)/2-1,n-1))%mod)%mod;
	}
	for (int i=2*m+1;i<=3*m;i++) b=(b+c(n+3*m-i-2,n-2))%mod;
	b=(b*n)%mod;
	printf("%lld\n",(a-b+mod)%mod);
}

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

using namespace std;
#define lint long long

typedef pair<int, int> P;

const int INF = 10000;

int main() {
    vector<int> dic = {100, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    
    int N, M;
    cin >> N >> M;
    
    vector<int> A(M);

    for(int i = 0; i < M; ++i){
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    
    int dp[N + 1];
    dp[0] = 0;
    for(int i = 1; i < N + 1; ++i){
        dp[i] = -INF;
    }
    
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j < M; ++j){
            if(i - dic[A[j]] >= 0){
                dp[i] = max(dp[i], dp[i - dic[A[j]]] + 1);
            }
        }
    }
//
//    for(int i = N; i >= 0; --i){
//        cout << i << " " << dp[i] << endl;
//    }
//
    for(int i = dp[N]; i >= 0; --i){
        for(int j = M - 1; j >= 0; --j){
            if(N - dic[A[j]] < 0){
                continue;
            }
            if(dp[N - dic[A[j]]] == dp[N] - 1){
                cout << A[j];
                N -= dic[A[j]];
                break;
            }
        }
    }
    cout << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int num(int i, int n, int s) 
{
 int cnt = 0;

 if (n == 0){
 return (!s); }

 if (i == 10 || s < 0){
 return (0); }

 cnt += num(i + 1, n - 1, s - i);
 cnt += num(i + 1, n, s); return (cnt);
 }

 int main(void) {
 int n, s; while (1){
 scanf("%d %d", &n, &s); 
 if (n == 0 && s == 0){ break; }
 printf("%d\n", num(0, n, s)); }
 return (0); } 





Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main (String[] args){
	    Scanner scan = new Scanner(System.in);
	    int num = Integer.parseInt(scan.next());
	    scan.nextLine();

	    ArrayList<Integer> intList = new ArrayList<Integer>();
	    for(int i = 0; i < num; i++){
	    	intList.add(Integer.parseInt(scan.next()));
	    }
	    Collections.sort(intList);

	    int max = intList.get(intList.size()-1);
	    int min = intList.get(0);

	    System.out.println(max - min);
	}
}

Measured memory_bytes: 21844
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=3e18;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, a, b, c, d; 
map<int, int> mp;

int f(int x) {
    if(x == 0) return mp[0] = 0;
    if(x == 1) return mp[1] = d;
    if(mp[x] != 0) return mp[x];

    int res = INF;
    if((ld)d * (ld)x < INF) {
        res = d * x;
    }
    if(f(x / 2) < INF) chmin(res, d * (x % 2) + a + f(x / 2));
    if(x / 2 + 1 < x && f(x / 2 + 1) < INF) chmin(res, d * (2 - x % 2) + a + f(x / 2 + 1));
    if(f(x / 3) < INF) chmin(res, d * (x % 3) + b + f(x / 3));
    if(x / 3 + 1 < x && f(x / 3 + 1) < INF) chmin(res, d * (3 - x % 3) + b + f(x / 3 + 1));
    if(f(x / 5) < INF) chmin(res, d * (x % 5) + c + f(x / 5));
    if(x / 5 + 1 < x && f(x / 5 + 1) < INF) chmin(res, d * (5 - x % 5) + c + f(x / 5 + 1));

    return mp[x] = res;
}

void solve() {
	cin >> n >> a >> b >> c >> d;
    cout << f(n) << endl;
    mp.clear();
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	int t; cin >> t; rep(i, t)solve();
	//solve();
    return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    string s,t;cin>>s>>t;
    cout<<t<<s<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int M;
    scanf("%d", &M);
    LL sum = 0, ans = 0;
    for (int i = 0; i < M; i++) {
        LL d, c;
        scanf("%lld %lld", &d, &c);
        sum += (d * c);
        ans += c;
    }
    ans--;
    while (sum >= 10) {
          LL tmp = sum / 10;
          ans += (tmp);
          sum %= 10;
          sum += tmp;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
n,*l=map(int,open(0).read().split())
a=l[::3];b=l[1::3];c=l[2::3]
A,B,C=a[0],b[0],c[0]
M=max
for i in range(1,n):
	A,B,C=a[i]+M(B,C),b[i]+M(C,A),c[i]+M(A,B)
print(M(A,B,C))

Measured memory_bytes: 35636
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    int ans;
    double best = 1e32;
    for(int i=0; i<N; i++){
        int H;
        cin >> H;
        double diff = abs(T - H * 0.006 - A);
        if(diff < best){
            best = diff;
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <sstream>      // std::ostringstream
using namespace std;
vector<string> split_s(const string &str, char sep);
vector<int> split_i(const string &str, char sep);
void draw_kochcurve(double x1, double y1, double x2, double y2, int restdrawtimes);
void draw_kochcurve_rec(double x1, double y1, double x2, double y2, int restdrawtimes);
const double ROOT3 = 1.7320508;
int main()
{
  string line="";
  cin >> line;
  int drawtimes = stoi(line);

  vector<double> startx;
  startx.reserve(2);
  vector<double> starty;
  starty.reserve(2);

  //始点
  startx.push_back(0.0);
  starty.push_back(0.0);
  
  //終点
  startx.push_back(100.0);
  starty.push_back(0.0);

  //再帰によりコッホ曲線を描画
  //draw_kochcurve(startx, starty, drawtimes);
  draw_kochcurve(0, 0, 100, 0, drawtimes);
}
void draw_kochcurve(double x1,double y1,double x2,double y2,int restdrawtimes)
{
  draw_kochcurve_rec(x1, y1, x2, y2, restdrawtimes);
  printf("%f %f\n", x2,y2);
}
//2辺に対し，内部にコッホ曲線をn回描いたとき，曲線を構成する頂点群を出力するメソッド
void draw_kochcurve_rec(double x1,double y1,double x2,double y2,int restdrawtimes)
{
  if (restdrawtimes == 0)
  {
      //前エッジのみ描画する(後ろエッジまで描画すると描画がダブってしまう)ことに注意！
      printf("%f %f\n", x1,y1);
  }
  else
  {
    //前エッジ
    double x_1 = (x1 * 2 + x2) / 3;
    double y_1 = (y1 * 2 + y2) / 3;
    //後エッジ
    double x_3 = (x1 + 2 * x2) / 3;
    double y_3 = (y1 + 2 * y2) / 3;
    //中エッジ
    double x_2=(x_1 + x_3 - ROOT3  * (y_3 - y_1))/2;
    double y_2=(y_1+ y_3+ ROOT3 * (x_3 - x_1))/2;

/*
      printf("{1,_1,_2,_3,2} = {\n%f %f\n%f %f\n%f %f\n%f %f\n%f %f\n }\n\n", 
      x1,y1,
      x_1,y_1,
      x_2,y_2,
      x_3,y_3,
      x2,y2
      );
*/

    //各エッジ間に対して再帰的にコッホ曲線を描く
    draw_kochcurve_rec(x1,y1,x_1,y_1, restdrawtimes - 1);
    draw_kochcurve_rec(x_1,y_1,x_2,y_2, restdrawtimes - 1);
    draw_kochcurve_rec(x_2,y_2,x_3,y_3, restdrawtimes - 1);
    draw_kochcurve_rec(x_3,y_3,x2,y2, restdrawtimes - 1);
  }
}
//文字列を分割して取得
vector<string> split_s(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
vector<int> split_i(const string &str, char sep)
{
  vector<int> veci;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        veci.push_back(stoi(buffer));
    }
  return veci;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int n; cin >> n;
  int odd = (n + 1)/2;
  double ans;
  ans = (double)odd/n;



  cout << fixed << setprecision(15) << ans << endl;
	return 0;
}



Measured memory_bytes: 3796
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int ans;
int n;
int a[200];
int sans;
int main()
{
	ans=INF;
	cin>>n;
	rep(i,n)cin>>a[i];
	for(int k=-100;k<=100;k++)
	{
		sans=0;
		rep(i,n)
		{
			sans+=(k-a[i])*(k-a[i]);
		}
		ans=min(ans,sans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n){
    cin>>vec[i];
  }
  vector<int> vec3;
  for(int t=0;t<n;t++){
    int sum1=0;
    int sum2=0;
    for(int i=0;i<t;i++){
      sum1+=vec[i];
    }
    for(int j=t;j<n;j++){
      sum2+=vec[j];
    }
    vec3.emplace_back(abs(sum1-sum2));
  }
  int ans=*min_element(vec3.begin(),vec3.end());
  cout<<ans<<endl;
    
}

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

int64_t gcd(int64_t a,int64_t b){
  int64_t g=max(a,b),l=min(a,b),n=l;
  while(g%l!=0){
    n=l;
    l=g%l;
    g=n;
  }
  return l;
}

int main(){
  int64_t a,b;
  cin >> a >> b;
  int64_t n=gcd(a,b);
  int ans=1;
  for(int64_t i=2;i*i<=n;i++){
    if(n%i==0){
      ans++;
      while(n%i==0)
      n/=i;
    }
  }
  if(n!=1)ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628