akhauriyash/Code-Regression huggingface dataset:
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define vz(x) x.size()
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 1e5 + 10;
const ll INF = 1e18 + 50;
const ll MOD = 1e9 + 7;
ll n;

int main() {
  in(n);
  vector <ll> v(3 * n + 1);
  for (ll i = 1 ; i <= 3 * n ; i++) {
    in(v[i]);
  }

  vector <ll> pmax(3 * n + 1 , -INF), smin(3 * n + 2 , INF);
  {
    priority_queue <ll , vector <ll> , greater <ll>> pq;
    ll sum = 0;
    for (ll i = 1 ; i <= n ; i++) {
      sum += v[i];
      pq.push(v[i]);
    }
    pmax[n] = sum;
    for (ll i = n + 1 ; i <= 2 * n ; i++) {
      ll lowest = pq.top(); pq.pop();
      sum -= lowest;
      if (v[i] > lowest) {
        pq.push(v[i]);
        sum += v[i];
      } else {
        pq.push(lowest);
        sum += lowest;
      }
      pmax[i] = max(pmax[i - 1] , sum);
    }
  }
  {
    priority_queue <ll> pq;
    ll sum = 0;
    for (ll i = 3 * n ; i > 2 * n ; i--) {
      sum += v[i];
      pq.push(v[i]);
    }
    smin[n * 2 + 1] = sum;
    for (ll i = 2 * n ; i >= n + 1 ; i--) {
      ll highest = pq.top(); pq.pop();
      sum -= highest;
      if (v[i] < highest) {
        pq.push(v[i]);
        sum += v[i];
      } else {
        pq.push(highest);
        sum += highest;
      }
      smin[i] = min(smin[i + 1] , sum);
    }
  }

  ll ans = -INF;
  for (ll i = n ; i <= 2 * n ; i++) {
    ans = max(ans , pmax[i] - smin[i + 1]);
  }
  printf("%lld\n" , ans);
  return 0;
}

void in(ll &x){
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 12064
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    int day;
    cin >> day;
    
    if(25==day) cout << "Christmas" << endl;
    else if(24==day) cout << "Christmas Eve" << endl;
    else if(23==day) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int main(){
	int a, b, c, cnt = 0;
	std::cin >> a >> b >> c;
	REP(i, a, b + 1){
		if (c % i == 0)++cnt;
	}
	std::cout << cnt << std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
  cin>>n>>m;
  vector<pair<long long,long long > >shop(n);
  for(int i=0,a,b;i<n;i++){
  	cin>>a>>b;
    shop.push_back(make_pair(a,b));
  }
  sort(shop.begin(),shop.end());
  long long items=m;
  long long money = 0;
  for(int i=0;items>0;i++){
  	money+=shop[i].first*min(items,shop[i].second);
    items-=min(items,shop[i].second);
  }
  cout<<money;
}

Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int x[5];



int main () {
    
    
    map<char, int> value;
    // 挿入
    value['I'] = 1;
    value['V'] = 5;
    value['X'] = 10;
    value['L'] = 50;
    value['C'] = 100;
    value['D'] = 500;
    value['M'] = 1000;

    
    
    string roma;
    while(cin>>roma){
        int before = 9999;
        int now = 0;
        int sum = 0;
        
        for(int i=0; i<roma.length(); i++){
            now = value[roma[i]];
            if(before>=now){
                sum+=now;
                before = now;
            }else{
                sum+=now-before*2;
                before = now;
            }
        }
        
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <limits.h>
#define N 8

int CAPACITY[N] = {4, 1, 4, 1, 2, 1, 2, 1};
#define CAPACITY(a,offset) CAPACITY[(a+offset)%N]

int main(void)
{
     int clients[N];

     while(~scanf("%d",clients)){
          int n, min=INT_MAX, minV=INT_MAX, minN;

          for(n=1; n<N; n++) scanf("%d",clients+n);

          for(n=0; n<N; n++){
               int i, t=0, v=0;

               for(i=0; i<N; i++){
                    v = v*10 + CAPACITY(i,n);
                    if(CAPACITY(i,n) < clients[i])
                         t += clients[i] - CAPACITY(i,n);
               }

               if(min>t || (min==t && minV>v))
                    min = t, minV = v, minN = n;
          }

          printf("%d",CAPACITY(0,minN));
          for(n=1; n<N; n++)
               printf(" %d",CAPACITY(n,minN));
          puts("");
     }

     return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

void insertionSort(vector<int> &a, int n, int g, int &cnt){
	int v, j;
	for (int i = g; i < n; i++){
		v = a[i];
		j = i - g;
		while (j >= 0 && a[j] > v){
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j + g] = v;
	}
}

int shellSort(vector<int> &a, vector<int> G, int m, int n){
	int cnt = 0;
	for (int i = 0; i < m; i++){
		insertionSort(a, n, G[i], cnt);
	}
	return cnt;
}

int main(){
	int n, m, cnt;
	cin >> n; 
	vector<int> a(n), G(100);
	for (int i = 0; i < n; i++) cin >> a[i];
	G[0] = 1;
	for (int i = 1; i < 100; i++) G[i] = 3 * G[i - 1] + 1;
	for (m = 0; n >= G[m]; m++);
	reverse(G.begin(), G.begin() + m);
	cout << m << endl;
	for (int i = 0; i < m; i++){
		cout << G[i];
		if (i != m - 1) cout << " ";
	}
	cnt = shellSort(a, G, m, n);
	cout << endl << cnt << endl;
	for (int i = 0; i < n; i++) cout << a[i] << endl;
}

Measured memory_bytes: 6668
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf 9223372036854775807
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int t,a,b,c,n,d,l,r,k;
int h[maxn];
int dp[maxn];

int32_t main(){
io();
IOS;    
		cin>>n;
		for(int i=1;i<=n;i++)cin>>h[i];

		dp[0]=0;
		dp[1]=0;
		h[0]=inf;
		for(int i=2;i<=n;i++){
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		}
		cout<<dp[n]<<endl;

       



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
const long long M=998244353;
#define ri register int 
#define rl register long long
int n,m,i,j,l,r,a,f[1000005],mu[1000005],p[1000005];
long long ans,s[1000005];
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		ans-=a;
		f[a]++;
	}
	for(i=1;i<=1000000;i++)
		mu[i]=1;
	for(i=2;i<=1000000;i++)
		if(p[i]==0)
		{
			for(j=i;j<=1000000;j+=i)
			{
				p[j]=1;
				if(j/i%i==0)
					mu[j]=0;
				mu[j]=-mu[j];
			}
		}
	for(i=1;i<=1000000;i++)
	{
		long long t=qpow(i,M-2);
		for(j=i;j<=1000000;j+=i)
			s[j]=(s[j]+t*mu[j/i])%M;
	}
	for(i=1;i<=1000000;i++)
	{
		long long m=0;
		for(j=i;j<=1000000;j+=i)
			m+=1ll*f[j]*j;
		m%=M;
		ans=(ans+s[i]*m%M*m)%M;
	}
	cout<<(ans*qpow(2,M-2)%M+M)%M;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D)
  {
    cout <<"Balanced" << endl;
  }
  else if (A + B <= C + D)
  {
    cout << "Right" << endl;
  }
  else if (A + B >= C + D)
  {
    cout << "Left" << endl;
  }
}

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

int main () {
    int n; cin >> n;
    int x;
    vector<pair<int, int> > pairs(n);
    for (int i = 0; i < n; i++) {
        cin >> x;
        pairs[i] = make_pair(x, i + 1);
    }
    sort(pairs.begin(), pairs.end());
    for (int i = 0; i < n; i++) {
        printf("%d ",pairs[i].second);
    }
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int A, B; cin >> A >> B;

    cout << (A - 1) * (B - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
double x;

long long N,i,y;
cin >> N;
x=sqrt(N);
for(i=x;x>=1;i--){if(N%i==0)break;
}
y=N/i;
cout << i-1+y-1 << endl;  
return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
const int MAXN = 100 ; 
int F[MAXN][MAXN] ; 
int P[MAXN][MAXN] ; 
int main(){
	int n ; 
	cin >> n ; 
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin >> F[i][j] ; 
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++){
			cin >> P[i][j] ; 
		}
	}
	int res = -1e9 ; 
	for(int mask=1;mask<(1<<10);mask++){
		int ans = 0 ; 
		for(int i=0;i<n;i++){
			int cnt = 0 ; 
			for(int j=0;j<10;j++){
				if ( mask & (1 << j) && F[i][j] ) cnt++ ; 
			}
			ans += P[i][cnt] ; 
		}
		res = max(res,ans) ; 
	}
	cout << res << endl;
    return 0 ;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    string s; cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc") cout << "Yes";
    else cout << "No";
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long A = inputArray[0];
			long B = inputArray[1];

			var FA = Fn(A - 1);
			var FB = Fn(B);
			var ans = FA ^ FB;
			Console.WriteLine(ans); 

		}

		/// <summary>
		/// 0からnまでのF(0,N)を求める
		/// </summary>
		/// <param name="n"></param>
		/// <returns></returns>
		private static long Fn(long n) {

			//偶数個処理する場合
			if ((n+1) % 2 == 0) {
				var ans = ((n + 1) / 2) % 2;
				return ans;
			}
			else {
				var deletepair = n;//0からn-1まで消す
				var a = (deletepair / 2) % 2;

				if (a == 0) {
					return　n;
				}

				if (a == 1 && n % 2 == 1) {
					return n - 1;
				}

				//答えの出力
				return n + 1;


			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 28076
#include "stdio.h"
#include <stdlib.h>
#include <utility>
using namespace std;

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

char N;
int d[10000];

int main(void){
	pair<int, int> d_num_pair[10000];
	int J = 0;

	scanf("%d", &N);

	FOR(i, 0, N-1){
		scanf("%d", &d[i]);
		FOR(j, 0, N-1){
			if(d_num_pair[j].first==0){
				d_num_pair[j].second = d[i];
				d_num_pair[j].first++;
				J = j+1;
				break;
			}else if(d_num_pair[j].second==d[i]){
				d_num_pair[j].first++;
				break;
			}
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x;
    cin>>x;

    if(x>=30){
        cout<<"Yes"<<"\n";
    }

    else{
        cout<<"No"<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

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

        int n = sc.nextInt();

        if (n%2==0){
            System.out.println(n/2 -1);
        }else {
            System.out.println(n/2);
        }

    }
}

Measured memory_bytes: 24276
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        String s = sc.next();
        String t = sc.next();
        long a = sc.nextLong();
        long b = sc.nextLong();
        String u = sc.next();

        // 処理
        if (u.equals(s)) {
            a--;
        } else {
            b--;
        }
        String out = Long.toString(a) + " " + Long.toString(b);

        // 出力
        System.out.println(out);
    }
}

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

using namespace std;

int used[1005][1005];
vector < pair < int, int > > Q;
vector < pair < int, int > > to = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

main(){
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    char t;
    int what = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            cin >> t;
            if (t == '#'){
                used[i][j] = 1;
                what++;
                Q.push_back({i, j});
            }
        }
    }
    int ans = 0;
    while (what != n * m){
        vector < pair < int, int > > add;
        for (auto key : Q){
            int x = key.first, y = key.second;
            int flag = 1;
            for (int j = 0; j < 4; ++j){
                x = key.first + to[j].first, y = key.second + to[j].second;
                if (x >= 1 && x <= n && y >= 1 && y <= m){
                    if (used[x][y] == 0){
                        used[x][y] = 1;
                        what++;
                        add.push_back({x, y});
                    }
                }
            }
        }
        ans++;
        Q = add;
    }
    cout << ans << '\n';
    return 0;
}


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

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

  // ここにプログラムを追記
  int i = 0;
  while (i < A) {
    string b;
    cin >> b;
    if (b == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == A-1) {
      cout << "Three" << endl;
    }
    i++;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;

LL a,b,c,k;

int main() {
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	if(k&1) {
		printf("%lld\n",b-a);
	}
	else {
		printf("%lld\n",a-b);
	}
}

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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] gains = new int[n][3];
        for (int i = 0; i < n; ++i) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            gains[i][0] = a;
            gains[i][1] = b;
            gains[i][2] = c;
        }
//        System.out.println(solve(gains));
        System.out.println(solveIt(gains));
    }

    private static int solve(int[][] gains) {
        int[][] dp = new int[gains.length][3];
        for (int i = 0; i < gains.length; ++i) {
            Arrays.fill(dp[i], -1);
        }
        return Math.max(
                Math.max(
                        findMax(0, 0, gains, dp),
                        findMax(1, 0, gains, dp)),
                findMax(2, 0, gains, dp));
    }

    private static int findMax(int cur, int ind, int[][] gains, int[][] dp) {
        if (ind == gains.length) {
            return 0;
        }
        if (dp[ind][cur] > 0)
            return dp[ind][cur];
        int res;
        if (cur == 0) {
            res = gains[ind][cur] + Math.max(findMax(1, ind + 1, gains, dp), findMax(2, ind + 1, gains, dp));
        } else if (cur == 1) {
            res = gains[ind][cur] + Math.max(findMax(0, ind + 1, gains, dp), findMax(2, ind + 1, gains, dp));
        } else {
            res = gains[ind][cur] + Math.max(findMax(0, ind + 1, gains, dp), findMax(1, ind + 1, gains, dp));
        }
        dp[ind][cur] = res;
        return res;
    }

    private static int solveIt(int[][] gains) {
        int[][] dp = new int[gains.length][3];
        dp[0][0] = gains[0][0];
        dp[0][1] = gains[0][1];
        dp[0][2] = gains[0][2];
        for (int i = 1; i < gains.length; ++i) {
            dp[i][0] = gains[i][0] + Math.max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = gains[i][1] + Math.max(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = gains[i][2] + Math.max(dp[i - 1][0], dp[i - 1][1]);
        }
        return Math.max(dp[gains.length - 1][0], Math.max(dp[gains.length - 1][1], dp[gains.length - 1][2]));
    }
}


Measured memory_bytes: 94172
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N;
    int[] ps;
    private void solve() {
        N = nextInt();
        ps = new int[N];
        for(int i = 0;i < N;i++) {
            ps[i] = nextInt();
        }

        Arrays.sort(ps);

        ps[N - 1] /= 2;
        int sum = 0;
        for(int i = 0;i < N;i++) {
            sum += ps[i];
        }
        out.println(sum);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 24660
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int mod = 998244353;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[3010],num[3010];
int main(){
	n=read();m=read();
	for(register int i=1;i<=n;i++)a[i]=read();
	int ans=0;
	/*for(register int l=1;l<=n;l++){
		for(register int i=1;i<=m;i++)num[i]=0;num[0]=1;
		for(register int r=l;r<=n;r++){	
			for(register int i=m;i>=a[r];i--){
				(num[i]+=num[i-a[r]])%=mod;
			}
			(ans+=num[m])%=mod;
		}
	}*/
	for(register int i=1;i<=n;i++){ 
		for(register int j=m;j>=a[i];j--){
			(num[j]+=num[j-a[i]])%=mod;
			//cerr<<i<<" "<<j<<": "<<f[j]<<endl;
		}
		(num[a[i]]+=i)%=mod;
		(ans+=num[m])%=mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int a_kun,b_kun,times;
  int counta;


  scanf("%d %d %d",&a_kun,&b_kun,&times);

  for(counta=0;counta<times;counta++){
    if((counta%2==0)&&(a_kun%2==1)){
      a_kun--;
      b_kun+=a_kun/2;
      a_kun=a_kun/2;
    }
    else if((counta%2==0)&&(a_kun%2==0)){
      b_kun+=a_kun/2;
      a_kun=a_kun/2;
    }
    if((counta%2==1)&&(b_kun%2==1)){
      b_kun--;
      a_kun+=b_kun/2;
      b_kun=b_kun/2;
    }
    else if((counta%2==1)&&(b_kun%2==0)){
      a_kun+=b_kun/2;
      b_kun=b_kun/2;
    }
  }

  printf("%d %d",a_kun,b_kun);

  return 0;

}

Measured memory_bytes: 128
# coding=utf-8
def reconstruction(left, right):
    global pre_order
    global in_order
    global post_order
    global n

    if left > right:
        return None
    elif left == right:
        root = pre_order.pop(0)
        post_order.append(root)
        return None
    else:
        root = pre_order.pop(0)

    root_pos = in_order.index(root)
    reconstruction(left, root_pos-1)
    reconstruction(root_pos+1, right)
    post_order.append(root)

n = int(input())
pre_order = list(map(int, input().split()))
in_order = list(map(int, input().split()))
post_order = []

reconstruction(0, n-1)
print(*post_order)

Measured memory_bytes: 7744
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			int n=int.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		//昼は11:00 ~ 14:59,
		//夕は18:00~20:59,
		//深夜は21:00~翌01:59
		
		int[] total=new int[3];//0-initialized
		int[] cnt=new int[3];//0-initialized
		
		for(int i=0;i<N;i++){
			var d=Array.ConvertAll(Console.ReadLine().Split(new char[]{' ',':'}),e=>int.Parse(e));
			int m=d[2]-d[1];
			if(m<0)m+=60;
			if(d[0]*60+d[1]>=11*60+0 && d[0]*60+d[1]<=14*60+59){
				total[0]++;
				if(m<=8)cnt[0]++;
			}
			if(d[0]*60+d[1]>=18*60+0 && d[0]*60+d[1]<=20*60+59){
				total[1]++;
				if(m<=8)cnt[1]++;
			}
			if(d[0]*60+d[1]>=21*60+0 && d[0]*60+d[1]<=23*60+59){
				total[2]++;
				if(m<=8)cnt[2]++;
			}
			if(d[0]*60+d[1]>=0*60+0 && d[0]*60+d[1]<=1*60+59){
				total[2]++;
				if(m<=8)cnt[2]++;
			}
		}
		Console.WriteLine("lunch "   +(total[0]==0?"no guest":(100*cnt[0]/total[0]).ToString()));
		Console.WriteLine("dinner "  +(total[1]==0?"no guest":(100*cnt[1]/total[1]).ToString()));
		Console.WriteLine("midnight "+(total[2]==0?"no guest":(100*cnt[2]/total[2]).ToString()));
		
	}

	int N;
	public Sol(int n_){
		N=n_;
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5800
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n; long double px[200], py[200], pz[200], vx[200], vy[200], vz[200], r[200], vr[200], dist[200][200];
vector<int>I; bool used[200]; long double rets[200];
long double dst(long double rx, long double ry, long double rz, long double sx, long double sy, long double sz) {
	return sqrtl((rx - sx)*(rx - sx) + (ry - sy)*(ry - sy) + (rz - sz)*(rz - sz));
}
long double search(int p1, int p2, long double t) {
	return dst(px[p1] + vx[p1] * t, py[p1] + vy[p1] * t, pz[p1] + vz[p1] * t, px[p2] + vx[p2] * t, py[p2] + vy[p2] * t, pz[p2] + vz[p2] * t) - (max(0.0l, r[p1] - vr[p1] * t) + max(0.0l, r[p2] - vr[p2] * t));
}
long double solve(int p1, int p2) {
	if (p1 == p2)return 1e9;
	long double L = 0.0l, R = 1000000.0l, c1, c2, ret = 1000000.0l;
	for (int i = 0; i < 70; i++) {
		c1 = (L + L + R) / 3.0l; c2 = (L + R + R) / 3.0l;
		long double H1 = search(p1, p2, c1), H2 = search(p1, p2, c2);
		if (H1 < H2)R = c2; if (H1 > H2)L = c1; ret = min(ret, min(H1, H2));
	}
	L = 0.0l, R = (c1 + c2) / 2.0l; long double M, mx = 1000000.0l;
	for (int i = 0; i < 120; i++) {
		M = (L + R) / 2.0l;
		long double H1 = search(p1, p2, M);
		if (H1 > 0)L = M; if (H1 < 0)R = M; mx = min(mx, H1);
	}
	if (M > min(r[p1] / vr[p1], r[p2] / vr[p2]) || mx > 0.0l)return 1e9;
	return M;
}
int main() {
	while (true) {
		cin >> n; if (n == 0)break; for (int i = 0; i < n; i++) { used[i] = false; } for (int i = 0; i < n; i++) { cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i]; }
		for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++)dist[i][j] = 1e12; }
		while (true) {
			I.clear(); for (int i = 0; i < n; i++) { if (used[i] == false)I.push_back(i); }
			long double Y = 1000000.0l; if (I.size() == 0)break;
			for (int i : I) {
				for (int j : I) { if (dist[i][j] == 1e12)dist[i][j] = min(solve(i, j), r[i] / vr[i]); Y = min(Y, dist[i][j]); }
			}
			for (int i : I) { for (int j : I) { if (dist[i][j] == Y || (r[i] / vr[i]) == Y) { used[i] = true; rets[i] = Y; } } }
		}
		for (int i = 0; i < n; i++) { printf("%.20Lf\n", rets[i]); }
	}
	return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int arr[100005][3];
int dp[100005][3];
int main(){
	int n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(int i =0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
		
	}
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+arr[i][2];
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

return 0;
}

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

int main()
{
    int A, B;
    int ans;
    char cal;
    
    cin >> A >> cal >> B;
    
    if(cal == '+')
    {
        ans = A + B;
    }
    else if(cal == '-')
    {
        ans = A - B;
    }
    
    cout << ans << endl; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a1 = scanner.nextInt();
		int min = a1;
		int max = a1;
		for (int i=1; i<n; i++){
			int a = scanner.nextInt();
			min = Math.min(min, a);
			max = Math.max(max, a);
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 21844
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, K = sc.nextInt()
    val H = Array.fill(N)(sc.nextInt()).sorted

    var l = 1
    var r = K
    var min = H(K - 1) - H(0)
    while (r < N) {
      min = Math.min(min, H(r) - H(l))
      l += 1
      r += 1
    }
    println(min)
  }

}

Measured memory_bytes: 56596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long a,b;
    cin>>a>>b;
    if((a+b)%2!=0)
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    else
    {
        cout<<(a+b)/2<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC136
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            WriteLine(Max(0,s[2]-(s[0]-s[1])));
        }
    }
}


Measured memory_bytes: 11220
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4|| n == 5|| n == 7|| n == 9) {
        print("hon");
    } else     if (n == 0 || n == 1|| n == 6|| n == 8) {
        print("pon");
    } else {
        print("bon");
    }

    return 0;
}


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

int main(void){
  char buf[32] = { 0 };
  int num_500 = 0;
  int num_100 = 0;
  int num_50 = 0;
  int price = 0;
  
  //入力読み込み
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &num_500);
 
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &num_100);
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &num_50);
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &price);
  
  int count = 0; //支払い方法
  int prc_no_500 = price;
  int i = 0;
  
  while(i <= num_500 && prc_no_500 >= 0){    
    int j = 0;
    int prc_no_100 = prc_no_500;
    
    while(j <= num_100 && prc_no_100 >= 0){      
      if(prc_no_100 % 50 == 0 && prc_no_100 / 50 <= num_50) count++;     
      j++;
      prc_no_100 = prc_no_500 - 100 * j;
    }    
    i++;
    prc_no_500 = price - 500 * i;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1720
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
# last sum
if k > (n-1)*(n-2)//2:
    print("-1")
else:
    es = []
    cur = (n-1)*(n-2)//2-k
    for c in range(2, n+1):
        for d in range(2, n+1):
            if c < d and cur > 0:
                es.append((c, d))
                cur -= 1
    for i in range(1, n):
        es.append((1, i+1))
    print(len(es))
    for e in es:
        print(e[0], e[1])


Measured memory_bytes: 45680
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, t;
    cin >> a >> b >> t;
    cout << t/a*b << endl;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] input = reader.readLine().split(" ");
            int w = Integer.parseInt(input[0]), h = Integer.parseInt(input[1]);
            if(w==0 || h==0){
                return;
            }
            int[][] verticalWalls = new int[w-1][h], horizontalWalls = new int[w][h-1], cells = new int[w][h];

            input = reader.readLine().trim().split(" ");

            for(int j=0; j<w-1; j++){
                verticalWalls[j][0] = Integer.parseInt(input[j]);
            }

            for(int i=0; i < h-1; i++){
                input = reader.readLine().trim().split(" ");
                for(int j=0; j<w; j++){
                    horizontalWalls[j][i] = Integer.parseInt(input[j]);
                }

                input = reader.readLine().trim().split(" ");

                for(int j=0; j<w-1; j++){
                    verticalWalls[j][i+1] = Integer.parseInt(input[j]);
                }
            }
            for(int i=0; i<w; i++){
                for(int j=0; j<h; j++){
                    cells[i][j] = w * h + 1;
                }
            }
            search(verticalWalls, horizontalWalls, cells, 0, 0, 1);
            System.out.println((cells[w-1][h-1]==w*h+1)?0:cells[w-1][h-1]);
        }
    }

    public static void search(int[][] verticalWalls, int[][] horizontalWalls, int[][] cells, int x, int y, int value){
        if(x>verticalWalls.length || y>horizontalWalls[0].length){
            return;
        }
        if(cells[x][y] > value){
            cells[x][y] = value;
            if(x<verticalWalls.length && verticalWalls[x][y]==0){
                search(verticalWalls, horizontalWalls, cells, x + 1, y, value + 1);
            }

            if(x>0 && verticalWalls[x-1][y]==0){
                search(verticalWalls, horizontalWalls, cells, x - 1, y, value + 1);
            }

            if(y<horizontalWalls[0].length && horizontalWalls[x][y]==0){
                search(verticalWalls, horizontalWalls, cells, x, y + 1, value + 1);
            }

            if(y>0 && horizontalWalls[x][y-1]==0){
                search(verticalWalls, horizontalWalls, cells, x, y - 1, value + 1);
            }
        }
    }
}

Measured memory_bytes: 51632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll X; cin >> X;
    ll s = 100;
    ll ans = 0;
    for(int i = 0; i < 10000; ++i){
        ld tmp = (ld)s * 1.01;
        s = tmp;
        if(s >= X){
            ans = i;
            break;
        }
    }
    cout << ans+1 << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	//入力機構
	size_t N,M;
	int X,Y;
	std::cin>>N>>M>>X>>Y;
	std::vector<int> x(N,0);
	std::vector<int> y(M,0);
	for(size_t i=0;i<N;i++){
		std::cin>>x[i];
	}
	for(size_t i=0;i<M;i++){
		std::cin>>y[i];
	}

	//処理機構
	//(Xとx[i]の最大値)<(Yとy[i]の最小値)であれば、Zは存在する
	//逆に、この条件を満たさない場合Zは存在しない
	x.push_back(X);
	y.push_back(Y);
	const int xmax=*(std::max_element<std::vector<int>::iterator>(x.begin(),x.end())),ymin=*(std::min_element<std::vector<int>::iterator>(y.begin(),y.end()));

	//出力機構
	std::cout<<(xmax<ymin?"No War":"War")<<std::endl;

	return 0;
}

Measured memory_bytes: 256
//In the name of Allah
// #isart
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair<int, int>
#define MP make_pair

using namespace std;

const int MAXN = 2000 + 10;
ll dp[MAXN][MAXN], INF = -1e9, mod = 1e9 + 7;
int k;

int calc(int x, int y){
	if(dp[x][y] != -INF) return dp[x][y];
	dp[x][y] = 0;
	for(int i = 0; i <= min(k - 1, x); i ++){
		if(y >= k - 1 - i){
			dp[x][y] = (dp[x][y] + calc(x - i, y - (k - 1 - i))) % mod;
		}		
	}
	return dp[x][y];
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m, ans = 0; 
	cin >> n >> m >> k; n --;
	for(int i = 0; i <= n; i ++)
		for(int j = 0; j <= m; j ++)
			dp[i][j] = -INF;
	dp[0][0] = 1;
	calc(n, m);
	for(int j = m; j > 0; j -= k - 1){
		ans = (ans + dp[n][j]) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	map<int, llong> m{};
	int N;
	cin >> N;
	llong sum = 0;
	vector<llong> A(N);
	for(int i=0; i<N; ++i){
		cin >> A[i];
		sum += A[i];
		++m[A[i]];
	}
	int Q;
	cin >> Q;
	vector<llong> B(Q);
	vector<llong> C(Q);
	for(int i=0; i<Q; ++i) cin >> B[i] >> C[i];
	for(int i=0; i<Q; ++i){
		if(m[B[i]]!=0){
			sum -= B[i]*m[B[i]];
			sum += C[i]*m[B[i]];
			m[C[i]] += m[B[i]];
			m[B[i]] = 0;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 11244
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;
 
int n, A[MAX], s;
int B[MAX], T[VMAX + 1];
 
int solve() {
  int ans = 0;
 
  bool V[MAX];
  for ( int i = 0; i < n; i++ ) {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B + n);
  for ( int i = 0; i < n; i++ ) T[B[i]] = i;
  for ( int i = 0; i < n; i++ ) {
    if ( V[i] ) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while ( 1 ) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if ( V[cur] ) break;
    }
    ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
  }
  return ans;
}
 
int main() {
  cin >> n;
  s = VMAX;
  for ( int i = 0; i < n; i++ ) {
    cin >> A[i];
    s = min(s, A[i]);
  }
  int ans = solve();
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3180
import numpy as np

N,M,C = map(int,input().split())
B = np.array(list(map(int,input().split())))

count=0

for i in range(N):
    A = np.array(list(map(int,input().split())))
    if np.sum(A*B)+C>0:
        count = count+1

print(count)

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

#define reg register
typedef long long ll;
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)

char IO;
int rd(){
	int s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=810;
const int z[5][4]={{0,1},{0,-1},{1,0},{-1,0}};

int n;
double a[N];
double s;

int main(){
	n=rd();
	rep(i,1,n) a[i]=rd();
	sort(a+1,a+n+1);
	rep(i,2,n) a[i]=(a[i]+a[i-1])/2.0;
	printf("%.6lf\n",a[n]);
}









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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string a;
    cin >> a;
    if (a == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1) {
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
long long n,c,value;
long long f[101][100001];
long long v[101],w[101];
int main()
{
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
		value+=v[i];
	}
	for(int j=1;j<=value;j++)
		f[0][j]=(long long)10e11+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=value;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=v[i])
				f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
		}
	for(int i=value;i>=1;i--)
	{
		if(f[n][i]<=c)
		{
			printf("%d",i);
			break;
		}
	}
}

Measured memory_bytes: 79104
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	ans := (n / (a + b)) * a
	mod := n % (a + b)
	if mod < a {
		ans += mod
	} else {
		ans += a
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int a , b;
int main()
{
    IOS
    //freopen("planet.in", "r", stdin);
    cin >> a >> b;
    if (a < 6) {
        cout << 0 << endl;
    } else if (a >= 6 && a <= 12) {
        cout << (b>>1) << endl;
    } else {
        cout << b << endl;
    }


    return 0;
}


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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long t,x;
  cin >> t >> x;
  cout << (double)t/x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    void solve() {
        long X = in.nextLong();
        long t = in.nextLong();
        if (t >= X) {
            out.println(0);
        } else {
            out.println(X - t);
        }
    }


    FastScanner in;
    PrintWriter out;

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

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

}

Measured memory_bytes: 21332
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int a, b;
int n;
/**********************************************/

int main(){
   
    cin >> n;
    int num1 = n/1000;
    int num2 = n % 10;
    int num3 = (n/10)% 10;
    int num4 = (n/100)% 10;
    if((num1 == num3 && num1 == num4) || (num2 == num3 && num2 == num4)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = input()
    a = 0
    b = int(s)
    
    for i in s:
        a += int(i)
        
    if b % a ==0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 5144
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int v[100005],n,x;
int main()
{
	scanf("%d",&n);
	mem(v);
	int maxn=0;
	while(n--)
	{
		scanf("%d",&x);
		v[x]++,maxn=max(maxn,v[x]);
		v[x+1]++,maxn=max(maxn,v[x+1]);
		if(x-1>=0) v[x-1]++,maxn=max(maxn,v[x-1]);
	}
	printf("%d\n",maxn);
	return 0;
}

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

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<ll> b(m);
  rep(i,m) cin >> b[i];
  
  int ans = 0;
  rep(i,n){
    vector<ll> a(m);
    rep(j,m) cin >> a[j];
    int sum = 0;
    rep(k,m) sum += b[k]*a[k];
    if(sum+c>0) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
a,b,c,d,e,f=gets.split.map &:to_i
w=[];s=[]
(0..f).map{|i|(0..f).map{|j|
	x=(a*i+b*j)*100
	y=c*i+d*j
	w<<x if x<=f
	s<<y if y<=f
}}
g=[]
w.map{|i|s.map{|j|
	g<<[j*100.0/(i+j),i+j,j] if 0<i+j&&i+j<=f&&j<=i*e/100.0
}}
g=g.max
puts g[1..-1]*' '

Measured memory_bytes: 122748