akhauriyash/Code-Regression huggingface dataset:
public class Main {
	MyScanner sc = new MyScanner();

	void run() {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] dp = new int[H][W];
		int max = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				dp[i][j] = (sc.nextInt() == 0) ? 1 : 0;
				max = Math.max(max, dp[i][j]);
			}
		}
		for (int i = 1; i < H; i++) {
			for (int j = 1; j < W; j++) {
				if (dp[i][j] == 0) continue;
				dp[i][j] = Math.min(dp[i - 1][j], Math.min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
				max = Math.max(max, dp[i][j]);
			}
		}
		System.out.println(max * max);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
	}
}

Measured memory_bytes: 33404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b < c + d) cout << "Right";
    else if(a + b > c + d) cout << "Left";
    else cout << "Balanced";
}

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

int main(){
	string S;
	int ans = 0;
	cin >> S;
	for(int i = 0; i < 4; i++)
	{	
		if(S[i] == '+') ans++;
		else if(S[i] == '-') ans--;
	}
	cout << ans << endl;
		
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
  int i,j;
  int N;
  long ans=0;

  scanf("%d",&N);

  int d[N+1];

  for(i=1; i<=N; i++){
    scanf("%d",&d[i]);
  }

  for(i=1;i<=N-1; i++){
    for(j=i+1; j<=N; j++){
      ans+=d[i]*d[j];
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	//ABC165 A
	int k, a, b;
	// K
	// A B
	//cin >> x >> y >> a >> b >> c;

	cin >> k;
	cin >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}

	cout << "NG";

	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  bool flag = true;
  for (int i = 1; i < 1010; i++){
    if (floor(i * 0.08) == a && floor(i * 0.1) == b){
      cout << i;
      flag = false;
      break;
    }
  }
  if (flag) cout << -1;
}

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

int main(void){

    int a, b, c;

    scanf("%d%d%d", &a, &b, &c);

    int max;

    if(a >= b && a >= c){
        max = a;
    }else if(b >= a && b >= c){
        max = b;
    }else{
        max = c;
    }

    printf("%d\n", a+b+c-max);

    return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
int a;
  cin>>a;
  cout<<"ABC"<<a<<endl;
	return 0;
}

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

using namespace std;

const int MOD = 1000000007;

void add(int &x, int y) { if ((x += y) >= MOD) x -= MOD; }

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N, M; cin >> N >> M;
   vector<array<int, 2>> dp(N + 1);
   for (int i = 0; i <= N; ++i) dp[i][i == 0] = 1;
   for (int z = 0; z < M; ++z) {
      vector<array<int, 2>> ndp(N + 1);
      for (int i = 0; i <= N; ++i) {
         for (int j = 0; j < 2; ++j) {
            if (i > 0) {
               add(ndp[i - 1][j | (i == 1)], dp[i][j]);
               add(ndp[i][j | (i == 1)], dp[i][j]);
            }
            if (i < N) {
               add(ndp[i][j], dp[i][j]);
               add(ndp[i + 1][j], dp[i][j]);
            }
         }
      }
      dp = move(ndp);
   }
   int ans = 0;
   for (int i = 0; i <= N; ++i) add(ans, dp[i][1]);
   cout << ans << '\n';
   return 0;
}


Measured memory_bytes: 3636
while 1:
    n = input()
    if n == 0:
        break
    s = raw_input()
    Q = set()
    lock = 0
    P = []
    for c in s:
        if c is 'u':
            lock = 0
        else:
            v = (lock, 1 << int(c))
            if v not in Q:
                P.append(v)
                Q.add(v)
            lock |= 1 << int(c)
    i = 0; ok = 1
    while i < len(P) and ok:
        lock1, t1 = P[i]
        if lock1 & t1 == t1:
            ok = 0
        for j in xrange(i):
            lock2, t2 = P[j]
            if lock1 & lock2 == 0 and t1 & lock2 == t1:
                if t2 & lock1 == t2:
                    ok = 0
                v = (lock1 | lock2, t2)
                if v not in Q:
                    P.append(v)
                    Q.add(v)
        i += 1
    print "SAFE"*ok or "UNSAFE"

Measured memory_bytes: 6628
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "Yes" << endl
#define no                 cout << "No" << endl
#define inf                3223372036854775807
#define endl               '\n' 
#define PI                  3.14159265
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
  //  cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        cin >> m;
        if(m % 2)
        {
        	no;
        	continue;
        	// return 0;
        }
        if(m < 2 * n or m > 4 * n)
        {
        	no;
        	continue;
        	// return 0;
        }
        yes;
    }
    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

int n,want;
vector<int> a;
vector<int> b;
vector<int> ans;

vector<int> inv(const vector<int> &a) { vector<int> ret(n); REP(i,n) ret[a[i]]=i; return ret; }
vector<int> combine(const vector<int> &a,const vector<int> &b) { vector<int> ret(n); REP(i,n) ret[i]=a[b[i]]; return ret; }
vector<int> pw(vector<int> x,int k) { vector<int> ret(n); REP(i,n) ret[i]=i; while(true) { if(k&1) ret=combine(ret,x); if((k>>=1)==0) return ret; x=combine(x,x); } }

void solve() {
	if(want==1) { ans=a; return; }
	vector<int> ainv=inv(a),binv=inv(b);
	int nfull=(want-2)/6,nrem=(want-2)%6;
	vector<int> leftperiod=combine(b,combine(ainv,combine(binv,a)));
	vector<vector<int>> mid(6);
	mid[0]=b;
	mid[1]=combine(b,ainv);
	mid[2]=combine(b,combine(ainv,binv));
	mid[3]=combine(b,combine(ainv,combine(binv,combine(a,binv))));
	mid[4]=combine(b,combine(ainv,combine(binv,combine(a,combine(a,binv)))));
	mid[5]=combine(b,combine(ainv,combine(binv,combine(a,combine(b,combine(a,binv))))));
	vector<int> leftfull=pw(leftperiod,nfull);
	ans=combine(leftfull,combine(mid[nrem],inv(leftfull)));
}

void run() {
	scanf("%d%d",&n,&want);
	a=vector<int>(n); REP(i,n) scanf("%d",&a[i]),--a[i];
	b=vector<int>(n); REP(i,n) scanf("%d",&b[i]),--b[i];
	solve();
	REPSZ(i,ans) { if(i!=0) printf(" "); printf("%d",ans[i]+1); } puts("");
}

bool isopp(char a,char b) { return a!=b&&tolower(a)==tolower(b); }
void research() {
	vector<string> ops(101);
	ops[1]=string("a");
	ops[2]=string("b");
	FORE(i,3,100) {
		ops[i]=ops[i-1]; for(int j=SZ(ops[i-2])-1;j>=0;--j) ops[i]+=islower(ops[i-2][j])?toupper(ops[i-2][j]):tolower(ops[i-2][j]);
		int cnt=0; REPSZ(j,ops[i]) if(cnt!=0&&isopp(ops[i][cnt-1],ops[i][j])) --cnt; else ops[i][cnt++]=ops[i][j]; ops[i].resize(cnt);
	}
	FORE(i,1,100) {
		int nsym=0; while(2*(nsym+1)<=SZ(ops[i])&&isopp(ops[i][nsym],ops[i][SZ(ops[i])-1-nsym])) ++nsym;
		int nrep=0; while(4*(nrep+1)<=nsym&&ops[i][4*nrep]=='b'&&ops[i][4*nrep+1]=='A'&&ops[i][4*nrep+2]=='B'&&ops[i][4*nrep+3]=='a') ++nrep; nsym=4*nrep;
		int nmid=SZ(ops[i])-2*nsym;
		printf("%3d (%2d,%d,%d): ",i,nrep,nsym-4*nrep,nmid); REP(j,nmid) printf("%c",ops[i][nsym+j]); REP(j,7-nmid) printf(" "); printf(" | "); REP(j,nsym-4*nrep) printf("%c",ops[i][4*nrep+j]); puts("");
	}
}

int main() {
	//research();
	run();
	return 0;
}


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

using ll = long long;
int main() {

    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ll max_height = 0;
    ll sum = 0;
    for(int i=0;i<N;i++){
        max_height =  max(max_height, (ll) A[i]);
        sum += max_height - A[i];
    }
    cout<<sum;

    return 0;
}

Measured memory_bytes: 3976
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n, k, x, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> x;
        ans += min(x, k-x) * 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool ok = 1;
	for (int i = 0; i < a; ++i)
	{
		ok *= ('0' <= s[i] && s[i] <= '9');
	}
	ok *= (s[a] == '-');
	for (int i = a+1; i < s.size(); ++i)
	{
		ok *= ('0' <= s[i] && s[i] <= '9');
	}
	cout << (ok?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


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

	int n;
	cin >> n;
	vector<int> count(100001);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		count[a]++;
		sum += a;
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int b, c;
		cin >> b >> c;
		int b_count = count[b];
		sum += (c - b) * b_count;
		count[b] -= b_count;
		count[c] += b_count;
		cout << sum << "\n";
	}
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3668
#include <stdio.h>

int main(){
  int i,cnt = 0, flg = 1, N, A[100], tmp, j;

  scanf("%d",&N);

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

  for(i = 0; flg == 1; i++){
    flg = 0;
    for(j = N-1; j >= i+1; j--){
      if(A[j] < A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	flg = 1;
	cnt++;
      }
    }
  }

  for(i = 0; i < N; i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;



void solve(){
	int x , y , a , b , c ;
	cin >> x >> y >> a >> b >> c ;
	vll A(a) , B(b) , C(c) ;;
	for ( int i = 0 ; i < a ; i++ ) cin >> A[i] ;
	for ( int i = 0 ; i < b ; i++ ) cin >> B[i] ;
	for ( int i = 0 ; i < c ; i++ ) cin >> C[i] ;
	priority_queue < int , vector < int > , greater < int > > pq ;
	sort ( all (A)  );
	reverse ( all (A) ) ;
	sort ( all (B) );
	reverse ( all (B) ) ;
	for ( int i = 0 ; i < x ; i++ ) pq.push(A[i])  ;
	for ( int i = 0 ; i < y ; i++ ) pq.push(B[i])  ;
	sort (all( C )) ;
	reverse ( all (C) ) ;
	int ans = 0 ;
	for ( int i = 0 ; i < c ; i++ ){
		if ( C[i] > pq.top() ){

			pq.pop() ;
			pq.push(C[i]) ;
		}
	} 
	while ( sz(pq) ){
		ans += (int)pq.top() ;
		pq.pop() ;
	}
	cout << ans ;		   
}
int32_t main(){
    int t;
    t=1;
    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 
 
 

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));

  vector<bool> f(1000005, true);

  int ans = 0;
  rep(i, n) {
    if(!f[a[i]]) continue;
    if(distance(lower_bound(ALL(a), a[i]), upper_bound(ALL(a), a[i])) == 1) ++ans;
    for(int j = 2; a[i]*j <= 1000000; ++j) f[a[i]*j] = false;
    int index = distance(a.begin(), upper_bound(ALL(a), a[i]));
    i = index-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

using ll = long long;

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

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

const int INF = 1001001001;

int dp[100005];

void Main() {
  int n;
  std::cin >> n;
  std::vector<int> h(n);
  for (auto &hi : h) {
    std::cin >> hi;
  }

  rep(i, 100005) { dp[i] = INF; }

  dp[0] = 0;

  for (int i = 1; i < n; ++i) {
    chmin(dp[i], dp[i - 1] + std::abs(h[i] - h[i - 1]));
    if (i > 1) {
      chmin(dp[i], dp[i - 2] + std::abs(h[i] - h[i - 2]));
    }
  }
  std::cout << dp[n - 1] << std::endl;
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

int main() {
	long long n, m, sum = 0;
	cin >> n >> m;
	vector<int> a(n), b(m), c(m);
	vector<pair<int, int>> da(m);
	for (int i = 0;i < n;i++)
		cin >> a[i];
	for (int i = 0;i < m;i++) {
		cin >> b[i] >> c[i];
		da[i].second = b[i];
		da[i].first = c[i];
		sum = sum + b[i];
	}
	sort(da.begin(), da.end());
	reverse(da.begin(), da.end());
	int co=n;
	vector<int> ta(n * 2);
	for (int i = 0;i < n;i++) {
		ta[i] = a[i];
	}
	int p = 0;
	while (co <min(sum,n)+n) {
		if (da[p].second > 0) {
			da[p].second--;
			ta[co] = da[p].first;
			co++;
		}
		else
			p++;
	}
	sort(ta.begin(), ta.end());
	reverse(ta.begin(), ta.end());
	long long ans = 0;
	for (int i = 0;i < n;i++)
		ans = (long long)ans + ta[i];
	cout << ans << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <math.h>
#define N 10000
int isprime(int);
int main()
{
  int n,i,count=0,x;
  int array[N];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&array[i]);
      x=isprime(array[i]);
      if(x==1) count=count+1;
    }
  printf("%d\n",count);
  return 0;
}

int isprime(int x)
  {
    int i,count=0;
    if(x==2) return 1;
    if(x<2 || x%2==0) return 0;
      for(i=3;i<=sqrt(x);i++)
      {
       	if(x%i==0)
	  {
      return 0;
	  }
      }
      return 1;
  }

Measured memory_bytes: 1780
#include<stdio.h>
int main(void)
{
    int a[9],b[9],i,c[9];
	char name[9][16];
	for(i=0;i<9;i++){
	    scanf("%s %d %d",name[i],&a[i],&b[i]);
		c[i]=a[i]*200+b[i]*300;
		a[i]=a[i]+b[i];	
		b[i]=c[i];
	}
	for(i=0;i<9;i++){
	    printf("%s %d %d\n",name[i],a[i],b[i]);
	}
	return 0;
}

Measured memory_bytes: 2744
#include<iostream>

using namespace std;

int main(){
    int at1, hp1, at2, hp2;
    cin >> hp1 >> at1 >> hp2 >> at2;

    int flag;
    while(1){
        hp2 = hp2 - at1;
        if(hp2 <= 0){
            flag = 1;
            break;
        }
        hp1 = hp1 - at2;
        if(hp1 <= 0){
            flag = 2;
            break;
        }
    }
    if(flag==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define mod 1'000'000'007
typedef long long ll;

template<typename T>
void deb(initializer_list<T> l)
{
	for (auto &e : l)
		cout << e << ' ';
	cout << endl;
}

int n, m, k;

bool solve(vector<string> a, int rmask, int cmask)
{
	for (int i = 0; i < n; ++i)
		if (rmask & (1 << i))
			a[i] = string(m, ',');

	for (int j = 0; j < m; ++j)
		if (cmask & (1 << j))
			for (int i = 0; i < n; ++i)
				a[i][j] = ',';

	int cnt = 0;
	for (auto& r : a)
		for (auto& e : r)
			cnt += e == '#';

	return cnt == k;
}

void solve()
{
	cin >> n >> m >> k;
	vector<string> a(n);
	for (auto& e : a)
		cin >> e;

	int ans = 0;
	for (int i = 0; i < (1 << n); ++i)
		for (int j = 0; j < (1 << m); ++j)
			ans += solve(a, i, j);

	cout << ans << '\n';
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes";
    else cout << "No";
	return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

string s;

int main(){
  cin >> s;
  for(int i=0;i<s.size();++i){
    cout << 'x';
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split(' ')))
m = max(set(ls))
d = {}
for l in ls:
    d[l] = d.get(l, 0) + 1
ans = 0 if (ls[0] != 0 or d.get(0) >= 2) else 1
for i in range(1, m+1):
    if i not in d:
        ans = 0
    ans = (ans * (d.get(i-1, 0) ** d.get(i, 0))) % 998244353 
print(ans)

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

void solve(){
    
}
int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);
    int n,k,i;
    cin >> n >> k;
    int arr[n];
    for(i=0;i<n;i++)
    cin >> arr[i];
    sort(arr,arr+n);
    long int s = 0;
    for(i=0;i<k;i++)
    s+=arr[i];
    cout << s;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())

if (N // 10) < 1:
    print(N)
elif (N // 100) < 1:
    print(9)
elif (N // 1000) < 1:
    print(N- 90)
elif (N // 10000) < 1:
    print(909)
elif (N // 100000) < 1:
    print(N - 9090)
else:
    print(90909)

Measured memory_bytes: 3064
from collections import Counter

def main():
    n = int(input())
    s = list(input())

    t = Counter(s)

    ans = t['R']*t['G']*t['B']

    for i in range(n):
        for j in range(n):
            if i+j*2<n:
                if s[i]!=s[i+j] and s[i+j]!=s[i+j*2] and s[i]!=s[i+j*2]:
                    ans-=1
            else:
                break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = 0;
  
  for (int i = 0; i < K; i++){
    if(A > 0){
      ans += 1;
      A -= 1;
    } else if(B > 0){
      B -= 1;
    } else if(C > 0){
      ans -= 1;
      C -= 1;
    }
  }
  
  cout << ans;
}

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

const int inf = 1e9;
const ll linf = 1e18;

struct P { int y, x; };

int main()
{
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];
    
    // count black cells
    int b = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') b++;
        }
    }

    // bfs
    queue<P> q;
    vector<vector<int>> d(h, vector<int>(w, -1));
    d[0][0] = 1; q.push({0, 0});
    while (!q.empty()) {
        P p = q.front(); q.pop();
        if (p.y == h-1 && p.x == w-1) break;

        P dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
        for (auto &dp: dir) {
            int ny = max(0, min(h-1, p.y + dp.y));
            int nx = max(0, min(w-1, p.x + dp.x));
            if (d[ny][nx] == -1 && s[ny][nx] == '.') {
                d[ny][nx] = d[p.y][p.x] + 1;
                q.push({ny, nx});
            }
        }
    }

    if (d[h-1][w-1] == -1) cout << -1 << endl;
    else cout << h*w - b - d[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

typedef	pair<int,int>	pii;

int main(){
	for(int n,m,p,s,g;scanf("%d%d%d%d%d",&n,&m,&p,&s,&g),n;){
		s--,g--;
		int tic[8];
		for(int i=0;i<n;i++)	scanf("%d",tic+i);
		static int adj[30][30];
		for(int i=0;i<m;i++)for(int j=0;j<m;j++)	adj[i][j]=(i==j?0:-1);
		for(int i=0;i<p;i++){
			int x,y,d;	scanf("%d%d%d",&x,&y,&d);
			x--,y--;
			adj[y][x]=adj[x][y]=d;
		}

		double ans=-1;
		double tmin[30][1<<8];
		for(int i=0;i<m;i++)for(int j=0;j<(1<<n);j++)	tmin[i][j]=1e9;
		tmin[s][(1<<n)-1]=0;
		priority_queue< pair<double,pii> > pq;	pq.push(mp(0,mp(s,(1<<n)-1)));
		while(!pq.empty()){
			pair<double,pii> a=pq.top();	pq.pop();
			double t=-a.first;
			int u=a.second.first,hav=a.second.second;
			if(u==g){ ans=t; break; }
			if(tic==0)	continue;
			for(int v=0;v<m;v++){
				if(~adj[u][v]){
					for(int i=0;i<n;i++){
						if(hav&(1<<i)){
							double nextt=t+1.*adj[u][v]/tic[i];
							int nexthav=hav&~(1<<i);
							if(nextt<tmin[v][nexthav]){
								pq.push(mp(-nextt,mp(v,nexthav)));
								tmin[v][nexthav]=nextt;
							}
						}
					}
				}
			}
		}

		if(ans<0)	puts("Impossible");
		else		printf("%f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1436
N, A, B = map(int,input().split())
x = input().split()
sumx = 0
for i in range(N-1):
    if (int(x[i+1])-int(x[i]))*A<B:
        sumx+=(int(x[i+1])-int(x[i]))*A
    else:
        sumx+=B
print(sumx)

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


int main(){
    CIN(N,k);
    vi h(N);
    rep(i,N)cin>>h[i];
    int ans=0;
    rep(i,N){
        if(h[i]>=k)ans++;
    }
    
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

int main()
{
    string S;
    cin >> S;
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int D; cin >> D;
    vector<int> C(26); vector<vector<int>> S(D, vector<int>(26));
    REP(i, 0, 26) cin >> C[i];
    REP(i, 0, D) REP(j, 0, 26) cin >> S[i][j];

    vector<int> T(D);
    REP(i, 0, D) cin >> T[i];

    vector<vector<int>> last(26, vector<int>(D, 0));
    vector<ll> ret(26, 0);
    REP(i, 0, D) {
        ret[T[i] - 1] += S[i][T[i] - 1];
        last[T[i] - 1][i] = i + 1;
        REP(j, 0, 26) {
            if (i > 0 && !last[j][i]) last[j][i] = last[j][i - 1];
            ret[j] -= C[j] * (i + 1 - last[j][i]);
        }
    }

    int M; cin >> M;
    REP(i, 0, M) {
        int d, q; cin >> d >> q; d--;

        int prev = T[d] - 1, next = q - 1;
        T[d] = q;
        last[prev].assign(D, 0);
        last[next].assign(D, 0);
        ret[prev] = 0;
        ret[next] = 0;
        REP(i, 0, D) {
            if (T[i] == prev + 1 || T[i] == next + 1) {
                ret[T[i] - 1] += S[i][T[i] - 1];
                last[T[i] - 1][i] = i + 1;
            }
            if (i > 0) {
                if (!last[prev][i]) last[prev][i] = last[prev][i - 1];
                if (!last[next][i]) last[next][i] = last[next][i - 1];
            }
            ret[prev] -= C[prev] * (i + 1 - last[prev][i]);
            ret[next] -= C[next] * (i + 1 - last[next][i]);
        }
        cout << accumulate(ALL(ret), 0LL) << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)

class Cube {
public:
    int f[6];

    Cube() {}

    void roll_z() { roll(1, 2, 4, 3); }//
    void roll_y() { roll(0, 2, 5, 3); }//
    void roll_x() { roll(0, 1, 5, 4); }//
    void roll(int i, int j, int k, int l) {
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    };

    void move(char ch) {
        if (ch == 'E') REP(i, 3) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') REP(i, 3) roll_x();
    }
};

bool eq(Cube c1, Cube c2) {
    REP(i, 6) {
        if (c1.f[i] != c2.f[i]) return false;
    }
    return true;
}

bool equal(Cube c1, Cube c2) {
    REP(i, 6) {
        REP(j, 4) {
            if (eq(c1, c2)) return true;
            c1.roll_z();
        }
        if (i % 2 == 0) c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

Cube C[100];
int n;

bool check() {
    REP(i, n - 1) {
        FOR(j, i + 1, n) {
            if (equal(C[i], C[j])) return false;
        }
        return true;
    }
}

int main() {
    cin >> n;

    Cube c1, c2;

    REP(j, n) {
        REP(i, 6) cin >> C[j].f[i];
    }

    if (check()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		int k=Integer.parseInt(sc.next());

		String str=sc.next();
		String[] str2=str.split(""); //一文字ずつ取り出す
		for(int i=0;i<n;i++){
			if(i!=k-1)System.out.print(str2[i]);
			else System.out.print(str2[i].toLowerCase());
		}

	}

}

Measured memory_bytes: 23764
n , m = map(int,input().split())
aka = [False for i in range(n+1)]
kazu = [1 for i in range(n+1)]
aka[1] = True
for i in range(m):
    x , y = map(int,input().split())
    if aka[x]:
        if kazu[x] >= 2:
            kazu[x] -= 1
            kazu[y] += 1
        elif kazu[x] == 1:
            kazu[x] -= 1
            kazu[y] += 1            
            aka[x] = False
        aka[y] = True
    elif not aka[x]:
        kazu[x] -= 1
        kazu[y] += 1
ans = 0
for i in range(1,n+1):
    if aka[i]:
        ans += 1
print(ans)

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

    int main(){
        ll n , a , b;
        cin >> n ;
        vector<ll> va , vb;
        ll na , nb;
        na = 0; 
        nb = 0;
        for(long i = 0 ; i < n ; i++){
            cin >> a;
            va.push_back(a);
        }
        for(long i = 0 ; i < n ; i++){
            cin >> b;
            vb.push_back(b);
        }
        for(long i = 0 ; i < n ; i++){
            if(va[i] == vb[i]){
                
            }else if(va[i] > vb[i]){
                nb += va[i] - vb[i];
            }else{
                na += (vb[i] - va[i]) / 2;
            }
        }
        //cout << na << ":" << nb << endl;
        if(nb > na){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
        
        
        return 0;
        
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    string A; cin >> A;
    int N = SZ(A);

    mat pos(26);
    REP(i, N) pos[A[i] - 'a'].pb(i);
    REP(j, 26) pos[j].pb(N);
    
    vec dp(N + 2, INF);
    dp[N] = 1; dp[N + 1] = 0;
    IREP(i, N){
        REP(j, 26){
            int k = pos[j][Lower_bound(pos[j], i)];
            chmin(dp[i], dp[k + 1] + 1);
        }
    }

    string ans = "";
    int now = 0;
    while(now <= N){
        if(now == N){
            ans += 'a';
            now++;
        }else{
            REP(j, 26){
                int k = pos[j][Lower_bound(pos[j], now)];
                if(dp[k + 1] < dp[now]){
                    now = k + 1;
                    ans += 'a' + j;
                    break;
                }
            }
        }
    }
    Out(ans);

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	int ans[n];
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
		ans[a[i]-1] = i+1;
	}
	for(int i=0; i<n; i++)
	{
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include<stdio.h>
#include<algorithm>
#define maxn 1000000005
#define ll long long
using namespace std;
ll ans[100005];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%lld",&ans[i]);
    }
    sort(ans,ans+N);
    for(int i=1;i<N;i++)
    {
        if(ans[i]==ans[i-1])
        {
            ans[i] = 0;
            ans[i-1] = 0;
        }
    }
    int num=0;
    for(int i=0;i<N;i++)
    {
        if(ans[i]!=0)
            num++;
    }
    printf("%d\n",num);
    return 0;
}


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

int main()
{
    long K,N;
    cin >> K >> N;
    long A[N],B[N+1];
    rep(i,N) cin >> A[i];
    B[0] = A[0];
    B[N] = K - A[N-1] + A[0];
    rep(j,N-1){
        B[j+1] = A[j+1] - A[j];
    }
    sort (B, B+N+1);
    cout << K-B[N];
    return 0;

}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  string S;
  cin >> S;
  if (S == "ABC") {
    cout << "ARC\n";
  } else {
    cout << "ABC\n";
  }
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <vector>

int swap_counter = 0;

void show_data(std::vector<int>& data)
{
    printf("%d", data[0]);
    for(int i = 1; i < data.size(); i++) {
        printf(" %d", data[i]);
    }
    puts("");
}

void swap(int* a, int* b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
    swap_counter++;
}

void do_selection_sort(std::vector<int>& data)
{
    int min_index;
    for(int i = 0; i < data.size() - 1; i++) {
        min_index = i;
        for(int j = i; j < data.size(); j++) {
            if(data[j] < data[min_index]) {
                min_index = j;
            }
        }
        if(i != min_index) {
            swap(&data[i], &data[min_index]);            
        }
    }
}

int main()
{
    int input_size;
    std::cin >> input_size;
    std::vector<int> data(input_size);
    for(int i = 0; i < data.size(); i++) {
        std::cin >> data[i];
    }

    do_selection_sort(data);
    show_data(data);
    printf("%d\n", swap_counter);

    return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;

vector<int> bit[30];
int n, q;

void update(int u, int dif, int x){
  for(int i = u; i < bit[x].size(); i = i | (i + 1)) bit[x][i] += dif; 
}

int query(int u, int x){
  int res = 0;
  for(int i = u; i >= 0; i = (i & (i + 1)) - 1) res += bit[x][i];
  return res;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin>>n;
  string s; cin>>s;
  FORN(i,0,26) bit[i] = vector<int> (n,0);
  cin>>q;
  FORN(i,0,n) update(i,1,s[i]-'a');
  FORN(i,0,q){
    int a; cin>>a;
    if(a == 1){
      int pos; char c;
      cin>>pos>>c;
      pos--;
      update(pos,-1,s[pos]-'a');
      update(pos,1,c-'a');
      s[pos] = c;
    }
    else{
      int l, r, ans = 0;
      cin>>l>>r;
      l--, r--;
      FORN(i,0,26){
	int k = query(r, i);
	if(l) k -= query(l-1,i);
	ans += (k > 0);
      }
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 51868
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    int all;
    all =0;
    for (int i = 0; i < M; i++)
    {
        cin >>  A.at(i);
        all = all + A.at(i); 
    }
    if (all > N)
    {
        cout << -1;
    }else
    {
        cout << N-all;
    }    
}


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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  int max = 0;
  int p;
  for(int i = 0; i < N; i++){
    cin >> p;
    sum += p;
    if( p > max) max = p;
  }
  sum -= (max / 2);
  
  cout << sum << endl;
  return 0;
  
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        cout << "x";
} 

void run() {

}

void write() {

}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    read();
    run();
    write();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
#include <set>

#define F first
#define S second

using namespace std;

const int maxn = 1e5 + 500;
map <int, int> mp;
int a[maxn];

int main (){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]] ++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        int p = mp[a[i]];
        if (p > a[i]){
            ans += p - a[i];
            mp[a[i]] = a[i];
        }
        if (p < a[i]){
            ans += p;
            mp[a[i]] = 0;
        }
    }
    cout << ans << endl; 
}  

Measured memory_bytes: 5120
w=int(raw_input())
 
number = range(1,w+1)
for i in xrange(input()):
    a,b=map(int,raw_input().split(","))
    tmp=number[a-1]
    number[a-1]=number[b-1]
    number[b-1]=tmp
print '\n'.join(map(str,number))

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(0ll, min(b, d) - max(a, c)) << endl;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n; int q = 0;
	while(cin >> n, n){
		if(q != 0) cout << endl;
		int p[4] = {10, 50, 100, 500};
		int c[4];
		vector<int> ret(4);
		int sum = 0;
		rep(i, 4){ cin >> c[i]; sum += c[i]*p[i];}
		sum -= n;
		for(int i = 3; 0 <= i; i--){ret[i] = sum/p[i]; sum %= p[i];}
		for(int i=0; i < 4; i++){
			if(c[i]-ret[i] > 0) cout << p[i] << " " << c[i]-ret[i] << endl;
		}
		q++;
	}
}

Measured memory_bytes: 1192
import java.io.*;
import java.math.*;

class Main{
	static final String[] unit = {"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		for(;;){
			String[] str = br.readLine().split(" ");
			int m = Integer.parseInt(str[0]);
			int n = Integer.parseInt(str[1]);
			if(m == 0 && n == 0) break;
			BigInteger num = BigInteger.ONE;
			for(int i = 0; i < n; i++){
				num = num.multiply(BigInteger.valueOf(m));
			}
			String res = new String();
			for(int i = 0; i < unit.length; i++){
				BigInteger rem = num.remainder(BigInteger.valueOf(10000));
				num = num.divide(BigInteger.valueOf(10000));
				if(rem.compareTo(BigInteger.ZERO) == 0) continue;
				res = rem.toString() + unit[i] + res;
			}
			pw.println(res);
		}
		pw.close();
	}
}



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

namespace AGC018A
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NK = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            long[] A = Console.ReadLine().Split(' ').Select(b => long.Parse(b)).ToArray();
            Console.WriteLine(solve(NK[1], A) ? "POSSIBLE" : "IMPOSSIBLE");
        }

        static bool solve(long K, long[] A)
        {
            if (K > A.Max())
            {
                return false;
            }
            
            long[] diffs = new long[A.Length];
            long Gcd = A[0];
            
            for (int i = 0; i < A.Length; i++)
            {
                diffs[i] = A[i] - K;
                Gcd = gcd(A[0], A[i]);
            }

            for (int i = 0; i < A.Length; i++)
            {
                if (diffs[i] % Gcd == 0)
                {
                    return true;
                }
            }
            return false;
        }

        static long gcd(long a, long b)
        {
            long mod;
            while (b != 0)
            {
                mod = a % b;
                a = b;
                b = mod;
            }

            return a;
        }
    }
}

Measured memory_bytes: 23648