akhauriyash/Code-Regression huggingface dataset:
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

char grid[100][100];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool used[100][100];
int dist[100][100], n, m;

bool ok(int x, int y){
	if(x >= 0 && x < n && y >= 0 && y < m && grid[x][y] != '#')return true;
	return false;
}

void bfs(int x, int y){
	used[x][y] = true;
	dist[x][y] = 0;
	queue<pii> q;
	q.push({x, y});
	while(!q.empty()){
		auto u = q.front();
		q.pop();
		forn(i, 4){
			int tx = u.fi + dx[i];
			int ty = u.se + dy[i];
			if(!used[tx][ty] && ok(tx, ty)){
				used[tx][ty] = true;
				dist[tx][ty] = dist[u.fi][u.se] + 1;
				q.push({tx, ty});
			}
		}
	}
			
}

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

	int n;
	cin >> n;
	vector<int> a;
	a.pb(0);
	forn(i, n){
		int x;
		cin >> x;
		a.pb(x);
	}
	a.pb(0);
	int tot = 0;
	forn(i, a.size() - 1)tot += abs(a[i] - a[i + 1]);
	for1(i, n){
		int cur = tot;
		cur -= abs(a[i] - a[i - 1]);
		cur -= abs(a[i] - a[i + 1]);
		cur += abs(a[i - 1] - a[i + 1]);
		cout << cur << '\n';
	}
	return 0;
}



Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   /* ll t;
    cin>>t;
    while(t--)*/
    {
 
 
        ll n,m,sum=0;
       cin>>n;
       while(n>0)
       {m=n%10;
       if(m==7)
       {
           cout<<"Yes"<<endl;
           return 0;
       }
           n=n/10;
       }
       cout<<"No"<<endl;
       
    }
 
    return 0;
}

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

if 1 <= N < 10:
    print(N)
elif 10 <= N < 100:
    print(9)
elif 100 <= N < 1000:
    print((N-100+1)+9)
elif 1000 <= N < 10000:
    print(9+900)
elif 10000 <= N < 100000:
    print((N-10000+1)+900+9)
else:
    print(90000+900+9)


Measured memory_bytes: 9188
#include <stdio.h>
 
int main(void)
{char str[4];
  int x=0, b=0, c=0;
  
  scanf("%s", str);
 
 if(str[0]=='a')
   x=x+1;
 if (str[1]=='a')
    x=x+1;
 if (str[2]=='a')
    x=x+1;
 
  if(str[0]=='b')
   b=b+1;
 if (str[1]=='b')
    b=b+1;
 if (str[2]=='b')
    b=b+1;
 
  if(str[0]=='c')
   c=c+1;
 if (str[1]=='c')
    c=c+1;
 if (str[2]=='c')
    c=c+1;
 
 if(x==1 &&b==1&&c==1)
   printf("Yes");
 else
   printf("No");
 
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
signed main() {
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<min({abs(a+b-c-d),abs(a+c-b-d),abs(a+d-b-c)})<<endl;
}


Measured memory_bytes: 3112
import java.util.Scanner;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b = 0;
        a = sc.nextInt();
        b = sc.nextInt();
        
        System.out.printf("%d %d %f\n", a / b, a % b, (double)a / (double)b);
        
    }

}



Measured memory_bytes: 26296
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

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

  int next = s.at(0)-'0';

  int count = 0;

  for (int i = 1; i < s.size(); ++i) {
    next ^= 1;
    
    if ((s.at(i)-'0') != next) {
      if (next == 1) {
        s.at(i) = '1';
      } else {
        s.at(i) = '0';
      }
      count++;
    }
  }

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


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

signed main() {
    int n,m;
    cin >> n >> m;
  	int arr[n+1][2]={{}};
  	for(int i=0; i<m; i++){
  	    int p; cin >> p;
  	    string v; cin >> v;
  	    if(v == "WA" and arr[p][1] == 0) arr[p][0]++;
  	    else if(v == "AC") arr[p][1] = 1;
  	}
  	int a=0,w=0;
  	for(int i=1; i<=n; i++){
  	    if(arr[i][1])
  	        w += arr[i][0];
  	    a += arr[i][1];
  	}
  	cout << a << " " << w << endl;
}

Measured memory_bytes: 1792
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> A(N);
    map<string, int> m;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    } 

    int max_cnt = 0;

    for(auto it : m) {
        max_cnt = max(it.second, max_cnt);
    }

    vector<string> v;
    for(auto it : m) {
        if(max_cnt == it.second) {
            v.push_back(it.first);
        }
    }

    sort(v.begin(), v.end());

    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 28404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n;
			n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}
			int p = 0;
			int d = -1;
			for (int i = 0; i < n; i++) {
				int _p, _d;
				StringTokenizer st = new StringTokenizer(br.readLine());
				_p = Integer.parseInt(st.nextToken());
				_d = Integer.parseInt(st.nextToken())
						+ Integer.parseInt(st.nextToken());
				if (_d > d) {
					p = _p;
					d = _d;
				}
			}
			System.out.println(p + " " + d);
		}
	}
}

Measured memory_bytes: 55928
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int H[]=new int[N];
		for(int i=0;i<N;i++) {
			H[i]=sc.nextInt();
		}
		sc.close();
		boolean signal=true;
		for(int j=(N-1);j>0;j--) {
			if(H[j]==H[j-1]-1) {
				H[j-1]-=1;
			}else if(H[j]<H[j-1]-1) {
				signal=false;
				break;
			}
		}
		if(signal) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 49752
def counting_sort(a, b, k):
    c = [0 for _ in range(k+1)]
    n = len(a)

    for j in range(n):
        c[a[j]] += 1

    for i in range(1, k+1):
        c[i] += c[i-1]

    for j in range(n - 1, -1, -1):
        b[c[a[j]] - 1] = a[j]
        c[a[j]] -= 1


def print_list_split_whitespace(a):
    for x in a[:-1]:
        print(x, end=" ")
    print(a[-1])


n = int(input())
a = [int(x) for x in input().split()]
b = a.copy()
k = max(a)

counting_sort(a, b, k)

print_list_split_whitespace(b)


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

typedef long long ll;
#define pii pair<pii , pii>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1000005

int n , G = 0;
int a[MAXX];

int main()
{
    _FastIO;
    vector<bool> used(MAXX , false);
    cin >> n;
    bool f = true;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(G != 1){
            if(!i)
            G = a[0];
        else
            G = __gcd(G , a[i]);
        }
        if(f){
            int s = 0;
        for(ll j = 2; j * j <= a[i]; j++){
            if((a[i] % j) == 0){
                if(used[j])
                    f = false;
                used[j] = true;
                int k = a[i] / j;
                if(used[k] && k != j)
                    f = false;
                used[k] = true;
                s++;
            }
        }
        if(a[i] != 1 && !s){
            if(used[a[i]])
                f = false;
            used[a[i]] = true;
        }
        }

    }
    if(f){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    if(G == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 7672
#pragma warning (disable:4996)
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)cout << "Yay!"<<endl;
	else cout << ":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
pii A[100100];//(個数,番号)
int Ans[100100];

signed main() {
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        A[i] = pii(a, i);
    }
    A[N] = pii(0, N + 2);
    sort(A, A + N + 1, greater<pii>());
    int minv = INF;
    int cnt = 0;
    rep(i, N) {
        minv = min(minv, A[i].second);
        int d = A[i].first - A[i + 1].first;
        cnt++;
        Ans[minv] += d * cnt;
    }
    rep(i, N) {
        cout << Ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string r = Console.ReadLine();
                if (r == null) break;
                double[] k0 = new double[6];
                for (int i = 0; i < 6; i++) k0[i] = double.Parse(r.Split(' ')[i]);
                Console.WriteLine(String.Format("{0:0.000} {1:0.000}", (k0[2] - k0[1] * (k0[2] * k0[3] - k0[0] * k0[5]) / (k0[1] * k0[3] - k0[0] * k0[4])) / (k0[0]), (k0[2] * k0[3] - k0[0] * k0[5]) / (k0[1] * k0[3] - k0[0] * k0[4])));
            }
        }
    }
}

Measured memory_bytes: 9092
K = gets.to_i

queue = (1..9).to_a
lun = 0
K.times do
  lun = queue.shift
  queue.push(lun * 10 + (lun % 10 - 1)) if lun % 10 > 0
  queue.push(lun * 10 + (lun % 10))
  queue.push(lun * 10 + (lun % 10 + 1)) if lun % 10 < 9
end

puts lun


Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#define NUMBER 5
using namespace std;
int main() {
	//vector<int> a(5);
	int a[NUMBER];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int k; cin >> k;
	int key = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = i; j < 5; j++) {
			int dis = abs(a[i] - a[j]);
			if (dis > k) {
				key++;
			}
		}
	}
	if (key == 0) { cout << "Yay!" << endl; }
	else { cout << ":(" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <algorithm>
#define N 2000
using namespace std;
typedef pair<int,int>P;
long long f[N+1][N+1]={0};
P d[N];
int main(int argc,char ** argv)
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i){cin>>d[i].first;d[i].second=i;}
    sort(d,d+n,[](P& a,P& b)->bool{return a.first>b.first;});

    for(int i=0;i<=n;++i){
        for(int j=0;j+i<=n;++j){
            f[i][j]=+max((i>0?f[i-1][j]+(long long)d[i+j-1].first*abs(i-1-d[i+j-1].second):0),(j>0?f[i][j-1]+(long long)d[i+j-1].first*abs(n-j-d[i+j-1].second):0));
        }
    }
    long long ans=0;
    for(int i=0;i<=n;++i){
        ans=max(ans,f[i][n-i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 26144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10005,INF=1<<30;

map<char,int> MA;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<char,int> MA;
    for(char c='1';c<='9';c++) MA[c]=int(c-'0');
    MA['T']=10;
    MA['J']=11;
    MA['Q']=12;
    MA['K']=13;
    MA['A']=14;
    
    while(1){
        char X,Y;cin>>X;
        if(X=='#') break;
        
        vector<vector<string>> S(4,vector<string>(13));
        
        for(int i=0;i<4;i++) for(int j=0;j<13;j++) cin>>S[i][j];
        Y=S[0][0][0];
        
        int ns=0,ew=0;
        
        for(int j=0;j<13;j++){
            vector<pair<int,int>> T(4);
            
            for(int i=0;i<4;i++){
                T[i].first+=MA[S[i][j][0]];
                if(S[i][j][1]==X) T[i].first+=30;
                else if(S[i][j][1]==Y) T[i].first+=15;
                T[i].second=i;
                //cout<<T[i].first<<" ";
            }
            //cout<<endl;
            
            sort(all(T));
            
            if(T[3].second%2==0) ns++;
            else ew++;
            
            if(j!=12) Y=S[T[3].second][j+1][1];
            
            //cout<<T[3].second<<endl;
        }
        
        if(ns>=7) cout<<"NS "<<ns-6<<endl;
        else cout<<"EW "<<ew-6<<endl;
    }
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,T,A,ans;
  int min=1<<30;
  scanf("%d%d%d",&N,&T,&A);
  for(int i=1;i<=N;i++){
    int H,temp,def;
    scanf("%d",&H);
    temp=T*1000-H*6;
    def=temp-A*1000;
    if(def<0){
      def*=-1;
    }
    if(def<min){
      min=def;
      ans=i;
    }
  }
  printf("%d",ans);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, X; cin >> N >> X;
    vector<ll> diff(N);
    rep(i, N){ll x; cin >> x; diff.at(i) = abs(X - x);}
    ll ans = diff.at(0);
    rep(i, N-1){ans = __gcd(ans, diff.at(i+1));}
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
import itertools

def judge(lis):
    l = list(str(int("".join(lis))))
    if "3" in l:
        if "5" in l:
            if "7" in l:
                if not "0" in l:
                    return True
    else:
        return False

N = int(input())
length = len(str(N))

count = 0
seq = ("0", "3", "5", "7")
jun = list(itertools.product(seq, repeat=length))

for i in jun:
    num = int("".join(list(i)))
    if N >= num:
        if judge(list(i)):
            count += 1
        
print(count)


Measured memory_bytes: 36980
#include<bits/stdc++.h>
using namespace std;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0;
  string s,c="CODEFESTIVAL2016";
  cin>>s;
  for(int i=0;i<16;i++){
    if(s[i]!=c[i]){
      a++;
    }
  }
  cout<<a<<"\n";
}

  


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct data
{
	int num;
	int tot;
}a[100005];
int cmp(data x,data y)
{
	return x.num<y.num;
}
int main()
{
	int n;long long k;
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].num,&a[i].tot);
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(k<=a[i].tot)
		{
			
			printf("%d",a[i].num);
			return 0;
		}
		else
		k-=a[i].tot;
	}
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int a = 0; a <= 100; ++a) {
        for (int b = 0; b <= 100; ++b) {
            if (N == 4 * a + 7 * b) {
                    cout << "Yes" << endl;
                    return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define endl '\n'
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll d,t, s; cin >> d >> t >> s;
    if(t*s >= d)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, M, A[1123456];

int main() {

	cin >> N >> M;
	rep(i, M) cin >> A[i];

	int sum = 0;
	rep(i, M) sum += A[i];

	if (sum <= N) cout << N - sum << endl;
	else cout << -1 << endl;

	return 0;
}


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

public static partial class Program
{
    public static void Main()
    {
        var antena = new long[5];
        for (int i = 0; i < 5; i++)
        {
            antena[i] = CRL().ToInt();
        }

        var k = CRL().ToInt();
        for (int i = 0; i < 5; i++)
        {
            for (int j = i + 1; j < 5; j++)
            {
                if (antena[j] - antena[i] > k)
                {
                    CWL(":(");
                    return;
                }
            }
        }

        CWL("Yay!");
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    //テンプレここまで
}


Measured memory_bytes: 11092
def main(K, A, B):
    a = int(A / K)
    b = int(B / K)
    if A == 0 or (a == b and A % K != 0):
        print('NG')
    else:
        print('OK')


if __name__ == '__main__':
    K = int(input())
    A, B = list(map(int, input().split()))
    main(K, A, B)


Measured memory_bytes: 9176
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<double> arr(N);
  for(int i=0;i<N;++i){
    cin>>arr[i];
  }
  sort(arr.begin(), arr.end());
  double ans = arr[0];
  for(int i=1;i<N;++i){
    ans += arr[i];
    ans /= 2;
  }
  cout<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

VVI A(3, VI(3)); rep(i, 0, 3) invec(A[i]);
int N; cin >> N;
vector<vector<bool>> a(3, vector<bool>(3, false));
rep(i, 0, N){
    int b; cin >> b;
    rep(i, 0, 3) rep(j, 0, 3) 
        if (A[i][j] == b) a[i][j] = true;
}

rep(i, 0, 3) if (all_of(ALL(a[i]), [](int b){return b;})){
    cout << "Yes\n";
    return 0;
}

rep(i, 0, 3){
    bool bingo = true;
    rep(j, 0, 3) if(!a[j][i]) bingo = false;
    if (bingo){
        cout << "Yes\n";
        return 0;
    }
}
bool bingo = true;
rep(i, 0, 3){
    if (!a[i][i]) bingo = false;
}
if (bingo){
    cout << "Yes\n";
    return 0;
}
bingo = true;
rep(i, 0, 3){
    if (!a[i][2-i]) bingo = false;
}
if (bingo){
    cout << "Yes\n";
    return 0;
}

cout << "No\n";
return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
A, B = map(int, input().split())
if A == 1 and B == 13:
    winner = "Alice"
elif A == 13 and B == 1:
    winner = "Bob"
elif A > B:
    winner = "Alice"
elif A < B:
    winner = "Bob"
else:
    winner = "Draw"
print(winner)

Measured memory_bytes: 9080
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)

Sum = 0
for i in range(N+1):
    Sum += abs(A[i+1] - A[i])

for i in range(1, N+1):
    if (A[i-1] < A[i] < A[i+1]) or (A[i+1] < A[i] < A[i-1]):
        ans = Sum
    elif A[i] > A[i-1]:
        ans = Sum - 2 * abs(A[i] - max(A[i-1], A[i+1]))
    elif A[i] < A[i-1]:
        ans = Sum - 2 * abs(A[i] - min(A[i-1], A[i+1]))
    else:
        ans = Sum
    print(ans)


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    
    vector<int> Cs(N), Vs(N), Bs(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> Vs[i];
    }
    for (int i = 0; i < N; ++i)
    {
        cin >> Cs[i];
    }
    for (int i = 0; i < N; ++i)
    {
        Bs[i] = Vs[i] - Cs[i];
    }

    int maxBenefit = 0;
    for (const int B : Bs)
    {
        if (B > 0) maxBenefit += B;
    }
    cout << maxBenefit;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main() {
  double H,A;cin>>H>>A;
  int ans = ceil(H/A);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
typedef long long ll;
using namespace std;
ll N,A,B;
ll dis[100000];
ll ans;

int main(){
  cin>>N>>A>>B;
  ll fX;
  cin>>fX;
  for(int i = 1; i < N; i++){
    ll X;
    cin>>X;
    dis[i-1] = X - fX;
    fX = X;
  }

  for(int i = 0; i < N-1; i++){
    if(dis[i]*A < B)ans += dis[i] * A;
    else ans += B;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int N;
	cin >> N;
	int* a = alloc(N, int);
	repeat(i, i < N)
		scanf("%d", &a[i]);

	int ans = 0;
	repeat(i, i < N) {
		if (i % 2 == 0&&a[i]%2!=0) {
			ans++;
		}
	}

	cout << ans;

	free(a);
	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 3776
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

bool ok(int n, const vi & bad) {
  while (n) {
    if (bad[n%10]) return 0;
    n /= 10;
  }
  return 1;
}

int main() {
  int n, k;
  cin >> n >> k;
  vi d(k);
  vi bad(10);
  for (int i = 0; i < k; ++i) {
    cin >> d[i];
    bad[d[i]] = 1;
  }
  while (!ok(n, bad)) ++n;
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,g,h,r,w,l;
ll num,ans;
ll x[500005],y[500005],z[500005];
bool dame,flag;
ll ok,ng;
string s,t;


int main(){
	cin >> s;
	n = s.size();//p(n);
	t = "keyence";
	for(i=0;i<=7;i++){
		a = 0;
		//pe(i);
		if(s.substr(0,i) == t.substr(0,i) || i == 0){
			a++;
		}
		if(s.substr(n-7+i,7-i) == t.substr(i,7-i) || i == 7){
			a++;
		}
		//p(a);
		if(a == 2){
			p("YES");
			return 0;
		}
	}
	p("NO");
	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  long long n;
  string S;
  
  cin >> n ;
  cin >> S ;
  
  map<char,long long> count;
  
  for(long long i=0; i<n; i++){
    count[S.at(i)]++;
  }
  
  long long nocount;
  
  for(long long i=1; i<n-1; i++){
    for(long long j=0; j<min(i,n-i-1); j++){
      if(S.at(i)!=S.at(i+j+1)&&S.at(i-j-1)!=S.at(i)&&S.at(i-j-1)!=S.at(i+j+1)){
        nocount++;
      }
    }
  }

  long long ans;
  
  ans=count['R']*count['B']*count['G']-nocount;
    
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n;
int a[20][20];
int dp[1 << 16];
int b[1 << 16];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
        }
    }
    rep(i, 0, 1 << n){
        int tmp = 0;
        rep(j, 0, n){
            if(i & (1 << j)){
                rep(k, j + 1, n){
                    if(i & (1 << k)){
                       tmp += a[j][k];
                    }
                }
            }
        }
        b[i] = tmp;
    }
    dp[0] = 0;
    for(int mask = 0; mask < (1 << n); mask++){
        int idx = -1;
        rep(i, 0, n){
            if(mask & (1 << i)) continue;
            idx = i; 
            break;
        }
        if(idx == -1) break;
        for(int i = mask; i > 0; i = (i - 1) & mask){
            int tmp = b[i | (1 << idx)];
            tmp += dp[mask - i];
            dp[mask | (1 << idx)] = max(dp[mask | (1 << idx)], tmp);
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mx 100010
#define pi acos(-1)
#define endl '\n'
#define Fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
//
int main()
{
    string s;

    cin >> s;
    int l = s.size();

    char a, b;

    b = s[l - 1];
    if (b != 's')
    {
        cout << s << 's' << endl;
    }
    else
    {
        cout << s << "es" << endl;
    }
}


Measured memory_bytes: 3624
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] h = new long[n+1];
        boolean[] good = new boolean[n+1];

        for (int i = 1; i <= n; i++) {
            h[i] = sc.nextLong();
            good[i] = true;
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (h[a] < h[b]) {
                good[a] = false;
            } else if (h[a] > h[b]) {
                good[b] = false;
            } else {
                good[a] = false;
                good[b] = false;
            }
        }

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (good[i]) ans++;
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 60436
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		char[] arr = in.nextLine().toCharArray();
		
		String str = "";
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] == '0') {
				str += "0";
			}
			else if (arr[i] == '1') {
				str += "1";
			}
			else {
				if (str.equals(""))
					continue;
				str = str.substring(0, str.length() - 1); 
			}
		}
		
		System.out.println(str);
	}
}


Measured memory_bytes: 21844
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	if s == "RRR" {
		fmt.Fprintln(wr, 3)
	} else if strings.Contains(s, "RR") {
		fmt.Fprintln(wr, 2)
	} else if strings.Contains(s, "R") {
		fmt.Fprintln(wr, 1)
	} else {
		fmt.Fprintln(wr, 0)
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(abs(a-c)<=d||abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 



int main(){
    LL MOD=1000000007;
    int n;
    cin>>n;
    LL c[n];
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(c,c+n);
    LL x=0;
    LL y=0;
    for(int i=0;i<n;i++){
        x=x+c[i];
    }
    x=x%MOD;
    for(int i=0;i<n;i++){
        y=y+(n-i)*c[i];
        y=y%MOD;
    }
    
    LL pow[2*n];
    for(int i=0;i<2*n;i++){
        if(i==0){pow[i]=1;}
        else{pow[i]=(pow[i-1]*2)%MOD;}
    }

    LL ans=0;
    ans=(x+y)%MOD;
    ans=(ans*pow[2*n-2])%MOD;
    if(n==1){cout<<(x*2)%MOD<<endl;}
    else{cout<<ans<<endl;}
    return 0;
}

Measured memory_bytes: 4992
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	ans = 1;
	for (int i = 2; i <= N; i++) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque

def main():
    point = 0
    watermarks = []
    ponds = []

    for mark in list(stdin.readline()):
        point += 1
        if mark == "\\":
            watermarks.append(point)
        elif mark == "/":
            if watermarks:
                start_point = watermarks.pop()
                area = point - start_point
                while ponds and ponds[-1][0] > start_point:
                    area += ponds.pop()[1]
                ponds.append((start_point, area))

    pond_list = [pond[1] for pond in ponds]
    print(sum(pond_list))
    print(len(pond_list), *pond_list)

main()


Measured memory_bytes: 6988
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e2 + 5;
int n, a[N], b[N*N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for (int i = 1; i <= n; i++)cin>>a[i];
    
    b[0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = n*100; j >= 0 ; j--){
            if (b[j]==0 &&j - a[i]>=0)b[j] = b[j-a[i]];
        }
    }
    
    for (int j = n*100; j >= 0 ; j--){
        if (b[j]>0&&j%10!=0){
            cout<<j<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    
    return 0;
}



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

const int MAX_N = 1e5+3;
int N;
ll K;
ll A[MAX_N];

ll cal(int x)
{
	ll res = 0;
	for(int p=0;p<x;++p){
		int z=0,o=0;
		for(int i=0;i<N;++i){
			if(A[i]>>p&1) o++;
			else z++;
		}
		res += (1LL<<p)*max(z,o);
	}
	
	for(int i=0;i<N;++i){
		res += A[i] & (1LL<<x);
	}

	for(int p=x+1;p<63;++p){
		for(int i=0;i<N;++i){
			res += (K&(1LL<<p))^(A[i]&(1LL<<p)); 
		}
	}
	return res;
}

void solve()
{
    if(K == 0) cout << accumulate(A,A+N,0LL) << '\n';
    else{
	    ll ans = 0;
	    for(int i=0;i<N;++i) ans+=A[i]^K;
	    for(int p=63;p>=0;--p)if(K>>p&1){
	        ll cur = cal(p);
            ans = max(ans, cur);
	    }
	    cout << ans << '\n';
    }
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}int dec(int x,int y){x-=y;return x<0?x+p:x;}int mul(int x,int y){return (ll)x*y%p;}struct edge{int f,t,l;}w[N];int n,m,S,T,head[N],nxt[N];
void add(int f,int t,int l){
	static int cnt=0;
	w[++cnt]=(edge){f,t,l};
	nxt[cnt]=head[f];
	head[f]=cnt;
}
ll disS[N],disT[N];
int dpS[N],dpT[N];
bool vis[N];
typedef pair<ll,int> pii;
priority_queue<pii,vector<pii>,greater<pii> > Q;
int q[N];ll *val;
bool cmp(int x,int y){return val[x]<val[y];}
void dijsktra(int S,ll *dis,int *dp){
	for (int i=1;i<=n;i++) dis[i]=1e18,vis[i]=0;
	Q.push(pii(dis[S]=0,S));
	while (!Q.empty()){
		int v=Q.top().second;Q.pop();
		if (vis[v]) continue;vis[v]=1;
		for (int i=head[v];i;i=nxt[i]){
			int u=w[i].t;
			if (dis[u]>dis[v]+w[i].l) Q.push(pii(dis[u]=dis[v]+w[i].l,u));
		}
	}
	dp[S]=1;
	for (int i=1;i<=n;i++) q[i]=i;
	val=dis;sort(q+1,q+n+1,cmp);
	for (int i=1;i<=n;i++){
		int v=q[i];
		for (int i=head[v];i;i=nxt[i]){
			int u=w[i].t;
			if (dis[u]==dis[v]+w[i].l) dp[u]=inc(dp[u],dp[v]);
		}
	}
}
int main()
{
	scanf("%d%d%d%d", &n, &m, &S, &T);
	for(register int i=1; i<=m; ++i){
		int u, v, l;
		scanf("%d%d%d", &u, &v, &l);
		add(u, v, l);
		add(v, u, l);
	}
	dijsktra(S, disS, dpS);
	dijsktra(T, disT, dpT);
	long long len=disS[T];
	int ans=mul(dpS[T], dpS[T]);
	for(register int i=1; i<=n; ++i){
		int k=mul(dpS[i], dpT[i]);
		k=mul(k, k);
		if(disS[i]*2==len)
			ans=dec(ans, k);
	}
	for(register int v=1; v<=n; ++v)
		for(int i=head[v]; i; i=nxt[i]){
			int u=w[i].t;
			if (disS[v]+w[i].l^disS[u]||len^(disS[v]+w[i].l+disT[u])) continue;
			int k=mul(dpS[v],dpT[u]);
			k=mul(k, k);
			if (disS[v]*2<len&&disS[u]*2>len)
				ans=dec(ans, k);
		}
	printf("%d\n", ans);
	return 0;
}

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

int partition(vector<int>&a,int p,int r){
	int x=a.at(r),i=p-1;
	for(int j=p;j<r;++j){
		if(a.at(j)<=x){
			swap(a.at(++i),a.at(j));
		}
	}
	swap(a.at(++i),a.at(r));
	return i;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,l;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;++i)cin>>v.at(i);
	l=partition(v,0,n-1);
	if(l==0)cout<<"["s<<v.at(0)<<"]"s;
	else cout<<v.at(0);
	for(int i=1;i<n;++i){
		if(l==i)cout<<" ["s<<v.at(i)<<"]"s;
		else cout<<" "s<<v.at(i);
	}
	cout<<"\n"s;
}


Measured memory_bytes: 3232
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ll gcd(ll a, ll b) {
	if (b > a) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return (a / g) * (b / g) * g;
}

signed main() {
	ll n, m; cin >> n >> m;
	vector<ll> b(n);
	for (int i = 0; i < n; ++i) {
		ll a; cin >> a;
		b[i] = a / 2;
	}
	ll x = 1;
	for (auto bi : b) {
		x = lcm(x, bi);
		if (x > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	vector<ll> d(n);
	for (int i = 0; i < n; ++i) {
		if (((x / b[i]) & 1LL) == 0LL) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ((m) / x + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A > B) swap(A, B);
    cout << (A < C && C < B ? "Yes\n" : "No\n");
    return 0;
}


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

#define range(i, l, r) for(int i=l;i<r;i++)
using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  double tempx, summ = 0;
  string tempu;
  range(i, 0, N){
    std::cin >> tempx >> tempu;
    (tempu == "JPY")?summ += tempx:summ+= tempx * 380000.0;
  }
  std::cout << summ << '\n';
  return 0;
}


Measured memory_bytes: 760
#include<iostream>
 
using namespace std;
 
int main()
{
   int N,M;
   cin >> N >> M;
  
   int a[N];
   bool c[N];
   bool isOK = true;
  
     for(int i=0;i<N;i++)
   {
       a[i] = 0;
       c[i] = false;
   }
  
   for(int i=0;i<M;i++)
   {
     int tmp1, tmp2;
     cin >>tmp1 >> tmp2;
     if((tmp1-1)==0 && tmp2 == 0 && N >1)
     {isOK=false;break;}
     if(c[tmp1-1]==false)
     {
       a[tmp1-1] = tmp2;
       c[tmp1-1] = true;
     }
     else
     {
       if(a[tmp1-1]!=tmp2)
       {
       isOK=false;
       break;
       }
     }
   }
   
   if(isOK)
   {
     if(a[0]==0 && N>1) a[0]=1;
     
     int ans=0;
     int tmp =1;
          for(int i=N-1;i>-1;i--)
   			{
            ans += a[i]*tmp;
            tmp*=10;
          }
     cout << ans << endl;
   }
  else
  {
    cout << "-1" << endl;
  }
  
    return 0;
}

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

const int N = 2e5 + 100;
vector<int> e[N];
int fa[N];

void bfs() {
    queue<int> que;
    que.push(1);
    fa[1] = 1;
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (auto v : e[u]) {
            if (fa[v] == 0) {
                que.push(v);
                fa[v] = u;
            }
        }
    }
}

int main() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    bfs();
    for (int i = 2; i <= n; i++) {
        if (fa[i] == 0) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    for (int i = 2; i <= n; i++) {
        cout << fa[i] << "\n";
    }
}


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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    
    if( A[A.size()-1] == B[0] and B[B.size()-1] == C[0] ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
S=input()

def judge(x):
    if ''.join(list(reversed(x)))==x:
        return True
    else:
        return False
    
def solve(x):
    t=len(x)-1//2
    t2=(len(x)+1)//2
    if judge(x) and judge(x[t2:]) and judge(x[0:t]):
        print('Yes')
    else:
        print('No')
        
solve(S)

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

const int N = 305;
long long in[N][N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) cin >> in[i][j];

    long long res = 0;

    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j) {
            int cnt = 0;
            for (int k = 1; k <= n; ++k) {
                if(i == k or j == k) continue;
                if (in[i][k] + in[k][j] < in[i][j]) return !printf("-1\n");
                if (in[i][k] + in[k][j] == in[i][j]) cnt++;
            }
            if (cnt == 0) res += in[i][j];
        }

    printf("%lld\n", res);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int L,R,d; cin >> L >> R >> d;
    int ans = 0;
    for(int i = L;i <= R;i++){
        if(i%d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>

int isATCG(char b);

int main(void) {
  char S[10];
  scanf("%s", S);

  int max = 0;
  int current = 0;
  for(int i=0, n=strlen(S); i < n; i++) {
    if(isATCG(S[i])) {
      current ++;
    } else {
      max = max < current ? current : max;
      current = 0;
    }
  }
  max = max < current ? current : max;

  printf("%d\n", max);

  return 0;
}


int isATCG(char b){
  switch(b) {
    case 'A': return 1;
    case 'T': return 1;
    case 'C': return 1;
    case 'G': return 1;
  }
  return 0;
}

Measured memory_bytes: 128
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1
#print(a_4,a_2,a_1)
print('Yes' if (a_4+1) >= (a_1+a_2) else 'No')

Measured memory_bytes: 15020
# coding: utf-8
# Your code here!

def sum_digits(n,m):
   r = 0
   while n:
       r, n = r + n % m, n // m
   return r


N=int(input())

ans = 100000
for i in range(N+1):
    ans = min(ans, sum_digits(i,6)+sum_digits(N-i,9))

print(ans)    


Measured memory_bytes: 2940