akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x = x2 - x1;
  int y = y2 - y1;

  cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
}


Measured memory_bytes: 3600
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long n; cin>>n;
	vector<long long> freq(n+1,0);
	vector<long long> a(n+1,0); for (long long i = 1; i <= n; i++) cin>>a[i], freq[a[i]]++;

	long long s=0;
	for (long long i = 1; i <= n; i++) s+=(freq[i]*(freq[i]-1))/2;

	for (long long k = 1; k <= n; k++) {
		cout<<(s-freq[a[k]]+1)<<"\n";
	} 

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const int N = 405;

int n; ll a[N];
pll dp[N][N]; bool v[N][N];

pll fun(int i, int j) {
  if (i > j) {
    return make_pair(0, 0);
  }
  if (i == j) {
    return make_pair(a[i], 0);
  }
  if (v[i][j]) {
    return dp[i][j];
  }
  v[i][j] = true;
  pll &ret = dp[i][j];
  ll got = 1e18;
  for (int k = i; k < j; k++) {
    pll A = fun(i, k);
    pll B = fun(k + 1, j);
    ll cur = A.first + B.first + A.second + B.second;
    if (cur < got) {
      got = cur;
      ret.first = A.first + B.first;
      ret.second = cur;
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  memset(v, false, sizeof v);
  cout << fun(0, n - 1).second << '\n';
  return 0;
}



Measured memory_bytes: 2816
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0295

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    d, c = map(int, input().split())
    print(d * c)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 5620
//simple.cpp
#include<iostream>
using namespace std;

int main()
{
    int i,a,b;
    string op;
    for ( i = 0; i < 10000; i++)
    {
        cin>>a>>op>>b;
        if (op=="?")
        {
            break;
        }
        else if (op=="+")
        {
            cout<<a+b<<endl;
        }
        else if (op=="-")
        {
            cout<<a-b<<endl;
        }
        else if (op=="*")
        {
            cout<<a*b<<endl;
        }else
        {
            cout<<a/b<<endl;
        }
    }
}


Measured memory_bytes: 3148
#include<iostream>
#include<string>
#define INF (1 << 30)
using namespace std;

int main() {
    string s;
    cin >> s;
    int min_sub = INF;
    for (int i = 0; i < s.length() - 2; i++) {
        int num = stoi(s.substr(i, 3));
        if (min_sub > abs(753 - num)) min_sub = abs(753 - num);
    }
    cout << min_sub << endl;
    return 0;
}

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

int main() {
  string s;
  cin >>s;
  if (s == "RRR" ) {cout << 3 << endl;}
  else if ((s[0] == 'R' and s[1] == 'R') || (s[1] == 'R' and s[2] == 'R')) {cout << 2 << endl;}
  else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {cout << 1 << endl;}
  else {cout << 0 << endl;}
  return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    double Ans;
    scanf("%lf",&Ans);
    printf("%lf",Ans*acos(-1)*2);
    output();
    return 0;
}

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

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

    ll n, k; 
    cin >> n >> k;
    ll counter = 0;

    while (n>=k)
    {
        // cout << n/k << "\n";
        n = n/k;
        counter += 1;
    }

    cout << counter + 1 << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);  
    public static void main(String[] args) throws Exception {
        Set<Integer> set = new HashSet<>();
        int n = sc.nextInt();
        for (int i = 0;i < n;i++) {
            set.add(sc.nextInt());
        }
        int s = set.size();
        if (s%2==0) s--;
        System.out.println(s);
    }
}


Measured memory_bytes: 51176
# -*- coding: utf-8 -*-
INF=10**10

def main():
    
    k,s=list(map(int,input().split()))
    sum=0
    for i in range(k+1):
        for j in range(k+1):
            if s-(i+j)>=0 and s-(i+j)<k+1:
                sum+=1
    print(sum)
    
if __name__=="__main__":
    main()
    

Measured memory_bytes: 2940
N = int(input())

primes = {}

for i in range(2, N+1):
    tmpN = i
    n = 2
    while tmpN > 1:
        while tmpN%n == 0:
            tmpN //= n
            if n in primes:
                primes[n] += 1
            else:
                primes[n] = 1
        n += 1

kumi5 = 0
kumi3 = 0
kumi75 = 0
kumi25 = 0
kumi15 = 0
for key in primes.keys():
    if primes[key] >= 74:
        kumi75 += 1
    if primes[key] >= 24:
        kumi25 += 1
    if primes[key] >= 14:
        kumi15 += 1
    if primes[key] >= 4:
        kumi5 += 1
    if primes[key] >= 2:
        kumi3 += 1


ans = 0
if kumi5 >= 2 and kumi3 >= 3:
    ans += (kumi5 * (kumi5-1) // 2) * (kumi3-2)

if kumi75 >= 1:
    ans += kumi75

if kumi25 >= 1 and kumi3 >= 2:
    ans += kumi25 * (kumi3-1)

if kumi15 >= 1 and kumi5 >= 2:
    ans += kumi15 * (kumi5-1)

print(ans)


Measured memory_bytes: 3064
import math

p_max = 1000000 * 1000000
n, k = map(int, input().split())
w = [int(input()) for i in range(n)]

def check(p):
  i = 0
  for j in range(k):
    s = 0
    while (s + w[i] <= p):
      s += w[i]
      i += 1
      if i == n:
        return n
  return i

if __name__ == "__main__":
  right = p_max
  left = 0
  mid = 0
  while (right - left > 1):
    mid = math.floor((right + left) / 2)
    v = check(mid)
    if v >= n:
      right = mid
    else:
      left = mid
  
  print (right)


Measured memory_bytes: 9624
#include<iostream>
using namespace std;
int main() {

	int x[3] = { 0 };

	int i = 0;
	for (i = 0; i < 3; i++) {
		cin >>x[i];
	}

	int k = 0;
	for (i = 0; i < 2;i++){
		for (k = 2; k > i; k--) {
			if (x[k-1] > x[k]) {
				int j;
				j = x[k];
				x[k] = x[k-1];
				x[k-1] = j;
			}
		}
	}

	cout << x[0] << " " << x[1] << " " << x[2] << endl;

	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int a,b,c;
  cin >> a >> b >> c;
  int q1,q2,q3,all;
  all = a*b*c;
  if(a%2==0||b%2==0||c%2==0) {cout << 0 << endl;return 0;}
  q1 = a/2 *b*c;
  q1 = abs((all-q1)-q1);
  q2 = b/2 *a*c;
  q2 = abs((all-q2)-q2);
  q3 = c/2 *b*a;
  q3 = abs((all-q3)-q3);
  
  cout << min({q1,q2,q3}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
    ll q, que, x, y;
    multiset<ll> S;
    cin >> q;

    rep(i, q)
    {
        cin >> que >> x;
        if (que == 0)
            S.insert(x);
        else if (que == 2)
        {
            S.erase(x);
            continue;
        }
        else if (que == 3)
        {
            cin >> y;
            //delctype(S)
            multiset<ll>::iterator first_itr = S.lower_bound(x);
            multiset<ll>::iterator end_itr = S.upper_bound(y);

            for (auto i = first_itr; i != end_itr; ++i)
                cout << *i << endl;

            /*for (int i = x; i <= y; i++)
            {
                if (S.find(i) != S.end())
                {
                    cout << *S.find(i) << endl;
                }
            }*/

                /*for(struct { ll i; int j;} s = { x, 0} ; s.i <= y ; ++s.i , ++s.j)
            {
                if (S.find(s.i) != S.end())
                {
                    //cout << (s.j ? " " : "");
                    cout << *S.find(s.i) << endl;
                }
            }*/
                continue;
        }

        cout << (que ? S.count(x) : S.size()) << endl;
    }
    return 0;
}


Measured memory_bytes: 12256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;

struct edge { long long to, cost;};
typedef pair<long long, long long> Pair;
 
vector<long long> dijkstra(long long s, long long n, const vector<edge> G[]){
    vector<long long> dist(n);
    long long INF = 1LL<<60;
    for(int i=0; i<n; i++){
        dist[i] = INF;
    }
    priority_queue<Pair, vector<Pair>, greater<Pair>> que;
    dist[s] = 0;
    que.push(Pair(0, s));
    while(!que.empty()){
        Pair p = que.top();
        que.pop();
        long long v = p.second;
        if(dist[v] < p.first)continue;
        for(int i=0; i<G[v].size(); i++){
            edge e = G[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.push(Pair(dist[e.to], e.to));
            }
        }
    }
    return dist;
}


int main(){
    long long i, j, k;
    long long N, M, S, T;
    cin >> N >> M >> S >> T;
    S--; T--;
    vector<edge> edges[100000];
    vector<long long> U(M), V(M), D(M);
    for(i=0; i<M; i++){
        long long u, v, d;
        cin >> u >> v >> d;
        if(u>v) swap(u, v);
        edges[u-1].push_back({v-1, d});
        edges[v-1].push_back({u-1, d});
        U[i] = u-1; V[i] = v-1; D[i] = d;
    }
    auto dist_s = dijkstra(S, N, edges);
    auto dist_t = dijkstra(T, N, edges);
    long long dist = dist_s[T];

    vector<long long> num_s(N), num_t(N);
    for(i=0; i<N; i++){
        num_s[i] = 0;
        num_t[i] = 0;
    }
    vector<Pair> order(N);

    for(i=0; i<N; i++) order[i] = {dist_s[i], i};
    sort(order.begin(), order.end());
    num_s[S] = 1;
    for(auto p : order){
        i = p.second;
        for(auto e : edges[i]){
            if(dist_s[i] + e.cost == dist_s[e.to]) num_s[e.to] = (num_s[e.to] + num_s[i]) % MOD;
        }
    }

    for(i=0; i<N; i++) order[i] = {dist_t[i], i};
    sort(order.begin(), order.end());
    num_t[T] = 1;
    for(auto p : order){
        i = p.second;
        for(auto e : edges[i]){
            if(dist_t[i] + e.cost == dist_t[e.to]) num_t[e.to] = (num_t[e.to] + num_t[i]) % MOD;
        }
    }

    long long ans = num_s[T] * num_s[T] % MOD;

    for(i=0; i<N; i++){
        if(dist_s[i]*2 == dist){
            long long loss = num_s[i] * num_t[i] % MOD;
            loss = loss * loss % MOD;
            ans = (MOD + ans - loss) % MOD;
        }
    }

    for(i=0; i<M; i++){
        long long v1 = U[i];
        long long v2 = V[i];
        long long d = D[i];
        if(dist_s[v1]*2 == dist) continue;
        if(dist_s[v2]*2 == dist) continue;
        if(dist_s[v1]*2 <= dist && dist_t[v2]*2 <= dist && dist_s[v1] + dist_t[v2] + d == dist){
            long long loss = num_s[v1] * num_t[v2] % MOD;
            loss = loss * loss % MOD;
            ans = (MOD + ans - loss) % MOD;
        }
        if(dist_s[v2]*2 <= dist && dist_t[v1]*2 <= dist && dist_s[v2] + dist_t[v1] + d == dist){
            long long loss = num_s[v2] * num_t[v1] % MOD;
            loss = loss * loss % MOD;
            ans = (MOD + ans - loss) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 22552
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
 
 
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll b=k,r=n-k;
    for (ll i=0;i<k;i++){
        ll p=b-i-1;
        if (p<0) {cout << 0 << endl;continue;}
        ll ans=1;
        ans=combination(p+i,i);
        // ll uu=min(p,i);
        // vector<int> vv(uu+1);
        // rep(l,uu) vv.at(l)=0;
        // if (i!=0){for (ll j=i+p;j>max(p,i);j--){
        //     ll jj=j;
        //     for (ll l=uu;l>1;l--){
        //         if (vv.at(l)==0 && jj%l==0) {jj=jj/l;vv.at(l)=1;}
        //     }
        //     ans=(ans*jj)%are;
        // }}
        ll o=r-i;
        ans=ans*combination(o+i+1,i+1)%MOD;
        // ll kk=min(o,i+1);
        // if (o<0) {cout << 0 << endl;continue;}
        // vector<int> v(kk+1);
        // rep(l,kk+1) v.at(l)=0;
        // if (o>0){for (ll j=o+i+1;j>max(o,i+1);j--){
        //     ll jj=j;
        //     for (ll l=kk;l>1;l--){
        //         if (v.at(l)==0 && jj%l==0) {jj=jj/l;v.at(l)=1;}
        //     }
        //     ans=(ans*jj)%are;
        // }}
        cout << ans << endl;

    }
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void)
{
	int box[26],flg,len,i;
	char s[100001];
	scanf("%s",s);
	flg=0;
	for(i=0;i<26;i++){
		box[i]=0;
	}
	len=strlen(s);
	for(i=0;i<len;i++){
	    box[s[i]-'a']++;
	}
	for(i=0;i<26;i++){
		if(box[i]==0){
			printf("%c\n",i+'a');
			flg=1;
			break;
		}
	}
	if(flg==0){
		printf("None\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    string t;
    int n = s.size();
    rep(i, n) if (s[i] != 'x') t += s[i];
    if (t != string(t.rbegin(), t.rend())) {
        cout << -1 << endl;
        return 0;
    }
    int r = n-1;
    int ans = 0;
    for (int l = 0; l < r;) {
        if (s[l] == s[r]) {
            l++; r--;
        } else if (s[l] == 'x') {
            ans++; l++;
        } else if (s[r] == 'x') {
            ans++; r--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3780
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int A, B, C; cin >> A >> B >> C;
	if (B + C >= A)cout << C-(A-B) << endl;
	else cout << 0 << endl;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    vector<int> m(3);
    rep(i,3) cin >> m[i];
    sort(all(m));
    cout << m[0] + m[1] << endl;
    return 0;
}

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


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


#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif

template<typename T> T ModPOW(T a, long long n, T e = 1) {
	T ret = e;
	while (n) {
		if (n & 1) ret *= a;
		a *= a;
		n >>= 1;
	}
	return ret;
}

template<long long mod> struct ModLL
{
	long long x;
	ModLL() : x(0) {}
	ModLL(long long x_) { if ((x = x_ % mod + mod) >= mod) x -= mod; }
	ModLL& operator+=(ModLL mll) { if ((x += mll.x) >= mod) x -= mod; return *this; }
	ModLL& operator-=(ModLL mll) { if ((x -= mll.x) < 0) x += mod; return *this; }
	ModLL& operator*=(ModLL mll) { x = (unsigned long long) x * mll.x % mod; return *this; }
	ModLL& operator/=(ModLL mll) { x = (unsigned long long) x * mll.inv().x % mod; return *this; }

	ModLL operator-() const { return -x < 0 ? mod - x : -x; }
	ModLL operator+(ModLL mll) const { return ModLL(*this) += mll; }
	ModLL operator-(ModLL mll) const { return ModLL(*this) -= mll; }
	ModLL operator*(ModLL mll) const { return ModLL(*this) *= mll; }
	ModLL operator/(ModLL mll) const { return ModLL(*this) /= mll; }
	bool operator==(ModLL mll) const { return x == mll.x; }
	bool operator!=(ModLL mll) const { return x != mll.x; }
	ModLL inv() const { return ModPOW(*this, mod - 2); }

	bool operator < (const ModLL& mll) const { return x < mll.x; }
	bool operator <= (const ModLL& mll) const { return x <= mll.x; }
	bool operator > (const ModLL& mll) const { return x > mll.x; }
	bool operator >= (const ModLL& mll) const { return x >= mll.x; }

	friend ostream& operator<<(ostream& s, ModLL<mod> a) { s << a.x; return s; }
	friend istream& operator>>(istream& s, ModLL<mod>& a) { s >> a.x; return s; }
};

using mll = ModLL<1000000007>;

mll Block1(vector<mll>& a)
{
	mll count = 0;
	rep(i, 0, size(a)-1)
	{
		rep(j, i+1, size(a))
		{
			if (a[i] > a[j])
				count += 1;
		}
	}

	return count;
}

mll Block2(vector<mll>& a1, vector<mll>& a2)
{
	mll count = 0;
	rep(i, 0, size(a1))
	{
		rep(j, 0, size(a2))
		{
			if (a1[i] > a2[j])
				count += 1;
		}
	}

	return count;
}

mll Comb2(mll k)
{
	mll ans = 1;

	ans *= k;
	ans *= (k - 1);
	ans /= 2;

	return ans;
}

int main(void)
{
	ll n; cin >> n;
	mll k;  cin >> k;

	vector<mll> a(n);
	rep(i, 0, n)
		cin >> a[i];

	mll sum = Block1(a) * k;

	mll c2 = Comb2(k);
	mll block2 = Block2(a, a);

	sum += (c2 * block2);

	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int dmax;
vector<vector<int>> G;
vector<vector<int>> color;

void bfs(int s, int d, int c) {
  queue<P> que;
  que.push({s, d});
  while (!que.empty()) {
    P p = que.front(); que.pop();
    int u = p.first, l = p.second;
    if (color[u][l] >= 0) continue;
    for (int i = 0; i <= l; i++) {
      if (color[u][i] == -1) color[u][i] = c;
    }
    for (auto&& v : G[u]) que.push({v, l - 1});
  }
}
main() {
  int N, M; cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int Q; cin >> Q;
  vector<int> v(Q), d(Q), c(Q);
  for (int i = 0; i < Q; i++) {
    cin >> v[i] >> d[i] >> c[i];
    v[i]--;
    dmax = max(dmax, d[i]);
  }
  color.assign(N, vector<int>(dmax + 1, -1));
  for (int i = Q - 1; i >= 0; i--) {
    bfs(v[i], d[i], c[i]);
  }
  for (int i = 0; i < N; i++) cout << ( (color[i][0] == -1) ? 0 : color[i][0] ) << endl;
}


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

namespace Beg122D
{
    class Program
    {
        public static int N,mod;
        public static Dictionary<Tuple<string, int>, int> memo;
        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());
            mod = 1000000000 + 7;
            memo = new Dictionary<Tuple<string, int>, int>();
            Console.WriteLine(dfs(0, "TTT"));


        }
        public static int dfs(int cur, string last3)
        {
            var pair = new Tuple<string, int>(last3, cur);
            if (memo.Keys.Contains(pair))
                return memo[pair];
            var ret = 0;
            if (cur == N)
                return 1;
            foreach(var c in "AGCT")
            {
                if (strOK(last3 + c))
                    ret = (ret + dfs(cur + 1, last3.Substring(1) + c)) % mod;
            }
            memo.Add(new Tuple<string, int>(last3, cur), ret);
            return ret;
        }
        public static bool strOK(string last4)
        {
            if (last4.Contains("AGC"))
                return false;
            for(int i=0;i<3;i++)
            {
                var last4Array = last4.ToArray();
                last4Array[i] = last4.ElementAt(i + 1);
                last4Array[i + 1] = last4.ElementAt(i);
                var converted = new String(last4Array);
                if (converted.Contains("AGC"))
                    return false;
            }
            return true;
        }
        
    }
}


Measured memory_bytes: 18364
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    String S = sc.next();
    StringBuilder Sb = new StringBuilder();
    Sb.append(S);
    switch (S.charAt(K-1)){
        case 'A': Sb.replace(K-1,K,"a"); break;
        case 'B': Sb.replace(K-1,K,"b"); break;
        case 'C': Sb.replace(K-1,K,"c"); break;
    }
    System.out.println(Sb.toString());
    sc.close();
  }
}

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

using ll = long long;

vector<string> maps;
int H, W;

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

void view(vector<string> field, int h){
    for(int i =0; i< h; i++){
        cout << field.at(i) << endl;
    }
    cout << endl;
}

int search(vector<string> field, int h, int w){
    queue<pair<vector<int>, int>> que;
    vector<int> b1 = {h, w};
    field.at(h).at(w) = 's';
    que.push(make_pair(b1, 0));
    int count = 0;
    int ans = 0;
    // cout << "aa" << endl;
    while(!que.empty()){
        pair<vector<int>, int> buf = que.front();
        que.pop();
        count = buf.second + 1;
        for(int i = 0; i< 4 ; i++){
            int yy = buf.first.at(0) + dy[i];
            int xx = buf.first.at(1) + dx[i];
            // cout << yy << xx << endl;
            if(yy < 0 || xx < 0 || yy >=H || xx >= W){
                continue;
            }else{

            if(field.at(yy).at(xx) == '.'){
                vector<int> b2 = {yy, xx};
                que.push(make_pair(b2, count));
                ans = max(ans, count);
                field.at(yy).at(xx) = 's';
                // view(field, H);
            }
            }
        }

    }
    return ans;
}

int main()
{

    cin >> H >> W;
    maps = vector<string>(H);
    for(int i = 0; i< H; i++){
        cin >> maps.at(i);
    }
    int ans = 0;

    for(int h = 0; h<H; h++){
        for(int w = 0; w<W; w++){
            if(maps.at(h).at(w) == '.'){
                ans = max(ans, search(maps, h, w));
            }
            
        }
    }

    cout << ans << endl;

}

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

#define MAXN 300

typedef long long ll;

using namespace std;

typedef struct EDGE {
  int s,t;
  ll w;
} edge;

bool operator< ( const edge& x, const edge& y )
{
  if ( x.w != y.w ) return x.w < y.w;
  return x.s < y.s;
}

ll D[MAXN][MAXN];
bool F[MAXN][MAXN];
int N;
vector<edge> E;

bool warshal ( void )
{
  for ( int k = 0; k < N; ++k ) {
    for ( int i = 0; i < N; ++i ) {
      for ( int j = 0; j < N; ++j ) {
        ll tmp = D[i][j];
        D[i][j] = min( D[i][j], D[i][k]+D[k][j] );
        if ( tmp != D[i][j] ) return false;
      }
    }
  }

  return true;
}

ll cal ( void ) {
  if ( !warshal() ) return -1;

  ll ans = 0;
  sort(E.begin(), E.end() );

  for ( int i = 0; i < N; ++i ) for ( int j = 0; j < N; ++j ) F[i][j] = true;

  for ( auto it = E.begin(); it != E.end(); ++it ) {
    edge tmp = *it;
    //if ( !F[it->s][it->t] ) continue;
    for ( int i = 0; i < N; ++i ) {
      if ( tmp.t != i && tmp.w + D[tmp.t][i] == D[tmp.s][i] ) F[tmp.s][i] = F[i][tmp.s] = false;
      if ( tmp.s != i && tmp.w + D[tmp.s][i] == D[tmp.t][i] ) F[tmp.t][i] = F[i][tmp.t] = false;
    }
  }

  for ( int i = 0; i < N; ++i ) {
    for ( int j = 0; j < N; ++j ) {
      if ( F[i][j] ) ans += D[i][j];
    }
  }

  return ans/2;
}

int main()
{
  cin >> N;

  for ( int i = 0; i < N; ++i ) {
    for ( int j = 0; j < N; ++j )  {
      scanf("%d", &D[i][j]);
      if ( i < j ) E.push_back( { i, j, D[i][j]} );
    }
  }

  cout << cal() << "\n";

  /*
  for ( auto it = E.begin(); it != E.end(); ++it ) {
    cout << it->s << " " << it->t << " " << it->w << "\n";
  }
  */
}


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

int main() {
    string s;
    cin >> s;
    int cnt01, cnt10;
    cnt01 = cnt10 = 0;
    string str01, str10;
    rep(i, s.size()) {
        if (i%2==0) {
            if (s[i] == '0') cnt10 += 1;
            else cnt01 += 1;
        } else {
            if (s[i] == '1') cnt10 += 1;
            else cnt01 += 1;
        }
    }
    cout << min(cnt01, cnt10) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N, vector<ll> A){
    ll ct = 0, j = 0;
    rep(i,N) if(A[i] == i+1) ct++;
    rep(i,N-1) if(A[i] == i+1 && A[i+1] == i+2) j++, i++;
    ct -= j;
    return ct;
}

int main(){
    ll N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    pr(solve(N,A));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/


struct Edge{
    long long to, cost;
    Edge(long t, long c){
        to = t;
        cost = c;
    }
};

class Bellman_Ford{
    private:
        const long long Inf = 1LL << 50;
        vector<long long> dist;
        vector<vector<Edge> > adj;
    public:
        Bellman_Ford(int v){
            dist = vector<long long>(v + 1);
            adj = vector<vector<Edge> >(v + 1);
            for(int i = 0; i < (int)dist.size(); i++)dist[i] = Inf;
        }

        void add_edge(int from, int to, int cost){
            adj[from].push_back(Edge(to, cost));
        }

        bool shortest_path(int s){
            dist[s] = 0;
            for(int k = 0; k < (int)dist.size(); k++){
                for(int i = 0; i < (int)dist.size(); i++){
                    for(int  j = 0; j < (int)adj[i].size(); j++){
                        Edge e = adj[i][j];
                        if(dist[e.to] > dist[i] + e.cost && dist[i] != Inf){
                            dist[e.to] = dist[i] + e.cost;
                        }
                    }
                }
            }
            return true;
        }

        long long get_distance(int x){
            return dist[x];
        }

        void DEBUG(){
            for(int i = 0; i < (int)dist.size(); i++){
                cout << 1 << " --> " << i << " = " << dist[i] << endl;
            }
        }
};

int main(){
    int n, m, a, b, c;
    cin >> n >> m;
    Bellman_Ford bel(n + 1);
    rep(i, m){
        cin >> a >> b >> c;
        bel.add_edge(a, b, -c);
    }
    bel.shortest_path(1);
    ll first = bel.get_distance(n);
    bel.shortest_path(1);
    ll second = bel.get_distance(n); 
    if(first == second){
        cout << -first << endl;
    }else{
        cout << "inf" << endl;
    }
    return 0;
}


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

struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
  Ps operator+(const Ps&p)const
  { return Ps(r+p.r,c+p.c);  }
  friend istream& operator>>(istream&is,Ps&p)
  {is >> p.r >> p.c; return is;  }
};

int main(){
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s >> g;
  s = s+Ps(-1,-1);
  g = g+Ps(-1,-1);
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c;}() == '.';
  optional<int> distance[1000][1000];
  deque<pair<Ps,int>> dq;
  dq.emplace_front(s,0);
  while(!dq.empty()){
    auto [ps,di] = dq.front();
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    if(ps.r==g.r && ps.c==g.c)break;
    static int mr[] = {0,0,1,-1};
    static int mc[] = {1,-1,0,0};
    for(int i = 0; i < 4; ++i){
      Ps nps = ps + Ps(mr[i],mc[i]);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      if(distance[nps.r][nps.c])continue;
      dq.emplace_front(nps,di);
      mz[nps.r][nps.c] = 0;
    }
    for(int i = -2; i <= 2; ++i){
      for(int j = -2; j <= 2; ++j){
	Ps nps = ps + Ps(i,j);

	if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
	if(!mz[nps.r][nps.c])continue;
	if(distance[nps.r][nps.c])continue;
	dq.emplace_back(nps,di+1);
      }
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c].value() : -1) << endl;
}


Measured memory_bytes: 12116
#include<cstdio>
#include<cstring>
char s[100001];
int main()
{
    //freopen("f.in","r",stdin);
    //freopen("f.out","w",stdout);
    int n,i,t=1;
    scanf("%s\n",s);
    n=strlen(s);
    if(s[0]=='0'||s[n-1]=='1')
        printf("-1\n");
    else
    {
        for(i=1;i<=(n-2)/2;++i)
        {
            if(s[i]!=s[n-2-i])
            {
                printf("-1\n");
                break;
            }
        }
        if(i==n/2)
        {
            for(i=0;i<n-1;++i)
            {
                printf("%d %d\n",t,i+2);
                if(s[i]=='1')
                    t=i+2;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(){
    int A[3][3];
    bool Abingo[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A[i][j];
            Abingo[i][j]=false;
        }
    }
    int N;
    cin>>N;
    int b[N];
    for(int i=0;i<N;i++)cin>>b[i];

    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(b[i]==A[j][k]){
                    Abingo[j][k]=true;
                }
            }
        }
    }
    bool judge=false;
    for(int i=0;i<3;i++){
        if(Abingo[i][0]&&Abingo[i][1]&&Abingo[i][2]){
            judge=true;
            break;
        }
        if(Abingo[0][i]&&Abingo[1][i]&&Abingo[2][i]){

            judge=true;
            break;
        }
        if(Abingo[0][0]&&Abingo[1][1]&&Abingo[2][2]){
            judge=true;
            break;
        }
        if(Abingo[2][0]&&Abingo[1][1]&&Abingo[0][2]){
            judge=true;
        }
        
    }
    if(judge){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line =sc.nextLine();
            String answer ="";
            int length=line.length();
            for(int i=0;i<length;i++){
                char ch=line.charAt(i);
                if('a'<=ch && ch<='z'){
                 ch-=32;
                }else if('A'<=ch && ch<='Z'){
                    ch+=32;
                }
               answer+=ch;
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31548
import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
us = np.zeros((H,W), dtype=int)    # .の連続数を格納用
ds = np.zeros((H,W), dtype=int)    # .の連続数を格納用
ls = np.zeros((H,W), dtype=int)    # .の連続数を格納用
rs = np.zeros((H,W), dtype=int)    # .の連続数を格納用

for h in range(1,H):
    us[h, :] = (us[h-1, :] + 1) * S[h-1, :]
for h in range(H-2, -1, -1):
    ds[h, :] = (ds[h+1, :] + 1) * S[h+1, :]
for w in range(1,W):
    ls[:, w] = (ls[:, w-1] + 1) * S[:, w-1]
for w in range(W-2, -1, -1):
    rs[:, w] = (rs[:, w+1] + 1) * S[:, w+1]

ans = ((us + ds + ls + rs)*S).max() + 1
print(ans)

Measured memory_bytes: 219816
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


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

  string S, T;
  cin >> S >> T;

  for(int i=0;i<N;i++){
    cout << S[i] << T[i];
  }
  cout << endl;

  return 0;
}


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

int main() {
  string s; cin >> s;
  vector<int> v(4);
  for (int i = 0; i < 4; i++) v[i] = s[i] - '0';
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int ans = v[0];
        ans += i ? -v[1] : v[1];
        ans += j ? -v[2] : v[2];
        ans += k ? -v[3] : v[3];
        if (ans == 7) {
          cout << v[0] << (i ? '-' : '+');
          cout << v[1] << (j ? '-' : '+');
          cout << v[2] << (k ? '-' : '+');
          cout << v[3] << "=7" << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
def nyu():
    K,N  = map(int,input().split())
    A = list(map(int,input().split()))
    return K,N,A

def check(K,N,A):
    a_dsn =[]
    sum = 0

    for a in range(len(A)-1):
        a_dsn.append(A[a+1] - A[a])
    
    a_dsn.append(A[0]+K-A[N-1])
    a_dsn.sort()
    #print(a_dsn)
    
    for a in range(len(a_dsn)-1):
        sum += a_dsn[a]

    print(sum)
    



K,N,A = nyu()
check(K,N,A)

Measured memory_bytes: 26444
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    s = input()
    if s[-1] == 's':
        s+='es'
    else:
        s+='s'
    print(s)






main()


Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n, k; cin >> n >> k;
    ll ans = k;
    rep(i, n-1) ans *= k-1;
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    float ans = 0.0;
    float a[60];
    for(int i = 0;i < n;i++) cin >> a[i];
    sort(a,a+n);
    float tmp = (a[0]+a[1])/2;
    if(n == 2){
         cout << fixed << setprecision(10) << tmp  << endl;
         return 0;
    }
    for(int i = 0;i < n-2;i++){
        tmp = (tmp+a[i+2])/2;
        //tmp = ans;
    }
    cout << fixed << setprecision(10) << tmp  << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)#7
a = 0
f = (N-1)//2
for i in range(N):
    if S[i] != S[-i-1]:
        a = 1
for i in range(f):
    if S[i] !=S[f-i-1]:
        a = 1
b = 0
for j in range((N+3)//2-1,N):
    b += 1
    if S[j] != S[N-b]:
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n, l;
	cin >> n >> l;
	int sum = 0;

	std::vector<int> t(n);
	rep(i,n){
		t[i] = abs(l + i);
	}
	sort(ALL(t));

	rep(i,n){
		if(abs(l+i) != t[0]){
			sum += l+i;
		}
	}
	cout << sum << endl;


  return 0;
}


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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           200001
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(ll i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(ll i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<ll> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}

void solve(ll test){

    ll l,r,d;
    cin >> l >> r >> d;
    ll cnt = 0;

    fr(i,l,r+1,1){
        if(i%d == 0)cnt++;
    }

    cout << cnt;


}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

string render(int x, int y){
    string x_str = to_string(x);
    string ans = "";
    rep(i,y){
        ans = ans + x_str;
    }
    return ans;
}

void solve(){
  int a,b;
  cin >> a >> b;
  string ans = a<b ? render(a,b): render(b,a);
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,a[N],vis[N],tot[N],ans[N],nxt[N];
ll k;
vector<int>v[N];

int main(){
	n=read(),k=read();
	For(i,1,n) a[i]=read(),v[a[i]].pb(i),vis[i]=-1;
	int x=1,cnt=1;
	vis[x]=1;
	while (233){
		if (x==v[a[x]].back()) nxt[x]=v[a[x]][0],++cnt;
			else nxt[x]=*upper_bound(all(v[a[x]]),x);
		if (cnt>=k){
			x=1,--k;break;
		}
		x=nxt[x];
		if (x==n) x=1,++cnt;
			else ++x;
		if (vis[x]!=-1){
			int tmp=cnt-vis[x];
			k=(k-vis[x])%tmp;
			break;
		}
		vis[x]=cnt;
	}
	while (k){
		if (nxt[x]<=x) k--;
		x=nxt[x];
		if (x==n) x=1,--k;
			else ++x;
	}
	For(i,x,n){
		if (tot[a[i]]){
			while (tot[a[i]]) tot[ans[*ans]]--,--*ans;
		} else ans[++*ans]=a[i],tot[a[i]]++;
	}
	For(i,1,*ans) printf("%d ",ans[i]);
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 200001

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n, a, b, m = 0;
    cin >> n;
    map<ll, ll> job;
    REP(i, 0, n) {
        cin >> a >> b;
        m = max(m, b);
        job[b] += a;
    }
    ll p = 1, t = m;
    for (auto i = job.rbegin(); i != job.rend(); i++) {
        a = i->first, b = i->second;
        t = min(t, a);
        if (b <= t)
            t -= b;
        else {
            p = 0;
            break;
        }
    }
    if (p)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
using namespace std;
#include<algorithm>
int main() {
	// your code goes here
	int n,i;
	cin>>n;
	int a[n];
	int ans = n;
	for(i = 0;i<n;i++)
	{
		cin>>a[i];}
	sort(a,a+n);
	int mark = a[0];
	for(i = 1;i<n;i++)
	{
		if(a[i]==mark)
			ans--;
		else 
			mark = a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
    a,b = input().split()
    l.append((a,b))
x = input()
count = 0
for i in range(n):
  if l[i][0] == x:
    f = i
    break
for i in range(f+1,n):
  count += int(l[i][1])
print(count)


Measured memory_bytes: 3060