akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <bitset>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll qmi(ll a , ll b) {
  ll res = 1 ;
  while(b) {
    if(b & 1) res = res * a % mod ;
    a = a * a % mod ;
    b >>= 1 ;
  }
  return res ;
}
int work()
{
  ll n ;
  cin >> n ;
  ll ans = qmi(10 , n) + qmi(8 , n) - 2 * qmi(9 , n) ;
  ans = (ans % mod + mod) % mod ;
  cout << ans << endl ;
  return 0 ;
}
int main()
{
  //   freopen("C://Users//spnooyseed//Desktop//in.txt" , "r" , stdin) ;
  //   freopen("C://Users//spnooyseed//Desktop//out.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3140
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 12
#define NIL -1

string M[MAX];
static int color[MAX][MAX + 1];

void dfs(int h, int w, int c) {
	color[h][w] = c;
	if (h != MAX - 1 && M[h + 1][w] == '1'&&color[h + 1][w] == NIL)
		dfs(h + 1, w, c);
	if (h != 0 && M[h - 1][w] == '1'&&color[h - 1][w] == NIL)
		dfs(h - 1, w, c);
	if (w != MAX - 1 && M[h][w + 1] == '1'&&color[h][w + 1] == NIL)
		dfs(h, w + 1, c);
	if (w != 0 && M[h][w - 1] == '1'&&color[h][w - 1] == NIL)
		dfs(h, w - 1, c);
}


int main() {

	for (string s; cin >> s && s != "S";) {
		M[0] = s;
		for (int h = 1; h < MAX; h++) {
			cin >> s;
			M[h] = s;
		}
		fill(color[0], color[MAX], NIL);
		int c = 0;
		for (int i = 0; i < MAX; i++) {
			for (int j = 0; j < MAX; j++) {
				if (color[i][j] == NIL&&M[i][j] == '1') { dfs(i, j, c++); }
			}
		}
		//for (int i = 0; i < MAX; i++) {
		//	for (int j = 0; j < MAX; j++) {
		//		cout << i << " " << j << " " << color[i][j] << endl;
		//	}
		//}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

/* see https://github.com/pllk/cphb/ */
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;

typedef unsigned int uint;
typedef long long ll;
//typedef __int128 lll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<int> f(256);

    for(int i=0; i<s.size(); i++)
        f[s[i]]++;
    
    for(int i=0; i<f.size(); i++)
        if(f[i]!=0 && f[i]!=2) {
            cout<<"No"<<endl;
            return 0;
        }

    cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

int main(){

    int n,z,w;
    cin >> n >> z  >>w;
    vector<int> a(n);
    
    for(int i = 0;i < n;i++){
    	cin >> a[i];
    }
    
    if(n==1)cout << abs(a[0]-w) << endl;
    else cout << max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])) << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())

ans = 0


def keta_sum(num):
	sum = 0
	while num:
		sum += num % 10
		num = num // 10
    
	return sum

for i in range(N):
	num = i + 1
	sum = keta_sum(num)
	if (sum >= A) and (sum <= B):
		ans += num

print(ans)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main () {
    int x, y;
    cin >> x >> y;
    while (x || y) {
        if (x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }   
        cin >> x >> y;
    }   
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define vi vector<int>
using namespace std;
int vis[1000][1000];
long long gn;
long long po(long long a,long long b){
    if(b==0)return 1;
    if(b==1)return a;
    if(b&1) return a*po(a*a,(b-1)/2);
    if(b&1^1)return po(a*a,b/2);
    return 1;
}
int vectoint(std::vector<int>v){
    reverse(v.begin(), v.end());
    long long p=0;
    for(int i=0;i<v.size();i++){
        p+=v[i]*po(2,i);
    }
return p;
}
int dp[100][100];
int print(int x,int y){
    if(x<=1){
            if(y>2 || y<=0)return 0;
            else return 1;
    }
  if(dp[x][y]!=0)return dp[x][y];
    else{

    return dp[x][y]=print(x-1,y)+print(x-1,y-1);
} }
void dele(stack<int>&s,int k){
    if(k==1){
        s.pop();
        return ;
    }
    int x=s.top();
    s.pop();
    dele(s,k-1);
    s.push(x);
    return;
}
void sort0(){

}
void finddup(){
    int arr[]={1,2,3,4,5,4};
    int tor=arr[0];
    int hare=arr[0];
    do{
        tor=arr[tor];
        hare=arr[arr[hare]];
    }
    while(hare!=tor);
    hare=arr[0];
    while(hare!=tor){
        hare=arr[hare];
        tor=arr[tor];
    }
    cout<<hare<<endl;
    return;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
    int t;
    // stack<int>s;
    // s.push(1);
    // s.push(111);
    // s.push(112);
    // s.push(112312);
    // s.push(12312);
    //  s.push(122);


    // cout<<s.size()<<endl;
    // stack<int>p=s;
    // while(!p.empty()){cout<<p.top()<<" ";p.pop();}
    // cout<<endl;
    // dele(s,(s.size()%2==0)?s.size()/2:(s.size()/2)+1);
    // cout<<s.size()<<endl;
    // while(!s.empty()){cout<<s.top()<<" ";s.pop();}
    //finddup();
    //sort0();
    int n;
    cin>>n;
    string str;
    map<string,int> m;
    for(int i=1;i<=n;i++){
        cin>>str;
        m[str]++;
    }
    cout<<"AC"<<" x "<<m["AC"]<<endl;

    cout<<"WA"<<" x "<<m["WA"]<<endl;
    cout<<"TLE"<<" x "<<m["TLE"]<<endl;
    cout<<"RE"<<" x "<<m["RE"]<<endl;
return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int f_x = 0;
  
  for (int i = 1; i <= 100000000; i*=10) {
    f_x += (N % (i * 10)) / i;
    if (N < i) break;
  }
  
  if (N % f_x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))

s = sum(a)
c = 0
for i in range(len(a)):
    if a[i] >= 1 / (4 * m) * s:
        c += 1
if c >= m:
    print('Yes')
else:
    print('No')


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

int main(){
        int H, W;
        do{
                cin >> H >> W;
                for(int i = 0; i < H; i++){
                        for(int ii = 0; ii < W; ii++){
                                cout << "#";
                        }
                        cout << endl;
                }
                if (H || W)cout << endl;
        }while(H || W);
}



Measured memory_bytes: 3108
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>

using namespace std;


int main() {
    int d;
    string s;
    cin >> d;
    if (d == 25) {
        s = "Christmas";
    } else if (d == 24) {
        s = "Christmas Eve";
    } else if (d == 23) {
        s = "Christmas Eve Eve";
    } else {
        s = "Christmas Eve Eve Eve";
    }

    cout << s << endl;

    return 0;
}

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

int main(void) {
    std::vector<int> coordinate;

    for (int i = 0; i < 5; i++) {
        int coord;
        std::cin >> coord;
        coordinate.push_back(coord);
    }
    int k;
    std::cin >> k;

    sort(coordinate.begin(), coordinate.end());
    if (coordinate.at(coordinate.size() - 1) - coordinate.at(0) > k) {
        std::cout << ":(" << std::endl;
        return 0;
    }
    std::cout << "Yay!" << std::endl;
}




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

int main(){
    int N;
    cin >> N;

    int f = 0;
    int t;
    t=N;
    while(t>=1){
        f += t % 10;
        t = t/10;
    }
    
    if(N%f==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 764
N,A,B,C = gets.split.map(&:to_i)
ls = N.times.map{ gets.to_i }

def merge(main, joins)
  if joins.empty?
    sorted = main.sort
    (sorted[0]-C).abs + (sorted[1]-B).abs + (sorted[2]-A).abs
  else
    joins_dup = joins.dup
    current = joins_dup.pop
    scores = [
      merge([main[0],main[1],main[2]], joins_dup),
      merge([main[0]+current,main[1],main[2]], joins_dup) +10,
      merge([main[0],main[1]+current,main[2]], joins_dup) +10,
      merge([main[0],main[1],main[2]+current], joins_dup) +10
    ]
    scores.min
  end
end

min = 100000000000000000
N.times.map{|i| i}.combination(3) do |a,b,c|
  joins = ls.dup
  main = [joins.delete_at(c), joins.delete_at(b), joins.delete_at(a)]
  mp = merge(main, joins)
  min = [min, mp].min
end
puts min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int n,a;
  cin >> n >> a;
  cout << ((n%500<=a)?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 bool cards[4][14];
 int n, rank;
 char suit;
 for( int s = 0; s < 4; s++ )
  for ( int r = 1; r <= 13; r++ )
   cards[s][r] = 0;
 cin >> n;
 for ( int i = 0; i < n; i++ ){
  cin >> suit >> rank;
  if ( suit == 'S' ) cards[0][rank] = 1;
  if ( suit == 'H' ) cards[1][rank] = 1;
  if ( suit == 'C' ) cards[2][rank] = 1;
  if ( suit == 'D' ) cards[3][rank] = 1;
 }
 for ( int s = 0; s < 4; s++){
  for ( int r = 1; r <= 13; r++){
   if ( cards[s][r] ) continue;
   if ( s == 0 ) suit = 'S';
   if ( s == 1 ) suit = 'H';
   if ( s == 2 ) suit = 'C';
   if ( s == 3 ) suit = 'D';
   cout << suit << " " << r << endl;
 }
}
return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
 
using namespace std;
 
int main(){
  int N, M;
  cin >> N >> M;
  cout << N * (N-1) / 2 + M * (M-1) / 2;
  return 0;  
}
  

Measured memory_bytes: 256
(let ((N (parse-integer (read-line)))
	  (c 0))
  (labels ((f (n c)
			  (if (< n 3)
				c
				(f (- n 3) (+ c 1))
				)
			  )
		   )
	(format t "~A~%" (f N c))
	)
)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    string s; cin >> s;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R' && s[i + 1] == 'R' && s[i + 2] == 'R'){
            cout << 3 << endl;
            return 0;
        }
        if(s[i] == 'R' && s[i + 1] == 'R'){
            cout << 2 << endl;
            return 0;
        }
        if(s[i] == 'R'){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]){
    int N,K;
    cin >> N >> K;
    int x[N];
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        if (x[i] > K-x[i]){
           ans = ans + 2*(K-x[i]);
        }
        else{
            ans = ans + 2*x[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  case class Point(index: Int, x: Int, y: Int, pattern: Int)

  case class Rect(xs: Int, xe: Int, ys: Int, ye: Int)

  val Array(w, h, n) = StdIn.readLine().split(" ").map(_.toInt)
  val points = (0 until n).map { i =>
    val a = StdIn.readLine().split(" ").map(_.toInt)
    Point(i, a(0), a(1), a(2))
  }

  val r = points.foldLeft(Rect(0, w, 0, h)) { (acc, p) =>
    p.pattern match {
      case 1 => Rect(if (acc.xs < p.x) p.x else acc.xs, acc.xe, acc.ys, acc.ye) // < Xi
      case 2 => Rect(acc.xs, if (acc.xe > p.x) p.x else acc.xe, acc.ys, acc.ye) // > Xi
      case 3 => Rect(acc.xs, acc.xe, if (acc.ys < p.y) p.y else acc.ys , acc.ye) // < Yi
      case 4 => Rect(acc.xs, acc.xe, acc.ys, if (acc.ye > p.y) p.y else acc.ye) // > Yi
    }
  }
  // println(r)
  // println(r.xe - r.xs , r.ye - r.ys)
  println(if(r.xe < r.xs || r.ye < r.ys) 0 else (r.xe - r.xs) * (r.ye - r.ys))
}


Measured memory_bytes: 27164
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
s = deque(s)
q = INT()

r_count = 0
L = [S_LIST() for i in range(q)]
for i in range(q):
    if L[i][0] == "1":
        r_count ^= 1
        # s.reverse()
    else:
        query, sent = int(L[i][1]), str(L[i][2])
        if r_count == 0:
            if query == 1:
                s.appendleft(sent)
            else:
                s.append(sent)
        else:
            if query == 2:
                s.appendleft(sent)
            else:
                s.append(sent)

if r_count != 0:
    s.reverse()
print("".join(list(s)))
    
    




Measured memory_bytes: 46408
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


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

    for (int i=0; i<n; i++) cout << s[i] << t[i];
    cout << endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int main(){
  int N,M;bool f;
  char A[51][51],B[51][51];
  scanf("%d %d",&N,&M);
  for(int i=1;i<=N;i++){
    scanf(" %c",&A[i][1]);
    for(int j=2;j<=N;j++) scanf("%c",&A[i][j]);
  }
  for(int i=1;i<=M;i++){
    scanf(" %c",&B[i][1]);
    for(int j=2;j<=M;j++) scanf("%c",&B[i][j]);
  }
  for(int i=1;i<=N-M+1;i++){
    for(int j=1;j<=N-M+1;j++){
      if(A[i][j]==B[1][1]){
        f=true;
        for(int k=i;k<=i+M-1;k++){
          for(int l=j;l<=j+M-1;l++){
            if(A[k][l]!=B[k-i+1][l-j+1]){
              f=false;break;
            }
            if(!f) break;
          }
        }
        if(f){
          printf("Yes\n");
          return 0;
        }
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
correct = defaultdict(bool)
local_wa = defaultdict(int)

N, M = map(int, input().split())
p = []
s = []
for i in range(M):
    a, b = input().split()
    p.append(int(a))
    s.append(b)
    
ac = 0
wa = 0


for pp in p:
    correct[pp] = False

for pp, ss in zip(p,s):
    if correct[pp]:
        pass
    else:
        if ss == 'AC':
            correct[pp] = True
            ac += 1
            wa += local_wa[pp]
            local_wa[pp] = 0

        elif ss == 'WA':
            local_wa[pp] += 1
print(ac, wa)                


Measured memory_bytes: 75988
#include <iostream>

using namespace std;

int main()
{
    long long x,y;
    char z;
    x>=1;
    y<=1000000000;
    cin>>x>>z>>y;
    if(z=='+'){cout<<x+y<<endl;}
     else if(z=='-'){cout<<x-y<<endl;}
    return 0;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  long N;
  cin >> N;
  map<long, long> A;
  vector<long> v;
  for (int i = 0; i < N; i++) {
    long tmp;
    cin >> tmp;
    A[tmp]++;
  }
  for (auto x : A) {
    int s = x.second;
    for (int i = 0; i < s / 2; i++)
      v.push_back(x.first);
  }
  if (v.size() >= 2) {
    sort(v.begin(), v.end(), ::greater<int>());
    cout << v[0] * v[1] << endl;
  } else {
    cout << 0 << endl;
  }
}


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

int main(){
    int a, b;
    while(cin >> a >> b){
        bool flag = true;
        for(int i = 1; i <= 2000000; i++){
            double temp = (double)i*(0.08);
            ll tempA = floor(temp);
            temp = (double)i*(0.1);
            ll tempB = floor(temp);
            if( tempA == a && tempB == b ){
                cout << i << "\n";
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "-1\n";
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)

string s,s1,s2;

int f(string s3)
{
    string ss=s3;
    reverse(ss.begin(),ss.end());
    if(ss==s3) return 1;
    else return 0;
}
int main()
{
        IO;
        int i, j, n, m, k, l, mx=0;
        cin>>s;
        n=s.size();
        for(i=0; i<n; i++){
            if(i<n/2)s1+=s[i];
            else if(i!=n/2)s2+=s[i];
        }
        if(f(s)&&f(s1)&&f(s2)) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
W, H = map(int, input().split())
P = [int(input()) for _ in range(W)]
Q = [int(input()) for _ in range(H)]
PQ = P + Q
Idx = list(range(W+H))
Idx.sort(key=lambda x: PQ[x])
ans = 0
p = W+1
q = H+1
for idx in Idx:
    if idx >= W:
        ans += PQ[idx] * p
        q -= 1
    else:
        ans += PQ[idx] * q
        p -= 1
print(ans)


Measured memory_bytes: 23916
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    R, C, K, *RCV = map(int, read().split())

    item = dict()
    for r, c, v in zip(*[iter(RCV)] * 3):
        item[(r - 1, c - 1)] = v

    dp = [0] * (C + 1)
    for i in range(R):
        dp, dp_prev = [0] * (C + 1), dp
        v = [0] * 4
        for j in range(C):
            for k in range(4):
                if v[k] < dp_prev[j + 1]:
                    v[k] = dp_prev[j + 1]
            if (i, j) in item:
                for k in range(2, -1, -1):
                    if v[k + 1] < v[k] + item[(i, j)]:
                        v[k + 1] = v[k] + item[(i, j)]
            dp[j + 1] = v[3]

    print(dp[C])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 168936
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
/*
vector<double> rotate(int x0, int y0, int x1,int y1, int a){
    double x = cos(a)*(x1-x0)+sin(a)*(y1-y0) + x0;
    double y = -sin(a)*(x1-x0)+cos(a)*(y1-y0) + y0;
    vector<double> r(2);
    r[0] = x;
    r[1] = y;
    return r;
}
 vector<vector<double> > koch(double x0, double y0, double x1,double y1, int n){
 vector<vector<double> > t(5, vector<double>(2));
 double pt1[2] = {x0+(x1-x0)/3, y0+(y1-y0)/3};
 double pt2[2] = {(x0+(x1-x0))*2/3,(y0+(y1-y0))*2/3};
 double pt3[2] = rotate()
 t[0][0] = x0;
 t[0][1] = y0;
 t[1][0] = x0+(x1-x0)/3;
 t[1][1] = y0+(y1-y0)/3;
 t[2][0] = rotate(x0+(x1-x0)/3,y0+(y1-y0)/3,(x0+(x1-x0))*2/3,(y0+(y1-y0))*2/3,-M_PI/3)[0];
 t[2][1] = rotate(x0+(x1-x0)/3,y0+(y1-y0)/3,(x0+(x1-x0))*2/3,(y0+(y1-y0))*2/3,-M_PI/3)[1];
 t[3][0] = (x0+(x1-x0))*2/3;
 t[3][1] = (y0+(y1-y0))*2/3;
 t[4][0] = x1;
 t[4][1] = y1;
 if(n==1){
 return t;
 }else{
 vector<vector<double> > ta(0);
 for(int i = 0; i < 4; i++){
 vector<vector<double> > tb;
 tb = koch(t[i][0],t[i][1],t[i+1][0],t[i+1][1],n-1);
 ta.insert(ta.end(),tb.begin(),tb.end());
 ta.pop_back();
 }
 ta.insert(ta.end(),t.end(),t.end());
 return ta;
 }
 }
 */
void rotate(double r[2], const double pos0[2], const double pos1[2], double a){
    double x = cos(a)*(pos1[0]-pos0[0])-sin(a)*(pos1[1]-pos0[1]) + pos0[0];
    double y = sin(a)*(pos1[0]-pos0[0])+cos(a)*(pos1[1]-pos0[1]) + pos0[1];
    r[0] = x;
    r[1] = y;
}
void koch(double ans[20000][2], int &k, double s[2], double g[2], int n){
    double pt1[2] = {s[0]+(g[0]-s[0])/3, s[1]+(g[1]-s[1])/3};
    double pt2[2] = {s[0]+(g[0]-s[0])*2/3,s[1]+(g[1]-s[1])*2/3};
    double pt3[2];
    rotate(pt3,pt1,pt2,M_PI/3);
    double t[5][2] = {
        {s[0],s[1]},
        {pt1[0],pt1[1]},
        {pt3[0],pt3[1]},
        {pt2[0],pt2[1]},
        {g[0],g[1]}
    };
    if(n == 0){
        ans[0][0] = s[0];
        ans[0][1] = s[1];
        k++;
    }else if(n == 1){
        for(int i = 0; i < 4; i++){
            ans[k][0] = t[i][0];
            ans[k++][1] = t[i][1];
        }
    }else{
        for(int i = 0; i < 4; i++){
            koch(ans,k,t[i],t[i+1],n-1);
        }
    }
}


int main(){
    int n;
    scanf("%d",&n);
    double ans[20000][2], s[2] = {0,0}, g[2] = {100,0};
    int k = 0;
    koch(ans,k,s,g,n);
    ans[k][0] = g[0];
    ans[k++][1] = g[1];
    for(int i = 0; i < k; i++){
        printf("%f %f\n",ans[i][0],ans[i][1]);
    }
}

Measured memory_bytes: 2976
n,m,k = map(int,input().split())

arr = []
for _ in range(n):
  arr.append(list(input()))
ans = 0  
for i in range(1<<n):
  for j in range(1<<m):
    black = 0
    for q in range(n):
      for r in range(m):
        if i & (1<<q) and j & (1<<r) and arr[q][r] == "#":
          black += 1
    if black == k: ans += 1
print(ans)

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

struct PR {
	int Par;
	int Rank;
};

struct route {
	long long Cost;
	int From;
	int To;
	int WH;
};

static PR PRW[100010], PRH[100010];

void init(int X, PR pr[]) {
	for (int i = 0; i <= X; i++) {
		pr[i].Par = i;
		pr[i].Rank = 0;
	}
}

int root(int X, PR pr[]) {
	if (pr[X].Par == X) return X;
	else return pr[X].Par = root(pr[X].Par, pr);
}

void unite(int X, int Y, PR pr[]) {
	X = root(X, pr), Y = root(Y, pr);
	if (pr[X].Rank < pr[Y].Rank) pr[X].Par = Y;
	else {
		pr[Y].Par = X;
		if (pr[X].Rank == pr[Y].Rank) pr[X].Rank++;
	}
}

bool same(int X, int Y, PR pr[]) {
	return root(X, pr) == root(Y, pr);
}

int main() {
	static long long W, H, A, B, P, Q, ANS = 0;
	auto SORT = [](route R1, route R2) {return R1.Cost > R2.Cost; };
	priority_queue<route, vector<route>, decltype(SORT)> PQ(SORT);
	cin >> W >> H;
	A = W + 1, B = H + 1;
	init(W, PRW);
	init(H, PRH);
	for (int i = 0; i < W; i++) cin >> P, PQ.push(route{ P, i, i + 1, 1 });
	for (int i = 0; i < H; i++) cin >> Q, PQ.push(route{ Q, i, i + 1, 2 });
	while (!PQ.empty()) {
		route R = PQ.top();
		PQ.pop();
		if (R.WH == 1) {
			if (!same(R.From, R.To, PRW)) {
				ANS += R.Cost * B;
				A--;
				unite(R.From, R.To, PRW);
			}
		}
		else {
			if (!same(R.From, R.To, PRH)) {
				ANS += R.Cost * A;
				B--;
				unite(R.From, R.To, PRH);
			}
		}
	}
	cout << ANS;
}

Measured memory_bytes: 10096
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , a[ N ];
void init(){
  n = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
}
void solve(){
  LL sum = 0 , bs = 0;
  for( int i = 0 ; i < n ; i ++ ){
    sum += a[ i ];
    bs += i + 1;
  }
  if( sum % bs ){
    puts( "NO" );
    Bye;
  }
  LL tms = sum / bs , cnt = 0;
  for( int i = 0 ; i < n ; i ++ ){
    LL dlt = a[ ( i + 1 ) % n ] - a[ i ];
    LL tmptms = ( tms - dlt );
    if( tmptms % n || tmptms < 0 ){
      puts( "NO" );
      Bye;
    }
    tmptms /= n;
    cnt += tmptms;
  }
  if( cnt != tms )
    puts( "NO" );
  else
    puts( "YES" );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;


int main()
{
	double ma = DBL_MIN;
	double mi = DBL_MAX;
	double al;
	while (scanf("%lf", &al) != EOF)
	{
		if (al > ma)
			ma = al;
		if (al < mi)
			mi = al;
	}

	printf("%.1f\n", ma-mi);

	return 0;
}

Measured memory_bytes: 0
#include <cstdlib>
#include <set>
#include <cstdio>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int a[100];
int b[100];

int main(){
  int n;
  while(scanf("%d", &n), n){
    char message[110];
    scanf("%s", message);

    REP(i, n){
      scanf("%d%d", &a[i], &b[i]); a[i]--; b[i]--;
    }

    for(int i = n - 1; i >= 0; i--){
      swap(message[a[i]], message[b[i]]);
      int diff = b[i] - a[i];
      int all = 'z' - 'a' + 1;

      message[a[i]] = (message[a[i]] - 'a' + diff) % all + 'a';
      message[b[i]] = (message[b[i]] - 'a' + diff) % all + 'a';
    }
    puts(message);
  }
  return 0;
}

Measured memory_bytes: 0
import math
K = int(input())
ans = 0

#i<j<k
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            gcd_ij_1 = math.gcd(i, j)
            gcd_ijk_1 = math.gcd(gcd_ij_1, k)
            ans += gcd_ijk_1 * 6

for l in range(1, K):
    for m in range(l+1, K+1):
        gcd_lm_1 = math.gcd(l,m)
        ans += gcd_lm_1 * 6

for n in range(1, K+1):
    ans += n

print(ans)


Measured memory_bytes: 9208
//#include <cmath>
//#include <ctime>
#include <cstdio>
#include <climits>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 200005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

int l[MAXN], r[MAXN];

LL a[MAXN];

vector<int> L[MAXN];
vector<int> R[MAXN];

int root, lc[MAXN * 2], rc[MAXN * 2];
LL mx[MAXN * 2], tag[MAXN * 2], ans, qans;

int n, m, tot;

void build(int &x, int l, int r) {
    x = ++tot;
    mx[x] = tag[x] = 0;
    if (l < r) {
        int mid = (l + r) >> 1;
        build(lc[x], l, mid);
        build(rc[x], mid + 1, r);
    }
}


void add(int x, LL val) {
    mx[x] += val;
    tag[x] += val;
}

void push_down(int x) {
    if (tag[x] != 0ll) {
        add(lc[x], tag[x]);
        add(rc[x], tag[x]);
        tag[x] = 0ll;
    }
}

void push_up(int x) {
    mx[x] = max(mx[lc[x]], mx[rc[x]]);
}

void modify(int x, int l, int r, int ll, int rr, LL val) {
    if (ll <= l && r <= rr) {
        add(x, val);
        return;
    }
    push_down(x);
    int mid = (l + r) >> 1;
    if (ll <= mid) modify(lc[x], l, mid, ll, rr, val);
    if (rr > mid) modify(rc[x], mid + 1, r, ll, rr, val);
    push_up(x);
}

void query(int x, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) {
        qans = max(qans, mx[x]);
        return;
    }
    push_down(x);
    int mid = (l + r) >> 1;
    if (ll <= mid) query(lc[x], l, mid, ll, rr);
    if (rr > mid) query(rc[x], mid + 1, r, ll, rr);
}

int main() {
    n = getint();
    m = getint();
    for (int i = 1; i <= m; ++i) {
        l[i] = getint();
        r[i] = getint();
        a[i] = getint();
        L[l[i]].push_back(i);
        R[r[i]].push_back(i);
    }
    build(root, 0, 200001);
    for (int i = 1; i <= n + 1; ++i) {
        for (auto j : L[i])
            modify(root, 0, 200001, 0, l[j] - 1, a[j]);
        qans = LONG_LONG_MIN;
        query(root, 0, 200001, 0, i - 1);
        ans = max(ans, qans);
        #ifdef DEBUGMODE
        printf("%lld\n", qans);
        #endif
        
        modify(root, 0, 200001, i, i, qans);
        for (auto j : R[i])
            modify(root, 0, 200001, 0, l[j] - 1, -a[j]);
    }

    printf("%lld", ans);
}


Measured memory_bytes: 34688
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

double cut(int r,int n,int i){
    double res=r*r-(r-r*(double)i/(double)n)*(r-r*(double)i/(double)n);
    return pow(res,0.5)*2;
}

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0;r*i<=n;i++){
        for(int j=0;r*i+g*j<=n;j++){
            int B=n-g*j-r*i;
            if(B%b==0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, n;
    int a[64];
    
    scanf("%d", &n);
    for ( i = 0; i <= n; i++)
    {
        if (i == 0 || i == 1)
            a[i] = 1;
        else
            a[i] = a[i - 1] + a[i - 2];
    }
    printf("%d\n", a[n]);
    return 0;
    
}


Measured memory_bytes: 2100
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
    int n,a,b,i,j;
    scanf("%d",&n);
    a=0;
    for(i=1;i<=n;i++)
    {
        if(i%2==1)
            a++;
    }
    printf("%.10lf",double(a)/n);
    return 0;
}


Measured memory_bytes: 256
m = []
9.times{|i|
  m[i] = gets.chomp.split("").map(&:to_i)
}

x = 0
y = 0
direc = 0
name = ["R", "D", "L", "U"]

50.times{
  print name[direc]
  if direc == 0
    if y > 0 && x < 8 && m[y-1][x+1] == 1
      direc = 3
      y -= 1
      x += 1
    elsif x < 8 && m[y][x+1] == 1
      x += 1
    elsif y < 8 && x < 8 && m[y+1][x+1] == 1
      direc = 1
      y += 1
      x += 1
    else
      direc = 2
    end
  elsif direc == 1
    if y < 8 && m[y+1][x] == 1
      direc = 0
      y += 1
    elsif y < 7 && m[y+2][x] == 1
      y += 2
    elsif y < 8 && x > 0 && m[y+1][x-1] == 1
      direc = 2
      y += 1
      x -= 1
    else
      direc = 3
    end
  elsif direc == 2
    if y < 8 && m[y+1][x] == 1
      direc = 1
      y += 1
    elsif x > 0 && m[y][x-1] == 1
      x -= 1
    elsif y > 0 && m[y-1][x] == 1
      direc = 3
      y -= 1
    else
      direc = 0
    end
  elsif direc == 3
    if y > 0 && x > 0 && m[y-1][x-1] == 1
      direc = 2
      y -= 1
      x -= 1
    elsif y > 1 && m[y-2][x] == 1
      y -= 2
    elsif y > 0 && m[y-1][x] == 1
      direc = 0
      y -= 1
    else
      direc = 1
    end
  end
  break if x == 0 && y == 0 && direc == 0
}

puts

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;



int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int l = max(A,C);
	int r = min(B,D);
	cout<<max(0, r-l)<<endl;
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vc vector
#define vi vc<int>
#define vvi vc<vi>
#define pqmin priority_queue<int,vector<int>,greater<int>>
#define pqmax priority_queue<int>
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define w(t) int t; cin>>t; while (t--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define out(x) cout<<x<<endl;
#define print(a, n) rep (i, n) cout<<a[i]<<" "; cout<<endl;
#define clr(a, x) memset(a, x, sizeof a)

const int mod = 1e9+7;
const int mod2 = 998244353;
const int N = 2e5;
const int inf = 1e18;

//=====================================================


template<typename... T>
void read(T&... args) {((cin >> args), ...);}
template<typename... T>
void write(T&&... args) {((cout << args << " "), ...);}
template<typename... T>
void writeline(T&&... args) {((cout << args << " "), ...); cout << endl;}

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
string binary(int x) {string res = ""; rep(i, 32) res += (1<<i & x)?'1':'0'; return res; }
int in(int x, int y, int z) { if (y > z) swap(y, z); return (x >= y && x <= z);}
struct customCompare {
    bool operator () (pii x, pii y) {
        return x.first > y.second;
    }
};

//=====================================================


vector<int> g[N+1];
void ipgraph(int n, int m) {

    for (int i=1; i<=n ; i++) 
        g[i].clear();

    while (m--) {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

int vis[N];
void dfs(int u) {
    for (auto v: g[u]) {
        if (vis[v]) continue;
        vis[v] = 1;
        dfs(v);
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    ipgraph(n, m);

    int cc = 0;

    fo (i, 1, n+1) {
        if (vis[i] == 0) {
            cc++;
            vis[i] = 1;
            dfs(i);
        }
    }

    cout << cc-1;
}

int32_t main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);


    solve();

    return 0;                                           
}

Measured memory_bytes: 13420
inputa = input()
isfirstMM = False
islastMM = False
if int(inputa[0:2]) >= 1 and int(inputa[0:2]) <= 12:
  #MMXX
  isfirstMM = True
if int(inputa[2:4]) >= 1 and int(inputa[2:4]) <= 12:
  #XXMM
  islastMM = True

if isfirstMM == True:
  if islastMM == True:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif islastMM == True:
  print("YYMM")
else:
  print("NA")

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

using namespace std;

int a[111111];
int main() {
	int n, k, m = 0;
	string s;
	cin >> n >> k >> s;
	s += '1';
	for (int i = 0; i < n; i++) {
		a[i + 1] = a[i];
		if (s[i] == '0' &&s[i + 1] == '1')
			a[i + 1]++;
	}
	for (int l = 0, r = 1; r <= n;) {
		if (a[r] - a[l] > k) l++;
		else {
			if (r == n || s[r - 1] == '1')
				m = max(m, r - l);
			r++;
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        TreeSet<Integer> set2 = new TreeSet<>();
        int base = 1;
        while (base < 1000000000) {
            base *= 2;
            set2.add(base);
        }
        int n = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (map.containsKey(x)) {
                map.put(x, map.get(x) + 1);
            } else {
                map.put(x, 1);
            }
        }
        int count = 0;
        while (map.size() > 0) {
            int target = map.lastKey();
            map.put(target, map.get(target) - 1);
            if (map.get(target) == 0) {
                map.remove(target);
            }
            int next = set2.higher(target) - target;
            if (map.containsKey(next)) {
                count++;
                map.put(next, map.get(next) - 1);
                if (map.get(next) == 0) {
                    map.remove(next);
                }
            }
        }
        System.out.println(count);
    }
}


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

int main() {
  int N, M = -101, m = 101;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    M = max(M, A.at(i));
    m = min(m, A.at(i));
  }
  int ans = 100000000;
  for (int K = m; K <= M; K++) {
    int S = 0;
    for (int i = 0; i < N; i++) S += (K - A.at(i)) * (K - A.at(i));
    ans = min(ans, S);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Good Sequence
int N;
map<int, int> m;
int ans = 0;

int main(){
    cin >> N;
    rep(i, 0, N){
        int tmp;
        cin >> tmp;
        ++m[tmp];
    }
    for(auto itr = m.begin();itr != m.end();++itr){
        if(itr->first <= itr->second){
            ans += itr->second - itr->first;
        }else{
            ans += itr->second;
        }
    }

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




Measured memory_bytes: 4736
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

s = S()
count = 0
for i in s:
    count += int(i)

if count % 9 == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 68056
import copy

s=list(str(input()))
n=int(input())
s_base = copy.deepcopy(s)
i0 = s[0]
count = 0
if len(s) == 1:
    ans = n//2
else:
    #r1 = n//2 + n%2
    #s

    for i, name in enumerate(s[1:]):
        if name == i0:
            i0 = -1
            count += 1
            s[i+1] = i0
        else:
            i0 = name
    if s[0] == s[-1]:
        al = n-1
        if s[1] == -1:
            s2 = copy.deepcopy(s)
            for i in s_base:
                s2.append(i)
            i0 = s2[0]
            count2 = copy.deepcopy(count)
            for i, name in enumerate(s2[1:]):
                if name == i0:
                    i0 = -1
                    count2 += 1
                    s2[i+1] = i0
                else:
                    i0 = name
            al = (count2 - count*2)*(n//2)
            if s2[0] == s2[-1]:
                al = (count2 - count * 2) * (n-1)
    else:
        al = 0
    ans = count*n + al
print(ans)

Measured memory_bytes: 38480
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	llong x,y;
	cin>>x>>y;
	
	llong ans=1;
	while(1){
		if(2*x>y) break;
		x*=2;
		//cout<<x<<endl;//!!!
		ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m,a500,a100,a50,a10,a5,a1,k,sum=0;
    //cin >> m;
    
    while(true){
        cin >> m;
        if(m==0){
            break;
        }
        for(int i=0;i<5;i++){
            k=1000-m;
            a500=k/500;
            k=k%500;
            a100=k/100;
            k=k%100;
            a50=k/50;
            k=k%50;
            a10=k/10;
            k=k%10;
            a5=k/5;
            k=k%5;
            a1=k;
            sum=a500+a100+a50+a10+a5+a1;
        }
    
    cout << sum << endl;
    }
}


Measured memory_bytes: 3060
#include"stdio.h"
#include<iostream>
#define n_max 500000
#define INF 1000000000;
using namespace std;

int A[n_max] = { 0 };
int L[n_max / 2 + 1] = { 0 };
int R[n_max / 2 + 1] = { 0 };
int cnt = 0;
int n;

void Merge(int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;

	for (int i = 0; i < n1; ++i)
		L[i] = A[left + i];
	for (int i = 0; i < n2; ++i)
		R[i] = A[mid + i];
	L[n1] = R[n2] = INF;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; ++k)
	{
		++cnt;
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			++i;
		}
		else
		{
			A[k] = R[j];
			++j;
		}
	}

	return;
}

void MergeSort(int left, int right)
{
	if (left + 1< right)
	{
		int mid = left + (right - left) / 2;
		MergeSort(left, mid);
		MergeSort(mid , right);
		Merge(left, mid, right);
	}
	return;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	MergeSort(0, n);
	for (int i = 0; i < n; ++i)
		printf("%d%c", A[i], i == n - 1 ? '\n' : ' ');
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 7036
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    //          int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();

    public static void Main()
    {
        int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = split[0];
        int L = split[1];
        int min_abs = int.MaxValue;
        int minimum = int.MaxValue;
        List<int> list = new List<int>();
        for (int i = 0; i < N; i++)
        {
            int taste = L +i;
            if (Math.Abs(taste) < min_abs)
            {
                min_abs = Math.Abs(taste);
                minimum = taste;
            }
            list.Add(taste);

        }
        Console.WriteLine(list.Sum() - minimum);
    }


    

}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int a, b, h, area;


int main()
{
	cin >> a;
	cin >> b;
	cin >> h;
	area = (a + b)*h / 2;
	cout << area << endl;

	
	//system("pause");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int MAX = 2e5;
    int cnt[MAX];
    fill(cnt, cnt+MAX, 0);
    rep(i, N) cnt[A[i]]++;
    int ans = 0, hold = 0;
    int sum = 0;
    rep(i, MAX){
        if(cnt[i] == 0) continue;
        else{
            hold++;
            sum += cnt[i]-1;
        }
    }
    hold -= sum%2;
    cout << hold << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//a
int main(){
  
  string S; cin >> S;
  if(S == "ABC") cout << "ARC" << endl;
  if(S == "ARC") cout << "ABC" << endl;
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
long long n,ans=0,tmp,cmp=1;
int main(){
  cin >> n;
  bool f=false;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[0]!=0){
      f=true;
    }
    if(i>0){
      if(a[i]-a[i-1]>1){
        f=true;
      }
    }
  }
  if(f){
    cout << -1 << endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(a[i]>=a[i+1]){
      ans+=a[i];
    }
  }
  cout << ans+a[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	if s == "Sunny" {
		fmt.Print("Cloudy")
	} else if s == "Cloudy" {
		fmt.Print("Rainy")
	} else if s == "Rainy" {
		fmt.Print("Sunny")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;
	cin >> s;
	int sum = 0;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		sum += (s[i] - '0');
	}
	int x = atoi(s.c_str());

	if (x % sum == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;

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

    int n,w;
    cin >> n >> w;
    vector<int> we(n);
    vector<vector<int>> dp(n+1,vector<int>(w+1));
    rep(i,n) {
        int va,we;
        cin >> va >> we;
        rep(j,w+1) {
            if (j+we<=w) dp[i+1][j+we]=max(dp[i][j+we],dp[i][j]+va);
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
    
    return 0;
}


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

int A, B, K;

int main()
{
	scanf("%d%d%d", &A, &B, &K);
	for (int i = A; i <= min(B, A+K-1); ++i) printf("%d\n", i);
	for (int i = max(B-K+1, A+K); i <= B; ++i) printf("%d\n", i);
}


Measured memory_bytes: 256