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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int a , b , c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    LL s = 0;
    if(k >= a){
        s += a;
        k = k - a;
    }else{
        s += k;
        k = 0;
    }

    if(k >= b){
        k = k - b;
    }else{
        k = 0;
    }

    if(k >= c){
        s -= c;
        k = k - c;
    }else{
        s -= k;
        k = 0;
    }
    cout << s << "\n";

    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 3636
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
struct Z { int l,r; };
bool operator<(const Z &a,const Z &b) { return a.l<b.l; }

int n;
Z z[MAXN];

int pref[MAXN+1];
int suff[MAXN+1];

ll solve() {
	ll ret=0;
	REP(i,n) ret=max(ret,(ll)z[i].r-z[i].l+1);
	int rmn=z[0].r; REP(i,n) rmn=min(rmn,z[i].r);
	int lmx=z[0].l; REP(i,n) lmx=max(lmx,z[i].l);
	if(lmx<=rmn) REP(i,n) ret=max(ret,(ll)rmn-lmx+1+z[i].r-z[i].l+1);
	sort(z,z+n);
	pref[0]=INT_MIN; REP(i,n) pref[i+1]=max(pref[i],z[i].l);
	suff[n]=INT_MAX; for(int i=n-1;i>=0;--i) suff[i]=min(suff[i+1],z[i].r);
	FORE(i,1,n-1) if(pref[i]<=rmn&&suff[i]>=lmx) {
		ll cur=(ll)(rmn-pref[i]+1)+(ll)(suff[i]-lmx+1);
		ret=max(ret,cur);
	}
	return ret;
}

void run() {
	scanf("%d",&n);
	REP(i,n) scanf("%d%d",&z[i].l,&z[i].r);
	printf("%lld\n",solve());
}

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


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

using namespace std;

int main() {
  int N;
  cin >> N;
  set<string> S;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 19260
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    cout << count-1 << endl;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc067 c
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        long[] a = in.nl(n), sum = new long[n];
        sum[0] = a[0];
        for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];
        long min = INF;
        for (int i = 0; i < n-1; i++) {
            min =Math.min(min, Math.abs(sum[i]-(sum[n-1]-sum[i])));
        }
        out.println(min);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 46092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aeroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] cnt = new int[11];
            for (int i = 0; i < 3; ++i) cnt[in.nextInt()]++;

            if (cnt[5] == 2 && cnt[7] == 1) out.println("YES");
            else out.println("NO");
        }

    }
}



Measured memory_bytes: 23636
#include<stdio.h>
int main(void){
        int point[20],count=0,answer=0,i,cancel,minimum=0;
        for(count=0; count<10; count++){
                scanf(" %d",&point[count]);
                if(point[count]<=minimum){
                	minimum=point[count];
                	}
                }
        answer=minimum;
        for(count=0; count<3; count++,point[cancel]=minimum,answer=minimum){
                for(i=0; i<=9; i++){
                        if(point[i]>=answer){
                                answer=point[i];
                                cancel=i;
                                }
                        }
                printf("%d\n",answer);
                }
        return 0;
}

Measured memory_bytes: 600
/*AOJ-ITP-2-2*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int[] sort =  {a,b,c}; 
		int v=0;
		
		if(!(a >= 1 || b >= 1 || c >= 1 || a <= 10000 || b <= 10000 || c <= 10000)){System.exit(1);}
		
		for(int i = 1 ; i < sort.length ; i++){
			if(sort[i-1] > sort[i]){
				v = sort[i-1];
				sort[i-1] = sort[i];
				sort[i] = v;
			}
		}
		
		for(int i = 1 ; i < sort.length ; i++){
			if(sort[i-1] > sort[i]){
				v = sort[i-1];
				sort[i-1] = sort[i];
				sort[i] = v;
			}
		}
		
		System.out.println(sort[0] + " " + sort[1] + " " + sort[2]);
		
	}
}

Measured memory_bytes: 24272
n,m = map(int,input().split())
k1 = list(map(int,input().split()))
del k1[0]
k1 = set(k1)
for i in range(n-1):
    k = list(map(int,input().split()))
    del k[0]
    k = set(k)
    k1 = k1 & k
print(len(k1))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010;

int n, k, cur = 0;
ll ans = 0;
vector<int> a[N];

priority_queue<int, vector<int>, greater<int>> q1;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q2;

int main() {


  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    int t, d;
    scanf("%d%d", &t, &d);
    if (a[t].empty())
      ++cur;
    a[t].push_back(d);
    ans += d;
  }
  for (int i = 1; i <= n; ++i) {
    sort(a[i].begin(), a[i].end(), greater<int>());
    if (!a[i].empty()) {
      q1.push(a[i].front());
      if (a[i].size() > 1)
      q2.emplace(a[i].back(), i);
    }
  }
  ans += cur * (ll)cur;
  int rep = n - k;
  while (rep--) {
    int v1 = cur * 2 - 1 + q1.top();
    int v2 = q2.empty() ? (1 << 30) : q2.top().first;
    if (v1 < v2) {
      ans -= v1;
      q1.pop();
      --cur;
    } else {
      ans -= v2;
      int id = q2.top().second;
      q2.pop();
      a[id].pop_back();
      if (a[id].size() > 1)
        q2.emplace(a[id].back(), id);
    }
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 6396
import java.util.*;

public class Main {
	
    private static Integer count = 0;
      
	public static void main(String[] args) {

		// argumentの取得
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
      
        if (x == 1) {
          System.out.println(0);
          return;
        }
      
        if ((x % 2) == 0) {
         //System.out.println(x + " は偶数");
         System.out.println((x-2)/2);
        } else {
         //System.out.println(x + " は奇数");
         System.out.println((x-1)/2);
        }
	} 
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
struct node
{
    ll bb,li,ui;
}tt[maxn];
ll n,X;
bool cmp(node asd,node qwe)
{
//    if((X-asd.bb)*asd.ui==(X-qwe.bb)*qwe.ui)
//        return asd.li*asd.bb>qwe.li*qwe.bb;
//    else return (X-asd.bb)*asd.ui<(X-qwe.bb)*qwe.ui;

    return asd.li*asd.bb+(X-asd.bb)*asd.ui>(X-qwe.bb)*qwe.ui+qwe.li*qwe.bb;
}
bool check(ll x)
{
    ll ans=-0x3f3f3f3f3f3f3f3f,sum=0;
    ll lft=x%X;
    if(lft==0) lft=X;
    ll cnt=(x-lft)/X;

    for(int i=1;i<=cnt;i++)
        sum+=(X-tt[i].bb)*tt[i].ui;
    for(int i=cnt+1;i<=n;i++)
        sum-=tt[i].bb*tt[i].li;

    for(int i=cnt+1;i<=n;i++)
    {
        ll tmp;
        if(lft>=tt[i].bb)
            tmp=(lft-tt[i].bb)*tt[i].ui;
        else
            tmp=(lft-tt[i].bb)*tt[i].li;
        ans=max(ans,sum+tt[i].bb*tt[i].li+tmp);
    }
    sum+=(X-tt[cnt+1].bb)*tt[cnt+1].ui;
    sum+=tt[cnt+1].bb*tt[cnt+1].li;
    for(int i=1;i<=cnt;i++)
    {
        ll tmp;
        if(lft>=tt[i].bb)
            tmp=(lft-tt[i].bb)*tt[i].ui;
        else
            tmp=(lft-tt[i].bb)*tt[i].li;
        ans=max(ans,sum-(X-tt[i].bb)*tt[i].ui+tmp);
    }
    if(ans>=0) return true;
    else       return false;
}
int main()
{
    scanf("%lld%lld",&n,&X);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&tt[i].bb);
        scanf("%lld%lld",&tt[i].li,&tt[i].ui);
    }
    sort(tt+1,tt+1+n,cmp);
    ll l=0,r=n*X;
    while(l<r)
    {
        ll mid=(l+r)>>1;
        if(check(mid))
            r=mid;
        else
            l=mid+1;
    }
    if(check(l))
        printf("%lld\n",l);
    else if(check(r))
        printf("%lld\n",r);
    return 0;
}


/*
7 1 3 6 7
.#..#..

8 1 3 9 6
...#....



*/


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = scan.nextInt();
        }
        Arrays.sort(l);
        int answer = 0;
        for (int i = n-k; i < n; i++) {
            answer += l[i];
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21332
N, M = map(int, input().split())

mod_num = 10 ** 9 + 7
a = []
for _ in range(M):
    a.append(int(input()))

val = [0,1]
for i in range(1, N + 1):
    ans = (val[0] + val[1]) % mod_num
    val[0] = val[1]
    val[1] = ans
    if len(a) > 0:
        if i == a[0]:
            val[1] = 0
            a.pop(0)
 
print(ans)

Measured memory_bytes: 7056
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
  
int main()
{
	int n,m;
	int p[50];
	int i,j;
	int ans;

	while(1){
	scanf("%d %d",&n,&m);
	if((n==0)&&(m==0))
		break;
	//ここまでテンプレ

	for(i=0;i<n;i++)
		p[i]=0;
	j=m;
	ans=-1;
	while(1){
		for(i=0;i<n;i++){
			if(j>0){
				p[i]++;
				j--;
				if(p[i]==m){
					ans=i;
					break;
				}
			}else if(j==0){
				j+=p[i];
				p[i]=0;
			}

		}
		if(ans>-1)
			break;
	}

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


	//ここからテンプレ
	}
	return 0;
}

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

void dfs(int a, std::vector<std::vector<int>> &vec, std::vector<bool>& b, int n) {
    if (b[a]) {
        return;
    }
    b[a] = true;
    for (int i = 1; i <= n; i++) {
        if (vec[a][i] == 1) {
            dfs(i, vec, b, n);
        }
    }
}

int n, m, a, b;
std::vector<std::vector<int>> vec;
std::vector<std::pair<int, int>> edge;
int c = 0;

int main() {
    std::cin >> n >> m;
    vec.assign(n+1, std::vector<int>(n+1, 0));
    edge.assign(m, {0, 0});
    for (int i = 0; i < m; i++) {
        std::cin >> a >> b;
        vec[a][b] = 1;
        vec[b][a] = 1;
        edge[i].first = a;
        edge[i].second = b;
    }
    for (int i = 0; i < m; i++) {
        std::vector<bool> visited(n+1, false);
        int x = edge[i].first;
        int y = edge[i].second;
        vec[x][y] = 0;
        vec[y][x] = 0;
        for (int p = 0; p < m; p++) {
            if (p != i) {
                dfs(edge[p].first, vec, visited, n);
                for (int j = 1; j <= n; j++) {
                    if (!visited[j]) {
                        c++;
                        break;
                    }
                }
                break;
            }
        }

        vec[x][y] = 1;
        vec[y][x] = 1;
    }
    std::cout << c << std::endl;
}


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

int main() {
    int n;cin>>n;
    if(n%2==0)cout<<1.0/2.0<<endl;
    else cout<<(n+1)/2.0/n<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string> 
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s == "Sunny")
		cout<<"Cloudy\n";
	else if(s == "Cloudy")
		cout<<"Rainy\n";
	else if(s == "Rainy")
		cout<<"Sunny\n";
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int MAXN=1000001;
bool p[MAXN];
vector<int> a;
int main(){
	memset(p,false,sizeof(p));
	for (int i=2;i<sqrt(MAXN);i++)
		for (int j=i+i;j<MAXN;j+=i)
			p[j]=true;
	for (int i=2;i<MAXN;i++)
		if (!p[i])
			a.push_back(i);
	int n;
	while (cin >> n){
		vector<int>::iterator f=lower_bound(a.begin(),a.end(),n);
		if (*f==n)
			cout << f-a.begin()+1 << endl;
		else
			cout << f-a.begin() << endl;
	}
	return 0;
}

Measured memory_bytes: 2568
import java.util.*;

public class Main {
	final static int MOD = 1000000007;
	
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		int n = in.nextInt();
		int[] a = in.nextIntArray(n);
		int[] b = in.nextIntArray(n);
		int[] c = in.nextIntArray(n-1);
		
		int sum = 0;
		
		for (int i = 0; i < a.length; i++) {
			sum += b[a[i]-1];
			if (i!=0&&(a[i]-1==a[i-1])) {
				sum += c[a[i-1]-1];
			}
		}
		System.out.println(sum);
		
	}
	
	static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
		String[] nextLineArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLine();
			}
			return array;
		}
		
		int[][] nextIntMatrix(int n, int m) {
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}
		
		double[][] nextDoubleMatrix(int n, int m) {
			double[][] matrix = new double[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextDouble();
				}
			}
			return matrix;
		}
		
		long[][] nextLongMatrix(int n, int m) {
			long[][] matrix = new long[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextLong();
				}
			}
			return matrix;
		}
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    vector<int> W(N); for(int i = 0; i < N; ++i) cin >> W[i];
    int res = 1 << 29;
    for (int i = 1; i < N; ++i) {
        int ga = 0;
        int gb = 0;
        for (int j = 0; j < i; ++j) ga += W[j];
        for (int j = i; j < N; ++j) gb += W[j];
        res = min(res, abs(ga - gb));
    }
    cout << res << endl;

}


Measured memory_bytes: 256
function Main(s) {
  var s = s.split("\n")[0];
  var n = s.length - 1;
  var ans = 0;
  for (var bit = 0; bit < 1<<n; bit++) {
    var ops = new Array(n);
    for (var i = 0; i < n; i++) {
      if (bit & (1<<i)) {
        ops[i] = "+";
      } else {
        ops[i] = "";
      }
    }
    var a = s[0];
    for (var j = 0; j < n; j++) {
      a += ops[j] + s[j + 1];
    }
    ans += eval(a);
  }
  console.log(Math.max(ans, Number(s)));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7880
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

map<string,int>M;
vector<string>vec;
int n;
int main(){
	cin >> n;
	rep(i,n){
		string a; cin >> a; M[a]++;
	}
	int mx = 0;
	for(auto it:M) mx = max(mx,it.sc);
	for(auto it:M) if(it.sc == mx) vec.pb(it.fi);
	SORT(vec);
	rep(i,vec.size()) cout << vec[i] << '\n';
}

Measured memory_bytes: 26996
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; 
        x=(x*x)%p;
    }
    return res;
}
inline void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */

/* -------------------------------------- */

int main() {
	boost();
	priority_queue<double, vector<double>, greater<double>> pq;
	int n;cin>>n;int a[n];
	for(int i=0;i<n;i++){
		double x;cin>>x;
		pq.push(x);
	}
	while(pq.size()!=1){
		double a = pq.top();pq.pop();
		double b = pq.top();pq.pop();
		pq.push((a+b)/2);
	}
	cout<<pq.top();
}

Measured memory_bytes: 256
dict_alp = dict([(chr(i), i - 97) for i in range(97, 97+26)])
alp = [chr(i) for i in range(97, 97+26)]

s = list(input())
k = int(input())
l = len(s)

i = 0
while k > 0:
    if i == l - 1:
        k %= 26
        s[i] = alp[(dict_alp[s[i]] + k) % 26]
        break

    if s[i] == alp[0]:
        i += 1
        continue

    if k < 26 - dict_alp[s[i]]:
        i += 1
        continue

    k -= (26 - dict_alp[s[i]])
    s[i] = alp[0]

    i += 1

print("".join(s))


Measured memory_bytes: 4152
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

void apple(int a[], int b[], int c) {
	for (int i = 0; i < c; i++) {
		b[i] = (a[i] + a[i+1]) % 10;
	}

	return;
}


int main () {

	string std;
	int i[10];
	int j[10];

	while (cin >> std) {
		for (int k = 0; k < 10; k++) {
			i[k] = std[k] - '0';
		}

		apple(i,j,9);
		apple(j,i,8);
		apple(i,j,7);
		apple(j,i,6);
		apple(i,j,5);
		apple(j,i,4);
		apple(i,j,3);
		apple(j,i,2);
		apple(i,j,1);

		cout << j[0] << endl;
		
	}

	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using P = pair<int,int>;

// code starts
int main()
{
  int n;
  cin >> n;
  vector<char> c(n);
  int i;
  rep(i,n) cin >> c[i];
  int ans = 0;
  int noww = 0;
  for(i=n-1;i>=0;i--)
  {
    if(c[i] == 'W') continue;
    while(noww < i && c[noww] != 'W')
    {
      noww++;
    }
    if(noww == i) break;
    else
    {
      swap(c[i],c[noww]);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
fun main(args: Array<String>) {
    val S = readLine()!!
    if (!S.startsWith("A")) {
        println("WA")
        return
    }

    if (S.substring(2, S.length - 1).count { it == 'C' } != 1) {
        println("WA")
        return
    }

    if (!(S.count { it == 'C' } == 1 && S.count { it == 'A' } == 1)) {
        println("WA")
        return
    }

    if (S.filter { it.isLowerCase() }.count() != S.count() - 2) {
        println("WA")
        return
    }

    println("AC")
}


Measured memory_bytes: 33536
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);

int n, t;
int a[MAXN];

void read()
{
	cin >> n >> t;
	for(int i = 0; i < n; i++)
		cin >> a[i];
}

void solve()
{
	int mx = 0;
	set<pair<int, int> > st;
	for(int i = 0; i < n; i++)
	{
		if(!st.empty()) { mx = max(mx, a[i] - st.begin()->first); }
		st.insert({a[i], i});
	}

	int cnt = 0;
	st.clear();
	for(int i = 0; i < n; i++)
	{
		if(!st.empty() && a[i] - st.begin()->first == mx)
            cnt++;
		st.insert({a[i], i});
	}

    cout << cnt << endl;
}

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

	read();
	solve();
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    cin>>n;
    long long int arr[n],sum=0,h;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    h=arr[0];
    for(i=1;i<n;i++)
    {
        if(arr[i]<h)
        {
            sum+=(h-arr[i]);
        }
        else
        {
            if(arr[i]==h)
            {
                continue;
            }
            else
            {
                h=arr[i];
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[100100] = {};
	long long res = 0;
	for(int i = 0; i < n; i++) {
		int A; cin >> A;
		res += A;
		a[A]++;
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++)
	{
		int b, c; cin >> b >> c;
		if(a[b] == 0) {
			cout << res << endl;
		}
		else {
			res += (c - b) * a[b];
			a[c] += a[b];
			a[b] = 0;
			cout << res << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3984
_n = gets.to_i
as = gets.strip.split.map(&:to_i)
answer = 0
cnt =0
buf = as[0]
for num in 1.._n-1 do
    if buf>=as[num]
      cnt+=1;
    else
      if cnt>answer
        answer=cnt
      end
      cnt=0
    end
    buf = as[num]
end
if cnt>answer
   answer=cnt
end

puts answer

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, D;
    cin >> N >> D;
    vector<vector<int>> points(N, vector<int>(D));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) {
            int X;
            cin >> X;
            points.at(i).at(j) = X;
        }
    }
    int ans = 0;
    for (int k = 0; k <= N - 2; ++k) { // k番目(0 <= k <= N-2)と
        for (int l = k + 1; l <= N - 1; ++l) { // k < l な l番目を比較
            int squared = 0;
            for (int m = 0; m < D; ++m) {
                int dist = points.at(k).at(m) - points.at(l).at(m);
                squared += dist * dist;
            }
            if (sqrt(squared) == (int)sqrt(squared)) ans += 1;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int N=205;
int T,i,j,n;
ll a[N],b[65];
inline bool ins(ll x){
	for(j=59;j>=0;--j)if(x>>j&1){if(!b[j]){b[j]=x;return 1;}x^=b[j];}
	return 0;
}
char c[N];
int main(){
	for(scanf("%d",&T);T--;){
		memset(b,0,sizeof b);
		scanf("%d",&n);
		for(i=1;i<=n;++i)scanf("%lld",a+i);
		scanf("%s",c+1);
		for(i=n;i;--i)if(ins(a[i]) && c[i]=='1')break;
		puts(i?"1":"0");
	}
}

Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{

    lint n, m;
    scanf("%lld", &n);
    scanf("%lld", &m);

    std::vector<std::vector<std::pair<lint, lint>>> cities(n);

    for (int i = 0; i < m; ++i)
    {
        lint p, y;
        scanf("%lld", &p);
        scanf("%lld", &y);

        cities[p - 1].push_back(std::make_pair(y, i));
    }

    std::vector<std::string> ans(m);

    for (int i = 0; i < n; ++i)
    {
        std::sort(cities[i].begin(), cities[i].end());

        std::stringstream p_ss;
        p_ss << std::setw(6) << std::setfill('0') << i + 1;

        lint count = 1;

        for (auto city = cities[i].begin(); city != cities[i].end(); city++)
        {
            std::stringstream c_ss;
            c_ss << std::setw(6) << std::setfill('0') << count;
            ans[city->second] = p_ss.str() + c_ss.str();
            count++;
        }
    }

    for (auto cityid : ans)
    {
        std::cout << cityid << "\n";
    }

    return 0;
}


Measured memory_bytes: 12416
X, Y = map(int, input().split())
def comb(n, r, mod=10 ** 9 + 7):
  n1 = n + 1
  r = min(n, n - r)
  numer = denom = 1
  for i in range(1, r + 1):
    numer = numer * (n1 - i) % mod
    denom = denom * i % mod
  return numer * pow(denom, mod - 2, mod) % mod
# x + y coordinates increase by 3 per one move
# x + y should be factor of 3
ans = 0
if (X + Y) % 3 == 0 and 2 * Y >= X and 2 * X >= Y:
  # The number of up move and right move
  up, right = (2 * Y - X) // 3, (2 * X - Y) // 3
  # up + right = (X + Y) % 3
  ans = comb(up + right, right)
print(ans)

Measured memory_bytes: 3064
/**akshaykumar99**/

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

#define F first
#define S second
#define pp pop_back()
#define pu(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define all(v) v.begin(),v.end()
#define f(i,x,n) for(i=x;i<n;i++)
#define rall(v) v.rbegin(),v.rend()

const int MOD=1e9+7 , INF=INT_MAX;
const long long LINF=LLONG_MAX;

typedef long long ll;
typedef long double ld;
typedef vector<int> ivc;
typedef pair<int,int> ipr;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,d;
    cin>>n>>d;
    ll z=n/(2*d+1);
    if(n%(2*d+1)!=0)
    	z++;
    cout<<z<<endl;
    

}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int N = Integer.parseInt(in.readLine());
		int result = N / 2;
		if (N % 2 != 0) {
			++result;
		}
		System.out.println(result);
	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	long a; long res = 0;
	long ans = 0;
	rep(i,0,N){
		cin>>a;
		if(res + 1 < a){ ans += (a - 1) / (res + 1); res = max(res, (long)1); }
		else res = max(res, a);
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {

	var K int
	fmt.Scanf("%d", &K)

	var sum int = 0
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			for c := 1; c <= K; c++ {
				sum = sum + gcd(gcd(a, b), c)
			}
		}
	}

	fmt.Println(sum)

}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        string s, sq; cin >> s>> sq;
        cout << sq<< s;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String W = stdIn.next().toLowerCase();
        stdIn.nextLine();
        int answer = 0;
        while(true) {
            String line = stdIn.nextLine();
            if(line.equals("END_OF_TEXT")) {
                break;
            }
            for(String word : line.toLowerCase().split(" ")) {
                if(word.equals(W)) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a;
	bool f=true;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2==0){
			if(a%3==0||a%5==0){

			}else{
				f=false;
			}
		}
	}
	if(f){
		cout<<"APPROVED"<<endl;
	}else{
		cout<<"DENIED"<<endl;
	}
	return 0;
}


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

int main() {

	string s,res="";
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '0') res += '0';
		if (s.at(i) == '1') res += '1';
		if (s.at(i) == 'B') res = res.substr(0, res.size() - 1);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

//Question
//https://atcoder.jp/contests/abc118/tasks/abc118_a

  int a,b,modulo;

  cin >> a >> b;

  //制約により0除算チェック無し
  modulo = b % a;
  if (modulo == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }

  return 0;
}

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

const int N = 1e6;

int dp[N+10][2];
int main(){

    int n;
    string s;
    cin >> s;
    n = s.size();
    s  = s + "0";
    int me = 0, ans = 0;
    dp[n][0] = 0; dp[n][1] = 1;
    for (int i = n-1; i >= 0; i--){
        int x = s[i] - '0' + me; me = 0;

        if (x >= 6){
            me = 1;
            ans += 10 - x;
        } else {
            if (x == 5 && i > 0 && s[i - 1] >= '5') me = 1, ans += 10 - x; else {
                ans += x;
            }
        }
    }

    ans += me;

    cout << ans;
}


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

int main() {
    long long int N, A0, A;
    long long int ans = 0;

    cin >> N;
    cin >> A0;
    for (int i = 1; i < N; ++i) {
        cin >> A;
        if ((A - A0) < 0) {
            ans += A0-A;
            A = A0;
        }

        A0 = A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <math.h>
 
#define rep(i, n) for(int i = 0; (int)(i) < n; i++)
 
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  long long r = 0, g = 0, b = 0;
  
  for(char c : S){
    if(c == 'R') r++;
    else if(c == 'G') g++;
    else b++;
  }
  long long all = r * g * b;
  long long sub = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      if(S[i] == S[j]) continue;
      int k = j * 2 - i;
      if(k >= N || S[k] == S[i] || S[k] == S[j]) continue;
      sub++;
    }
  }
  cout << all - sub << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int digitsum(ll num)
{
    ll res = 0;
    while(num){
        res+=(num%10);
        num/=10;
    }
    return res;
}

void getnxt(long long &c)
{
    ll cur;
    ll n;

	for(ll i=1;;i*=10) {
        cur = c/i%10;
		if(cur==9) continue;
        n = c-cur*i;
        n += 9*i;
		if(c*digitsum(n)<=n*digitsum(c)) return;
		c=n;
	}
}

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>k;

    ll res = 1;

    while(k--){
        cout<<res<<"\n";
        res++;
        getnxt(res);
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC128C()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int> > sw(M);
	for (int i = 0; i < M; ++i)
	{
		int k;
		cin >> k;
		sw[i].resize(k);
		for (int j = 0; j < k; ++j)
			cin >> sw[i][j];
	}
	vector<int> p(M);
	for (int i = 0; i < M; ++i)
		cin >> p[i];

	int ct = 0;
	for (int i = 0; i < (1 << N); ++i)
	{
		bool isGood = true;
		for (int j = 0; j < M; ++j)
		{
			const auto& theSw = sw[j];
			int nOn = 0;
			for (int k = 0; k < theSw.size(); ++k)
			{
				nOn += 1 & (i >> (theSw[k]-1));
			}
			if (p[j] != (nOn % 2))
			{
				isGood = false;
				break;
			}
		}
		if (isGood)
			++ct;
	}
	cout << ct << endl;
}
int main()
{
	ABC128C();
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = cin.nextInt();
            }

            var list = a.ToList();       
            list.Sort();

            for (int i = 0; i < N; i++)
            {
                var now = a[i];
                if(now == list[N - 1])
                {
                    Console.WriteLine(list[N-2]);
                }
                else
                {
                    Console.WriteLine(list[N-1]);
                }                
            }
            
        }
    }

    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 17984
#include <bits/stdc++.h>
using namespace std;
double INF = 1000000;
double EPS = 0.00000001;
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<double> x(N), y(N), z(N), r(N);
  vector<long long> l(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
  }
  for (int i = 0; i < Q; i++){
    double sx, sy, sz, dx, dy, dz;
    cin >> sx >> sy >> sz >> dx >> dy >> dz;
    double lx = dx - sx;
    double ly = dy - sy;
    double lz = dz - sz;
    long long ans = 0;
    for (int j = 0; j < N; j++){
      double left = 0;
      double right = 1;
      double dist = INF;
      for (int k = 0; k < 50; k++){
        double mid1 = (left * 2 + right) / 3;
        double mid2 = (left + right * 2) / 3;
        double d1 = sqrt(pow(sx + lx * mid1 - x[j], 2) + pow(sy + ly * mid1 - y[j], 2) + pow(sz + lz * mid1 - z[j], 2));
        double d2 = sqrt(pow(sx + lx * mid2 - x[j], 2) + pow(sy + ly * mid2 - y[j], 2) + pow(sz + lz * mid2 - z[j], 2));
        if (d1 > d2){
          left = mid1;
          dist = min(dist, d2);
        } else {
          right = mid2;
          dist = min(dist, d1);
        }
      }
      if (dist < r[j] + EPS){
        ans += l[j];
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3224
n, x = map(int, input().split())
a = list(map(int, input().split()))
b = a[:]

ans = sum(a)
for k in range(1, n):
  for i in range(n):
    if b[i] > a[i-k]:
      b[i] = a[i-k]
  ans = min(ans, sum(b) + k*x)
print(ans)
      

Measured memory_bytes: 3188
from collections import defaultdict
import math

def main():
    MOD = 10**9+7
    N = int(input())
    zero_cnt = 0
    L = defaultdict(int)
    L2 = defaultdict(int)
    for _ in range(N):
        x,y = map(int,input().split())
        if x == 0 and y == 0:
            zero_cnt += 1
            continue
        d = math.gcd(x,y)
        x //= d
        y //= d
        if x == 0 and y == 0:
            zero_cnt += 1
        if y < 0:
            x *= -1
            y *= -1
        elif ｙ == 0 and ｘ < 0:
            x *= -1
            y *= -1
        rot90 = (x <= 0)
        if rot90:
            tmp = x
            x = y
            y = -tmp
        if rot90:
            L[(x,y)] += 1
        else:
            L2[(x,y)] += 1

    ans = 1
    keys = set(list(L.keys()) + list(L2.keys()))
    for k in keys:
        now = 1
        s = L[k]
        t = L2[k]
        now += pow(2,s,MOD) - 1
        now += pow(2,t,MOD) -1
        ans *= now
        ans %= MOD
    ans -= 1
    ans += zero_cnt
    print(ans%MOD)

main()

Measured memory_bytes: 75844
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
#define FOR(i,n) for(int i = 0; i < n; ++i)
typedef vector<long> vec;
int cnt = 0;

void Merge(vec& vA, int l, int m, int r){
	int d1 = m - l,
		d2 = r - m;
	vec vL(d1 + 1, 0);
	vec vR(d2 + 1, 0);
	int i, j, k;
	FOR(i, d1) vL[i] = vA[l + i];
	FOR(i, d2) vR[i] = vA[m + i];
	vL[d1] = LONG_MAX;
	vR[d2] = LONG_MAX;
	i = j = 0;
	for (k = l; k < r; ++k){
		++cnt;
		if (vL[i] <= vR[j]){
			vA[k] = vL[i];
			++i;
		}
		else{
			vA[k] = vR[j];
			++j;
		}
	}
}

void MergeSort(vec& vA, int l, int r){
	if (l >= r - 1)	return;
	int m = (l + r) / 2;
	MergeSort(vA, l, m);
	MergeSort(vA, m, r);
	Merge(vA, l, m, r);
}

int main()
{
	int n;
	cin >> n;
	vec vA(n, 0);
	FOR(i, n) cin >> vA[i];
	MergeSort(vA, 0, n);
	FOR(i, n){
		cout << vA[i];
		if (i != n - 1) cout << " ";
	}
	cout << "\n" << cnt << "\n";

	return 0;
}

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



int main(void){
    int N;
    cin >> N;
    long long M0 = 0;
    long long M1 = 0;
    long long M2 = 0;
    long long M3 = 0;
    long long M4 = 0;
    string S;
    for(int i = 0; i < N; i++){
        cin >> S;
        if(S.substr(0,1)=="M")M0++;
        if(S.substr(0,1)=="A")M1++;
        if(S.substr(0,1)=="R")M2++;
        if(S.substr(0,1)=="C")M3++;
        if(S.substr(0,1)=="H")M4++;
    }
    // if(M==0&&A==0&&R==0&&C==0&&H==0){
    //     cout << 0 << endl;
    //     return 0;
    // }
    // if(M==0)M=1;
    // if(A==0)A=1;
    // if(R==0)R=1;
    // if(C==0)C=1;
    // if(H==0)H=1;
    cout << M0*M1*M2+M0*M1*M3+M0*M1*M4+M0*M2*M3+M0*M2*M4+M0*M3*M4+M1*M2*M3+M1*M2*M4+M1*M3*M4+M2*M3*M4<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int x = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		int z = Integer.parseInt(st.nextToken());
		
		int tmp = x;
		x = y;
		y = tmp;
		
		tmp = x;
		x = z;
		z = tmp;
		
		System.out.println(x + " "+ y+ " " + z);
	}

}

Measured memory_bytes: 37128
#include <iostream>
#include <queue>
#include <utility>

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

int a,b,ans;
int q[20+5][20+5];
char p[20+5][20+5];

using namespace std;
int main() {
	queue<pair<int,int> > M;
	pair<int,int> X;
	while(cin >> a >> b){
		for (int i=1; i<=21; i++){
			for (int j=1; j<=21; j++){
				q[i][j] = 0;
				p[i][j] = ' ';
			}
		}
		if (a==0) return 0;
		ans = 0;
		for (int i=1; i<=b; i++){
			for (int j=1; j<=a; j++){
				cin >> p[i][j];
				if (p[i][j] == '@'){
					M.push(make_pair(i,j));
					ans = 1;
					q[i][j] = 1;
				}
			}
		}
	

		while(!M.empty()){
			a = M.front().first;
			b = M.front().second;
			M.pop();
			for (int i=0; i<=3; i++){		
				if (p[a+dx[i]][b+dy[i]]=='.' && q[a+dx[i]][b+dy[i]]==0){
					M.push(make_pair(a+dx[i],b+dy[i]));
					q[a+dx[i]][b+dy[i]] = 1;
					ans+=1;
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main() {

  int N;
  cin >> N;

  double answer = 0.0;

  for (int i = 0; i < N; i++) {
    double x;
    cin >> x;
    string u;
    cin >> u;
    if (u == "BTC") {
      answer += (double) 380000 * x;
    } else {
      answer += (double) x;
    }
  }

  cout << setprecision(20) << answer << endl;

}

Measured memory_bytes: 256