akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);

    long long int mindiv=5000000000000,mitr,lastmin;

    for(int i=0;i<n-3;i++){
        if(mindiv > (a[i+1]-a[i])){
            mindiv = a[i+1] - a[i];
            mitr = i;
        }
    }

    lastmin = a[n-1] - a[n-2];

    double ans = ((double)(a[n-1]+a[n-2])/(double)mindiv);
    if(mitr != n-3 && mitr !=n-4) {
        ans = max((double) (a[n - 3] + a[n - 4]) / (double) min(mindiv, lastmin),ans);
    }
    if(mitr != n-4 && mitr != n-5) {
        ans = max((double) (a[n - 1] + a[n - 4]) / (double)mindiv, ans);
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

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

int s[1000];
int main() {
	int a,b; cin >> a >> b;
	s[0]=0;
	for(int i=1;i<=999;i++) {
		s[i]=s[i-1]+i;
	}
	cout << s[b-a]-b << endl;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        Set<Character> visited = new HashSet<>();
        for(char c : str.toCharArray()) {
          if(visited.contains(c)) {
            System.out.println("no");
            return;
          }
          visited.add(c);
        }
        System.out.println("yes");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int N;
	cin>>N;
	vector< vector<int> > arr;
	for(int i=0;i<N;i++)
	{
		vector<int> s;
		int a,b,c;
		cin>>a>>b>>c;
		s.push_back(a);
		s.push_back(b);
		s.push_back(c);
		arr.push_back(s);
	}
	vector< vector <int> > dp(N,vector<int>(3));
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(int i=1;i<N;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][2],dp[i-1][0]);
		dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(max(dp[N-1][1],dp[N-1][0]),dp[N-1][2]);

}

Measured memory_bytes: 11440
n = input()
nStr = input().split()
number = list(map(int,nStr))
 
frby = 1
twby = -1
 
for i in number:
    if i % 4 == 0:
        frby += 2
    elif i % 2 == 0:
        twby += 1
        
if int(n) == 1 and frby == 3:
    print("Yes")
elif int(n) == (twby + 1):
    print("Yes")
elif int(n) <= (frby):
    print("Yes")
elif int(n) <= (frby + twby):
    print("Yes")
else :
    print("No")


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[100010];
ll h[100010];


int main()
{
    int n,k;
    cin >> n >> k;
    rep(i,n)
    {
        cin >> h[i];
    }
    rep(i,n)
    {
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i,n)
    {
        rep(j,k+1)
        {
            chmin(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    string s, t; cin >> s >> t;
    REP(i, n) cout << s[i] << t[i];
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Map<String, Integer> map = new HashMap<>();
        try (Scanner scanner = new Scanner(System.in)) {
            while (scanner.hasNext()) {
                String str = scanner.next();
                if (!map.containsKey(str)) {
                    map.put(str, 0);
                }
                int integer = map.get(str);
                map.put(str, integer + 1);
            }
            String mostWord = map.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get().getKey();
            String maxLengthWord = map.keySet().stream().max(Comparator.comparingInt(String::length)).get();
            System.out.printf("%s %s\n", mostWord, maxLengthWord);
        } catch (Exception e) {

        }
    }
}

Measured memory_bytes: 31896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 2020;
ll dp[nax][nax];

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<pair<ll, int>> order(n);
	REP(i, n) {
		cin >> order[i].st;
		order[i].nd = i;
	}
	sort(ALL(order)); reverse(ALL(order));
	ll best = -1;
	REP(i, nax) REP(j, nax) dp[i][j] = -1;
	dp[0][0] = 0;
	REP(len, n) {
		// printf("\tlen: %d,  ord: %lld, %d\n", len, order[len].st, order[len].nd);
		// adding order[len]
		REP(l, len + 1) {
			int r = len - l;
			// printf("dp[%d][%d] = %lld\n", l, r, dp[l][r]);
			dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + abs(order[len].nd - l)*order[len].st );
			dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + abs(order[len].nd - (n - 1 - r) )*order[len].st);
		}
	}
	REP(i, n) best = max(best, dp[i][n - i]);
	cout << best << endl;
}

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

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

int main()
{
    int A, B;
    string S;
    cin >> A >> B;
    cin >> S;

    int len = (int)S.length();
    rep(i, len) {
        char c = S[i];
        if (i == A) {
            if (c != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (c < '0' || c > '9') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> c(H);
  rep(i, H)
  {
    cin >> c[i];
  }
  int sum = 0;
  for (int i = 0; i < (1 << H); i++)
  {
    for (int j = 0; j < (1 << W); j++)
    {
      int cnt = 0;
      for (int h = 0; h < H; h++)
      {
        for (int w = 0; w < W; w++)
        {
          if (i & (1 << h) || j & (1 << w))
          {
            continue;
          }
          else
          {
            if (c[h][w] == '#')
            {
              cnt++;
            }
          }
        }
      }
      if (cnt == K)
      {
        sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int ans=0;

  if(a+b>c*2){
    int r=min(x,y);
    ans+=c*r*2;
    x-=r;
    y-=r;
  }

  ans+=x*min(a,c*2);
  ans+=y*min(b,c*2);

  cout<<ans<<endl;
}


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

const int base = 1e9;

void solve(long long S){
    if (S == (long long)1e18) {
        cout << "0 0 0 1000000000 1000000000 0" << endl;
        return;
    }

    long long p = S / base;
    long long q = S % base;
    cout << "0 0 1 1000000000 " << p + 1 << " " << base - q << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 100010

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n, m, q;
int color[MAXN];
bool visited[MAXN][11];
vector< vector<int> > adj;
vector< tuple<int, int, int> > ops;

void dfs(int node, int c, int d) {
  if (visited[node][d]) return;

  visited[node][d] = true;
  if (color[node] == 0) color[node] = c;

  if (d > 0) {
    for (auto child : adj[node]) {
      if (visited[child][d-1] == 0) {
        dfs(child, c, d-1);
      }
    }
  }
}

int main() {
  memset(color, 0, sizeof color);
  memset(visited, 0, sizeof visited);
  GI(n); GI(m);
  adj.resize(n+1);

  FORN(i, m) {
    int a, b;
    GI(a); GI(b);
    adj[a].PB(b);
    adj[b].PB(a);
  }

  GI(q);
  FORN(i, q) {
    int v, d, c;
    GI(v); GI(d); GI(c);
    ops.PB(make_tuple(v, c, d));
  }

  for (int i = ops.size()-1; i >= 0; i--) {
//    printf("query %d %d %d\n", get<0>(ops[i]), get<2>(ops[i]), get<1>(ops[i]));
    dfs(get<0>(ops[i]), get<1>(ops[i]), get<2>(ops[i]));
  }

  FOR1(i, n) {
    printf("%d\n", color[i]);
  }
  
  return 0;
}


Measured memory_bytes: 9460
#include <iostream>
#include <complex>
#include <vector>
#include <utility>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define INF 100000
using namespace std;
typedef complex<double> point; 
void makeroad(vector< vector < pair<int,double> > > &road,point* mapl,int n){
  double tmp;
  rep(i,0,n)
    rep(j,i+1,n)
      if((tmp=abs(mapl[i]-mapl[j]))<=50){
	road[i].push_back(make_pair(j,tmp));

	road[j].push_back(make_pair(i,tmp));
      }
}
int* dijk(const int n, vector< vector< pair<int,double> >  >&list,int s,int g){
  int* keiro;
  int i,j,u;
  double minn;
  double *length;
  bool *check=new bool[n];
  length= new double[n];
  keiro=new int[n];
 
  for(i=0;i<n;i++){
    length[i]=INF;    check[i]=true; keiro[i]=n+1;}
  //rep(i,0,n)
    //cout<<keiro[i]<<'!'<<endl;
  length[s]=0.0;
  while(check[g]){
    minn=(double)INF;


  
    rep(j,0,n)
      if(check[j] && (minn>length[j]) ){
	u=j; minn=length[j];}
    //cout<<u<<"!?"<<endl;
    if(minn==INF) break;
    rep(i,0,list[u].size())
      if(list[u][i].second+length[u]<length[list[u][i].first]){
	length[list[u][i].first]=list[u][i].second+length[u];
	keiro[list[u][i].first]=u;
      }  
    check[u]=false;
  }
  
  return keiro;
}



int main(){
  int n,m,ts,tg,tt;
  int* ans;
  vector<int> anss;
  double ta,tb;
  cin>>n;
  while(n){

    point mapl[n]; 
    rep(i,0,n){
      cin>>tt>>ta>>tb;
      mapl[tt-1]=point(ta,tb);
    }
    //いったんビルの情報を取りましょう
    vector<vector<pair<int,double> > > road(n);//これが道になる
    makeroad(road,mapl,n);//makeroadはmaplでroadを作
    cin>>m;
    rep(i,0,m){
      cin>>ts>>tg;
      ans=dijk(n,road,ts-1,tg-1);   
      //      cout<<endl;
      if (ans[tg-1]>n) cout <<"NA"<<endl;
      else{
	tt=tg-1;
	anss.resize(n);
	int k=0;
	anss[k++]=tg-1;
	for(;ans[tt]!=ts-1;tt=ans[tt]){
	  anss[k++]=ans[tt];
	}
	anss[k++]=ts-1;
	
	rep(l,1,k)
	  cout<<anss[k-l]+1<<" ";
	cout<<tg<<endl;
      }

    }
   
    cin>>n;
  }
  return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

/*
	グラフGの頂点sからすべての頂点への最短距離をDijkstra法により求める.
*/
template<typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>>& G) {
	const int n = G.size();
	vector<T> d(n, numeric_limits<T>::max());
	vector<int> b(n, -1);
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while (!q.empty()) {
		pair<T, int> p = q.top();
		q.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& e : G[v]) {
			int u = e.first;
			T c = e.second;
			if (d[u] > d[v] + c) {
				d[u] = d[v] + c;
				b[u] = v;
				q.emplace(d[u], u);
			}
		}
	}
	return d;
}


signed main() {
	int x, y, z, n, m, s, t;
	cin >> x >> y >> z >> n >> m >> s >> t;
	--s; --t;
	// サンド、カツ、カレーを頂点、
	// カツサンド、カツカレーを辺と見たグラフを構築
	vector<vector<pair<int, int>>> g(x + y + z);
	vector<int> st(2), gl(2);
	for (int i = 0; i < n; ++i) { // カツサンドの読み込み
		int a, b; cin >> a >> b;
		--a; --b;
		b += x;
		g[a].emplace_back(b, 1);
		g[b].emplace_back(a, 1);
		if (i == s) {
			st[0] = a; st[1] = b;
		}
	}
	for (int i = 0; i < m; ++i) { // カツカレーの読み込み
		int c, d; cin >> c >> d;
		--c; --d;
		c += x; d += x + y;
		g[c].emplace_back(d, 1);
		g[d].emplace_back(c, 1);
		if (i == t) {
			gl[0] = c; gl[1] = d;
		}
	}
	// st[0]からダイクストラ
	vector<int> res_0 = dijkstra(st[0], g);
	int res = min(res_0[gl[0]], res_0[gl[1]]);
	// st[1]からダイクストラ
	vector<int> res_1 = dijkstra(st[1], g);
	res = min({res, res_1[gl[0]], res_1[gl[1]]});
	// 答えの出力
	if (res != numeric_limits<int>::max())
		cout << (res + 1) << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 21260
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    vector<vector<int>> vec(3, vector<int>(3));
    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin>>vec[i][j];
    int n;
    cin>>n;
    for(int i = 0; i < n; i++){
        int num;
        cin>>num;
        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                if(vec[i][j] == num){
                    vec[i][j] = -1;
                }
    }
    for(int i = 0; i <3 ; i++){
        int cnt = 0;
        for(int j = 0; j < 3; j++)
            cnt += vec[i][j]==-1;
        if(cnt == 3){
            cout<<"Yes\n";
            return ;
        }
    }
    for(int i = 0; i < 3; i++){
        int cnt = 0;
        for(int j = 0; j < 3; j++)
            cnt += vec[j][i]==-1;
        if(cnt == 3){
            cout<<"Yes\n";
            return ;
        }
    }
    int cnt = 0;
    for(int i = 0; i < 3; i++)
        cnt += vec[i][i]==-1;
    if(cnt == 3){
        cout<<"Yes";
        return ;
    }
    cnt = 0;
    for(int i = 0; i < 3; i++)
        cnt += vec[i][2-i]==-1;
    if(cnt == 3){
        cout<<"Yes";
        return ;
    }
    cout<<"No";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3640
from collections import Counter

n = int(input())
aa = tuple(sorted(map(int, input().split())))
cnt = Counter(aa)
amax = max(aa)
af = [False] * (amax + 1)

ans = 0
for i in range(n):
    x = aa[i]
    if af[x]:
        continue
    while x <= amax:
        af[x] = True
        x += aa[i]
    if cnt[aa[i]] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 38124
n=int(input())

ans=0
s=list(str(input()))
r=[]
b=[]
g=[]
for i in range(n):
    if s[i]=='R':
        r.append(i)
    if s[i]=='B':
        b.append(i)
    if s[i]=='G':
        g.append(i)
count=0
aida=1

while aida*2-1<=n:
    for i in range(n-aida*2):
        #print("DF")
       # print(s[i],i,s[i+aida],i+aida,s[i+aida*2],i+aida*2)
        aa=set()
        aa.add(s[i])
        aa.add(s[i+aida])
        aa.add(s[i+aida*2])
        #print(aa)
        if len(aa)==3:
            count+=1
    aida+=1
#print(count)

print(len(r)*len(b)*len(g)-count)

Measured memory_bytes: 68604
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int disx = x2 - x1;
    int disy = y2 - y1;
    cout << x2 - disy << ' ' << y2 + disx << ' ' << x1 - disy << ' ' << y1 + disx << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string S;
  cin >> S;
  int ans = 0;
  if (S[0]!='C') ans++;
  if (S[1]!='O') ans++;
  if (S[2]!='D') ans++;
  if (S[3]!='E') ans++;
  if (S[4]!='F') ans++;
  if (S[5]!='E') ans++;
  if (S[6]!='S') ans++;
  if (S[7]!='T') ans++;
  if (S[8]!='I') ans++;
  if (S[9]!='V') ans++;
  if (S[10]!='A') ans++;
  if (S[11]!='L') ans++;
  if (S[12]!='2') ans++;
  if (S[13]!='0') ans++;
  if (S[14]!='1') ans++;
  if (S[15]!='6') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
#include <algorithm> 
using namespace std;

int main() { 	
	long long a, b, c, d; 
	priority_queue<long long> values; 
	
	cin >> a >> b >> c >> d; 
	
	values.push(a*c);
	values.push(a*d);
	values.push(b*c);
	values.push(b*d); 	
	
	cout << values.top() << endl ;
	
	return 0; 
} 


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

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

    vector<int> arr(n);
    vector<int> count(n);

    bool flag=true;
    for(int i=0;i<m;i++) {
        int s,c;
        cin>>s>>c;

        if(count[s-1]!=0&&arr[s-1]!=c) flag=false;
        else {
            arr[s-1]=c;
            count[s-1]++;
        }
    }
    if(count[0]!=0&&arr[0]==0&&n!=1) flag=false;

    if(flag) {
        if(arr[0]==0&&n!=1) {
            arr[0]=1;
        }
        for(int i=0;i<n;i++) {
            cout<<arr[i];
        }
        cout<<endl;
    }
    else cout<<-1<<endl;

}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int flag[8];
int main()
{
    int n,i,a,mini=0,maxi=0,sum=0;
    scanf(" %d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a<400){
            if(flag[0]==0)  flag[0]++;
        }
        else if(a<800){
            if(flag[1]==0)  flag[1]++;
        }
        else if(a<1200){
            if(flag[2]==0)  flag[2]++;
        }
        else if(a<1600){
            if(flag[3]==0)  flag[3]++;
        }
        else if(a<2000){
            if(flag[4]==0)  flag[4]++;
        }
        else if(a<2400){
            if(flag[5]==0)  flag[5]++;
        }
        else if(a<2800){
            if(flag[6]==0)  flag[6]++;
        }
        else if(a<3200){
            if(flag[7]==0)  flag[7]++;
        }
        else{
            flag[8]++;
        }
    }
    for(i=0;i<=7;i++){
        sum=flag[i]+sum;
    }
    if(sum==0){
        mini=1;
        maxi=flag[8];
    }
    else{
        mini=sum;
        maxi=sum+flag[8];
    }
    printf("%d %d\n",mini,maxi);
    return 0;
}


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

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

    if(4*a*b<(c-a-b)*(c-a-b) && c-a-b>0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

ll combo(ll a, ll b){
  ll ue=1;
  ll shita=1;
  if(a<b) return 0;
  else{
    for(ll i=a; i>=a-b+1; i--) ue*=i;
    for(ll i=b; i>=1; i--) shita*=i;
    return ue/shita;
  } 
}

int main() {
  ll N; cin>>N;
  vector<ll> A(N);
  map<ll, ll> M;
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    A[i]=a;
    if(M.count(a)) M[a]++;
    else M[a]=1;
  }
  ll sum=0;
  for(auto p:M){
    ll v=p.second;
    sum+=combo(v, 2);
  }
  for(ll i=0; i<N; i++){
    ll p=combo(M[A[i]], 2);
    ll q=combo(M[A[i]]-1, 2);
    cout<<sum-p+q<<endl;
  }
}


Measured memory_bytes: 11008
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;

int32_t main()
{
  BOOST;
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;
int tt[31][100010] = {};
int sum[100010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    int s[100010], t[100010], c[100010];
    rep(i,0,N){
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
    }
    rep(i,0,N){
        rep(j,s[i],t[i]+1){
            tt[c[i]][j] = 1;
        }
    }
    // printa2(tt, C, 20);
    rep(i,0,100010){
        rep(j,0,C){
            sum[i] += tt[j][i];
        }
    }
    int ans = 0;
    rep(i,0,100010){
        ans = max(ans, sum[i]);
    }
    // printa(sum,20);
    print(ans);
    


}


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

int main()
{
    string X, Y;
    cin >> X >> Y;

    if( X<Y ){
        cout << '<' << endl;
    }else if ( X>Y ){
        cout << '>' << endl;
    }else{
        cout << '=' << endl;
    }

    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    vector<pair<int, int>> B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) {
        int b, c;
        cin >> b >> c;
        B[i] = make_pair(c, b);
    }
    
    sort(A.begin(), A.end());
    sort(B.rbegin(), B.rend());
    vector<int> S;
    int cnt = 0;
    rep(i, M) {
        int b = B[i].second;
        int c = B[i].first;
        rep(j, b) S.push_back(c);
        cnt += b;
        if (cnt >= N) break;
    }
    rep(i, N) S.push_back(A[i]);
    sort(S.rbegin(), S.rend());
    
    long long ans = 0;
    rep(i, N) ans += S[i];
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int N,W;
    cin>>N>>W;
    ll w[N+1], v[N+1];
    for(int i=1;i<=N;i++) cin>>w[i]>>v[i];
    ll dp[N+1][W+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=N;i++)
    {
        for(int j=0;j<=W;j++) 
        {
            if(j>=w[i])
                dp[i][j]=max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[N][W];
    return 0;
}

Measured memory_bytes: 79104
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        c: i32,
        b: [i32; m],
    };

    let mut count = 0;
    for _ in 0..n {
        input! {
            a: [i32; m],
        };

        let a: Vec<i32> = a;

        let mut sum: i32 = 0;
        for (ai, bi) in a.iter().zip(b.iter()) {
            sum += ai * bi;
        }
        sum += c;

        if sum > 0 {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2200
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<i64> A;
  tools::read(A, M);
  std::cout << std::max<i64>(-1, N - std::accumulate(A.begin(), A.end(), static_cast<i64>(0))) << std::endl;
  return 0;
}

Measured memory_bytes: 3628
from heapq import heapify, heappush, heappop
N, K = map(int, input().split())
H = list(map(int, input().split()))

H = [-h for h in H]
heapify(H)
for _ in range(K):
    if len(H) == 0:
        break
    heappop(H)

print(-sum(H))

Measured memory_bytes: 25896
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin  >> A >> B >> X;
  if (A <= X && X <= A+B) cout <<"YES" << endl;
  else cout << "NO" << endl;


}


Measured memory_bytes: 256
open System
open System.Text;
open System.Linq
open System.Collections.Generic

[<EntryPoint>]
let main _ = 
    let ab = Console.ReadLine().Split() |> Array.map int
    Console.WriteLine(if (ab.[0] * ab.[1]) % 2 = 0 then  "Even" else "Odd")
    0

Measured memory_bytes: 11220
n=int(input())
l=[i for i in range(3,n+1) if i%3==0 or i%10 ==3 or int(i/10)%10==3 or int(i/100)%10==3 or int(i/1000)%10==3]
s=" ".join(map(str,l))
print(" "+s)


Measured memory_bytes: 6112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,a,b,ans=0,t=0,rem=0,bball=0;
	cin>>n>>a>>b;
	ans=(n/(a+b))*a;
	rem=n%(a+b);
	ans+=min(a,rem);
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, V, a[100000];
bool query0() {
	for (int i = 1; i <= V; i++) {
		if (a[i] == 0) { return true; }
		if (a[i] != i) { return false; }
	}
	return true;
}
void query1() {
	int cnt = 1, cnt2 = 0;
	for (int i = 1; i <= V; i++) {
		if (a[i] >= 1) {
			int b = a[i];
			a[i] = 0;
			a[cnt] = b;
			cnt++; cnt2++;
		}
	}
	V = cnt2;
}
void query2() {
	for (int i = 1; i <= V; i++) {
		a[i]--;
	}
	a[V + 1] = V;
	V++;
}
int main() {
	while (true) {
		for (int i = 0; i < 100000; i++) {
			a[i] = 0;
		}
		cin >> n; V = n;
		if (n == 0) { break; }
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		int cnt = 0;
		while (true) {
			bool ok = query0();
			if (ok == true) { cout << cnt << endl; break; }
			query1(); query2(); query1();
			cnt++;
			if (cnt > 10000) { cout << "-1" << endl; break; }
		}
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 7));
    int d = stoi(s.substr(8, 10));
    int ok = 0;
    if (y < 2019) {
        ok = 1;
    } else if (y == 2019 && m < 4) {
        ok = 1;
    } else if (y == 2019 && m == 4 && d <= 30) {
        ok = 1;
    }
    cout << (ok ? "Heisei" : "TBD") << endl;
}

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

class vec{
public:
	double x,y;
	vec(){
		x = y = 0.0;
	}
	vec(double x,double y){
		this->x = x;
		this->y = y;
	}
	vec operator+(vec &r) const{
		return vec(x+r.x,y+r.y);
	}
	vec operator-(vec &r) const{
		return vec(x-r.x,y-r.y);
	}
	void operator=(vec &r){
		this->x = r.x;
		this->y = r.y;
	}
	double norm2(){
		return x*x+y*y;	
	}
};

double dot(vec v,vec u){
	return v.x*u.x + v.y*u.y;
}
double closs(vec v,vec u){
	return v.x*u.y - v.y*u.x;
}
bool is_zero(double b){
	double ep = 1e-10;
	return fabs(b) < ep;
}

int main(){
	int q;
	vec p0,p1,p2,p3;
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
		vec u = p1 - p0;
		vec v = p3 - p2;
		if(is_zero(closs(u,v))){
			cout << 2 << endl;
		}
		else if(is_zero(dot(u,v))){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3220
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int x, t;
  cin >> x >> t;
  cout << max(0, x-t) << endl;

  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int>H(N);
	vector<vector<int>> data(100, vector<int>(N));
	for (int n = 0;n<N;++n) {
		cin >> H[n];
		for (int m = 0;m<H[n];++m) {
			data[m][n] = 1;
		}
	}
	int ans = 0;
	for (int n = 0; n < 100; ++n) {
		for (int m = 0;m<N;++m) {
			if (0 ==  m) {
				ans += data[n][m];
			}
			else {
				if (0== data[n][m - 1] && 1 == data[n][m]) {
					ans++;
				}
			}
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    int n;
    cin >> n;
    VI a(n);
    REP(i, 0, n)
        cin >> a[i];
    sort(all(a));
    cout << a[n - 1] - a[0] << endl;
}

int main()
{
    solve();

    return 0;
}

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

int main()
{
  int x, y;
  for (int i = 0; i < 3000; i++) {
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x < y) cout << x << " " << y << endl;
    else cout << y << " " << x << endl;
  }
  return 0;
}


Measured memory_bytes: 3016
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
  int n,a[100],f[8]={},sum=0,cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]<3200)
      f[a[i]/400]=1;
    else
      cnt++;
  }
  for(int i=0;i<8;i++)
    sum+=f[i];
  printf("%d %d\n",max(1,sum),sum+cnt);
}

Measured memory_bytes: 128
h,w,k =map(int,input().split())
ma = []
for i in range(h):
    ma.append(list(map(int,list(input()))))
ans = [0]*2**(h-1)
for i in range(2**(h-1)):
    idx = [0]*h #縦の何枚目か
    group = 0
    for j in range(h):
        idx[j] = group
        if (i>>j & 1):
            group +=1
    ans[i] += idx[-1]#h方向の分割
    n = idx[-1]+1#縦に何枚あるか
    cnt = [0]*n ##各ブロックの白チョコの数
    div_w = 0 #w方向の分割
    for e in range(w):
        temp = [0]*n #一時的な列を保存
        for j in range(h):
            p = idx[j]
            cnt[p] += ma[j][e]
            temp[p] += ma[j][e]
        if max(cnt) >k:
            div_w +=1
            cnt = temp
        if max(temp) >k:#この時h方向の分割そのものがだめ
            div_w = 10**9
            break
    ans[i] += div_w
print(min(ans))


Measured memory_bytes: 45276
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {

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

	int N;
	cin >> N;
	vector<int>p(N);
	for (int i = 0;i < N;++i) {
		cin >> p[i];
	}
	int cnt = 0;
	for (int i = 0;i < N;++i) {
		if (p[i] == i + 1) {
			++cnt;
			if (i == N - 1)break;
			else ++i;
		}
	}
	cout << cnt << "\n";

	return 0;
}


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

#define ll long long int 
ll mod=1e9+7;
int arr[26];

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }
//         q.pop();
// }

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    
    // int t;
    // cin >> t;
    // while(t--)
    // {        
    // }

    // int n,i,j;
    // cin >> n;
    // int arr[n];

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

    string s;
    cin >> s;
    // vector<int> v[26];

    // int c1 = 0;
    // int c2 = 0;
    // int flag1,flag2;

    for(int i=0;i<4;i++)
    {
        int temp = s[i]-'A';
        arr[temp]++;
    }    

    int count=0;
    for(int i=0;i<26;i++)
    {
        if(arr[i] > 0 && arr[i] == 2)
        {
            count ++;
        }
    }
    
    if(count == 2)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
}

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

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

  int a=s.size();
  int b=t.size();
  int c=0;


  for(int i=0; i<a; i++){
  if(s.at(i)==t.at(i)){
    c++;
  }
  }
  
  if(a+1==b&&c==a){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}
      



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

int main(){
	int n,i,j,fc=0,lc=0;
	char s[16384][32],sf[32],sl[32],t[i];
	scanf("%d",&n);
	for(i = 1;i <= n;i++){scanf("%s",s[i]);}
	scanf("%s",t);
	for(i = 1;i <= n;i++){
		for(j = 0;j < 32;j++){sf[j]=0;sl[j]=0;}
		for(j = 0;j < strlen(s[i]);j++){
			if(s[i][j] == '?'){sf[j]='a';sl[j]='z';}
			else{sf[j]=s[i][j];sl[j]=s[i][j];}
		}
		if(strcmp(t,sf) < 0){lc++;}
		if(strcmp(sl,t) < 0){fc++;}
	}
	for(i = fc+1;i <= n-lc+1;i++){if(i != fc+1){printf(" ");}printf("%d",i);}
	printf("\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    int sum[n][n] = {};
    rep (i, m) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        sum[l][r - l]++;
    }
    rep (i, n) {
        rep (j, n - 1) sum[i][j + 1] += sum[i][j];
    }
    rep (i, q) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        int ans = 0;
        range (j, p, q + 1) ans += sum[j][q - j];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

// {days, rewards}
vector<pair<int, int>> works;

int main(void) {
    int N, M;
    cin >> N >> M;

    works.resize(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        works[i] = {a, b};
    }
    sort(works.begin(), works.end());

    int ind_works = 0;
    priority_queue<int> que;
    ll ans = 0;

    for (int req_days = 1; req_days <= M; req_days++) {
        while (ind_works < N && works[ind_works].first <= req_days) {
            que.push(works[ind_works].second);
            ind_works++;
        }

        if (!que.empty()) {
            int work = que.top();
            // printf("req_days: %d, work: %d\n", req_days, work);
            que.pop();
            ans += work;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int arr[26];
	int keep[26];
	for(int i = 0; i < 26; i++) {
		arr[i] = INT_MAX / 2;
	}
	for(int i = 0 ; i < n; i++) {
		for(int j = 0; j < 26; j++) {
			keep[j] = 0;
		}
		string str;
		cin >> str;
		for(int j = 0; j < str.length(); j++) {
			keep[str[j] - 'a']++;
		}
		for(int j = 0; j < 26; j++) {
			if(keep[j] < arr[j]) {
				arr[j] = keep[j];
			}
		}
	}

	for(int i = 0; i < 26; i++) {
		for(int j = 0; j < arr[i]; j++) {
			printf("%c", i + 'a');
		}
	}
	cout << endl;

	return 0;
}

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

namespace AtCoder
{
    internal class Program
    {
        private static void Main()
        {
            var hwk = (Console.ReadLine() ?? "").Split(" ").Select(int.Parse).ToArray();
            var h = hwk[0];
            var w = hwk[1];
            var k = hwk[2];
            var s = 0;

            var l = new string[h];
            for (var i = 0; i < h; ++i) l[i] = Console.ReadLine();

            for (var i = 0; i < 1 << h; i++)
            {
                for (var j = 0; j < 1 << w; j++)
                {
                    var cnt = 0;
                    for (var m = 0; m < h; m++)
                    {
                        for (var n = 0; n < w; n++)
                        {
                            if ((i >> m & 1) == 1) continue;
                            if ((j >> n & 1) == 1) continue;
                            if (l[m][n] == '#') cnt++;
                        }
                    }
                    if (cnt == k) s++;
                }
            }
            Console.WriteLine(s);
        }
    }
}


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

template <typename F>
struct y_comb {
  F func;

  template <typename... Args>
  decltype(auto) operator()(Args&&... args) {
    return func(*this, std::forward<Args>(args)...);
  }

  template <typename... Args>
  decltype(auto) operator()(Args&&... args) const {
    return func(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
y_comb(F) -> y_comb<F>;

int main() {
  int n;
  cin >> n;
  int n2 = n + 2;
  auto to2 = [&](int i, int j) {
    return (i + 1) * n2 + j + 1;
  };

  auto dist = vector<int>(n2 * n2);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dist[to2(i, j)] = min({i, n - 1 - i, j, n - 1 - j});
    }
  }
  auto isOccupied = vector<bool>(n2 * n2, true);
  int ans = 0;

  auto update = y_comb{[&](auto& self, int u) -> void {
    int d = dist[u] + isOccupied[u];
    for (int v : {u - n2, u - 1, u + 1, u + n2}) {
      if (dist[v] > d) {
        dist[v] = d;
        self(v);
      }
    }
  }};

  for (int i = 0; i < n * n; i++) {
    int u;
    cin >> u;
    u--;
    u = to2(u / n, u % n);
    ans += dist[u];
    isOccupied[u] = false;
    update(u);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 18880
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

long long V[50];
int main(){
    int N;
    int K;
    cin >> N >> K;
    long long V_sum = 0;
    for(int i = 0; i < N; i++){
        cin >> V[i];
        V_sum += V[i];
    }


    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i; j <= N; j++){
            if(N - (j - i) > K){
                continue;
            }
            long long tmp_ans = 0;
            vector <long long> removed_jewels;
            for(int k = 0; k < N; k++){
                if(k < i || j <= k){
                    tmp_ans += V[k];
                    removed_jewels.push_back(V[k]);
                }
            }
            sort(removed_jewels.begin(), removed_jewels.end());
            for(int k = 0; k < min((int)removed_jewels.size(), K - (N - (j - i))); k++){
                if(removed_jewels[k] > 0){
                    break;
                }
                tmp_ans -= removed_jewels[k];
            }
            ans = max(ans, tmp_ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256