akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

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

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.nextLine();
		int x = sc.nextInt();
		int y = sc.nextInt();
		boolean start = true;
		boolean is_x = true;
		List<Integer> xs = new ArrayList<>();
		List<Integer> ys = new ArrayList<>();
		int charge = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == 'F') {
				if (start) {
					x--;
				} else {
					charge++;
				}
			}
			if (c == 'T') {
				if (charge > 0) {
					if (is_x) {
						xs.add(charge);
					} else {
						ys.add(charge);
					}
				}
				start = false;
				is_x = !is_x;
				charge = 0;
			}
		}
		if (charge > 0) {
			if (is_x) {
				xs.add(charge);
			} else {
				ys.add(charge);
			}
		}
		Collections.sort(xs);
		Collections.sort(ys);
		int sum_x = 0;
		for (int tmp_x : xs) {
			sum_x += tmp_x;
		}
		int sum_y = 0;
		for (int tmp_y : ys) {
			sum_y += tmp_y;
		}
		int diff_x = sum_x - x;
		int diff_y = sum_y - y;
		if (search(xs, 0, diff_x) && search(ys, 0, diff_y)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	private boolean search(List<Integer> list, int start_index, int diff) {
		Set<Integer> sums = new HashSet<>();
		sums.add(0);
		for (int tmp : list) {
			Set<Integer> new_sums = new HashSet<>(sums);
			if (tmp > diff) {
				break;
			}
			for (int sum : sums) {
				int next = sum + tmp * 2;
				if (next < diff) {
					new_sums.add(next);
				}
				if (next == diff) {
					return true;
				}
			}
			sums = new_sums;
		}
		return diff == 0;
	}
}

Measured memory_bytes: 89440
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>v(2*N); rep(i, 0, 2*N) { cin >> v[i]; }
	sort(all(v));
	int a = 0;
	rep(i, 0, N) {
		a += v[i * 2];
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
  char str[100];
  int i = 0, count = 0, size = 0;
  scanf("%s", str);
  size = strlen(str);
  for(i = 0; i < (size / 2); i++){
    if(str[i] != str[size - 1 - i])
      count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn primes() -> Vec<usize> {
    const n: usize = 55555;
    let mut mask = vec![true; n + 1];
    mask[0] = false;
    mask[1] = false;
    let mut cur = 2;
    while cur <= n {
        for i in ((2 * cur)..(n + 1)).filter(|i| i % cur == 0) {
            mask[i] = false;
        }
        cur += 1;
        while cur <= n && !mask[cur] {
            cur += 1;
        }
    }
    mask.into_iter()
        .enumerate()
        .filter(|&(i, b)| b)
        .map(|(i, x)| i)
        .collect()
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n = parse!(it);
    let p = primes();
    println!(
        "{}",
        p.iter()
            .filter(|&x| x % 5 == 1)
            .take(n)
            .map(|x| x.to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
long long dp[51][51][2501];
int main(){
	int n,a,x[50];
	cin>>n>>a;
	int X=a;
	for(int i=0;i<n;i++)
		cin>>x[i];
	long long ans=0;
	for(int i=0;i<n;i++)
		X=max(X,x[i]);
	dp[0][0][0]=1;
	for(int j=1;j<=n;j++)
		for(int k=0;k<=n;k++)
			for(int s=0;s<=n*X;s++)
				if(s<x[j-1])
					dp[j][k][s]=dp[j-1][k][s];
				else if(k>=1)
					dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]];
	for(int k=1;k<=n;k++)
		ans+=dp[n][k][k*a];
	cout<<ans<<endl;
}


Measured memory_bytes: 50048
//n分木(0-indexed)の頂点xに対する親は[(x-1)/n] 子は x*n + 1, x*n + 2, ... , x*n + (n-1) 
//かな？
#include<bits/stdc++.h>
using namespace std;

int main(){

    int n, q; cin >> n >> q;

    

    for(int i = 0; i < q; i++){

        int v, w; cin >> v >> w;

        if(n == 1){
            cout << min(v, w) << endl;
        }else{

            v--; w--;

            while(1){
                
                if(v == w){
                    cout << v + 1 << endl;
                    break;
                }

                if(v > w){
                    v = (v - 1) / n;
                }else{
                    w = (w - 1) / n;
                }
                
            }

        }
    }

    return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<lint> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    double ans1 = 0;
    lint ans2 = 0;
    rep(i, a){
        ans1 += v[i];
    }
    ans1 /= (double)a;
    lint comb[55][55] = {{0}};
    rep(i, n+1){
        rep(j, i+1){
            if(j == 0){
                comb[i][j] = 1;
            }else{
                comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            }
        }
    }
    int k = 0, l = 0;
    while(k < n && v[k] > v[a-1]){
        k++;
    }
    while(l < n && v[l] >= v[a-1]){
        l++;
    }
    if(v[0] == v[a-1]){
        REP(i, a, b+1){
            ans2 += comb[l-k][i];
        }
    }else{
        ans2 = comb[l-k][a-k];
    }
    cout << fixed << setprecision(8) << ans1 << endl;
    cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int t, x;
    
    scanf("%d%d", &t, &x);
    
    printf("%lf", (double)t/x);
    
    return 0;
}



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

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

    int a,b,c;

    a = N / 100;
    b = (N-(a*100))/10;
    c = N-(a*100)-(b*10);

    if(a == 7 || b == 7 || c == 7){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(void){
    
    int N;
    int ch;
  	int ret, ret2;
    
    ret = scanf("%d", &N);
    
    int A[N], B[N];
    
    
    for (int j=0;j < N; j++){
        A[j]=0;
        B[j]=0;
    }
    
    for(int k=0; k < (N-1); k++){
        ret2 = scanf("%d", &A[k]);
        //printf("A[%d]=%d\n", k, A[k]);
    }
    
    for(int k=0; k < (N-1); k++){
        B[A[k]-1]++;
    }
    
    for(int i=0; i < N; i++){
        
        printf("%d\n", B[i]);
        
    }
    
}


Measured memory_bytes: 3288
# データ読み込み

import sys
from collections import deque

def input_data(d=""):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, *B  = map(int,input_data().split())

out = 0
for i in B:
  d = i
  while d % 2 == 0:
    d = d / 2
    out += 1

print(out)

Measured memory_bytes: 4468
N,*A=map(int,open(0).read().split());f=a=0
for i,j in zip(A,A[1:]):
 if f<0:
  if i<j:a+=1;f=0
 elif f<1:f=(i<j)-(i>j)
 else:
  if i>j:a+=1;f=0
print(a+1)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

ll saiki(vector<int>& V, int b, ll& A, ll X) {
	if (b < 0) {
		return X;
	}
	if (V[b] == 0) {
		return saiki(V, b - 1, A, X);
	}
	else if (V[b] == 2) {
		X += (1LL << b);
		if (X > A) {
			return -1;
		}
		return saiki(V, b - 1, A, X);
	}
	else {
		X += (1LL << b);
		ll jud;
		if (X > A) {
			jud = -1;
		}
		else {
			jud = saiki(V, b - 1, A, X);
		}
		if (jud < 0) {
			X -= (1LL << b);
			return saiki(V, b - 1, A, X);
		}
		else {
			return jud;
		}
	}
	
}

int main() {
	int N;
	cin >> N;
	ll A, B, C, D;
	cin >> A >> B;
	if (N == 2) {
		if (A >= B) {
			C = A - B;
			if (C % 2 == 1)cout << -1 << endl;
			else cout << C / 2 << endl;
			return 0;
		}
		cout << -1 << endl;
		return 0;
	}

	cin >> C;
	for (int i = 3;i < N;i++) {
		cin >> D;
		C ^= D;
	}
	//AからBに石を移してxorをDにしたい
	if ((A ^ B ^ C) & 1) {
		cout << -1 << endl;
		return 0;
	}
	D = A + B;

	bool br = 0;
	vector<int> bit(43);
	for (ll i = 42;i >= 0;i--) {
		B = 1LL << i;
		if (B & C) {
			if (B & D) {
				if (br) {
					//矛盾
					cout << -1 << endl;
					return 0;
				}
				else {
					//01のbr=0
					br = 0;
					bit[i] = 1;
				}
			}
			else {
				if (br) {
					//01のbr=1
					br = 1;
					bit[i] = 1;
				}
				else {
					//矛盾
					cout << -1 << endl;
					return 0;
				}
			}
		}
		else {
			if (B & D) {
				if (br) {
					//11のbr=1
					br = 1;
					bit[i] = 2;
				}
				else {
					//00のbr=1
					br = 1;
					bit[i] = 0;
				}
			}
			else {
				if (br) {
					//11のbr=0
					br = 0;
					bit[i] = 2;
				}
				else {
					//00のbr=0
					br = 0;
					bit[i] = 0;
				}
			}
		}
	}
	D = saiki(bit, 42, A, 0);
	if (D <= 0) {
		cout << -1 << endl;
		return 0;
	}
	else {
		cout << A - D << endl;
		return 0;
	}
}

Measured memory_bytes: 3604
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    x = int(input())
    div = x // 11
    mod = x % 11
    if mod == 0:
        add = 0
    elif mod < 7:
        add = 1
    else:
        add = 2
    print(div * 2 + add)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <climits>

int solve(std::string S)
{
    int ans_zero = 0, ans_one = 0, ans = 0;
    for(int i = 0; i < S.length(); i+=2)
    {
        if(S[i] != '0') ans_zero += 1;
        else ans_one += 1;
    }
    for(int i = 1; i < S.length(); i+=2)
    {
        if(S[i] != '1') ans_zero += 1;
        else ans_one += 1;
    }

    ans = std::min(ans_one, ans_zero);

    return ans;
}

int main()
{
    std::string S;
    std::cin >> S;
    
    int ans = solve(S);

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

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

ll A[100005];
ll B[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N + 1) {
        cin >> A[i];
        B[A[i] - 1]++;
    }

    Combination cmb(N + 5);
    pll p(-1, -1);
    REP(i, N + 1) {
        if (B[A[i] - 1] > 1) {
            if (p.first < 0)
                p.first = i;
            else
                p.second = i;
        }
    }

    REP(i, N + 1) {
        ll ret = cmb.get(N + 1, i + 1);
       // ll x = cmb.get(N + 1 - (p.second - p.first + 1), i);
        ret = (MOD + ret - cmb.get(N + 1 - (p.second - p.first + 1), i)) % MOD;
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t << endl;

}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int sum = 0;
  REP(i,N){
    sum += min(A.at(i),K - A.at(i));
  }

  cout << sum * 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            int[][] x = new int[N][];
            int[][] y = new int[N][];
            for (int n = 0; n < N; n++) {
                A[n] = in.nextInt();
                x[n] = new int[A[n]];
                y[n] = new int[A[n]];
                for (int a = 0; a < A[n]; a++) {
                    x[n][a] = in.nextInt() - 1;
                    y[n][a] = in.nextInt();
                }
            }

            int max = 0;
            maskLoop: for (int mask = 0; mask < (1 << N); mask++) {
                int mask2 = mask;
                for (int n = 0; n < N; n++) {
                    if ((mask & (1 << n)) == 0) {
                        continue;
                    }
                    for (int a = 0; a < A[n]; a++) {
                        if (y[n][a] == 0) {
                            mask2 &= -1 ^ (1 << x[n][a]);
                        }
                        if (y[n][a] == 1) {
                            if ((mask & (1 << x[n][a])) == 0) {
                                continue maskLoop;
                            }
                        }
                    }
                }

                if (mask2 == mask) {
                    max = Math.max(max, Integer.bitCount(mask));
                }
            }

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


Measured memory_bytes: 28432
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}

void solve() {
	int n;
	cin >> n;
	for (int x = 1; x <= 50000; x += 1) {
		if ((x * 108) / 100 == n) {
			cout << x;
			return;
		}
	}
	cout << ":(";
}     	

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

struct BruteForce {
    S: Vec<char>,
    si: usize,
    R: Vec<char>,
    B: Vec<char>,
    sols: HashMap<(Vec<char>, Vec<char>), usize>,
}

impl BruteForce {
    fn next(&mut self) {
        if self.si == self.S.len() {
            let pair = (self.R.clone(), self.B.clone());
            *self.sols.entry(pair).or_insert(0) += 1;
            return;
        }

        let c = self.S[self.si];
        self.si += 1;

        self.R.push(c);
        self.next();
        self.R.pop();

        self.B.push(c);
        self.next();
        self.B.pop();

        self.si -= 1;
    }

    pub fn run(S: Vec<char>) -> HashMap<(Vec<char>, Vec<char>), usize> {
        let mut solver = BruteForce {
            S: S,
            si: 0,
            R: Vec::new(),
            B: Vec::new(),
            sols: HashMap::new(),
        };
        solver.next();
        solver.sols
    }
}

pub fn main() {
    let N = read!(usize);
    let S = rl().chars().vec();

    let L = S.iter().take(N).cloned().vec();
    let R = S.iter().rev().take(N).cloned().vec();

    let ls = BruteForce::run(L);
    let rs = BruteForce::run(R);

    let mut total = 0;
    for ((r, b), lm) in ls {
        if let Some(&rm) = rs.get(&(r, b)) {
            total += lm * rm;
        }
    }

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


Measured memory_bytes: 127224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x;
	long long ans;
	ans = 0;
	scanf("%d", &n);

	f(i, n+1){
		x = i;
		if (x % 2 == 1){
			k = 0;
			for (int j = 1; j <= x; j++){
				if (x%j == 0)k++;
			}
			if (k == 8)ans++;
		}
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 128
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def divisors(n):
    lower = []
    upper = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)

    lower.extend(reversed(upper))
    return lower


def main():
    N, *A = map(int, read().split())

    B = [False] * (N + 1)
    C = [0] * (N + 1)

    for i, a in reversed(list(enumerate(A, 1))):
        if a == C[i]:
            continue
        B[i] = True
        divs = divisors(i)
        for d in divs:
            C[d] ^= 1

    ans = [i for i in range(1, N + 1) if B[i]]
    print(len(ans))
    if len(ans) > 0:
        print(' '.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 109312
#include<stdio.h>
#include<string.h>

int  main()
{
  int n,m;
  char a[51][51]={},b[51][51]={};
  int i,j;
  int tmp=0;
  
  scanf("%d%d",&n,&m);
  
  for(i=0;i<n;i++)
  {
    scanf("%s",&a[i]);
  }
  
  for(i=0;i<m;i++)
  {
    scanf("%s",&b[i]);
  }
  
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      if(strstr(a[i],b[j])==NULL)
      {
        printf("No\n");
        return 0;
      }
        else
        {
          tmp=1;
        }
    }
  }

  
  if(tmp==1)
  {
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
def main():
    a, b = map(int, input().split())
    ans_w = [["."]*100 for _ in range(50)]
    ans_b = [["#"]*100 for _ in range(50)]
    cnt = 1
    for i in range(0, 50, 2):
        if cnt == a:
            break
        for j in range(0, 100, 2):
            ans_b[i][j] = "."
            cnt += 1
            if cnt == a:
                break
    cnt = 1
    for i in range(1, 50, 2):
        if cnt == b:
            break
        for j in range(0, 100, 2):
            ans_w[i][j] = "#"
            cnt += 1
            if cnt == b:
                break
    print("100 100")
    for i in range(50):
        for j in range(100):
            print(ans_b[i][j], end="")
        print("")
    for i in range(50):
        for j in range(100):
            print(ans_w[i][j], end="")
        print("")
if __name__ == "__main__":
    main()

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

int main()
{
    int n;
    cin>>n;
    vector<int>h;
    int d[n];
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        h.push_back(t);
    }
    d[0]=0;
    d[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++)
    {
        d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));
    }
    //int i=0;
    cout<<d[n-1];
}


Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int a[111111],k;
	
	rep(i,5)cin>>a[i];
	cin>>k;
	rep(i,5){
		rep(j,5){
			if(abs(a[i]-a[j])>k){
				cout<<":("<<endl;
					return 0;
			}
		}
	}
	cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define PI 3.14159265359
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    double R;
    cin >> R;

    cout << 2*R*PI << endl;

    return 0;
}


Measured memory_bytes: 3784
N = int(input())
H = list(map(int, input().split()))

for i in range(N - 1):
  if H[i] > H[i + 1] + 1:
    print("No")
    exit()
  elif H[i] == H[i + 1] + 1:
    H[i + 1] += 1
print("Yes")

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

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i,n) cin >> a[i];
  vector<int> t,d;

  REP(i,n) {
    d.push_back(a[i]);
    swap(t,d);
  }

  reverse(t.begin(),t.end());
  t.insert(t.end(), d.begin(), d.end());
  REP(i,n) {
    if (i>0) cout << " ";
    cout << t[i];
  }
  return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string S; cin >> S;
  const int n = S.size();
  
  if (S.substr(1) == string(n - 1, '9')) {
    int ans = 0;
    rep(i, n) {
      ans += S[i] - '0';
    }
    cout << ans << endl;
  } else {
    int ans = (S[0] - '0') - 1 + 9 * (n - 1);
    cout << ans << endl;
  }
}

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

using namespace std;
typedef long long int lli;

#define all(arr) arr.begin(),arr.end()
#define f first
#define s second
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define nl cout<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cout<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define space ' '
#define kick(t) cout << "Case #" << t << ":" << endl;

typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

template <typename T>
void input(vector<T> &arr,lli n) {
  T temp;
  for(lli i=0;i<n;i++) cin>>temp, arr.push_back(temp);
}

template <typename T>
void output(vector<T> arr) {
  for(auto x:arr) cout<<x<<" ";
  cout<<endl;
}


template <typename T>
void input_set(set<T> &arr,lli n) {
  T temp;
  for(lli i=0;i<n;i++) cin>>temp, arr.insert(temp);
}

lli mul(lli a, lli b) {
  return (a%MOD*b%MOD)%MOD;
}

lli power(lli a,lli b) {
  lli ans = 1;
  while(b > 0) {
    if(b&1)
      ans = mul(ans, a);
    a = mul(a,a);;
    b >>= 1;
  }
  return ans;
}

void solve() {
  vector<lli> a, b;
  input(a, 2);
  input(b, 2);
  vector<lli> temp;
  for(auto x:a)
    for(auto y:b)
      temp.pb(x*y);
  sort(all(temp));
  cout << temp[3] << endl;
}

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

  lli testcases=1;
  while(testcases--) {
    solve();
  }
}



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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int j=0;j<n;j++){
    cin >> a[j];
  }
  for(int loop=0;loop<k;loop++){
    int l[n];
    int r[n];
    for(int cnt=0;cnt<n;cnt++){
      l[cnt] = 0;
      r[cnt] = 0;
    }
    for(int j=0;j<n;j++){
      l[max(0,j-a[j])] += 1;
      r[min(j+a[j], n-1)] += 1;
    }
    int lighted = 0;
    bool flag = true;
    for(int j=0;j<n;j++){
      lighted += l[j];
      a[j] = lighted;
      lighted -= r[j];
      if(a[j]<n){
        flag = false;
      }
    }
    if(flag){
      break;
    }
  }
  for(int j=0;j<n-1;j++){
    cout << a[j] << ' ';
  }
  cout << a[n-1] << endl;
}

Measured memory_bytes: 5544
def solve():
    n, a, b = list(map(int, input().split()))
    ok_numbers = []
    for num in range(n + 1):
        total = sum([int(i) for i in str(num)])
        if a <= total <= b:
            ok_numbers.append(num)
    return sum(ok_numbers)


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3296
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: u32) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: u32, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

use std::cmp;

use std::collections::BTreeMap;
use std::collections::BinaryHeap;
fn main() {

  let n = read::<u32>();
  let m = read::<i64>();
  let a = read_n::<i64>(n);
  let mut bh_a: BinaryHeap<i64> = BinaryHeap::new();

  let mut sum = 0;

  for i in a {
    bh_a.push(-i);
  }

  let mut bmap: BTreeMap<i64, i64> = BTreeMap::new();

  for _ in 0..m {
    let b = read::<i64>();
    let c = read::<i64>();
    if bmap.contains_key(&c) {
      let mut temp = bmap.get_mut(&c).unwrap();
      *temp += b;
    } else {
      bmap.insert(c, b);
    }
  }

  let mut done = false;

  for (idx, val) in bmap.iter().rev() {

    for i in 0..*val {
      let bh_a_pop = match bh_a.pop() {
        Some(s) => s,
        None => {
          done = true;
          break;
        }
      };

      if -bh_a_pop >= *idx {
        bh_a.push(bh_a_pop);
        done = true;
        break;
      } else {
        bh_a.push(-idx);
      }
    }

    if done {
      break;
    }
  }

  let sum_bh_a: i64 = bh_a.iter().sum();
  println!("{}", -sum_bh_a);

}

fn get_maxinum(bmap: &mut BTreeMap<i64, i64>) -> i64 {
  let mut found_num = 0;
  for (idx, val) in bmap.iter().rev() {
    if *val > 0 {
      found_num = *idx;
      break;
    }
  }
  found_num
}

fn subscribe_bmap(bmap: &mut BTreeMap<i64, i64>, used_index: &i64) {
  if bmap.contains_key(used_index) {
    let mut temp = bmap.get_mut(used_index).unwrap();
    *temp -= 1;
  }
}


Measured memory_bytes: 12632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl

unsigned int MOD = 1e9+7;

int pow2(long long x, int n) { //x^n 計算量O(logn)
	long long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1)ans = ans * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return ans;
}

int comb(int a, int b){
	if (a - b < b) return comb(a, a - b);
	long long mul = 1;
	long long div = 1;
	for (int i = 0; i < b; i++){
		mul *= (a - i);
		div *= (i + 1);
		mul %= MOD;
		div %= MOD;
	}
	int ans = mul * pow2(div, MOD - 2) %MOD;
	return ans; 
}


int main(void){
    long long n,m,ans;
    ans = 1;
    cin >> n >> m;
    long long m2 = m;
    for(int i = 2;i*i<=m2;i++){
        int memo = 0;
        while(m%i == 0){
            m /= i;
            memo++;
        }
        ans *= comb(memo+n-1,memo);
        ans %= MOD;
    }
    if(m!=1)ans = n*ans%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> A(n);
    vector<int> F(n);
    rep(i,n) cin >> A[i];
    rep(i,n) cin >> F[i];
    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    ll l = -1,r = 1e12;
    while(l+1<r){
        ll mid = (l+r)/2;
        bool ok = [&](){
            ll s = 0;
            rep(i,n){
                s += max(0ll,A[i]-mid/F[i]);
            }
            return s <= k;
        }();
        if(ok) r = mid;else l = mid;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// author: Seong Yong-ju <sei40kr@gmail.com>

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let R: i64;
    let G: i64;
    let B: i64;
    let n: i64;

    input! {
        R: i64,
        G: i64,
        B: i64,
        n: i64,
    };

    let ans = (0..n / R + 1)
        .flat_map(|r| (0..n / G + 1).map(move |g| (r, g)))
        .filter(|&(r, g)| {
            let t = n - R * r - G * g;
            t % B == 0 && 0 <= t / B
        })
        .count();

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


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, x, t, ans;
    cin >> n >> x >> t;
    if (n % x)
        ans = (n / x + 1) * t;
    else
        ans = n / x * t;
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<set>
#define LL long long
LL N, x;
int SP[4];
bool used[200010];
int main() {
	std::cin >> N >> x;
	if (x == 1 || x == 2 * N - 1) {
		std::cout << "No" << std::endl;
		return 0;
	}
	std::cout << "Yes" << std::endl;
	if (N == 2) {
		for (int i = 1; i <= 3; i++) {
			std::cout << i << std::endl;
		}
		return 0;
	}
	int sum = 1;
	for (int i = 1; i < N - 1; i++) {
		if (x == 2 * N - 2) {
			if (sum == x - 2) {
				sum += 4;
			}
		}
		else {
			if (sum == x - 1) {
				sum += 4;
			}
		}
		std::cout << sum << std::endl;
		sum++;
	}
	if (x == 2 * N - 2) {
		std::cout << x - 2 << std::endl;
		std::cout << x << std::endl;
		std::cout << x + 1 << std::endl;
		std::cout << x - 1 << std::endl;
	}
	else {
		std::cout << x + 1 << std::endl;
		std::cout << x  << std::endl;
		std::cout << x - 1 << std::endl;
		std::cout << x + 2 << std::endl;
	}
	for (int i = N + 3; i <= 2*N - 1; i++) {
		if (x == 2 * N - 2) {
			if (sum == x - 2) {
				sum += 4;
			}
		}
		else {
			if (sum == x - 1) {
				sum += 4;
			}
		}
		std::cout << sum << std::endl;
		sum++;
	}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0;
  vector<int> vec(3);
  for(int i=0;i<3;i++)cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  cnt+=(vec.at(2)-vec.at(1));
  vec.at(0)+=cnt;
  vec.at(1)+=cnt;
  if((vec.at(2)-vec.at(0))%2==0)cnt+=(vec.at(2)-vec.at(0))/2;
  else cnt+= (vec.at(2)-vec.at(0))/2+2;
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag = false;
		for(int i = 1; i <= 9; i++) {
			int a = n/i;
			if(a*i == n && a < 10 && a > 0) {
				flag = true;
				break;
			}
		}
		System.out.println(flag ? "Yes" : "No");
		sc.close();
	}
}

Measured memory_bytes: 22996
fun main(args: Array<String>) {
    abc042b()
}

fun abc042b() {
    val (n, l) = readLine()!!.split(" ").map { it.toInt() }
    val sList = (1..n).map { readLine()!! }

    val answer = sList.sorted().joinToString("")

    println(answer)
}


Measured memory_bytes: 38064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,now=-1,ans=0;
  bool up=true,down=true;
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(now==-1){
      now=a;
    }else{
      if(now<a){
        if(!up){
          ans++;
          up=true;down=true;
        }else{
          up=true;down=false;
        }
      }else if(now>a){
        if(!down){
          ans++;
          up=true;down=true;
        }else{
          up=false;down=true;
        }
      }
      now=a;
    }
  }
  cout<<ans+1<<endl;
}


Measured memory_bytes: 256
num = int(raw_input())
line = raw_input()

item_str = line.strip().split(" ")
print " ".join(item_str)
A = map(int, item_str)

for i in range(1, num):
    v = A[i]
    j = i - 1
    for j in range(j, -1, -1):
        if A[j] > v:
            A[j+1] = A[j]
            j -= 1
        else:
            break
    A[j+1] = v
    str_A = map(str, A)
    print " ".join(str_A)

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

using namespace std;
int main(){
    int n,d[101],i,j;
    cin >> n;
    for(int i=0; i<n; i++)
       cin >> d[i];
    int sum = 0;
    for(i=0; i<n-1; i++){
       for(j=i+1; j<n; j++){
           sum += d[i]*d[j];
       }
    }
    cout << sum << endl;
}

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

using namespace std;

using node_t = std::vector<int>;  // 自分に接続しているedgeのindex達

bool allConnected(int startNodeIdx, int ignoredEdgeIdx,
                  std::unordered_set<int>& visitedNodeIdxes,
                  const std::vector<std::pair<int, int>>& edges,
                  const std::vector<node_t>& nodes) {
  if (visitedNodeIdxes.size() == nodes.size()) {
    return true;
  }

  const auto& startNode = nodes[startNodeIdx];
  for (auto const ei : startNode) {
    if (ei == ignoredEdgeIdx) {
      continue;
    }

    const auto& e = edges[ei];
    auto const anotherNi = e.first == startNodeIdx ? e.second : e.first;
    if (visitedNodeIdxes.count(anotherNi)) {
      continue;
    }
    visitedNodeIdxes.insert(anotherNi);
    if (allConnected(anotherNi, ignoredEdgeIdx, visitedNodeIdxes, edges,
                     nodes)) {
      return true;
    }
  }

  return false;
}

int calc(int const n, const std::vector<std::pair<int, int>>& edges) {
  int const m = edges.size();
  std::vector<node_t> nodes(n);
  for (auto& node : nodes) {
    node.reserve(50);
  }
  for (int ei = 0; ei < m; ei++) {
    const auto& e = edges[ei];
    nodes[e.first].push_back(ei);
    nodes[e.second].push_back(ei);
  }

  int ret = 0;
  for (int bridgeCandidateEdgeIdx = 0; bridgeCandidateEdgeIdx < m;
       bridgeCandidateEdgeIdx++) {
    bool foundUnconnected = false;
    for (int startNodeIdx = 0; startNodeIdx < n; startNodeIdx++) {
      std::unordered_set<int> visitedNodeIdxes;
      visitedNodeIdxes.insert(startNodeIdx);
      if (!allConnected(startNodeIdx, bridgeCandidateEdgeIdx, visitedNodeIdxes,
                        edges, nodes)) {
        foundUnconnected = true;
        break;
      }
    }
    if (foundUnconnected) {
      ret++;
    }
  }
  return ret;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::pair<int, int>> edges(m);
  for (auto& e : edges) {
    std::cin >> e.first >> e.second;
    e.first--;
    e.second--;
  }
  std::cout << calc(n, edges) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n);
    set<double>S;
    REP(i,0,n){
        cin>>a[i];
        // S.insert(1.0*a[i]);
    }

    // while(S.size()!=1){
    //     auto fir=*(S.begin());
    //     S.erase(S.begin());
    //     auto sec=*(S.begin());
    //     S.erase(S.begin());
    //     auto mean=(fir+sec)/2.0;
    //     S.insert(mean);
    // }
    // double ans=*(S.begin());
    sort(a.begin(),a.end());
    double ans=a[0];
    for(int i=1;i<a.size();i++){
        ans=(ans+a[i])/2.0;
    }
    printf("%0.9lf\n",ans);





    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{

	double n, a, b, c, x, y, z;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		if (a >= max(b, c)) {
			z = a; x = b; y = c;
		}
		else if (b >= max(a, c)) {
			z = b; x = a; y = c;
		}
		else if (c >= max(a, b)) {
			z = c; x = a; y = b;
		}

		if (z * z == x * x + y * y) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


Measured memory_bytes: 3136
#include <iostream>

using namespace std;

int main()
{   
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
    int i;
    string str;
    
    cin>>str;
    
     int n=str.size();
     
    for(i=0;i<n;i++)
    {
        if(str[i]=='R')
        {
            if(i%2!=0)
            {
                cout<<"No"<<endl;
                break;
            }
            
        }
        else if(str[i]=='L')
        {
            if(i%2==0)
            {
                cout<<"No"<<endl;
                break;
            }
        }
        
    }
    if(i==n)
    cout<<"Yes"<<endl;
    return 0;
}


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

#define V vector
typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f(i,a) for(int i = 0 ; i < a ; i++)
#define ff first
#define ss second
#define all(x) (x).begin() ,(x).end()

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1



int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
	{
		ll k;
		cin >> k;

		ll n = 0;
		bool ok = false;

		for (ll i = 1 ; i <= (ll)(1e7) ; i++)
		{
			n = (n * 10 + 7) % k;

			if (n == 0)
			{
				cout << i << "\n";
				ok = true;
				break;
			}
		}

		if (!ok)
			cout << "-1\n";
	}

	return 0;
}





Measured memory_bytes: 3624