akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string X;
  cin >> X;
  int N = X.size();
  int c = 0;
  int LOL = 0;
  vector<int> vec(0);
  rep(i, N) {
    if(X.at(i) == 'X') {
      
    }
    else {
      rep2(j, i, N) {
        if(X.at(i) == X.at(j)) {
          c++;
          vec.push_back(j);
        }
      }
      vec.push_back(i);
      rep(j, vec.size()) {
        X.at(vec.at(j)) = 'X';
      }
      if(c % 2 == 1) {
        LOL++;
        break;
      }
    }
  }
  if(LOL > 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << '\n';
}


Measured memory_bytes: 3632
x, n = map(int, input().split())

ps = list(map(int, input().split()))

seen = [0]*(100+2)

for p in ps:
    seen[p] = 1

if seen[x] == 0:
    print(x)
    exit()

count = 1
candidate = []
while True:
    nside = max(0, x - count)
    if seen[nside] == 0:
        candidate.append(nside)
        print(nside)
        exit()

    pside = min(102, x + count)
    if seen[pside] == 0:
        candidate.append(pside)
        print(pside)
        exit()
    count += 1


Measured memory_bytes: 9208
#include<stdio.h>


int max(int a,int b){

  if(a>b){
    return a;
  }else{
    return b;
  }

}

int gcd(int a,int b){
  int r,tmp;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  r=a%b;
  while(r!=0){
  a=b;
  b=r;
  r=a%b;
}

  return b;
}

int main(void){
  int n;
  int a[120000];
  int i;
  int ans=0;
  int p[120000];
  int q[120000];
  int tmpg;
  int tmpt;
  int tmps;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  p[0]=a[0];
  tmpg=a[0];

  for(i=1;i<n-1;i++){
    tmpg=gcd(a[i],tmpg);
    p[i]=tmpg;
  }
  q[n-1]=a[n-1];
  tmpt=a[n-1];

  for(i=(n-2);i>0;i--){
    tmpt=gcd(a[i],tmpt);
    q[i]=tmpt;
    }





  ans=max(p[n-2],q[1]);


  for(i=1;i<n-1;i++){
      tmps=gcd(p[i-1],q[i+1]);
      if(tmps>ans){
        ans=tmps;
      }
  }


  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

template <typename T>
inline bool read(T& ret) {
    T x = 0, f = 1; char ch = getchar();
    while(ch!=EOF && (ch > '9' || ch < '0')) { if(ch == '-') f = -1; ch = getchar();  }
    if(EOF==ch)return false;
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    ret = x * f;
    return true;
}


inline char nc() {
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
bool rn(T& v) {
    static char ch;
    while (ch != EOF && !isdigit(ch)) ch = nc();
    if (ch == EOF) return false;
    for (v = 0; isdigit(ch); ch = nc())
        v = v * 10 + ch - '0';
    return true;
}

template <typename T>
void o(T p) {
    static int stk[70], tp;
    if (p == 0) { putchar('0'); return; }
    if (p < 0) { p = -p; putchar('-'); }
    while (p) stk[++tp] = p % 10, p /= 10;
    while (tp) putchar(stk[tp--] + '0');
}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



void Solve(){
}


int main(){
#ifdef L_JUDGE
    freopen("in1.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int T;
    string s;
    cin>>s;
    if(s=="RRR"){
        cout<<3<<endl;
    }else if(s=="RRS"){
        cout<<2<<endl;
    }else if(s=="RSR"){
        cout<<1<<endl;
    }else if(s=="RSS"){
        cout<<1<<endl;
    }else if(s=="SRR"){
        cout<<2<<endl;
    }else if(s=="SRS"){
        cout<<1<<endl;
    }else if(s=="SSR"){
        cout<<1<<endl;
    }else if(s=="SSS"){
        cout<<0<<endl;
    }


    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}


Measured memory_bytes: 3184
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int a[20][20];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<pair<int, int> > z;
    int i;
    for (i = 0; i < n; i++) {
        double tmp;
        scanf("%lf", &tmp);
        ll aa=(ll)(tmp * 1000000000 + 0.1);
        assert(aa);
        int cnt0 = 0, cnt1 = 0;
        {
            ll bb = aa;
            while (bb%2==0) {
                bb /= 2;
                cnt0++;
            }
        }
        {
            ll bb = aa;
            while (bb%5==0) {
                bb /= 5;
                cnt1++;
            }
        }
        cnt0 = MIN(cnt0, 18);
        cnt1 = MIN(cnt1, 18);
        z.push_back(make_pair(cnt0, cnt1));
        //printf("%d %d\n", cnt0, cnt1);
        a[cnt0][cnt1]++;
    }

    ll sum = 0, sum2 = 0;;
    for (i = 0; i < n; i++) {
        int cnt0 = z[i].first, cnt1 = z[i].second;
        if (cnt0 >= 9 && cnt1 >= 9) sum2++;
        int lim0 = 18 - cnt0, lim1 = 18 - cnt1;
        int j, k;        
        for (j = lim0; j < 20; j++) {
            for (k = lim1; k < 20; k++) {
                sum += a[j][k];
            }
        }
    }
    printf("%lld\n", (sum - sum2) / 2);

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 4868
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll N = 3005;
ll dp[N][N], a[N], sum[N], n;
ll f(int l, int r){
    return sum[r] - sum[l - 1];
}
ll calc(int l, int r){
    if(l > r)return 0;
    if(dp[l][r] != 0)return dp[l][r];
    return dp[l][r] = f(l, r) - min(calc(l + 1, r), calc(l, r - 1));
}
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    cout << 2 * calc(1, n) - sum[n] << endl; 
}    

Measured memory_bytes: 70144
N = int(input())
X_1 = 9
X_2 = 900
X_3 = 90000
if N < 10:
  X = N
elif N < 10**2:
  X = X_1
elif N < 10**3:
  X = (N - 99) + X_1
elif N < 10**4:
  X = X_1 + X_2
elif N < 10**5:
  X = (N - 9999) + X_1 + X_2
elif N == 10**5:
  X = X_1 + X_2 + X_3

print(X)

Measured memory_bytes: 3060
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int m, k; cin >> m >> k;
  if(m == 0) {
    if(k == 0) {
      cout << "0 0\n";
    } else {
      cout << "-1\n";
    }
  } else if(m == 1) {
    if(k == 0) {
      cout << "0 0 1 1\n";
    } else {
      cout << "-1\n";
    }
  } else {
    if(k < (1 << m)) {
      if(k == 0) {
        for(int i = 0; i < (1 << m); i++) {
          cout << i << " " << i << " \n"[i + 1 == (1 << m)];
        }
      } else {
        cout << "0 " << k << " 0 ";
        for(int i = 1; i < (1 << m); i++) {
          if(i == k) continue;
          cout << i << " ";
        }
        cout << k << " ";
        for(int i = (1 << m) - 1; i >= 1; i--) {
          if(i == k) continue;
          cout << i << " \n"[i == 1];
        }
      }
    } else {
      cout << "-1\n";
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  int a,b;
  cin>>a>>b;
  if(a==b) cout<<a+b<<endl;
  else cout<<max(a,b)*2-1<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import *
n=int(input())
a=list(map(int,input().split()))
b=sorted(set(a))[::-1]
d=defaultdict(int)
wid=0
hei=0
for i in a:
  d[i]+=1
for i in b:
  if(d[i]>3):
    if(wid==0):wid,hei=i,i
    else:hei=i
    break
  elif(d[i]>1):
    if(wid==0):wid=i
    else:
      hei=i
      break
print(wid*hei)


Measured memory_bytes: 21028
unittest
{
	assert( [ "bac" ].parse.expand.solve == "Yes" );
	assert( [ "bab" ].parse.expand.solve == "No" );
	assert( [ "aaa" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.strip;
	return tuple( s );
}

auto solve( string s )
{
	auto ss = s.to!( dchar[] ).sort();
	return ss.equal( "abc" ) ? "Yes" : "No";
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.text.DecimalFormat;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		for (int i = sc.nextInt(); i > 0; i--)
		{
			double x1 = sc.nextFloat();
			double y1 = sc.nextFloat();
			double x2 = sc.nextFloat();
			double y2 = sc.nextFloat();
			double x3 = sc.nextFloat();
			double y3 = sc.nextFloat();
		
			//(lhx, lhy)ツ湘」ツづ畦aツづ個陳シツ静シツ湘」
			double la;
			double lhx;
			double lhy;
			if (y1 != y2)
			{
				la = -1.0 * (x1 - x2) / (y1 - y2);
				lhx = (x1 + x2) / 2.0;
				lhy = (y1 + y2) / 2.0;
			}
			else
			{
				la = -1.0 * (x3 - x2) / (y3 - y2);
				lhx = (x3 + x2) / 2.0;
				lhy = (y3 + y2) / 2.0;
			}
			//(mhx, mhy)ツ湘」ツづ稽aツづ個陳シツ静シツ湘」
			double ma;
			double mhx;
			double mhy;
			if (y1 != y3)
			{
				ma = -1.0 * (x1 - x3) / (y1 - y3);
				mhx = (x1 + x3) / 2.0;
				mhy = (y1 + y3) / 2.0;
			}
			else
			{
				ma = -1.0 * (x3 - x2) / (y3 - y2);
				mhx = (x3 + x2) / 2.0;
				mhy = (y3 + y2) / 2.0;
			}
		
			double x = (lhy - mhy + ma * mhx - la * lhx) / (ma - la);
			double y = la * (x - lhx) + lhy;
		
		
			DecimalFormat df = new DecimalFormat();
			df.applyLocalizedPattern("0.000");
		
			System.out.print(df.format(x) + " " + df.format(y) + " ");
			System.out.println(df.format(Math.sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1))));
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if(a<=c&&c<=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
s = input()


def lower_checker(ss):

    for k in ss:
        if k != 'A' and k != 'C' and k.islower() is False:
            return False
    return True

def C_counter(ss):
    cnt = 0
    for k in ss:
        if k == 'C':
            cnt += 1
    if cnt == 1:
        return True
    else:
        return False

flag = True
if s[0] != 'A':
    flag = False
if flag is False or C_counter(s[2:-1]) is False:
    flag = False
if flag is False or lower_checker(s) is False:
    flag = False

if flag:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    string s;
    cin>>s;
    if(s=="ooo") cout<<"1000"<<endl;
    else if(s=="oox") cout<<"900"<<endl;
    else if(s=="xoo") cout<<"900"<<endl;
    else if(s=="oxo") cout<<"900"<<endl;
    else if(s=="xxx") cout<<"700"<<endl;
    else cout<<"800"<<endl;
}


Measured memory_bytes: 3128
A, B, C = sorted(map(int, input().split()))
if (C-B) % 2 and (C-A) % 2 == 0:
    C += 1
    A += 1
    print((C-B)//2+(C-A)//2+1)
elif (C-B) % 2 and (C-A) % 2:
    B += 1
    A += 1
    print((C-B)//2+(C-A)//2+1)
elif (C-B) % 2 == 0 and (C-A) % 2:
    B += 1
    C += 1
    print((C-B)//2+(C-A)//2+1)
else:
    print((C-B)//2+(C-A)//2)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] len = new long[n];
		for(int i = 0 ; i<n; i++){
			len[i] = sc.nextInt();
		}
		Arrays.sort(len);
		long res = 0;
		for(int i = 0 ; i<len.length-1; i++){
			for(int j = i+1 ; j<len.length-1; j++){
				for(int k = j+1 ; k<len.length; k++){
					if(! (len[i]+len[j] > len[k]))break;
					res++;
				}
			}
		}
		System.out.println(res);
	}
}


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

void solve () {
    long long n, m;
    cin >> n >> m;
    map<int, int> mp;
    for (int i = 0; i < m; i++) {
        int x; cin >> x;
        mp[x] = 1;
    }
    vector<long long> fibo(2);
    fibo[0] = 0;
    fibo[1] = 1;
    long long md = 1e9 + 7;
    for (int i = 1; i <= n; i++) {
        long long x = fibo[0] + fibo[1];
        fibo[0] = fibo[1];
        if (mp.count(i)) {
            x = 0;
        }
        fibo[1] = x % md;
    }
    cout << fibo[1] << endl;

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


Measured memory_bytes: 8204
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int[] w = new int[n+1];
    int[] b = new int[n+1];
    for(int i = 1;i <= n;i++){
      if(s.charAt(i-1)=='.'){
        w[i]=w[i-1]+1;
        b[i]=b[i-1];
      }else{
        w[i]=w[i-1];
        b[i]=b[i-1]+1;
      }
    }
    int min = 1000000000;
    for(int i = 0;i <= n;i++){
      min = Math.min(min,b[i]+w[n]-w[i]);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 28696
import math

n, k = [int(i) for i in input().split()]

t = [[1 for i in range(k)] for j in range(k)]

for i in range(2, k):
    for j in range(1, i):
        t[i][j] = t[i-1][j-1]+t[i-1][j]

cnt = 0
for i in range(k):
    if i <= n-k:
        ans = math.factorial(n-k+1)//(math.factorial(i+1)*math.factorial(n-k-i))*t[k-1][i]
        print(ans%(10**9+7))
    else:
        print(0)


Measured memory_bytes: 357092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p.at(i);
    int ans=0;
    rep(i,n){
        if(p.at(i)==i+1){
            ans++;
            i++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<string>
using namespace std;

long long n;
long long res=0;

long long dfs(long long x,bool f3,bool f5,bool f7){
    if(x>n) return 0;
    if(f3&&f5&&f7) res++;
    dfs(10*x+3,true,f5,f7);
    dfs(10*x+5,f3,true,f7);
    dfs(10*x+7,f3,f5,true);
    return res;
}

int main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << res << endl;
}

Measured memory_bytes: 256
import java.lang.Math.max

fun main(args: Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map(String::toInt)
    val S = readLine()!!
    var wa = IntArray(S.length)
    for (i in S.indices) {
        if (i == 0) continue
        if (S[i-1] == 'A' && S[i] == 'C') {
            wa[i] = 1
        }
    }
    for (i in wa.indices) {
        if (i == 0) continue
        wa[i] += wa[i-1]
    }
    for (i in (1..Q)) {
        val (l, r) = readLine()!!.split(" ").map(String::toInt)
        println(wa[r-1] - wa[l-1])
    }
}

Measured memory_bytes: 64904
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;



int main(void) {
    ll N;
    cin >> N;
    ll a[MAX];
    ll i;
    
    for(i=0; i<N; i++)
        cin >> a[i];
    sort(a, a+N);
    if(a[N-1]-a[0]>1) {
        pt("No");
    }else if(a[0]==a[N-1]) {
        if(a[0]*2<=N || a[0]==N-1) pt("Yes");
        else pt("No");
    }else {
        ll p=0, q=0;
        for(i=0; i<N; i++)
            if(a[0]==a[i]) q++;
        p=N-q;
        
        ll aloneMax=p/2+q-1;
        ll aloneMin=q;
        
        if(aloneMin<=a[0] && a[0]<=aloneMax) pt("Yes");
        else pt("No");
    }
}







Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;//for StringBuilder
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var sum = new long[10000001];
        for (int i = 1; i <= 10000000; i++)
        {
            int temp = 1;
            while (temp * i <= 10000000)
            {
                sum[temp * i]++;
                temp++;
            }
        }
        long ans = 0;
        for (int i = 0; i <= n; i++)
        {
            ans += sum[i] * i;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 105728
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = [i for i in range(1, n + 1)]
count = 0

if p == q:
    print(0)
    exit()
    
for i in itertools.permutations(l, n):
    count += 1
    if i == p:
        a = count
    elif i == q:
        b = count

print(max(a, b) - min(a, b))


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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    a = max(a-b,0);
    cout << max(c-a,0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K % 2 == 0)
        cout << A - B << endl;
    else
        cout << B - A << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,jm,tes,t,k[100009],f[100009];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    for(i=1; i<=a; i++){
        cin>>f[i];
        k[f[i]]++;
        jm+=f[i];
    }
    cin>>tes;
    for(t=1; t<=tes; t++){
        cin>>c>>d;
        jm+=(d-c)*k[c];
        k[d]+=k[c];
        k[c]=0;
        cout<<jm<<endl;
    }
    return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int n,m;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n>>m;
    if (n % 2 == 0) {
        rep(i,m) {
            int j = i / 2;
            if (i % 2 == 0) {
                cout << j + 1 << ' ' << n - j << '\n';
            } else {
                cout << n/2 - (j + 1) << ' ' << n/2 + (j + 1) << '\n';
            }
        }
    } else {
        rep(i,m) {
            cout << i + 1 << ' ' << n - i << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

int main()
{

    long long unsigned int a, b, k, ab, n = 0,s[1000] = {0};

    std::cin >> a >> b >> k;
    if(a > b){
        ab = a;
    }
    else {
        ab = b;
    }
    for(int i  = 1;i <= ab;i++){
        if(a % i == 0&& b % i == 0){
            s[n] = i;
            n++;
        }
    }

    if(n == 0){
        std::cout << 1;

        return 0;
    }

    std::cout << s[n - k];


    return 0;

}

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

using namespace std;

int main()
{
	int a = 0, b = 0;
	int tmp1 = 0, tmp2 = 0;

	cin >> a >> b;
	tmp1 = a * b;
	tmp2 = a * 2 + b * 2;
	cout << tmp1 << " " << tmp2 << endl;

	return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


//エラトステネスの篩 O(n loglog n)
#define MAX_N 10000000
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N + 1];
int sieve(int n) {
	int p = 0;
	memset(is_prime, true, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = false;
		}
	}
	return p;
}



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

	int n;
	cin >> n;
	int np = sieve(n + 2);

	int ans = 0;
	for (int i = 1; i<np && prime[i] <= n ;i++) {
		if (is_prime[prime[i] + 2])ans += 2;
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 15476
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
const int N=1e5+5,M=N<<2;
struct edge{
    int u,v,w,next;
}e[M];
int head[N],cnt;
void add_edges(int u,int v,int w)
{
    e[++cnt].u=u;e[cnt].v=v;e[cnt].w=w;e[cnt].next=head[u];head[u]=cnt;
    e[++cnt].u=v;e[cnt].v=u;e[cnt].w=w;e[cnt].next=head[v];head[v]=cnt;
}
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >heap;
int n,m,u,v,dist[N],pre[N];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        add_edges(u,v,1);
    }
    mm(dist,inf);
    dist[1]=0;
    heap.push({0,1});
    while(!heap.empty()){
        pair<int,int> cur=heap.top();
        heap.pop();
        int u=cur.second;
        for(int i=head[u];i;i=e[i].next){
            int v=e[i].v,w=e[i].w;
            if(dist[v]>dist[u]+w){
                dist[v]=dist[u]+w;
                pre[v]=u;
                heap.push({dist[v],v});
            }
        }
    }
    int i;for(i=1;i<=n;i++)if(dist[i]==inf)break;
    if(i!=n+1)puts("No");
    else{
        puts("Yes");
        for(i=2;i<=n;i++)cout<<pre[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11624
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
			continue;
		}
		int j = i;
		while (j > 0) {
			if (j % 10 == 3) {
				cout << " " << i;
				break;
			}
			j /= 10;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3044
#include<iostream>

using namespace std;

int main(void)
{
  int a,b,c; cin>>a>>b>>c;
  int sum=a+b+c;
  
  int max=a;
  if(max<b){max=b;}
  if(max<c){max=c;}
  
  int min=a;
  if(min>b){min=b;}
  if(min>c){min=c;}
  
  int med=sum-max-min;
  
  if((med+min)==max){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val Array(h, w) = StdIn.readLine().split(' ').map(_.toInt)
  val a = Array.fill[Char](h + 2, w + 2)(" ".charAt(0))

  (1 to h).foreach { i =>
    a(i) = (" " + StdIn.readLine() + " ").toCharArray
  }

  def countBom(center: (Int, Int)): Int = {

    val offsets = List(
      (-1, -1), (-1, 0), (-1, 1),
      ( 0, -1), ( 0, 0), ( 0, 1),
      ( 1, -1), ( 1, 0), ( 1, 1))

    offsets.foldLeft(0){ (acc, o) =>
      acc + (if (a(center._1 - o._1)(center._2 - o._2) == '#') 1 else 0)
    }
  }


  (1 to h).foreach { i =>
    (1 to w).foreach { k =>
      a(i)(k) = if(a(i)(k) == '#') '#' else countBom((i, k)).toString.charAt(0)
    }
  }

  a.slice(1, h + 1).foreach{ l =>
    println(l.slice(1, w + 1).mkString(""))
  }
  
}


Measured memory_bytes: 28652
K, A, B = map(int, input().split())
 
ans = 1
if A + 1 >= B  or A >= K:
    ans += K
else:
    # ビスケットがA がたまるまでの操作回数
    K -= A - 1
    # A枚→1円→B枚で2回操作
    r = K // 2
    m = K % 2
    ans = A +  r * (B - A) + m
 
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <vector>
#include <algorithm> 
#include <stdio.h>
#include <ctype.h>
using namespace std;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m,n,c,a,b;
  cin >> n;
  cout << n + n*n + n*n*n << "\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
const int N=1e5+5;
 
 
int pa[N];
int n,m;
 
ll szz[N];
ll ans[N];
struct edge{
    int u,v;
}edges[N];
 
int find(int x){
    if(pa[x]==x) return pa[x];
    else{
        pa[x]=find(pa[x]);
        return pa[x];
    }

}


 
int main(){
    IOS
    cin>>n>>m;
    int a,b;
    
    for(int i=1;i<=m;++i){
        cin>>edges[i].u>>edges[i].v;
 
    }
    //cout<<"hre"<<endl;
    
    for(int i=1;i<=n;++i){
        //raank[i]=0;
        pa[i]=i;
        szz[i]=1;
    }
    ans[m]=(ll)n*(n-1)/2;
    //cout<<"herew   df  "<<endl;
    for(int i=m;i>=1;--i){
 
          a=find(edges[i].u);
          b=find(edges[i].v);
          
         
          if(a==b){
               ans[i-1]=ans[i];
          }
          else{
               ans[i-1]=ans[i]-(szz[a]*szz[b]);
               szz[a]+=szz[b];
               pa[b]=a;
          }
          //cout<<szz[a]<<endl;
     
 
 
     }
     for(int i=1;i<=m;i++) 
         cout<<ans[i]<<endl;
      
    
     return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    // 0101...
    bool zero = true;
    int cnt0 = 0, cnt1 = 0;
    for(char c: s){
        if(zero && (c == '1')) cnt0++;
        if(!zero && (c == '0')) cnt0++;
        zero = !zero;
    }
    // 1010...
    zero = false;
    for(char c: s){
        if(zero && (c == '1')) cnt1++;
        if(!zero && (c == '0')) cnt1++;
        zero = !zero;
    }
    cout << min(cnt0, cnt1) << endl;
}


Measured memory_bytes: 512
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    a1 = pow(10, n, MOD)
    a2 = pow(8, n, MOD)
    a3 = pow(9, n, MOD) - a2
    # print(a1, a2, a3)
    print((a1 - 2 * a3 - a2) % MOD)

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 10392
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };
    let Q: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (v, d, c): (Vec<usize>, Vec<usize>, Vec<usize>) = {
        let (mut v, mut d, mut c) = (vec![], vec![], vec![]);
        for _ in 0..Q {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            v.push(iter.next().unwrap().parse().unwrap());
            d.push(iter.next().unwrap().parse().unwrap());
            c.push(iter.next().unwrap().parse().unwrap());
        }
        (v, d, c)
    };

    // 最後の操作から順に処理
    // 拡張グラフに対してDFSすることで計算量を抑える
    let G = {
        let mut G = vec![std::collections::HashSet::new(); N + 1];
        for i in 0..M {
            G[a[i]].insert(b[i]);
            G[b[i]].insert(a[i]);
        }
        G
    };
    fn f(x: usize, dist: usize, color: usize,
        G: &Vec<std::collections::HashSet<usize>>, res: &mut Vec<usize>, reacheable: &mut Vec<Vec<bool>>) {
        if reacheable[x][dist] {
            reacheable[x][dist] = false;
            if res[x] == 0 { res[x] = color; }
            if dist > 0 {
                for &y in &G[x] { f(y, dist - 1, color, &G, res, reacheable); }
            }
        }
    }
    let mut res = vec![0; N + 1];
    let mut reacheable = vec![vec![true; 11]; N + 1];
    for i in (0..Q).rev() { f(v[i], d[i], c[i], &G, &mut res, &mut reacheable); }
    let ans = res[1..].iter()
        .map(std::string::ToString::to_string)
        .collect::<Vec<_>>()
        .join("\n");

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


Measured memory_bytes: 78460
li = input().split()
N=int(li[0])
A=int(li[1])
B=int(li[2])
K=int(li[3])
mod = 998244353 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0;
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
count=0
for i in range (N+1):
    if(((A+B)*N-A*i-K)%B==0):
        k=((A+B)*N-A*i-K)//B
        ca=cmb(N,i,mod)
        cb=cmb(N,k,mod)
        count=count+ca*cb
print(count%mod)

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

int main(){
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  if(A+B > C+D){
    cout << "Left" << endl;
  } else if (A+B < C+D){
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
  
}

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

#define fread freopen("in.txt", "r", stdin)
#define fwrite freopen("out.txt", "w", stdout)

#define ll long long int
#define PI acos(-1)

using namespace std;

int main()
{

   int x, y, sum = 0;
   cin >> x >> y;
   int arr[] = {0,300000,200000,100000};

   if(x == 1 && y == 1)
   {
      cout << "1000000\n";
   }
   else
   {
     if(x < 4) sum += arr[x];
     if(y < 4) sum += arr[y];
     cout << sum << '\n';
   }

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	vector<int> n(4);
    rep(i, 4) {
        cin >> n[i];
    }
    sort(all(n));
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  map<int,int> ma;

  rep(i,n){
    int d;
    cin>>d;
    ma[d]++;
  }

  int res = 0;
  for(auto &p : ma){
    if(p.se >= p.fi) res += p.se - p.fi;
    else res += p.se;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	const int INFTY=1<<29;
	for(int n,m;cin>>n>>m,n|m;){
		vvi a(n,vi(n,INFTY));
		rep(i,m){
			int s,d;
			cin>>s>>d;
			a[s-1][d-1]=a[d-1][s-1]=1;
		}
		
		vi dist(n,INFTY),visited(n,0);
		dist[0]=0;
		rep(i,n){
			int minval=INFTY,minid=-1;
			rep(j,n)
				if(!visited[j] && dist[j]<minval){
					minval=dist[j];
					minid=j;
				}
			if(minval==INFTY)
				break;
			visited[minid]=1;
			rep(j,n)
				dist[j]=min(dist[j],dist[minid]+a[minid][j]);
		}
		
		int res=0;
		repi(i,1,n)
			res+=dist[i]<=2;
		
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
n = input()
n = int(n)
x = raw_input()
x_list = x.split()
x_list = map(int, x_list)

max = x_list[0]
min = x_list[0]
sum = x_list[0]

for i in range(1, n):
    if max < x_list[i]:
        max = x_list[i]
    elif min > x_list[i]:
        min = x_list[i]
    sum += x_list[i]

print("%d %d %d" %(min, max, sum))

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int MX = 100 * 1000 + 7;
int a[MX];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            res++;
            if (i + 1 <= n && a[i + 1] == i + 1) {
                i++;
            }
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int A, B;

    printf("\n");
    scanf("%d %d",&A, &B);

    
    if(2<=A<=100&&2<=B<=100)
    {
        printf("%d", (A-1)*(B-1));
    }
    else
    {
        printf("error\n");
    }
    
}


Measured memory_bytes: 128
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))

for a1 in range(101):
    b1 = [l1[0]-a1, l1[1]-a1, l1[2]-a1]
    for a2 in range(101):
        b2 = [l2[0] - a2, l2[1] - a2, l2[2] - a2]
        for a3 in range(101):
            b3 = [l3[0] - a3, l3[1] - a3, l3[2] - a3]
            if b1 == b2 == b3:
                print("Yes")
                exit()
else:
    print("No")

Measured memory_bytes: 40940
#include <iostream>

int main() {
    char S[2];
    for(int i=0;i<3;i++){
        std::cin>>S[i];
    }
    if(S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[0]){
        std::cout<<"Yes";
    }else{
        std::cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: f64,
    }
    println!("{}", (1i64 << (n.log2() as i64 + 1)) - 1);
}


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin >> k >> s;
    if(sz(s) <= k)
    	cout << s << "\n";
    else
    	cout << s.substr(0, k) << "...\n";	
    return 0;
}


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

typedef long long ll;
ll n, m, a[100005];
int main()
{
	ll i, j;
	cin >> n >> m;
	for (i= 1; i <= n; i++) {
		scanf ("%lld", &a[i]);
	}
	for (i = 1; i + 1 <= n; i++) {
		if (a[i] + a[i + 1] >= m) break;
	}
	if (i + 1 <= n) {
		cout << "Possible" << endl;
		for (j = 1; j < i; j++) {
			printf("%lld\n", j);
		}
		for (j = n - 1; j > i; j--) {
			printf("%lld\n", j);
		}
		printf("%lld\n", i);
	} else {
		cout << "Impossible";
	}
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll H, W; cin >> H >> W;
  ll result = H==1||W==1 ? 1 : (H*W+1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256