akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int Q=1000,P=1<<18;
#define ll long long
int las[Q],e[P],nn[P],c[P];
ll v[P];
queue<int> q;
int S,T;
const ll inf=100000000000000000LL;
ll dis[Q];
int inc;
void iNS(int x,int y,int z,ll w)
{
    e[++inc]=y;
    nn[inc]=las[x];
    las[x]=inc;
    c[inc]=z;
    v[inc]=w;
}
void ins(int x,int y,int z,ll w)
{
    iNS(x,y,z,w),iNS(y,x,0,-w);
}
int ch[Q];
int pn[Q],pt[Q];
int Spfa()
{
    for(int i=1;i<=T;i++)
        dis[i]=-inf;
    dis[S]=0;
    q.push(S);
    while(q.size()){
        int x=q.front();q.pop();
        ch[x]=0;
        for(int t=las[x];t;t=nn[t]){
            int y=e[t];
            if(c[t]&&dis[x]+v[t]>dis[y]){
                dis[y]=dis[x]+v[t];
                pn[y]=x,pt[y]=t;
                if(!ch[y])ch[y]=1,q.push(y);
            }
        }
    }
    return dis[T]>-inf;
}
ll tmp,als=0;
void Upd()
{
    tmp+=dis[T];
    for(int now=T;now!=S;now=pn[now]){
        int nt=pt[now];
        --c[nt],++c[nt^1];
    }
}
int n,m;
int X[Q],Y[Q];
int A[Q],B[Q];
char ty[Q][5];
ll V[Q];
int L[Q],R[Q];
int U[Q],D[Q];
inline void Gmax(int &a,int b)
{a<b?a=b:1;}
inline void Gmin(int &a,int b)
{a>b?a=b:1;}
void Deal(int Num)
{
    S=(Num<<1)+(n<<1)+1,T=S+1;
    for(int i=1;i<=T;i++)
        las[i]=0;
    inc=1;
    for(int i=1;i<=Num;i++)L[i]=D[i]=-998244353,R[i]=U[i]=998244353;
    for(int i=1;i<=m;i++){
        if(Num<=B[i])continue;
        if(ty[i][0]=='L')Gmax(L[B[i]+1],A[i]+1);
        if(ty[i][0]=='D')Gmax(D[B[i]+1],A[i]+1);
        if(ty[i][0]=='R')Gmin(R[Num-B[i]],A[i]-1);
        if(ty[i][0]=='U')Gmin(U[Num-B[i]],A[i]-1);
    }
    for(int i=2;i<=Num;i++)
        Gmax(L[i],L[i-1]),Gmax(D[i],D[i-1]);
    for(int i=Num-1;i;--i)
        Gmin(R[i],R[i+1]),Gmin(U[i],U[i+1]);
    int ini=(Num<<1);
    for(int i=1;i<=Num;i++){
        ins(S,i,1,0),ins(i+Num,T,1,0);
        for(int j=1;j<=n;j++)
            if(X[j]>=L[i]&&X[j]<=R[i])
                ins(i,ini+j,1,0);
        for(int j=1;j<=n;j++)
            if(Y[j]>=D[i]&&Y[j]<=U[i])
                ins(ini+n+j,i+Num,1,0);
    }
    for(int i=1;i<=n;i++)
        ins(i+ini,i+ini+n,1,V[i]);
    tmp=0;
    int tim=0;
    while(Spfa())Upd(),++tim;
    if(tim==Num)als=max(als,tmp);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d%lld",&X[i],&Y[i],&V[i]);
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
        scanf("%s%d%d",ty[i],&A[i],&B[i]);
    for(int i=1;i<=n;i++)
        Deal(i);
    printf("%lld\n",als);
    return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1e9+7;
ll dp[402][402],ar[402],pre[402];
ll summ(ll i,ll j)
{
	return (pre[j]-pre[i-1]);
}
int main()
{
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>ar[i];
		pre[i]+=ar[i]+pre[i-1];
	}
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i;j>=1;j--)
		{
			dp[j][i]=1e16;
			if(j == i)
			{
				dp[j][i]=0;
			}
			for(ll k=j;k<i;k++)
			{
				dp[j][i]=min(dp[j][i],dp[j][k]+dp[k+1][i]+summ(j,i));

			}
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}


Measured memory_bytes: 1536
def main():
    _ = int(input())
    a = [int(i) for i in input().split()]

    if 0 in a:
        print(0)
        return

    mul = 1
    for ai in a:
        mul *= ai
        if mul > 1000000000000000000:
            print(-1)
            return

    print(mul)

main()

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

#define int long long

signed main() 
{ 
	int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> v1,v2;
    int ans = 0;

    
    
    for(int i=0;i<n;i++){
        if(s[i] == 'W'){
            v1.push_back(i);
        }
        else
        {
            v2.push_back(i);
        }
        
    }
    if(v1.size()==0 || v2.size()==0){
        cout<<0;
        return 0;
    }
    int st = v1[0],c1=0,c2=v2.size()-1;
    int end = v2[v2.size()-1];

    while(st<end && c1<v1.size() && c2>=0){
        ans++;
        c1++;
        c2--;
        st = v1[c1];
        end = v2[c2];
    }
    cout<<ans;
	
} 


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long x=0;
    for(int i=0;i<n;i++){
        if(i%2) x -= a[i];
        else x += a[i];
    }
    vector<int> ans(n,0);
    ans[0]=x/2;
    for(int i=0;i<n-1;i++) ans[i+1]=a[i]-ans[i];

    for(auto t : ans) cout<<t*2<<endl;
}

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



int main(){
  int d,g;
  cin >> d >> g;
  vector<int> p(d),c(d);
  for(int i=0;i<d;++i) cin >> p[i] >> c[i];


  ll ans=1000000000000000;
  for(int bit=0;bit<(1<<d);++bit){
    ll sum=0;
    ll num=0;
    for(int i=0;i<d;++i){
      if(bit & (1<<i)){
        sum+=c[i]+p[i]*100*(i+1);
        num+=p[i];
      }
    }
    if(sum>=g) ans=min(ans,num);
    else{
      for(int i=d-1;i>=0;--i){
        if(bit & (1<<i)) continue;
        for(int j=0;j<p[i];++j){
          if(sum>=g) break;
          sum+=100*(i+1);
          ++num;
        }
      }
      ans=min(ans,num);
    }
  }

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


Measured memory_bytes: 3632
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
multiset<int> s;
int a[maxn];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    f1(i,n) cin>>a[i], s.insert(a[i]);
    f1(i,n)
    {
        s.erase(s.lower_bound(a[i]));
        cout << *s.rbegin() << "\n";
        s.insert(a[i]);
        
    }
    return 0;
}


Measured memory_bytes: 11776
N, K = map(int, input().split())
R, S, P = map(int, input().split())
score = {"r": P, "s": R, "p": S, "x": 0}
T = input()

ans = 0

for i in range(K):
    temp = []
    for j in range(i, N, K):
        if not temp:
            temp.append(T[j])
        else:
            if temp[-1] == T[j]:
                temp.append("x")
            else:
                temp.append(T[j])
        ans += score[temp[-1]]
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int x1, x2, x3, x4, x5; cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if(x1 == 0) cout << 1 << endl;
    else if(x2 == 0) cout << 2 << endl;
    else if(x3 == 0) cout << 3 << endl;
    else if(x4 == 0) cout << 4 << endl;
    else if(x5 == 0) cout << 5 << endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int N;
    string S;
    cin >> N >> S;
    bool flag = true;

    if (N % 2 == 0) {
        for (int i = 0; i < N/2; i++) {
            if (S.at(i) != S.at(i + (N/2))) {
                flag = false;
                break;
            }
        }
    }
    else flag = false;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import bisect

A, B, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = [int(stdin.readline().rstrip()) for _ in range(A)]
T = [int(stdin.readline().rstrip()) for _ in range(B)]
X = [int(stdin.readline().rstrip()) for _ in range(Q)]
S.append(10 ** 18)
T.append(10 ** 18)
S.insert(0, -10 ** 18)
T.insert(0, -10 ** 18)

for x in X:
    index_s = bisect.bisect_left(S, x)
    index_t = bisect.bisect_left(T, x)
    print(min(
        abs(S[index_s - 1] - T[index_t - 1]) + abs(x - S[index_s - 1]),
        abs(S[index_s - 1] - T[index_t - 1]) + abs(x - T[index_t - 1]),
        abs(S[index_s] - T[index_t - 1]) + abs(x - S[index_s]),
        abs(S[index_s] - T[index_t - 1]) + abs(x - T[index_t - 1]),
        abs(S[index_s] - T[index_t]) + abs(x - S[index_s]),
        abs(S[index_s] - T[index_t]) + abs(x - T[index_t]),
        abs(S[index_s - 1] - T[index_t]) + abs(x - S[index_s - 1]),
        abs(S[index_s - 1] - T[index_t]) + abs(x - T[index_t]),
    ))


Measured memory_bytes: 130140
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   long a = sc.nextLong();
   long b = sc.nextLong();
   long x = sc.nextLong();
   long low =0;
   long high = b/x +1;
   if(a==0) low=0;
   else low =(a-1)/x +1;
   
   System.out.println(high-low);
 }
}

Measured memory_bytes: 22736
from bisect import bisect_right

def main():    
    N = int(input())
    A = [int(input()) for i in range(N)]
    n = [A.pop(-1)]
    A.reverse()
    
    for a in A:
        if n[-1] <= a: n.append(a)
        else: n[bisect_right(n, a)] = a
    
    print(len(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int money = 100000; //返す金額
    int week = Integer.parseInt(reader.readLine());
    int roundingDigit = 1000; //何円に丸めるか
    
    for (int i = 0; i < week; i++) {
      money *= 1.05;
      money = floor(money, roundingDigit);
    }
    System.out.println(money);
  }

  public static int ceil(int n, int digit) {
    return n - (n % digit == 0 ? 0 : n % digit);
  }
  
  public static int floor(int n, int digit) {
    return n + (n % digit == 0 ? 0 : digit - n % digit);
  }
  
}

Measured memory_bytes: 15012
import bisect
H,W = map(int,input().split())
ans = H*W
for h in range(H):
    h1 = (H-h)//2 if (H-h)%2==0 else (H-h)//2+1
    Smax = max(h*W, h1*W)
    Smin = min(h*W, ((H-h)//2)*W)
    ans = min(ans, Smax-Smin)
    w1 = W//2 if W%2==0 else W//2+1
    Smax = max(h*W, (H-h)*w1)
    Smin = min(h*W, (H-h)*(W//2))
    ans = min(ans, Smax-Smin)
for w in range(W):
    w1 = (W-w)//2 if (W-w)%2==0 else (W-w)//2+1
    Smax = max(H*w, H*w1)
    Smin = min(H*w, H*((W-w)//2))
    ans = min(ans, Smax-Smin)
    h1 = H//2 if H%2==0 else H//2+1
    Smax = max(H*w, h1*(W-w))
    Smin = min(H*w, (H//2)*(W-w))
    ans = min(ans, Smax-Smin)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N,Y; cin>>N>>Y;
  REP(i,N+1){
    REP(j,N+1){
      if(Y==(10000*i+5000*j+1000*(N-i-j)) && (N-i-j)>=0) {
        cout<<i<<" "<<j<<" "<<N-i-j<<"\n";
        return 0;
      }
    }
  }

  cout<< -1<<" "<< -1<<" "<< -1<<"\n";
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
money = 0
li = [list(map(int, input().split())) for _ in range(n)]
li.sort()

for j in range(n):
    shop = li[j]
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)



Measured memory_bytes: 27760
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;
int x,y;
vector<int> vx;
vector<int> vy;

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 cout.precision(10);
 cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in", "r", stdin); 
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
 cin>>s;
 cin>>x>>y;
 int n=(int)s.size();
 bool now=0;//0->x,1->y
 int nowx=0;
 int nowy=0;
 for(int i=0;i<n;i++){
  if(s[i]=='T'){
   now=(bool)1-now;
   if(nowy!=0)vy.push_back(nowy);
   if(nowx!=0)vx.push_back(nowx);
   nowy=0;
   nowx=0;
   continue;
  }
  if(now){
   nowy++;
  }else{
   nowx++;
  }
 }
 //cerr<<1<<endl;
 if(nowx!=0)vx.push_back(nowx);
 if(nowy!=0)vy.push_back(nowy);
 nowx=0;
 if(s[0]!='T'){
  nowx=vx[0];
  vx.erase(vx.begin());
 }
 //cerr<<2<<endl;
 /*for(int i=0;i<(int)vy.size();i++){
  cout<<vy[i]<<" ";
 }
 cout<<endl;*/
 sort(vy.begin(),vy.end());
 reverse(vy.begin(),vy.end());
 sort(vx.begin(),vx.end());
 reverse(vx.begin(),vx.end());
 //cerr<<3<<endl;
 for(int i=0;i<(int)vx.size();i++){
  if(nowx>x){
   nowx-=vx[i];
  }else if(nowx<x){
   nowx+=vx[i];
  }else{
   nowx+=vx[i];
  }
 }
 //cerr<<4<<endl;
 nowy=0;
 for(int i=0;i<(int)vy.size();i++){
  if(nowy>y){
   nowy-=vy[i];
  }else if(nowy<y){
   nowy+=vy[i];
  }else nowy+=vy[i];
 }
 //show(nowx);
 //show(nowy);
 //cerr<<5<<endl;
 if(nowx==x && nowy==y)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define INF 2000000000

int main(){
	int n,t,i,j;
	int a[100000];
	scanf("%d%d",&n,&t);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	int mins[100000],maxs[100000]={0};maxs[n-1]=a[n-1];
	for(i=0;i<n;i++)mins[i]=INF;mins[0]=a[0];
	for(i=1;i<n;i++)mins[i]=min(mins[i-1],a[i]);
	for(i=n-2;i>=0;i--)maxs[i]=max(maxs[i+1],a[i]);
	int ans=0,dm=0;
	for(i=0;i<n;i++)dm=max(dm,maxs[i]-mins[i]);
	for(i=0;i<n;i++){
		if(maxs[i]-mins[i]==dm&&maxs[i]==a[i])ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  char buf[1002];
  fgets(buf, sizeof(buf), stdin);
  buf[strlen(buf)-1] = '\0';
  int w;
  scanf("%d", &w);
  for(size_t i = 0; i < strlen(buf); i += w) {
    putchar(buf[i]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,z=-1;
  bool x=false,y=false;
  cin>>A>>B;
  for(int i=0;i<1009;i++)
  {
    x=(i+1)*2/25==A?true:false;
    y=(i+1)/10==B?true:false;
    if(x==true&&y==true){z=i+1;break;}
  }
  cout<<z<<endl;
}

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

using namespace std;

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

  int n, X;
  cin >> n >> X;
  vector<int> x(n);
  for (auto &xx : x) cin >> xx;
  x.push_back(X);
  ++n;
  sort(x.begin(), x.end());
  int res = 0;
  for (int i = 1; i < n; ++i) {
    res = __gcd(res, x[i]-x[i-1]);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
  int n;
  while(~scanf("%d", &n) && n){
    vector<pair<int, int> > info(n);
    for(int i = 0; i < n; i++){
      scanf("%d %d", &info[i].second, &info[i].first);
    }
    sort(info.begin(), info.end());
    int many = 0;
    for(int i = 0; i < n; i++){
      if(info[i].first < many + info[i].second){
        many = -1;
        break;
      }
      many += info[i].second;
    }
    printf("%s\n", ~many ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 1016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;

		for (int i = 1; i <= N; i++) {
			String tmp = String.valueOf(i);
			if (tmp.length() % 2 != 0) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 28116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
  	int A,B,C,D;
  	cin>>A>>B>>C>>D;
  	int count=0;
  	int sw[101];
  	rep(i,101){
		sw[i]=0;
    }
  
  	for(int i=A;i<=B;i++){
     	sw[i]++;	 
    }
  	for(int j=C;j<=D;j++){
      	sw[j]++;
    }
  
  	rep(i,100){
     	if(sw[i]==2 && sw[i+1]==2) count++; 
    }
  	cout<<count<<endl;
}

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

int main(){
  int n,m; cin>>n>>m;
  vector<int> hw(m);
  for(int &i:hw)
    cin>>i;
  
  for(int i=0;i<m;i++)
    n-=hw[i];
  
  if(n>=0)
    cout<<n<<endl;
  else
    cout<<-1<<endl;
}


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

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

    int h, w;
    cin >> h >> w;
    int A[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> A[i][j];
        }
    }

    vector<pair<pair<int, int>, pair<int, int>>> Ope;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(A[i][j] % 2){
                if(i != h - 1){
                    A[i + 1][j]++;
                    Ope.push_back({{i + 1, j + 1},{i + 2, j + 1}});
                }else{
                    if(j != w - 1){
                        A[i][j + 1]++;
                        Ope.push_back({{i + 1, j + 1},{i + 1, j + 2}});
                    }
                }
            }
        }
    }

    cout << Ope.size() << endl;
    for(auto x: Ope){
        cout << x.first.first << ' ' << x.first.second << ' ' << x.second.first << ' ' << x.second.second << endl;
    }

    return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <queue>
#include<algorithm>
#include <vector>
#include<string>
#include<map>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	ll n;
	cin >> n;
	int sn = 0;
	ll a = n;
	while (a > 0) {
		sn += a % 10;
		a /= 10;
	}
	if (n%sn == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000005;

string str;
vector <char> v[2];
int fg=0;
int q;
int t1,t2;

signed main() {
    ios::sync_with_stdio(false);
    cin>>str;
    cin>>q;
    for(int i=1;i<=q;i++) {
        cin>>t1;
        if(t1==1) {
            fg^=1;
        }
        else {
            cin>>t2;
            char ch;
            cin>>ch;
            if(t2==1) {
                v[fg].push_back(ch);
            }
            else {
                v[fg^1].push_back(ch);
            }
        }
    }
    if(fg==0) {
        while(v[0].size()) cout<<v[0].back(), v[0].pop_back();
        cout<<str;
        for(char c:v[1]) cout<<c;
    }
    else {
        while(v[1].size()) cout<<v[1].back(), v[1].pop_back();
        reverse(str.begin(),str.end());
        cout<<str;
        for(char c:v[0]) cout<<c;
    }
}



Measured memory_bytes: 976
#include<iostream>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];int &t=p[B|1<<i][k];R(j,k+1)t=min(t,p[B][j]+d[i]);}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}

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

const int D = 365, T = 26;

vector<int> c(T);
vector<vector<int>> s(D, vector<int>(T));
vector<vector<int>> pena(T, vector<int>(D + 2));

struct State {
    vector<int> ct;
    vector<vector<int>> h;
    State() : ct(D), h(T) {
        for(int t = 0; t < T; ++t) {
            h[t].push_back(-1);
            h[t].push_back(D);
        }
    }
    void add(int d, int i) {
        auto it = lower_bound(h[i].begin(), h[i].end(), d);
        h[i].insert(it, d);
        ct[d] = i;
    }
    void rmv(int d) {
        h[ct[d]].erase(remove(h[ct[d]].begin(), h[ct[d]].end(), d), h[ct[d]].end());
    }
    int calc_each(int i) {
        int res = 0;
        for(auto &d : h[i]) {
            if(d == -1 || d == D) continue;
            res += s[d][i];
        }
        for(int d = 0; d < h[i].size() - 1; ++d) {
            res -= pena[i][h[i][d + 1] - h[i][d]];
        }
        return res;
    }
    int calc() {
        int res = 0;
        for(int t = 0; t < T; ++t) res += calc_each(t);
        return res;
    }
    int calc_diff(int d, int p, int q) {
        int res = s[d][q] - s[d][p];
        {
            auto it = lower_bound(h[p].begin(), h[p].end(), d);
            int r = *next(it) - d, l = d - *prev(it);
            res -= pena[p][l + r] - pena[p][r] - pena[p][l];
        }
        {
            auto it = lower_bound(h[q].begin(), h[q].end(), d);
            int r = *it - d, l = d - *prev(it);
            res += pena[q][l + r] - pena[q][r] - pena[q][l];
        }
        return res;
    }
    void output() {
        for(int i = 0; i < D; ++i) cout << ct[i] + 1 << '\n';
    }
};

State best;

void input() {
    int _; cin >> _;
    for(int i = 0; i < T; ++i) cin >> c[i];
    for(int i = 0; i < D; ++i) {
        for(int j = 0; j < T; ++j) cin >> s[i][j];
    }
}

void init() {
    for(int i = 0; i < D; ++i) {
        int t; cin >> t;
        t--;
        best.add(i, t);
    }
    for(int t = 0; t < T; ++t) {
        for(int i = 2; i <= D + 1; ++i) {
            pena[t][i] = pena[t][i - 1] + c[t] * (i - 1);
        }
    }
}

int main() {
    input();
    init();
    int now = best.calc();
    int M; cin >> M;
    while(M--) {
        int d, q;
        cin >> d >> q;
        d--, q--;
        int p = best.ct[d];
        now += best.calc_diff(d, p, q);
        best.rmv(d);
        best.add(d, q);
        cout << now << '\n';
    }
    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a[201];
int b[201];
int c[201];
int main()
{
	int i,j,l,n,sum=0;
	cin>>n>>l;
	for(i=1;i<=n;i++)
	{
		a[i]=l+i-1;
		sum+=a[i];
	}
	for(i=1;i<=n;i++)
	{
		b[i]=sum-a[i];
		c[i]=abs(sum-b[i]);
	
	}
	for(i=1;i<=n-1;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(c[j]>c[j+1])
			{
				swap(b[j],b[j+1]);
				swap(c[j],c[j+1]);
			}
				
		}
	}
	cout<<b[1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

set<int> s;

ll solve(ll n) {
  ll ans = 0;
  for (ll i = 2; i*i <= n; ++i) {
    if ((n%i) == 0) {
      ll m = n;
      while ((m%i) == 0) m /= i;
      if (m % i == 1) ++ans;
    }
  }
  --n;
  for (ll i = 1; i*i <= n; ++i) {
    if ((n%i) == 0) {
      if (i > 1) ++ans;
      if (i*i < n) ++ans;
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  ll ans = solve(n)+1;
  cout<<ans<<endl;
  return 0;
}


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

int main(void){
	int size;
	int *A;
	int i;

	scanf("%d",&size);

	A=(int*)malloc(sizeof(int)*(size+1));

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

	for(i=1;i<=size;i++){
		printf("node %d: ",i);
		printf("key = %d, ",A[i]);
		if(i/2 > 0) printf("parent key = %d, ",A[i/2]);
		if(2*i <= size) printf("left key = %d, ",A[2*i]);
		if(2*i+1 <= size) printf("right key = %d, ",A[2*i+1]);
		printf("\n");
	}

	return 0;
}

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

#define int long long

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

const int N = 1e5 + 5;
int a[N], p[64];

void insert(int x)
{
	for (int i = 60; i >= 0; --i) if (x >> i)
	{
		if (p[i]) x ^= p[i];
		else { p[i] = x; break; }
	}
}

signed main()
{
	int n = read(), sum = 0, ans = 0;
	for (int i = 1; i <= n; ++i) sum ^= (a[i] = read());
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= 60; ++j)
			if ((sum >> j & 1) && (a[i] >> j & 1))
				a[i] -= (1LL << j);
	
	for (int i = 1; i <= n; ++i) insert(a[i]);
	for (int i = 60; i >= 0; --i) 
		if ((ans ^ p[i]) > ans) ans ^= p[i];
	
	printf("%lld\n", ans + (sum ^ ans));
	
	return 0;
}


Measured memory_bytes: 896
# coding: utf-8
# Your code here!
import math

tanshin,choshin,jikan,hun=map(int,input().split(" "))

x1=tanshin*math.cos(math.radians(-(jikan*30+hun*0.5-90)))
y1=tanshin*math.sin(math.radians(-(jikan*30+hun*0.5-90)))
x2=choshin*math.cos(math.radians(-(hun*6-90)))
y2=choshin*math.sin(math.radians(-(hun*6-90)))
ans=math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
print(ans)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007
#define ABS(x ,y) (x) > (y) ? (x) - (y) : (y) - (x)

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int x[N + 1], y[N + 1], t[N + 1];
    x[0] = 0;
    y[0] = 0;
    t[0] = 0;
    REP(i, N)
    {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    bool reachable = true;
    REP(i, N)
    {
        int xDiff = ABS(x[i + 1], x[i]);
        int yDiff = ABS(y[i + 1], y[i]);
        int tDiff = t[i + 1] - t[i];
        if (xDiff + yDiff > tDiff)
        {
            reachable = false;
            break;
        }
        else
        {
            if ((tDiff - (xDiff + yDiff)) % 2 != 0)
            {
                reachable = false;
                break;
            }
        }
        
    }
    string ans;
    ans = reachable ? "Yes" : "No";

    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int maxn = 2e5 + 10;
int a[maxn];
int n, m;
int check(int mid) {
	int res = 0;
	for(int i = 1; i <= n - mid; i++) { // 2*mid+1 ~ 2*n
		if(a[2 * mid + i] + a[2 * n - i + 1] < m) return -1;
		res = max(res, a[2 * mid + i] + a[2 * n - i + 1] - m);
	}
	for(int i = 1; i <= mid; i++) { // 1 ~ 2*mid
		res = max(res, (a[i] + a[2 * mid - i + 1]) % m);
	}
	return res;
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= 2 * n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 2 * n + 1);
//	for(int i = 1; i <= 2 * n; i++) printf("%d ", a[i]); puts("");
	int l = 0, r = n;
	while(l < r) {
		int mid = (l + r) >> 1;
		int tmp = check(mid);
		if(tmp == -1) l = mid + 1;
		else r = mid;
	}
	printf("%d\n", check(l));
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;


int main(){
    ll N; cin >> N;
    string S; cin >> S;
    ll c = 0;
    for(int i=0; i<1000; i++){
        char k, l, m; string p;
        if(i<10){
            k = '0';
            l = '0';
            p = to_string(i);
            m = p[0];
        }
        else if(i<100){
            k = '0';
            p = to_string(i);
            l = p[0];
            m = p[1];
        }
        else{
            p = to_string(i);
            k = p[0];
            l = p[1];
            m = p[2];
        }
        ll h = 0;
        for(int j=0; j<N; j++){
            if(h == 0){
                if(S[j] == k){
                    h++;
                }
            }
            else if(h == 1){
                if(S[j] == l){
                    h++;
                }
            }
            else if(h == 2){
                if(S[j] == m){
                    h++;
                }
            }
            else{
                continue;
            }
        }
        if(h == 3){
            c++;
        }
    }
    cout << c;
}

Measured memory_bytes: 256
S = list(input())
ans = "Yes"
cnt = 0
for s in S:
    if s == "U" or s == "D":
        cnt += 1
        continue
    elif cnt % 2 == 0 and s == "L":
        cnt += 1
        ans = "No"
        break
    elif cnt % 2 == 1 and s == "R":
        cnt += 1
        ans = "No"
        break
    else:
        cnt += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,r,x,tmp;
  cin>>a>>b;
  x=a*b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
   cout<<x/b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() { 
char c;
cin >> c;
if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') { 
  cout << "vowel" << endl;
}
else {
  cout << "consonant" << endl;
}
}


Measured memory_bytes: 256
while true
line = gets.split.map(&:to_i)
break if line[0] == 0
x,y = line.sort[0..1]
min = Math.sqrt(x*x + y*y)
n = gets.chomp.to_i
  n.times do
    r = gets.chomp.to_i
  puts min < 2 * r ? "OK" : "NA"
  end
end


Measured memory_bytes: 6848
n = gets.to_i
cnt = 0

while n > 0
    if n / 10 != 0 and n % 10 != 9
        n -= n % 10 + 1
        cnt += n % 10
        n /= 10
    else
        cnt += n % 10
        n /= 10
    end
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define foru(i,a,n) for(ll i=(a); i<=(n); ++i)
#define ford(i,n,a) for(ll i=(n); i>=(a); --i)
using namespace std;
const int inf = 1e9;
const int N = 3030;
ll n, a[N], dp[N][N], vis[N][N];

ll sol(int L, int R){
	if(L==R) return a[L];
	if(vis[L][R]) return dp[L][R];
	vis[L][R] = 1;
	ll chontrai = a[L] - sol(L+1, R);
	ll chonphai = a[R] - sol(L, R-1);
	return dp[L][R] = max(chonphai, chontrai);
}

int main() {
	//freopen("a.in","r",stdin);
	ios::sync_with_stdio(0);
	cin >>n;
	foru(i,1,n) cin >>a[i];

	memset(vis, 0, sizeof(vis));
	//sol(1,n,0) bat dau tu player 1 chon la bai tu a[1]..a[n]
	cout <<sol(1, n);
    
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

Measured memory_bytes: 143744
#include <bits/stdc++.h>
#define fast_io ios :: sync_with_stdio(false); cin.tie(NULL)
#define ultimo 26;
using namespace std;
int main(){
fast_io;
int n;
string s;
cin>>n;
cin>>s;
int j=0;
char aux;
int aux2;
for(int i=0;i<s.size();i++){
    if(s[i]+n<='Z'){
    aux= s[i]+n;
    cout<<aux;
    }
    else {
    aux2=(s[i]+n)-ultimo;
    aux=aux2;
    cout<<aux;
    }
    j++;
}
    return(0);
}


Measured memory_bytes: 3688
Scanf.scanf "%d" (fun n ->
    let rec loop i acc =
        if i = n then acc else
            let acc = Scanf.scanf " %d %d" (fun l r -> acc + r - l + 1) in
            loop (i + 1) acc
    in
    loop 0 0 |> Printf.printf "%d\n"
)


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

const int N = 128;

char erst[N], str[N];

int main() {
#ifdef HOME
	freopen("agc16a.in", "r", stdin);
	freopen("agc16a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int cnt, ant;
	bool flag, eq;

	ant = 1e9;

	cin >> erst;
	for (char ch = 'a'; ch <= 'z'; ++ch) {
		strcpy(str, erst);

		cnt = 0;
		while (true) {
			flag = eq  = true;
			for (int i = 0; str[i]; ++i) {
				flag&= str[i] != ch;
				eq&= str[i] == ch; }

			if (eq)
				break;
			if (flag) {
				cnt = 1e9;
				break; }

			cnt+= 1;
			for (int i = 0; str[i]; ++i)
				if (str[i + 1] == '\0' || str[i + 1] == ch)
					str[i] = str[i + 1]; }

		ant = min(ant, cnt); }

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    ll MOD = 1e9+7;

    ll m[k+1] = {};
    drep(i,k+1){
        ll ii = i;
        if(i == 0)break;
        int x = k / i; 
        m[i] += mod_pow(x, n, MOD);
        m[i] %= MOD;
        ans += ii * m[i] % MOD;
        ans %= MOD;
        // cout << i << ' ' << m[i] << endl;
        if(i == 1)continue;
        m[1] += (MOD - m[i]);
        srep(j, 2, i){
            if(j * j > i){
                break;
            }else if(j * j == i){
                m[j] += (MOD - m[i]);
            }else if(i % j == 0){
                m[j] += (MOD - m[i]);
                m[i/j] += (MOD - m[i]);
            }
        }
    }
    /*
    rep(i, k+1) cout << m[i] << ' ';
    cout << endl;
    */
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 4412
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[111];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(register int i=1;i<len;++i)
		if(s[i]=='A'&&s[i+1]=='C'){puts("Yes");return 0;}
	puts("No");
	return 0;
}




Measured memory_bytes: 128
dance=input()
i=1
easydance=True
for dancestep in dance:
   if i%2==1:
       if dancestep=="L":
           easydance=False
   elif i%2==0:
       if dancestep=="R":
           easydance=False
   i+=1

if easydance==True:
    print("Yes")

else:
    print("No")

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

int main() {
    int N; cin >> N;
    vector<long long> a(N), b(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) cin >> b[i];
    long long biggerA = 0, biggerB = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] > b[i]) biggerA += a[i] - b[i];
        if (b[i] > a[i]) biggerB += (b[i] - a[i])/2;
    }
    if (biggerB >= biggerA) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main()
{
	string s;
	cin>>s;
	int alphabet[26]={0};
	for(int i=0;i<s.length();i++){
		alphabet[s[i]-'a']=1;
	}
	for(int i=0;i<26;i++){
		if(!alphabet[i]){
			printf("%c",'a'+i);
			return 0;
		}
	}
	printf("None");
	return 0;
}

Measured memory_bytes: 512
N = str(input())
#print(N)
len(N)

#１文字削る
N = N[:len(N)-1]

#条件式　文字列の長さが偶数かどうか
#偶数でなければ1文字削る
while True:        
    if len(N) % 2 != 0:
#        print(N)
        N = N[:len(N)-1]
 #       print(N)
    else:
        N1 = N[:len(N)//2]
        N2 = N[len(N)//2:]
  #      print(N1,N2)
        if N1 == N2:
   #         print(N1,N2)
            print(len(N))
            break
        else:
            N = N[:len(N)-1]

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	map<int,int>tot;int ans=0;
	for (int n=gi();n--;) tot[gi()]++;
	for (auto t:tot)
		ans+=t.first<=t.second?t.second-t.first:t.second;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    vector<int> score(n + 1);
    for (int i = 0; i < m; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            int b;
            cin >> b;
            if (b == a[i]) ++score[j + 1];
            else ++cnt;
        }
        score[a[i]] += cnt;
    }
    for (int i = 1; i <= n; ++i) {
        cout << score[i] << '\n';
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <map>
#include <utility>

#define abs(X) ((X) < 0 ? -(X) : (X))

using namespace std;

int sum[90005];
pair<int, int> point[90005];

int main()
{
    int h, w, d;
    int q;
    int l, r;
    int a;
    
    cin >> h >> w >> d;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a;
            point[a] = make_pair(i, j);
        }
    }

    for (int i = 1; i <= d; i++) {
        int x = i;

        sum[x] = 0;

        while (x + d <= h * w) {
            sum[x + d] = sum[x] + abs(point[x + d].first - point[x].first) +
                abs(point[x + d].second - point[x].second);

            x += d;
        }
    }
         
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> l >> r;

        cout << sum[r] - sum[l] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2176
N,T=map(int,input().split())
flag=1001
for _ in range(N):
    c,t=map(int,input().split())
    if t>T:
        continue
    else:
        count=c
        if count<=flag:
            flag=count

if flag==1001:
    print("TLE")
else:
    print(flag)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

typedef long long ll;

ll n, x, y;
ll a[200005], b[200005];
map<pair<ll, ll>, ll> ma;

ll fnd1(ll p)
{
    if(a[p] == p) return p;
    else return a[p] = fnd1(a[p]);
}

ll fnd2(ll p)
{
    if(b[p] == p) return p;
    else return b[p] = fnd2(b[p]);
}

int main()
{
    scanf("%lld%lld%lld", &n, &x, &y);
    for(ll i = 1; i <= n; i++) a[i] = b[i] = i;
    for(ll i = 0; i < x; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        if(fnd1(t1) != fnd1(t2)) a[fnd1(t1)] = fnd1(t2);
    }
    for(ll i = 0; i < y; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        if(fnd2(t1) != fnd2(t2)) b[fnd2(t1)] = fnd2(t2);
    }
    for(ll i = 1; i <= n; i++)
    {
        ma[{fnd1(i), fnd2(i)}]++;
    }
    for(ll i = 1; i <= n; i++)
    {
        printf("%lld ", ma[{fnd1(i), fnd2(i)}]);
    }
    return 0;
}


Measured memory_bytes: 15104
#include <stdio.h>

int main()
{
    int i,j;
    long long int n,sum=0,sumo=0,mod = 1000000007;
    scanf("%lld",&n);
    long long int str[n];
    for(i=0; i<n; i++)
    {
        scanf("%lld",&str[i]);
    }
    for(i=n-1; i>=0; i--)
    {
        sum+=str[i]*sumo;
        sumo+=str[i];
        sum%=mod;
        sumo%=mod;
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  ll n, p;
  cin >> n >> p;
  ll ans = 1;
  ll q = p;
  if (n == 1) {cout << p << endl; return 0;}
  for (ll i = 2; i*i <= q; i++)
  {
    int ex = 0;
    while (p % i == 0)
    {
      p /= i;
      ex++;
    }
    rep(j,ex/n) ans *= i;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

int main(){
    int n, m;
    cin>>n>>m;
    int b[51]={0};
    int a;
    while(cin>>a) b[a-1]++;
    for(int i=0; i<n; i++) cout<<b[i]<<endl;
    
}


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

vector<int> a;

int main(){
  int n, i, x;
  cin >> n >> x;
  a.push_back(x);
  for(i = 0; i < n; i++){
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int g = a[1]-a[0];
  for(i = 2; i < a.size(); i++){
    g = __gcd(g, a[i]-a[i-1]);
  }
  cout << g << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define pb push_back
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sc(a) scanf("%I64d", &a)
#define pr(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<int,int>
#define PII pair<LL,LL>
#define MAX 600005
#define CASE(i) printf("Case %d:", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)
#define CHECK_BIT(var,pos) ((var & (1 << pos)) == (1 << pos))

using namespace std;
//
LL MOD = 1000000007;
//
//LL bigmod(LL a, LL b){
//    LL x = 1, y = a%MOD;
//    while(b > 0) {
//        if(b%2 == 1) {
//            x=(x*y);
//            if(x>MOD) x%=MOD;
//        }
//        y = (y*y);
//        if(y>MOD) y%=MOD;
//        b /= 2;
//    }
//    return x;
//}
//
//LL MODINVERSE(LL a){
//    return bigmod(a, MOD-2);
//}

//LL dp[900][1000];
//LL NCR(int n, int r)
//{
//    if(r==1) return n;
//    else if(n==r) return 1;
//    else
//    {
//        if(dp[n][r]!=-1) return dp[n][r];
//        else
//        {
//            dp[n][r]=NCR(n-1,r) + NCR(n-1,r-1);
//            return dp[n][r];
//        }
//    }
//}

const int MAXN = 1050;
int status[(MAXN/32)+10];

bool check(int n, int pos) { return (bool)(n & (1<<pos)); }
int SET(int n, int pos){ return n=n|(1<<pos);}

void sieve()
{
    int sqrtN=int (sqrt(MAXN));
    status[1>>5]=SET(status[1>>5],1&31);
    for(int j=4; j<=MAXN; j=j+2)
        status[j>>5]=SET(status[j>>5],j&31);
    for(int i=3; i<=sqrtN; i=i+2)
    {
        if(check(status[i>>5],i&31)==0)
        {
            for(int j=i*i; j<=MAXN; j= j + (i<<1))
            {
                status[j>>5]=SET(status[j>>5],j&31);
            }
        }
    }
}

LL arr[100005];

int main()
{
    LL N, K, X, Y;
    scanf("%lld %lld %lld %lld", &N, &K, &X, &Y);
    if(N<K) K = N;
    LL cost = X*K + Y*(N-K);
    printf("%lld", cost);

}


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

int main(){
	int N, count = 0;
	vector<int> v;
	cin >> N;
	for(int i=0;i<N;i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
		while(v[i]%2==0){
			v[i]/=2;
			count++;
		}
		
	}
	cout << count << endl;
	return 0;
}

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

namespace ABC138
{
    class Program
    {
        static void Main(string[] args)
        {
            A();

            Console.Read();
        }


        static void A()
        {
            int a = int.Parse(Read());
            string s = Read();
            if (a >= 3200) Show(s);
            else Show("red");
        }





        static string Read() { return Console.ReadLine(); }
        static void Show(string s) { Console.WriteLine(s); }
    }
}


Measured memory_bytes: 11092
n = int(input())
hn = list(map(int, input().split()))

maxi = 0
cnt = 0
h0 = hn[0]
for hi in hn[1:]:
  if hi <= h0:
    cnt += 1
  else:
    maxi = max(maxi, cnt)
    cnt = 0
  h0 = hi
maxi = max(maxi, cnt)
print(maxi)

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


int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i) cin >> H[i];

    bool ans = true;
    --H[0];
    for(int i = 0; i < N; ++i){
        if(H[i] < H[i-1]){
            ans = false;
            break;
        }
        if(H[i] > H[i-1]) --H[i];
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,l;
	cin >>n >>l;
	
	int df=1<<30, svi=0;
	rep2(i,1,n+1){
		int x=abs(l+i-1 );
		if(df > x){
			df=x; svi=i;
		} 
	}
	//dbg(svi);
	ll ans=0;
	rep2(i,1,n+1){
		if(i !=svi) ans += l+i-1;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
/*
日本でよく使われる紙幣は、10000円札、5000円札、1000円札です。以下、「お札」とはこれらのみを指します。

青橋くんが言うには、彼が祖父から受け取ったお年玉袋にはお札が
N枚入っていて、合計でY円だったそうですが、嘘かもしれません。
このような状況がありうるか判定し、ありうる場合はお年玉袋の中身の候補を一つ見つけてください。なお、彼の祖父は十分裕福であり、お年玉袋は十分大きかったものとします。
*/

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, Y;
  int yen10000, yen5000, yen1000;
  bool flag = false;
  cin >> N >> Y;

  for (int i = 0; i <= N; i++) {
    yen10000 = 10000 * i;
    for (int j = 0; j <= N - i; j++) {
      yen5000 = 5000 * j;
      yen1000 = 1000 * (N - i - j);
      if (yen10000 + yen5000 + yen1000 == Y) {
        cout << i << " " << j << " " << N - i - j << endl;
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  if (!flag) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3636