akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		char[]a = stdIn.next().toCharArray();
		char[]b = stdIn.next().toCharArray();
		
		
		char[] c = new char[a.length];
		
		for(int i = 0; i < a.length; i++) {
			c[i] = a[a.length-i-1];
		}
		/*System.out.println(b);
		System.out.println(c);
		*/
		
		for(int i = 0; i < 3; i++) {
			if(c[i]!=b[i]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		
	}

}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int A, B, K;

	cin >> A >> B >> K;
	set<int> st;
	rep(i,K) if(A+i <= B) st.insert( A+i );
	rep(i,K) if(B-i >= A) st.insert( B-i );

	for(auto t: st) cout << t << endl;

	return 0;
}

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

#define ll long long
#define sz(x) (int)x.size();

using namespace std;

ll n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	ll x=0;
	ll ans=0;
	while(n){
		ans+=pow(2ll,x);
		x++;
		n/=2;
	}
	cout<<ans;
	
}

Measured memory_bytes: 4124
n = input().rstrip().split()
n=[int(x) for x in n]

ans=0
for i in range(n[0],n[1]+1):
  ct=0
  a=list(str(i))
  for j in range(len(a)):
    if a[j]==a[-j-1]:
    	ct+=1
  if ct==len(a):
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>


using namespace std;

//入力xの各桁の和を求める
int digitsum(int x){
    int sum = 0;
    while(x>0){
        sum+=x%10;
        x/=10;
    }
    return sum;
}

int main(){

    int A,B,N;
    int sum;
    int ans = 100000;
    cin >> N;

    for(int i=1; i<N; i++){
        A = i;
        B = N - i;
        int DsumA = digitsum(A);
        int DsumB = digitsum(B); 
        sum = DsumA + DsumB;
        ans = min(ans,sum);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll a;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> a;
	ll aa = a * a;
	ll aaa = aa * a;
	cout << a + aa + aaa << '\n';
}


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

int main(){
    int h,w;
    cin>>h>>w;
    char box[100][100] = {'.'};
    rep(i,h){
        string s;
        cin >> s;
       rep(j,w) {
           box[i+1][j+1] = s[j];
        }
    }

    for(int i=1;i<h+1;i++) {
        for(int j=1;j<w+1;j++){
            if (box[i][j]=='#') {
                cout<<'#';
                continue;
            }

            int ans=0;
            if (box[i-1][j-1] == '#'){
              ans++;
            }
            if (box[i][j-1] == '#'){
              ans++;
            }
            if (box[i+1][j-1] == '#'){
              ans++;
            }
            if (box[i-1][j] == '#'){
              ans++;
            }
            if (box[i+1][j] == '#'){
              ans++;
              }
            if (box[i-1][j+1] == '#'){
              ans++;
            }
            if (box[i][j+1] == '#'){
              ans++;
              }
            if (box[i+1][j+1] == '#'){
              ans++;
            }
            cout<<ans;
        }

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define BUG cout << "acdsfas" << endl
 
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 22;
int n, m, a[N][N], dp[N][1 << N], fbit[1 << N];
 
inline void add(int &a, int b) {
    a += b;
    if(a >= mod)
        a -= mod;
}
 
main() {
    scanf("%d\n", &n);
    for(int i = 1; i <= n; ++i)
        for(int j = 0; j < n; ++j)
            scanf("%d", &a[i][j]);
    dp[0][0] = 1;
    for(int i = 0; i < (1 << N); ++i)
        fbit[i] = inf;
    for(int mask = 0; mask < (1 << N); ++mask)
        for(int i = 0; i < N; ++i)
            if(((1 << i) & mask) == 0) {
                fbit[mask] = i;
                break;
            }
    for(int i = 1; i <= n; ++i) {
        for(int mask = 0; mask < (1 << n); ++mask) {
            if(cntbit(mask) != i - 1)
                continue;
            int cur_mask = mask;
            while(1) {
                int j = fbit[cur_mask];
                if(j >= n)
                    break;
                if(a[i][j])
                    add(dp[i][mask | (1 << j)], dp[i-1][mask]);
                cur_mask |= 1 << j;
            }
        }
    }
    printf("%d\n", dp[n][(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 196864
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! {
        x: u32,
        y: u32,
        z: u32,
    }
    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <stdio.h>
  int main(){
   int a[4],b[4];
    scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]);
      scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
         int ascore,bscore;
           ascore = a[0]+a[1]+a[2]+a[3];
             bscore = b[0]+b[1]+b[2]+b[3];
               if(ascore > bscore){
                 printf("%d\n",ascore);
                  }else if(ascore <bscore){
                    printf("%d\n",bscore);
                     }else{
                       printf("%d\n",ascore);
                        }
return 0;
}

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

bool check(string s){
	if((s[0] - '0') == (s[4] - '0') && (s[1] - '0') == (s[3] - '0')) return true;
	else return false;
}

int main() {
	int a, b, r = 0;
	cin >> a >> b;
	for(int i = a; i <= b; i++){
		string s = to_string(i);
		if(check(s)){
			r++;
		}
	}
	cout << r << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
for(int i=0;i<=9;i++)
    for(int j=0;j<=9;j++){
if(i*j==n)
    {cout<<"Yes"<<endl;return 0;}
if(i==9&&j==9)
    cout<<"No"<<endl;
}
return 0;}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int n, X; ll Ans, Res; struct Seg{int l,r; Seg(){} Seg(int _l, int _r){l=_l,r=_r;} inline int Mv(){int p; p = X<l?l:X>r?r:X; X = abs(p-X); swap(p,X); return p;}
inline bool operator < (const Seg &b)const{return l^b.l?l>b.l:r<b.r;} inline bool operator > (const Seg&b)const{return r^b.r?r<b.r:l>b.l;}}T; multiset<Seg> R,B; multiset< Seg,greater<Seg> >L,A;
int main()
{
	n = read(); for(rint i = 1, l, r; i <= n; l = read(), r = read(), L.insert(Seg(l,r)), R.insert(Seg(l,r)), i++); A = L, B = R;
	for(Res = 0; L.size(); T=*L.begin(),L.erase(L.find(T)),R.erase(R.find(T)),Res+=T.Mv(),R.size()?T=*R.begin(),L.erase(L.find(T)),R.erase(R.find(T)),Res+=T.Mv():0); Ans = Res+Seg(0,0).Mv();
	for(Res = 0; B.size(); T=*B.begin(),A.erase(A.find(T)),B.erase(B.find(T)),Res+=T.Mv(),A.size()?T=*A.begin(),A.erase(A.find(T)),B.erase(B.find(T)),Res+=T.Mv():0); return !printf("%lld\n",max(Ans,Res+Seg(0,0).Mv()));
}

Measured memory_bytes: 18944
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int n;
  scan(n);
  n %= 1000;
  int ans = 0;
  if (n > 0) {
    ans = 1000 - n;
  }
  print(ans);
}

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


Measured memory_bytes: 3220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var ca = S.ToCharArray();
		ca[K] = (char)(ca[K] + 'a' - 'A');
		Console.WriteLine(new String(ca));
		
	}
	int N,K;
	String S;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1] - 1;
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var n = toIntArr(input);
	var x = n[0];
	var y = n[1];

	console.log(x + y/2)

}



Measured memory_bytes: 21192
h,w = map(int,input().split())
grid = []
datah = []
dataw = []
for i in range(h):
    l = list(input())
    grid.append(l)
    if l.count("#") == 0:
        datah.append(i)
for j in range(w):
    for k in range(h):
        if grid[k][j] == "#":
            break
    else:
        dataw.append(j)
for i in range(h):
    if i in datah:
        continue
    print("".join([grid[i][n] for n in range(w) if not n in dataw]))


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

int main() {
  string s;
  cin >> s;
  bool ans=1;
  for(int i=0;i<s.size();i++){
    if((i+1)%2==0 && (s.at(i)=='R')) ans=0;
    else if((i+1)%2==1 && (s.at(i)=='L')) ans=0;
  }
  if(ans) cout <<"Yes" <<endl;
  else cout << "No" <<endl;    
}

Measured memory_bytes: 256
#include <stdio.h>

int search(int array[10],int headed){
  int i;
  int tmp[10];
  int ret = 0;
  int all_zero = 1;
  
  for(i = 1;i < 10;i++){
    tmp[i] = array[i];
    if(array[i] != 0){all_zero = 0;}
    //printf("%d ",array[i]);
  }
  //printf("\n");

  if(all_zero){return 1;}
  
  for(i = 1;i < 10;i++){
    if(!headed){
      if(array[i] >= 2){
	tmp[i] -= 2;
	ret += search(tmp,1);
	tmp[i] += 2;
      }
    }else{
      if(array[i] >= 3){
	tmp[i] -= 3;
	ret += search(tmp,headed);
	tmp[i] += 3;
      }
      
      if(i <= 7 && array[i] >= 1 && array[i+1] >= 1 && array[i+2] >= 1){
	tmp[i] -= 1;
	tmp[i+1] -= 1;
	tmp[i+2] -= 1;
	ret += search(tmp,headed);
	tmp[i+2] += 1;
	tmp[i+1] += 1;
	tmp[i] += 1;
      }
    }
  }
  
  return ret;
}

int main(int argc,char* argv[]){
  int nums[10],tmp[10];
  char def[14];
  int nothing;
  int i = 0,use;
  int end = 0;

  while(scanf("%s",def) != EOF){
    for(i = 0; i < 10; i++){
      nums[i] = 0;
    }

    for(i = 0; i < 13; i++){
      nums[def[i] - '0']++;
    }
    
    
    nothing = 1;
    for(use = 1;use < 10;use++){
      end = 0;
      for(i = 0; i < 10; i++){
	tmp[i] = nums[i];
      }
      tmp[use]++;
      
      for(i = 0; i < 10; i++){
	if(tmp[i] > 4){
	  end = 1;
	  break;
	}
      }
      
      if(end == 1){continue;}
      
      if(search(tmp,0) > 0){
	if(nothing == 1){
	  nothing = 0;
	  printf("%d",use);
	}else{
	  printf(" %d",use);
	}
      }
      
    }

    if(nothing){
      printf("0");
    }

    printf("\n");
    
  }

  return 0;
  
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int match_index(vector<int> &vec){
    for(int i=vec.size()-1;i>=0;i--){
        if(vec[i]==i+1){
            return i;
        }
    }
    return -1;
}

int main(){
    INT(n);
    vector<int> vec(n);
    in(vec);
    stack<int> ans;
    int x;
    while((x=match_index(vec))!=-1){
        ans.push(x+1);
        vec.erase(vec.begin()+x);
        if(vec.empty())break;
    }
    if(x==-1)out(-1);
    else{
        rep(i,n){
            out(ans.top());
            ans.pop();
        }
    }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int a[100000];

int main() {
    int N;
    cin >> N;
    rep(i, N) cin >> a[i];

    map<int, int> mp;
    rep(i, N) mp[a[i]]++;

    int ans = 0;
    for (auto p: mp) {
        int x = p.first;
        int n = p.second;
        if (n < x) ans += n;
        else ans += n - x;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5120
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W := scanInt(), scanInt()
	Map := make([]string, H)
	for i := 0; i < H; i++ {
		sc.Scan()
		Map[i] = sc.Text()
	}

	cntMap := make([][]int, H)
	for i := 0; i < H; i++ {
		cntMap[i] = make([]int, W)
	}

	// right
	for i := 0; i < H; i++ {
		cnt := 0
		for j := 0; j < W; j++ {
			if string(Map[i][j]) == "#" {
				cnt = 0
			} else {
				cnt++
				cntMap[i][j] += cnt
			}
		}
	}

	// left
	for i := 0; i < H; i++ {
		cnt := 0
		for j := W - 1; j >= 0; j-- {
			if string(Map[i][j]) == "#" {
				cnt = 0
			} else {
				cnt++
				cntMap[i][j] += cnt
			}
		}
	}

	// up
	for j := 0; j < W; j++ {
		cnt := 0
		for i := 0; i < H; i++ {
			if string(Map[i][j]) == "#" {
				cnt = 0
			} else {
				cnt++
				cntMap[i][j] += cnt
			}
		}
	}

	// down
	for j := 0; j < W; j++ {
		cnt := 0
		for i := H - 1; i >= 0; i-- {
			if string(Map[i][j]) == "#" {
				cnt = 0
			} else {
				cnt++
				cntMap[i][j] += cnt
			}
		}
	}

	ans := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			ans = intMax(ans, cntMap[i][j]-3)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 40192
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 1500000-1;
const int MAX_N = 100;

int M, N;
int W[MAX_N];

bool C ( int x )
{
	int sum = 0, res = 1;

	for (int i = 0; i < N; ++i) {
		if (sum+W[i] <= x) {
			sum += W[i];
		}
		else {
			++res;
			if (x < W[i]) { return false; }
			sum = W[i];
		}
	}
	return M >= res;
}

int main ( void )
{
	while (cin >> M >> N, M | N) {
		for (int i = 0; i < N; ++i) {
			cin >> W[i];
		}

		int l = 0, u = INF;

		while (u-l > 1) {
			int mid = (l + u) / 2;
			if (C(mid)) {
				u = mid;
			}
			else {
				l = mid;
			}
		}

		cout << u << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
using namespace std;
int main(){
  int dx[] = {1,0,-1,0,1,1,-1,-1}, dy[] = {0,1,0,-1,1,-1,1,-1};
  int H, W, N;
  cin >> H >> W >> N;
  int a, b;
  map<pair<int,int>, int> M;
  for(int i = 0; i < N; ++i){
    cin >> a >> b;
    if(a > 1 && a < H && b > 1 && b < W){
      ++M[make_pair(a,b)];
    }
    for(int j = 0; j < 8; ++j){
      int s = a + dx[j], t = b + dy[j];
      if(s > 1 && s < H && t > 1 && t < W){
	++M[make_pair(s,t)];
      }
    }
  }
  long long int ans[10], t = (long long int)(H-2)*(W-2);
  fill(ans,ans+10,0LL);
  for(map<pair<int,int>, int>::iterator itr = M.begin(); itr != M.end(); ++itr){
    ++ans[itr->second];
    --t;
    //cout << itr->first.first << ", " << itr->first.second << " = " << itr->second << endl;
  }
  ans[0] = t;
  for(int i = 0; i < 10; ++i){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 56448
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long
class UnionFind {
private:
public:
    int sz;
    vector<int> par, size_,psz;
    vector<bool> flag;
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1),psz(sz,1),flag(sz,0){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    void unite2(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
        psz[x] +=psz[y];
    }
    void unite3(int x,int y){
        x = find(x), y = find(y);
        par[y] = x;
        size_[x] += size_[y];
        psz[x] +=psz[y];    
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    int psize(int x){
        x = find(x);
        return psz[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};


signed main(){
    long long n,m,q;
    cin >> n >> m >> q;
    ll K = 0;
    UnionFind uf(n);
    vector<pair<int,int> > p;
    rep(i,q){
        int a,b,c;
        cin >> a >> b >> c;
        if(c==1){
            p.push_back(MP(a,b));
        }else{
            if(uf.same(a,b)){
            }else{
                uf.unite(a,b);
                K++;
            }
        }
    }
    bool flag[100001]={};
    ll c = 0;
    rep(i,n){
        if(!flag[uf.find(i)]){
            c++;
            flag[uf.find(i)]=1;
        }
    }
    if(c<=2&&p.size()!=0){
        //assert(0);
        cout << "No" << endl;
        return 0;
    }
    vector<int> pp(n);
    rep(i,n){
        pp[i] = uf.find(i);
    }
    rep(i,p.size()){
        int a = p[i].first;
        int b = p[i].second;
        if(pp[a]==pp[b]){
            //assert(0);
            cout << "No" << endl;
            return 0;
        }
    }
    if(p.size()==0&&K+c-1<=m&&K + c*(c-1)/2 >=m){
        cout << "Yes" << endl;
        return 0;
    }
    if(K+c <=m&&K + c*(c-1)/2 >=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
#define N 301000
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-48);c=getchar();}
	x*=p;
}
long long n,a,b,k;
const long long mod=998244353;
long long exgcd(long long &x,long long &y,long long a,long long b)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	long long d=exgcd(x,y,b,a%b);
	long long tmp=x;
	x=y;
	y=tmp-a/b*x;
	return d;
}
long long fac[N],inv[N];
long long ksm(long long x,long long mc)
{
	long long tmp=x%mod;
	long long res=1;
	while(mc)
	{
		if(mc&1ll)res=res*tmp%mod;
		tmp=tmp*tmp%mod;
		mc>>=1ll;
	}
	return res;
}
void init()
{
	fac[1]=fac[0]=inv[1]=inv[0]=1;
	for(long long i=2;i<=n+10;i++)
		(fac[i]=fac[i-1]*i%mod)%=mod;
	inv[n+10]=ksm(fac[n+10],mod-2);
	for(long long i=n+9;i>=2;i--)
		(inv[i]=inv[i+1]%mod*(i+1)%mod)%=mod;
}
long long C(long long x,long long y)
{
	if(x<y)return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
//	freopen("mnth.in","r",stdin);
//	freopen("mnth.out","w",stdout);
	read(n);read(a);read(b);read(k);
	if(k==0)return cout<<1<<endl,0;
	init();
	long long ans=0;
	for(long long i=0;i<=n;i++)
	{
		if(k-i*a<0)break;
		if((k-i*a)%b==0)(ans+=C(n,i)*C(n,(k-i*a)/b)%mod)%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    for(char c='a'; c<='z'; ++c){
        if(s.find(c) == string::npos){
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
m = [0] * n
for i in range(n):
    m[i] = int(input())

k -= sum(m)
ans = n
while k >= 1:
    if min(m) <= k:
        ans += 1
        k -= min(m)
    else:
        break

print(ans)

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
import java.lang.ArrayIndexOutOfBoundsException;
import java.math.*;


class Main {
	static Scanner sc = new Scanner(new InputStreamReader(System.in));
	public static void main(String[] args) throws Exception {
		try{
		while(true) {
			int r = sc.nextInt();
			int n = sc.nextInt();
			if(r+n == 0) break;
			System.out.printf("%.4f\n", solve(r, n));
		}
		} catch(Exception e) {
			System.out.println(e);
		}
	}
	
	
	static double solve(int r, int n) {
		int[] dp = new int[40];
		for (int i = 0; i < n; i++) {
			int xl = sc.nextInt();
			int xr = sc.nextInt();
			int h = sc.nextInt();
			for(int j = xl; j < xr; j++) {
				int index = j + 20;
				dp[index] = Math.max(dp[index], h);
			}
		}
		
		for(double ans = -r; ans < 20.0; ans += 0.0005) {
			for (int i = 1-r; i < r; i++) {
				int index = i + 20;
				int h = Math.min(dp[index-1], dp[index]);
				double dist = sqdist(0.0, ans, (double)i, (double)h);
				if(dist <= (double)(r*r)) {
					return ans + (double)r;
				}
			}
		}
		return 0.0;
	}
	
	public static double sq(double d) {
		return d * d;
	}
	
	public static double sqdist(double x1, double y1, double x2, double y2) {
		return sq(x1 - x2) + sq(y1 - y2);
	}
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
  int N; cin >> N;
  vec v(N);
  rep(i, N) cin >> v[i];
  
  ll res=0;
  sort(all(v));
  per(i, N){
    for(int j=i-1; j >= 0; j--){
      int a = v[j];
      int b = abs(v[i] - v[j]);
      
    //   auto upit = lower_bound(all(v), a);
      auto dwit = upper_bound(all(v), b);
      
      int c = j - distance(v.begin(), dwit);
      if(c > 0) res += c;
    }
  }
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    string str;
    cin >> str;
    int len = str.size();
    int flag = 0;
    for (int i = 0; i < len; i++)
    {
        if (str[i] == '7')
        {
            flag = 1;
            break;
        }
    }
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n, m, A, B;

char Ans[1010][1010];

int main() {
    scanf("%d%d%d%d", &n, &m, &A, &B);
    if((A + B) * 2 > n * m || A > m / 2 * n || B > n / 2 * m) {
        puts("NO");
        return 0;
    }
    memset(Ans, '.', sizeof Ans);
    if(n & 1) {
        for(int i = 1; i < m && A; i += 2)
            if(1) {
                Ans[n][i] = '<';
                Ans[n][i + 1] = '>';
                A--;
            }
    }
    if(m & 1) {
        for(int i = n - 1; i >= 1 && B; i -= 2)
            if(1) {
                Ans[i][m] = '^';
                Ans[i + 1][m] = 'v';
                B--;
            }
    }
    int N = n / 2 * 2, M = m / 2 * 2;
    if(N * M < (A + B) * 2) {
        puts("NO");
        return 0;
    }
    for(int i = 1; i < n; i += 2)
        for(int j = 1; j < m; j += 2) if(!((n & 1) && (m & 1) && (i == 1 && j == m - 2))) {
            if(A > 1) {
                Ans[i][j] = '<';
                Ans[i][j + 1] = '>';
                if(A != 1) {
                    Ans[i + 1][j] = '<';
                    Ans[i + 1][j + 1] = '>';
                    A -= 2;
                } else A--;
            } else if(B > 1) {
                Ans[i][j] = '^';
                Ans[i + 1][j] = 'v';
                if(B != 1) {
                    Ans[i][j + 1] = '^';
                    Ans[i + 1][j + 1] = 'v';
                    B -= 2;
                } else B--;
            } else if(A == 1) {
                
                Ans[i][j] = '<';
                Ans[i][j + 1] = '>';
                A--;
            } else if(B == 1) {
                Ans[i][j] = '^';
                Ans[i + 1][j] = 'v';
                B--;
            }
        }
    if(A || B) {
        if(n == 1 || m == 1) {
            puts("NO");
            return 0;
        }if((n & 1) && (m & 1) && B == 0 && A <= 2) {
            int i = 1, j = m - 2;
            Ans[i][j] = '<';
            Ans[i][j + 1] = '>';
            if(A != 1) {
                Ans[i + 1][j] = '<';
                Ans[i + 1][j + 1] = '>';
                A -= 2;
            } else A--;
        } else if((n & 1) && (m & 1) && A == 0 && B <= 2) {
            int i = 1, j = m - 2;
            Ans[i][j] = '^';
            Ans[i + 1][j] = 'v';
            if(B != 1) {
                Ans[i][j + 1] = '^';
                Ans[i + 1][j + 1] = 'v';
                B -= 2;
            } else B--;
        } else if((n & 1) && (m & 1) && A == 1 && B == 1) {
            Ans[1][m - 2] = '^';
            Ans[2][m - 2] = 'v';
            Ans[1][m - 1] = '<';
            Ans[1][m] = '>';
        } else {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) putchar(Ans[i][j]);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 2176
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s = line.trim();
    match s {
        "AAA" | "BBB" => println!("No"),
        _ => println!("Yes"),
    }
}


Measured memory_bytes: 2048
# ABC161
# B Popular Vote
N, M = map(int, input().split())  # N種類　M個選ぶ
a = sorted(list(map(int, input().split())),reverse=True)
x = sum(a)
q = x / (4 * M)
b =[]
for i in range(M):
    b.append(a[i])
b = sorted(b)
for j in b:
    if j < q:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
long long int dp[100100];
map<int,list<int> >edge;
long long int dfs(int node)
{
if(dp[node]!=-1)
    return dp[node];
dp[node]=0;
     for(auto i:edge[node])
    {

            dp[node]=max(dp[node],1+dfs(i));
    }
    return dp[node];

}






int main()
{
    long long int n,e;
    cin>>n>>e;
    n++;
    for(int i=0;i<n;i++)
        dp[i]=-1;
    long long int a,b;

    for(int i=0;i<e;i++)
    {
        cin>>a>>b;
        edge[a].push_back(b);
    }

    long long int ans=0;
    for(int i=1;i<n;i++)
       {
    ans=max(ans,dfs(i));

       }
       cout<<ans;
       return 0;
}


Measured memory_bytes: 12416
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var X = vals[1];
        var L = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int count = 1;
        var p = 0;
        foreach(var l in L)
        {
            p += l;
            if(p > X)
            {
                break;
            }
            count++;
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13268
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def rooptimes(ai, mi):
    x = ai % mi
    i = 1
    while x != 1:
        x = ai * x % mi
        i += 1
    return(i)

while True:
    a = list(map(int, input().split()))
    if a.count(0) == 6:
        break
    ix = rooptimes(a[0], a[1])
    iy = rooptimes(a[2], a[3])
    iz = rooptimes(a[4], a[5])

    ixy = ix * iy // gcd(ix, iy)
    print(ixy * iz // gcd(ixy, iz))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, x;
    cin >> n >> x;
    int d = 0;
    int cnt = 1;
    rep (i, n) {
        int l;
        cin >> l;
        d += l;
        if (d <= x) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}



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

int main() {
	int x;
	cin >> x;
	int kyu = 8 - (x-400)/200;
	cout << kyu << endl;
	return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int d[100];

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,0,N) cin >> d[i];
    set<int> s;
    REP(i,0,N) s.insert(d[i]);
    CO(s.size());
    return 0;
}

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

using namespace std;

bool bigger(const string &s1, const string &s2)
{
    if (s1.size() > s2.size()) return true;
    if (s1.size() < s2.size()) return false;
    for (int i = 0; i < (int) s1.size(); ++i) if (s1[i] != s2[i]) {
        return s1[i] > s2[i];
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    set<int> a;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        a.insert(x);
    }
    vector<int> match = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    map<int, char> t;
    for (auto x: a) {
        t[match[x]] = x + '0';
    }
    string ans;
	if (t.count(2)) {
		if (n & 1) {
			for (auto &kv: t) if (kv.first & 1) {
				ans += kv.second;
				n -= kv.first;
				break;
			}
		}
		if (n) ans += string(n/2, t[2]);
		cout << ans << endl;
		return 0;
	}
	if (t.count(3)) {
		t.erase(6);
	}
	int cnt = 0;
	if (n > 420*2) {
		cnt = (n / 420) - 1;
		n -= 420 * cnt;
	}
    int v, vv;
    string s, ss;
    queue<pair<int, string>> q;
    q.push({0, ""});
    while (q.size()) {
        map<int, string> tt;
        while (q.size()) {
            tie(v, s) = q.front();
            q.pop();
            for (auto &kv: t) {
                vv = v + kv.first, ss = s + kv.second;
                if (vv == n) {
                    if (bigger(ss, ans)) ans = ss;
                } else if (vv < n) {
                    if (bigger(ss, tt[vv])) tt[vv] = ss;
                }
            }
        }
        for (auto &kv: tt) q.push(kv);
    }
	if (cnt) {
		int k = t.begin()->first, v = t.begin()->second;
		ans += string(420*cnt/k, v);
		vector<char> vec;
		for (auto &c: ans) vec.push_back(c);
		sort(vec.rbegin(), vec.rend());
		ans.clear();
		for (auto &c: vec) ans += c;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  vector<int> c(n);
  for (int i = 0; i + 1 < n; i++) {
    cin >> c[i];
  }
  int ans = 0;
  int prv = -100;
  for (int i = 0; i < n; i++) {
    ans += b[a[i]];
    if (prv + 1 == a[i]) {
      ans += c[prv];
    }
    prv = a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,x,minn,maxx;
int a[200005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
	  scanf("%d",&a[i]);
	  if(a[i]>maxx) maxx=a[i];
	  else minn=max(minn,a[i]);
	}
	for(int i=1;i<=n;i++)
	  if(a[i]==maxx) printf("%d\n",minn);
	  else printf("%d\n",maxx);
	return 0;
	
}

Measured memory_bytes: 2432
with open(0) as f:
    N, *a = map(int, f.read().split())
i, j, k = 0, 0, 0
for x in a:
    if x%4 == 0:
        i += 1
    elif x%2 == 0:
        j += 1
    else:
        k += 1
    
if j > 0:
    k += 1
print('Yes' if k <= i+1 else 'No')


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

int M;

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

long long sum1(long long r, long long n) {
    // sum_{i <= n} r^i
    long long ans = 0;
    if (n == 0) return 1;
    if (n % 2 == 0) ans += modexp(r, n, M), n--;
    ans += (1+r) * sum1(r*r%M, n/2) % M;
    return (ans % M + M) % M;
}

long long sum2(long long r, long long n) {
    // sum_{i <= n} i*r^i
    long long ans = 0;
    if (n == 0) return 0;
    if (n % 2 == 0) ans += n % M * modexp(r, n, M), n--;
    ans += r * sum1(r*r%M, n/2) % M;
    ans += 2 * (1+r) * sum2(r*r%M, n/2) % M;
    return (ans % M + M) % M;
}

pair<int, long long> solve(long long L, long long A, long long B) {
    int e = 0;
    long long p = 1;
    while (e < 18 && p * 10 <= A) e++, p *= 10;
    long long ans = 0;
    long long c = 1;
    if (e < 18 && 10 * p <= A + (L-1) * B) {
        long long L1 = 1 + (10 * p - 1 - A) / B;
        auto x = solve(L-L1, A + L1 * B, B);
        ans = x.first;
        c = x.second;
        L = L1;
    }
    long long add = 0;
    add += (A % M + (L - 1) % M * B % M) * sum1(p%M*10%M, L-1) % M;
    add -= B % M * sum2(p%M*10%M, L-1) % M;
    ans += add * c % M;
    ans = (ans % M + M) % M;
    c *= modexp(p%M*10%M, L, M);
    return {ans, c%M};
}

int main() {
    long long L, A, B; cin >> L >> A >> B >> M;
    cout << solve(L, A, B).first << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i] == 'x')cnt++;
    }
    if(cnt >= 8){
        puts("NO");
    }else{
        puts("YES");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int a[200010];
int main() {
    int n;
    cin>>n;
    long long sum=0,ans=0;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++) {
        ans=(ans+a[i]*sum)%mod;
        sum=(sum+a[i])%mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

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

int main()
{
    vector<int> time(4);
    cin >> time.at(0) >> time.at(1) >> time.at(2) >> time.at(3);
    if(time.at(1) <= time.at(2) || time.at(3) <= time.at(0))
    {
        cout << 0 << endl;
        return 0;
    }

    sort(time.begin(), time.end());
    cout << abs(time.at(1) - time.at(2)) << endl;
}

Measured memory_bytes: 256
def mondai(n, k):

    keta = 0
    a = n
    b = []
    ans = 0
    d = 0

    while a >= 10:
        c = a % 10
        b.append(c)
        a = a // 10
        keta = keta + 1
    
    for i in range(len(b)):
        d = d + b[i] * (10 ** i)

    if k == 1:
        ans = keta * 9 + a

    elif k == 2:
        if keta == 0:
            ans = 0
        elif keta == 1:
            ans = keta * 9 * (a - 1) + mondai(d, 1)
        else:
            for i in range(1, keta):
                ans = ans + i * 81
            ans = ans + keta * 9 * (a - 1) + mondai(d, 1)
        
    else:
        if keta == 0 or keta == 1:
            ans = 0
        elif keta == 2:
            ans = keta * 81 * (a - 1) + mondai(d, 2)
        
        else:
            for i in range(2, keta):
                ans = ans + i * (i - 1) / 2 * 9 * 9 * 9
            ans = ans + keta * (keta - 1) / 2 * 81 * (a - 1) + mondai(d, 2) 
            
                
    return ans

n = int(input())
k = int(input())

ans = int(mondai(n, k))
    
print(ans)

Measured memory_bytes: 3064
#dp=[[ for i in range(3000)] for j in range(3000)]
n=int(input())
A=list(int(i) for i in input().split())
dp=[[0 for i in range(n)] for j in range(n)]
for i in range(n-1,-1,-1):
    for j in range(i,n):
        if i==j:
            dp[i][j]=A[i]
        else:
            dp[i][j]=max(A[i]-dp[i+1][j],A[j]-dp[i][j-1])
print(dp[0][-1])


Measured memory_bytes: 120284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int w = s.size();
  int e = w / 2;
  int q = 0;
  for(int i = 0; i < e; i++) {
    if(s.at(i) == s.at(w - i - 1)) {
    }
    else {
      q++;
    }
  }
  cout << q << endl;
}

Measured memory_bytes: 256