akhauriyash/Code-Regression huggingface dataset:
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int N;
vector<int> P;
int main(){
    cin>>N;
    REP(i,N){int aa;cin>>aa;P.push_back(aa);  cerr<<aa<<endl;}
    int num=0; int stock;
    REP(i,N){
        if(P[i]==i+1){
            stock=P[i];
            P[i]=P[i+1];
            P[i+1]=stock;
            num++;
        }
    }
   cout<<num<<endl;

}


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

int main() {
  
  int n;
  cin >> n;
  
  cout << ((n / 10 == 9 || n % 10 == 9) ? "Yes" : "No") << endl;
}

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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

bool Check(string s)
{
    if (s[0] != 'A')
        return false;

    int n = s.size(), cnt = 0;

    for (int i = 2; i < n - 1; ++i)
        if (s[i] == 'C')
            ++cnt;

    if (cnt != 1)
        return false;

    for (int i = 0; i < n; ++i)
        if (s[i] >= 'A' && s[i] <= 'Z')
            ++cnt;

    return cnt == 3;
}

int main()
{  
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    if (Check(s))
        cout << "AC";
    else
        cout << "WA";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2];
	#ifdef ANIKET_GOYAL
		// cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

Measured memory_bytes: 3656
#include <sstream>
#include <set>
#include <iostream>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

using namespace std;

struct rule{
  int permit;
  string from;
  string to;

  rule(string p, string f, string t){
    if(p == "permit") permit = 1;
    else permit = 0;
    from = f;
    to = t;
  }
};

bool match(string s, string t){
  REP(i,s.size()){
    if(s[i] == '?' || t[i] == '?') continue;
    if(s[i] != t[i]) return false;
  }
  return true;
}

int main(){
  int n, m;
  while(cin >> n >> m, n + m){
    vector<rule> r;
    REP(i,n){
      string p, f, t;
      cin >> p >> f >> t;
      r.push_back(rule(p, f, t));
    }

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

    vector<string> ans;
    REP(i,m){
      string f, t, mes;
      cin >> f >> t >> mes;

      REP(j,n){
	if(match(f, r[j].from) && match(t, r[j].to)){
	  if(r[j].permit){
	    stringstream ss;
	    ss << f << " " << t << " " << mes;
	    ans.push_back(ss.str());
	  }
	  break;
	}
      }
    }

    cout << ans.size() << endl;
    REP(i,ans.size()) cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1044
x = int(input())

if x <= 6:
    ans = 1
elif x <= 11:
    ans = 2
else:
    ans = x // 11 * 2
    if x % 11 == 0:
        pass
    elif x % 11 <= 6:
        ans += 1
    else:
        ans += 2

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 X, N;
  cin >> X >> N;
  vector<i64> p(N);
  for (i64 i = 0; i < N; i++)
    cin >> p[i];
  i64 ans = 1e9;
  for (i64 i = X - 101; i < X + 101; i++)
    if (abs(i - X) < abs(ans - X))
    {
      bool ok = true;
      for (i64 j = 0; j < N; j++)
        if (i == p[j])
          ok = false;
      if (ok)
        ans = i;
    }
  cout << ans << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)

const int MAX_N = 100;
const int INF = 0x3f3f3f3f;

int main() {
  int n, p[MAX_N + 1], m[MAX_N + 1][MAX_N + 1] = {0}; 

  cin >> n;
  REP(i, n) cin >> p[i] >> p[i + 1];

  REP(i, n) REP(l, n - i) {
    if (i == 0) continue;
    int r = l + i;
    m[l][r] = INF;
    FOR(j, l, r) m[l][r] = min(m[l][r], m[l][j] + m[j + 1][r] + p[l] * p[j + 1] * p[r + 1]);
  }
  cout << m[0][n - 1] << endl;

  return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,ap,bp,a,b;
    cin>>n;
    while(n!=0){
        ap=0;
        bp=0;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            ap+=a==b?a:(a>b?a+b:0);
            bp+=a==b?b:(a<b?a+b:0);
        }
        cout<<ap<<' '<<bp<<endl;
        cin>>n;
    }
}

Measured memory_bytes: 3000
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll>p(n);
    rep(i,n)cin>>p[i];
    vector<ll>s(n);
    ll c=0;
    rep(i,n){
        s[i]=c+(p[i]+1);
        c=s[i];
    }
    ll ans=s[k-1];
    //cout<<ans<<endl;
    ll mx=0;
    rep(i,n-k){
        mx=s[i+k]-s[i];
        ans=max(ans,mx);
    }
    cout<<ans/2<<".";
      if((ans)%2==0)cout<<"00000000000"<<endl;
    else cout<<"50000000000"<<endl;
}








Measured memory_bytes: 3328
package main

import (
	"fmt"
	"log"
)

func main() {
	log.SetFlags(log.Lshortfile)
	var A, B int
	fmt.Scan(&A, &B)
	if A+B >= 10 {
		fmt.Println("error")
	} else {
		fmt.Println(A + B)
	}
}


Measured memory_bytes: 512
S = input()
cnt01, cnt10 = 0, 0
for i in range(len(S)):
    if (i % 2 == 0):
        if (S[i] == '1'): cnt01 += 1
        else: cnt10 += 1
    else:
        if (S[i] == '1'): cnt10 += 1
        else: cnt01 += 1
print(min(cnt01, cnt10))


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

void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[200001];  // 作業用配列
  if (left < right) {
    mid = (left + right)/2; // 真ん中
    merge_sort(array, left, mid);  // 左を整列
    merge_sort(array, mid+1, right);  // 右を整列
    for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; // 右半分を逆順
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}


int main(void){
int n;
int l[100];
 
    scanf("%d",&n);
  
    for(int i=0;i<n;i++){
        scanf("%d",&l[i]);
    }
    
    merge_sort(l,0,n-1); 
 int ans=0;
   for(int i=0;i<n-2;i++){
       for(int j=i+1;j<n-1;j++){
           for(int k=j+1;k<n;k++){
               if(l[i]!=l[j]&&l[j]!=l[k]){
                   if(l[i]+l[j]>l[k]){
                       ans++;
                   }
               }
               
           }
       }
   }
   
   
    printf("%d",ans);
    
}


Measured memory_bytes: 1764
import sys
n = int(input())
print(0)
s = input()
if s == "Vacant":
    sys.exit()
lb, ub = 0, n
ls, us = s, s
while True:
    mid = (lb + ub) // 2
    print(mid)
    mis = input()
    if mis == "Vacant":
        sys.exit()
    if (ls == mis) ^ ((mid - lb) & 1):
        lb = mid
        ls = mis
    else:
        ub = mid
        us = mis


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char in[12];
int main(){
  rd(in);
  in[3]++;
  wt_L(in);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20171023-1 [beta]

// --- original code ---
// char in[12];
// {
//   rd(in);
//   in[3]++;
//   wt(in);
// }


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
	int t,n,w,i;
	for(i=1;i<=4;i++){
		scanf("%d %d",&t,&n);
		if(t==1){
			w=6000*n;
		}
		else if(t==2){
			w=4000*n;
		}
		else if(t==3){
			w=3000*n;
		}
		else {
			w=2000*n;
		}
	printf("%d\n",w);	
	}		

	
	return 0;
}	

Measured memory_bytes: 600
s=input()
a=s.split(" ")

mp={}
freq=""
longest=""

mx=0
for v in a:
    #???????????°????????????
    if v in mp:
        mp[v]+=1
    else:
        mp[v]=1

    if mx<mp[v]:
        freq=v
        mx=mp[v]

    #?????????????????´??°
    if len(longest)<len(v):
        longest=v

print(freq,longest)

Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 全探索
  int N, X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  vector<int> cnt(N);
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int d = min(j-i, abs(i-X) + abs(j-Y) + 1);
      cnt[d]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << cnt[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

template<typename T>bool chkmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool chkmin(T &a,T b){return (a>b)?a=b,1:0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int n,m;
struct node{
   int l,r;
}p[500005];
namespace bf{
	int mp[405][405];
	void dfs(int x,int step){
	   if(step==m+1){
	      F(i,1,n){
			  if(x&(1<<(i-1))){
					F(j,i+1,n){
					    if(x&(1<<(j-1)))mp[i][j]=1;
					}
			  }
		  }
		  return ;
	   }
       bool flag1=(x&(1<<(p[step].l-1))),flag2=(x&(1<<(p[step].r-1)));
	   if(flag1&flag2){
	       dfs(x^(1<<(p[step].l-1)),step+1);
		   dfs(x^(1<<(p[step].r-1)),step+1);
	   }
	   else if(flag1)dfs(x^(1<<(p[step].l-1)),step+1);
	   else if(flag2)dfs(x^(1<<(p[step].r-1)),step+1);
	   else dfs(x,step+1);
	}
	void Bf(){
		dfs((1<<n)-1,1);
		int ans=0;
		F(i,1,n)F(j,i+1,n){
		   if(mp[i][j])ans++;
		}
		printf("%d\n",ans);
	}
	bitset<505>s[505];
	bool alive[505];
	void BF(){
	  F(i,1,n)s[i].set(i),alive[i]=1;
	  F(i,1,n){
	     f(j,m,1){
		  if(s[i][p[j].l]&&s[i][p[j].r]){
		     alive[i]=0;
			 break;
		  }
		  else if(s[i][p[j].l])s[i][p[j].r]=1;
		  else if(s[i][p[j].r])s[i][p[j].l]=1;
		 }
	  }
	  int ans=0;
	  F(i,1,n){
	     if(alive[i]){
		    F(j,i+1,n){
			  if(alive[j]){
			    if((s[i]&s[j]).none())ans++;
			  }
			}
		 }
	  }
	  printf("%d\n",ans);
	}
}
int main () {
#ifndef ONLINE_JUDGE
//file("c");
#endif  
    n=read();
	m=read();
	F(i,1,m){
	  p[i].l=read();
	  p[i].r=read();
	}
	if(n<=20){
	   bf::Bf();
	   return 0;
	}
	   bf::BF();
    return 0;
}

Measured memory_bytes: 1024
A,B,C= [int(i) for i in input().split()]

flag = 0

for i in range(B):
    if(i==0):
        continue

    amari = (i * A) % B

    if(amari == C):
        flag = 1

if(flag==1):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
  vector<ll> cnt(N);
  vector<vector<ll>> g(N,vector<ll>());
  vector<ll> tree(N);
  REP(N-1){
    --a[i];--b[i];
  }
  REP(Q){
    --p[i];
  }
  REP(N-1){
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  deque<pll> q;
  q.push_back(pll(0,-1));
  while(!q.empty()){
    auto tmp=q.front();q.pop_front();
    for (auto &&i : g[tmp.first])
    {
      if(i==tmp.second)continue;
      q.push_back(pll(i,tmp.first));
    }
    tree[tmp.first]=tmp.second;
  }
  REP(Q){cnt[p[i]]+=x[i];}
  deque<ll> qq;
  vector<ll> ans=cnt;
  qq.push_back(0);
  while(!qq.empty()){
    auto tmp=qq.front();qq.pop_front();
    dump(tmp);
    for (auto &&i : g[tmp])
    {
      dump(i);
      dump(ans[i]);
      if(i==tree[tmp])continue;
      ans[i]+=ans[tmp];
      qq.push_back(i);
    }
  }
  REP(N){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  dump(cnt);
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&x[i]);
    }
    solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
    return 0;
}


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

using namespace std;

using ll = long long;

void dfs(int cur, int par, ll val, vector< vector<int> >& g, vector<ll>& v, vector<ll>& ans) {
    val += v[cur];
    ans[cur] = val;
    for (int nex : g[cur]) {
        if (nex == par) continue;
        dfs(nex, cur, val, g, v, ans);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector< vector<int> > g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<ll> v(n, 0);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        v[p] += x;
    }

    vector<ll> ans(n, 0);
    dfs(0, -1, 0, g, v, ans);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << " \n"[i + 1 == n];
    }
    return 0;
}

Measured memory_bytes: 32128
#include<iostream>
using namespace std;
int main(){
  int n, l, i=0, cnt=0;
  cin >> n;
  int p[n];
  // pは0からn-1に格納されることに注意
  while(cin>>l){
   	p[i]=l;
    //cout << p[i];
    i++;
  }
  int n1=p[0], n2=p[1], n3=p[2];
  for (int j = 1; j < n-1; j++){
    n1 = p[j-1];
    n2 = p[j];
    n3 = p[j+1];
    //cout << "n1" << "n2" << "n3" <<endl;
    //cout << n1 << n2 << n3 << endl;
    if (((n1 <= n2) && (n2 < n3)) || ((n3 <= n2) && (n2 < n1))) {
     cnt++;
     //cout << "cnt=" << cnt << endl;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;


int main(){
    int N,k;
    cin >> N >> k;
    vint h(N+1,1);
    h[0] = 0;
    int d,a;
    rep(i,k){
        cin >> d;
        rep(j,d){
            cin >>a;
            h[a]=0;
        }
    }
    cout << accumulate(h.begin(),h.end(),0);
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------
const int MX = 100000 + 7;
int n,k;
string s;
//int frm[MX];
vector<PII> v;

int main(){
    cin >> n >> k >> s;
    //char prev = s[0]; //int idx = 0;
    //frm[0] = idx;
    FOR(i,0,n-1){
        if((s[i-1]== '1' && s[i] == '0') || (i==0 && s[i] == '0')){
            int cur = i;
            while(s[i] == '0'){
                i++;
            }
            v.push_back(MP(cur,i));
            //cout << cur << ' ' << i << endl;
        }
    }
    int ans = 0;
    if(v.empty()){ cout << n; return 0;}
    int left = v[0].FI; 
    int right;
    FOR(i,0,v.size()-1){
        if(v.size()-i <= k){
            ans = max(ans, n-1-v[i].FI+1+left);
            //cout << "yes";
            break;
        }
        int sm = left+v[i+k].FI-v[i].FI;
        //cout << sm << ' ';
        ans = max(ans, sm);
        left = v[i+1].FI-v[i].SE;
        //cout << left << "  ";
    }

    cout << ans;
    return 0;
}


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

int func(int a,int b){
  if(a>12){
	return b;
  }else if(a>5){
	return b/2;
  }else{
    return 0;
  }
}

int main(){
  int a,b;
  cin>>a>>b;
  cout<<func(a,b)<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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



int main(){
  ll a,b; cin >> a >> b;
  cout << a*b<< endl;
  }

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

int compare(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A > *B) return -1;
	if (*A < *B) return 1;
	return 0;
}


int main(){
	int N,H,ans=0;
	scanf("%d%d",&N,&H);
	int a[N],b[N];
	for(int i=0;i<N;i++)scanf("%d%d",&a[i],&b[i]);
	qsort(a,N,sizeof(int),compare);
	qsort(b,N,sizeof(int),compare);
	if(b[0]<a[0]){
		printf("%d\n",(H+a[0]-1)/a[0]);
		return 0;
	}
	int maxb=0;
	for(;maxb<N-1;maxb++)if(b[maxb+1]<a[0])break;
	for(int i=0;i<=maxb;i++){
		ans++;
		H-=b[i];
		if(H<=0)break;
	}
	if(H>0)ans+=(H+a[0]-1)/a[0];
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1396
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

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

    rep(i,0,s.length()) {
        int op = (26 - (s[i] - 'a')) % 26;
        if(K >= op) {
            s[i] = 'a';
            K -= op;
        }
        
        if(i == (int)s.length() - 1) {
            int n = (s[i] - 'a' + K) % 26;
            s[i] = (char)('a' + n);
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(998244353);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	READV(S);
	pll F[3001];
	FORI(j,0,3001)
	{
		F[j].fi=0;
		F[j].se=0;
	}
	FORI(i,1,N+1)
	{
		READV(x);
		pll F1[3001];
		FORI(j,0,3001)
		{
			F1[j]={0,0};
			F1[j]=F[j];
			F1[j].fi=(F1[j].fi+F1[j].se)%MOD;
		}
		FORI(j,1,3001)
		{
			if(j+x<=3000)
			{
				F1[j+x].fi=(F1[j+x].fi+F[j].se)%MOD;
				F1[j+x].se=(F1[j+x].se+F[j].se)%MOD;
			}
		}
		F1[x].fi=(F1[x].fi+i)%MOD;
		F1[x].se=(F1[x].se+i)%MOD;
		FORI(j,0,3001)
		{
			F[j]=F1[j];
		}
	}
	cout<<F[S].fi<<endl;

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N;
    cin >> N;
    ll a;
    multiset<ll> S;
    REP(i,0,N-1) {
        cin >> a;
        S.insert(a);
    }
    REP(i,1,N+1) {
        _PR(S.count(i));
    }



    

    return 0;
}

/*



*/

Measured memory_bytes: 12972
#include <iostream>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	string s[26][26];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
				if(s[i][j]=="snuke")cout<<(char)(j+65)<<i+1<<endl;
		}
	}
	return 0;
}	 
	 


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

using str = string;
using ss = stringstream;

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

    int n,m;
    cin>>n;

    map<str,int> a,b;

    for(int i=0;i<n;i++)
    {
        str s;
        cin>>s;

        a[s]++;
    }

    cin>>m;
    for(int i=0;i<m;i++)
    {
        str s;
        cin>>s;

        b[s]++;
    }

    int ans=0;

    for(auto const& aa:a)
    {
        int cnt=aa.second-b[aa.first];
        if(cnt>0)ans=max(ans,cnt);
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3672
H, W, K = [int(x) for x in input().split()]
c = []
ans = []
a = 1
f = []
for i in range(H):
    c.append(input())
for i in range(H):
    ans.append([])
    if c[i] == '.' * W:
        pass
    else:
        t = 0
        for j in range(W):
            if c[i][j] == '.':
                pass
            else:
                if t == 0:
                    t += 1
                else:
                    a += 1
            ans[-1].append(a)
        if f == []:
            f = ans[-1]
        a += 1
for i in range(H):
    if ans[i] == []:
        for j in range(W-1):
            print(f[j], end=' ')
        print(f[-1])
    else:
        for j in range(i, H):
            if ans[j] == []:
                ans[j] = ans[j-1]
            for k in range(W-1):
                print(ans[j][k], end=' ')
            print(ans[j][-1])
        break

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

using namespace std;
int main() {

	int n, k;

	cin >> n >> k;

	int tmp1 = 1, tmp2 = 1, ans = 1;

	for (int i = 0; i < n; i++) {
		tmp1 = ans;
		tmp2 = ans;

		tmp1 = ans * 2;
		tmp2 += k;
		if (tmp1 <= tmp2) {
			ans = tmp1;
		}
		else {
			ans = tmp2;
		}
	}
	cout << ans;

	return 0;

}

Measured memory_bytes: 256
days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
week = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]

ans :: [Int] -> String
ans (m:d:_) =
  let md = sum $ take (m-1) days
      dd = md + d - 1 + 3
      wd = dd `mod` 7
  in
    week!!wd
      

main = do
  c <- getContents
  let i' = map (map read) $ map words $ lines c :: [[Int]]
      i  = takeWhile (/= [0, 0]) i'
      o  = map ans i
  mapM_ putStrLn o
  

Measured memory_bytes: 3868
n,a,b = map(int,input().split())
ans = 0
 
if n % (a+b) == 0:
  ans += n//(a+b) *a
  
else:
  if n%(a+b)<a:
    ans += n//(a+b)*a + n%(a+b)
  else:
    ans += n//(a+b)*a + a
  
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define sbit __builtin_popcount
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define sz(a) (int)a.size()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sp(x) setprecision(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
#define scni(x) scanf("%d",&x)
#define prt(x) printf("%d\n",x)
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> myset;
const int mod=1e9+7;
const int mex=1e6+1;
inline ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int pr[mex];
vec prime;
inline void seive()
{
    rp(i,2,mex) pr[i]=1;
    for(int i=2;i*i<mex;i++)
    {
        if(pr[i])
        for(int j=i*i;j<mex;j+=i)
        pr[j]=0;
    }
    vec prime;
    rp(i,2,mex)
    {
        if(pr[i]) prime.pb(i);
    }
}
ll int xx,xy,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        xx=1;
        xy=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=xx;
        xx=xy;
        xy=temp-(a1/b1)*xy;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (xx%M+M)%M;
}
int main()
{
    fast
    int n;
    cin>>n;
    string p[2];
    fr(i,n)
    {
        int x;
        cin>>x;
        p[0].pb('0'+x);
    }
    fr(i,n)
    {
        int x;
        cin>>x;
        p[1].pb('0'+x);
    }
    sort(p,p+2);
    int cnt=0;
    while(1)
    {
        if(p[0]==p[1]) break;
        next_permutation(p[0].begin(),p[0].end());
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int k,a,b;
    cin >> k >> a >> b;
    FOR(i,a,b+1){
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

}
 

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

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


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

string s;
int a[500100];
int b[500100];
int main(){
	cin>>s;
	a[0]=0;
	for(int i=1;i<=s.size();i++){
		if(s[i-1]=='<'){
			a[i]=a[i-1]+1;
		}else{
			a[i]=0;
		}
	}
	b[s.size()]=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='>'){
			b[i]=b[i+1]+1;
		}else{
			b[i]=0;
		}
	}
	ll ans=0;
	for(int i=0;i<=s.size();i++){
		ans+=(max(a[i],b[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int dp[80][80][16000];

int main(){
    int h,w; cin >> h >> w;
    int a[h][w];
    int b[h][w];
    rep(i,h)rep(j,w) cin >> a[i][j];
    rep(i,h)rep(j,w) cin >> b[i][j];
    rep(i,h)rep(j,w) a[i][j]=abs(a[i][j]-b[i][j]);
    rep(i,h)rep(j,w)rep(k,16000) dp[i][j][k]=0;
    dp[0][0][a[0][0]]=1;
    rep(i,h)rep(j,w)rep(k,16000){
        if(i>0){
            if(dp[i-1][j][k]){
                dp[i][j][k+a[i][j]]=1;
                dp[i][j][abs(k-a[i][j])]=1;
            }
        }
        if(j>0){
            if(dp[i][j-1][k]){
                dp[i][j][k+a[i][j]]=1;
                dp[i][j][abs(k-a[i][j])]=1;
            }
        }
    }
    int now=0;
    for(;;){
        if(dp[h-1][w-1][now]){
            cout << now << endl;
            return 0;
        }
        now++;
    }
return 0;
}


Measured memory_bytes: 400256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=5e6+5;

ll f[N],inv[N],m=1e9+7;

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)
		r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

ll ncr(ll n,ll r)
{
	if(n<r||r<0)return 0;
	if(n<0)return 0;
	ll ans=(f[n]*inv[r])%m;
	ans=(ans*inv[n-r])%m;
	return ans;
}

int main()
{ios_base::sync_with_stdio(false);
f[0]=1;
rep(i,1,N-1)
{
	f[i]=(f[i-1]*1ll*i)%m;
}
inv[N-1]=p(f[N-1],m-2);
ren(i,N-2,0)inv[i]=(inv[i+1]*1ll*(i+1))%m;

ll r1,c1,r2,c2;
cin>>r1>>c1>>r2>>c2;

ll ans=0;

rep(i,r1,r2)
{
	ans=(ans+ncr(i+c2+1,i+1))%m;
	ans=(ans-ncr(i+c1,i+1))%m;
	
}
ans=(ans+m)%m;
ol(ans);
return 0;
}



Measured memory_bytes: 78464
n, m, x = map(int, input().split())
a = [int(i) for i in input().split()]
cost0 = 0
costN = 0

for i in range(1, x):
    if a.count(i) == 1:
        cost0 += 1

for i in range(x+1, n):
    if a.count(i) == 1:
        costN += 1

print(min(cost0, costN))

Measured memory_bytes: 3188
n = int(input())
b = [int(i) for i in input().split()]
isContinue = True
res = []
isContinue = True
while isContinue and len(b)>0:
    tmp = 0
    for i in range(len(b)):
        if b[i] == i + 1:
            tmp = i + 1
    if tmp == 0:
        print(-1)
        isContinue = False
        break
    res.append(b.pop(tmp - 1))
if len(res) == n:
    for i in range(1, n + 1):
        print(res[-i])

                    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin>>n>>k;
	vector<ll> a(n);
	map<ll, ll> index;
	for(int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	vector<pair<ll, ll> > v(n), temp1(n);
	vector<ll> temp(n);
	temp = a;
	sort(temp.begin(), temp.end());
	for(int i = temp.size()-1; i >=0 ; i--)
	{
		index[temp[i]] = i;
	}
	vector<ll> ans(n, 0);
	for(int i = 0; i < n; i++)
	{
		for(int j = i+1; j < n; j++)
		{
			if(a[i]>a[j])
			{
				ans[i]++;
			}
		}
	}
	ll f_ans = 0, mod = 1000000007;
	for(int i = 0; i < n; i++)
	{
		ll z = ((k*(k-1))/2)%mod;
		ll t = ((k%mod * ans[i]%mod)%mod + (z%mod * index[a[i]]%mod)%mod)%mod;
		f_ans=(t%mod+f_ans%mod)%mod;
	}
	cout<<f_ans%mod<<endl;
}

Measured memory_bytes: 512
import java.util.*;
		import java.io.*;
		class Main {
			static int n;
			static double arr[],dp[][];
			public static void main(String[] args) throws IOException{
				BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
				int t=1;
		//		Integer.parseInt(br.readLine().trim());
				StringBuilder printans=new StringBuilder();
				while(t-->0)
				{
					StringTokenizer tok=new StringTokenizer(br.readLine()," ");
					n=Integer.parseInt(tok.nextToken());
					tok=new StringTokenizer(br.readLine()," ");
					arr=new double[n];
					for(int i=0;i<n;i++) {
						arr[i]=Double.parseDouble(tok.nextToken());
					}
					dp=new double[n+1][n+1];
					memset();
					System.out.println(dfs(n,0));
					
					
				}
				
				
			}
			static double  dfs(int i,int h) {
				if(dp[i][h]!=-1d)return dp[i][h];
				if(i<=0) {
					if(h>n/2) {
						return 1;
					}
					return 0;
				}
				
				dp[i][h]=(double)(arr[i-1]*dfs(i-1,h+1)+(1-arr[i-1])*dfs(i-1,h));
				
				return dp[i][h];
				
				
				
			}
	//		
			static void memset() {
				for(double a[]:dp) {
					Arrays.fill(a,-1d);
				}
			}
			
				
		}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);


  string s; cin >> s;
  rep(i,0,s.size()){if(i%2==0)cout<<s[i];}
  cout<<endl;


  return 0;
}


Measured memory_bytes: 592
//Forever... Check size - Reading order - Use scanf - Clear structures
#pragma GCC optimize ("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
#define REP(i,a,b) for(int i = int(a); i < int(b); ++ i)
typedef long long ll;
typedef pair<int, int> ii;

const int N = 2e5 + 2;

int l[N], r[N];
vector<ll> vec, psum;

ll getsum(int l, int r){
	ll res = psum[r - 1];
	if(l) res -= psum[l - 1];
	return res;
}

int main(){
	fastio;
	int n; cin >> n;
	vec.resize(n); psum.resize(n);
	ll sum = 0;
	REP(i,0,n){
		cin >> vec[i];
		psum[i] += vec[i];
		if(i) psum[i] += psum[i-1];
	}
	int ptr = 1;
	REP(i,2,n){
		while(ptr + 1 < i && llabs(getsum(0,ptr) - getsum(ptr, i)) > llabs(getsum(0,ptr+1) - getsum(ptr+1,i))) ptr ++;
		l[i] = ptr;
	}
	ptr = n - 1;
	for(int i = n - 2; i >= 0; -- i){
		while(ptr - 1 > i && llabs(getsum(i,ptr) - getsum(ptr,n)) > llabs(getsum(i,ptr-1) - getsum(ptr-1,n))) ptr --;
		r[i] = ptr;
	}
	ll ans = 1e18;
	REP(i,2,n-1){
		int x = l[i], y = i, z = r[i];
		ll b = getsum(0, x), c = getsum(x, y), d = getsum(y, z), e = getsum(z, n);
		ll low = min(b, min(c, min(d, e)));
		ll high = max(b, max(c, max(d, e)));
		ans = min(ans, high - low);
	}
	cout << ans << endl;
	return 0;
}


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

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

	int N;
	char c;
	int count = 0;
	int min_count = 0;
	// int max_count = 0;
	scanf("%d", &N);
	scanf("%c", &c);
	string S;

	cin >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == '(') {
			count++;
			// max_count = max(max_count, count);
		} else if (S[i] == ')') {
			count--;
			min_count = min(min_count, count);
		} else {
			break;
		}
		// printf("count = %d\n", count);
	}

	for (int i = 0; i < -min_count; i++) {
		printf("(");
	}
	cout << S;
	for (int i = 0; i < count - min_count; i++) {
		printf(")");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  for(ll i = 0; i < n; i += 2) {
    if (a[i] % 2 == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
# ABC067C - Splitting Pile (ARC078C)
def main():
    n = int(input())
    lst = tuple(map(int, input().rstrip().split()))
    l, r, ans = 0, sum(lst), float("inf")
    for i in lst[:-1]:
        l += i
        r -= i
        ans = min(ans, abs(l - r))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25068
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

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

  string ans;
  while(1){
    C=C-B;
    if(C<=0){
      ans="Yes";
      break;
    }
    A=A-D;
    if(A<=0){
      ans="No";
      break;
    }
  }

  cout << ans <<endl;
  
  return 0;
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//Union Find
struct UnionFind {
  vector<int> par; // 親ノード
  vector<int> rank; // ランク

  UnionFind(int n = 1) {
    init(n);
  }
  void init(int n = 1) {
    par.resize(n); rank.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
  }
  int root(int x) {
    if (par[x] == x) {
    return x;
  }
    else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return true;
  }
};

int main() {
  int N,M,x,y,z;
  cin >> N >> M;
  vector<vector<int>> g(N);
  vector<int> ans(N,-1);
  UnionFind uf(N);

  rep(i,M) {
    cin >> x >> y >> z;
    x--;y--;
    if (z%2==2) {
      ans[x] = ans[y] = 2;
    }
    uf.merge(x,y);
  }
  set<int> known;
  rep(i,N) {
    if (ans[i]%=2) known.insert(uf.root(i));
  }
  
  cout << known.size() << endl;
}

Measured memory_bytes: 8448