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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    map<ll, ll> counts;
    for(auto a : A){
        if(counts.count(a)==0) counts[a]=0;
        counts[a]++;
    }
    ll v_base = 0;
    for(auto m : counts){
        v_base += m.second * (m.second - 1) / 2;
    }
    for(auto a : A){
        cout << (v_base - counts[a] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 12672
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string S;
	cin >> S;
	if(S=="Sunny")cout << "Cloudy";
	if(S=="Cloudy")cout << "Rainy";
	if(S=="Rainy")cout << "Sunny";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

int n;
int a[111111];
int b[111111];
int d[222222]; 

void add(int x){
	while(x<222222){
		d[x]++;
		x+=x&-x;
	}
}

int sum(int x){
	int ret=0;
	while(x>0){
		ret+=d[x];
		x-=x&-x;
	}
	return ret;
}

bool check(int x){
	memset(d,0,sizeof(d));
	ll ans=0;
	int cnt=100010;
	add(cnt);
	FOR(i,0,n){
		if(a[i]<=x)cnt++;
		else cnt--;
		ans+=sum(cnt-1);
		if(ans>=1ll*n*(n+1)/2/2+1)return 1;
		add(cnt);
	}
	return 0;
}

int I_Love_Hashimoto_Kanna() {
	fastio;
	n=read();
	FOR(i,0,n){
		a[i]=b[i]=read();
	}
	sort(b,b+n);
	int l=-1,r=n-1;
	while(l<r-1){
		int mid=l+r>>1;
		if(check(b[mid]))r=mid;
		else l=mid;
	}
	Tone(b[r]);
	return 0;
}


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

using namespace std;

int main()
{
    char nexto = 'R';
    char nexte = 'L';
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if((i + 1) % 2 != 0){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
                cout << "No";
                return 0;
            }
        }
        else{
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <set>
#include <cmath>

#define FOR(i,n) for(int i=0; i<n; i++)
#define FORI(i,z,n) for(int i=z; i<n; i++)

using namespace std;

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

    set<int> coins;
    vector<int> dyn(n);
    dyn[0] = 1;

    FOR(i, m) {
        int c;
        cin >> c;
        coins.insert(c);
    }

    FORI(i, 1, n) {
        int coinVal = i+1;
        if (coins.find(coinVal) != coins.end()) {
            // There is an exact coin for the value i
            dyn[i] = 1;
        } else {
            // We need to combine previous value e.g: (n-1, 1), (n-2, 2), ...
            int minVal = 0;
            FOR(j, ceil(i/2) + 1)
                if (minVal == 0 || dyn[j] + dyn[i-j-1] < minVal)
                    minVal = dyn[j] + dyn[i-j-1];
            dyn[i] = minVal;
        }
    }

    cout << dyn[n-1] << endl;
}



Measured memory_bytes: 3180
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int N;
	cin >> N;
	string ans = "Three";
	while(N-- > 0){
		string S;
		cin >> S;
		if(S == "Y"){
			ans = "Four";
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
red = list(map(int,input().split()))
green = list(map(int,input().split()))
colorless = list(map(int,input().split()))
red.sort(reverse=True)
green.sort(reverse=True)
apple = red[:x] +  green[:y] + colorless
apple.sort(reverse=True)
print(sum(apple[:x+y]))

Measured memory_bytes: 111852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        String s = stdin.readLine();

        Deque<Character> stack = new ArrayDeque<>();
        for (char ch : s.toCharArray()) {
            if (ch == 'S') {
                stack.addLast(ch);
            } else {
                if (stack.isEmpty() || stack.peekLast() == 'T') {
                    stack.addLast(ch);
                } else {
                    stack.pollLast();
                }

            }
        }
        System.out.println(stack.size());
    }
}

Measured memory_bytes: 24788
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 998244353;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(n, k);
	int l[k + 1], r[k + 1], dp[n + 1] = {}, pre[n + 1] = {};
	FOR (i, 1, k) cin >> l[i] >> r[i];
	
	dp[1] = pre[1] = 1;
	FOR (i, 2, n)
	{
	    FOR (j, 1, k) dp[i] = (dp[i] + pre[max(0LL, i - l[j])] - pre[max(0LL, i - r[j] - 1)]) % mod;
	    pre[i] = (pre[i - 1] + dp[i]) % mod;
	}
	
	cout << (dp[n] + 2*mod) % mod;
}



















Measured memory_bytes: 6776
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int num[maxn];

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    rep(i, 1, n) {
        int x;
        cin >> x;
        ++num[x];
        sum += x;
    }
    int q;
    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;
        sum = sum + num[x] * y - num[x] * x;
        num[y] += num[x];
        num[x] = 0;
        cout << sum << '\n';
    }
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 4324
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int x[100000];
	for(int i=0; i<n; i++){
		scanf("%d", &x[i]);
	}
	int l, q;
	scanf("%d", &l);
	scanf("%d", &q);
	int pow[16];
	pow[0]=1;
	for(int i=1; i<16; i++){
		pow[i]=pow[i-1]*2;
	}
	vector<int> s[100000];
	int p[100000][16];
	for(int i=0; i<n; i++){
		p[i][0]=upper_bound(x, x+n, x[i]+l)-x-1;
	}
	for(int t=1; t<16; t++){
		for(int i=0; i<n; i++){
			p[i][t]=p[p[i][t-1]][t-1];
		}
	}
	for(int i=0; i<q; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		if(a>b) swap(a, b);
		int ans=0;
		int t=15;
		while(1){
			if(a==b) break;
			if(t==0 && p[a][t]>=b){
				ans++;
				break;
			}else if(p[a][t]>=b){
				t--;
				continue;
			}
			ans+=pow[t];
			a=p[a][t];
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
const int sz=1e5+9;
int n,x,arr[sz],dp[sz];

int clac(int i){
    if(i==n) return 0;
    if(dp[i]!=-1)return dp[i];
    int left=abs(arr[i]-arr[i+1])+clac(i+1);
    int right=inf;
    if(i+2<=n){
        right=abs(arr[i]-arr[i+2])+clac(i+2);
    }
    return dp[i]=min(left,right);
}




void solve(){

    cin>>n;


    reset(dp,-1);
    //bug(n,dp[n]);
    lp(i,1,n+1)cin>>arr[i];
    cout<<clac(1)<<"\n";

}

int main(){
    //FasterIO;
   // #ifndef ONLINE_JUDGE
      //  freopen("1.txt","r",stdin);
   // #endif
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		ll a, b, n;
		cin >> a >> b >> n;
		
//		if(b >= a){
//			ll x = min(b-1, n);
//			cout << (a*x) / b;
//		}
//		else{
//			cout << min(n, b-1);
//		}
		ll x = min(n, b-1);
		cout << (a*x) / b;
	}
}


Measured memory_bytes: 3652
h,w=input().split()
h=int(h)
ch='#'
w=int(w)
lt=[]
for i in range(h):
    a = []
    a.append(input())
    lt.append(a)
for j in range(w+2):
    print(ch,end='')
print()
for i in range(h):
    for j in range(w):
        if j==0:
            print(ch,end='')
        print(lt[i][0][j],end='')
        if j==w-1:
            print(ch,end='')
    print()
for j in range(w+2):
    print(ch,end='')

Measured memory_bytes: 4468
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int[] arr = {a,b,c};
		for(int i = 0; i < 3; i++){
			for(int j = i+1; j < 3; j++){
				if(arr[i] > arr[j]){
					int temp = arr[i];
					arr[i] = arr[j];
					arr[j] = temp;
				}
			}
		}
		System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
	}

}

Measured memory_bytes: 26156
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) cout << c << endl;
	else if (a == c) cout << b << endl;
	else cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int t = scan.nextInt();
		while(t!=0){
			char[] a = scan.next().toCharArray();
			
			Arrays.sort(a);
			int m = Integer.parseInt(new String(a));
			char[] b = new char[8];
			for(int i=0;i<8;i++){
				b[i]=a[7-i];
			}
			System.out.println(Integer.parseInt(new String(b))-m);
			
			t--;
		}
	}
}

Measured memory_bytes: 26212
#include <stdio.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int N, M;
	cin >> N >> M;
	if (M==0) {
		printf("0 0\n");
		exit(0);
	}
	int p;
	string s;
	bool AC_bool[105000];
	int WA_num[105000];
	int WA_res = 0;
	int AC_res = 0;
	rep(i, N) WA_num[i] = 0, AC_bool[i] = false;

	rep(i, M) {

		cin >> p >> s;	
		
		if (AC_bool[p]) {
			continue;
		}else if (s == "AC" ){
			AC_res += 1;
			WA_res += WA_num[p];
			AC_bool[p] = true;
		}
		else if(s == "WA"){
			WA_num[p] += 1;
		}

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


}

Measured memory_bytes: 768
s = input()
n = len(s)
a = (n-1)/2
f = True
for i in range(int(a)):
    if s[i] != s[n-i-1]:
        print('No')
        f = False
        break
        
if f == True:
    for i in range(int(a/2)):
        if s[i] != s[int(a)-i-1]:
            print('No')
            f = False
            break
            
if f == True:
    print('Yes')

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

int main(){
  string b;
  cin >> b;
  
  if(b == "A"){
    cout << "T" << endl;
  }else if(b == "T"){
    cout << "A" << endl;
  }else if(b == "C"){
    cout << "G" << endl;
  }else{
    cout << "C" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define sort(v) sort(v.begin(), v.end())
#define sortg(v) sort(v.begin(), v.end(), greater<int> ())

using namespace std;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;

using namespace std;



void solve() {

    string s, t;
    cin>>s>>t;
    int ns=s.size(), nt=t.size(), miny=MOD;
    
    for(int i=0; i<ns-nt+1; i++){
        int curr=0, cnt=0;
        for(int j=i; j<i+nt; j++){
            if(s[j]!=t[curr]) cnt++;
            curr++;
            
        }
     
        miny=min(cnt, miny);
    }
    
    cout<<miny<<endl;
}

int main() {


	
	solve();

	return 0;
}

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

class Main
{
	static int gcd(int a, int b)
	{
		if (b == 0)
			return a;
		return gcd(b, a % b);

	}
	public static void main(String[] args) throws IOException
	{
		Scan in = new Scan();
		Print out = new Print();
		int n = in.scanInt();
		int sum = 0;
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=n; j++) {
				for(int k=1; k<=n; k++) {
					int gcd = gcd(i, gcd(j, k));
					sum += gcd;
				}
			}
		}
		out.println(sum);
		out.close();
	}
}

class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
			throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
				return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
			return true;
		return false;
	}
}

class Print
{
	private final BufferedWriter bw;
	public Print()
	{
		this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
	}
	public void print(Object object)throws IOException
	{
		bw.append(""+object);
	}
	public void println(Object object)throws IOException
	{
		print(object);
		bw.append("\n");
	}
	public void close()throws IOException
	{
		bw.close();
	}
}

Measured memory_bytes: 36624
n=input()
plan=[(0,0,0)]
for i in range(int(n)):
    plan.append(tuple(int(a) for a in input().split()))

f=True
for i in range(int(n)):
    m = plan[i+1][0] - plan[i][0] - abs(plan[i+1][1] - plan[i][1]) - abs(plan[i+1][2] - plan[i][2]) 
    if m < 0 or m%2!=0:
        print("No")
        f=False
        break


if f:
    print("Yes")


Measured memory_bytes: 17344
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long

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

    string s; cin >> s;
    int n = s.size();

    vector<int> t(n);
    for(int i = 0;i < n;i ++) t.at(i) = s.at(i) - '0';

    vector<int> rekkyo(n);

    int ans = 0;

    while(rekkyo.at(0) == 0){
        int power = 0;
        for(int i = n-1;i >= 0;i --){
            ans += t.at(i) * pow(10,power);
            power ++;
            if(rekkyo.at(i) == 1) power = 0;
        }

        rekkyo.at(n-1) ++;
        for(int i = n-1;i >= 1;i --){
            if(rekkyo.at(i) == 2){
                rekkyo.at(i) = 0;
                rekkyo.at(i-1) ++;
            }
        }
    }

    cout << ans << endl;

}


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

using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void solve() {
    int x;
    cin >> x;
    cout << 1 - x;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    // int t;
    // cin >> t;
    // while (t--)
        solve();
       
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x,y;
	cin>>x>>y;
	int g[13];
	g[1]=0;
	g[2]=2;
	g[3]=0;
	g[4]=1;
	g[5]=0;
	g[6]=1;
	g[7]=0;
	g[8]=0;
	g[9]=1;
	g[10]=0;
	g[11]=1;
	g[12]=0;
	cout<<(g[x]==g[y]?"Yes\n":"No\n");
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
map<char,set<int> > m;
set<int> N();
set<int> solve();
set<int> u;
string s;
int p;

set<int> U(set<int> a, set<int> b) {
  tr(it,b) a.insert(*it);
  return a;
}
set<int> I(set<int> a, set<int> b) {
  set<int> c;
  tr(it,b) {
    if(a.count(*it)) c.insert(*it);
  }
  return c;
}
set<int> D(set<int> a, set<int> b) {
  set<int> c;
  tr(it,a) {
    if(!b.count(*it)) c.insert(*it);
  }
  return c;
}
set<int> S(set<int> a, set<int> b) {
  set<int> c=D(a,b),d=D(b,a);
  return U(c,d);
}
set<int> C(set<int> a) {
  set<int> b;
  tr(it,u) {
    if(!a.count(*it)) b.insert(*it);
  }
  return b;
}

set<int> N() {
  if(s[p]=='(') {
    p++;
    return solve();
  } else if(s[p]=='c') {
    p++;
    return C(N());
  }
  set<int> a=m[s[p]];
  p++;
  return a;
}

set<int> solve() {
  set<int> a=N();
  while(p<s.size()&&s[p]!=')') {
    char ch=s[p];p++;
    set<int> b=N();
    if(ch=='u') a=U(a,b);
    else if(ch=='i') a=I(a,b);
    else if(ch=='d') a=D(a,b);
    else a=S(a,b);
  }
  p++;
  return a;
}
  
int main() {
  char c;
  int n;
  while(cin >> c >> n) {
    m.clear();
    u.clear();
    for(int i=0; i<n; i++) {
      int x;
      cin >> x;
      m[c].insert(x);
      u.insert(x);
    }
    while(cin >> c >> n && c!='R') {
      for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        m[c].insert(x);
        u.insert(x);
      }
    }
    cin >> s;
    p=0;
    set<int> ans=solve();
    if(ans.size()) {
      bool f=0;
      tr(it,ans) {
        if(f) cout << " ";f=1;
        cout << *it;
      }
      cout << endl;
    } else cout << "NULL" << endl;
  }
  return 0;
}


Measured memory_bytes: 1216
#include <stdio.h>

int main(){
	int n, a, b, c, d, count = 0;
	while (scanf("%d",&n) != EOF){
	for (a = 0;a <= 9;a++){
		for (b = 0;b <= 9;b++){
			for (c = 0;c <= 9;c++){
				for (d = 0;d <= 9;d++){
					if (a + b + c + d == n) count++;
				}
			}
		}
	}
	
	printf("%d\n", count);
	count = 0;
	}
	return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N+2];


void solve()
{
      cin >> n;
      map<int,int>  mp;
      int ans = 0;
      lop(i,0,n) cin >> arr[i] , ans += mp[ arr[i] ], mp[ arr[i] ]++;

      lop(i,0,n)
      {
            int r = mp[ arr[i] ] - 1;
            cout << ans - r << endl;
      }
      
}


int32_t main()
{
      
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
     // INP(); 
      int t = 1;
      //cin >> t;
      while(t--) solve();

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 11136
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto A = scan!int(N);

  long solve() {
    long ans;
    foreach(i, a; A) {
      if (i % 2 == 0 && a % 2 == 1) ans++;
    }
    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 2764
import copy

def printData(data) :
    for i, value in enumerate(data) :
        if i > 0 :
            print(" ", end = "")
        print(value[0] + str(value[1]), end = "")
    print()
    
def isStable(data1, data2) :
    for v1, v2 in zip(data1, data2) :
        if v1[0] != v2[0] :
            return "Not stable"
    return "Stable"

def bubbleSort(data, N) :
    flag = 1
    for i in range(N) :
        if not flag :
            break
        flag = 0
        for j in reversed(range(i + 1, N)) :
            if data[j][1] < data[j - 1][1] :
                buf = data[j]
                data[j] = data[j - 1]
                data[j - 1] = buf
                flag = 1
    printData(data)
    print("Stable")
    
def selectionSort(data, N) :
    for i in range(N) :
        minIdx = i
        for j in range(i + 1, N) :
            if data[j][1] < data[minIdx][1] :
                minIdx = j
        if minIdx != i :
            buf = data[minIdx]
            data[minIdx] = data[i]
            data[i] = buf
    printData(data)


N = int(input())
data = [list(value) for value in input().split()]
for value in data :
    value[1] = int(value[1])
    
copy_data1 = copy.deepcopy(data)
bubbleSort(copy_data1, N)
copy_data2 = copy.deepcopy(data)
selectionSort(copy_data2, N)
print(isStable(copy_data1, copy_data2))




Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

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

	string a[] = {"Sunny", "Cloudy", "Rainy", "\0"};
	string s;
	cin >> s;

	for(int i = 0; i < 3; i++){
		// cout << a[i] << endl;
		if(s == a[i]){
			// cout << (i + 1) % 3 << endl;
			cout << a[(i + 1) % 3] << endl;
			return 0;
		}
	}
}	


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int Check(int x){
    char s[10];
    sprintf(s+1,"%d",x);
    int len=strlen(s+1);
    for(int i=1;i<=len/2;i++)
        if(s[i]!=s[len-i+1])
            return 0;
    return 1;
}

int main(){
    int A,B,Ans=0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++)
        Ans+=Check(i);
    printf("%d",Ans);
    return 0;
}
/*****/

Measured memory_bytes: 128
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

K, = list(map(int, sys.stdin.readline().rstrip().split()))

N = 50

As = [0 for _ in range(50)]
if K > 50:
    bias = K // 50
    K = K - bias * 50


    # for i in range(50):
    #     if i < K:
    #         As[i] += (50 + 1 - i + bias * 50)
    #
    if bias > 0:
        for i in range(50):
            As[i] += (50 - i + bias -1 )

    # for i in range(50):
    #     if i < K:
    #         As[N - 1 - i] += (50 - i + bias)
    for i in range(50):
        if i < K:
            As[i] += 1
            # As[i] += (50 - i + bias)
else:
    for i in range(50):
        if i < K:
            As[i] += (50 - i)
print(50)
print(" ".join(map(str, As)))

exit(0)


Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
    int n = 0;
    std::cin >> n;

    int count[4] = { 0 };
    for (auto i = 0; i < n; ++i)
    {
        std::string s;
        std::cin >> s;
        switch (s[0])
        {
        case 'A':
            ++count[0];
            break;
        case 'W':
            ++count[1];
            break;
        case 'T':
            ++count[2];
            break;
        case 'R':
            ++count[3];
            break;
        }
    }
    
    std::cout << "AC x " << count[0] << std::endl;
    std::cout << "WA x " << count[1] << std::endl;
    std::cout << "TLE x " << count[2] << std::endl;
    std::cout << "RE x " << count[3] << std::endl;
}

Measured memory_bytes: 3624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

tree = UnionFind(N)

for _ in range(M):
    A, B = MAP()
    tree.union(A-1, B-1)

ans = 0

for i in range(N):
    ans = max(ans, tree.size(i))
print(ans)


Measured memory_bytes: 15744
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let ab = read_nums();
    let a = ab[0];
    let b = ab[1];

    let mut ret = 0;
    if a>=13 {
        ret = b;
    } else if a>=6 {
        ret = b/2;
    }
    


    print!("{}", ret);
}   

Measured memory_bytes: 4352
#include<stdio.h>
#define MAX 100000

int main(){
    int n,i,a[MAX];

    scanf("%d" ,&n);
    for(i=0; i<n; i++){
        scanf("%d" , &a[i]);
    }

    for(i=0; i<n; i++){
        printf("node %d: key = %d, " ,i+1 ,a[i]);

        if(i){
            printf("parent key = %d, " ,a[(i+1)/2-1]);
        }

        if(2*i+1 < n){
            printf("left key = %d, " ,a[2*i+1]);
        }
        if(2*i+2 < n){
            printf("right key = %d, " ,a[2*i+2]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
// abc058_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    vector<map<char, int>> mp(N);
    REP(i, N){
        REP(j, S[0].size()){
            mp[i][S[i][j]]++;
        }
    }

    map<char, int> common;
    REP(c, 26){
        common[c + 'a'] = 255;
    }
    REP(i, N){
        REP(c, 26){
            common[c + 'a'] = min(common[c + 'a'], mp[i][c + 'a']);
        }
    }

    string ans;
    REP(c, 26){
        REP(i, common[c + 'a']){
            ans += c + 'a';
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 384
n = int(input())
t,a = map(float,input().split())
h = list(map(float,input().split()))
best = 10 ** 5
ans = -1
for i in range(n):
    tt = t - h[i] * 0.006
    best = min(best,abs(tt - a))
    if abs(a - tt) == best:
        ans = i
print(ans+1)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;

#define ll long long int
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define se second
#define fi first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)

#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
// typedef __int128 bign;


#define TRACE

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

#define MD          1000000007
#define M 			1011
#define LN 			14
#define fftmod      998244353
#define EPS         (double)1e-10
#define PI          3.14159265358979323846264

ll md=MD;
ll inf=2e18;


inline ll exp(ll a,ll b){ll r=1LL;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}

ll a[M];

int main(){


    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,s,j,m,x,y,n,z,p,k,T;string s1,s2;x=1;
    cin>>n>>k;
    lp(1,n)cin>>a[i];
    p=1e-9;

    priority_queue<ll,vector<ll>,greater<ll> > pq;
    for(i=0;i<=n;++i){
    	for(j=i+1;j<=(n+1);++j){
    		if(i+(n-j+1)>k)continue;
    		for(x=1;x<=i;++x)pq.push(a[x]);
    		for(x=n;x>=j;--x)pq.push(a[x]);
    		for(x=1;x<=(k-(i+(n-j+1)));++x){
    			if(pq.empty())break;
    			if(pq.top()>0)break;
    			pq.pop();
    		}
    		ll ans=0;
    		while(!pq.empty()){
    			// trace(pq.top());
    			ans+=pq.top();
    			pq.pop();
    		}
    		// trace(ans,i,j);
    		p=max(p,ans);
    	}
    }
    cout<<p<<"\n";






    






    return 0;
}



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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  vi p(n);
  rep(i, n) std::cin >> p[i];
  int mi = inf, ans = 0;
  rep(i, n) {
    if (mi >= p[i])
      mi = p[i], ans++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 1024
using System;
class p
{
  static void Main()
  {
    string w = Console.ReadLine();
    bool result = true;
    for (int i = 0; i < w.Length; i++) {
      int count = 0;
      for (int j = 0; j < w.Length; j++) {
        if (w[i] == w[j]) { count++; }
      }
      if (count % 2 != 0) {
        result = false;
        break;
      }
    }
    Console.WriteLine(result ? "Yes" : "No");
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

ll parent[100005];
ll root(ll a){
    if(parent[a]==a)return a;
    return parent[a] = root(parent[a]);
}

void unite(ll x,ll y){
    ll rx = root(x);
    ll ry = root(y);
    parent[rx] = ry;
}


int main(void) {
    ll n,m;
    cin >> n >> m;
    ll p[n];
    vector<pair<ll, ll> > xy;
    rep(i,n)cin >> p[i];
    rep(i,m){
        ll tx,ty;
        cin >> tx >> ty;
        xy.push_back(make_pair(tx,ty));
    }
    rep(i,n+1)parent[i]=i;
    rep(i,m){
        unite(xy[i].first,xy[i].second);
    } 
    ll res=0;
    DEBUG{
        rep(i,n){
            printf("p%d : %lld\n", i+1, parent[i+1]);
        }
    }
    rep(i,n){
        if(root(i+1)==root(p[i]))res++;
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll a[n],b[n];
    rep(i,0,n){
        cin >> a[i];
        b[i] = a[i];
    }

    ll ans1 = 0,memo = 0;
    rep(i,0,n){
        memo += a[i];
        if(i % 2 == 0 && memo <= 0){
            ans1 += abs(memo) + 1;
            memo = 1;
        }
        else if(i % 2 == 1 && memo >= 0){
            ans1 += memo + 1;
            memo = -1;
        }
    }

    ll ans2 = 0;
    memo = 0;
    rep(i,0,n){
        memo += a[i];
        if(i % 2 == 1 && memo <= 0){
            ans2 += abs(memo) + 1;
            memo = 1;
        }
        else if(i % 2 == 0 && memo >= 0){
            ans2 += memo + 1;
            memo = -1;
        }
    }

    cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 5164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(){

  int n, k;

  scanf("%d%d", &n, &k);

  vector<ll> lft, rt;

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

    ll x; scanf("%lld", &x);
    if(x == 0)k--;
    else if(x < 0)lft.push_back(-x);
    else rt.push_back(x);
  }

  if(k==0){
    cout << 0 << '\n';
    return 0;
  }
  reverse(lft.begin(),lft.end());

  ll ans = LLONG_MAX;

  for(int i = 0; i < lft.size(); i++){

    int x = (k-i-1);
    if(x <= rt.size() && x > 0){
      ans = min(ans,lft[i] + lft[i] + rt[x-1]);
    }

  }
  for(int i = 0; i < rt.size(); i++){

    int x = (k-i-1);
    if(x <= lft.size() && x > 0){
      ans = min(ans,rt[i] + rt[i] + lft[x-1]);
    }

  }

  if(lft.size() >= k)ans = min(ans, lft[k-1]);
  if(rt.size() >= k)ans = min(ans, rt[k-1]);

  cout << ans << '\n';




}


Measured memory_bytes: 1656
#include <cstdio>
#include <iostream>
#include<complex>

using namespace std;

typedef complex<double> P;
 
P reflect(P a, P b, P c){
  b -= a; c -= a;
  return a + conj(c / b) * b;
}

int main() {
  int n;
  double ax, ay, bx, by, cx, cy;
  scanf("%lf %lf %lf %lf %d",&ax, &ay, &bx, &by, &n);
  while(n--) {
    scanf("%lf %lf",&cx,&cy);
    P p = reflect(P(ax, ay), P(bx, by), P(cx, cy));    
    printf("%.8f %.8f\n", p.real(), p.imag());
  }
  return 0;
}


Measured memory_bytes: 3248