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

using namespace std;
using ll = long long;

class DisjointSets
{
public:
    DisjointSets(const int v)
    {
        m_parent.resize(v);
        m_rank.resize(v);
        m_size.resize(v);
        for (int i = 0; i < v; i++) {
            m_parent[i] = i;
            m_rank[i] = 0;
            m_size[i] = 1;
        }
    }

    bool same(const int a, const int b)
    {
        return find(a) == find(b);
    }


    int find(const int a)
    {
        if (m_parent[a] == a) {
            return a;
        } else {
            return m_parent[a] = find(m_parent[a]);
        }
    }

    void unite(const int a_, const int b_)
    {
        const int a = find(a_);
        const int b = find(b_);
        if (a == b) {
            return;
        }
        if (m_rank[a] > m_rank[b]) {
            m_parent[b] = a;
            m_size[a] += m_size[b];
        } else {
            m_parent[a] = b;
            m_size[b] += m_size[a];
        }
        if (m_rank[a] == m_rank[b]) {
            m_rank[b]++;
        }
    }

    int getSize(const int a)
    {
        return m_size[m_parent[a]];
    }

private:
    vector<int> m_parent;
    vector<int> m_rank;
    vector<int> m_size;
};

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

    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0 and m == 0) {
            break;
        }
        using P = pair<int, int>;
        vector<pair<int, P>> edge(m);
        for (int i = 0; i < m; i++) {
            int s, t, c;
            cin >> s >> t >> c;
            s--, t--;
            edge[i] = make_pair(c, make_pair(s, t));
        }
        sort(edge.begin(), edge.end());
        DisjointSets uf(n);
        vector<int> cost;
        for (int i = 0; i < m; i++) {
            const int c = edge[i].first;
            const int u = edge[i].second.first;
            const int v = edge[i].second.second;
            if (not uf.same(u, v)) {
                uf.unite(u, v);
                cost.push_back(c);
            }
        }
        cout << ((n - 1) % 2 == 1 ? cost[n / 2 - 1] : (cost[n / 2 - 1] + cost[n / 2]) * 1.0 / 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3396
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    VEC(ll,cost,4);
    ll n;cin>>n;
    vector<pair<ll,int>>r;
    rep(i,4){
        r.emplace_back(cost[i]*pow(2,3-i),i);
    }
    sort(ALL(r));
    vector<int>o(4);
    rep(i,4){
        o[i] = r[i].second;
    }
    ll res = 0;
    for(auto c : o){
        ll m = n;
        if(c==0){
            res += cost[c]*m*4;
            break; 
        }
        if(c==1){
            res += cost[c]*m*2;
            break; 
        }
        if(c==2){
            res += cost[c]*m;
            break; 
        }
        if(c==3){
            n -= 2*(m/2);
            res += cost[c]*(m/2);
        }
    }
    cout<<res<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

P dp[110][50010];

P max(P p1, P p2){
    if(p1.fi > p2.fi) return p1;
    if(p1.fi < p2.fi) return p2;
    if(p1.se < p2.se) return p1;
    if(p1.se > p2.se) return p2;
    else return p1;
}

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

    int n;
    cin >> n;
    while(n != 0){
        vector<int> p(n);
        REP(i, n) cin >> p[i];
        
        REP(i, n+1)REP(j, 50000) dp[i][j] = mp(-1, 0);
        dp[0][0] = mp(0, 0);
        REP(i, n){
            int req = p[i]%1000;
            if(req == 0) req = 1000;
            REP(j, 50000){
                if(dp[i][j].fi >= 0){
                    int c = req-500;
                    // 1000円払って 500円+小銭をGET
                    if(req <= 500) dp[i+1][j+(500-req)] = mp(dp[i][j].fi+1, dp[i][j].se+p[i]);
                    else{
                        // 1000+c円払って 500円を1枚GET
                        if(j >= c) dp[i+1][j-c] = max(dp[i+1][j-c], mp(dp[i][j].fi+1, dp[i][j].se+p[i]));
                        // 1000円払って 小銭をGET
                        dp[i+1][j+(1000-req)] = max(dp[i+1][j+(1000-req)], mp(dp[i][j].fi, dp[i][j].se+p[i]));
                        // 買わない
                        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
                    }
                }
            }
        }
        P ans = mp(0, 0);
        REP(i, 50000){
            ans = max(ans, dp[n][i]);
        }
        cout << ans.fi << " " << ans.se << "\n";

        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 82052
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, M, K;
    cin >> N >> M >> K;
    vector<long long> A(N + 1, 0), B(M + 1, 0);
    for(int i = 0; i < N; i++) {
        cin >> A[i + 1];
        if(i > 0) A[i + 1] += A[i];
    }
    for(int i = 0; i < M; i++) {
        cin >> B[i + 1];
        if(i > 0) B[i + 1] += B[i];
    }
    int t = 0;
    for(int i = 0; i < N + 1; i++){
        long long temp = 0;
        int ans = 0;
        if(A[i] <= K) {
            ans = i;
            temp = A[i];
        }
        int c = upper_bound(B.begin(), B.end(), K - temp) - B.begin() - 1;
        ans += c;
        t = max(ans, t);
    }
    cout << t << endl;
}

Measured memory_bytes: 6340
#include <iostream>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int a, b;
  cin >> a >> b;

  string s, t;
  for(int i = 0; i < b; i++){
    s += to_string(a);
  }
  for(int i = 0; i < a; i++){
    t += to_string(b);
  }
  if(s < t){
    cout << s << endl;
  } else {
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 3680
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


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

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

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

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;

	cin >> n;
	int dumn = n;
	int dig = cnt_digit(n);
	int s = 0;
	rrep(i, dig-1, 0) {
		s += dumn % 10;
		dumn /= 10;
	}
	if (n % s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(ll i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

int solve(int a, int b, int ba){
    if (ba == 0) {
        return min(a, b);
    }
    else if(a+b > 0){
        return ba + min(a,b);
    }
    else {
        return ba - 1;
    }
}

int main() {
    int N;
    cin >> N;
    int a = 0;
    int b = 0;
    int ba = 0;
    int ab = 0;
    rep(i,N){
        string str;
        cin >> str;
        rep(j,str.size()-1){
            if(str[j] == 'A' && str[j+1] == 'B'){
                ++ab;
            }
        }
        if(str[0] == 'B' && str[str.size()-1] == 'A')++ba;
        else if(str[0] == 'B')++b;
        else if(str[str.size()-1] == 'A') ++a;
    }
    cout << ab + solve(a,b,ba)<< endl;

   return 0;  
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair



int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	cout << s.substr(0, (int)s.length() - 8) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

class ABC(object):

    def __init__(self):
        pass


    def main(self):
        n = int(input())

        n_c = n - 1

        ans = 0
        for i_a in range(1, n_c+1):
            max_b = n_c // i_a
            ans += max_b

        print(ans)
        return


if __name__ == "__main__":
    obj = ABC()
    obj.main()
    sys.exit(0)

Measured memory_bytes: 62896
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>

int main() {
  int       N;
  long long count = 0;
  std::cin >> N;
  std::vector<int> A(N), B(N);

  // 入力
  for (auto& a_i : A) {
    std::cin >> a_i;
  }
  for (auto& b_i : B) {
    std::cin >> b_i;
  }

  std::set<std::pair<int, int>, std::greater<std::pair<int, int>>>
      uncomp_B_index;
  for (int i = 0; i < N; i++) {
    if (A.at(i) != B.at(i)) {
      uncomp_B_index.emplace(B.at(i), i);
    }
  }

  while (!uncomp_B_index.empty()) {
    auto       it = uncomp_B_index.begin();
    const auto i  = it->second;
    int &      a = A.at(i), &b = B.at(i);

    uncomp_B_index.erase(it);

    const int d = B.at((N + i - 1) % N) + B.at((i + 1) % N); // 変化量

    const int howMany = (b - a) / d;
    b -= d * howMany;
    count += howMany;

    if (howMany <= 0) {
      std::cout << "-1";
      return 0;
    }

    if (a != b) {
      uncomp_B_index.emplace(b, i);
    }
  }

  std::cout << count;

  return 0;
}


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

typedef pair<int, int> P;

int main() {
  int N, M;
  while ( cin >> N >> M, N ) {

    vector<P> dat(N);
    for ( int i = 0; i < N; i++ ) {
      int d, p;
      cin >> d >> p;
      dat[i] = P(p, d);    
    }

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

    int ans = 0;
    for ( P i: dat ) {
      int p = i.first, d = i.second;
      if ( M < d ) ans += p*(d-M);
      M -= min(M, d);    
    }

    cout << ans << endl;
  }  
  return 0;
}




Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll N;
    cin>>N;
    vector<char>ans;
    while(N>0){
        N--;
        ll K=N%26;
        char S='a'+(K);
        ans.push_back(S);
        N=N/26;
    }
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()){
        cout<<ans[i];
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String a = sc.next(), b = sc.next();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length(); i++) {
			sb.append(a.charAt(i));
			if (b.length() > i) {
				sb.append(b.charAt(i));
			}
		}
		System.out.println(sb);
	}
}

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

int main() {
  
  int r, c; cin >> r >> c; int table[r + 1][c + 1];
  
  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c + 1; j++) {
      table[i][j] = 0;
    }
  }
  
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> table[i][j];
    }
  }
  
  for (int i = 0; i < r; i++) {
    
    int sum = 0;
    
    for (int j = 0; j < c; j++) {
      sum += table[i][j];
    }
    
    table[i][c] = sum;
    
  }
  
  for (int i = 0; i < c; i++) {
    
    int sum = 0;
    
    for (int j = 0; j < r; j++) {
      sum += table[j][i];
    }
    
    table[r][i] = sum;
    
  }
  
  int tmp = 0;
  
  for (int i = 0; i < r; i++) tmp += table[i][c];
  
  table[r][c] = tmp;
  
  for (int i = 0; i < r + 1; i++) {
    for (int j = 0; j < c; j++) {
      cout << table[i][j] << " ";
    }
    cout << table[i][c] << endl;
  }
  
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	
    vector<char> s(N);
	for (int i = 0; i < N; i++) {
		char s;
		cin >> s;
		if (s == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 3592
from sys import stdin
def make_divisors(n):
    mod0 = set()
    mod1 = set()
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            mod0.add(i)
            mod0.add(n/i)
        if (n-1)%i==0:
            mod1.add(i)
            mod1.add((n-1)/i)

    return mod0,mod1

N=list(map(int,(stdin.readline().strip().split())))
num=N[0]
K=0
mod0,mod1=(make_divisors(num))
mod0.remove(1)
mod1.remove(1)
for i in mod0:
    num = N[0]
    while(num % i == 0):
        num//=i

    if num%i==1:
        K+=1
K+=len(mod1)
print(K)


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

using namespace std;

int n, m, k;

int dfs(int num, int sum)
{
  if(num == n) return max(sum-k, 1);
  int ret = 0;
  for(int i = 1; i <= m; i++){
    ret += dfs(num + 1, sum + i);
  }
  return ret;
}

int main()
{
  while(cin >> n >> m >> k, n || m || k){
    printf("%.10f\n", dfs(0, 0)/pow(m, n));
  }
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	string s, t;	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i += 1) {
		if (s[i] != t[i])
			ans++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3804
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
a = [abs(x) for x in a]
a.sort()
if cnt%2:
    a[0] = -a[0]
print(sum(a))

Measured memory_bytes: 16384
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    int L[1000];
    int i,j,s=0,p,t;
    for(i=0;i<N;i++){
        scanf("%d",&L[i]);
    }
    int max=L[0];
    for(i=0;i<N;i++){
        if(L[i]>max){
            max=L[i];

        }

    }
    for(i=0;i<N;i++){
        s=s+L[i];
    }


    p=s-max;


        if(p>max){
            printf("Yes\n");
        }
        else if(p=max){
            printf("No");
        }
        else{
            printf("No");
        }

    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N ; 
long long h[100010];
long long dp[100010];
int main(){
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];
for (int i = 0; i < N; ++i) dp[i] = INF;
dp[0] = 0;
for (int i = 0; i < N; ++i){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1){
        chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
}
cout << dp[N - 1] << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 111;
const int mod = 1e9 + 7;
int f[N][N];
int h[N], d[N], n, tot;
int ksm(int base, int x){
	int ans = 1;
	while(x){
		if(x & 1)ans = 1LL * ans * base % mod;
		x >>= 1;
		base = 1LL * base * base % mod;
	}
	return ans;
}
int main(){
	cin>>n;
	for(int i = 1;i <= n; i++){
		scanf("%d", &h[i]);
		d[++tot] = h[i];
	}
	sort(d + 1, d + 1 + tot);
	tot = unique(d + 1, d + 1 + tot) - (d + 1);
	f[1][0] = (ksm(2, h[1]) - 2 * ksm(2, h[1] - d[1]) % mod + mod) % mod;
	for(int i = 1;i <= tot && d[i] <= h[1]; i++){
		if(d[i] < h[1])f[1][i] = 2ll * (ksm(2, h[1] - d[i]) - ksm(2, h[1] - d[i+1]) + mod) % mod;
		else f[1][i] = 2;
	}
	for(int i = 1;i < n; i++){
//		printf("i=%d\n", i);
		int x = lower_bound(d + 1, d + 1 + tot, h[i+1]) - d;
		for(int j = 0;d[j] <= h[i] && j <= tot; j++){
			if(h[i] >= h[i+1]){
				if(d[j] < h[i+1])f[i+1][j] = f[i][j];
				else{
					f[i+1][x] = (f[i+1][x] + 2 * f[i][j] % mod) % mod;
				}
			}
			else{
				if(d[j] < h[i]){
					f[i+1][j] = (f[i+1][j] + 1LL * f[i][j] * ksm(2, h[i+1] - h[i]) % mod) % mod;
				}
				if(d[j] == h[i]){
					for(int k = j;k < x; k++){
						f[i+1][k] = (f[i+1][k] + 2LL * f[i][j] * (ksm(2, h[i+1] - d[k]) - ksm(2, h[i+1] - d[k+1]) + mod) % mod);
					}
					f[i+1][x] = 2 * f[i][j] % mod;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0;i <= tot; i++){
		ans = (ans + f[n][i]) % mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
a = STDIN.readline.chomp.to_i
b = STDIN.readline.chomp.to_i
c = STDIN.readline.chomp.to_i
x = STDIN.readline.chomp.to_i

def f50(c50, total)
  (c50 * 50 >= total) ? 1 : 0
end

def f100(c100, c50, total)
  count = 0
  if (c100 > 0 && total >= 100)
    count = f100(c100 - 1, c50, total - 100)
  end
  count + f50(c50, total)
end

def f500(c500, c100, c50, total)
  count = 0
  if (c500 > 0 && total >= 500)
    count = f500(c500 - 1, c100, c50, total - 500)
  end
  count + f100(c100, c50, total)
end

puts f500(a, b, c, x)


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

int main() {
    int H,W;

    while ( 1 ) {

        cin >> H >> W;
        if ( H==0 && W==0 ) break;

        for (int i=0;i<H;i++) {
            for (int j=0;j<W;j++) {
                if ( (i%2==0 && j%2==0) || (i%2==1 && j%2==1) ) {
                    cout << "#";
                }else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
n, m = [int(i) for i in input().split()]
s = []
c = []
for i in range(m):
    tmp = [int(j) for j in input().split()]
    s.append(tmp[0])
    c.append(tmp[1])

for i in range(10 ** (n - 1) - int(n == 1) ,10 ** n):
#for i in range(10 ** (n - 1),10 ** n):

    status = True
    for j in range(m):
        if(str(i)[s[j] - 1] != str(c[j])):
            status = False
    if(status):
        print(i)
        exit()
print(-1)


Measured memory_bytes: 3064
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1,d2): return [[INIT_VAL]*d2 for _ in range(d1)]
def DD3(d1,d2,d3): return [DD2(d2,d3) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    s = Counter(IS())
    print(s['1'])

if __name__ == '__main__':
    main()

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[401][401];
LL sum[401][401];
LL powd[401][401];
LL powm(LL a, LL b){
  if(b == 0) return 1;
  return (powm(a*a%MOD, b/2) * (b%2==1?a:1LL) % MOD);
}

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

  LL N, C; cin >> N >> C;
  vector<LL> as(N), bs(N);
  REP(i,N) cin >> as[i];
  REP(i,N) cin >> bs[i];

  REP(i,401) REP(j,401) powd[i][j] = powm(i,j);

  REP(i,N){
	REP(j,C+1){
	  for(LL x=as[i];x<=bs[i];++x){
		(sum[i][j] += powd[x][j]) %= MOD;
	  }
	}
  }

  dp[0][0] = 1;
  for(int i=0;i<N;++i){
	for(int j=0;j<=C;++j){
	  for(int k=0;k<=j;++k)
		(dp[i+1][j] += sum[i][k] * dp[i][j-k]) %= MOD;
	}
  }

  cout << dp[N][C] << endl;
  
  return 0;
}


Measured memory_bytes: 4096
from collections import Counter
n, k = map(int, input().split())
a = list(input().split())
len_a = len(set(a))
if len_a <= k:
    print(0)
else:
    counter = Counter(a)
    count = 0
    s = len_a - k
    sort_counter = sorted(counter.items(), key=lambda  x:x[1])
    for x in range(s):
        count += sort_counter[x][1]
    print(count)

Measured memory_bytes: 53272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,hikaku1,hikaku2,hikaku3,count;
  count=0;
  cin>>n;
  
  vector<int> P(n);
  for(int i=0;i<n;i++){
    cin>>P.at(i);
  }

   for(int j=0;j<n-2;j++){
    hikaku1=P.at(j);
    hikaku2=P.at(j+1);
    hikaku3=P.at(j+2);
    if(hikaku1<=hikaku2&&hikaku2<=hikaku3||hikaku3<=hikaku2&&hikaku2<=hikaku1){
      count+=1;
    }
   }
  cout<<count<<endl;
 }

Measured memory_bytes: 256
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

def judge(n, sc):
    ns = str(n)
    for s, c in sc:
        if ns[s-1] != str(c):
            return False
    return True

ret = -1
for i in range(1000):
    if len(str(i)) != N:
        continue
    if judge(i, sc):
        ret = i
        break

print(ret)


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;

int main(){
    int R[MAX], n;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> R[i];
    }
    
    int maxv = -10000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3864
#include <iostream>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a>0)cout<<"Positive"<<endl;
    if(a<=0&&b>=0)cout<<"Zero"<<endl;
    if(b<0&&(b-a)%2==0)cout<<"Negative"<<endl;
    if(b<0&&(b-a)%2==1)cout<<"Positive"<<endl;
}

Measured memory_bytes: 256
from sys import exit
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - i - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      print('%d %d %d' % (i, j, k))
      exit()
print('-1 -1 -1')


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

int main(){
  int N,tmpL,Lmax,Lsum=0;
  vector<int> L;
  scanf("%d\n", &N);
  for(int i=0;i<N;i++){
	scanf("%d", &tmpL);
    L.push_back(tmpL);
    Lsum+=tmpL;
  }
  Lmax=*(max_element(L.begin(),L.end()));
  Lsum-=Lmax;
  if(Lmax<Lsum)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    string str;
    in >> str;
    auto i = str.find("AC");
    if(i != string::npos) {
      out << "Yes\n";
    } else {
      out << "No\n";
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




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

int main() {
    long a[3], k;
    cin>>a[0]>>a[1]>>a[2]>>k;

    long ans = 0;
    for(int i=0; i<3; i++){
        if(i == 0) ans += min(k, a[i]);
        if(i == 2) ans -= min(k, a[i]);
        k -= a[i];
        if(k < 0) break;
    }

    cout << ans << endl;
}

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

using namespace __gnu_pbds;
using namespace std;
#define INF 10000000000000LL
#define DIM 100007
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> myset;
typedef  pair< long long, pair<long long, long long> > ppll;
ll n,m,c,x,x2,y2,e,h,k,res1,a1,a2,w,a3,y,z,a4,a5,a6,last,LL,timer,start,finish,maxmask,newmax,reslast,tests,police,brothers;
string s,s1;
ll al,ar;
ll mas[100007],mas1[100007],mas2[1000007];
int main(){

    cin>>n;
    cin>>mas[1]>>mas1[1]>>mas2[1];
    for(int i=2;i<=n;i++){
        cin>>a1>>a2>>a3;
        mas[i]=max(mas1[i-1],mas2[i-1])+a1;
        mas1[i]=max(mas[i-1],mas2[i-1])+a2;
        mas2[i]=max(mas1[i-1],mas[i-1])+a3;
    }

    cout<<max({mas[n],mas1[n],mas2[n]})<<endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    string arr[100]={};
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        cout<<arr[i];
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
ll N, K;
ll candle[101000];
ll cost[101000];
ll sum[101000];
ll ans = 200000000000000;

int main(){
    cin >> N >> K;
    rep(i, 0, N){
        cin >> candle[i];
        cost[i] = 200000000000000;
    }

    rep(i, 0, (N-K+1)){
            cost[i] = abs(candle[i]);
            cost[i] += abs(candle[i] - candle[i+K-1]);
    }
    for(int i=N-1;i>=N-(N-K+1);--i){
        ll tmp = abs(candle[i]);
        ll haji = i-K+1;
        tmp += abs(candle[i] - candle[haji]);
        cost[i] = min(tmp, cost[i]);
    }
    rep(i, 0, N){
        ans = min(ans, cost[i]);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[2][40];
ll dp[40][2];
ll k;
ll solve(ll i,ll p2,ll lt){
    if(i==-1)
        return 0;
    if(dp[i][lt]!=-1)
        return dp[i][lt];
    dp[i][lt]=0;
    if(lt){
        dp[i][lt]=p2*max(c[0][i],c[1][i])+solve(i-1,p2>>1,lt);
    }
    else{
        if(k&p2){
            dp[i][lt]=p2*c[0][i]+solve(i-1,p2>>1,lt);
            dp[i][lt]=max(dp[i][lt],p2*c[1][i]+solve(i-1,p2>>1,1));
        }
        else
            dp[i][lt]=p2*c[1][i]+solve(i-1,p2>>1,lt);
    }
    return dp[i][lt];
}
int main(){
    int n;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        ll v=1;
        for(int i=0;i<40;i++){
            if(x&v)
                c[1][i]++;
            else
                c[0][i]++;
            v*=2;
        }
    }
    for(int i=0;i<40;i++)
        for(int j=0;j<2;j++)
            dp[i][j]=-1;
    cout<<solve(39,1ll<<39,0)<<endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    h, w, k = input_int_list()
    num = 0
    grid = []
    for _ in range(h):
        grid.append(list(input()))

    # 分割統治法
    def solver(x_b, y_b, x_e, y_e):  # x_end,y_endは包含/排他範囲
        # いちごの数を数える
        cnt = 0
        first = None
        second = None
        for i in range(x_b, x_e):
            for j in range(y_b, y_e):
                if grid[i][j] == "#":
                    cnt += 1
                    if not first:
                        first = [i, j]
                    elif not second:
                        second = [i, j]
        if cnt == 1:
            nonlocal num
            num += 1
            for i in range(x_b, x_e):
                for j in range(y_b, y_e):
                    grid[i][j] = num
            return
        # いちごが少なくとも1つ含まれるように分割する
        if cnt > 1:
            if first[0] != second[0]:
                x_edge = max(first[0], second[0])
                solver(x_b, y_b, x_edge, y_e)
                solver(x_edge, y_b, x_e, y_e)
            elif first[1] != second[1]:
                y_edge = max(first[1], second[1])
                solver(x_b, y_b, x_e, y_edge)
                solver(x_b, y_edge, x_e, y_e)

    solver(0, 0, h, w)
    for line in grid:
        print(*line)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 99556
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

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

Measured memory_bytes: 256
import itertools
N = int(input())
S = [input() for _ in range(N)]
s = [e[0] for e in S]
d = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for e in s:
    if e in d.keys():
        d[e] += 1
res = 0
for e1, e2, e3 in itertools.combinations(d.keys(), 3):
    res += d[e1]*d[e2]*d[e3]
print(res)


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

// APG4b-N
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d.at(i);

  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());

  int largest = d.at(0);
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (d.at(i) < largest) {
      ans++;
      largest = d.at(i);
    }
  }

  cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  bool f = true;
  rep(i, S.size()) {
    if ((i + 1) % 2 == 1 && (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')) {
      cout << "No" << endl;
      return 0;
    }
    if ((i + 1) % 2 == 0 && (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3588
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(Math.Ceiling((double)(n[0] + n[1]) / 2));
    }
}


Measured memory_bytes: 13268
f[168],z[]={23,24,25,12,36,11,13,35,37,22,26,48,0},x,s,m,i=23,c=100;main(y){for(;s?++f[y*12+x+z[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++i<142?i%12<10?m=fmax(m,f[i]),f[i]?c--:1:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
S=gets.chomp
values=S.split(//)
a,b,c,d=0,0,0,0
for str2 in values[2..-2]
    b+=1
    if str2=="C"
        a+=1
        values.delete_at(b+1)
        break
    end
end
if values[0]=="A"
    values.delete_at(0)
    c+=1
end

for str3 in values
    if str3<="Z"
        d+=1
        break
    end
end

if a==1 and c==1 and d==0
    puts "AC"
else
    puts "WA"
end


Measured memory_bytes: 1788
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

s = 0
for i in range(n)[::-1]:
	if a[i + 1] - b[i] > 0:
		s += b[i]
		continue
	s += a[i + 1]
	rb = b[i] - a[i + 1]
	if a[i] - rb > 0:
		s += rb
		a[i] -= rb
		continue
	s += a[i]
	a[i] = 0
print(s)

Measured memory_bytes: 19648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void readLong(ll &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
/*================Header Template==============*/
const ll mod=1e9+7;
const int maxn=4005;
ll fac[maxn][maxn],a,b,ans=0;
inline void init() {
	memset(fac,0,sizeof(fac));
	fac[0][0]=1;
	for(int i=1;i<=4000;i++) {
		fac[i][0]=1;
		for(int j=1;j<=i;j++)
			fac[i][j]=(fac[i-1][j-1]+fac[i-1][j])%mod;
	}
}
inline bool check(int x,int y){return (b-x)+(b-x-y)<=a;}
inline int getindex(int x,int y){return a-(b-x)-(b-x-y)+2;}
inline void solve() {
	for(int cnta=1;cnta<b;cnta++)
		for(int cntb=1;cntb<=b-cnta;cntb++)
			if(check(cnta,cntb)) {
				ll tmp=fac[b-1][cnta-1]*fac[b-cnta-1][cntb-1]%mod;
				tmp=tmp*fac[getindex(cnta,cntb)][2]%mod;
				ans=(ans+tmp)%mod;
			}
	ans=(ans+a+1)%mod;
}
int main() {
	init();
	readLong(a);
	readLong(b); 
	solve();
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 125568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
    long int k;
    string s;

    cin>>k>>s;

    if(s.size() > k)
      cout<<s.substr(0,k)<<"...";
    else
      cout<<s;
   return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=1e6+10;

ll a[MAXN];

ll sz=1 , t=1;

ll solve(ll n)
{
    if (n==1)
    {
        return 0;
    }

    if (n%2==0)
    {
        ll x=solve(n/2);

        for(ll i=sz+1;i>=x+3;i--)
        {
            a[i]=a[i-2];
        }

        for(ll i=x+1;i>=2;i--)
        {
            a[i]=a[i-1];
        }

        a[1]=t;
        a[x+2]=t;

        t++;
        sz+=2;

        return x+1;
    }
    else
    {
        ll x=solve(n/2);

        for(ll i=sz+3;i>=x+5;i--)
        {
            a[i]=a[i-4];
        }

        for(ll i=x+1;i>=2;i--)
        {
            a[i]=a[i-1];
        }

        a[1]=t;
        a[x+4]=t;
        a[x+2]=t+1;
        a[x+3]=t+1;

        t+=2;
        sz+=4;

        return x+2;
    }
}

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

	solve(n);

	a[sz++]=t;
	a[sz++]=t;

    cout<<sz-1<<endl;

    for(ll i=1;i<sz;i++)
    {
        cout<<a[i]<<" ";
    }
}


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

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(4*i+7*j==n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int price;
  price = 700;
  string s;
  cin >> s;
  
  for(int i=0;i<3;i++){
  	if(s.at(i) == 'o') price += 100;
  }
  
  cout << price << endl;
}

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

int main() {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int y=y2-y1;
    int x=x2-x1;
    int x3 = x2-y;
    int y3 = y2+x;
    int x4 = x1-y;
    int y4 = y1+x;
    cout << x3 <<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

	int n = sc.nextInt();

	long factorial = n;
	for(int i=1; i<n; i++){
	    factorial = factorial*(n-i);
	}

	System.out.println(factorial);
    }
}

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

int main()
{
	string s;
	cin>>s;
	bool p=true;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]==s[i-1])
		{
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
//


int main(int argc, char **argv) {
    int n = get_uint();
    int G[100][100] = {};
    for(int i = 0; i < n; ++i) {
        int u = get_uint() - 1;
        int k = get_uint();
        for(int j = 0; j < k; ++j) G[u][get_uint() - 1] = 1;
    }
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j) {
            put_uint(G[i][j]);
            putchar_unlocked(j == n - 1 ? '\n' : ' ');
        }
    return 0;
}



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

order = []

for _ in range(5):
    menu = int(input())
    if menu%10 != 0:
        lossTime = 10 - menu % 10
    else:
        lossTime = 0
    order.append((lossTime, menu))
    
order.sort()

time = 0

for i in order:
    time += i[0] + i[1]
    
print(time - order[-1][0])


Measured memory_bytes: 2940
#include<stdio.h>
 
int main(void)
{
  int hit,n;
  scanf("%d %d",&hit, &n);
  
  int a[n];
  
  for (int i=0; i<n; i++){
    scanf("%d",&a[i]);
  	hit-=a[i];
  }
  
  if(hit<=0) printf("Yes");
  
  else printf("No");
  
  return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    ArrayList<Character> ss, ts;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        char[] tempSs = sc.next().toCharArray();
        char[] tempTs = sc.next().toCharArray();
        ss = new ArrayList<>();
        ts = new ArrayList<>();
        for (int i = 0; i < tempSs.length; i++) {
            ss.add(tempSs[i]);
        }
        for (int i = 0; i < tempTs.length; i++) {
            ts.add(tempTs[i]);
        }
        solve();
    }

    void solve() {
        Collections.sort(ss);
        Collections.sort(ts, Collections.reverseOrder());
        Iterator<Character> ssIt = ss.iterator();
        Iterator<Character> tsIt = ts.iterator();
        while (ssIt.hasNext() && tsIt.hasNext()) {
            char s = ssIt.next();
            char t = tsIt.next();
            if (s < t) {
                System.out.println("Yes");
                return;
            } else if (s > t) {
                System.out.println("No");
                return;
            }
        }
        if (tsIt.hasNext()) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main(){
  	int A1,A2,A3;
  	cin>>A1>>A2>>A3;
  	if(A1+A2+A3>=22){
    	cout<<"bust";
    }
  	else{
   		cout<<"win";
    }
  
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B=0,C=0;
  cin >> A;
  vector<int>S(A);
  for(int i=0;i<A;i++)cin >> S[i];
  sort(S.begin(),S.end());
  for(int i=0;i<A-1;i++)B+=S[i];
  if(S[A-1]<B)cout<<"Yes" << endl;
  else cout << "No" << endl;
}


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

bool sortf(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) {
    return a.first.first == b.first.first ? a.first.second > b.first.second : a.first.first < b.first.first;
}

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

    pair<pair<string, int>, int> sp[n];

    for (int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;

        sp[i] = {{s, p}, i + 1};
    }

    sort(sp, sp + n, sortf);

    for (int i = 0; i < n; i++) {
        cout << sp[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256