akhauriyash/Code-Regression huggingface dataset:
A = [[0] * 3 for i in range(3)]

for i in range(3):
    A[i] = [int(s) for s in input().split()]

N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

ans = "No"
# yoko
for i in range(3):
    if sum(A[i]) == 0:
        ans = "Yes"

# tate
x = A[0][0] + A[1][0] + A[2][0]
if x == 0:
    ans = "Yes"
x = A[0][1] + A[1][1] + A[2][1]
if x == 0:
    ans = "Yes"
x = A[0][2] + A[1][2] + A[2][2]
if x == 0:
    ans = "Yes"

# naname
x = A[0][0] + A[1][1] + A[2][2]
if x == 0:
    ans = "Yes"
x = A[0][2] + A[1][1] + A[2][0]
if x == 0:
    ans = "Yes"


print(ans)


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const ll MOD = 1000000007;
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> a;
	REP(i,n)
	{
		int t;
		cin >> t;
		if (t != 0)
			a.pb(t);
	}
	
	sort(ALL(a));
	int s = a.size();
	a.erase(unique(ALL(a)), a.end());
	for(auto i : a) dbg(i);
	dbg(s);dbg(a.size());
	if ((a.size()*2) != s)
	{
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	REP(i,a.size())
	{
		ans *= 2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

long long N;
string S;
int P;

long long solve() {
    if (P == 2 || P == 5) {
        long long res = 0;
        for (int i = 0; i < N; ++i) if ((S[N-i-1]-'0') % P == 0) res += N-i;
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor = 1;
    long long cur = 0;
    val[cur]++;
    for (int i = 0; i < N; ++i) {
        cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
        tenfactor = (tenfactor * 10) % P;
        val[cur]++;
    }
    long long res = 0;
    for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
    return res;
}

int main() {
    cin >> N >> P >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 640
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	int a,b;
	char op;
	
	do
	{cin >>a >>op >>b;
		if (op =='+')
			{cout <<a +b <<"\n";}
		else if(op =='-'){
			cout << a - b<<"\n";
		}
		else if(op =='*'){
			cout <<a * b<<"\n";
		}
		else if (op =='/'){
			cout << a/b <<"\n";
		}
		else if (op =='?') break;} while(op !='?');
	return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a, cnt[200005], ans;
map<int, int>mp;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (!i)cnt[i] = a;
		else cnt[i] = cnt[i - 1] + a;
	}
	mp[0] = 1;
	for (int i = 0; i < n; i++) {
		ans += mp[cnt[i]];
		mp[cnt[i]]++;
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 14336
#include <cstdio>
#include <algorithm>
#include <utility>

int dp[3000];

int main()
{
  int n, t;
  scanf("%d%d", &n, &t);
  using pair = std::pair<short, short>;
  pair ab[3000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", &ab[i].first, &ab[i].second);
  }
  std::sort(ab, ab + n);
  int ans = 0;
  for (int i = 0; i < n - 1; ++i)
  {
    for (int j = t - 1; j >= 0; --j)
    {
      if (j - ab[i].first >= 0 && dp[j] < dp[j - ab[i].first] + ab[i].second)
      {
        dp[j] = dp[j - ab[i].first] + ab[i].second;
      }
    }
    if (ab[i + 1].second + dp[t - 1] > ans) ans = ab[i + 1].second + dp[t - 1];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		//入力
		int x = sc.nextInt();

		//処理
		int ans = 0;
		ans = x * x * x;

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

	}

}



Measured memory_bytes: 26112
# D - Lazy Faith

import bisect
INF = 10**18
A, B, Q = map(int, input().split())
S = [0]*A
T = [0]*B
X = [0]*Q
for i in range(A):
    S[i] = int(input())

for i in range(B):
    T[i] = int(input())

for i in range(Q):
    X[i] = int(input())

for x in X:
    #print(x)
    idxS = bisect.bisect_left(S, x)
    #print('idxS', idxS)
    if idxS==0:
        leftS = INF
        rightS = S[idxS] - x
    elif idxS==A:
        leftS = x - S[idxS-1]
        rightS = INF
    else:
        leftS = x - S[idxS-1]
        rightS = S[idxS] - x
    #print(leftS, rightS)
    idxT = bisect.bisect_left(T, x)
    if idxT==0:
        leftT = INF
        rightT = T[idxT] -x
    elif idxT==B:
        leftT = x - T[idxT-1]
        rightT = INF
    else:
        leftT = x - T[idxT-1]
        rightT = T[idxT] - x
    #print(leftT, rightT)
    ans = max(leftS, leftT)
    ans = min(ans, max(rightS, rightT))
    ans = min(ans, leftS * 2 + rightT)
    ans = min(ans, leftT * 2 + rightS)
    ans = min(ans, leftS + rightT * 2)
    ans = min(ans, leftT + rightS * 2)
    print(ans)

Measured memory_bytes: 16128
#include<stdio.h>
#include<string.h>
int main(){
    int n;
    int ac,wa,tle,re;
    ac=wa=tle=re=0;
    char s[100000+1][3+1];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    for(int i=0;i<n;i++){
        if(strcmp(s[i],"AC")==0){
            ac++;
        }else if(strcmp(s[i],"WA")==0){
            wa++;
        }else if(strcmp(s[i],"TLE")==0){
            tle++;
        }else if(strcmp(s[i],"RE")==0){
            re++;
        }
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
}

Measured memory_bytes: 2116
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
//////////////////////////////////////////////////////////

int main(void){
	int a,b;cin >> a >> b;
	if(b >= a){
		cout << "unsafe" << '\n';
	}else{
		cout << "safe" << '\n';
	}
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  vector<int> h(N);
  REP(i, N) { cin >> h.at(i); }

  int ans = 0;
  int l;
  while (true) {
    l = -1;
    REP(i, N) {
      // cout << i << ":" << h.at(i) << endl;
      if (h.at(i) > 0) {
        if (l == -1) {
          l = i;
        }
        --h.at(i);
      } else {
        if (l != -1) {
          break;
        }
      }
    }

    if (l == -1) {
      break;
    }
    ++ans;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include<iostream>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
int main(){
   //A
   /*
   int r;cin>>r;
   cout<<2*M_PI*r<<endl;
   */
  //B
  /*
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  int c=0;
  rep(i,0,m){ 
    cin>>a[i];
    c+=a[i];
  }
  if(c<=n) cout<<n-c<<endl;
  else cout<<-1<<endl;
  */
  //C
  int n;cin>>n;
  vector<int> a(n-1);
  rep(i,0,n-1) cin>>a[i];
  map<int,int> p;
  rep(i,0,n-1){
      p[a[i]]++;
  }
  rep(i,0,n) cout<<p[i+1]<<endl;
}

Measured memory_bytes: 13520
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var an = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            var bn = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            var ba = 0L;
            var ab = 0L;
            for(var i=0;i<N;i++)
            {
                var a = an[i];
                var b = bn[i];
                if (b > a) ba += (b - a) / 2;
                else ab += a - b;
            }
            Console.WriteLine(ba >= ab ? "Yes":"No");
        }
    }
}

Measured memory_bytes: 21184
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD =1000000007;

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}
ll modComb(ll n,ll a){
  ll x=1,y=1;
  rep(i,a){
    x*=n-i;
    x%=MOD;
    y*=i+1;
    y%=MOD;
  }
  y=modPow(y,MOD-2);
  return (x*y)%MOD;
}

int main(){
  ll N,ans=0;
  cin >> N;
  vector<ll> A(N),Pow(61);
  vector<P> B(60,P(0,0));
  rep(j,61){
    Pow.at(j)=(ll)pow(2,j);
  }
  rep(i,N){
    cin >> A.at(i);
    rep(j,60){
      if(A.at(i)%Pow.at(j+1)>A.at(i)%Pow.at(j)){
        B.at(j).first++;
      }else{
        B.at(j).second++;
      }
    }
  }
  rep(j,60){
    ans+=((B.at(j).first*B.at(j).second)%MOD)*modPow(2,j);
    ans%=MOD;
  }
  cout << ans << endl;
  
  
  
  
  
  
}

Measured memory_bytes: 2560
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <ostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef queue< pair<int, int> > qpii;
typedef vector<int> vi;
typedef vector<int, int> vii;
typedef vector<string> vs;
typedef vector< pair<int, int> > vpii;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

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

	stack<int> s;
	int k;

	while(cin >> k) {
		if(k == 0) {
			cout << s.top() << endl;
			s.pop();
		} else {
			s.push(k);
		}
	}

	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  cin>>n ;
  ll arr[n] ;
  for(i=0;i<n;i++)
    cin>>arr[i] ;
  sort(arr,arr+n,greater<ll>()) ;
  cnt=0 ;
  k=n-2 ;
  cnt=arr[0] ;
  for(i=1;i<n;i++)
  {
      if(k==0)
        break ;
      cnt+=arr[i] ;
      k-- ;
      if(k==0)
        break ;
      cnt+=arr[i] ;
      k-- ;

  }

  cout<<cnt ;
  return 0 ;}


Measured memory_bytes: 5180
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >>n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int count = 0;
		for(int i = 0; i < n - 1; ++i)
		{
			for(int j = n - 1; j > i; --j)
			{
				if(Vec[j - 1] > Vec[j])
				{
					int temp = Vec[j];
					Vec[j] = Vec[j - 1];
					Vec[j - 1] = temp;
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef vector<int> vi;

int main() {
	int N,Lsum = 0,Lmax = 0;
	cin >> N;
	vi L(N);
	rep(i,N){
		cin>>L[i];
		Lmax = max(Lmax,L[i]);
		Lsum+=L[i];
	}
	string ans = "No";
	if(Lsum-Lmax > Lmax)ans = "Yes";
	cout << ans << endl;
}

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

deque<char> X,Y;
LL A,E,S,R;
LL dp[101][101];

bool loop(){
 X.clear(); Y.clear();

 string SX,SY;
 cin>>SX; if(SX=="#") return false;
 cin>>SY;
 for(char c:SX) X.push_back(c);
 for(char c:SY) Y.push_back(c);
 cin>>A>>E>>S>>R;

 LL offset=0;
 LL ans=1000000000000000;

 rep(i,Y.size()){
  rep(x,X.size()+1) rep(y,Y.size()+1) dp[x][y]=1000000000000000;
  dp[0][0]=offset;
  rep(x,X.size()+1) rep(y,Y.size()+1){
   if(x!=X.size()) dp[x+1][y]=min(dp[x+1][y],dp[x][y]+E);
   if(y!=Y.size()){
    if(y<i) dp[x][y+1]=min(dp[x][y+1],dp[x][y]+A-R);
    else dp[x][y+1]=min(dp[x][y+1],dp[x][y]+A);
   }
   if(x!=X.size() && y!=Y.size()){
    if(X[x]==Y[y]) dp[x+1][y+1]=dp[x][y];
    else dp[x+1][y+1]=min(dp[x+1][y+1],dp[x][y]+S);
   }
  }

  ans=min(ans,dp[X.size()][Y.size()]);

  Y.push_front(Y.back()); Y.pop_back(); offset+=R;
 }
 cout<<ans<<endl;
 return true;
}

int main(){
 while(loop());

 return 0;
}



Measured memory_bytes: 3164
N=int(input())
a=[]
button=1
i=0
cnt=0
for j in range(N):
    a.append(int(input()))
while i < N and button != 2:
    button=a[button-1]
    i+=1
    cnt+=1
if i == N:
    print("-1")
else:
    print(str(cnt))

Measured memory_bytes: 7084
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	
	int n;
	int[] A;
	int m,cnt;
	int h;
	public ArrayList<Integer> G  = new ArrayList<Integer>();
	
	public void input() {
		n = sc.nextInt();
		A = new int[n];
		for(int i=0; i<n; i++) {A[i] = sc.nextInt();}
	}
	
	public void shellSort() {
		cnt = 0;
		m = 0;
		for(h =1; h<=n; h=h*3+1) {
			m++;
			G.add(h);
		}
		for(int i=m-1; i>=0; i--) {insertSort(G.get(i));}
	}
	
	public void insertSort(int g) {
		for(int i=g; i<n; i++) {
			int v = A[i];
			int j = i -g;
			while(j>=0 && A[j] > v) {
				A[j+g]  =A[j];
				j -= g;
				cnt++;
			}
			A[j+g] = v;
		}
	}
	
	public void output() {
		System.out.println(m);
		for(int i=G.size()-1; i>=0; i--) {
			if(i == 0) System.out.println( G.get(i) );
			else System.out.print(G.get(i)+" ");
		}
		System.out.println(cnt);
		for(int i=0; i<n; i++) System.out.println(A[i]);
		System.out.println();
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.shellSort();
		obj.output();
	}
}



Measured memory_bytes: 306656
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

int main(){
  int K, T;
  vector<int>vec;
  cin >> K >> T;
  priority_queue<int>que;
  for(int i = 0 ; i < T ; i++){
    int t; cin >> t;
    que.push(t);
  }
  while(que.size() > 1){
    int x = que.top();
    que.pop();
    int y = que.top();
    que.pop();
    x--;
    y--;
    if(x)que.push(x);
    if(y)que.push(y);
  }
  cout << que.top() - 1 << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int N;
	cin >> N;
	vector<long long int> A(N);
	int i;
	long long int hi=0;
	int he;
	cin >> A[0];
	he = A[0];
	for (i = 1; i < N;i++) {
		cin >> A[i];
			if (A[i] < A[i-1]) {
				hi +=he - A[i];
				A[i] = A[i - 1];
			}
			else {
				he = A[i];
			}
	}
	cout << hi;
	return 0;
}

Measured memory_bytes: 4724
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  int t, a;
  readf("%s %s\n", &t, &a);
  
  auto h = readln.chomp.split.to!(int[]);
  int ri;
  auto rd = double.max;
  foreach (i; 0..n) {
    auto ld = abs(a - (t - h[i] * 0.006));
    if (ld < rd) {
      ri = i + 1;
      rd = ld;
    }
  }

  ri.writeln;
}


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

int main() {
    int n;
    cin >> n;
    string _s;
    cin >> _s;
    V<bool> s;
    for (char c: _s) s.push_back(c == '1');
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < n; j++) {
            if (!s[i] && s[i | (1 << j)]) {                
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    using P = pair<int, int>;
    V<P> ans;
    for (int i = 0; i < (1 << n); i++) {
        if (s[i]) continue;
        bool minimum = true;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) && !s[i ^ (1 << j)]) {
                minimum = false;
                break;
            }
        }
        if (!minimum) continue;
        //
        int st = 0;
        while (!(i & (1 << st))) st++;
        V<P> path = {P(st + 1, 0), P(st, 0), P(st, 1), P(st + 1, 1)};
        for (int j = st + 1; j < n; j++) {
            if (i & (1 << j)) {
                V<P> npath = {P(j + 1, 0)};
                npath.insert(npath.end(), path.begin(), path.end());
                npath.push_back(P(j, 0));
                npath.push_back(P(j + 1, 0));
                npath.push_back(P(j + 1, 1));
                npath.insert(npath.end(), path.rbegin(), path.rend());
                npath.push_back(P(j, 1));
                npath.push_back(P(j + 1, 1));
                path = npath;
            } else {
                path.insert(path.begin(), P(j + 1, 0));
                path.push_back(P(j, 0));
                path.push_back(P(j + 1, 0));
                path.push_back(P(j + 1, 1));
            }
        }
        ans.insert(ans.end(), path.begin(), path.end());
    }
    ans.push_back(P(n, 0));
/*    V<P> ans2;
    for (auto p: ans) {
        ans2.push_back(p);
        int s = int(ans2.size());
        if (s >= 3 && ans2[s - 1] == ans2[s - 3]) {
            ans2.pop_back();
            ans2.pop_back();
        }
    }
    ans = ans2;*/

    assert(ans.size() <= 250000);
    cout << "Possible" << "\n";
    cout << int(ans.size()) - 1 << "\n";
    for (auto p: ans) {
        cout << p.first << " " << p.second << "\n";
    }
    return 0;
}


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

void to_int(char x, long &n) {
  
  if (x == '0') n = 0;
  else if (x == '1') n = 1;
  else if (x == '2') n = 2;
  else if (x == '3') n = 3;
  else if (x == '4') n = 4;
  else if (x == '5') n = 5;
  else if (x == '6') n = 6;
  else if (x == '7') n = 7;
  else if (x == '8') n = 8;
  else if (x == '9') n = 9;
  else cout << "error 'to_int' x different int" << endl;
}

long many_formulas(long i, long a, long b, vector<long> number_sequence) {
  long ans, n = number_sequence.at(i);

  if (i + 1 >= number_sequence.size()) return a + n + b;
  
  b += n;
  ans = many_formulas(i + 1, a, b * 10, number_sequence);
  
  a += b;
  return ans + many_formulas(i + 1, a, 0, number_sequence);
}

int main() {
  string X;
  char x;
  
  cin >> X;
  
  vector<long> number_sequence(X.size());
  for (long i = 0; i < number_sequence.size(); i++) {
  	x = X.at(i);
    
    to_int(x, number_sequence.at(i));
  }
  
  
  
  cout << many_formulas(0, 0, 0, number_sequence) << endl;
}


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

int main()
{
    ll n,i,k,min1,j;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n]={0};
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        if(i>1)
        {
          min1=1e18;
          for(j=i-1;j>=max(i-k,(ll)0);j--)
          {
            min1=min(min1,dp[j]+abs(a[i]-a[j]));
          }
          dp[i]=min1;
        }
        else
        {
          dp[i]=abs(a[i]-a[i-1])+dp[i-1];
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
	int N;
  	string S;
  	cin >> N >> S;
  	int ans = 0;
  	for(int i = 1; i < N; i++){
      	int cnt = 0;
      	for(char c = 'a'; c <= 'z'; c++){
          	bool l = false, r = false;
          	for(int j = 0; j < i; j++){
              	if(S.at(j) == c){
                  	l = true;
                }
            }
            for(int j = i; j < N; j++){  
              	if(S.at(j) == c){
                  	r = true;
                }
            }
            if(l && r){
                  	cnt ++;
            }
        }
		if(ans < cnt){
          	ans = cnt;
        }
    }
      cout << ans;
      return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint zyo[100100],rz[100100];
lint sum[100100];
lint a[100100];
lint mo=1000000007;
lint co(int n,int m){
	if(n<0 || m<0 || n-m<0) return 0;
	return ((zyo[n]*rz[m])%mo*rz[n-m])%mo;
}
int main()
{
	zyo[0]=1;rep(i,100010) zyo[i+1]=(zyo[i]*(i+1))%mo;
	rep(i,100010) rz[i]=invMod(zyo[i],mo);
	int n,k;
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	sum[0]=0;rep(i,n) sum[i+1]=sum[i]+a[i];
	lint out=0;
	rep(i,n){
		out+=a[i]*co(i,k-1);out%=mo;
		out-=a[i]*co(n-i-1,k-1);out%=mo;
	}
	out%=mo;out+=mo;out%=mo;
	cout<<out<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
string s;
int k;
int INF=1000000000;
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> > p;
    p.resize(m);
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    int ans=0;
    int bri=0;
    rep(i,0,m){
        if(!(bri>p[i].second&&bri<=p[i].first)){
            ans++;
            bri=p[i].first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n=sz(s);
    vector<string> suffixes;
    for(int i=0;i<n;++i) {
        string t = "";
        for(int j=i;j<n;++j) t+=s[j];
        suffixes.push_back(t);
    }
    sort(all(suffixes));
    int k;
    cin >> k;
    string res="";
    for(int i=0;i<n;++i) {
        const string &s2=suffixes[i];
        string s1 = "";
        if(i>0) s1 = suffixes[i-1];
        int l1 = s1.size(), l2=s2.size();
        int lcp=0;
        while(lcp<l1 && lcp<l2 && s1[lcp]==s2[lcp]) ++lcp;
        int j;
        for(j=lcp;k>0 && j<l2;++j) {
            --k;
        }
        if(k==0) {
            for(int l=0;l<j;++l) res+=s2[l];
            break;
        }
    }
    cout<<res<<"\n";

}


Measured memory_bytes: 24704
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int groups[] = {
	1,3,1,2,1,2,1,1,2,1,2,1,
};

int main(void)
{

	int x, y;
	cin >> x >> y;

    if (x == 2 || y == 2) {
    	printf("No\n");
    }
    else if (groups[x - 1] == groups[y - 1]) {
    	printf("Yes\n");
    }
    else {
    	printf("No\n");
    }

	return 0;
}

Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
E = [[] for _ in range(N+1)]
for _ in range(M):
    ta, tb = map(int, input().split())
    E[ta].append(tb)
    E[tb].append(ta)

q = [1]

root = [0] * (N+1)
root[0], root[1] = -1, -1
flg = [0] * (N+1)
flg[0], flg[1] = 1, 1

while q:
    cp = q.pop(0)
    for np in E[cp]:
        if root[np] != 0:
            continue
        else:
            root[np] = cp
            q.append(np)

for i in range(2, N+1):
    if root[i] == 0:
        print('No')
        sys.exit()

print('Yes')
for i in range(2, N+1):
    print(root[i])

Measured memory_bytes: 34620
#include <iostream>
#include <unordered_map>
using namespace std;
unordered_map<int, int> m;

bool check (int t) {
    int tmp;
    for (int i = 0; i < t; i++) {
        scanf("%d", &tmp);
        m[tmp]--;
        if (m[tmp] < 0) return false;
    }
    return true;

}

int main() {
    int n, t, tmp;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);
        m[tmp]++;
    }
    scanf("%d", &t);
    if (check(t)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    double sum = 0;
    while(n--){
        double a;
        cin >> a;
        sum += 1/a;
    }
    sum = 1 / sum;
    cout << setprecision(7) << fixed << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    ll x, y, a, b, t;
    while(cin>>a>>x>>b>>y>>t){	
    	if(x*t-y*t>=abs(a-b)){
    		printf("YES\n");
    	}
    	else{
    		printf("NO\n");
    	}
    }
  return 0;
}




Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var T = Read();
            var cnt = 0;
            for (int i = 0; i < 3; i++)
            {
                if (S[i] == T[i]) cnt++;
            }

            Console.WriteLine(cnt);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11092
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( stdin.hasNextInt() ) {
	    final int c1 = stdin.nextInt();
	    final int c2 = stdin.nextInt();
	    final int c3 = stdin.nextInt();

	    boolean[] selected = new boolean[11];
	    selected[c1] = true;
	    selected[c2] = true;
	    selected[c3] = true;

	    int count = 0;
	    for ( int i = 1; i <= 10; i++ ) {
		if ( !selected[i] && i <= 20 - c1 - c2 ) {
		    count++;
		}
	    }
	    if ( count >= 4 ) {
		System.out.println( "YES" );
	    } else {
		System.out.println( "NO" );
	    }
	}	
    }    
}

Measured memory_bytes: 17200
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {

	string S;
	cin >> S;

	int num_win = 0;
	int num_nokori = 15 - (int)S.size();

	REP(i, (int)S.size()) {
		char ch = S[i];
		if (ch == 'o') {
			num_win++;
		}
	}

	if (num_nokori + num_win >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using P = pair<int, int>;
int h, w, m;
vector< int > x, y, ch(3e5, 0), cw(3e5, 0);
vector< set<int> > x2y(3e5, set<int>() );
int main(void){
    cin >> h >> w >> m;
    x.assign(m, 0);
    y.assign(m, 0);
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i];
        ch[--x[i]]++;
        cw[--y[i]]++;
        x2y[x[i]].insert(y[i]);
    }
    vector< P > ph, pw;
    for(int i=0;i<h;i++) ph.push_back(P(ch[i], i));
    for(int i=0;i<w;i++) pw.push_back(P(cw[i], i));
    sort(ph.begin(), ph.end(), greater<P>());
    sort(pw.begin(), pw.end(), greater<P>());
    bool flg = false;
    int ans = 0;
    for(int i=0;i<h;i++){
        if(i > 0 && ph[i].first < ph[i-1].first) break;;
        for(int j=0;j<w;j++){
            if(j > 0 && pw[j].first < pw[j-1].first) break;;
            int tmp = ph[i].first + pw[j].first;
            auto itr = x2y[ ph[i].second ].find( pw[j].second );
            if(itr != x2y[ ph[i].second ].end()) tmp--;
            else flg = true;
            ans = max(ans, tmp);
            if(flg) break;
        }
        if(flg) break;
    }
    cout << ans << endl;

}


Measured memory_bytes: 37036
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int n;
  cin >> n;
  string s = to_string(n);
  if(s[s.size() - 1] == '3') {
    cout << "bon" << endl;
  }else if(s[s.size() - 1] == '0') {
    cout << "pon" << endl;
  }else if(s[s.size() - 1] == '1') {
    cout << "pon" << endl;
  }else if(s[s.size() - 1] == '6') {
    cout << "pon" << endl;
  }else if(s[s.size() - 1] == '8') {
    cout << "pon" << endl;
  }else if(s[s.size() - 1] == '2') {
    cout << "hon" << endl;
  }else if(s[s.size() - 1] == '4') {
    cout << "hon" << endl;
  }else if(s[s.size() - 1] == '5') {
    cout << "hon" << endl;
  }else if(s[s.size() - 1] == '7') {
    cout << "hon" << endl;
  }else if(s[s.size() - 1] == '9') {
    cout << "hon" << endl;
  }
}


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

queue<pair<int, pair<int, int>>> q; //first int distance, second int current node location

int g[1000][1000];
int dist[1000][1000];

//vector<int> g[200005];

vector<char> input[1000];

int dr[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, 1, -1};

int main()
{

    int h, w;

    int blacks = 0;

    cin >> h >> w;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            char inp;
            cin >> inp;
            if (inp == '.')
            {
                g[j][i] = 0;
            }
            else
            {
                g[j][i] = 1;
                blacks += 1;
            }
        }
    }

    //changes all elements of array into 0/-1
    memset(dist, -1, sizeof(dist)); // works only for 0 or -1

    q.push(make_pair(0, make_pair(0,0)));

    while (!q.empty())
    {
        int d = q.front().first, x = q.front().second.first, y = q.front().second.second;

        q.pop();

        if (dist[x][y] != -1)
        {
            continue;
        }

        dist[x][y] = d;

        for (int i = 0; i < 4; i++)
        {
            if (x + dr[i] < w && x + dr[i] >= 0 && y + dc[i] < h && y + dc[i] >= 0)
            {
                if(g[x+dr[i]][y+dc[i]] == 0){
                    q.push(make_pair(d + 1, make_pair(x + dr[i], y + dc[i])));
                }
            }
        }

    }

    if(dist[w-1][h-1] == -1){
        cout << -1;
    } else {
        cout << h*w -1 - blacks -dist[w-1][h-1];

    }

    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
vector<int>BIT;
void init(int N) {
  for (int i = 0; i <= N; i ++) BIT[i] = 0;
}
int sumUp(int a) {
  int ret = 0;
  while(a) {
    ret += BIT[a];
    a -= (a & -a);
  }
  return ret;
}
void add(int a, int n, int N) {
  if (a == 0) return;
  while (a <= N) {
    BIT[a] += n;
    a += (a & -a);
  }
}
int main () {
  int N;
  cin >> N;
  int Q;
  cin >> Q;
  BIT.resize(N + 5);
  init(N);
  vector<int>A(N + 1);
  for (int i = 1; i <= N; i ++) cin >> A[i];
  vector<tuple<int, int, int>>query(Q + 1);
  for (int i = 1; i <= Q; i ++) {
    int l, r;
    cin >> l >> r;
    query[i] = make_tuple(r, l, i);
  }
  query[0] = make_tuple(0, 0, 0);
  sort(query.begin(), query.end());
  vector<int>color(N + 1, 0);
  vector<int>ans(Q + 1);
  for (int i = 1; i <= Q; i ++) {
    int rp = get<0>(query[i - 1]);
    int l, r, j;
    tie(r, l, j) = query[i];
    for (int i = rp + 1; i <= r; i ++) {
      int t = color[A[i]];
      color[A[i]] = i;
      add(t, -1, N);
      add(i, 1, N);
    }
    ans[j] = sumUp(r) - sumUp(l - 1);
    //cout << i << endl;
  }
  for (int i = 1; i <= Q; i ++) cout << ans[i] << endl;
  //add(0, 1, N);
  //cout << sumUp(0);
}


Measured memory_bytes: 17416
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	int i;
	int line[5];
	cin >> line[0] >> line[1] >> line[2] >> line[3] >> line[4] ;
	sort(line,line+5,greater<int>());
	for(i=0;i<4;i++){
		cout << line[i] << " " ;
	}
	cout << line[4] << endl;
}

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  for(int j=0; j<N; j++){
    vec.at(j) = abs(vec.at(j) - X);
  }
  
  sort(vec.begin(),vec.end());
  
  int ans = vec.at(0);
  if(N != 1){
  for(int j=0; j<N-1; j++){
    int a = vec.at(j+1);
    int b = vec.at(j);
    int r = a % b;
   while(r!=0){
    a = b;
    b = r;
    r = a % b;
   }
   vec.at(j+1) = b;
   ans = b;
  }
  }
  
  cout << ans << endl;
 
}

Measured memory_bytes: 640
/*      ***    BE GOOD DO GOOD    ***         */



#include<bits/stdc++.h>

using namespace std;

#define LL long long int
#define D double
#define ULL unsigned
#define PI 2.0*acos(0.0)
#define sz size()
#define PB push_back
#define NL printf("\n")
#define CHR getchar()
#define SQR(n) (n*n)
#define xx first
#define yy second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define all(a) a.begin(),a.end()
#define end return 0
#define N 2000001


int main()
{
   int n;
   cin>>n;
   int a[n],mx=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   int s=0;
   for(int i=0;i<n;i++)
   {
      int t=a[i];
      t=t-1;
      s=s+t;
   }
   cout<<s<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

string ng[] = {"AGC", "ACG", "GAC", "AGTC", "ATGC", "AGGC", "AGAC"};

signed main() {
  ios::sync_with_stdio(false);
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  ll l[n];
  REP(i, n) cin >> l[i];
  ll arr_mx = power(4, n, mod);
  ll ans = 1000000000;
  REP(arrange, arr_mx) {
    vector<ll> x;
    vector<ll> y;
    vector<ll> z;
    REP(i, n) {
      int bit = 3 & (arrange >> (i*2));
      if(bit==1) {
        x.push_back(l[i]);
      }
      if(bit==2) {
        y.push_back(l[i]);
      }
      if(bit==3) {
        z.push_back(l[i]);
      }
    }
    if(x.empty() || y.empty() || z.empty()) continue;
    ll tmp = 0;
    tmp += abs(accumulate(all(x), 0) - a) + (x.size() - 1) * 10;
    tmp += abs(accumulate(all(y), 0) - b) + (y.size() - 1) * 10;
    tmp += abs(accumulate(all(z), 0) - c) + (z.size() - 1) * 10;
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


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

int n;
double a[55];
double res;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf",&a[i]);
    }
    sort(a,a+n);
    res=(a[0]+a[1])/2;
    for(int i=2;i<n;i++){
        res=(res+a[i])/2;
    }
    printf("%.10lf\n",res);

    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	LL n, a, b;
	cin >> n >> a >> b;
	if ((b - a) & 1)
	{
		LL ans1 = a;
		ans1 += (b - a - 1) / 2;
		
		LL ans2 = n - b + 1;
		ans2 += (n - (a + n - b + 1)) / 2;
		cout << min(ans1, ans2) << endl;
	}
	else
		cout << (b - a) / 2 << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

using namespace std;

typedef long long int ll;

template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }

typedef pair<int,int> pair;

int main(){
    string s;
    int q;
    vector<int> t;
    vector<int> f;
    vector<string> c;
    //Input
    cin >> s >> q;
    for(int i=0;i<q;i++){
        int tI;
        cin >> tI; t.emplace_back(tI);
        if(tI==2){
            int fI; string cI;
            cin >> fI >> cI;
            if(fI==2) fI=-1;
            f.emplace_back(fI);
            c.emplace_back(cI);
        }
    }

    /*処理*/
    int j=0; //Counter
    int revTog=1;
    string front;
    for(int tC=0;tC<q;tC++){
        if(t[tC]==1){
            revTog*=-1;
        }else{
            if(f[j] == revTog){
                front+=c[j];
            }else{
                s+=c[j];
            }
            j++;
        }
    }
    reverse(front.begin(),front.end());
    s=front+s;

    if(revTog<0){
        /*int length=s.size();
        for(int i=0;i<length/2;i++){
            char tmp=s[i];
            s[i]=s[length-i-1];
            s[length-i-1]=tmp;
        }*/
        reverse(s.begin(),s.end());
    }

    cout << s << endl;
}

Measured memory_bytes: 14040
#include<bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    double n;cin>>n;
    n/=3;
    printf("%.12f\n",n*n*n);
}


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

typedef  long long int ll;
typedef  vector<int> vi;
#define  IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  fn for(int i=0;i<n;i++)
#define  all(x) x.begin(), x.end()
#define  endl "\n"


void solve()
{
	// write your code here :
string s;
	cin>>s;
	if(s[0]==s[1] and s[1]==s[2])
		cout<<"No";
	else cout<<"Yes";
  cout<<endl;
}

int main()
{
	IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
	// int t;
	// cin>>t;
	// while(t--)
	solve();
}


Measured memory_bytes: 256
K = int(input())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

gcd_table = [[0] * (K+1) for i in range(K+1)]
for i in range(1, K+1):
    for j in range(i, K+1):
        g = gcd(i, j)
        gcd_table[i][j] = gcd_table[j][i] = g


ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            g1 = gcd_table[a][b]
            g2 = gcd_table[g1][c]
            ans += g2

print(ans)

Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{template<class U>static auto c(U v)->decltype(v.begin(),v.end(),std::true_type());static std::false_type c(...);public:const static bool value=decltype(c(std::declval<T>()))::value;};
template<class T,typename enable_if<iterable<T>::value, nullptr_t>::type=nullptr>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vi a(n),b(n),c(n-1);
    cin>>a>>b>>c;
    int ans=0;
    REP(i,n){
        ans+=b[a[i]-1];
        dprint("got", b[a[i]-1]);
        if(i && a[i-1]+1==a[i]){
            ans+=c[a[i-1]-1];
            dprint("got+", c[a[i-1]-1]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main(){
    int A,B; cin >> A >> B;
    if (max(A,B)>8){
        cout << ":(";
    } else{
        cout << "Yay!";
    }
    return 0;
}

Measured memory_bytes: 256