akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }

int main() {
  ull n, k;
  cin >> n >> k;

  ull m = pow(10, 5);
  vector<ull> r;

  cout << std::fixed << std::setprecision(10);

  //if (n < k) {
    double result = 0;
    for (ull i=0; i < n; i++) {
      ull p = (i+1);
      ull times = 0;
      while (p < k) {
        p = p * 2;
        times++;
      }

      result += (1.0/(double)n * pow(1.0/2.0, times));
    }

    cout << result << endl;
    /*
  } else {
    double result = 1;

    }*/




  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    char str[100];
    int cntc=0,cntf=0,i;
    scanf("%s",str);
    for(i = 0;1;++i)
    {
        if(str[i] == 'C'){
            cntc = i+1;
        }
        if(str[i] == 'F'){
            cntf = i+1;
        }
        if(cntc < cntf && cntf != 0 && cntc != 0){
            printf("Yes\n");
            return 0;
        }
        if(str[i] == '\0' && (cntc >= cntf || cntc == 0 || cntf == 0)){
            printf("No\n");
            return 0;
        }
    }
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int n,h,a,b,c,d;
    while(scanf("%d",&n)!=EOF){
        h=0;
        for(a=0; a<10; a++){
            for(b=0; b<10; b++){
                for(c=0; c<10; c++){
                    for(d=0; d<10; d++){
                        if((a+b+c+d)==n){
                            h++;
                        }
                    }
                }
            }
        }
        printf("%d\n",h);
    }
    return 0;
}

Measured memory_bytes: 596
N = int(input())
s = input()
l = 0
r = len(s) - 1
ans = 0
while True:
    while l < len(s) - 1 and s[l] == 'R':
        l += 1
    while r >= 0 and s[r] == 'W':
        r -= 1

    if l < r:
        ans += 1
        l += 1
        r -= 1
    else:
        break

print(ans)


Measured memory_bytes: 73212
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define FOR(i,n,a) for(int i = a;i<n;i++)
#define rep(i,n) FOR(i,n,0)
#define UNFOR(i,n,a) for(int i = a;i>n;i--)
#define unrep(i,n) UNFOR(i,0.n)
typedef long long ll;
using namespace std;

int par[100010];
int urank[100010];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
}

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

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

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

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

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

	vector<int> p(n + 10);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	init(n);

	int x, y;
	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
		unite(x, y);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (same(i, p[i])) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cstring>
#include <iostream>
#define ios ios::sync_with_stdio(false)
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long ll;
const ll maxn = 1e7 + 10;
const ll mod = 1e9 + 7;
int a, b, x[maxn], y[maxn];
int main() {
    int n;
    ll ans;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a >> b;
        x[i] = a - b;
        y[i] = a + b;
    }
    sort(x + 1, x + n + 1);
    sort(y + 1, y + n + 1);
    ans = max(x[n] - x[1], y[n] - y[1]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define fi first
#define se second
#define pii pair<int,int>

int mod=1e11+3;
int X;
int ret,ret1;
bool check(int k){
    int lim=sqrt(k);
    forinc(i,2,lim) if(k%i==0) return 0;
    return 1;
}
int pw(int a,int i){
    int b=1;
    for(;i;i>>=1,a=a*a%mod) if(i&1) b=b*a%mod;
    return b;
}
int FIND(int z){
    forinc(i,-120,120){
        if(pw(i,5)==z) return i;
    }
    return -1;
}
main(){
    cin>>X;
    forinc(A,-120,120){
       int s=pw(A,5)-X;
        if(FIND(s)!=-1){
            ret=A,ret1=FIND(s);
            break;
        }
    }
    cout<<ret<<" "<<ret1;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
//#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, y, a, b, c;
  cin >> n >> y;
  y/=1000;
  y-=n;
  bool able=0;
  for(b=0; b<=min((ll)9, y/4); b++) {
    c=y-4*b;
    if(c%9==0) {c/=9; able=1; break;}
  }
  a=n-b-c;
  if(able && a>=0) cout << c << " " << b << " " << a << newl;
  else cout << "-1 -1 -1" << newl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n,k,i,j,index,out[200001]={0},output;
    long long a[200001]={0};
    int flag=0,repeat=0;
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(i=1;i<=k;i++){
        if(i==1){
            output = a[1];
            out[i] = a[1];
            a[1] = -out[1];
            index = out[i];

        }
        else{
            output = a[index];
            out[i] = a[index];
            a[index] = -out[i];
            index = out[i];
        }
        if(output<0){
            for(j=1;j<i;j++){
                if((-out[i])==out[j]){
                    repeat = i-j;
                    flag = 1;
                    break;
                }
            }
        }
        if(flag==1){
            index = (k-j)%repeat;
            output = out[j+index];
            break;
        }
    }
    printf("%lld\n",output);
    return 0;
}


Measured memory_bytes: 4824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		System.out.println((x - z) / (y + z));
		sc.close();

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    VLL h(N);
    VLL DP(N);
    rep(i,N){   
        cin >> h[i];
    }
    rep(i,N){
        DP[i]=INF;
    }
    DP[0]=0;
    rept(i,1,N){
        DP[i]=min(DP[i],DP[i-1]+abs(h[i]-h[i-1]));
        if(i>1){
            DP[i]=min(DP[i],DP[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout << DP[N-1] << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
	private	static	BufferedReader	br = null;
	private	static	String[]		rk = {
		"AAA",
		"AA",
		"A",
		"B",
		"C",
		"D",
		"E",
		"NA"
	};

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		double[]	rec = null;

		while ((rec = parseRec()) != null) {
			int	rank = get500Rank(rec[0]);

			if (rank != 7) {
				rank = Math.max(rank, get1000Rank(rec[1])); 
			}

			System.out.println(rk[rank]);
		}
	}

	private static int get500Rank(double rec) {
		int	rank = 7;

		if (rec < 35.50) {
			rank = 0;
		}
		else if (rec < 37.50) {
			rank = 1;
		}
		else if (rec < 40.00) {
			rank = 2;
		}
		else if (rec < 43.00) {
			rank = 3;
		}
		else if (rec < 50.00) {
			rank = 4;
		}
		else if (rec < 55.00) {
			rank = 5;
		}
		else if (rec < 70.00) {
			rank = 6;
		}

		return rank;
	}

	private static int get1000Rank(double rec) {
		int	rank = 7;

		if (rec < 71.00) {
			rank = 0;
		}
		else if (rec < 77.00) {
			rank = 1;
		}
		else if (rec < 83.00) {
			rank = 2;
		}
		else if (rec < 89.00) {
			rank = 3;
		}
		else if (rec < 105.00) {
			rank = 4;
		}
		else if (rec < 116.00) {
			rank = 5;
		}
		else if (rec < 148.00) {
			rank = 6;
		}

		return rank;
	}

	private static double[] parseRec() {
		double[]	rec   = null;
		String		stdin = null;

		if ((stdin = parseStdin()) != null) {
			String[]	lines = stdin.split(" ");

			rec    = new double[2]; 
			rec[0] = Double.parseDouble(lines[0]);
			rec[1] = Double.parseDouble(lines[1]);
		}

		return rec;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 15128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,i,s;
  cin>>n;
  ll a[n+1];
  for(i=1;i<=n;i++)
    cin>>a[i];
  ll dp[n+1];
  dp[0]=0;dp[1]=0;dp[2]=abs(a[2]-a[1]);
  for(i=3;i<=n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n];
}

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

#define MAXN 200010
#define ll long long
#define mod 1000000007

using namespace std;

int n, m, k, ans = INT_MAX, tot;

string s;

int a[MAXN];

int main(){
	int t;
	scanf("%d%d", &k, &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	ans = k - a[n] + a[1];
	ans = k - ans;
	for (int i = 1; i < n; i++) {
		ans = min(ans, k - a[i + 1] + a[i]);
//		cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
#include <array>

using namespace std;

int main()
{
    map<char, array<bool,13> > in_posession = {{'S', {}}, {'H', {}}, {'C', {}}, {'D', {}}};
    int n;

    scanf("%d\n", &n);
    for (int i = 0; i < n; i++) {
        char suit;
        int rank;

        scanf("%c %d\n", &suit, &rank);
        in_posession[suit][rank-1] = true;
    }

    for (char suit : { 'S', 'H', 'C', 'D' })
        for (int i = 0; i < 13; i++)
            if (!in_posession[suit][i])
                cout << suit << ' ' << i+1 << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define d first
#define t second
using namespace std;typedef long l;l N,K,i,n,p,s,u[1<<17];vector<pair<l,l>>v;priority_queue<l,vector<l>,greater<l>>q;
main(){cin>>N>>K;v.resize(N);for(i=0;i<N;i++)cin>>v[i].t>>v[i].d;sort(v.rbegin(),v.rend());for(i=0;i<K;i++){s+=v[i].d;if(u[v[i].t])q.push(v[i].d);else u[v[i].t]=1,n++;}p=s+n*n;for(i=K;i<N;i++){if(!u[v[i].t]){if(!q.size())break;u[v[i].t]=1;s+=v[i].d;s-=q.top();q.pop();p=max(p,s+(++n)*n);}}cout<<p<<endl;}


Measured memory_bytes: 3196
from __future__ import absolute_import, print_function, unicode_literals
import sys

def judge(a, b, c):
    print('YES' if (a == b + c or b == c + a or c == a + b) else 'NO')

sys.stdin.readline()
for line in sys.stdin:
    judge(*(int(n) ** 2 for n in line.split()))

Measured memory_bytes: 4304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

int dp[1<<26];
void solve() {
  string s;
  cin >> s;
  for(int i = 1; i < (1<<26); i++) dp[i] = 1 << 25;
  int curr = 0;
  for(int i = 0; i < s.size(); i++) {
    curr ^= 1 << (s[i] - 'a');
    for(int x = 0; x < 26; x++) {
      dp[curr] = min(dp[curr], 1 + dp[curr ^ (1<<x)]);
    }
  }
  cout << max(1, dp[curr]) << "\n";
}

void casesolve() {
  int t;
  cin >> t; cin.ignore();
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 262736
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

double ans=0;
int n;
int main(){
	cin>>n;
	REP(i,n){
		double a;
		cin>>a;
		ans+=(1/a);
	}
	printf("%.15f",1/ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,M;
long K,A[2<<17],B[2<<17];
main()
{
	cin>>N>>M>>K;
	long S=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		S+=A[i];
	}
	for(int i=0;i<M;i++)cin>>B[i];
	int ans=0;
	int j=0;
	for(int i=N;i>=0;i--)
	{
		if(i<N)S-=A[i];
		while(j<M&&S+B[j]<=K)
		{
			S+=B[j++];
		}
		if(S<=K)ans=max(ans,j+i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6720
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

w, h, x, y = rm()
print(w*h/2, 1 if x == w/2 and y == h/2 else 0)


Measured memory_bytes: 27080
#include<bits/stdc++.h>
using namespace std;
int main()

{
	int m,n,k,sum=0;
	cin>>n >>m;
	vector<int>p;
	for(int i=0; i<m;i++)
	{
		cin>>k;
		p.push_back(k);
	}
	for(int i=0;i<m;i++)
	{
		sum+=p.back();
		p.pop_back();
	}
	if(n>=sum)
	cout<<n-sum;
	else
	cout<<"-1";
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
int n,x,l[200];
int i;
int now=0;
int bou=1;
scanf("%d %d",&n,&x);
for(i=1;i<=n;i++){
scanf("%d",&l[i]);
}
for(i=1;i<=n;i++){
now=now+l[i];
if(now<=x){bou++;}
  else{break;}
}
printf("%d",bou);
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> elevations;
    vector<bool> hill(n,true);
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        elevations.push_back(h);
    }
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (elevations[a-1] <= elevations[b-1]) {
            hill[a-1] = false;
        }
        if (elevations[b-1] <= elevations[a-1]) {
            hill[b-1] = false;
        }
    }
    int peaks = 0;
    for (int i = 0; i < n; i++) {
        if (hill[i] == true) {
            peaks += 1;
        }
    }
    cout << peaks;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res=0;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;
	f(i,0,n-1) cin>>ara[i];

	m=n/2;

	f(i,0,n-1){
        count+=(ara[i]%4==0);
        res+=(ara[i]%2==0);
	}

	(count+((res-count)/2)>=m && (count>0 || res==n))?cout<<"Yes"<<endl:cout<<"No"<<endl;

}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
signed main(){
	cin >> N;
	cout << (N+1)/2 << endl;
}

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

namespace RacconVSMonster
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var attackInput = Console.ReadLine().Split(' ');
            int monsterNumber = int.Parse(input[0]);
            int specialAttack = int.Parse(input[1]);

            List<long> monsterPower = new List<long>();
            for (int i = 0; i < monsterNumber; i++)
            {
                monsterPower.Add(long.Parse(attackInput[i]));
            }

            monsterPower.Sort();
            monsterPower.Reverse();

            int[] afterSpecialMove = new int[monsterNumber];
            long attackPower = 0;
            if (specialAttack >= monsterNumber)
            {
                for (int i = 0; i < monsterNumber; i++)
                {
                    afterSpecialMove[i] = 0;
                }
                attackPower = afterSpecialMove.Sum();
            }
            else
            {
                for (int i = 0; i < specialAttack; i++)
                {
                    monsterPower[i] = 0;                    
                }
                attackPower = monsterPower.Sum();
            }

            
            Console.WriteLine(attackPower);
        }
    }
}

Measured memory_bytes: 36992
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int now=1;
	int cnt=0; 
	for(int i=1;i<=n;i++){
		if(a[i]==now){
			cnt++;
			now++;
		}
	}
	if(cnt==0){
		cout<<"-1";
		return 0;
	}
	cout<<n-cnt;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
 
using namespace std;

int main(){
int A,B,C,D;
  
  
  cin >>A >> B >> C >> D;

if(A * B < C * D){
cout << C*D<<endl;}else{
cout <<A*B<<endl;}

  
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

ll par[1028];
int rank[1028];

void init(int n)
{
	for(int i = 0; i < n; i++)
	{
		par[i] = i;
		rank[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;
	}
	else
	{
		if(rank[x] < rank[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if(rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}
}

int main()
{
	int V, d;
	ll F[1028];
	while(cin >> V >> d)
	{
		init(V+1);

		F[0] = 1; F[1] = 2;
		for(int i = 2; i <= V; i++)
		{
			F[i] = F[i-1] + F[i-2];
			F[i] %= 1001;
		}
		/*
		for(int i = 0; i <= V; i++)
		{
			printf("%d %d\n",i ,F[i]);
		}
		*/
		
		for(int i = 1; i <= V; i++)
		{
			for(int j = i+1; j <= V; j++)
			{
				if(	abs(F[i]-F[j]) < d )
				{				
					//printf("%d:%d %d:%d\n",i ,F[i] ,j ,F[j] );
					unite(i, j);
				}
			}
		}

		int ans = 0;
		for(int i = 1; i <= V; i++)
		{
			//cout << F[i] << endl;
			if(par[i] == i)
			{
				ans++;
			}
		}

		cout << ans << endl;
	}
}

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

int main() {
	int x, a, b; cin >> x >> a >> b;
	if(b - a <= 0) {
		cout << "delicious" << endl;
	} else if(x >= b - a) {
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>
#include<iomanip>

using namespace std;

long Lcm(long, long);
long Gcd(long, long);

int main(){
    long N,K;
    cin >> N >> K;
    vector<long> denomList; //確率の分母を保存

    //出た目の場合ごとに回す
    for(int i=1; i<=N; i++)
    {
        long denom = N;  //確率の分母
        long x = i;
        while(x<K)
        {
            denom *= 2;
            x *= 2;
        }
        denomList.emplace_back(denom);
    }
    //それぞれの確率から出力する確率を計算する
    long lcm = 1;
    for(int i=0; i<denomList.size(); i++)
    {
        lcm = Lcm(lcm, denomList[i]);
    }

    long mol = 0;

    for(int i=0; i<denomList.size(); i++)
    {
        mol += (lcm/denomList[i]);
    } 

    long double output = 0.0000000000;
    output = static_cast<long double>(mol) / static_cast<long double>(lcm);

    cout << fixed << setprecision(10) << output << endl;
}

//2数の最大公約数を見つける
long Gcd(long a, long b)
{
    if(a < b)
    {
        return Gcd(b, a);
    }
    else if(b > 0)
    {
        return Gcd(b, a % b);
    }
    else
    {
        return a;
    }
}

//2数の最小公倍数を見つける
long Lcm(long a, long b)
{
    return a / Gcd(a, b) * b;
}

Measured memory_bytes: 1400
#include<cstdio>

int main(void)
{
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    int a = (h>w)?h:w;
    int b = n/a;
    if(b*a != n) ++b;
    printf("%d\n",b);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
#endif
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int x, y;
   cin >> x >> y;
   for(int i=1;i<=x;i++)
   {
      int a=x-i;
      if(a*2+i*4==y || a*4+i*2==y)
      {
         cout<<"Yes";
         return 0;
      }
   }
   cout<<"No";
   return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if ((i + 1) % 2 == 1) {
                sb.append(s.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23764
n = int(input())
count = 0
flag = False
while count < n:
  a, b = map(int, input().split())
  count += 1
  if a == b and count < n:
    a, b = map(int, input().split())
    count += 1
    if a == b and count < n:
      a, b = map(int, input().split())
      count += 1
      if a == b and count <= n:
        flag = True
        print("Yes")
        break

if flag == False:
  print("No")
 

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint a, b, n;
bool used[4005];
llint ans[4005];
vector<llint> vec;

llint qcnt;
llint query(llint a, llint b)
{
	if(qcnt++ >= 2*n) while(1);
	cout << "? " << a << " " << b << endl;
	char res;
	cin >> res;
	return (res=='Y')?1:0;
}

llint get(void)
{
	for(int i = 0; i < n; i++){
		if(!used[i]){
			used[i] = true;
			return i;
		}
	}
	return -1;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	if(a <= b){
		cout << "Impossible" << endl;
		return 0;
	}
	n = a+b;
	
	llint goal = b+1, res;
	while(vec.size() < goal){
		if(vec.size() == 0) vec.push_back(get());
		llint x = get();
		if(x == -1) break;
		res = query(vec.back(), x);
		if(res == 1) vec.push_back(x);
		else vec.pop_back(), goal--;
	}
	llint x = vec.back();
	for(int i = 0; i < n; i++) ans[i] = query(x, i);
	
	cout << "! ";
	for(int i = 0; i < n; i++) cout << ans[i];
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;

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

  int n;
  cin >> n;

  ll ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int i,j,k;
  int a[2][n];
  for(i=0;i<2;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
    }
  }
  int pt[n],ans;
  for(i=0;i<n;i++){
    pt[i]=0;
    for(j=0;j<n;j++){
      if(j<=i){
        pt[i]+=a[0][j];
      }
      if(j>=i){
        pt[i]+=a[1][j];
      }
    }
  }
  ans=pt[0];
  for(i=1;i<n;i++){
    if(ans<pt[i]){
      ans=pt[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	const int MAX_N = 100000;
	ll a[MAX_N];
	ll dp[MAX_N][2] = {};
	rep(i,0,MAX_N) rep(j,0,2) dp[i][j] = 0;
	int n;
	cin >> n;
	rep(i,0,n) cin >> a[i];
	dp[0][0] = a[0];
	dp[0][1] = a[0] * -1;
	//cout << dp[0][0] << " " << dp[0][1] << endl;
	rep(i,1,n-1){
		dp[i][0] += max( dp[i-1][0] + a[i] , dp[i-1][1] + a[i] * -1 );
		dp[i][1] += max( dp[i-1][0] + a[i] * -1 , dp[i-1][1] + a[i] );
		//cout << dp[i][0] << " " << dp[i][1] << endl;
	}

	dp[n-1][0] = dp[n-2][0] + a[n-1];
	dp[n-1][1] = dp[n-2][1] + a[n-1] * -1;
	//cout << dp[n-1][0] << " " << dp[n-1][1] << endl;
	cout << max( dp[n-1][1] , dp[n-1][0] ) << endl;

	ret 0;
}

Measured memory_bytes: 2560
N = gets.to_i
a_list = gets.split.map(&:to_i)
table = Hash.new { 0 }
a_list.each do |a|
  table[a] += 1
end
sorted = table.sort_by { |k, v| -k }.select { |k, v| v >= 2 }
if sorted.size == 0
  puts '0'
elsif sorted.size == 1
  ans = if sorted[0][1] < 4
    0
  else
    sorted[0][0] * sorted[0][0]
  end
  puts ans
else
  ans = if sorted[0][1] >= 4
    sorted[0][0] * sorted[0][0]
  else
    sorted[0][0] * sorted[1][0]
  end
  puts ans
end


Measured memory_bytes: 22280
#include<iostream>

using namespace std;

void StartingAScenicRailroadService(const int board[], const int alight[], const int n) {
	static int geton[100001], getoff[100001], order[200000];
	int policy1 = 0, policy2 = 0;
	for (int s = 1;s <= 100000;s++)geton[s] = getoff[s] = 0;
	for (int i = 0;i < n;i++)++geton[board[i]], ++getoff[alight[i]];
	for (int s = 1;s < 100000;s++)geton[s + 1] += geton[s], getoff[s + 1] += getoff[s];
	for (int i = 0;i < n;i++)order[--geton[board[i]]] = i;
	for (int k = 0;k < n;k++) {
		int a = alight[order[k]], b = board[order[k]];
		if (geton[a] - getoff[b] > policy1)policy1 = geton[a] - getoff[b];
		if (geton[b + 1] - getoff[b] > policy2)policy2 = geton[b + 1] - getoff[b];
	}
	cout << policy1 << ' ' << policy2 << endl;
}

int main() {
	static int board[200000], alight[200000];
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> board[i] >> alight[i];
	StartingAScenicRailroadService(board, alight, n);
}


Measured memory_bytes: 6216
N=int(input())
H=map(int,input().split())
H=list(H)
x=0
xmax=0
for i in range(1,N):
    if H[i-1]>=H[i]:
        x+=1
    else:
        xmax=max(x,xmax)
        x=0
xmax=max(x,xmax)
print(xmax)

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

signed main() {
  int N;
  cin >> N;
  
  string alfa = "abcdefghijklmnopqrstuvwxyz";
  string S;
  
  vector<int> kazu(26, 100); //最小で何回出てきたか
  int a = 0;
  for( int i = 0; i < N; i++ ){
    cin >> S;
    for( int i = 0; i < 26; i++ ){
      a = count(S.begin(), S.end(), alfa.at(i));
      kazu.at(i) = min(kazu.at(i), a);
    }
  }
  
  string ans;
  for( int i = 0; i < 26; i++ ){
    for( int j = 0; j < kazu.at(i); j++ ){
      ans += alfa.at(i);
    }
  }
  cout << ans << endl;
  
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 305, mod = 998244353;

inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
int dp[N][N];
int dp2[N][N];
void getdp2(){
	for(int k = 0; k < N; k++){
		dp2[0][k] = dp[0][k];
		for(int r = 1; r < N; r++) dp2[r][k] = add(dp2[r - 1][k], dp[r][k]);
	}
	// trace(dp2[1][0], dp[1][0]);
}

int main(){
	int K;
	string s; cin >> s >> K;
	vector<int> y;
	int n = s.length();
	int old= -1;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == '0'){
			y.push_back(i - old - 1);
			old = i;
		}
	}
	y.push_back(n - old - 1);
	if(sz(y) == 1){
		cout << 1 << endl;
		return 0;
	}
	// trace(y);
	dp[0][0] = 1;
	int sm = 0;
	for(int i = 0; i < sz(y); i++){
		getdp2();
		int num = y[i];
		sm += num;
		for(int j = n; j >= 0; j--) for(int k = n; k >= 0; k--){
			if(j < sm){
				dp[j][k] = 0;
				continue;
			}
			if(i == 2 && j == 2 && k == 0){
				// trace(j, num, dp[j - num][k]);
			}
			dp[j][k] = j < num ? 0 : dp2[j - num][k];
			for(int h = 0; h < num; h++){
				if(k + h - num >= 0)
					dp[j][k] = add(dp[j][k], dp[j - h][k + h - num]);
			}
		}
		// trace(i, sm, dp[sm][0]);
	}
	int ret = 0;
	for(int i = 0; i <= min(n, K); i++) ret = add(ret, dp[sm][i]);
	cout << ret << endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	// your code goes here
	string S;
	cin >>S;
	int flag =0;
	for(int i=0; i<S.length()-1;i++){
		if(S[i]=='A' && S[i+1]=='C'){flag=1;}
	}
	if(flag==1)cout <<"Yes" << endl;
	else cout<< "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

const int MAX = 16;
 
int n,m;
int r,c,size,angle;
int field[MAX][MAX];
int tmp[MAX][MAX];  
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
bool flg;
 
void print(){
    for(int i = 0 ;i < n ; i++){
	for(int j = 0 ; j < n ; j++){
	    if(!j) cout << field[i][j];
	    else cout << " " << field[i][j];
	}
	cout << endl;
    }
}
 
void rt(){
    for(int i = 0 ; i < size ; i++){
	for(int j = 0 ; j < size ; j++){
	    tmp[r+i-1][c+j-1] = field[r+size-j-2][c+i-1]; 
	}
    }
 
    for(int i = 0 ; i < size ; i++){
	for(int j = 0 ; j < size ; j++){
	    field[r+i-1][c+j-1] = tmp[r+i-1][c+j-1];
	}
    }
}
 
void rot(){
    if(angle == 0 || angle == 360) return;  
   
    int cnt;
 
    if(angle == 90) cnt = 1;
    else if(angle == 180) cnt = 2;
    else cnt = 3;
 
    for(int i = 0 ; i < cnt ; i++){
	memset(tmp,0,sizeof(tmp));
	rt();
    }
}
 
void rev(){
    for(int i = r-1 ; i < r+size-1 ; i++){
	for(int j = c-1 ; j < c+size-1 ; j++){
	    field[i][j] = abs(field[i][j]-1);
	}
    }
}
 
void ls(){
    int tmp = field[r-1][0];
    for(int i = 0 ; i < n-1 ; i++){
	field[r-1][i] = field[r-1][i+1];
    }
    field[r-1][n-1] = tmp;
}
 
void rs(){
    int tmp = field[r-1][n-1];
    for(int i = n-1 ; i >= 1 ; i--){
	field[r-1][i] = field[r-1][i-1];
    }
    field[r-1][0] = tmp;
}
 
void irev(int x,int y){
    if(0 <= x && x < n && 0 <= y && y < n){
	if(flg){
	    field[x][y] = 0;
	    for(int i = 0 ; i < 4 ; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0 <= nx && nx < n && 0 <= ny && ny < n
		   && field[nx][ny]) irev(nx,ny);
	    }
	}
	else{
	    field[x][y] = 1;
	    for(int i = 0 ; i < 4 ; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0 <= nx && nx < n && 0 <= ny && ny < n
		   && !field[nx][ny]) irev(nx,ny);
	    }
	}
    }
}
 
int main(){
    cin >> n >> m;
    for(int i = 0 ; i < n ; i++)
	for(int j = 0 ; j < n ; j++)
	    cin >> field[i][j];
 
    while(m--){
	int o;
	cin >> o;
	switch(o){
	case 0:
	    cin >> r >> c >> size >> angle;
	    rot();
	    break;
	case 1:
	    cin >> r >> c >> size;
	    rev();
	    break;
	case 2:
	    cin >> r;
	    ls();
	    break;
	case 3:
	    cin >> r;
	    rs();
	    break;
	case 4:
	    cin >> r >> c;
	    if(field[r-1][c-1]) flg = true;
	    else flg = false;
	    irev(r-1,c-1);
	    break;
	}
    }
    print();
    return 0;
}

Measured memory_bytes: 3120
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    char c; cin >> c;
    if (c == 'a' || c == 'i' ||c == 'u' ||c == 'e' ||c == 'o' ) {
        print("vowel");
    } else {
        print("consonant");
    }
}

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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<ll,ll> pll ;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------


const int MAX_V = 300 ;

int d[MAX_V][MAX_V] ;
int n ;

void war(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        d[i][j] = min(d[i][j],d[i][k] + d[k][j]) ;
      }
    }
  }
}






//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m, r ;
  cin >> n >> m >> r ;
  vint num(r) ;
  REP(i,r){
    int a ;
    cin >> a ;
    num[i] = a-1 ;
  }
  
  REP(i,n){
    REP(j,n){
      d[i][j] = INF ;
    }
  }
  REP(i,n){
    d[i][i] = 0 ;
  }
  
  REP(i,m){
    int b, c, e ;
    cin >> b >> c >> e ;
    d[b-1][c-1] = e ;
    d[c-1][b-1] = e ;
  }
  
  war() ;
  
  sort(ALL(num)) ;
  
  ll ans = INF ;
  
  do{
    ll tmp = 0 ;
    REP(i,r-1){
      tmp += d[num[i]][num[i+1]] ;
    }
    ans = min(tmp,ans) ;
  }
  while(next_permutation(ALL(num))) ;
  
  cout << ans <<endl ;
    
  
  
  return 0 ;
}



Measured memory_bytes: 512
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
if m<=n:
    print(0)
else:
    dif = []
    for i in range(m-1):
        dif.append(x[i+1]-x[i])
    dif = sorted(dif)
    print(sum(dif[:m-n]))

Measured memory_bytes: 58408
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >>a>>b>>c;
    if(c>=a&&c<=b)printa("Yes");
    else printa("No");
    return 0;
}

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

typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    ll a;
    ll v= 1;
    ll lim = 1e18;
    bool invalid = false, hasZero = false;
    for(int i=0;i<n;i++) {
        scanf("%lld",&a);
        ll nv = v* a;
        if(a==0) {
            hasZero = true;
        }
        if(nv>lim || nv<v) {
            invalid = true;
        }
        v = nv;
    }
    if(hasZero) cout << 0 << endl;
    else if(invalid) cout << -1 << endl;
    else cout << v << endl;
}


Measured memory_bytes: 3764
n, k, q = map(int, input().split())
a = []
for i in range(q):
    ai = int(input())
    a.append(ai)

points = [0] * n
for i in range(q):
    points[a[i]-1] += 1

for i in range(n):
    if k - (q - points[i]) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll x, y;
  cin >> x >> y;
  ll n = x + y;
  if(n % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (-x + 2 * y) / 3;
  combination c(3e6);
  cout << c(a + b, min(a, b)) << endl;
}

Measured memory_bytes: 47104
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var nStr string
	fmt.Scan(&nStr)

	n, _ := strconv.Atoi(nStr)
	l := len(nStr)

	if l == 1 {
		fmt.Println(n)
	} else if l == 2 {
		fmt.Println(9)
	} else if l == 3 {
		fmt.Println(n - 99 + 9)
	} else if l == 4 {
		fmt.Println((999 - 99) + 9)
	} else if l == 5 {
		fmt.Println(n - 9999 + (999 - 99) + 9)
	} else if l == 6 {
		fmt.Println((99999 - 9999) + (999 - 99) + 9)
	}

}


Measured memory_bytes: 512