akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int n,a[21],b[21],c[21],i,x,sum=0,pre=0;
    scanf("%d",&n);
    for(i=0;i<n+1;i++) a[i]=b[i]=c[i]=0;
    for(i=1;i<n+1;i++) scanf("%d",&a[i]);
    for(i=1;i<n+1;i++) scanf("%d",&b[i]);
    for(i=1;i<n;i++) scanf("%d",&c[i]);
    for(i=1;i<n+1;i++)
    {
        sum+=b[a[i]];
        if(pre+1==a[i]) sum+=c[pre];
        pre=a[i];
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n;
  ll x;
  cin>>n>>x;
  ll a[2*n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i+n]=a[i];
  }
  ll b[n][n], ans=0;
  for(int i=0;i<n;i++){
    b[0][i]=a[i];
    ans+=a[i];
  }
  for(int k=1;k<n;k++){
    ll tmp=k*x;
    for(int i=n;i<2*n;i++){
      b[k][i-n]=min(b[k-1][i-n], a[i-k]);
      tmp+=b[k][i-n];
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 31488
using System;
using System.Linq;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

                if (inputs.All(x => x == 0))
                {
                    goto Finish;
                }

                var height = inputs[0];
                var width = inputs[1];

                for (int i = 0; i < height; i++)
                {
                    for (int j = 0; j < width; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }

                Console.WriteLine();
            }

            Finish:
            return;
        }
    }
}



Measured memory_bytes: 18328
N = int(input())
testimony = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = [int(i) for i in input().split()]
        x -= 1
        testimony[i].append((x, y))


def judge(bit: int) -> bool:
    for i in range(N):
        if not (bit & (1 << i)):
            continue

        for x, y in testimony[i]:
            if ((bit >> x) & 1) ^ y:
                return False

    return True


def main() -> None:
    res = 0
    for bit in range(1 << N):
        count = 0
        if judge(bit):
            for i in range(N):
                if bit & 1 << i:
                    count += 1
            res = max(res, count)

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
typedef vector<vector<int> > vvi; 
typedef pair<int, int> P;

int h, w, c;
vector<vector<int> > p;

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

bool contain(int y, int x){
	return (0 <= y && y < h && 0 <= x && x < w);
}

int ans = 0;

vvi change(vvi a, int k, int y = 0, int x = 0){
	int color = a[y][x];
	bool f[10][10] = {};
	queue<P> q;
	q.push(P(y, x));
	f[y][x] = true;
	a[y][x] = k;
	ans = 1;
	while(!q.empty()){
		P p = q.front(); q.pop();
		rep(i, 0, 4){
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if(!contain(ny, nx) || f[ny][nx]) continue;
			// cout << 2 << endl;
			f[ny][nx] = true;
			if(a[ny][nx] != color) continue; 
			a[ny][nx] = k;
			ans++;
			q.push(P(ny, nx));
		}
	}
	return a;
}

int main(){
	while(1){
		cin >> h >> w >> c;
		// cout << h << w << c << endl;
		c--;
		if(h + w + c == -1) break;
		p.clear();
		p.resize(h, vector<int>(w));
		rep(i, 0, h){
			rep(j, 0, w){
				cin >> p[i][j];
				p[i][j]--;
			}
		}
		// cout << 1 << endl;
		int MAX = 0;
		rep(i, 0, 6){
			vvi a = change(p, i);
			rep(j, 0, 6){
				vvi b = change(a, j);
				rep(k, 0, 6){
					vvi d = change(b, k);
					rep(l, 0, 6){
						vvi e = change(d, l);
						vvi g = change(e, c);
						vvi z = change(g, 0);
						// if(MAX < ans){
						// 	rep(y, 0, h){
						// 		rep(x, 0, w){
						// 			cout << z[y][x];
						// 		}
						// 		cout << endl;
						// 	}
						// 	cout << endl;
						// }
						MAX = max(MAX, ans);
					}
				}
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3144
N = int(input())
L1 = []
for i in range(N) :
    L1.append(input())
M = int(input())
L2 = []
for i in range(M) :
    L2.append(input())
ans = -10**8
L3 = list(set(L1))
for i in range(len(L3)) :
    p = L1.count(L3[i])
    q = L2.count(L3[i])
    if ans < p-q :
        ans = p-q
if ans < 0 :
    ans = 0
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
 
int main(){
    char ch;
    while((ch = getchar()) != EOF){
            if(ch >= 97 && ch <= 122)
                printf("%c",ch-32);
            else if(ch >= 65 && ch <= 90)
                printf("%c",ch+32);
            else
                printf("%c",ch);
    }
}



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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int x;
  cin >> x;
  int ans = 1;
  forr(i,2,x+1){
    int a = i*i;
    forr(j,2,11){
      if(a>x){
        continue;
      }else {
        ans= max(ans,a);
        a*=i ;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <math.h>
#include <stack>
#include <cctype>
using namespace std;
#define int long long
#define pi 2*acos(0.0)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	string s;
	cin >> s;
	int min = 999;
	int max = 0;
	REP(i, s.length()){
		if (s[i] == 'A'){
			min = i; break;
		}
	}
	for (int i = s.length()-1; i >= 0; i--){
		if (s[i] == 'Z'){
			max = i; break;
		}
	}
	cout << max - min + 1 << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
#define INF 0x3f3f3f3f
#define CLR(a) memset(a, 0, sizeof(a))
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int x,y;
	while(cin>>x>>y){
		cout<<x+y/2<<endl;
	}
	return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    ll ans = 1e16;
    vector<ll> A(N+2),S(N+2);
    REP(i,N){
        cin >> A[i+1];
        S[i+1] = A[i+1] + S[i];
    }

    FORq(i,1,N-1){
        ll left = S[i];
        ll right = S[N] - S[i];
        //DB2(i,abs(right-left));
        //DB2(left,right);
        chmin(ans,abs(right-left));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
n = int(input())
s = input()
count_r = s.count("R")
count_g = s.count("G")
count_b = s.count("B")
sum = count_r * count_g * count_b
minus = 0

for i in range(n-2):
    for j in range(2, n-i+1, 2):
        if i+j <= n-1:
            tem = [s[i], s[i+j//2], s[i+j]]
            if tem[0] != tem[1] and tem[0] != tem[2] and tem[1] != tem[2]:
                minus += 1
            

print(sum - minus)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
const int N=100010;lint ps[N],ss[N];int a[N],sg[N],R[N];
inline lint S(int l,int r) { if(l>r) return 0;return ss[r]-ss[l-1]; }
int main()
{
	int n=inn();a[1]=inn(),ps[1]=a[1],ss[1]=a[1];
	for(int i=1;i<n;i++)
	{
		while((sg[i]=gc)!='+'&&sg[i]!='-');a[i+1]=inn();
		if(sg[i]=='+') ps[i+1]=ps[i]+a[i+1];
		else ps[i+1]=ps[i]-a[i+1];ss[i+1]=ss[i]+a[i+1];
	}
	R[n]=n;lint ans=ps[n];for(int i=n-1;i;i--) if(sg[i]=='+') R[i]=R[i+1];else R[i]=i;
	rep(i,1,n-1) if(sg[i]=='-')
		ans=max(ans,ps[i]-S(i+1,R[i+1])+ss[n]-ss[R[i+1]]);
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 2944
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		long[] R = new long[N];
		for(int i = 0; i < N; i++){
			R[i] = scanner.nextLong();
		}
		long tmp = R[0];
		long max = Integer.MIN_VALUE;
		for(int i = 0; i < N-1; i++){
			if(tmp >= R[i]){
				tmp = R[i];
			}
			max = Math.max(R[i+1]-tmp, max);
		}
		System.out.println(max);
	}
}



Measured memory_bytes: 103736
from itertools import permutations
n=int(input())
p="".join(input().split())
q="".join(input().split())
N=""
for i in range(1,n+1):
  N += str(i)
perms = list(permutations(N,n))
for i in range(len(perms)):
  perms[i] = "".join(list(perms[i]))

print(abs(perms.index(p) - perms.index(q)))

Measured memory_bytes: 8180
function main(input) {
  input=input.trim();
  const x = parseInt(input.split(" ")[0], 10);
  const a = parseInt(input.split(" ")[1], 10);
  const b = parseInt(input.split(" ")[2], 10);
  if(b<=a){
    console.log("delicious");
  }else if(b-a<=x){
    console.log("safe");
  }else{
    console.log("dangerous");
  }

  

}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;
int main(void){
    int N,K;
    cin>>N>>K;
    int A[N];
    
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N);
    reverse(A,A+N);
    int T;
    T=0;
    for(int i=0;i<K;i++){
        T=T+A[i];
    }
    
     
    cout<<T<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())
if H > W:
    if N%H == 0:
        print(N//H)
    else:
        print(N//H+1)
else:
    if N%W == 0:
        print(N//W)
    else:
        print(N//W+1)


Measured memory_bytes: 3316
/*
ID: sstfmsc1
TASK: milk2
LANG: C++
*/
#include <bits/stdc++.h>
 
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( int i = 0; i < (int)n; ++i )
#define MAXN 50000
#define INF 1000000
typedef long long ll;
const char nl = '\n';
ll MOD = (ll)(1e9 + 7);
 
void solve()
{
    int n; cin >> n;
    vector<ll> a(n);
    forin(i, n) cin >> a[i];

    ll suma = 0, mayor = 0;
    forin(i, n)
    {
        mayor = max(mayor, a[i]);
        suma += max(0LL, mayor - a[i]);
    }

    cout << suma << nl;
    return;
}
 
int main()
{
    //freopen("milk2.in", "r", stdin);
    //freopen("milk2.out", "w", stdout);
    //IOS
    //int q; cin >> q;
    //while(q--) 
    solve();
        
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    cout << n*(n+1)/2 << endl;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;








int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int a,b,c; cin >> a >> b >> c;
  	if(a<= c && c<=b) cout << "Yes"<<endl;
  	else cout << "No"<< endl;
    
    
    
    
    
    
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int q; cin >> q;
rep(i, 0, q){
    string X, Y; cin >> X >> Y;
    // lsc[x][y] = X の x文字目 とYの y 文字目まで を見た時のlcs
    VVI lcs(X.size()+1, VI(Y.size() + 1, 0));
    rep(x, 1, X.size()+1){
        rep(y, 1, Y.size()+1){
            if (X[x-1] == Y[y-1])
                lcs[x][y] = lcs[x-1][y-1] + 1;
            else
                lcs[x][y] = max(lcs[x][y -1], lcs[x-1][y]);
        }
    }

    cout << lcs[X.size()][Y.size()] << "\n";
}

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり




Measured memory_bytes: 10884
# AGC011B - Colorful Creatures
def main():
    N, *A = map(int, open(0).read().split())
    A.sort()
    total, ng = 0, 0
    # ng := max index where A[i] > sum(A[:i]) * 2
    for i, a in enumerate(A):
        if a > total * 2:
            ng = i
        total += a
    ans = N - ng
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14284
#include <stdio.h>

int main(void)
{
  int n,i;

  i = 0;
  while(i < 50){
    int ans = 0;
    scanf("%d", &n);
    if( n == -1){
      break;
    }
    if(n <= 36){
      for(int a = 0;a <= 9;a++){
	for(int b = 0;b <= 9;b++){
	  for(int c = 0;c <= 9;c++){
	    for(int d = 0;d <= 9;d++){
	      if((a+b+c+d) == n){
		ans++;
	      }
	    }
	  }
	}
      }
    }
    printf("%d\n", ans);
    i++;
  }
  return 0;
}

Measured memory_bytes: 2584
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

struct UnionFind {
    vector<int> parent;
    vector<int> rank;
    UnionFind() {}
    void init(int size) { parent.assign(size, -1); rank.assign(size, 0); }
    int operator[](int x) { return find(x); }
    int find(int x) { return parent[x] < 0 ? x : (parent[x] = find(parent[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
    bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        return rank[x] = max(rank[x], rank[y] + 1), parent[x] += parent[y], parent[y] = x, 1;
    }
    bool uniteByRank(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        else if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) ++rank[x];
        return parent[x] += parent[y], parent[y] = x, 1;
    }
    bool uniteBySize(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        else if (size(x) < size(y)) swap(x, y);
        return rank[x] = max(rank[x], rank[y] + 1), parent[x] += parent[y], parent[y] = x, 1;
    }
};

int main() {
    int N;
    cin >> N;
    vector<pair<pair<int, int>, int>> xy(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        xy[i] = mp(mp(x, y), i);
    }

    vector<pair<int, pair<int, int>>> edges;
    sort(all(xy));
    rep(i, N - 1) {
        edges.emplace_back(abs(xy[i].first.first - xy[i + 1].first.first), mp(xy[i].second, xy[i + 1].second));
    }
    sort(all(xy), [](auto& l, auto& r) { return l.first.second < r.first.second; });
    rep(i, N - 1) {
        edges.emplace_back(abs(xy[i].first.second - xy[i + 1].first.second), mp(xy[i].second, xy[i + 1].second));
    }
    sort(all(edges));

    UnionFind uf;
    uf.init(N);
    ll ans = 0;
    rep(i, edges.size()) {
        if (uf.uniteByRank(edges[i].second.first, edges[i].second.second)) {
            ans += edges[i].first;
        }
    }
    write(ans);
}

Measured memory_bytes: 6004
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nq = readints;
    int n = nq[0], q = nq[1];
    string s = read!string;

    // acc[i] = [0..1] までの AC の出現回数
    auto acc = new int[s.length];
    for (int i = 1; i < s.length; i++) {
        int x = s[i] == 'C' && s[i-1] == 'A';
        acc[i] = x + acc[i - 1];
    }

    foreach (_; 0..q) {
        auto lr = readints;
        int l = lr[0] - 1;
        int r = lr[1] - 1;

        int x = acc[r] - acc[l];
        writeln(x);
    }
}


Measured memory_bytes: 4476
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int Z = S.size();
	vector<char>al(26);
	al = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	vector<int>M(26);
	rep(i, Z) {
		rep(j, 26) {
			if (S[i] == al[j]) {
				M[j]++;
			}
		}
	}
	rep(i, 26) {
		if (M[i] == 0) {
			cout << al[i] << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n, t;cin>>n>>t;
  vector<int> a(n);
  rep(i, n){
    cin>>a[i];
  }
  vector<int> m(n);
  m[0]=a[0];
  rep(i, n-1){
    m[i+1]=min(m[i], a[i+1]);
  }
  int cnt=0, Md=-1;;
  rep(i, n){
    Md=max(Md, a[i]-m[i]);
  }
  rep(i, n){
    if(a[i]-m[i]==Md)cnt++;
  }
  cout<<cnt<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] count) {

		Scanner scan = new Scanner(System.in);

		int n = Integer.parseInt(scan.next());

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(scan.next());
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(scan.next());
		}
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(scan.next());
		}

		scan.close();

		// start
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);

		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (binarySearchA(a, b[i]) + 1) * (n - binarySearchC(c, b[i]));
		}

		System.out.println(ans);

	}

	private static long binarySearchA(int[] array, int key) {
		int ok = -1;
		int ng = array.length;

		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] < key) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		return ok;

	}

	private static long binarySearchC(int[] array, int key) {
		int ng = -1;
		int ok = array.length;

		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (array[mid] > key) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		return ok;
	}

}


Measured memory_bytes: 64552
/* 
 * Author: sr1jan
 * I shall taste the blood...
 *
*/
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mp make_pair
#define pb push_back

typedef long long ll;
// global 

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

void solve(){
    int n, m;
    cin>>n>>m;
    vector<pair<int,int>> sc;
    for(int i=0; i<m; i++){
        int s, c;
        cin>>s>>c;
        sc.pb(mp(c,s-1));
    }

    int ans = -1;
    for(int num=1000; num>=0; num--){
        string nm = to_string(num);
        bool c = true;
        if(nm.size()!=n) c = false; 
        for(int i=0; i<m; i++){
            if(nm[sc[i].se] != (char)('0'+sc[i].fi)) c = false;
        }
        if (c) ans = num;
    }
    cout << ans << endl;
    return;

    /* int ans[n]; */
    /* bool state[n]; */
    /* memset(state, false, sizeof state); */
    /* memset(ans, 0, sizeof ans); */
    /* sort(all(sc)); */

    /* for(auto sci: sc){ */
    /*     cout << sci.fi << ' ' << sci.se << endl; */
    /* } */

    /* for(auto sci: sc){ */
    /*     if(sci.se==0&&sci.fi==0&&n>1) continue; */
    /*     if(state[sci.se]==false){ */
    /*         ans[sci.se] = sci.fi; */
    /*         state[sci.se] = true; */
    /*     } */
    /* } */

/*     if((ans[0]==0||state[0]==false)&&n>1){ */
/*         cout << -1 << endl; */
/*         return; */
/*     }else{ */
/*         for(auto d: ans){ */
/*             cout << d; */
/*         } */
/*         cout << '\n'; */
/*         return; */
/*     } */

}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

    solve();

}


Measured memory_bytes: 256
/**
 *    author:  zjsdut
 *    created: 2020/01/20 06:29:33
**/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template<typename A, typename B>
bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template<typename A, typename B>
bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec) stream >> x;
  return stream;
}

void scan() {}

template<class T, class ...Args>
void scan(T &a, Args &...rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template<typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n) for(int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x: cont)
#define For(x, cont) for (auto &x: cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template<typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template<typename T>
void print(const vector<T> &t) { cout << t << '\n'; }

template<typename T>
void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template<typename T>
void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
  print(t);
  print(rest...);
}

template<typename T>
void println(const T &t) { cout << t << '\n'; }

template<typename T, typename ...Args>
void println(const T &t, const Args &...rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n;
  scan(n);
  vi p(n);
  scan(p);
  int mi = n;
  int ans = 0;
  rng (i, 0, n) {
    chkmin(mi, p[i]);
    if (mi == p[i]) {
      ++ans;
    }
  }
  println(ans);
  return 0;
}


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

int main() {
    bool res = false;
    for (int i = 0; i < 3; ++i) {
        if (cin.get() == '7') {
            res = true;
        }
    }
    cout << (res ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main(){
    int a, b;
    while(cin >> a >> b){
        if(a==0&b==0)
            break;
        for(int j=0;j<a;j++){
            for(int i=0;i<b;i++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;


int p[50];
int is[50];
int r, n;

int C(double t){
  if(p[20] < t) return 0;
  for(int i=0;i<41;i++){
    int x = i-20;
    if(SQ((t-r)-p[i])+SQ(x)  < SQ(r)) return 0;
  }
  return 1;
}
int main()
{
  while(1){
    cin >> r >> n;
    if(r == 0 && n == 0) return 0;
    memset(p, 0, sizeof(p));
    memset(is, -1, sizeof(is));
    int maxh = 0;
    int xl[32], xr[32], h[32];
    pii x[32];
    rep(i, n){
      cin >> xl[i] >> xr[i] >> h[i];
      //      cin >> x[i].first.first >> x[i].first.second >> x[i].second;
      for(int j=xl[i]+1;j<xr[i];j++){
	//      for(int j=x[i].first.first+1;j<x[i].first.second;j++){
	//	  cout << i << " " << j << " " << p[39] << endl;
	if(p[j+20] < h[i]){
	  //	if(p[j+20] < x[i].second){
	  //	  cout << p[j+20] << " " << x[i].second << endl;
	  //	  p[j+20] = x[i].second;
	  p[j+20] = h[i];
	}
	//	p[j+20] = max(p[j+20], x[i].second);

      }
      //      for(int j=x[i].first.first;j<=x[i].first.second;j++) is[j] = 0;
      maxh = max(maxh, h[i]);
    }
    sort(x, x+n);
    rep(i, n) rep(j, n){
      if(i == j) continue;
      //      if(x[i].first.second == x[j].first.first)
      //	p[x[i].first.second+20] = max(p[x[i].first.second+20], min(x[i].second, x[j].second));
      if(xr[i] == xl[j])
	p[xr[i]+20] = max(p[xr[i]+20], min(h[i], h[j]));
    }
    //    rep(i, 41) cout << p[i] << " "; cout << endl;
    double lb = 0.0, ub = maxh;
    rep(i, 100){
      double mid = (lb+ub)/2;
      //      cout << mid << endl;
      if(C(mid)) lb = mid;
      else ub = mid;
    }
    printf("%.12f\n", lb);
  }
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
using namespace std;
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100009;
int a[N];
int main(){
    GO();
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int mx=a[0];
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            mx=max(mx,a[i]);
        }
        else if(mx-a[i]>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

   vector<int> v(26,0);
   for(char c : s)
    v[c-'a']++;

   for(int index = 0 ;index < 26;index++)
    if(!v[index])
   {
     cout<<(char)('a'+index)<<endl;
       return 0;
   }
   cout<<"None"<<endl;

 return 0;
}


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

const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};

int main() {
    int N; cin >> N;
    vector<int> t(N), x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool can = true;
    for (int i = 0; i < N; i++) {
        int dist = 0; int diff = 0;
        if (i == 0) {
            diff = t[i];
            dist += x[i]+y[i];
        }
        else {
            diff = t[i]-t[i-1];
            dist += abs(x[i]-x[i-1]);
            dist += abs(y[i]-y[i-1]); 
        }

        if (dist % 2 != diff % 2 || dist > diff) can = false;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(){
	int n,r;
	while(1){
		cin>>n>>r;
		if(n==0&&r==0){
			break;
		}

		int *a;
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = n-i;
		}
		for(int i=0;i<r;i++){
			int p,c;
			cin>>p>>c;
			int *data1,*data2;
			data1 = new int[p];
			data2 = new int[c];

			for(int i=0;i<p-1;i++){
				data1[i]=a[i];
			}
			for(int i=0;i<c;i++){
				data2[i]=a[i+p-1];
			}
			for(int i=0;i<c;i++){
				a[i]=data2[i];
			}
			for(int i=0;i<p-1;i++){
				a[i+c]=data1[i];
			}
		}

		cout<<a[0]<<endl;
	}
	return 0;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    #if 0
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    vector<int> t(q);
    for(int i=0; i<q; i++){
        cin >> t[i];
    }

    int cnt = 0;
    for(int i=0; i<q; i++){    
        int left = 0, right = n-1;
        if(s[0] == t[i]){
            cnt++;
            continue;
        }
        while(right - left > 1){
            int mid = (left + right)/2;
            if(s[mid] < t[i]){
                left = mid;
            }
            else{
                right = mid;
            }
        }
        if(s[right] == t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;

    #else
    
    int n;
    cin >> n;
    set<int> s;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        s.insert(x);
    }
    int q;
    cin >> q;
    set<int> t;
    for(int i=0; i<q; i++){
        int x;
        cin >> x;
        t.insert(x);
    }

    set<int> inter;
    set_intersection(s.begin(), s.end(), t.begin(), t.end(), inserter(inter, inter.begin()));
    cout << inter.size() << endl;

    #endif

    return 0;
}


Measured memory_bytes: 10092
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M
B=[0]*M
S=[]
for i in range(M):
	A[i],B[i]=map(int,input().split())
	if H[A[i]-1]<H[B[i]-1]:
		S.append(A[i])
	elif H[A[i]-1]>H[B[i]-1]:
		S.append(B[i])
	else:
		S.append(A[i])
		S.append(B[i])
As=set(S)
count=len(As)
print(N-count)

Measured memory_bytes: 24404
"use strict";
    
const main = arg => {
    const s = arg.split("\n")[0].split("").sort().join("");
    const t = arg.split("\n")[1].split("").sort().reverse().join("");
    
    if(s < t) {
        console.log("Yes");   
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less   
using namespace __gnu_pbds;  
using namespace std;  
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> set1;
ll find(ll a,ll p[])
{
   //cout<<"find "<<a<<endl;
   if(a==p[a])
   return a;
   else return p[a]=find(p[a],p);

}
void join(ll a,ll b,ll p[],ll sz[])
{
   a=find(a,p);
   b=find(b,p);
   if(a!=b)
   {
      if(sz[a]<sz[b])
      swap(a,b);
      sz[a]+=sz[b];
      p[b]=a;
   }
}
ll power(ll a,ll b,ll mod)
{
   ll res=1;
   while(b>0)
   {
      if(b&1)
      res=(res*a)%mod;
      b=b/2;
      a=(a*a)%mod;
   }
   return res;
}
ll inverse(ll x, ll p)
{
   return power(x,p-2,p);
}
ll hash1(ll x,ll y)
{
   return x+y+x*y;
}
ll f[200000]={0};
ll mod=1000000007;
void ini()
{
   f[0]=1;
   for(ll i=1;i<=200000;i++)
   f[i]=(i*f[i-1])%mod;
}



ll ncr(ll n,ll r)
{
   ll res=1;
   ll k=f[n];
   ll v=inverse(f[n-r],mod);
   ll u=inverse(f[r],mod);
   ll x=(u*v)%mod;
   k=(k*x)%mod;
   return k;
}
struct edge
{
   ll from;
   ll to;
};
void dfs(ll v,ll vis[],ll dp[],vector<ll> adj[])
{
   ll k=adj[v].size();
   for(ll i=0;i<k;i++)
   {
      ll u=adj[v].at(i);
      if(vis[u]==0)
      {
         vis[u]=1;
         dfs(u,vis,dp,adj);
         dp[v]=max(dp[v],dp[u]+1);
      }
      else
      dp[v]=max(dp[v],dp[u]+1);
   }
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n,k;
   cin>>n>>k;
   ll a[n];
   for(ll i=0;i<n;i++)
   cin>>a[i];
  ll dp[k+1]={0};
for(ll j=1;j<=k;j++)
{
   for(ll i=0;i<n;i++)
   {
      if(j-a[i]>=0 && dp[j-a[i]]==0)
      dp[j]=1;
   }
}
if(dp[k])
cout<<"First"<<endl;
else
cout<<"Second"<<endl;
return 0;
}

Measured memory_bytes: 1024
from sys import stdin
X, Y = (int(i) for i in input().split())

price = [300000, 200000, 100000]
total = 0
if X == 1 and Y == 1:
    print(1000000) 
else:
    if X < 4:
        total += price[X-1]
    if Y < 4:
        total += price[Y-1]
    print(total)


Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node {
  int key;
  struct Node *prev, *next;
};  
struct Node *nil;

int main(void){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d",com, &key);
    if(com[0] == 'i') {
      insert(key);
      np ++;
      size++;
    }else if(com[0] == 'd') {
      if(strlen(com) > 6) {
	if( com[6] == 'F') {
	  deleteFirst();
	}else if(com[6] == 'L') {
	  deleteLast();
	}
      }else {
	deleteKey(key);
	nd ++;
      }
      size --;
    }
  }
  printList();
  return 0;
  
}

void init() {
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}
  
void insert(int key) {
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}
  
struct Node* listSearch(int key) {
  struct Node *cur = nil->next;
  while(cur != nil && cur->key != key ) {
    cur = cur-> next;
  }
  return cur;
}
  
void deleteNode(struct Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
  
void deleteFirst() {
  deleteNode(nil->next);
}
  
void deleteLast() {
  deleteNode(nil->prev);
}
void deleteKey(int key) {
  deleteNode(listSearch(key));
}
  
void printList() {
  struct Node *cur;
  cur = nil->next;
  int isf = 0;
  
  while(1) {
    if (cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

Measured memory_bytes: 31788
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll x,n; cin>>x>>n;
  if(!n){
    cout<<x<<endl;
    return 0;
  }
  bitset<102> bs;
  rep(i,n){
    int a; cin>>a;
    bs.set(a,true);
  }
  for(int i=0;;i++){
    if(!bs.test(x-i)){
      cout<<x-i<<endl;
      break;
    }
    if(!bs.test(x+i)){
      cout<<x+i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

using tl = tuple<ll, ll, ll>;

istream& operator>>(istream& in, tl& t)
{
    ll p,q,r;
    cin >> p >> q >> r;
    t = tl{p,q,r};
    return cin;
}

int n, m;
tl a[1000];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    ll sol = 0;
    for (int i = 0; i < (1 << 3); ++i)
    {
        ll cst[1000];
        for (int j = 0; j < n; ++j)
        {
            ll p,q,r;
            tie(p,q,r) = a[j];
            if (i & 1)
                p *= -1;
            if (i & 2)
                q *= -1;
            if (i & 4)
                r *= -1;
            cst[j] = p + q + r;
        }
        sort(cst, cst + n);
        reverse(cst, cst + n);
        ll sum = 0;
        for (int j = 0; j < m; ++j)
            sum += cst[j];
        sol = max(sol, sum);
    }
    cout << sol;
}


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

string d="";
int k(int a) {
	int b = 0;
	for (; a < d.length(); a++) {
		b = b * 10 + d[a] - 48;
	}
	return b;
}
int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c = 0;
		cin >> d;
		unordered_set<string>j;
		while (c++,1) {
			if (d.length() == 1) { cout << c-1 << endl; break; }
			int MAX = 0;
			int l =0,r=k(0);
			for (int f = 0; f < d.length(); f++) {
				MAX = max(MAX, l*r);
				l = l * 10 + d[f] - 48;
				r = k(f + 1);
			}
			d = to_string(MAX);
			if (j.find(d) != j.end()) { puts("-1"); return 0; }
			j.insert(d);
		}
	}
}

Measured memory_bytes: 3276
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin >> N){
    int ans = 1;
    for(int i = 1; i <= N; i++){
      ans += i;
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  vector<int> vec(3);
  
  for (int i=0; i<3; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  if (vec.at(0)==5 && vec.at(1)==5 && vec.at(2)==7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256