akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

using namespace std;

int a[19];
int b[19];
int dp[1 << 19][19];

int main() {
    int n, ans = 1e9, i, j, k;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (i = 1; i <= n; i++) scanf("%d", &b[i]);
    
    n++;
    
    for (i = 0; i < (1 << n); i++) {
        for (j = 0; j < n; j++) {
            dp[i][j] = 1e9;
        }
    }
    
    dp[1][0] = 0;
    
    for (i = 0; i < (1 << n); i++) {
        for (j = 0; j < n; j++) {
            int x;
            
            if (dp[i][j] == 1e9) continue;
            
            if (__builtin_popcount(i) % 2 == j % 2) {
                x = b[j];
            } else {
                x = a[j];
            }
            
            for (k = 0; k < n; k++) {
                int y, c;
                
                if ((i >> k) & 1) continue;
                
                if (__builtin_popcount(i) % 2 == k % 2) {
                    y = a[k];
                } else {
                    y = b[k];
                }
                
                if (x > y) continue;
                
                c = k - __builtin_popcount(i & ((1 << k) - 1));
                
                dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + c);
            }
        }
    }
    
    for (i = 0; i < n; i++) ans = min(ans, dp[(1 << n) - 1][i]);
    
    if (ans == 1e9) ans = -1;
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 39040
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

signed main(){
    int n;
    cin>>n;
    
    vector<int> c(5,0);
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='M')c[0]++;
        if(s[0]=='A')c[1]++;
        if(s[0]=='R')c[2]++;
        if(s[0]=='C')c[3]++;
        if(s[0]=='H')c[4]++;
    }
    
    ll ans = 0;
    rep(i,5){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans += c[i]*c[j]*c[k];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    int ret = 0;
    rep(i,n){
        int x = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        int y = c.end() - upper_bound(c.begin(),c.end(),b[i]);
        ret += x*y;
    }
    cout << ret << endl;
    return 0;
}

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


int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}

int main()
{
int n,k,i,p[1001],sum;
  scanf("%d %d",&n,&k);

  for (i=0;i<n;i++)
  {
  	scanf("%d",&p[i]);
  }
  
  qsort(p,n,sizeof(int),cmp);
  
  sum=0;
  for(i=0;i<k;i++)
  {
  sum+=p[i];
  }
  
  printf("%d",sum);
  
  return 0;
  
}


Measured memory_bytes: 2216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] tmpArray = br.readLine().split(" ");

		double[] input = new double[n];
		for(int i = 0; i < n; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}

		Arrays.sort(input);

		for(int i = 1; i < n; i++){
			input[i] = (input[i] + input[i - 1])/2;
		}

		System.out.printf("%.6f\n", input[n - 1]);
	}

}


Measured memory_bytes: 21460
// 復習2
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

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

    int n, m; cin >> n >> m;
    vector<bool> isSafe(n, true);
    for (int i = 0; i < m; ++i) {
        int a; cin >> a;
        isSafe[a] = false;
    }

    vector<int> dp(n+1);
    dp[0] = 1;
    dp[1] = (isSafe[1] ? 1 : 0);
    for (int i = 2; i <= n; ++i) {
        if (isSafe[i]) {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, q, a, b, s, x;
vector<ll> v(100005);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> x;
		++v[x];
		s += x;
	}
	cin >> q;
	while (q--)
	{
		cin >> a >> b;
		s -= (v[a] * a);
		s += (v[a] * b);
		v[b] += v[a], v[a] = 0;
		cout << s << "\n";
	}
	return 0;
}


Measured memory_bytes: 3836
a,b,k = (int(i) for i in input().split())
ct = 0
ans= []
for i in range(101):
  if i!= 0:
    if a%i == 0 and b%i == 0:
      ct += 1
      ans.append(i)
ans = sorted(ans,reverse = True)
print(ans[k-1])

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

int main() {
  int N;
  string s;
  cin >> N >> s;
  
  int R=0,B=0;
  for(int i=0; i<N; i++){
    if(s.at(i) == 'R') R++;
    else B++;
  }
  if(R>B) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	cout << x2 + y1 - y2 << ' ' << y2 + x2 - x1 << ' ' << x1 + y1 - y2 << ' ' << y1 + x2 - x1 << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer>[] g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < m; i++) {
			int v = sc.nextInt() - 1;
			int u = sc.nextInt() - 1;
			g[v].add(u);
		}
		int s = sc.nextInt() - 1;
		int t = sc.nextInt() - 1;
		int[][] d = new int[n][3];
		for (int i = 0; i < d.length; i++) {
			Arrays.fill(d[i], Integer.MAX_VALUE);
		}

		Queue<int[]> q = new LinkedList<>();
		q.offer(new int[]{s, 0});
		d[s][0] = 0;

		while (!q.isEmpty()) {
			int[] vx = q.poll();
			int v = vx[0];
			int state = vx[1];
			int next = (vx[1] + 1) % 3;
			for (int i = 0; i < g[v].size(); i++) {
				if (d[g[v].get(i)][next] != Integer.MAX_VALUE) continue;
				d[g[v].get(i)][next] = d[v][state] + 1;
				q.offer(new int[]{g[v].get(i), next});
			}
		}

		if (d[t][0] == Integer.MAX_VALUE) {
			System.out.println(-1);
			return;
		}

		System.out.println(d[t][0] / 3);
	}
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a.at(i);

    rep(i, h)
    {
        bool is_all_white = true;
        rep(j, w)
        {
            if (a.at(i).at(j) == '#')
            {
                is_all_white = false;
            }
        }
        if (is_all_white)
        {
            rep(j, w)
            {
                a.at(i).at(j) = '-';
            }
        }
    }
    rep(j, w)
    {
        bool is_all_white = true;
        rep(i, h)
        {
            if (a.at(i).at(j) == '#')
            {
                is_all_white = false;
            }
        }
        if (is_all_white)
        {
            rep(i, h)
            {
                a.at(i).at(j) = '-';
            }
        }
    }

    int answer = 0;
    rep(i, h)
    {
        bool is_write = false;
        rep(j, w)
        {
            if (a.at(i).at(j) != '-')
            {
                cout << a.at(i).at(j);
                is_write = true;
            }
        }
        if (is_write)
        {
            cout << endl;
        }
    }
}

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

#define fs first
#define sc second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    cout << 3*r*r << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

#+++++
		
def main():
	n = int(input())
	t , a = map(int, input().split())
	hl = list(map(int, input().split()))
	get_t=lambda x : t - x * 0.006
	get_e=lambda x : abs(a-get_t(x))
	
	mv=None
	mi=None
	
	for i,h in enumerate(hl):
		mm= get_e(h)
		if mv is None or mm < mv:
			mv = mm
			mi = i
	
	print(mi+1)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

#pragma GCC optimize ("Ofast")
//common
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,n) for(int i=0;i<n;i++)
#define Afor(i,v) for(auto i:(v))
//#define bfor(i,a,b) for(int i=a;i<b;i++)
//#define rfor(i,n) for(int i=n-1;i>=0;i--)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define vect(v,n) int (n); cin>>(n); vector <int> v(n); for(int i=0;i<(n);i++) cin>>v[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz(v) (v).size()
//#define sortv(v)  sort((v).begin(),(v).end())
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)   (v).erase(unique(all(v)),(v).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())
//equal range can also be used

typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;

/*/-----------------------------Code begins----------------------------------/*/
int main(){
    fio;
string s;
cin>>s;
//  2019/12/30
if(s[5]=='1')
    cout<<"TBD";
else {
    if(s[6]<='4')
        cout<<"Heisei";
    else cout<<"TBD";
}
    //Heisei
    return 0;}













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

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int sum = b*1900 + (a-b)*100;
	int c = pow(2, b);
	printf("%d\n", (sum*(c)));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 9
#define S 172
using namespace std;
int n,a[N],b[N];
double ans1,ans2;
int dp[(1<<N)][10][S];
 
int main(){
  cin>>n;
  while(n--){
    for(int i=0;i<N;i++)cin>>a[i];
    for(int i=0;i<N;i++)cin>>b[i];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<(1<<N);i++){
      for(int j=0;j<N;j++){
    if(__builtin_popcount(i)!=j)continue;
    for(int k=0;k<S;k++){
      if(!dp[i][j][k])continue;
      for(int l=0;l<N;l++){
        if(i&(1<<l))continue;
        if(a[l]<b[j]){
          dp[(i|(1<<l))][j+1][k+a[l]+b[j]]+=dp[i][j][k];
        }else dp[(i|(1<<l))][j+1][k]+=dp[i][j][k];
      }
    }
      }
    }
    ans2=1;
    for(int i=1;i<=9;i++)ans2*=i;
    ans1=0;
    for(int i=86;i<S;i++)ans1+=dp[(1<<N)-1][N][i];
    ans1/=ans2;
    printf("%.5f %.5f\n",(1-ans1),ans1);
  }
  return 0;
}

Measured memory_bytes: 4636
function Main(input) {
    tmp = input.split("\n");
    n = parseInt(tmp[0], 10);
    tmp2 = tmp[1];
    l = tmp2.split(" ");
    result = 0;

    if (n < 3) {
    } else{

        for (let i = 0; i < l.length - 2; i++) {
            base = parseInt(l[i], 10);
            for (let j = i + 1; j < l.length - 1; j++) {
                check1 = parseInt(l[j], 10);
               
                if (base != check1) {
                    for (let k = j + 1; k < l.length; k++) {
                        check2 = parseInt(l[k], 10);
                        if ( base != check2 && check1 != check2) {
                            if (base + check1 > check2 && check1 + check2 > base && check2 + base > check1) {
                                result += 1;

                            }
                        }
                    }
                }
            }
        }
    }

    console.log(result);
    

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32480
k,n = map(int,input().split())
n_inf = list(map(int,input().split()))
#n_inf.append(k)
#n_inf.insert(0,0)
kyori_list = [j for j in range(n-1)]
for i in range(n-1):
  kyori_list[i] = n_inf[i+1]-n_inf[i]
#print(kyori_list)
kyori_list.append((n_inf[0])+(k-n_inf[n-1]))
#print(kyori_list)
kyori_list.sort(reverse=1)
print(sum(kyori_list[1:n+1]))

Measured memory_bytes: 25836
#include<iostream>

using namespace std;

#define rep(i,n) for(i=0;i<(n);i++)
#define For(i,a,b) for(i=(a);i<(b);i++)



int main(){
  int i,j,k;

  i=1;
  while(cin >> j,j){
    cout << "Case " << i << ": " << j << endl;
    i++;
  }
  
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib> //func147bでインクルード
#include <vector>  //func146b
using namespace std;
 
void func140b() {
    int n, a, b, c;
 
    cin >> n;
    vector<int> v1;
    vector<int> v2;
    vector<int> v3;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        v1.emplace_back(a);
    }
    for (int i = 0; i < n; ++i) {
        cin >> b;
        v2.emplace_back(b);
    }
    for (int i = 0; i < n - 1; ++i) {
        cin >> c;
        v3.emplace_back(c);
    }
    int num = v2[v1[0] - 1];
    for (int i = 1; i < n; ++i) {
        num += v2[v1[i] - 1];
        if (v1[i] == v1[i - 1] + 1) num += v3[v1[i - 1] - 1];
    }
    cout << num << endl;
}
int main()
{
  func140b();
  return 0;
}

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

typedef long long ll;
const int maxn=1e5+10;
int n,k,a[maxn];
ll sum[maxn],b[maxn],c[maxn],ans;

inline void chkmax(ll&a,ll b){if(a<b)a=b;}

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+a[i],b[i]=a[i]>0?b[i-1]+a[i]:b[i-1];
	for(int i=n;i;--i)
		c[i]=a[i]>0?c[i+1]+a[i]:c[i+1];
	for(int i=0;i+k<=n;++i){
		chkmax(ans,b[i]+c[i+k+1]);
		chkmax(ans,b[i]+c[i+k+1]+sum[i+k]-sum[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  ll cu;
  vll ans(0);
  for(int i=1;;i++){
    if(i*(i+1)/2>=n){
      cu=i;
      break;
    }
  }
  ll k=cu*(cu+1)/2-n;

  for(int i=1;i<=cu;i++){
    if(i==k) continue;
    COUT(i);
  }
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/nomura2020/tasks/nomura2020_d
#include<bits/stdc++.h>
using namespace std;
#define nn 5008
#define mod 1000000007
#define int long long 
vector<int> v[nn];int n,pa[nn];
int unknown[nn];int og[nn];
int find(int x){
	if(pa[x]==x) return x;
	return pa[x]=find(pa[x]);	
}
void link(int x,int y){
	pa[find(x)]=find(y);
}
int qpow(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
void add(int&x,int y){
	x=(x+y)%mod;
}

int dp[nn],sze[nn],ans,f[nn];;
signed main(){
	f[0]=1;for(int i=1;i<nn;i++) f[i]=f[i-1]*i%mod;
	scanf("%lld",&n);for(int i=1;i<=n;i++) pa[i]=i;int uk=0;
	for(int i=1;i<=n;i++){
		int pp;scanf("%lld",&pp);
		if(pp==-1) og[i]=1,uk++;
		else link(pp,i);
	}
	for(int i=1;i<=n;i++) unknown[find(i)]+=og[i],sze[find(i)]++;
	for(int i=1;i<=n;i++) if(i==find(i) and !unknown[i]) ans+=qpow(n-1,uk),ans%=mod;
	vector<int> dope;
	for(int i=1;i<=n;i++) if(find(i)==i and unknown[i]) dope.push_back(sze[i]),add(ans,(sze[i]-1)*qpow(n-1,uk-1));
	
	
	dp[0]=1;for(int i=0;i<dope.size();i++) for(int j=nn-2;j>=0;j--) add(dp[j+1],dp[j]*dope[i]);
	
	for(int i=2;i<nn;i++) add(ans,dp[i]*f[i-1]%mod*qpow(n-1,uk-i));
			
		
	ans=qpow(n-1,uk)*n-ans;ans%=mod;ans+=mod;ans%=mod;cout<<ans;
	return 0;
} 

Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
using arr = array<ll, 3>;

int main() {
    init();
    ll N;
    cin >> N;
    vc<arr> A(N);
    vl ans(N + 1, INF);

    rep(i, N) cin >> A[i][0] >> A[i][1] >> A[i][2];

    vl tmp(N);
    rep(i, N) tmp[i] = min(abs(A[i][0]), abs(A[i][1])) * A[i][2];

    auto dfs = [&](auto&& dfs, string s, vl C) -> void {
        if(s.size()==N){
            ll cnt = 0;
            rep(i, N) cnt += (s[i] != '0');
            chmin(ans[cnt], accumulate(all(C), 0ll));
            return;
        }

        dfs(dfs, s + '0', C);

        ll n = s.size();
        vl D = C;
        rep(i, N) chmin(D[i], abs(A[i][0] - A[n][0]) * A[i][2]);
        dfs(dfs, s + '1', D);

        rep(i, N) chmin(C[i], abs(A[i][1] - A[n][1]) * A[i][2]);
        dfs(dfs, s + '2', C);
        return;
    };

    dfs(dfs, "", tmp);

    rep(i, N + 1) cout << ans[i] << endl;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;
int main(void)
{
	int N;
	cin >> N;

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


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

pair<int,int> directions[8]={{-1,-1},{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0}} ;

bool valid(int x,int y,int h,int w){
	return x>=0 && y>=0 && x<h && y<w ;
}

void solve(){
	
	int h,w ;
	cin>>h>>w ;

	char arr[h][w] ;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>arr[i][j] ;
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){

			if(arr[i][j]!='#'){	
				int count=0 ;
			for(auto dir:directions){

				int r=i+dir.first ;
				int c=j+dir.second ;

				if(valid(r,c,h,w) && arr[r][c]=='#')
					count++ ;

			}

			arr[i][j]=count+'0' ;

			}
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<arr[i][j] ;
		}
		cout<<"\n" ;
	}


}	

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char last = '-';
    for (auto &i : s) {
        if (last == i) continue;
        ++ans;
        last = i;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	int x;
	cin>>x;
	if(x==0)cout<<1;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ps push_back
#define fi first
#define so second
#define mod 1000000007
int r,s,p;
    string m;
int gain(char a,char b)
{
    if(a=='r' && b=='s') return r;
    if(a=='p' && b=='r') return p;
    if(a=='s' && b=='p') return s;
    return 0;
}

signed main()
{
    int n,i,j,l;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int s=0,z=0;
    for(i=0;i<n;i++)
    {
        for(j=i+2;j<n;j++)
        {
            //cout<<"upper_bound for "<<a[i]<<","<<a[j]<<endl;
            l = (upper_bound(a+i,a+j,a[j]-a[i])-a);
            //cout<<l<<endl;
            if(l==i || a[l]==a[j]-a[i]) {l++;}
            s+=max(z,j-l);
        }
    }
    cout<<s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;

ll fastpowMOD(ll a, ll p,ll MOD);
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; a %= MOD; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }

ll lcm(ll a,ll b){
	return (a*b)/__gcd(a,b);
}



int main(){
	fastio;
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n,0);
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	ll mm = 0;
	for(ll i=0;i<n-k;i++){
		mm += a[i];
	}
	cout<<mm<<"\n";
	
}


















Measured memory_bytes: 1792
// https://atcoder.jp/contests/agc030/tasks/agc030_b
//
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::fmt::*;
use std::io::*;
use std::str::*;

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

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

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

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

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

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

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

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

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

fn solve(x: Vec<u64>, all: u64) -> u64 {
    let n = x.len();
    if n == 1 {
        return x[0];
    }
    let mut ldsum = 0;
    let mut rdsum = 0;
    let mut left = vec![];
    let mut right = vec![];
    {
        let mut l = 0;
        let mut r = n - 1;
        while l <= r {
            left.push(x[l]);
            ldsum += x[l];
            if l != r {
                right.push(x[r]);
                rdsum += all - x[r];
            }
            l += 1;
            r -= 1;
        }
    }
    let mut ans = 0;

    let mut rt = right.len();
    for lh in 0..n {
        if lh >= 1 {
            ldsum -= left[lh - 1];
        }
        let mut lcnt = left.len() - lh;
        let mut rcnt = rt;
        if lcnt < rcnt {
            left.push(right[rt - 1]);
            rdsum -= all - right[rt - 1];
            ldsum += right[rt - 1];
            rt -= 1;
            lcnt += 1;
            rcnt -= 1;
        }
        let mut distances = 0;
        if lcnt == rcnt {
            // last = R
            distances += (ldsum + rdsum) * 2;
            distances -= all - right[rt - 1];
        } else if lcnt == rcnt + 1 {
            // last = L
            distances += (ldsum + rdsum) * 2;
            let ll = left.len();
            distances -= left[ll - 1];
        } else {
            panic!("arien");
        }
        ans = max(ans, distances);
    }
    ans
}

fn main() {
    input! {
        l: u64, n: usize,
        x: [u64; n]
    };

    let mut revx = vec![0; n];
    for i in 0..n {
        revx[i] = l - x[n - 1 - i];
    }

    let ans = max(solve(x, l), solve(revx, l));
    println!("{}", ans);
}


Measured memory_bytes: 14588
let n=read_int()open Array;;let a=init n(fun _->Scanf.scanf"%d "(fun e->e))and b=make n 0and c=make 10001 0;;iter(fun e->c.(e)<-c.(e)+1)a;iteri(fun i _->if i<>0then c.(i)<-c.(i)+c.(i-1))c;for i=n-1downto 0do b.(c.(a.(i))-1)<-a.(i);c.(a.(i))<-c.(a.(i))-1;done;print_int b.(0);for i=1to n-1do print_string" ";print_int b.(i);done;print_newline()

Measured memory_bytes: 36168
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

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

int main(){

  ll N;
  cin >> N;
  ll ans = 0;

  for (ll i = 1; i < N; i++) {
    ans += i;
  }

  cout << ans << endl;

  return 0;
}

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

// #define ff              first
// #define ss              second
// #define int             long long
// #define pb              push_back
// #define mp              make_pair
// #define pii             pair<int,int>
// #define vi              vector<int>
// #define mii             map<int,int>
// #define pqb             priority_queue<int>
// #define pqs             priority_queue<int,vi,greater<int> >
// #define setbits(x)      __builtin_popcountll(x)
// #define zrobits(x)      __builtin_ctzll(x)
// #define mod             1000000007
// #define inf             1e18
// #define ps(x,y)         fixed<<setprecision(y)<<x
// #define mk(arr,n,type)  type *arr=new type[n];
// #define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}




int32_t main() {


	int n ;
	cin >> n;

	int o = 0 ;
	for (int i = 1 ; i <= n ; i++) {
		if (i & 1) {
			o++;
		}
	}
	
	float ans = o / (1.0 * n) ;
	cout << ans;



	return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define all(a) (a.begin(),a.end())

using ll = long long;
using namespace std;
template<typename... Args>
void read(Args&... args)
{((cin >> args), ...);}

template<typename... Args>
void write(Args... args)
{((cout << args << " "), ...);}

template<typename... Args>
void writeln(Args... args)
{((cout << args << " "), ...); cout << "\n";}

template<typename T>
void read(vector<T> &a)
{for (auto &ele : a) cin >> ele;}

template<typename T>
void writeln(vector<T> &a)
{for (auto &ele : a) cout << ele << ' '; cout << "\n";}

const pii dxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
const pii fxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, { -1, -1}, { -1, 1}, {1, -1}};



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(false);
//	int t;cin >> t;while(t--) solve();
	string s;
	read(s);
	if (s.back() == 's') {
		writeln(s + "es");
	} else writeln(s + 's');
	return 0;
}



Measured memory_bytes: 3568
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    [a, b]<- words <$> getContents
    if a < b then putStrLn "<"
    else if a > b then putStrLn ">"
    else putStrLn "="

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

#define ll long long

using namespace std;

const int maxn = 2e5+50;

struct node
{
    int x;
    int id;
    friend bool operator < (const node &a, const node &b)
    {
        return a.x < b.x;
    }
} st[maxn];

int ans[maxn];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &st[i].x);
        st[i].id = i;
    }
    sort(st, st + n);
    for (int i = 0; i < n; ++i)
    {
        if (i < n/2) ans[st[i].id] = st[n/2].x;
        else ans[st[i].id] = st[n/2-1].x;
    }
    for (int i = 0; i < n; ++i)
        printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 4608
fun main(args : Array<String>) {
    val (a, b) = readLine()!!.split(' ').map(String::toInt)
    if (a <= 0 && b >= 0) println("Zero") else
        if (a > 0 || (b - a) % 2 != 0) println("Positive") else
            println("Negative")
}


Measured memory_bytes: 22188
#include <chrono>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pldll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<ld> vld;
#define newl '\n'
const ll M = 1e9 + 7;
const ll N = 1e2;
const ll INF = LONG_MAX;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define LOG_TWO_N 10
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-96;
}

template <class T>
void print(vector<T> &vec, int inc = 0, bool lb = true)
{
    for (auto v : vec)
        cout << v + inc << " ";
    if (lb)
        cout << newl;
}

void solve(ll t)
{
    string s; cin >> s;
    ll total = 0;
    for(char c: s) {
        int n= c -'0';
        total += n;
    }
    if(total % 9 == 0) {
        cout << "Yes" << newl;
    } else cout << "No";
}

int main()
{
    fast;

    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve(t);
    }

    return 0;
}

Measured memory_bytes: 3744
data = [int(input()) for i in range(5)]
upped = list(map(lambda x: x if x % 10 == 0 else (x // 10 + 1) * 10, data.copy()))
wait = []
for s, t in zip(data, upped):
    wait.append(t - s)
print(sum(upped) - max(wait))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  for(int i=0; i<n; i++){
    cin >> a[i];
    mp[a[i]] = i;
  }
  sort(a.begin(), a.end());
  for(int i=0; i<n; i++) ans += (i + mp[a[i]] ) % 2;
  cout << ans / 2 << endl;
}

Measured memory_bytes: 8320
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func readInt() int {
    if sc.Scan() {
        ret, _ := strconv.Atoi(sc.Text())
        return ret
    }
    return 0
}

func readShortLine() string {
    var ret string
    if sc.Scan() {
        ret = sc.Text()
    }
    return ret
}

func Abs(i int64) int64 {
    if i >= 0 {
        return i
    }
    return -i
}

func main(){
    s := readLine()
    initialColors := make([]int64, len(s))
    for i, c := range s {
        initialColors[i] = int64(c - '0')
    }
    // fmt.Println(initialColors)
    
    candidate1 := make([]int64, len(s))
    candidate2 := make([]int64, len(s))
    candidates := [][]int64{candidate1, candidate2}
    var firstColor int64
    for _, cand := range candidates {
        for i, _ := range cand {
            cand[i] = (firstColor + int64(i)) % 2
        }
        firstColor = (firstColor + 1) % 2
    }
    // fmt.Println(candidates[0])
    // fmt.Println(candidates[1])
    
    distances := make([]int64, 2)
    for i, cand := range candidates {
        for j, c := range cand {
            distances[i] += Abs(c - initialColors[j])
        }
    }
    // fmt.Println(distances)
    
    if distances[0] < distances[1] {
        fmt.Println(distances[0])
    } else {
        fmt.Println(distances[1])
    }
}


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

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

    ll ans=0;
    vector<int> vec;
    for(auto ch: n){
        vec.emplace_back(ch-'0');
    }
    reverse(vec.begin(),vec.end());
    vec.emplace_back(0);
    int ct=0;
    bool f=false;
    for(auto v:vec){
        if(f){
            ct=(v>4)?1:0;
        }
        if(v+ct==5)f=true;
        else f=false;

        if(v+ct>5){
            ans+=10-(v+ct);
            ct=1;
        }else{
            ans+=v+ct;
            ct=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7804
#include<stdio.h>

int main()
{
   int N, a, i, j, tmp, n;

   scanf("%d", &N);
   int A[N];
   for (i=0; i<N; i++)
      scanf("%d", &A[i]);

   for (i=0; i<N; i++){
      if (i<N-1)
         printf("%d ", A[i]);
      else if (i==N-1)
         printf("%d\n", A[i]);
   }

   for (a=1; a<N; a++){

      for (i=a; i<N; i++){
         tmp = A[i];
         j = i-1;
         while (j>=0 && A[j]>tmp){
            A[j+1] = A[j];
            j--;
         }
         A[j+1] = tmp;

         for (i=0; i<N; i++){
            if (i<N-1)
               printf("%d ", A[i]);
            else if (i==N-1)
               printf("%d\n", A[i]);
         }
      }

   }

   return 0;
}

Measured memory_bytes: 1804
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll n, m;
vector<vector<ll>> g(101010);
vector<vector<ll>> dp(101010, vector<ll>(2, -1));
vector<ll> info(101010, 1);

ll dfs(ll pos, ll par, ll col) {
	if(dp[pos][col] != -1) return dp[pos][col];
	ll ret = 0;
	if(!col) {
		REP(i, g[pos].size()) {
			if(g[pos][i] == par) continue;
			ret += (dfs(g[pos][i], pos, 0) + dfs(g[pos][i], pos, 1) - 1);
		}
		ret++;
		ret %= m;
	} else {
		ret = 1;
		vector<ll> v;
		REP(i, g[pos].size()) {
			if(g[pos][i] == par) continue;
			ret *= (1 + dfs(g[pos][i], pos, 1));
			ret %= m;
		}
	}
	return dp[pos][col] = ret % m;
}

void dfs2(ll pos, ll par) {
	ll tmp = info[pos];
	if(pos == 0) tmp = 0;
	ll acm = 1;
	REP(i, g[pos].size()) {
		if(g[pos][i] == par) continue;
		info[g[pos][i]] *= acm; info[g[pos][i]] %= m;
		info[g[pos][i]] *= (tmp + 1); info[g[pos][i]] %= m;
		acm *= (dp[g[pos][i]][1] + 1); acm %= m;
	}
	acm = 1;
	for(ll i = g[pos].size() - 1; i >= 0; i--) {
		if(g[pos][i] == par) continue;
		info[g[pos][i]] *= acm; info[g[pos][i]] %= m;
		acm *= (dp[g[pos][i]][1] + 1); acm %= m;
		dfs2(g[pos][i], pos);
	}
	return;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	REP(i, n - 1) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(0, -1, 0); dfs(0, -1, 1);
	dfs2(0, -1);
	info[0] = 0;
	REP(i, n) {
		cout << (dp[i][1] * (info[i] + 1) % m + m) % m << endl;
	}
	return 0;
}

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


Measured memory_bytes: 18816
#include<stdio.h>
#define N 100000

int Partition(int A[],int n,int p,int r){
  int x,h,i,j;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      h=A[i];
      A[i]=A[j];
      A[j]=h;
    }
  }
  h=A[i+1];
  A[i+1]=A[r];
  A[r]=h;
  return i+1;
}
  

int main(){
  int A[N];
  int n,i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=Partition(A,n,0,n-1);

  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==q){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==q){
      printf("]");
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2092
#include<stdio.h>

int main()
{
    int i, j, a[32], x;
    for ( i = 0; i <3; i++ ){
        scanf("%d", &a[i]);
     }
     for ( i = 0; i <2; i++ ){
       for ( j = 0; j < 2; j++){
          if ( a[j]  > a[j+1]){
          x =  a[j];
          a[j] = a[j+1];
          a[j+1] = x;
       }
       }
       }
        printf("%d %d %d\n", a[0], a[1], a[2]);
     return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    vector<string> A(N, ""), B(M, "");
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];

    for (int i = 0; i + M <= N; i++) {
        for (int j = 0; j + M <= N; j++) {
            bool T = false;
            for (int k = 0; k < M; k++) {
                string a = A[i + k].substr(j, M);
                if (a == B[k]) T = true;
                else {
                    T = false; break;
                }
            }
            if (T) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[][] A = new int[N][M];
		int[] B = new int[M];
		int a = 0;
		for(int i=0; i<M; i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0; i<N; i++) {
			for(int j=0; j<M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		sc.close();
		for(int i=0; i<N; i++) {
			int s = 0;
			for(int j=0; j<M; j++) {
				s += A[i][j] * B[j];
			}
			s += C;
			if(s>0) {
				a++;
			}
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 36576
#include <stdio.h>
int main(void){
	long long int n,m,ans;
	scanf("%lld%lld",&n,&m);
	if(n>=2&&m>=2) ans=(m-2)*(n-2);
	else if(n==1&&m==1) ans=1;
	else if(n==1&&m!=1) ans=m-2;
	else if(n!=1&&m==1) ans=n-2;
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128