akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

ans = 0
pos = 0
pos1 = 0
pos2 = 0

while True:
    if pos==N:
        break
    pos1 = pos
    pos2 = pos
    while pos1<N-1 and A[pos1] <= A[pos1+1]:
        pos1 +=1
#     print(pos1)
    while pos2<N-1 and A[pos2] >= A[pos2+1]:
        pos2 +=1
#     print(pos2)
    large = max(pos1, pos2)
    pos = large+1
    ans += 1
print(ans)

Measured memory_bytes: 14252
import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  int num,i,j;
  num = Integer.parseInt(br.readLine());
  int[][] cards = new int[4][13];   
   for(i=0;i<4;i++){
    for(j=0;j<13;j++){
     cards[i][j]=0;
    }
   }

   for(i=0;i<num;i++){ 
    String str = br.readLine(); 
    String[] strAry = str.split(" ");
    String op = strAry[0];
    int number = Integer.parseInt(strAry[1]);
    number--;   

    if(op.equals("S")){            
      cards[0][number]=1; 
    }else if(op.equals("H")){
      cards[1][number]=1;
    }else if(op.equals("C")){
      cards[2][number]=1;
    }else if(op.equals("D")){
      cards[3][number]=1;
    }
   }
    
   for( i=0;i<4;i++){
    for(j=0;j<13;j++){
     if(cards[i][j]==0){
       if(i==0){   
         System.out.println("S "+ (j+1));     
       }else if(i==1){
         System.out.println("H "+ (j+1));
       }else if(i==2){
         System.out.println("C "+ (j+1));
       }else if(i==3){
         System.out.println("D "+ (j+1));
       }
    }
   }
   
  }
 }
}

Measured memory_bytes: 24348
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	char b;
	cin >> b;
	if (b == 'A') {
		cout << 'T' << endl;
	}
	if (b == 'T') {
		cout << 'A' << endl;
	}
	if (b == 'C') {
		cout << 'G' << endl;
	}
	if (b == 'G') {
		cout << 'C' << endl;
	}
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> picture(h, vector<char>(w));

    rep(y, h) {
        rep(x, w) {
            cin >> picture[y][x];
        }
    }

    for(int y = 0 ; y < h ; y ++) {
        for (int x = 0; x < w; x++) {
            cout << picture[y][x];
        }
        cout << endl;
        for (int x = 0; x < w; x++) {
            cout << picture[y][x];
        }
        cout << endl;
    }
}

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

public class Main{
    public static boolean oppSide(char c1, char c2){
    	final Character[] right= {'y','u','i','o','p','h','j','k','l','n','m'};
    	
    	return ( !Arrays.asList(right).contains(c1) && Arrays.asList(right).contains(c2) )
    		    || ( Arrays.asList(right).contains(c1) && !Arrays.asList(right).contains(c2) );
    }
	
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while( !( (str= br.readLine()).equals("#") ) ){
        	int cnt= 0;        	
            for(int i=1; i<str.length(); i++){
            	if( oppSide(str.charAt(i-1),str.charAt(i)) ){
            		cnt++;
            	}
            }
            System.out.println(cnt);
        }
    }
}

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



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    if (a != b)
        cout << "D\n";
    else
        cout << "H\n";


    return 0;
}






Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	long long int n;
	long long int total=0;
	scanf("%lld", &n);
	
	for (int i=1;i<=n;i++){
		if( i%3==0 && i%5==0){
		}
		else if(i%3==0){
		}
		else if(i%5==0){
		}
		else{
			total+=i;
		}
	}
	
	printf("%lld", total);
	
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define inin freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const int N=2000005;
vector<int> adj[505];


int main(){
    //inin
    IOS
    int n,m,q;
    cin>>n>>m>>q;
    int aa,bb,cc,dd;
    fo(i,m){
        cin>>aa>>bb;
        cc=min(aa,bb);
        dd=max(aa,bb);
        adj[cc].pb(dd);

    }
    //dbg(sz(adj[1]));
    FOR(i,1,n){
        if(sz(adj[i])) sort(all(adj[i]));
    }
    while(q--){
        cin>>aa>>bb;
        int count=0;
        cc=min(aa,bb);
        dd=max(aa,bb);
        FOR(i,cc,dd){
        int tmp=upper_bound(all(adj[i]),dd)-adj[i].begin();
        // dbg2(i,tmp);
        count+=tmp;
        }
        cout<<count<<endl;

    }

    
}

Measured memory_bytes: 2176
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
using namespace std;

int main(void){
	string ohn,mezikara;
	int p,n,i;
	while(1){
		cin>>ohn;
		if(ohn=="-"){
			break;
		}
		cin>>n;
		for(;n>0;n--){
			cin>>p;
			ohn=ohn.substr(p)+ohn.substr(0,p);
			}
		cout<<ohn<<endl;
		}

	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b)
        cout << "a < b" << endl;
    else if(a>b)
        cout << "a > b" << endl;
    else
        cout << "a == b"<< endl;
    
    return 0;
}


Measured memory_bytes: 3108
N,K = map(int,input().split())

a = list(map(int,input().split()))

psum = 0

for i in a:
    if i > 0:
        psum += i


nsum = 0

for i in range(K):
    nsum += a[i]

    if a[i] > 0:
        psum -= a[i]

ans = max( psum + nsum , psum )

for i in range(N - K):

    nsum -= a[i]
    if a[i] > 0:
        psum += a[i]

    nsum += a[K+i]
    if a[K+i] > 0:
        psum -= a[K+i]

    ans = max( ans , psum + nsum , psum )

print (ans)

    


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

struct Dice {
    int s[6];
    void roll (char c) {
        int b;
        if (c == 'E') {
            b = s[0];
            s[0] = s[3];
            s[3] = s[5];
            s[5] = s[2];
            s[2] = b;
        }
        if (c == 'W') {
            b = s[0];
            s[0] = s[2];
            s[2] = s[5];
            s[5] = s[3];
            s[3] = b;
        }
        if (c == 'N') {
            b = s[0];
            s[0] = s[1];
            s[1] = s[5];
            s[5] = s[4];
            s[4] = b;
        }
        if (c == 'S') {
            b = s[0];
            s[0] = s[4];
            s[4] = s[5];
            s[5] = s[1];
            s[1] = b;
        }
    }
    int top () {
        return s[0];
    }
};

int main() {

  Dice d;

  for (int i = 0; i < 6; i++) {
      cin >> d.s[i];
  }

  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
      d.roll(s[i]);
  }

  cout << d.top() << endl;

  return 0;

}


Measured memory_bytes: 3212
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            long[] A = new long[N];
            long[] B = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
                B[i] = in.nextInt();
            }

            ArrayList<Pair<Long, Integer>> pairs = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                pairs.add(new Pair<Long, Integer>(A[i], i));
            }
            Collections.sort(pairs);

            long money = 0;
            long count = 0;
            for (int i = 0; i < N; i++) {
                int j = pairs.get(i).second.intValue();
                if (count + B[j] <= M) {
                    money += A[j] * B[j];
                    count += B[j];
                } else {
                    money += A[j] * (M - count);
                    count += M - count;
                }
            }

            System.out.println(money);
        }
    }
}

class Pair<T extends Comparable<T>, S> implements Comparable<Pair<T, S>> {
    public T first;
    public S second;

    public Pair(T t, S s) {
        this.first = t;
        this.second = s;
    }

    private int hash = 0;

    @Override
    public int hashCode() {
        if (hash == 0) {
            final int prime = 31;
            int result = 1;
            result = prime * result + ((first == null) ? 0 : first.hashCode());
            result = prime * result + ((second == null) ? 0 : second.hashCode());
            hash = result;
        }
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair<T, S> other = (Pair<T, S>) obj;
        if (first == null) {
            if (other.first != null)
                return false;
        } else if (!first.equals(other.first))
            return false;
        if (second == null) {
            if (other.second != null)
                return false;
        } else if (!second.equals(other.second))
            return false;
        return true;
    }

    @Override
    public int compareTo(Pair<T, S> o) {
        return first.compareTo(o.first);
    }
}


Measured memory_bytes: 96144
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    char a, b;
    cin >> a >> b;
    cout << (a == b ? 'H' : 'D') << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
import numpy as np

H,W,K = map(int, input().split())

def s2n(s):
    if s=='#':
        return 1
    else:
        return 0

c = []

for i in range(H):
    c.append(list(map(s2n,list(input()))))
    # c.append(list(input()))

# mp = np.array(c)
ans = 0

def fill(mp,num,iscolumn):
    if iscolumn==0:
        mp[num]=0
    else:
        mp[:,num-H]=0
    return mp

for i in range(2**(H+W)):
    mp = np.array(c)
    for j in range(H+W):
        if((i>>j)&1):
            mp = fill(mp,j,j>=H)
    if np.sum(mp)==K:
        ans+=1

print(ans)

Measured memory_bytes: 27052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>



using namespace std;



int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 9 or b >= 9) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
} 

Measured memory_bytes: 256
def bubbleSort(arr)
  n = 0
  for i in 0..(arr.size - 1)
    j = arr.size - 1
    while j >= i + 1
      if arr[j] < arr[j - 1] then
        x = arr[j]
        arr[j] = arr[j - 1]
        arr[j - 1] = x
        n = n + 1
      end
      j = j - 1
    end
  end
  puts arr.join(' ')
  puts n
end

n = STDIN.gets.to_i
arr = STDIN.gets.split(' ').map{|x| x.to_i}
bubbleSort(arr)

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int h,w,d;
  cin>>h>>w>>d;
  auto A=make_v<Int>(h,w);
  using P = pair<Int, Int>;
  vector<P> R(h*w);
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>A[i][j],R[--A[i][j]]=P(i,j);

  vector<Int> dp(h*w,-1);

  auto calc=[&](Int x,Int y){
    if(y<0) return 0ll;
    //cout<<x+1<<" "<<y+1<<":"<<abs(R[x].first-R[y].first)+abs(R[x].second-R[y].second)<<endl;
    return abs(R[x].first-R[y].first)+abs(R[x].second-R[y].second);
  };
  function<Int(Int)> dfs=[&](Int x){
    if(x<0) return 0ll;
    if(~dp[x]) return dp[x];
    return dp[x]=dfs(x-d)+calc(x,x-d);
  };
  //for(Int i=0;i<h*w;i++) cout<<i<<":"<<dfs(i)<<endl;
  
  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int l,r;
    cin>>l>>r;
    l--;r--;
    cout<<dfs(r)-dfs(l)<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 8192
import Data.List

main = do
  _ <- getLine
  ai <- map read . words <$> getLine
  print . diffAliceBob' . reverse $ sort ai

diffAliceBob' :: [Int] -> Int
diffAliceBob' ns = if ((length ns) `mod` 2) == 0
  then diffAliceBob ns
  else diffAliceBob (init ns) + (head $ reverse ns)

diffAliceBob :: [Int] -> Int
diffAliceBob [] = 0
diffAliceBob (a:b:ns) = (a  - b) + diffAliceBob ns


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define N 1100005
struct node
{
	int st,ed,cnt;
	char c;
}a[N];
int c[N];
int n,z;
char ch[N],cc[N];
queue<int>q;
int main()
{
	//freopen("copy.in","r",stdin);
	//freopen("copy.out","w",stdout);
	scanf("%d%s%s",&n,ch+1,cc+1);
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		if(ch[i]!=cc[i])
		{
			flag=false;
			break;
		}
	}
	if(ch[1]!=cc[1])
	{
		puts("-1");return 0;
	}
	if(flag)
	{
		puts("0");return 0;
	}
	for(int i=1;i<=n;i++)
	{
		int j=i;
		while(j<=n&&cc[j]==cc[i])j++;
		a[++z].st=i;a[z].ed=j;
		if(cc[j]!=cc[i])a[z].ed--;
		a[z].c=cc[i];
		i=a[z].ed;
	}
	int la=n,ans=0;
	for(int i=z;i;i--)
	{
		la=min(la,a[i].st);
		while(la&&a[i].c!=ch[la])la--;
		if(la==0)
		{
			puts("-1");return 0;
		}
		while(!q.empty()&&q.front()-q.size()>=a[i].ed)q.pop();
		q.push(la);
		int te=q.size();
		ans=max(ans,te);
	}
	printf("%d\n",ans);
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> alis(n);
    REP(i, 0, n){cin >> alis[i];}
    ll key = -1;
    REP(i, 0, n){
        if(key+1 == alis[i]){
            key++;
        }else if(key >= alis[i]){
            key = alis[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = alis[n-1];
    for(int i = n-2; i >= 0; i--){
        if(alis[i]+1 == alis[i+1]){
            continue;
        }else{
            ans += alis[i];
        }
    }
    cout << ans << endl;
}

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

vector<long long int> a,b,c;

int main() {

    int n;

    cin >> n;

    for(int i=0; i<n; i++){
        long long int ai;
        cin >> ai;
        a.push_back(-ai);
    }

    for(int i=0; i<n; i++){
        long long int bi;
        cin >> bi;
        b.push_back(bi);
    }

    for(int i=0; i<n; i++){
        long long int ci;
        cin >> ci;
        c.push_back(ci);
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    long long int ans = 0;

    for(int i=0; i<n; i++){
        long long int lock_num = b[i];
        auto a_itr = upper_bound(a.begin(),a.end(),-lock_num);
        auto c_itr = upper_bound(c.begin(),c.end(),lock_num);
        long long int a_num = a.end() - a_itr;
        long long int c_num = c.end() - c_itr;

        ans += a_num * c_num;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int count_ab(string &s){
	int ans = 0;
	for(int i=0; i<s.length()-1; i++){
		if(s[i] == 'A' && s[i+1] == 'B') ans++;
	}
	return ans;
}

int main(){
	
	int N;
	string tmp;
	
	int ab = 0;
	int bx = 0, xa = 0, bxa = 0;
	bool tb, ta;
	
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> tmp;
		ab += count_ab(tmp);
		tb = (tmp[0] == 'B'); ta = (tmp[tmp.length()-1] == 'A');
		bx += tb ? 1 : 0;
		xa += ta ? 1 : 0;
		bxa += ta && tb ? 1 : 0;
	}
	
	int a_ans = min(bx, xa);
	int b_ans = ab;
	if(a_ans >= N || (bx == bxa && xa == bxa && a_ans != 0)) a_ans--;
	
	//printf("bx: %d, xa: %d, bxa: %d, a_ans: %d, b_ans:%d\n", bx, xa, bxa, a_ans, b_ans);
	printf("%d\n", a_ans + b_ans);
	
	return 0;
}

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

A = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)

print(A[K-1])

Measured memory_bytes: 2940
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    ans = 10**9
    for a in A:
        i = 0
        while a % 2 == 0:
            a //= 2
            i += 1
        ans = min(ans, i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
s = input()

alphabet_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

for i in range(len(s)):
  if s[i] in alphabet_list:
    try:
      alphabet_list.remove(s[i])
    except ValueError:
      continue

if alphabet_list:
  print(alphabet_list[0])
else:
  print('None')

Measured memory_bytes: 9048
#include<iostream>
using namespace std;
int main(){
	int a, b, c, x;
	cin >> a >> b >> c;
	if (a > b){
		x = a;
		a = b;
		b = x;
	}
	if (b > c){
		x = b;
		b = c;
		c = x;

	}
	if (a > b){
		x = a;
		a = b;
		b = x;
	}
	cout << a <<" "<< b <<" "<< c <<endl;
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}


int main()
{
    int A,P;
    cin >> A >> P;
    P += A*3;
    cout << P/2 << endl;
    return 0;
}


Measured memory_bytes: 764
import math
def main():
  s = input()
  flg=0
  if s[0]=='A':
    if s[2:len(s)-1].count('C')==1:
      s=s.replace('C','c')
      if s[1:].islower():
        print("AC")
        flg=1
  if flg==0:
    print("WA")
main()


Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<ll,ll>;
using vi = vector<ll>;
using vv = vector<vi>;

int powmod(int a, int n, int m){
  int rtn = 1;
  while(n){
    if(n&1)
      rtn = rtn * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return rtn;
}

int main(){
  string s;
  cin >> s;
  
  vi c(2019, 0);
  int a = 0;
  c[0] = 1;
  rep(i,(int)s.size()){
    a += powmod(10, (int)s.size()-1-i, 2019)*(s[i] - '0');
    a %= 2019;
    //cout<<i+1<<" "<<a<<endl;
    c[a]++;
  }
  ll ans = 0;
  rep(i,2019){
    ans += c[i]*(c[i]-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

void A_148()
{
  int A, B;
  cin >> A >> B;

  for (int i = 1; i < 4; ++i)
  {
    if (i != A && i != B) cout << i << endl;
  }
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  //C_149();
  //A_149();
  //B_149();
  A_148();
  return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
   void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W, N;
int globalIdx = 0;
int a[10010];
int B[109][109];

void init() {
   rep (i, H) {
      rep (j, W) {
         B[i][j] = -1;
      }
   }
}

void dfs(int y, int x) {
   rep (i, 4) {
      int py = y + dy[i], px = x + dx[i];
      if (py < 0 || py >= H || px < 0 || px >= W || B[py][px] != -1) continue;
      int ny = y, nx = x;
      while (1) {
         ny += dy[i], nx += dx[i];
         if (ny<0 || ny>=H || nx<0 || nx>=W || B[ny][nx]!=-1) break;
         B[ny][nx] = a[globalIdx];
         globalIdx++;
      }
      dfs(ny-dy[i], nx-dx[i]);
   }
}

int main() {
   cin >> H >> W >> N;
   init();
   int idx = 0;
   rep (i, N) {
      int x;
      cin >> x;
      rep (j, x) {
         a[idx] = i+1;
         idx++;
      }
   }
   
   B[0][0] = a[0];
   globalIdx++;
   dfs(0, 0);
   rep (i, H) {
      rep (j, W-1) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}

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


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

def lcm(a, b):
    return a*b//gcd(a, b)


tmp = 1
for i in range(N):
    T = int(input())
    ans = lcm(T, tmp)
    tmp = ans

print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int n,m,ans;

string t[100];
int u[100];
string str;

bool check(string a,string b){
  for(int i=0;i<8;i++){
    if(b[i]=='*')continue;
    if(a[i]!=b[i])return false;
  }
  return true;
}

int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    ans=0;
    for(int i=0;i<n;i++)cin>>t[i]>>u[i];

    for(int i=0;i<m;i++){
      cin>>str;
      for(int j=0;j<n;j++){
	if(check(str,t[j])){
	  ans+=u[j];
	  break;
	}
      }
    }
    cout<<ans<<endl;
  }
}

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

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

using ll = long long;
using lb = long double;
using P = pair<string,string>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  lb dense = -1;
  ll answ=0,anss=0;
  rep(i,30){
    rep(j,30){
      ll water = A*i*100+B*j*100;
      if(water>F) continue;
      ll smax = min((water/100)*E,F-water);
      ll sugar = (smax/C)*C,cnt = (smax/C);
      while(cnt!=-1){
        lb d = (lb)sugar/(water+sugar);
        if(chmax(dense,d)) {
          answ = water;
          anss = sugar;
        }
        cnt--;
        sugar -= C;
        if(sugar+D<=smax) sugar += D;
      }
    }
  }
  cout<<answ+anss<<" "<<anss<<endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
void change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D)
{
  int d,t,old,total=0,i,j;
  d=rand()%D+1;
  t=rand()%type+1;
  old=schedul[d];
  schedul[d]=t;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  start=clock();
  for(i=1;i<D+1;i++){
    int select;
    select=constant(i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.8){
    change(c,last,s,sum,schedul,D);
    count++;
    stop=clock();
  }
  /*
  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);
  */
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1812
n = gets.chomp.to_i
while true do
  flag = true
  
  (2..Math.sqrt(n).to_i).each do |i|
    if n % i == 0 then
      flag = false
      break
    end
  end
  
  if flag then
    puts n
    break
  end
  
  n += 1
end

Measured memory_bytes: 1788
from collections import deque
INF = 1001001001
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]

H, W = map(int, input().split())
S = [input() for _ in range(H)]

ans = 0
for si in range(H):
    for sj in range(W):
        if S[si][sj] == '#': continue
        dist = [[INF] * W for _ in range(H)]
        dist[si][sj] = 0
        q = deque([(si, sj)])
        while q:
            i, j = q.popleft()
            for dir in range(4):
                ni = i + di[dir]
                nj = j + dj[dir]
                if (ni<0 or ni>=H or nj<0 or nj>=W): continue
                if S[ni][nj] == '#': continue
                if dist[ni][nj] != INF: continue
                dist[ni][nj] = dist[i][j] + 1
                q.append([ni, nj])
        for i in range(H):
            for j in range(W):
                if dist[i][j] == INF: continue
                ans = max(ans, dist[i][j])
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
    long long int n,b=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];


    }
    for(int i=0;i<n-1;i++){
        if (a[i+1]<a[i]){
            b+=a[i]-a[i+1];
            a[i+1]=a[i];
        }


    }
    cout << b << endl;



}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	int m=0,n=0;
	int money=0;
	int year=0;
	int r=0;
	double rate=0;
	int tax=0;
	int risi=0;
	int ans=0;
	vector<int> anss;

	cin >> m;

	for(int i=0;i<m;i++){
		cin >> money;
		cin >> year;
		cin >> n;
		
		for(int j=0;j<n;j++){
			cin >> r >> rate >> tax;

			ans=money;

			if(r==0){
				for(int k=0;k<year;k++){
					risi = risi + floor(double(ans)*rate);
					ans = ans - tax;
				}
				ans = ans + risi;
			}else{
				for(int k=0;k<year;k++){
					ans = ans + floor(double(ans)*rate) - tax;
				}
			}
			anss.push_back(ans);
			risi=0;
			ans=0;
			tax=0;
		}
		sort(anss.begin(),anss.end());
		cout << anss.back() << endl;
		risi=0;
		ans=0;
		tax=0;
		anss.clear();
	}
}

Measured memory_bytes: 0
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			int g = __gcd(i, j);
			if (g == 1) {
				ans += n;
			} else {
				for (int k = 1; k <= n; k++)
					ans += __gcd(g, k);
			}

		}
	}

	cout << ans << '\n';

	return Accepted;
}

// B...a

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

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ans += __gcd(k, __gcd(i, j));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

i = 0

while True:
    a = list((int(x) for x in input().split()))
    a.sort()

    i += 1

    if a[0] ** 2 + a[1] ** 2 == a[2] ** 2:
        print("YES")
    else:
        print("NO")

    if i == N:
        break


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

int main(void)
{
	int i, j, k, p, n;
	char str[2048];
	char train[1024];
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		for (j = 0; j < 1024; j++){
			train[j] = '\0';
		}
		
		scanf("%s", str);
		
		train[0] = str[0];
		p = 1;
		j = 0;
		while (str[p] != '\0'){
			if (strncmp(&str[p], "->", 2) == 0){
				if (train[j+1] == '\0'){
					train[j+1] = str[p+2];
				}
				j++;
			}
			
			else if (strncmp(&str[p], "<-", 2) == 0){
				if (j == 0){
					for (k = 1024; k > 0; k--){
						train[k] = train[k-1];
					}
					train[0] = str[p+2];
				}
				
				else {
					j--;
				}
			}
			
			p += 3;
		}
		
		printf("%s\n", train);
	}
	
	return (0);
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll MAX=1e18;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(400);
    vector<ll> prefix(n+1);
    prefix[0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        prefix[i+1]=prefix[i]+a[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        dp[i][i]=0;
    }
    for(int i=n-1;i>=0;i--){
        for(int j=i+1;j<n;j++){
            dp[i][j]=MAX;
            for(int k=i;k<j;k++){
                dp[i][j]=min(dp[i][j],prefix[j+1]-prefix[i]+dp[i][k]+dp[k+1][j]);
            }
        }
    }
    cout<<dp[0][n-1]<<'\n';
    return 0;
}


Measured memory_bytes: 4520
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int w,h,n;
  cin>>w>>h>>n;
  int a=0,b=w,c=0,d=h;
  rep(i,n) {
    int x,y,z;
    cin>>x>>y>>z;
    if(z==1) a=max(x,a);
    if(z==2) b=min(x,b);
    if(z==3) c=max(c,y);
    if(z==4) d=min(d,y);
  }
  if(a<b&&c<d) {
    cout << (b-a)*(d-c)<<endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8

main :: IO ()
main = do
  contents <- B.getContents
  case parseOnly inputParser contents of
    Right r -> print $ solve r
    Left  e -> error e

inputParser = (,) <$> decimal <* space <*> decimal

solve :: (Int, Int) -> Int
solve (a, b)
  | a > 9 || b > 9 = -1
  | otherwise      = a * b

Measured memory_bytes: 508
K = int(input())
def enc(k, m):
  plain = list(m.encode("ascii")) 
  cipher = plain.copy() 
  for i,code in enumerate(plain ):
    cipher[i] = cipher[i] + k
    if (cipher[i] > 90):
      cipher[i] = cipher[i] - 26      
  return(bytes(cipher ). decode("ascii"))
angobun = enc(K,input())
print(angobun) 


Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M;
	cin >> N >> M;

	vector<Int> suki(M);

	Int k;
	Int  a;
	for (Int i = 0; i < N; i++) {
		cin >> k;
		for (Int j = 0; j < k; j++) {
			cin >> a;
			a--;
			suki[a]++;
		}
	}

	Int ans = 0;
	for (Int i = 0; i < M; i++) {
		if (suki[i]==N) {
			ans++;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;

int n;

vector<int>v[202];

bool viz[202], a[202][202];

int sett[202];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= n; ++j)
        {
            a[i][j] = (s[j-1] - '0');
            if(a[i][j])
                v[i].pb(j);
        }
    }
    int max_answer = -1;
    for(int start = 1; start <= n; ++start)
    {
        memset(viz, 0, sizeof(viz));
        memset(sett, 0, sizeof(sett));
        deque<int>d;
        d.pb(start);
        sett[start] = 1;
        viz[start] = 1;
        int pr = 1;
        while(!d.empty())
        {
            int nod = d[0];
            d.pop_front();
            for(int j = 0; j < v[nod].size(); ++j)
            {
                int vecin = v[nod][j];
                if(!viz[vecin])
                {
                    viz[vecin] = 1;
                    d.pb(vecin);
                    sett[vecin] = sett[nod] + 1;
                    pr = max(pr, sett[vecin]);
                }
            }
        }
        for(int i = 1; i <= n; ++i)
            for(int j = 1; j <= n; ++j)
                if(a[i][j])
                {
                    if(abs(sett[i] - sett[j]) != 1)
                        pr = -1;
                }
        max_answer = max(max_answer, pr);
    }
    cout << max_answer << '\n';
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(b==100)
    a*=1000;
    else if(b/10>0)
    a*=100;
    else
    a*=10;
    a+=b;
    int N=sqrt(a);
    if(N*N==a)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int main()
{
    int n,x[N];
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
            scanf("%d",&x[i]);
        sort(x,x+n);
        double ans =x[0],s;
        for(int i=1;i<n;i++)
            ans *=0.5,s =x[i]*0.5,ans +=s;
        printf("%f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n);
	vector<int> a(n);
	cin >> a;
	sort(ALL(a));
	bool ans = true;
	inc(i, n - 1) { ans &= (a[i] != a[i + 1]); }
	OUT(ans ? "YES" : "NO");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

int count(const string &S) {
    int res = 0;
    for (int i = 0; i + 1 < S.size(); ++i) {
        if (S[i] == 'A' && S[i + 1] == 'B') ++res;
    }
    return res;
}

int N;
vector<string> S;

ll solve() {
    ll res = 0;
    for (int i = 0; i < N; i++) res += count(S[i]);

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; i++) {
        if (S[i][0] == 'B' && S[i].back() == 'A') ++a;
        else if(S[i].back() == 'A') ++b;
        else if(S[i][0] == 'B') ++c;
    }
    ll add = 0;
    if (b + c == 0) add = max(0, a - 1);
    else add = a + min(b, c);

    res += add;
    return res;
}

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

    while(cin >> N) {
        S.resize(N);
        for (int i = 0; i < N; i++) cin >> S[i];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int N;
	long long ans[85];
	scanf("%d",&N);
	ans[0]=2;
	ans[1]=1;
	for(int i=2;i<=85;i++)
	{
		ans[i]=ans[i-1]+ans[i-2];
	}
	if(N<=85) printf("%lld\n",ans[N]);
	if(N==86) printf("939587134549734843");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;



int main(){
    ll N,P;
    cin >> N >> P;
    
    ll ans=1;
    
    if(N==1){
        cout<<P<<endl;
        return 0;
    }else{
        // equal or less than sqrt(P)
        ll Q=P;
        for(ll i=2; i*i<=Q; i++){
            ll n=0;
            while(P%i==0){
                n++;
                P/=i;
            }
            
            for(ll j=0; j<(n/N); j++){
                ans*=i;
            }
        }
        
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n;
  ll m;
  cin>>n>>m;

  vector<ll> s;
  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      s.push_back(i);
      s.push_back(m/i);
    }
  }
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    if(s[i]*n<=m){
      cout<<s[i]<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
s = gets.chomp
ans = "true"
if s[0] == "A" && s[2..s.length-2].count("C") == 1
	ans = "true" 
	s.delete!("A")
	s.delete!("C")
	if s.downcase != s
	    ans = "false"
	end
else
	ans = "false"
end
if ans == "true"
  puts "AC"
else
  puts "WA"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastio;
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

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

using namespace std;



int main()
{
    int n,h,k;
    cin>>n>>k;
    vector<int>vec;
    long long dp[n];
    for(int i=0;i<n;i++)
    {
        cin>>h;
        vec.push_back(h);
    }

    for(int i=0;i<n;i++)
    {
        dp[i]=100000000000;
    }
    dp[0]=0;
    for (int i=0;i<n;i++)
    {
        for(int j=1;j<k+1;j++)
        {
            if (i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(vec[i]-vec[i+j]));
            }
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1528