akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    string input;
    cin >> input;

    unsigned int size = input.size();

    bool cflag = false;

    for(unsigned int a = 0; a < size; a++ ){
        string ap = input.substr(a,1);

        if(ap == "C"){
            cflag = true;
        }
        if(cflag){
            if(ap == "F"){
                cout << "Yes" << endl;

                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

typedef long long ll;

void maxHeap(vector<ll> &h, int i){
    int left = i*2+1;
    int right = i*2+2;
    int largest = i;
    if(left < h.size() && h[left] > h[largest]) largest = left;
    if(right < h.size() && h[right] > h[largest]) largest = right;

    if(largest != i){
        swap(h[largest],h[i]);
        maxHeap(h,largest);
    }
}

void buildMaxHeap(vector<ll> &heap){
    for(int i=heap.size()/2;i>=0;i--){
        maxHeap(heap, i);
    }
}

void input(vector<ll> &heap, int i){
    int sub=i+1;
    if(sub <= 1)return;
    if(heap[sub-1] > heap[sub/2-1]){
        swap(heap[sub-1], heap[sub/2-1]);
        input(heap, sub/2-1);
    }

}

void printheap(const vector<ll> &h){
    cout << "size: " << h.size() << endl;;
    for(int i=0;i<h.size();i++)cout <<" " << h[i];
    cout << "\n";
}


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

    vector<ll> heap;
    string str;
    ll num;
    cin >> str;
    while(str != "end"){
        if(str == "insert"){
            cin >> num;
            heap.push_back(num);
            input(heap, heap.size()-1);
        }else if(str == "print"){
            printheap(heap);
        }else{
            if(!heap.empty()){
                cout << heap.front() << endl;
                heap[0] = heap.back();
                heap.pop_back();
                maxHeap(heap, 0);
            }
        }
        cin >> str;
    }
    return 0;
}



Measured memory_bytes: 11236
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;

    int x3 = x2 - dy, y3 = y2 + dx;
    int x4 = x1 - dy, y4 = y1 + dx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

	vector<int> A(3);
	REP(i,3) cin >> A[i];

	map<int,int> cnt;
	REP(i,3) cnt[A[i]]++;

	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		if (itr->second == 1) {
			cout << itr->first << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int MAX_E = 1e5 + 1;

class KRUSKAL {

   public: 
      int par[MAX_E];
      int UFTrank[MAX_E];
      struct edge { int u, v, cost; };
      edge es[MAX_E * 2];
      int E, V;

      bool comp(const edge& e1, const edge& e2) {
         return e1.cost < e2.cost;
      }
      
      void init(int e, int v) {
         E = e;
         V = v;
         // sort(es, es + E, comp);
         sort(es, es + E, [this] (edge& e1, edge& e2) { return  comp(e1, e2); } );
         for (int i = 0; i < V; i++) {
            par[i] = i;
            UFTrank[i] = 0;
         }
      }

      int find(int x) {
         if (par[x] == x) {
            return x;
         } else {
            return par[x] = find(par[x]);
         }
      }

      void unite(int x, int y) {
         x = find(x);
         y = find(y);
         if (x == y) return;

         if (UFTrank[x] < UFTrank[y]) {
            par[x] = y;
         } else {
            par[y] = x;
            if (UFTrank[x] == UFTrank[y]) UFTrank[x]++;
         }
      }

      bool same(int x, int y) {
         return find(x) == find(y);
      }       

      int getmin() {
         int ans = 0;
         for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (!same(e.u, e.v)) {
               unite(e.u, e.v);
               ans += e.cost;
            }
         }
         return ans;
      }
};



int main() {
   int V, E;
   cin >> V >> E;
   KRUSKAL mst;
   int s, t, w;
   for (int i = 0; i < E; i++) {
      cin >> s >> t >> w;
      mst.es[i].u = s;
      mst.es[i].v = t;
      mst.es[i].cost = w;
   }
   mst.init(E, V);
   int ans = mst.getmin();
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 4360
import java.util.*;

public class Main{
	public static void main(String[] args){

		List<String> rank = new ArrayList<String>();
		Scanner scan = new Scanner(System.in);
		for(;;){
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			if((m == -1) && (f == -1) && (r == -1)){
				break;
			}
			if((m == -1) || (f == -1)){
				rank.add("F");
			} else if((m + f) >= 80){
				rank.add("A");
			} else if((m + f) >= 65){
				rank.add("B");
			} else if((m + f) >= 50){
				rank.add("C");
			} else if(((m + f) >= 30) && (r >= 50)){
				rank.add("C");
			} else if(((m + f) >= 30) && (r < 50)){
				rank.add("D");
			} else {
				rank.add("F");
			}
		}

		for(String s : rank){
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 26332
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  vector<int> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 1; i < n + 1; i++) {
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    int dt = t[i] - t[i - 1];
    if (dist > dt || dist % 2 != dt % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
n = input()
wn = input().split()

n = int(n)
wn = [int(w) for w in wn]

minimum_diff_abs = float('inf')

for i in range(n-1):
    i = i + 1
    # i = 1 ~ n - 1
    left_sum = sum(wn[:i])
    right_sum = sum(wn[i:])
    diff_abs = abs(left_sum - right_sum)
    if diff_abs < minimum_diff_abs:
        minimum_diff_abs = diff_abs

print(minimum_diff_abs)


Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(){
  int s;
  cin>>s;
  bool YYMM=false,MMYY=false;
  
  YYMM=(s%100<=12&&1<=s%100);
  MMYY=(s/100<=12&&1<=s/100);
  
  
  cout<<((YYMM)?((MMYY)?"AMBIGUOUS":"YYMM"):((MMYY)?"MMYY":"NA"));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int r, g, b;
	cin >> r >> g >> b; if ((100 * r + 10 * g + b) % 4 == 0)print("YES"); else print("NO");






	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N, K;
ll A[2005];
ll inv, unit;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) {
            if(A[i] > A[j]) inv++;
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(A[i] < A[j]) unit++;
        }
    }
    ll ans = ((K * (K-1) / 2) % mod) * (unit % mod);
    ans += inv * K;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int N;
    cin >> N;

    int sum = 0;
    int min = 0;
    for (int i = 0; i < N; i++){
        int s;
        cin >> s;
        sum += s;

        if (s % 10 != 0){
            if (min == 0){
                min = s;
            }else{
                if (min > s){
                    min = s;
                }
            }
        }
    }
    
    int ans = sum;
    if (sum % 10 == 0){
        if (min != 0){
            ans = sum - min;
        }else{
            ans = 0;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    A,B,C,K = map(int,input().split())

    res = 0

    if A >= K:
        res += K
        K = 0
    else:
        res += A
        K -= A

    if B >= K:
        K = 0
    else:
        K -= B

    if C >= K:
        res -= K
        K = 0
    else:
        res -= A
        K -= C

    print(res)


main()


Measured memory_bytes: 9020
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ls <- replicateM n getLine
  let ansL = map ordAlpha' ls
  mapM_ putStrLn ansL

ordAlpha :: String -> String -> Int -> Int -> Int -> String
ordAlpha "" save _ _ _ = save
ordAlpha (c:rs) "" p l h = ordAlpha rs (c:[]) p l h
ordAlpha ('-':'>':c:rs) save p l h
  | p == h = ordAlpha rs (save++(c:[])) (p+1) l (h+1)
  | otherwise = ordAlpha rs save (p+1) l h
ordAlpha ('<':'-':c:rs) save p l h
  | p == l = ordAlpha rs (c:save) (p-1) (l-1) h
  | otherwise = ordAlpha rs save (p-1) l h

ordAlpha' :: String -> String
ordAlpha' ss = ordAlpha ss "" 0 0 0

Measured memory_bytes: 5528
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

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

    return 0;
}

Measured memory_bytes: 3688
N = int(input())
a = [int(input()) for _ in range(N)]

count = 1
now = 1
# print("lightning: {}".format(now))
while count < len(a):
    now = a[now-1]
    # print("lightning: {}".format(now))
    if now == 2:
        print(count)
        exit()
    count += 1

print('-1')


Measured memory_bytes: 7320
/*alurquiza*/
//U:Grouping
#include <bits/stdc++.h>

using namespace std;

const int SIZE = 16,SIZE2 = 1 << 16;
int MA[SIZE][SIZE];
long long DP[SIZE2],AUX[SIZE2];

long long f(int mask){
    long long ret = 0;
    for(int i = 0;(1 << i) < mask;i++)
        if((1 << i) & mask)
            for(int j = i + 1;(1 << j) < mask;j++)
                if((1 << j) & mask)
                    ret += MA[i][j];

    return ret;
}

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

//    freopen(".in","r",stdin);
//    freopen(".out","w",stdout);

    int N;
    cin >> N;

    for(int i = 0;i < N;i++)
        for(int j = 0;j < N;j++)
            cin >> MA[i][j];

    fill(DP + 1,DP + SIZE2,-(1LL << 60)); //DP[0] = 0

    for(int mask = 0;mask < (1 << N);mask++){
        AUX[mask] = f(mask);

        ///iterar por todas las submask
        for(int smask = mask;smask;smask = mask & (smask - 1)){
            long long sum = AUX[smask];
            int imask = mask ^ smask;

            if(DP[imask] + sum > DP[mask])
                DP[mask] = DP[imask] + sum;
        }
    }

    cout << DP[(1 << N) - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define ROP(a) for(int i=0; i<a; i++)
using namespace std;

typedef unsigned long long ULL;
ULL X, Y;

int decompositPrime(ULL n)
{
	ULL a = 2;
	int ret = 0;

	while (n >= (a * a))
	{
		if (n%a == 0)
		{
			//printf("%llu * ", a);
			ret++;
			n /= a;
		}
		else
		{
			a++;
		}
	}
	ret++;

	return ret;
}

int main()
{
	cin >> X >> Y;
	ULL s = Y / X;
	
	int ret1 = decompositPrime(s);

	int ret2 = 0;
	while (X <= Y)
	{
		//printf("%d\n", count);
		X *= 2;
		ret2++;
	}

	printf("%d", ret1 > ret2 ? ret1 : ret2);

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
	public static final int vx[] = {1,0,-1,0};
	public static final int vy[] = {0,-1,0,1};
	public static int h = 0;
	public static int w = 0;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			h = sc.nextInt();
			w = sc.nextInt();
			if (h+w==0) {
				break;
			}
			char[][] f = new char[w][h];
			for (int y=0;y<h;y++) {
				String line = sc.next();
				for(int x=0;x<w;x++) {
					f[x][y] = line.charAt(x);
				}
			}
			int ans = 0;
			for (int x=0;x<w;x++) {
				for (int y=0;y<h;y++) {
					if (f[x][y]!='.') {
						ans++;
						//BFS-------
						char tf = f[x][y];
						Queue<Pos2d> q = new ArrayDeque<Pos2d>();
						q.offer(new Pos2d(x,y));
						while(!q.isEmpty()) {
							Pos2d p = q.poll();
							if (f[p.x][p.y]==tf) {
								f[p.x][p.y]='.';
								for(int i=0;i<4;i++) {
									int nx = p.x + vx[i];
									int ny = p.y + vy[i];
									if (nx>=0 && nx<w && ny>=0 && ny<h) {
										q.offer(new Pos2d(nx,ny));
									}
								}
							}
						}
						//----------
					}
				}
			}
			System.out.println(ans);
		}
	}
}
class Pos2d {
	public int x = 0;
	public int y = 0;
	public Pos2d(int x,int y) {
		this.x = x;
		this.y = y;
	}
	public boolean equals(Object o) {
		Pos2d p = (Pos2d) o;
		return (this.x==p.x && this.y==p.y);
	}
	public String toString() {
		return "("+x+","+y+")";
	}
}

Measured memory_bytes: 27760
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
using namespace std;
bool can(int max,int num2,vector<int>a,int num1){
    vector <int> m2;m2.push_back(0);
    for(int i=0;i<num1;i++) {
        if(a[i]+*(m2.end()-1)<=max) *(m2.end()-1)+=a[i];
        else m2.push_back(a[i]);
    }
     return (m2.size()<=num2);
}
int main()
{
    int num1,num2,tmp,max_;
    cin>>num1>>num2;
    vector<int> m,m3,copy;
    for(int i=0;i<num1;i++) {cin>>tmp;m.push_back(tmp);}
    copy=m;
    sort(copy.begin(),copy.end());
    if(copy[num1-1]>accumulate(m.begin(),m.end(),0)/num2)
    {max_=copy[num1-1];if(can(max_,num2,m,num1)) {cout<<max_<<endl;return 0;}}
    else max_=accumulate(m.begin(),m.end(),0)/num2;
    //cout<<"max_"<<max_<<endl;
    //cout<<"start:"<<start<<"end:"<<end<<endl;
    for(int i=max_;i<=max_+copy[num1-1];i++)
        if(can(i,num2,m,num1)) {cout<<i<<endl; return 0;}

}



Measured memory_bytes: 4736
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;


int main(){
  int x, a, b; cin>>x>>a>>b;
  if(abs(a-x)<abs(b-x)) cout << "A" << endl;
  else cout << "B" << endl;
}


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

using namespace std;


long long int DP[3001][3001];

long long int maximizexminusy(long long int *arr,int n,int i,int j){

    if(i>j)
    return 0; 

     if(DP[i][j]!=-1)
  return DP[i][j];


   else{


    
     return DP[i][j]=max(arr[i]+min(maximizexminusy(arr,n,i+2,j),maximizexminusy(arr,n,i+1,j-1)),arr[j]+min(maximizexminusy(arr,n,i+1,j-1),maximizexminusy(arr,n,i,j-2)));
    
    


   }

  //return DP[i][j][turn];



}


int main(){



  int n;

  cin>>n;

  long long int arr[n];
  long long int sum=0;

  for(int i=0;i<n;i++){
  	cin>>arr[i];
  	sum+=arr[i];
  }

 memset(DP,-1,sizeof DP);
  
  long long int x=maximizexminusy(arr,n,0,n-1);
  //cout<<x;
  
  long long int y=sum-x;

   cout<<(x-y)<<endl;
   

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  int ans=0;
  for(int i=1;i<N;){
    if(a.at(i)==a.at(i-1)){
      ans++;
      i+=2;
    }else{
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    string s;
    cin>>s;
    int len;
    len=s.size();
    rep(i,len){
        if(i%2==0){
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                cout<<"No"<<endl;
                return 0; 
            }
        }else{
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
                cout<<"No"<<endl;
                return 0; 
            }
        }
    }
    cout<<"Yes"<<endl;
}

                

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
	int n,count=0,max=0;
	string s;
	cin>>n>>s;
	if(1<=n<1000){
		for(int i=0;i<n;i++){
			if(s[i]=='I'){
				count++;
			}else
			{
			count--;}
		if(count>max){
			max=count;
		}
	}cout<<max;
}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int n;
bool f;
signed main(){
    
    cin>>n;
    int num=n%100;
    int cnt=n/100;
    rep(i,num+1){
        for(int j=0;2*j<=num;j++){
            for(int k=0;3*k<=num;k++){
                for(int l=0;4*l<=num;l++){
                    int ex=num-(i+j*2+k*3+l*4);
                    if(ex%5==0 && ex>=0 && i+j+k+l+ex/5<=cnt)f=true;
                }
            }
        }
    }
    if(f)cout<<1<<endl;
    else cout<<0<<endl;

}

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

bool ok[100010];

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

  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  char maze[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      maze[i][j] = s[(i+j)%n][n-j-1];
    }
  }

  for (int i = 0; i < n; i++) {
    bool f = 1;
    for (int j = 0; j < n; j++) {
      int l1 = 0, r1 = n - 1 - j;
      int l2 = r1 + 1, r2 = n - 1;
      while (l1 < r1) {
        f &= (maze[(i + j) % n][l1] == maze[(i + j) % n][r1]);
        l1++;
        r1--;
      }
      while (l2 < r2) {
        f &= (maze[(i + j) % n][l2] == maze[(i + j) % n][r2]);
        l2++;
        r2--;
      }
    }
    if (f) {
      ok[i] = 1;
      ok[i+n] = 1;
    }
  }

  int ans = 0;
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < n; b++) {
      ans += ok[a+b];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
var
 s,s1:string;
 i:longint;
begin
 readln(s);
 s1:='';
 for i:=1 to length(s) do
  begin
   if s[i]='1' then s1:=s1+'1';
   if s[i]='0' then s1:=s1+'0';
   if (s[i]='B') and (s1<>'') then delete(s1,length(s1),1);
  end;
 writeln(s1);
end.

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

#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int MXN = 1e5 + 5;


int main(){FIO
   #ifndef  ONLINE_JUDGE
   freopen("in", "r", stdin);
   freopen("out", "w", stdout);
   #endif
   int n; cin>>n;
   ll arr[n];
   for (int i = 0; i < n; ++i)
   {
   	cin>>arr[i];
   }
   sort(arr, arr+n);

   if(n % 2 == 0){
   	ll sum = arr[n-1];
      for (int i = 0; i < n/2-1; ++i)
      {
      	sum += 2*arr[n-i-2];
      }
      cout<<sum<<endl;
   }
   else{
      int i;
      ll sum = arr[n-1];
      for (i = 0; i < n/2 - 1; ++i)
      {
      	sum += 2*arr[n-i-2];
      }
      sum += arr[n-i-2];
      cout<<sum<<endl;
      
   }
   return 0;
}

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

int main() {
  string c;
  cin >> c; 
   
    if (c.at(0) == 'a'||c.at(0) =='i'||c.at(0) =='u'||c.at(0) =='e'||c.at(0) =='o') {
  cout << "vowel" << endl;
    }
   
   else {
  cout << "consonant" << endl;   
  }
  
  
  
  
  
  

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
      int n,k; cin >> n >> k;
      cout << setprecision(15);
      ld ans = 0.0;
      for(int i = 1; i <= n; i++){
         int score = i;
         ld pr = 1.0;
         while(score < k){
            score = score + score;
            pr = pr * (ld)(1 / 2.0);
         }
         ans += pr;
      }
      ans = ans * (ld)(1 / (ld)n);
      cout << setprecision(15) << ans << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 3788
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
  int N;
  scanf("%d",&N);
  int p[N],val[N+1];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&p[i]);
    if (p[i]==i+1) val[i]=1;
    else val[i]=0;
  }
  val[N]=0;
  int n=0;
  for(i=0;i<N;i++){
    if (val[i]==0) continue;
    else{
      if(val[i+1]==1){
	val[i+1]=0;
	n+=1;
      }
      else n+=1;
    }
  }
  printf("%d",n);
  return 0;
}
  

Measured memory_bytes: 896
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	cout<<(h2*60+m2)-(h1*60+m1)-k<<endl; 
	return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int dp[100030] = {};
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a + d-1) / d >= (c + b-1) / b) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    map<int, int> app;
    for (int i = 0, v; i < N; i++) {
        cin >> v;
        app[v]++;
    }

    int rem = 0;
    for (auto p : app)
        if (p.second >= p.first) rem += p.second - p.first;
        else rem += p.second;
    cout << rem << endl;

    return 0;
}



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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);
    ll s,w; cin>>s>>w;
    if(w>=s) puts("unsafe");
    else puts("safe");

    return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(){
	ll k,a,b;cin>>k>>a>>b;
	if(a>=k){
		puts("1");
		return 0;
	}
	if(a-b<=0){
		puts("-1");
		return 0;
	}
	ll d=(k/(a-b))*2;d=max(0LL,d-6);
	ll c=d/2*(a-b);
	while(1){
		c+=a;
		d++;
		if(c>=k){
			cout<<d<<endl;
			return 0;
		}
		c-=b;
		d++;
	}
}

Measured memory_bytes: 256
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda x: -x[2])

for cx in range(101):
    for cy in  range(101):
        h = l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)
        for i in l[1:]:
            if max(h - abs(i[0] - cx) - abs(i[1] - cy), 0) != i[2]:
                break
        else:
            print(cx,cy,h)
            exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

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

    int tc = 1;
    //cin >>  tc;
    while(tc--){
        int n;
        cin >> n;
        ll a[n];
        ll X = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            X = X ^ a[i];
        }
        for(int i = 0; i < n; i++){
            cout << (X ^ a[i]) << " ";
        }
    }
}



Measured memory_bytes: 5196
#include <iostream>
#include <string>
 
using namespace std;
 
int main(void){
  	string input_str;
  	cin >> input_str;
  	int A,B,C,D;
	A=input_str[0]-'0';
  	B=input_str[1]-'0';
  	C=input_str[2]-'0';
  	D=input_str[3]-'0';
  	int i,j,k;
	int sum_op1,sum_op2,sum_op3;
  	char op1,op2,op3;
  
  	for(i=0;i<2;i++){
      sum_op1=0;
      if(i==0)	sum_op1=A+B;
      else	sum_op1=A-B;
      
      for(j=0;j<2;j++){
        sum_op2=0;
        if(j==0)	sum_op2=sum_op1+C;
        else	sum_op2=sum_op1-C;
        
        for(k=0;k<2;k++){
           sum_op3=0;
           if(k==0)	sum_op3=sum_op2+D;
           else	sum_op3=sum_op2-D;
         if(sum_op3==7){
           if(i==0)	op1='+';
           else if(i==1) op1='-';
           if(j==0) op2='+';
           else if(j==1) op2='-';
           if(k==0) op3='+';
           else if(k==1) op3='-';
           cout << A << op1 << B << op2 << C << op3 << D << "=7" <<endl;
           return 0;
         }
      	}
        
      }
      
    }
}

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

map<int, int> input() {
    int n; cin >> n;
    map<int, int> mp;
    while (n--) {
        int a; cin >> a;
        mp[a]++;
    }
    return mp;
}

int main() {
    auto d = input(), t = input();
    for (auto &p: t) if (p.second > d[p.first]) return !(cout << "NO" << endl);
    cout << "YES" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];

ll calc(int p){
	ll ret = 1;
	for(int i = 1; i <= p; i++)
		ret = ret * 2 % MM;
	return ret;
}

void solve(int casi){
	cin>>n;
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	if (n & 1){	
		for(int i = 1; i <= n; i++){
			if (a[i] != i / 2 * 2){
				puts("0");
				return ;
			}
		}
		cout<<calc(n/2)<<endl;
	}
	else{
		for(int i = 1; i <= n; i++){
			if (a[i] != (i + 1) / 2 * 2 - 1){
				puts("0");
				return ;
			}
		}
		cout<<calc(n/2)<<endl;
	}
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




Measured memory_bytes: 640
#include <stdio.h>

#define N 2000
#define true 1
#define false 0

int solve(int,int);

int A[N],n;

int main()
{
  int i,q,m[N],k;
  

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++) scanf("%d",&m[i]);

  for(i=0;i<q;i++){
      k = solve(0,m[i]);
      if(k == false) printf("no\n");
      else if(k == true) printf("yes\n");
  }

  return 0;
}

int solve(int i,int m)
{
  int res;

  if(m == 0) return true;
  else if(i >= n) return false;
  res = solve(i + 1,m) || solve(i + 1,m - A[i]);

  return res;
}
    



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    VI x(3); VIin(x);
    SORT(x);
    OUT(x[2]*10+x[1]+x[0]);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0
#define LIM 1000000007

int main(){
	lli n,x;
	vector<lli> a;
	cin>>n>>x;
	a.resize(n);
	REP(i,n)cin>>a[i];

	lli ans=0;
	for(lli i=1;i<n;i++){
		lli sum = (a[i]+a[i-1])-x;
		if(sum>0){
			if(sum <= a[i]){
				a[i]-=sum;
				ans += sum;
			}
			else{
				ans += a[i];
				sum -= a[i];
				a[i]=0;
				a[i-1] -= sum;
				ans += sum;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
  
int main(void){
 int n,a[1000],i,j,b,c,min;
  
 while(1){
  scanf("%d",&n);
  
  if(n==0){
   break;
  }
  for(i=0;i<n;i++){
   scanf("%d",&a[i]);
  }
  for(i=0;i<n-1;i++){
   for(j=n-1;j>i;j--){
    if(a[j-1]<a[j]){
     b=a[j-1];a[j-1]=a[j];a[j]=b;
    }
   }
  }
  min=a[0];
  for(i=0;i<n-1;i++){
   c=a[i]-a[i+1];
   if(min>c){
    min=c;
   }
  }
  printf("%d\n",min);
 }
}

Measured memory_bytes: 2580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int [] ans_ar; 
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int ans = 1;
		for (int i = 0; i < 3; i++) {
			ans = ans *n;
		}

		out.println(ans);
		out.flush();
	}


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    bool ok = false;
    FOR(i, 0, s.length() - 1)ok |= s.substr(i, 2) == "AC";
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int n;
	while (cin >> n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		vector<int> b = a;
		sort(b.begin(), b.end());
		for (int i = 0; i < n; i++) {
			a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
		}
		int c = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 != i % 2) c++;
		}
		assert(c % 2 == 0);
		cout << c / 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
//3つ結合して、順にとる。透明ならストックしておく。
#include <bits/stdc++.h>
using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)

using P=pair<ll ,int>;



int main(){
  int x,y,a,b,c;
  std::cin >> x>>y>>a>>b>>c;

  std::vector<P> v;

  rep(i,a){
    ll temp;
    std::cin >> temp;
    v.push_back(P(temp,0));
  }
  rep(i,b){
    ll temp;
    std::cin >> temp;
    v.push_back(P(temp,1));
  }
  rep(i,c){
    ll temp;
    std::cin >> temp;
    v.push_back(P(temp,2));
  }
  sort(v.rbegin(),v.rend());

  // for(P p:v)std::cout <<"s:"<<p.first << '\n';

  ll ans=0;
  int nowx=x,nowy=y,stock=0;
  rep(i,v.size()){
    if(v[i].second==0){
      if(nowx>0){nowx--;ans+=v[i].first;}
    }
    if(v[i].second==1){
      if(nowy>0){nowy--;ans+=v[i].first;}
    }
    if(v[i].second==2){
      stock++;
      ans+=v[i].first;
      // std::cout <<" p"<<v[i].first << '\n';
    }
    if(nowx+nowy-stock==0)break;
  }

  std::cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 10604
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var s = ToInt64(input[0]);
        var c = ToInt64(input[1]);
        if (s >= c / 2) WriteLine(c / 2);
        else WriteLine(s + (c - 2 * s) /4);
    }
}


Measured memory_bytes: 11220
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto abc = readints;
    int a = abc[0], b = abc[1], c = abc[2];

    bool found = false;
    for (int i = 1; i <= b; i++) {
        if (a * i % b == c) {
            found = true;
            break;
        }
    }
    writeln(found ? "YES" : "NO");
}


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


int main(){
  ll X;
  cin >> X;

  ll pent[1000]={};
  for(ll i=0; i<1000; i++) pent[i] = i*i*i*i*i;


  ll plus, minus;
  for(int i=0; i<1000; i++)
    for(int j=0; j<1000; j++){
      if(pent[i] == pent[j]+X){
        cout << i << " " << j << endl;
        return 0;
      }
      if(pent[i] == X-pent[j]){
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  //cout << plus <<  " " <<minus << " "<< pent[10]<<  endl;
  return 0;
}


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



int main()
{
    string s;
    cin >> s;
    ll ans;
    if(s == "SUN") ans = 7;
    else if(s == "MON") ans = 6;
    else if(s == "TUE") ans = 5;
    else if(s == "WED") ans = 4;
    else if(s == "THU") ans = 3;
    else if(s == "FRI") ans = 2;
    else if(s == "SAT") ans = 1;
    cout << ans << endl;



}

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

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

int main() {

    ll n, a, b; cin >> n >> a >> b;

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
        return 0;
    } else {
        ll l = a - 1;
        ll r = n - b;

        if (l <= r) {
            ll t1 = b - 1;

            if (b - a <= 1) {
                cout << t1 << endl;
                return 0;
            }

            ll t2 = ((b - ((a - 1) * 2 + 1)) - a) / 2 + ((a - 1) * 2 + 1);

            cout << t2 << endl;
            return 0;
        } else {
            ll t1 = n - a;

            if (b - a <= 1) {
                cout << t1 << endl;
                return 0;
            }

            ll t2 = (b - (a + (((n - b) * 2) + 1))) / 2 + (((n - b) * 2) + 1);

            cout << t2 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double x1, y1, x2, y2, x, y;
	cin >> x1 >> y1 >> x2 >> y2;
	x = (x2 - x1)*(x2 - x1);
	y = (y2 - y1)*(y2 - y1);
	cout << fixed;
	cout << setprecision(6)<< sqrt(x + y) << endl;
	return 0;
}


Measured memory_bytes: 3236
<?php

fscanf(STDIN, "%d %d", $n, $m);
$A = [];
for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d", $a);
    $A[] = $a;
}

const MOD = 1000000007;

$broken = [];
for ($i = 0; $i < $m; ++$i) {
    $broken[$A[$i]] = 1;
}

$dp = array_fill(0, $n + 2, 0);
$dp[$n] = 1;
for ($i = $n - 1; $i >= 0; --$i) {
    if ($broken[$i]) {
        $dp[$i] = 0;
        continue;
    }

    $dp[$i] = ($dp[$i + 1] + $dp[$i + 2]) % MOD;
}

echo $dp[0], PHP_EOL;


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

int main(){
    while(1){
        int m,f,r;
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1 || m+f<30){
            cout << "F" << endl;
        }else if(m+f<50){
            if(r<50){
                cout << "D" << endl;
            }else{
                cout << "C" << endl;
            }
        }else if(m+f<65){
            cout << "C" << endl;
        }else if(m+f<80){
            cout << "B" << endl;
        }else{
            cout << "A" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3040