akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, L;
  std::cin >> N >> L;
  const i64 i = std::max<i64>(1, std::min<i64>(1 - L, N));
  std::cout << (L - 1) * N + N * (N + 1) / 2 - (L + i - 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main(void)
{
 long long int max;
 long long int parts;
 long long int di;
  cin >> max >> parts >> di;
 long long int num = max - di;
 double ans =0;
 if(di!=0)
 {
   ans = (double)num*2*(parts-1)/(max*max);
 }
 else
 {
   ans = (double)num*(parts-1)/(max*max);
 }
 printf("%10f",ans);
  return 0;
}


Measured memory_bytes: 256
s = input()
m = int(s[0:2])
n = int(s[2:4])

if m == 00 or m >= 13:
    if n == 00 or n >= 13:
        print("NA")
    else:
        print("YYMM")
else:
    if n == 00 or n >= 13:
        print("MMYY")
    else:
        print("AMBIGUOUS")

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        long A = in.nextLong();
        long B = in.nextLong();

        if (A > B) {
            long tmp = A;
            A = B;
            B = tmp;
        }

        long diff = (B - A);
        if (diff % 2 == 0) {
            System.out.println(diff / 2);
        } else {
            long diff1 = A - 1;
            long diff2 = N - B;

            long ans = Math.min(B - 1, N - A);
            ans = Math.min(ans, diff1 + 1 + (B - (diff1 + 1) - 1) / 2);
            ans = Math.min(ans, diff2 + 1 + (N - (A + diff2 + 1)) / 2);
            System.out.println(ans);
        }
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ll n;
    cin >> n;
    vector<ll> numbers(n);
    for(auto &i: numbers) cin >> i ;
    sort(numbers.begin(), numbers.end());
    ld ans = numbers[0];
    for(auto i: numbers) {
        ans = (ans + i)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rall(c) (c).rbegin(), (c).rend()

int main() {
    for (int m, a, b; cin >> m >> a >> b, m | a | b;) {
        vector<int> p(m);
        for (int& e : p) cin >> e;
        sort(rall(p));
        int n = a;
        for (int i = a + 1; i <= b; ++i) if (p[i - 1] - p[i] >= p[n - 1] - p[n]) n = i;
        cout << n << endl;
    }
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}


Measured memory_bytes: 2864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, k, C;
 	cin >> n >> k >> C;
 	string s;
 	cin >> s;   
	ll c = 0;
	vector <ll> v1;
	ll c2 = 0;
	while (c < n) {
		if (c2 == k) break;
		if (s[c] == 'x') c++;
		else {
			c2++;
			v1.pb(c);
			c += (C + 1);
		}
	} 	
	c = n - 1;
	c2 = 0;
	vector <ll> v2;
	while (c >= 0) {
		if (c2 == k) break;
		if (s[c] == 'x') c--;
		else {
			c2++;
			v2.pb(c);
			c -= (C + 1);
		}
	}
	reverse(all(v2));
	for (ll i = 0; i < k; i++) {
		if (v1[i] == v2[i]) {
			cout << v1[i] + 1 << endl;
		}
	}
 	return 0;
}

Measured memory_bytes: 5128
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,k = map(int,ipt().split())
#    n = 5000
#    k = 1
    p = [int(i)-1 for i in ipt().split()]
#    p = [(i-1)%n for i in range(n)]
#    c = [10**9 for i in range(n)]
    c = [int(i) for i in ipt().split()]
    ma = -10**18
    al = [False]*n
    for i in range(n):
        if al[i]:
            continue
        pts = []
        nap = i
        for j in range(n):
            nap = p[nap]
            pts.append(c[nap])
            al[nap] = True
            if nap == i:
                break
        ln = len(pts)
        jt = k%ln+ln
        sma = 0
        for jp in pts:
            sma += jp
        if sma > 0:
            nm = (k//ln-1)*sma
        else:
            nm = 0
        pts *= 2
        ma1 = -10**18
#        print(pts,al)
        for ji in range(ln):
            sm = 0
            for jj in range(jt):
                sm += pts[ji-jj]
#                print(i,j,j-jj,sm)
                if ma1 < sm:
                    ma1 = sm
        ma1 += nm
        if ma < ma1:
            ma = ma1
#        print(ma)

    print(ma)




    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 71072
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####

from collections import defaultdict as ddic

def solve(N, A):
    X = 0
    for x in A: X^=x
    return [X^x for x in A]


ans = solve(rri(), rrm())
print " ".join(map(str, ans))



Measured memory_bytes: 96904
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<utility>
#include<cassert>
#include<set>

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

const int MAXN = 444;
map<vi, int> me;
vi C[MAXN];
ll co[MAXN][MAXN];

vi minV(vi v) {
    vi ret = v;
    for (int i = 0; i < 4; i++) {
        rotate(v.begin(), v.begin()+1, v.end());
        ret = min(ret, v);
    }
    return ret;
}

ll calc(vi a) {
    if (a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) return 4;
    if (a[0] == a[2] && a[1] == a[3]) return 2;
    return 1;
}

ll powI(ll a, int p) {
    if (a == 0) return 0;
    if (p == 0) return 1;
    if (p == 1) return a;
    if (p%2) return a*powI(a, p-1);
    ll tmp = powI(a, p/2);
    return tmp*tmp;
}

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

    // co[i][j] = i*(i-1)*...*(i-j+1)
    for (int i = 0; i < MAXN; i++) {
        co[i][0] = 1;
        for (int j = 0; j < 8; j++) co[i][j+1] = co[i][j]*(i-j);
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        vi v(4, 0);
        for (int j = 0; j < 4; j++) cin >> v[j];
        C[i] = minV(v);
        me[C[i]]++;
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) for (int j = i+1; j < N; j++) {
        me[C[i]]--; me[C[j]]--;
        vi a = C[i], b = C[j];
        swap(b[0], b[2]);
        for (int k = 0; k < 4; k++) {
            map<vi, int> m;
            for (int l = 0; l < 4; l++) {
                vi v;
                v.push_back(a[l]);
                v.push_back(a[(l+3)%4]);
                v.push_back(b[(l+3)%4]);
                v.push_back(b[l]);
                m[minV(v)]++;
            }
            ll t = 1;
            auto it = m.begin();
            while (it != m.end()) {
                t *= co[me[it->first]][it->second];
                t *= powI(calc(it->first), it->second);
                ++it;
            }
            ans += t;
            rotate(b.begin(), b.begin()+1, b.end());
        }
        me[C[i]]++;
        me[C[j]]++;
    }
    ans /= 3;
    cout << ans << endl;
}


Measured memory_bytes: 141568
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
int a,b;
  cin>>a>>b;
  cout<<(a+b+1)/2<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var S string
	fmt.Scanf("%s", &S)

	if S[0] != S[1] && S[1] != S[2] && S[2] != S[3] {
		fmt.Println("Good")
	} else {
		fmt.Println("Bad")
	}

}


Measured memory_bytes: 1828
n = int(input())
tb = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
  t = int(str(i)[0])
  b = int(str(i)[-1])
  tb[t][b] += 1
ans = 0
for l in range(10):
  for m in range(10):
    ans += tb[l][m] * tb[m][l]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		int j(i);
		while (j < n) {
			a[j] += 1;
			j += (i + 1);
		}
	}
	ll sum(0);
	rep(i, n) {
		//cout << a[i] << endl;
		sum += ll(i + 1) * ll(a[i]);
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 42324
n,k=map(int,input().split())
v=list(map(int, input().split()))
m=min(n,k)
ans=0
for i in range(m+1): #A
  for j in range(m+1-i): #B
    l=[]
    l=l+v[0:i]+v[n-j:n]
    l.sort()
    for kk in range(min(k-i-j, i+j)):
      if l[kk]<0:
        l[kk]=0
    ans=max(ans, sum(l))
print(ans)

Measured memory_bytes: 9136
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int main ()
{
	string str;
	getline ( cin , str );
	for( auto &x : str )
	{
		if( x >= 'a'&&x <= 'z' )
		{
			x=x - 'a' + 'A';
		}
	}
	cout << str << endl;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)

int main(){
    long long int r,D,x,t=10;
    scanf("%lld %lld %lld",&r,&D,&x);
    long long int temp = x;
    while(t--){
        temp = temp*r-D;
        pld(temp);
    }
    return 0;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    vector<int> cnt(3, 0);
    rep(i, n) {
        if (p[i] <= a) ++cnt[0];
        else if (p[i] <= b) ++cnt[1];
        else ++cnt[2];
    }
    
    cout << min({cnt[0], cnt[1], cnt[2]}) << "\n";
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int n, sum, y, a[105];
double g, t = 1e9;
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	g = 1.0 * sum / n;
	for(int i = 0; i < n; i++) {
		if(abs(a[i] - g) < t){
			t = abs(a[i] - g);
			y = i;
		}
	}
	cout << y << endl;;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];
int main() {
    SS(ll,N,M,L);
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    SS(ll,Q);
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];

    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = MOD;
            dist[i][j] = MOD;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < MOD) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int A, B, C, D;
int main() {
    cin >> A >> B >> C >> D;
    int a = (A<B)? A : B;
    int b = (C<D)? C : D;
    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 100100
using namespace std;

int n,num[N];

inline bool cmp(int u,int v)
{
	return u>v;
}

int main()
{
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
	}
	sort(num+1,num+n+1,cmp);
	for(i=1;i<=n;i++)
	{
		if(i>num[i]) break;
	}
	i--;
	if((num[i]-i)&1)
	{
		puts("First");
		return 0;
	}
	for(j=i+1;num[j]==i;j++);
	j--;
	if((j-i)&1)
	{
		puts("First");
		return 0;
	}
	puts("Second");
}

Measured memory_bytes: 640
import java.util.*;

import static java.lang.Math.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if(n>=10) {
			pw.println(r);
		}else {
			pw.println(r+100*(10-n));
		}
		pw.close();

	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}

	}

	static class pair2 implements Comparable<pair2> {
		long x;
		int y;

		@Override
		public String toString() {
			// TODO Auto-generated method stub
			return y + " ";
		}

		public pair2(long d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair2 o) {
			// TODO Auto-generated method stub
			if (x - o.x > 0)
				return 1;
			else if (x - o.x == 0)
				return 0;
			return -1;
		}

	}

}


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

char S[55][55];

int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) scanf("%s", S[i]);
    int h[] = {1, 0, -1, 0}, w[] = {0, 1, 0, -1};
    bool ans = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') continue;
            bool flg = true;

            for (int k = 0; k < 4; k++) {
                int y = i + h[k], x = j + w[k];
                if (S[i][j] == '#' && 0 <= x && x < W && 0 <= y && y < H && S[y][x] == '#') {
                    flg = false;
                }
            }

            if (flg) ans = false;
        }
    } 
    if (ans) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int k = 0;
    if (s[0] == s[s.length() - 1]) k++;
    k += s.length() % 2;
    if (k % 2 == 0) cout << "Second";
    else cout << "First";
}

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

/**
 *
 * @author yoshkur
 */
public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			InputData inputData = new InputData(br);
			StringBuilder sb = new StringBuilder();
			sb.append(getArea(inputData));
			sb.append(" ");
			sb.append(getLength(inputData));
			System.out.println(sb.toString());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}

	private static Integer getArea(InputData inputData) {
		return inputData.getHeight() * inputData.getWidth();
	}

	private static Integer getLength(InputData inputData) {
		return (inputData.getHeight() + inputData.getWidth()) * 2;
	}

}

class InputData {

	private Integer height;
	private Integer width;

	public InputData(BufferedReader br) throws IOException {
		String line = br.readLine().trim();
		String[] values = line.split(" ");
		this.height = Integer.valueOf(values[0]);
		this.width = Integer.valueOf(values[1]);
	}

	public Integer getHeight() {
		return height;
	}

	public void setHeight(Integer height) {
		this.height = height;
	}

	public Integer getWidth() {
		return width;
	}

	public void setWidth(Integer width) {
		this.width = width;
	}
}

Measured memory_bytes: 23860
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <fstream>
 
using namespace std;
 
ifstream fin("../data.txt");
 
string s;
 
int main() {
 
  getline(cin, s);
  int a = 0, b = s.size() - 1;
  while(s[a] != 'A' || s[b] != 'Z') {
    if (s[a] != 'A') a++;
    if (s[b] != 'Z') b--;
  }
 
  cout << b - a + 1;
 
  return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
vector<int> num(n);
for(int i=0;i<n;i++){
cin >> num.at(i);
}
int ans=0;
for(int i=0;i<n;i++){
if((i+1)%2==1&&num.at(i)%2==1)
ans++;
}
  
cout << ans << endl;
  
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef __int128 i128;
const int N=110,P=998244353;
char s[N];i128 f[N];map<i128,int> dp[N];
inline void upd(int &x,int y){((x+=y)>=P)&&(x-=P);}
int solve(i128 s,int n){
	if(!n) return 1;
	if(dp[n].count(s)) return dp[n][s];
	int ans=solve(s>>1,n-1)*((s&1)+1)%P;
	rep(i,1,n/2){
		int j=i;i128 t=s&f[i];
		while(j+i<=n){
			t&=s>>j;
			j+=i;upd(ans,1ll*solve(t,i)*solve(s>>j,n-j)%P);
		}
	}
	return dp[n][s]=ans;
}
int main(){
	scanf("%s",s);int n=strlen(s);i128 a=0;
	rep(i,0,n-1) a|=i128(s[i]^48)<<i;
	rep(i,1,n-1) f[i]=f[i-1]<<1|1;
	printf("%d",solve(a,n));
	return 0;
}

Measured memory_bytes: 3840
H1, M1, H2, M2, K = map(int, input().split())

ans = 0
HM1 = H1 * 60 + M1
HM2 = H2 * 60 + M2

ans = HM2 - HM1 - K

if ans >= 0:
    print(ans)
else:
    print("0")


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(ll i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();
bool is_prime(int n){
    if(n==2)
        return true;
    if(n%2==0||n==1)
        return false;
    for(int i=3;i*i<=n;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
    vi v;
    for(int i=2;i<=55555;i++){
        if(is_prime(i)&&i%5==1)
            v.pb(i);
    }
    int n;
    cin>>n;
    loop(n)
        cout<<v[i]<<" ";
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/// 20
/// 15 7 13 15 15 15 15 13 19
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  long long n,b,c,a;
	cin>>n;
	for(a=sqrt(n)+1;a>0;a--)
	{
		if(n%a==0) 
		{
			b=a;
			break;
		}
	}
	c=n/b;
	cout<<b+c-2;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 998244353;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n;cin>>n;
    vector<vector<ll>> ans(n+1,vector<ll>(n+1));
    for(int i=0;i < n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int x=i,y=j,cnt=1;
            while(1){
                if((x&1) != (y&1)){
                    ans[i][j]=cnt;
                    break;
                }else{
                    x/=2;
                    y/=2;
                    cnt++;
                }
            }
        }
    }

    for(int i=0;i < n-1;i++)
    {
        for(int j=i+1;j <n;j++)
        {
            cout<<ans[i][j]<<(j==n-1?'\n':' ');
        }
    }    
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N, -1);
    
    priority_queue<ll> que;
        
    rep(i, N) {
        cin >> A.at(i);
        que.push(A.at(i));
    }

    ll k = 0;
    while(k!=M){
        ll tmp = que.top()/2;
        que.pop();
        que.push(tmp);
        k++;
    }

    ll sum = 0;
    for(ll i=0; i<N; i++){
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;
}

Measured memory_bytes: 2168
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)

func checkEven(a []int) bool {
    for i := 0; i < len(a); i++ {
        if a[i]%2 != 0 {
            return false
        }
    }
    return true
}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
    nextLine()
    inputs := strings.Split(nextLine(), " ")
    var nums []int
    for i := 0; i < len(inputs); i++ {
        num, _ := strconv.Atoi(inputs[i])
        nums = append(nums, num)
    }
    count := 0
    for checkEven(nums) {
        count++
        for i := 0; i < len(nums); i++ {
            nums[i] = nums[i] / 2
        }
    }
    fmt.Println(count)
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{

    char a[100];
    char b[100];
    char c[100];
    scanf("%s %s %s",a,b,c);
    int la=strlen(a);
    int lb=strlen(b);
    int lc=strlen(c);
    if((a[la-1]==b[0])&&(b[lb-1]==c[0]))
    {
       printf("YES\n");
    }
    else
    {
       printf("NO\n");
    }

   return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 1000000007
using namespace std;
vector<ll> prime,sfac;
vector<ll>ps;
void sieve(ll n)
{
	prime.assign(n+1,1);
	sfac.assign(n+1,1);    
    for (int p=2; p*p<=n; p++) 
    {         
        if (prime[p] == 1) 
        { 	sfac[p]=p;  			  
            for (int i=p*p; i<=n; i += p) 
              {  prime[i] = 0; sfac[i]=p;}
        } 
    } 
	for(ll i=2;i<=n;i++)
	{
		if(prime[i])
			ps.push_back(i);
	}
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
int isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return 0; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0; 
  
    return 1; 
} 

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll s=a[0];
    for(int i=1;i<n;i++)
        s^=a[i];
    for(int i=0;i<n;i++)
        cout<<(s^a[i])<<" ";
    cout<<endl;
}


Measured memory_bytes: 5192
import sys
input = sys.stdin.readline
n = int(input())
nt = int(n * (100/108))
tt = 108/100
ntt = int(nt * tt)
if n == ntt:
    print(nt)
    exit()
ntt = int((nt + 1) * tt)
if n == ntt:
    print(nt + 1)
else:
    print(':(')



Measured memory_bytes: 38384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M;
int p[20];

void func(){

	for(int i = 0; i < M; i++){
		scanf("%d",&p[i]);
	}

	sort(p,p+M);

	if(p[0] == 1){
		printf("0.0000000000\n");
	}else{
		printf("%.10lf\n",(double)N/2);
	}
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}
}

Measured memory_bytes: 3212
function main(input) {
  var marginDelete = input.trim();
  var args = marginDelete.split('');
  if ( args[0] === args[1] && args[0] === args[2]) {
    return "No";
  } else {
    return "Yes";
  }
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

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

    int count = 0;
    for(int i = 0; i < s.length()/2; i++) {
        if(s[i] != s[s.length()-1-i]) {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = stdin.nextInt();
            b[i] = stdin.nextInt();
        }

        // 締め切りの若い順番に仕事を進める。
        int[] idxs = IntStream.range(0, n)
                              .boxed()
                              .sorted(Comparator.comparing(i -> b[i]))
                              .mapToInt(Integer::intValue)
                              .toArray();
        int t = 0;
        boolean ok = true;
        for (int idx : idxs) {
            t += a[idx];
            if (b[idx] < t) {
                ok = false;
                break;
            } 
        }
        System.out.println(ok ? "Yes" : "No");
    }
}

Measured memory_bytes: 160432
#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 << "Left" << endl;
  } else if (a+b == c+d) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

#define For(i, j, k) for (int i = j; i <= k; ++ i)

using namespace std;

typedef long long ll;

inline int c(ll x) {
	int res = 0;
	while (x) res += x % 10, x /= 10;
	return res;
}

inline ll f(ll x) {
	double mn = 1.0 * x / c(x); ll res = x;
	for (ll d = 1; d <= x; d *= 10) {
		ll nw = x / d * d + d * 10 - 1;
		double t = 1.0 * nw / c(nw);
		if (t < mn) res = nw, mn = t;
	}
	return res;
}

int main() {

	int k; cin >> k;
	
	for (ll nw = 1; k --; nw = f(nw + 1)) printf("%lld\n", nw);

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n+2);
  for(int i=1;i<=n;i++) cin >> a[i];
  a[0]=0;
  a[n+2-1]=0;

  int cnt=0;
  int look=1;
  while(cnt<=n){
    cnt++;
    if(a[look]==2){
      cout << cnt << endl;
      return 0;
    }
    else{
      look=a[look];
    }
  }

  cout << "-1" << endl;
  
  return 0;
}


Measured memory_bytes: 640
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [0]*9

for i in li:
    if 1<= i < 400:
        lin[0] = 1
    elif 400<= i < 800:
        lin[1] = 1
    elif 800<= i < 1200:
        lin[2] = 1
    elif 1200<= i < 1600:
        lin[3] = 1
    elif 1600<= i < 2000:
        lin[4] = 1
    elif 2000<= i < 2400:
        lin[5] = 1
    elif 2400<= i < 2800:
        lin[6] = 1
    elif 2800<= i < 3200:
        lin[7] = 1
    else:
        lin[8] += 1

mi = lin[:-1].count(1)
ma = mi+lin[-1]
if mi == 0:
    mi = 1
print(mi,ma)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

double tmp, ans;
int n, k;
VI p;

int main()
{
    cin>>n>>k;
    p.resize(n);
    REP(i,n) {
        cin>>p[i];
        tmp += (p[i] + 1.0) / 2;
        if (i + 1 >= k) {
            //cout<<tmp<<endl;
            MAX(ans, tmp);
            tmp -= (p[i+1-k] + 1.0) / 2;
        }
    }
    cout<<fixed<<setprecision(6)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        count += bisect.bisect_left(l[j+1:],l[i]+l[j])
print(count)

Measured memory_bytes: 50912
#include<bits/stdc++.h>
using namespace std;
const int maxn=3006;
const int inf=1e9+7; 
typedef long long ll;
int dir[][2]={1,0,-1,0,0,1,0,-1};
int a[maxn],b[maxn],c[maxn],D[maxn],e[maxn],f[maxn];
int u[maxn][maxn],d[maxn][maxn],l[maxn][maxn],r[maxn][maxn],vis[maxn][maxn];
vector<int>xx({-inf,inf}),yy({-inf,inf});
void bfs(int x,int y){
	vis[x][y]=1;
	queue<pair<int,int>>q;
	q.push({x,y});
	while(!q.empty()){
		x=q.front().first,y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			if(i==0&&r[x][y]) continue;
			if(i==1&&l[x][y]) continue;
			if(i==2&&u[x][y]) continue;
			if(i==3&&d[x][y]) continue;
			int nx=x+dir[i][0];
			int ny=y+dir[i][1];
			if(nx<0||ny<0) continue;
			if(nx>=xx.size()-1||ny>=yy.size()-1) continue;
			if(vis[nx][ny]) continue;
			vis[nx][ny]=1;
			q.push({nx,ny});
		}
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		scanf("%d",&b[i]);
		scanf("%d",&c[i]);
		xx.push_back(a[i]);
		xx.push_back(b[i]);
		yy.push_back(c[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%d",&D[i]);
		scanf("%d",&e[i]);
		scanf("%d",&f[i]);
		xx.push_back(D[i]);
		yy.push_back(e[i]);
		yy.push_back(f[i]);
	}
	sort(xx.begin(),xx.end());
	sort(yy.begin(),yy.end());
	xx.resize(unique(xx.begin(),xx.end())-xx.begin());
	yy.resize(unique(yy.begin(),yy.end())-yy.begin());
	for(int i=0;i<n;i++){
		int aa=lower_bound(xx.begin(),xx.end(),a[i])-xx.begin();
		int bb=lower_bound(xx.begin(),xx.end(),b[i])-xx.begin();
		int cc=lower_bound(yy.begin(),yy.end(),c[i])-yy.begin();
		for(int x=aa;x<bb;x++){
			u[x][cc-1]=1;
			d[x][cc]=1;
		}
	}
	for(int i=0;i<m;i++){
		int dd=lower_bound(xx.begin(),xx.end(),D[i])-xx.begin();
		int ee=lower_bound(yy.begin(),yy.end(),e[i])-yy.begin();
		int ff=lower_bound(yy.begin(),yy.end(),f[i])-yy.begin();
		for(int y=ee;y<ff;y++){
			l[dd][y]=1;
			r[dd-1][y]=1;
		}
	}
	int x=lower_bound(xx.begin(),xx.end(),0)-xx.begin();
	int y=lower_bound(yy.begin(),yy.end(),0)-yy.begin();
	bfs(x-1,y-1);
	if(vis[0][0]){
		printf("INF\n");return 0;
	}
	ll ans=0;
	for(int i=0;i<xx.size()-1;i++){
		for(int j=0;j<yy.size()-1;j++){
			if(vis[i][j]) ans+=(ll)(xx[i+1]-xx[i])*(yy[j+1]-yy[j]);
		}
	}
	printf("%lld\n",ans);
}

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

int main()
{
    int N; cin>>N;
    map<int, int> cnt;
    for(int a; N--; ++cnt[min(a, 3200)/400]) cin>>a;

    int x=cnt.size();
    int y=cnt[8];
    if (x>1)
        cout<<x-(y>0)<<' '<<x+y-(y>0)<<endl;
    else
        cout<<x<<' '<<(y?:1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int N, i, ans = 0;
	scanf("%lld", &N);
	vector<int> C(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &C[i]);
	}
	sort(C.begin(), C.end());
	for(i = 0; i < N; i++){
		ans = MOD(ans + C[i] * MOD((N + 1 - i) * power(2, 2 * N  - 2)));
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
    }
    
  if (S == "Cloudy") {
    cout << "Rainy" << endl;
    }
    
  if (S == "Rainy") {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
A=sorted(list(map(int,input().split())),reverse=True)

ans,point,index=0,0,0
for i in range(n-1):
    ans +=A[index]
    point +=1
    if index==0 or point==2:
        index +=1
        point=0
print(ans)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,K;cin>>N>>K;
    int cnt[26]={};
    rep(i,N){
        string s;
        cin>>s;
        cnt[s[0]-'A']++;
    }

    for(int t=0;;t++){
        vpint vec;
        rep(i,26)vec.pb(pint(cnt[i],i));
        sort(all(vec));reverse(all(vec));
        if(vec[K-1].fi==0){
            cout<<t<<endl;
            return 0;
        }
        rep(i,K)cnt[vec[i].se]--;
    }
    return 0;
}


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

int main(){
    int n;
    int q;
    while(cin>>n>>q,n){
        vector<tuple<int,int,string>> eras(n);
        for(int i=0;i<n;i++){
            string eraname;
            int eray;
            int wesy;
            cin>>eraname>>eray>>wesy;
            int startwes=wesy-eray+1;
            int endwes=wesy;
            eras[i]=make_tuple(startwes,endwes,eraname);
        }
        sort(eras.begin(),eras.end());
        for(int i=0;i<q;i++){
            int year;
            cin>>year;
            for(int j=0;j<=n;j++){
                if(eras.size()<=j){
                    cout<<"Unknown"<<endl;
                    break;
                }
                if(get<0>(eras[j])<= year && year<=get<1>(eras[j])){
                    cout<<get<2>(eras[j])<<" "<<year-get<0>(eras[j])+1<<endl;
                    break;
                }


            }



        }
    }

    return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m, s = 0;
    cin >> n;
    int t[n];
    for (int i = 0; i < n; i++) 
    {
        cin >> t[i];
        s += t[i];
    }
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int p, x;
        cin >> p >> x;
        cout << s + x - t[p - 1] << endl;
    }
}

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main(){
    int n,x;
    while(true){
        cin >> n >> x;
        if(n==0 && x == 0) break;
        int i,j,k;
        int ans = 0;
        for(i=1;i<n+1;i++){
            for(j=i+1;j<n+1;j++){
                for(k=j+1;k<n+1;k++){
                    if(i+k+j == x) ans++;
                    if(i+k+j > x) break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
# coding: utf-8
N=int(input())
L=[]
L.append([0,0,0])
Flg=True
cnt=0
for i in range(1,N+1):
    t,x,y=map(int,input().split())
    L.append([t,x,y])
    if (t-L[i-1][0]-(abs(L[i-1][1]-x)+abs(L[i-1][2]-y)))%2==0 and t-L[i-1][0]>=(abs(L[i-1][1]-x)+abs(L[i-1][2]-y)):
        cnt+=1
        
if cnt==N:
    print('Yes')
else:
    print('No')

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

signed main(void)
{
	int n;
	cin >> n; 
	long long a, b, c, cnt;
	string s[n];

	rep(i, n) cin >> s[i];
	a = b = c = cnt = 0;
	rep(i, n)
	{
		rep(j, s[i].size() - 1)
		{
			if (s[i].substr(j, 2) == "AB")
				cnt++;
		}
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A')
			c++;
		else if (s[i][s[i].size() - 1] == 'A')
			a++;
		else if (s[i][0] == 'B')
			b++;
	}
	if (c == 0)
		cnt += min(a, b);
	else if (a + b > 0)
		cnt += c + min(a, b); 
	else
		cnt += c - 1;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.*

fun main(args: Array<String>) {
    val array = readFromCli()
    greatestCommonFactor(array[0], array[1])
}

private fun readFromCli(): Array<Int> {
    val scanner = Scanner(System.`in`)
    val prog: MutableList<Int> = scanner
            .nextLine()
            .split(" ")
            .map{ it.toInt() }
            .toMutableList()
    scanner.close()

    return hint(prog[0], prog[1])
}

private fun greatestCommonFactor(x: Int, y: Int) {
    var a = x
    var b = y
    var r = a % b

    while (r != 0) {
        a = b
        b = r
        r = a % b
    }

    println(b.toString())
}

private fun hint(x: Int, y: Int): Array<Int> {
    return if (x > y) {
        arrayOf(y, x%y)
    } else {
        arrayOf(x, y)
    }
}


Measured memory_bytes: 33368
#include<stdio.h>


int CountQ(char* a_acS);

int main(void) {
	int iS;
	char acS[7];

	//文字列Sを入力
	scanf("%d", &iS);
	//Sを配列に変換
	sprintf(acS, "%d", iS);
	//採用された問題の数を数え,結果を出力
	printf("%d\n",CountQ(acS));

	return 0;
}

int CountQ(char* a_acS) {
	int i;
	int count = 0;
	//文字列S中の1の数を数える
	for (i = 0;i < 6;i++) {
		if (a_acS[i] == '1') {
			count++;
		}
	}
	return(count);
}

Measured memory_bytes: 1704
#include <iostream>
using namespace std;
class dice {
    public:
        int top, front, right, left, back, bottom;
        dice(int a, int b, int c, int d, int e, int f) {
            top = a; front = b;
            right = c; left = d;
            back = e; bottom = f;
        }
        int tp() {
            return top;
        }
        void E() {
            int tmp = top;
            top = left;
            left = bottom;
            bottom = right;
            right = tmp;
        }
        void N() {
            int tmp = top;
            top = front;
            front = bottom;
            bottom = back;
            back = tmp;
        }
        void S() {
            int tmp = top;
            top = back;
            back = bottom;
            bottom = front;
            front = tmp;
        }
        void W() {
            int tmp = top;
            top = right;
            right = bottom;
            bottom = left;
            left = tmp;
        }
};

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    dice di(a, b, c, d, e, f);
    char ch;
    while (cin >> ch) {
        if (ch == 'E')
            di.E();
        else if (ch == 'N')
            di.N();
        else if (ch == 'S')
            di.S();
        else 
            di.W();
    }
    cout << di.tp() << '\n';
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
//#include <algorithm>
#define endl "\n"
typedef long long ll;

using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//int  frq[200];
int main(){
	Lancer();
	//cout << fixed << setprecision(12);

	string str;
	int k;
	cin >> str;
	bool ch = true;
	k = str.length() - 1;
	for (int i = 0; i < str.length(); i++){
		if (str[i] != str[k--]){
			ch = false;
			break;
		}
	}
	k = (str.length() / 2 )-1;
	for (int i = 0; i < str.length()/2; i++){
		if (str[i] != str[k--]){
			ch = false;
			break;
		}
	}
	k = str.length() - 1;
	for (int i = (str.length() + 3) / 2 -1; i < str.length(); i++){
		if (str[i] != str[k--]){
			ch = false;
			break;
		}
	}
	cout << (ch == true ? "Yes" : "No");
	cout << endl;
	return 0;
}


Measured memory_bytes: 256