akhauriyash/Code-Regression huggingface dataset:
let rec read n = 
  if n <= 0 then [] 
  else let x = read_line () in 
       List.map int_of_string (Str.split (Str.regexp "") x) :: read (n - 1)

let rec split = function
  | [] -> ([], [])
  | [] :: rest -> split rest
  | (hd :: tl) :: rest -> 
     let (hr, tr) = split rest in
     (hd :: hr, tl :: tr)

let rec transpose mx = 
  match split mx with
  | ([],_) | (_,[])-> []
  | (hd,tl) -> hd :: transpose tl

let figure = function
  | [[1;1];[1;1]] -> "A"
  | [[1;1;1;1]] -> "B"
  | [[1];[1];[1];[1]] -> "C"
  | [[0;1;1];[1;1;0]] -> "D"
  | [[1;0];[1;1];[0;1]] -> "E"
  | [[1;1;0];[0;1;1]] -> "F"
  | [[0;1];[1;1];[1;0]] -> "G"
  | _ -> "H"

let _ = 
  try 
    while true do
      let lst = read 8 in
      let lst1 = List.filter (fun x -> List.fold_left (+) 0 x <> 0) lst in
      let lst2 = List.filter (fun x -> List.fold_left (+) 0 x <> 0) (transpose lst1) in
      print_endline (figure lst2);
      ignore (read_line ())
    done
  with
    End_of_file -> ()

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

long p[100000]={};

int main(){
  long N, K, Q;
  cin >> N >> K >> Q;
  for(long i=0; i<Q; i++){
    int A; cin >> A;
    p[A-1]++;
  }
  for(long i=0; i<N; i++){
    if(K-Q+p[i]>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main() {
    while (1) {
        int min = 1000000;
        int e; cin >> e;
        if (e == 0) break;
        for (int z = 0; z * z * z <= e; ++z) {
            for (int y = 0; y * y <= e; ++y) {
                int x = e - y * y - z * z * z;
                if (0 <= x && x <= e) {
                    if (min > x + y + z) {
                        //cout << x << " " << y << " " << z << endl;
                        min = x + y + z;
                    }
                }
            }
        }
        cout << min << endl;
    }
    return 0;
}



Measured memory_bytes: 2988
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<string>
#include<queue>
#include<deque>
#define INF 0x3f3f3f3f
using namespace std;
int main(){
	char s[20];
	while(cin>>s){
		char* p;
		p=s;
		for(int i=1;i<3;i++){
			if(i%2==1){
				p+=5;
				*p=' ';
			}
			if(i%2==0){
				p+=8;
				*p=' ';
			}	
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//typedef int64_t int;
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define pb push_back
#define mk make_pair
#define endl "\n"
#define int int64_t
#define ll long long
#define in(num,n) std::vector<int> num(n); for (int i = 0; i < n; i++)cin >> num[i]
const ll Inf = 1e9 + 7;
std::vector<int> num;
std::vector<int> vis(1e5 + 1, -1);
int DP(int i) {
    if (vis[i] != -1)
        return vis[i];
    if (i == num.size() - 2) {
        return abs(num[i] - num[i + 1]);
    }

    if (i == num.size() - 1)
        return 0;


    int x = DP(i + 1) + abs(num[i + 1] - num[i]);
    int y = DP(i + 2) + abs(num[i + 2] - num[i]);
    return vis[i] = min(x, y);
}



void solve() {

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        num.push_back(x);
    }
    cout << DP(0) << endl;



}


int32_t main()
{
    fastio;
    precise;

    //int test; cin >> test; while (test--)
    solve();
    return 0;
}

Measured memory_bytes: 7964
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	if (n % 2 == 0)
		cout << "0.5000000";
	else if (n == 1)
	{
		cout << "1.00000000";
	}
	else
	{
		n = (double)n;
		double ans = (double)(n+1.000000) / (2.0000*n);
		cout << setprecision(8)<<ans;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	ll a;string bb;
	cin >> a >> bb;
	ll b = 100*(bb[0]-'0')+10*(bb[2]-'0')+bb[3]-'0';
	cout << (a*b)/100 << '\n';
}


Measured memory_bytes: 3648
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B;
    cin >> A >> B;
    cout << A * B - A - B + 1 << endl;

    return 0;
}


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

int main(){
    int N, i, j, k;
    int ans;
    int len;
    int lenall;
    char S[210000];
    char tmp[2];

    scanf("%s", &S);
    lenall = strlen(S);
    len = 1;
    ans = 0;

    //printf("%d\n", lenall);

    for(i=0; i<lenall; i++){
        if(len == 1){
            if(S[i]!=S[i+1]){
                ans++;
            }else{
                ans++;
                i++;
                len=2;
            }
        }else{
            ans++;
            len=1;
        }
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 384
from itertools import product

abcd = input()

pn = ["+","-",""]
for aa,bb,cc in product(pn,repeat=3):
    res = abcd[0]+aa+abcd[1]+bb+abcd[2]+cc+abcd[3]
    if eval(res) == 7:
        print(res+"=7")
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main(){
   int n,ans=0;
   cin >> n;
   vector<int> d(n);
   rep(i,n) cin >> d[i];
   rep(i,n-1){
       rep1(j,i+1,n){
           ans+=d[i]*d[j];
       }
   }
   cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <list>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>


using namespace std;

int main(){
    int N;
    cin >> N;
    /*
    vector<double> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    */
    double ans = 0, temp = 0;
    for(int i = 0; i < N; ++i){
        cin >> temp;
        ans += 1.0 / temp;
    }

    ans = 1.0 / ans;

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

const int MAX_N = 5e5;
int bit[26][MAX_N + 1], n, q;

int sum(int i, int j) {
    int s = 0;
    while (i > 0) {
        s += bit[j][i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int j, int x) {
    while (i <= n) {
        bit[j][i] += x;
        i += i & -i;
    }
}

int que[20000][3];
char s[500001];

int main() {
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 1; i <= n; i++) add(i, s[i - 1] - 'a', 1);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int m;
        scanf("%d", &m);
        que[i][0] = m; 
        if (m == 1) {
            int j; char c;
            scanf("%d %c", &j, &c);
            que[i][1] = j; 
            que[i][2] = c; 
        }
        else {
            int l, r;
            scanf("%d %d", &l, &r);
            que[i][1] = l; 
            que[i][2] = r; 
        }
    }
    for (int i = 0; i < q; i++) {
        if (que[i][0] == 1) {
            if (s[que[i][1] - 1] != que[i][2]) {
                add(que[i][1], s[que[i][1] - 1] - 'a', -1);
                add(que[i][1], que[i][2] - 'a', 1);
                s[que[i][1] - 1] = que[i][2];
            }
        }
        else {
            int ans = 0;
            for (int j = 0; j < 26; j++) {
                int res = sum(que[i][2], j) - sum(que[i][1] - 1, j);
                if (res > 0) ans++;
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}


Measured memory_bytes: 51712
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int n, k;
vector<int> vh;

void input() {
	cin >> n >> k;
	for(int i = 0; i < n; i++){
	    int h;
	    cin >> h;
	    vh.push_back(h);
	}
}

int calculate(){
    int minD = vh.at(n - 1) - vh.at(0);
    for(int i = 0; i < n - k + 1; i++){
        minD = min(minD, vh.at(i + k - 1) - vh.at(i));
    }
    return minD;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	input();
 
	sort(vh.begin(), vh.end());
	
	cout << calculate() << "\n";
 
	return 0;
}


Measured memory_bytes: 892
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

int main() {
  ll N, K;
  cin >> N >> K;
  unordered_map<ll, bool> m;
  rep(k, K) {
    ll d;
    cin >> d;
    rep(i, d) {
      ll s;
      cin >> s;
      m.emplace(s, true);
    }
  }
  ll ans = 0;
  rep1(i, N) if (!m[i]) ans += 1;
  ANS(ans);
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	int n,k;
	cin>>n>>k;
	
	int p[n];
	double d[n];
	
	forr(i,0,n){
		cin>>p[i];
		ll int an=(p[i]*(p[i]+1))/2;
		
		d[i]=(float)(an)/p[i];
	}
	
	double ans=0;
	double sum[n+1];
	sum[0]=0;
	
	for(int i=0;i<n;i++)
	sum[i+1]=sum[i]+d[i];
	
	for(int i=0;i<n-k+1;i++)
	ans=max(ans,sum[i+k]-sum[i]);
	
	cout<<setprecision(12)<<fixed<<ans;
	return 0;
}


Measured memory_bytes: 4224
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int N;
    string s;
    int l[200010] {};
    int r[200010] {};

    cin >> N >> s;
    if (s[0] == '#') ++l[0];

    for (int i = 1; i < N; ++i) {
        l[i] = l[i-1];
        if (s[i] == '#') ++l[i];
    }
    for (int i = N-1; i >= 0; --i) {
        r[i] = r[i+1];
        if (s[i] == '.') ++r[i];
    }

    i64 ans = r[0];
    for (int i = 0; i < N; ++i) {
        chmin(ans, l[i] + r[i+1]);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2180
#include<stdio.h>
int main(void)
{
	int H=1,W=1,i,j;
	while((H!=0)||(W!=0))
	{
		scanf("%d%d",&H,&W);
		if((H!=0)||(W!=0))
		{
			for(i=0;i<H;i++)
			{
				for(j=0;j<W;j++)
				{
					if(i%2==0)
					{
						if(j%2==0)
						{
							printf("#");
						}
						else
						{
							printf(".");
						}
					}
					else
					{
						if(j%2==0)
						{
							printf(".");
						}
						else
						{
							printf("#");
						}
					}
					
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2044
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    long long N; cin >> N;

    string s;
    while (N) {
        N--;
        s += 'a' + N % 26;
        N /= 26;
    }

    reverse(s.begin(), s.end());

    cout << s << endl;
}


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

Measured memory_bytes: 3616
#include <bits/stdc++.h>  
#define lli long long 
using namespace std; 
long long mod2=1e9+7,mod=998244353;
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }

int main() 
{ 
    // fact[0]=1;
    // for(int i=1;i<=2000005;i++)fact[i]=(i*fact[i-1])%mod;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        int n;cin>>n;
        int x[n],y[n];
        for(int i=0;i<n;i++){
            // int x,y;cin>>
            cin>>x[i]>>y[i];
        }
        int ans=0;
        for(int i=2;i<n;i++){
            if(x[i]==y[i] && x[i-1]==y[i-1] && x[i-2]==y[i-2])ans=1;
        }
        if(ans)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0; 
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>
const int N=1e3+10;

const int M = ((int)1e9 + 7);

string s;

double dis(int x1,int y1,int x2,int y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

vector<pi>v;
vector<int>ans;

signed main(){
   fast;
   int n;
   cin>>n;
   int a,b;
   for(int i=0;i<n;i++){
   		cin>>a>>b;
   		v.pb({a,b});
   		ans.pb(i+1);

   }
   double an=0;

   int cnt=0;
   do{
   		cnt++;
   		for(int j=1;j<ans.size();j++){
   			an+=dis(v[ans[j]-1].first,v[ans[j]-1].second,v[ans[j-1]-1].first,v[ans[j-1]-1].second);

   		}



   }
  while (next_permutation(ans.begin(), ans.end()));

	// for(int j=1;j<ans.size();j++){
 //   			an+=dis(v[ans[j]].first,v[ans[j]].second,v[ans[j-1]].first,v[ans[j-1]].second);

 //   		}
 // cout<<cnt<<" ";


	an = an/(cnt);

	printf("%.10f",an );

  	
   
   
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int n,k;
    
    cin >> n >> k;
    
    if (n%k == 0){
    
    cout << 0 << endl;
    
    }else{
    
    cout << 1 << endl;
    
    }
    
    
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

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

    int cnt = 0;
    int dcnt = 0;
    for(int i = 1; i <= n; i++){
        if(p[i] == i && p[i + 1] == i + 1){
            dcnt++;
            i++;
        } else if(p[i] == i){
            cnt++;
        }
    }

    cout << cnt + dcnt << endl;
}

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

int main(void) {
	int X, A, B;

	cin >> X >> A >> B;

	if (A - B >= 0) {
		cout << "delicious" << endl;
	}
	else if (X + A - B >= 0) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
priority_queue<int> PQ;
int a[2005], rd[2005];
struct graph {
	set<int> S[2005], E[2005];
	int vs[2005];
	void push(int x, int y) {
		S[x].insert(y);
	}
	void dfs(int nw) {
		vs[nw] = 1;
		auto IT = S[nw].begin();
		while(IT != S[nw].end()) {
			if(vs[*IT]) {++IT; continue;}
			++rd[*IT];
			E[nw].insert(*IT);
			dfs(*IT);
			++IT;
		}
	}
	void tuopu() {
		PQ.push(0);
		while(PQ.size()) {
			int nw = PQ.top();
			if(nw) printf("%d ", a[nw]);
			PQ.pop();
			auto IT = E[nw].begin();
			while(IT != E[nw].end()) {
				--rd[*IT];
				if(rd[*IT] == 0) PQ.push(*IT);
				++IT;
			}
		}
	}
}G;
int n;
int main() {
	scanf("%d", &n);

	rep(i, 1, n) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
	rep(i, 1, n) rep(j, 1, n) if(i != j && __gcd(a[i], a[j]) != 1) G.push(i, j); 
	rep(i, 1, n) G.push(0, i), G.push(i, 0);
	G.dfs(0);
	G.tuopu();
	return 0;
}

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

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> b(4);
    for (int i = 0; i < n; i++)
    {
        if(a[i]=="AC") b[0]+=1;
        if(a[i]=="WA") b[1]+=1;
        if(a[i]=="TLE") b[2]+=1;
        if(a[i]=="RE") b[3]+=1;
    }
    cout << "AC x " << b[0] << endl;
    cout << "WA x " << b[1] << endl;
    cout << "TLE x " << b[2] << endl;
    cout << "RE x " << b[3] ;
    
}

Measured memory_bytes: 6364
#include <iostream>
using namespace std;
//B - Cakes and Donuts
int main(void){
    int n;
    std::cin >> n;
    for (int i = n/7; i >=0 ; i--) {
        for (int j = 0; j <= n/4; j++) {
            if(i*7+j*4==n){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

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

int main(){
  int X;
  cin>>X;
  
  int ans=0;
  for (int i=1;i<33;i++){
    for (int j=2;j<10;j++){
      int n=pow(i,j);
      if (n<=X && ans<n){
        ans=n;
      }
    }
  }
  cout<<ans<<endl;
}
      


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N = ni()
A = nl()
L = 10 ** 18


def solve():
    ans = 1
    for a in A:
        if a == 0:
            ans = 0
            break
        if ans > 0:
            ans *= a
        if ans > L:
            ans = -1
    return ans


print(solve())


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

typedef long long ll;

static const int MAX=310;
static const ll INF=1e18;


ll dist[MAX][MAX]; //最短経路を記録
ll fuel[MAX][MAX];

int main(){
    ll N,M,L; cin >> N >> M >> L;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) dist[i][j]=fuel[i][j]=0;
            else dist[i][j]=fuel[i][j]=INF;
        }
    }
    for(int i=0;i<M;i++){
        ll a,b,c; cin >> a >> b >> c;
        a--;b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(dist[i][j]<=L){
                fuel[i][j]=1LL;
            }
        }
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                fuel[i][j]=min(fuel[i][j],fuel[i][k]+fuel[k][j]);
            }
        }
    }
    int q; cin >> q;
    while(q--){
        int s,t; cin >> s >> t;
        s--;t--;
        if(fuel[s][t]==INF) cout << -1 << endl;
        else cout << fuel[s][t]-1 << endl;
    }
}

Measured memory_bytes: 2048
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	N := readInt()
	_ = readInt()
	a := make([]int, N)
	for i := range a {
		a[i] = readInt()
	}

	b := make([]int, N)
	max := a[N-1]
	for i := N - 1; i >= 0; i-- {
		if max < a[i] {
			max = a[i]
		}
		b[i] = max
	}

	max = 0
	ans := 0
	for i := 0; i < N; i++ {
		d := b[i] - a[i]
		if max <= d {
			if max < d {
				ans = 0
			}
			max = d
			ans++
		}
	}
	println(ans)
}

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


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

using namespace std;

int main() {
  int k;
  scanf("%d", &k);
  if (k == 1) {
    puts("1");
    puts("1");
    return 0;
  }
  int n = (k + 3) / 4 * 2;
  printf("%d\n", n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int color = (i + j) % n;
      if ((i & 1) && color + n < k) {
        color += n;
      }
      printf("%d%c", color + 1, j == n - 1 ? '\n' : ' ');
    }
  }
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    deque<ll> A;
    if (n % 2 == 0) {
        rep(i, n/2) {
            ll a1, a2; 
            cin >> a1 >> a2;
            A.push_back(a1);
            A.push_front(a2);
        }
    }
    else {
        ll a;
        cin >> a;
        A.push_front(a);
        rep(i, (n-1)/2) {
            ll a2, a3;
            cin >> a2 >> a3;
            A.push_back(a2);
            A.push_front(a3);
        }
    }
    rep(i, n) {
        if (i == n-1) {
            cout << A[i] << endl;
            return 0;
        }
        cout << A[i] << " ";
    }
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  string S;
  cin>>S;
  int count_jp=0,count_al=0;
  vector<string> ans(N,"No");
  for(int i=0;i<N;i++){
    if(S.at(i)=='a' && count_jp+count_al<A+B){
      ans.at(i)="Yes";
      count_jp++;
    }
    else if(S.at(i)=='b' && count_jp+count_al<A+B && count_al<B){
      ans.at(i)="Yes";
      count_al++;
    }
  }  
  for(int i=0;i<N;i++){
  cout<<ans.at(i)<<endl;
  }
}

Measured memory_bytes: 6648
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll H;
ll DP[100005]; // 0番目はN, 1番目は[N/2], 2番目は[N/2]/2...

ll dfs(ll h, int idx) {
  if (h==1) return 1;
  if (DP[idx]>0) return DP[h];
  ll ret = 2*dfs(h/2, idx+1);
  DP[idx] = ret; 
  return ret;
}

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

  cin >> H;
  cout << 2*dfs(H, 0)-1 << "\n";
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n)    FOR(i, 0, n)
#define pb           push_back
#define all(a)       (a).begin(), (a).end()
#define UNIQUE(v)    v.erase(unique(all(v)), v.end());
#define fill(a, x)   memset(a, x, sizeof(a))
#define zero(a)      fill(a, 0)
#define minus(a)     fill(a, -1)
#define dbg(x)       cout << #x "=" << x << endl
// #define MAX          100000
// int A[MAX], n;

int partition(int *A, int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  i++;
  swap(A[i], A[r]);
  return i;
}

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

  int n;
  cin >> n;

  int A[n];

  int c = 0;
  while (c < n) {
    int tmp;
    cin >> tmp;
    A[c] = tmp;
    c++;
  }

  int k = partition(A, 0, n - 1);

  // for (int i = 0; i < n; i++) {
  //   if (i)
  //     cout << " ";
  //   if (i == k)
  //     cout << "[";
  //   cout << A[i];
  //   if (i == k)
  //     cout << "]";
  //   if (i == n - 1) {
  //     cout << endl;
  //   }
  // }

  // rep(i, n) {
  //   if (i != 0) {
  //     cout << " ";
  //   }
  //   if (i == k) {
  //     cout << "[" << A[i] << "]";
  //   } else {
  //     cout << A[i];
  //   }
  //   if (i == n - 1) {
  //     cout << endl;
  //   }
  // }

  rep(i, n) {
    if (i == k) {
      cout << "[" << A[i] << "] ";
    } else if (i == n - 1) {
      cout << A[i] << endl;
    } else {
      cout << A[i] << " ";
    }
  }

  return 0;
}



Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 998244353
#define N 100005  //check the limits, man
int main()
{
    int j,i,n,m,ans,f,k;
    string str;
    llin(str);
    ans=0;
    n=str.size();
    string temp;
    set<char> st;
    st.insert('A');
    st.insert('C');
    st.insert('G');
    st.insert('T');

    rep(i,n)
    {
        rep(j,i+1)
        {
            temp=str.substr(j,i-j+1);
            m=temp.size(),f=1;
            rep(k,m)
                if(st.find(temp[k])==st.end())f=0;
            if(f)
                ans=max(ans,m);
        }
    }
    out(ans);
}





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

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

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == ',')
        {
            cout << endl;
        }
        else
        {
            cout << s[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    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 line
    #define trace(...)
#endif

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    map<string, int> MP;
    string a, b;
    cin >> a >> b;
    int x, y;
    cin >> x >> y;
    MP[a] = x;
    MP[b] = y;
    string s;
    cin >> s;
    MP[s]--;
    cout << MP[a] << " " << MP[b] << endl;
    return 0;
}




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

using namespace std;

const int maxN = 1e5;

vector<int> graph[maxN];
bool visited[maxN];

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

	for (int i = 0; i < m; i++) {
		int from, to;
		cin >> from >> to;
		from--;
		to--;
		graph[from].push_back(to);
		graph[to].push_back(from);
	}

	vector<int> res(n, n + 2);
	vector<int> sign(n, -1);
	res[0] = 0;

	queue<int> q;
	q.push(0);

	while (q.size() > 0) {
		int curr = q.front();
		q.pop();
		if (visited[curr]) continue;
		visited[curr] = true;

		for (auto neigh : graph[curr]) {
			if (res[curr] + 1 < res[neigh]) {
				sign[neigh] = curr + 1;
				res[neigh] = res[curr] + 1;
			}
			q.push(neigh);
		}
	}

	for (auto r : res) {
		if (r == n + 2) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes" << endl;

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

Measured memory_bytes: 11540
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		
		if(a <=b*2) {
			System.out.println(0);
		}
 
		if(a>b*2) {
			System.out.println(a- 2*b);
		}
		
		
		
 
		sc.close();
	}
}


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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  if(a==b && b==c) cout << 1 << endl;
  if(a==b && a!=c) cout << 2 << endl;
  if(a==c && a!=b) cout << 2 << endl;
  if(b==c && a!=c) cout << 2 << endl;
  if(a!=b && b!=c && c!=a) cout << 3 << endl;
  return 0;
}



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

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

int main(){
	int w, h, s[20][20];
	while( cin >> w >> h, w || h ){
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> s[y][x];
			}
		}
		
		int dp[20][20] = {0};
		for(int x=0 ; x < w ; x++ ){
			if( s[0][x] == 0 ) dp[0][x] = 1;
		}
		for(int y=0 ; y < h-1 ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( s[y][x] == 0 ){
					for(int i=0 ; i < 3 ; i++ ){
						int mx = x + dx[i];
						int my = y + 1;
						if( mx < 0 || mx >= w ) continue;
						
						if( s[my][mx] == 0 ){
							dp[my][mx] += dp[y][x];
						}else if( i == 1 && s[my][mx] == 2 ){
							dp[my][mx] += dp[y][x];
						}
					}
				}else if( s[y][x] == 2 ){
					int mx = x;
					int my = y + 2;
					if( s[my][mx] != 1 ){
						dp[my][mx] += dp[y][x];
					}
				}
			}
		}
		
		int ans=0;
		for(int x = 0 ; x < w ; x++ ){
			ans += dp[h-1][x] + dp[h][x];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

void chmax_str(string &a,string &b) {
    if(SZ(a)<SZ(b)) a=b;
    else if(SZ(a)==SZ(b)) chmax(a,b);
}
signed main() {
    while(1){
        int W,H;
        cin>>W>>H;
        if(W+H==0) break;
        
        vector<string> s(H);
        cin>>s;
        vector<vector<string>> dp(H,vector<string>(W,""));

        string ans="";
        REP(i,H) {
            REP(j,W) {
                if('0'<=s[i][j] and s[i][j]<='9') {
                    string t="";
                    if(i>0) {
                        chmax_str(t,dp[i-1][j]);
                    }
                    if(j>0) {
                        chmax_str(t,dp[i][j-1]);
                    }
                    if(t=="" && s[i][j]=='0') {
                        dp[i][j]="";
                    }
                    else {
                        dp[i][j]=t+s[i][j];
                        chmax_str(ans,dp[i][j]);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct Node
{
	long long int sum,x,y;
};
bool compair(Node p,Node q)
{
	return p.sum<q.sum;
}
int main()
{
	long long int yy,n,xx,x,y;
	cin>>n;
	vector<Node> V1,V2;
	while(n--)
	{
		cin>>x>>y;
		V1.push_back({x+y,x,y});
		V2.push_back({x-y,x,y});
	}
	sort(V1.begin(),V1.end(),compair);
	sort(V2.begin(),V2.end(),compair);
	xx=labs(V1[0].x-V1[V1.size()-1].x)+labs(V1[0].y-V1[V1.size()-1].y);
	yy=labs(V2[0].x-V2[V2.size()-1].x)+labs(V2[0].y-V2[V2.size()-1].y);
	xx>yy ? cout<<xx : cout<<yy;
}

Measured memory_bytes: 12860
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            // 整数の入力
            long n = long.Parse(Console.ReadLine()) * 100;

            var capacity = new int[] {
                25, 50, 100, 200
            };

            var q = inputLongArray[0];
            var h = inputLongArray[1];
            var s = inputLongArray[2];
            var d = inputLongArray[3];

            var qq = inputLongArray[0];
            var hh = inputLongArray[1] / 2.0;
            var ss = inputLongArray[2] / 4.0;
            var dd = inputLongArray[3] / 8.0;

            var list = new List<double> {
                qq, hh, ss, dd
            };

            var min0 = list.LastIndexOf(list.Min());
            list[min0] = double.MaxValue;
            var min1 = list.LastIndexOf(list.Min());
            list[min1] = double.MaxValue;
            var min2 = list.LastIndexOf(list.Min());
            list[min2] = double.MaxValue;
            var min3 = list.LastIndexOf(list.Min());
            list[min3] = double.MaxValue;

            var a = n / capacity[min0];
            n -= a * capacity[min0];

            var b = n / capacity[min1];
            n -= b * capacity[min1];

            var c = n / capacity[min2];
            n -= c * capacity[min2];

            var e = n / capacity[min3];
            n -= e * capacity[min3];

            var val = a * inputLongArray[min0];
            val += b * inputLongArray[min1];
            val += c * inputLongArray[min2];
            val += e * inputLongArray[min3];

            Console.WriteLine(val);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {

	int a, b, n, ans;
	int h[100000];

	cin >> n >> a >> b;

	rep(i, n) {
		cin >> h[i];
	}

	sort(h, h + n);

	ans = 1;

	ll r, l;
	ll aa = a - b;
	l = 0; r = INF;

	while (r - l >= 1) {
		ll t = (r + l) / 2;
		ll c = 0;
		for (int j = n - 1; j >= 0; j--) {
			if (h[j] > b*t) {
				if ((h[j] - b * t) % aa == 0)c += (h[j] - b * t) / aa;
				else c += (h[j] - b * t) / aa + 1;
			}
			else {
				break;
			}
		}
		if (c <= t) {
			ans = t; r = t;
		}
		else {
			l = t + 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	cin >> n;
	while (n--){
		double x1, y1, x2, y2, x3, y3, px, py, r;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		double a, b, c;
		a = hypot(x1 - x2, y1 - y2);
		b = hypot(x2 - x3, y2 - y3);
		c = hypot(x3 - x1, y3 - y1);
		px = ((y1 - y3)*(pow(y1, 2) - pow(y2, 2) + pow(x1, 2) - pow(x2, 2)) - (y1 - y2)*(pow(y1 ,2) - pow(y3 ,2) + pow(x1 ,2) - pow(x3 ,2))) / (2*(y1 - y3)*(x1 - x2) - 2.0*(y1 - y2)*(x1 - x3));
		py = ((x1 - x3)*(pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2)) - (x1 - x2)*(pow(x1 ,2) - pow(x3 ,2) + pow(y1 ,2) - pow(y3 ,2))) / (2*(x1 - x3)*(y1 - y2) - 2.0*(x1 - x2)*(y1 - y3));
		r = a*b*c / sqrt((a + b + c)*(-a + b + c)*(a - b + c)*(a + b - c));
			printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
}

Measured memory_bytes: 1244
x = []
y = []
while(1):
    n1,n2 = map(int,input().split())
    if n1 == 0 and n2 == 0 :
        break
    else:
        x.append(n1)
        y.append(n2)    
for i in range(len(x)):
    if(x[i]>y[i]):
        x[i],y[i] = y[i],x[i]
        print("{} {}".format(x[i],y[i]))
    else:
        print("{} {}".format(x[i],y[i]))


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  cout << (n / 2 + n % 2) << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

int main() {
    vector<string> grid;grid.resize(3);
    for (auto& line: grid) {
        cin>>line;
    }
    
    
    for (auto i=0;i<3;i++) {
        cout << grid[i][i];
    }
    
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    for(ll i=1; i<=N; i++){
        ll temp = i*(i+1)/2;
        if(N <= temp){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3632