akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <decimal/decimal>
using namespace std;
using namespace __gnu_pbds;

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builtin_popcount
#define pop_count_64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count_64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count_64	__builtin_clzll

#define TEMP template<typename
#define CONST(type) constexpr type const

TEMP... Ts> struct is_con { static CONST(bool) value = false; };
TEMP... Ts> struct is_con<vector<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<list<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<deque<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<map<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_map<Ts...>> { static CONST(bool) value = true; };

TEMP T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> const& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
TEMP T> typename enable_if<is_con<T>::value, ostream>::type& operator<<(ostream& os, T const& c) {
	os << "{";
	bool first = true;
	for (auto const& x : c) {
		if (first) first = false;
		else os << ",";
		os << " " << x;
	}
	return os << " }";
}

TEMP T, typename... Ts> void dbg(T h, Ts... t) { cerr << " " << h; dbg<Ts...>(t...); }
template<> void dbg<int>(int x) { cerr << endl; }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__, 0)
#else
#define debug(...) 0
#endif

TEMP T, typename U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
TEMP T> using ordered_set = ordered_map<T, null_type>;

typedef long long i64;
typedef decimal::decimal128 i99;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

TEMP T> T& minn(T& lhs, T const& rhs) { return lhs = min(lhs, rhs); }
TEMP T> T& maxx(T& lhs, T const& rhs) { return lhs = max(lhs, rhs); }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	string s;
	cin >> n >> s;
	vi a(n);
	rep(i, 0, n) a[i] = s[i] - '0';
	int odd = 0;
	rep(i, 0, n) odd ^= a[i] & 1 & ((n - 1 & i) == i);
	if (n == 1) return cout << s << endl, 0;
	if (odd) {
		debug("odd");
		cout << (n == 1 && a[0] == 3 ? 3 : 1) << endl;
	} else {
		debug("even");
		int cnt[4] = { 0 };
		for (int x : a) ++cnt[x];
		if (cnt[2]) {
			cout << "0" << endl;
		} else {
			vi b(n - 1);
			rep(i, 0, n - 1) b[i] = a[i] != a[i + 1];
			rep(i, 0, n - 1) odd ^= b[i] & ((n - 2 & i) == i);
			cout << odd * 2 << endl;
		}
	}
}


Measured memory_bytes: 9244
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] P = new int [N];
		int[] G = new int [3];
		for (int i = 0; i < 3; i++){
			G[i] = 0;
		}
		for (int j = 0; j < N; j++){
			P[j] = sc.nextInt();
			if (P[j] <= A){
				G[0]++;
			}
			else if (P[j] > B){
				G[2]++;
			}
			else G[1]++;
		}
		if (G[0] < G[1] && G[0] < G[2]){
			System.out.println(G[0]);
		}else if (G[1] < G[0] && G[1] < G[2]){
			System.out.println(G[1]);
		}else{
			System.out.println(G[2]);
		}
	}
}


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

using namespace std;

int main() {
	string str;
	cin >> str;
	int q;
	cin >> q;
	while (q--) {
		string cmd;
		int a, b;
		cin >> cmd >> a >> b;
		cin.ignore();
		if (cmd == "print") {
			for (int i = a; i <= b; ++i) {
				cout << str[i];
			}
			cout << '\n';
		} else if (cmd == "reverse") {
			reverse(str.begin()+a, str.begin()+b+1);
			// for (int i = 0; i < (b - a)/2; ++i) {
				// swap(str[a+i], str[b-i]);
			// }
		} else {
			string p;
			cin >> p;
			for (int i = 0; i <= b-a; ++i) {
				str[a+i] = p[i];
			}
		}
	}
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define TASKNAME somethinghere
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);
 
    const ld PI = acos(-1);
    ld a, b, x;
    cin >> a >> b >> x;
    ld theta;
    if(x < a*a*b/2.0)
        theta = atan((a*b*b)/2/x);
    else
      theta = atan((2*(a*a*b - x)/a/a/a));
  
    cout << setprecision(10) << theta * 180.0 / PI;
 
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
 
// g++ .cpp -o .exe -DEVAL -std=c++11 -pipe -O2 -s -static -Wall -Wshadow
/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/

Measured memory_bytes: 256
#define Z(V) for(v=360,m=g();--m;V+=sin(x*z))v-=x=g();V+=sin(v*z)
a;g(){scanf("%d",&a);a?a:exit(0);}main(m,v,x){for(;;){double s=0,t=0,z=.01745,e=.000001;Z(s);Z(t);puts(s>t+e?"1":s+e<t?"2":"0");}}

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

int isPrime(int num)
{
    int sq_root = sqrt(num);
    for(int i = 2; i <= sq_root; i++)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
    return 1;
}

int check(int num) {
    do {
        if(!isPrime(num))
        {
            num++;
        }
    } while (!isPrime(num));
    return num;
}

int main() {
	int n;
	cin >> n;
//	if(n == 2)
//    {
//        cout << '2'; return 0;
//    }
//    if(n == 3)
//    {
//        cout << '3'; return 0;
//    }

	cout << check(n);
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	char c;
	cin >> c;
	cout << char(c + 1) << endl;
	return(0);
}

Measured memory_bytes: 3592
fun main(args: Array<String>) {
    val (A, B, C) = readLine()!!.split(" ").map { it.toLong() }
    val s = listOf(A, B, C)
    val max = s.max()!!
    val mid = s.sorted()[1]
    val min = s.min()!!

    var count = 0

    var minP = 0
    while (min + 1 + minP < mid) {
        count++
        minP += 2
    }

    if (mid != min + minP) {
        count += 2
    }

    var midP = 0
    while (mid + midP < max) {
        count++
        midP++
    }

    println(count)
}

Measured memory_bytes: 37568
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  ll H, W; cin >> H >> W;

  if (H == 1 || W == 1) cout << 1 << endl;
  else
    cout << (H * W + 1) / 2 << endl;
  // if (W % 2 == 0)
  //   cout << (W/2) * H << endl;
  // else {
  //   ll ans = (W+1) / 2;
  //   ans *= (H+1) / 2;
  //   ll res = W/2;
  //   res *= H/2;
  //   cout << ans + res << endl;
  // }

  // Wが偶数: すべての行は同じ数だけ(W/2)
  // Wが奇数-> 奇数行は(W+1)/2、偶数行はfloor(W/2)
  //
  // 奇数行は(H+1)/2子、
  // 奇数行はH/2子、
  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    int val[3];
    cin >> n >> val[0] >> val[1] >> val[2];
    if(val[0] + val[1] + val[2] == 0) {
        cout << "No" << endl;
    } else {
        vector<string> q(n);
        string ans;
        for(int i = 0; i < n; i++) {
            cin >> q[i];
        }
        if(val[(int)q[0][0]-65] == 0 && val[(int)q[0][1]-65] == 0) {
            cout << "No" << endl;
            return 0;
        }
        else {
            ans += "Yes\n";
        }
        for(int i = 0; i < n; i++) {
            int u = (int)q[i][0]-65;
            int v = (int)q[i][1]-65;
            if(val[u] == 0 && val[v] == 0) {
                cout << "No" << endl;
                return 0;
            }
            if(val[u] == 0 || val[v] == 0) {
                if(val[u] == 0) {
                    ans.pb((char)(u+65));
                    ans.pb('\n');
                    val[u]++;
                    val[v]--;
                } else {
                    ans.pb((char)(v+65));
                    ans.pb('\n');
                    val[u]--;
                    val[v]++;
                }
            } else if(val[u] == 1 && val[v] == 1 && val[2^1^u^v] == 0 && i != n-1 && q[i+1] != q[i]) {
                int uNxt = q[i+1][0]-65;
                int vNxt = q[i+1][1]-65;
                if(u == uNxt || u == vNxt) {
                    ans.pb((char)(u+65));
                    ans.pb('\n');
                    val[u]++;
                    val[v]--;
                } else {
                    ans.pb((char)(v+65));
                    ans.pb('\n');
                    val[u]--;
                    val[v]++;
                }
            } else {
                if(val[u] >= val[v]) {
                    ans.pb((char)(v+65));
                    ans.pb('\n');
                    val[u]--;
                    val[v]++;
                } else {
                    ans.pb((char)(u+65));
                    ans.pb('\n');
                    val[u]++;
                    val[v]--;
                }
            }
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 6752
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n; cin>>n; map<ll,ll>mp; ll sum=0;
    while(n--)
    {
        ll a; cin>>a; sum+=a; mp[a]++;
    }
    ll q; cin>>q; while(q--)
    {
        ll a,b; cin>>a>>b;
        if(mp[a]==0)
        {
            cout<<sum<<endl; continue;
        }
        ll k=mp[a];
        if(mp[b]==0 )mp[b]=k;
        else mp[b]+=k;
        mp[a]=0;
        ll s=k*a;
        sum=sum-s;
        sum=sum+(b*k);
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 9312
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

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

#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;


//template<class T>T max(T a, T b) { return a > b ? a : b; }
//template<class T>T min(T a, T b) { return a < b ? a : b; }
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmix(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

int n;
int a[100001], b[100000];


using namespace std;
int main()
{
	int n;
	cin >> n;

	REP(i, n + 1) {
		cin >> a[i];
	}
	REP(i, n) {
		cin >> b[i];
	}

	ll cnt = 0;
	REP(i, n) {
		if (a[i] < b[i]) {
			cnt += a[i];
			b[i] -= a[i];
			if (a[i + 1] < b[i]) {
				cnt += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				cnt += b[i];
				a[i + 1] -= b[i];
			}
		}
		else {
			cnt += b[i];
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T>
std::istream& operator >> (std::istream& is, std::vector<T>& vec){
  T tmp;
  is >> tmp;
  vec.push_back(tmp);
  return is;
}
template <class T>
auto mkVec(unsigned int x){
  return std::vector<int>(x);
}

template <class T>
auto mkVec2(unsigned int x, unsigned int y){
  return std::vector<std::vector<T>>(x, std::vector<T>(y));
}

template <class T>
auto mkVec3(unsigned int x, unsigned int y, unsigned int z){
  return std::vector<std::vector<std::vector<T>>>(x, std::vector<std::vector<T>>(y, std::vector<T>(z)));
}

// 113C
// #ifndef BOOST_TEST_MAIN
// int main(int const argc, char const** argv){
//   int N, M;
//   cin >> N >> M;
//   vector<ll> P;
//   vector<ll> Y;
//   auto X = mkVec2<ll>(N + 1, 0);
//   rep(i, M){
//     ll p, y;
//     cin >> p >> y;
//     P.push_back(p);
//     Y.push_back(y);
//     X[p].push_back(y);
//   }
//   rep(i, N + 1){
//     sort(X[i].begin(), X[i].end());
//   }
//   rep(i, M) {
//     ll y;
//     rep(j, N + 1){
//       auto x = find(X[j].begin(), X[j].end(), Y[i]);
//       if(x != X[j].end()){
//         y = x - X[j].begin();
//         break;
//       }
//     }
//     printf("%06lld%06lld\n", P[i], y + 1);
//   }
// }
// #endif

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  ll N;
  cin >> N;
  string rs;
  if(N == 0){
    cout << 0;
  }
  while(1){
    if(N == 0){
      break;
    }if(N == 1){
      rs = "1" + rs;
      break;
    }
    ll r;

    r = N % 2;
    if(N>0){
      N = N / - 2;
    }else if(N<0 && r){
      N = (N/ - 2) + 1;
    }else{
      N = (N / - 2);
    }
    if(r == 0){
      rs = "0" + rs;
    }else{
      rs = "1" + rs;
    }

  }
  cout << rs;
  
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
   int A, B, C, A2, B2, C2;
   ll ans = 0;
   cin >> A >> B >> C;
   A2 = A, B2 = B, C2 = C;
   bool flag = true;

   while(!(A2 % 2 || B2 % 2 || C2 % 2)){
      int tmp = A2, tmp2 = B2;
      A2 = B2/2 + C2 / 2;
      B2 = tmp/2+C2/2;
      C2 = tmp/2 + tmp2/2;
      ans++;
      if(A2 == A && B2 == B && C2 == C){
         ans = -1;
         break;
      }
   }

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


Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=Counter(list(map(int,input().split())))
a=[0,0]

for i in A:
    if A[i]>=2:
        a.append(i)
    if A[i]>=4:
        a.append(i)
a.sort()
print(a[-1]*a[-2])


Measured memory_bytes: 18600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
void swap(ll &a,ll &b){
    ll temp=a;
    a=b;
    b=temp;
}
ll gcd(ll a,ll b){
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;
}

void solve(){
    ll K;
    cin>>K;
    ll sum=0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    out(sum);

}

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
 
int main() {
 int64_t n,m;
 cin>>n>>m;
 if(2*n<=m){cout<<n+(m-2*n)/4<<endl;}
 else{cout<<m/2<<endl;}
  return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int a[h+2][w+2]={};
	for(int i=0;i<h;i++){
		char s[w]={};
		scanf("%s",s);
		for(int j=0;j<w;j++){
			if(s[j]=='#')a[i+1][j+1]=1;
		}
	}
	int u=0;
	for(int i=1;i<h+1;i++){
		for(int j=1;j<w+1;j++){
			if(a[i][j]==1&&a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]==0)u++;
		}
	}
	if(u==0)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
import sys

n = int(input())
b = list(map(int, input().split()))

check = 0
for i in range(n):
    if b[i] > i + 1:
        check = 1

if check == 1:
    print(-1)
    sys.exit()

ans = [] #Wanted Sequence

for i in range(n):
    ans.insert(i + 1 - b[i], b[i])

ans.reverse()

for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
lines = $stdin.read

array = lines.split("\n")

str = array[0]
n   = array[1]

for i in 2..(1+n.to_i)
  command = array[i].split(" ")[0]
  a = array[i].split(" ")[1].to_i
  b = array[i].split(" ")[2].to_i

  if command == "replace"
    str[a..b] = array[i].split(" ")[3]
  elsif command == "reverse"
    r = str[a..b].reverse
    len = str.length
    if a == 0
      str = "#{r}#{str[b+1..len]}"
    elsif b == 0
      str = "#{str[0..a-1]}#{r}"
    else
      res1 =
      str = "#{str[0..a-1]}#{r}#{str[b+1..len]}"
    end
  elsif command == "print"
    puts str[a..b]
  end
end

Measured memory_bytes: 8928
/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost		          ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;

const int nax = 2000+1;
//~ char s[nax][nax];

int dp[nax][nax];
int h , w;
int main()
{
	boost ;
	//~ scanf("%d%d",&h,&w);
	cin >> h >> w;
	string s[h];
	for(int i =0 ; i < h ; i++)
		//~ scanf("%s",s[i]);
		cin >> s[i];
	
	int maxi = 0;
	for (int i = 0 ; i < h ; i++){
		for(int j= 0 ; j < w ; j++){					
			if(s[i][j]=='#')
				continue ;
			int cnt = 0,st= j;
			while(j < w){
				if(s[i][j]=='#')
					break;
				cnt++;
				j++;
			}
			for(st=st ; st < j ; st ++)
				dp[i][st] +=cnt ;
		}
	}

	for (int i = 0 ; i < w ; i++){
		for(int j= 0 ; j < h ; j++){	

			if(s[j][i]=='#')
				continue ;
			int cnt = 0,st= j;
			while(j < h){
				if(s[j][i]=='#')
					break;
				cnt++;
				j++;
			}
			for(st=st ; st < j ; st ++)
				dp[st][i] +=cnt ;
		}
	}

	for(int i = 0 ; i < h ; i++)
		for(int j = 0 ; j < w ; j++)
			maxi = max(maxi, (int)dp[i][j]);

	printf("%d\n",maxi-1);
    return 0;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x; cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;

  return (0);
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i= 0; i < N; i++) {
  	cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int sum = 0;
 
  for(int i = 0; i < N - 1; i++){
    if(vec.at(i) == vec.at(i + 1)) {
    	sum ++;
    }
  }
  
  cout << N - sum << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i=0; i<n; i++){
        cin >> a[i];
    }
    multiset<LL> s;
    for(LL i=0; i<n; i++){
        auto itr=s.lower_bound(a[i]);
        if(itr!=s.begin()){
            itr--;
            s.erase(itr);
        }
        s.insert(a[i]);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 8688
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define vll vector<ll>
#define nloop(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define fill(i,n) memset(i,n,sizeof i)
#define all(a) a.begin(),a.end()
#define pb(x) push_back(x)
#define sz() size()
#define T(n) while(n--)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define endl '\n'
#define nfs  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll bin_expo(ll a, ll b, ll m){ll res = 1LL;while (b > 0){if(b % 2 == 1){res = (res * a) % m;}a = (a * a) % m; b = b/ 2;}return res;}

const  int MAXn= 3e5+5;
const  long long INF= 1e18;

int main(){
    int t=1;
    //cin>>t;
    T(t){
        ll n;
				cin>>n;
				ll ans=0;
				for(int i=1;i<=n;i++){
					int count=0;
					int x=i;
					while(x){
						x=x/10;
						count++;
					}
					if(count%2!=0)ans++;
				}
				cout<<ans;
    }
}

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

int main(){
   string s ; cin >> s;
   map<string,int> m;
   vector<string> ans  = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
   for(int i =0; i < ans.size(); i++){
          m[ans[i]] = i;
   }
   
   cout << abs(7 - m[s]);
}












Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)

for x, y, _ in xyz:
    x -= 1
    y -= 1
    uf.unite(x, y)

uf.update_p()
ans = len(set(uf.p))
print(ans)

Measured memory_bytes: 39180
#!/usr/bin/env python3
import sys
from itertools import accumulate
from bisect import bisect_right
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split())) + [INF]
    B = list(map(int, input().split())) + [INF]
    A = [0]+list(accumulate(A))
    B = [0]+list(accumulate(B))

    ans = 0
    for i in range(N+1):
        # Aの山からi冊読んだ場合
        j = bisect_right(B, K-A[i])-1
        if j < 0:
            continue
        ans = max(i+j, ans)
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 147240
N = int(input())
H = list(map(int,input().split()))

tmp = 0
ans = 0 # N=1のときはfor文を通っても0になる
for i in range(N):
  if(i != 0): 
    if(H[i-1]>=H[i]):
      tmp += 1
    else: 
      ans = max(ans,tmp)
      tmp = 0

ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 14252
k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

from collections import deque

q=deque([1,2,3,4,5,6,7,8,9])
ansl=[]
s=1
while len(str(s))<=10:
    s=q.popleft()
    ansl.append(s)
    sl=list(str(s))
    last_digit=int(sl[-1])
    for digit in range(max(0,last_digit-1),min(last_digit+1,9)+1):
        newval=int(str(s)+str(digit))
        #ansl.append(int(str(s)+str(digit)))
        q.append(newval)
print(ansl[k-1])


Measured memory_bytes: 70616
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

void solve(long long N) {
  rep(h, 1, 3501) {
    rep(n, 1, 3501) {
      ll x1 = N * h * n;
      ll x2 = 4 * h * n - N * n - N * h;
      if (x2 != 0 && x1 % x2 == 0 && 0 < x1 / x2 && x1 / x2 <= 3500) {
        print(h << " " << n << " " << x1 / x2);
        return;
      }
    }
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 21:18 on 2019-09-28.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}


void solve() {
    ll n, m;
    cin >> n >> m;
    vector<P> key;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        ll s = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            s |= 1 << c;
        }
        key.eb(s, a);
    }
    ll pow2 = 1 << n;
    vl dp(pow2, ll_inf); // dp[i]: 集合iの宝箱を開ける最小コスト
    dp[0] = 0;

    rep(s, pow2) {
        rep(i, m) {
            ll t = s | key[i].first; // 遷移先
            ll cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    ll ans = dp.back();
    if (ans == ll_inf) ans = -1;
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
main(n){int t,l,b,a,i,j,I,J,s;while(scanf("%d%d%d%d",&n,&t,&l,&b),n){double d[101][101]={{}},o=0;int f[101]={};while(l--)scanf("%d",&a),f[a]=1;while(b--)scanf("%d",&a),f[a]=2;d[0][0]=1;for(i=0;i<=t;i++){o+=d[i][n];d[i][n]=0;for(j=0;j<=n;j++){I=i+(f[j]==1?2:1);if(I>t)continue;for(s=1;s<7;s++){J=j+s;if(J>n)J=n-(J-n);if(f[J]==2)J=0;d[I][J]+=d[i][j]/6;}}}printf("%.9lf\n",o);}}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b;
    cin >> a >> b;
    if (b < 0) {
        int d = abs(a - b) + 1;
        if (d % 2 == 1) cout << "Negative" << '\n';
        else cout << "Positive" << '\n';
    }
    else if (a <= 0 && 0 <= b) cout << "Zero" << '\n';
    else if (0 < a) cout << "Positive" << '\n';
}


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


int main(){
    string s;
    bool rev=false;
    int q;
    
    cin>>s>>q;

    list<char> chars(s.begin(),s.end());

    while(q--){
        int t;
        cin>>t;
        
        if(t == 1){
            rev = !rev;
        }else{
            int f;
            char c;

            cin>>f>>c;

            if(f == 1){
                if(rev) chars.push_back(c);
                else chars.push_front(c);
            }else{
                if(rev) chars.push_front(c);
                else chars.push_back(c);
            }

        }
    }

    s = "";

    for(list<char>::iterator it = chars.begin(); it!=chars.end(); it++)
        s += *it;

    if(rev) reverse(s.begin(),s.end());

    cout << s << endl;

    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int n;
  cin >> n;
  vector<string> title(n);
  vector<int> time(n);
  for (int i = 0; i < n; i++) {
    cin >> title[i] >> time[i];
  }
  string x;
  cin >> x;
  bool deta = false;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (deta) ans += time[i];
    if (title[i] == x) deta = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H*W -h*W- w*H + h*w << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n,m,cc;
    vector<int> c; c.clear();
    cin>>n>>m;
    REP(i,m){
        cin>>cc;
        c.push_back(cc);
    }
    int mat[25][50005]={};
    REP(i,25)REP(j,50005)mat[i][j]=1<<30;
    mat[0][0]=0;
    REP(i,m){
        REP(j,n+1){
            if(j<c[i])mat[i+1][j]=mat[i][j];
            else mat[i+1][j] = min(mat[i][j], mat[i+1][j-c[i]]+1);
        }
    }
    cout<<mat[m][n]<<endl;
    return 0;
}


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

int main(void){
    ll n, x;
    cin >> n >> x;

    ll m[n];
    ll sum = 0, mi = 1000000;

    rep(i, n){
        cin >> m[i];
        sum += m[i];
        mi = min(mi, m[i]);
    }

    cout << (x - sum) / mi + n << endl;
    return 0;
}


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

using namespace std;

int main(){
    int K;
    cin>>K;
    int ans=0;
    int i,j,k;
    for(i=1;i<=K;i++){
        for(j=1;j<=K;j++){
            for(k=1;k<=K;k++){
                ans+=gcd(i,gcd(j,k));
            }
        }
    }   
    cout<<ans<<endl;
}

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

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

using namespace std;


int main(){
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int sum = a;
    int ans = 1;
    while (sum < b){
        sum += a-1;
        ans++;
    }

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

Measured memory_bytes: 888
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 3e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int dp[N][N][2], a[N];

int rec(int l, int r, int c){
	if(l > r)
		return 0;
	if(dp[l][r][c] != -1)
		return dp[l][r][c];
	if(c == 0)
		dp[l][r][c] = max(a[l] + rec(l+1, r, 1), a[r] + rec(l, r-1, 1));
	else
		dp[l][r][c] = min(-a[l] + rec(l+1, r, 0), -a[r] + rec(l, r-1, 0));
	return dp[l][r][c];
}
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			dp[i][j][0] = dp[i][j][1] = -1;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	cout << rec(1, n, 0);
	return 0;
}

Measured memory_bytes: 141440
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b=0;
	cin >> a ;
	for(int i=a;i>=1;i--){
		int t=i,j=1;
		while(t>=10){
			t=t/10;
			j++;
		}
		if(j%2==1)
			b++;
	}
	cout << b;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
  string s, p;

  getline(cin, s);
  getline(cin, p);
  
  bool judge;
  for(int j=0; j<s.size(); j++){
    if(p[0] == s[j]){
      judge = true;
      int s_index;
      for(int k=1; k<p.size(); k++){
        s_index = j+k;
        if(s_index >= s.size()){
          s_index -= s.size();
        }
        
        if(p[k] != s[s_index]){
          judge = false;
          break;
        }
      }
    }else{
      judge = false;
    }
    
    if(judge){
      break;
    }
  }

  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
  
  return(0);

}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);

    bool sieve[100100];
    for (int i = 0; i < 100100; ++i)
        sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for (int i = 2; i * i < 100100; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; j * i < 100100; ++j)
                sieve[i * j] = false;
        }
    }

    vector<int> primes;
    set<int> st;
    for (int i = 0; i < 100100; ++i)
    {
        if (sieve[i])
        {
            primes.push_back(i);
            st.insert(i);
        }
    }

    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        int ans = 0;
        for (int i = 0; primes.size(); ++i)
        {
            if (n / 2 < primes[i])
                break;
            if (st.find(n - primes[i]) != st.end())
                ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

satisfy = 0
satisfy += Bs[As[0]-1]

for now, prev in zip(As[1:], As[:-1]):
  satisfy += Bs[now-1]
  if now == prev + 1:
    satisfy += Cs[prev-1]

print(satisfy)

  

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1 ;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int n; cin >> n; 
		string s1 = "AC" , s2 = "WA" , s3 = "TLE" , s4 = "RE";
		int a = 0 , b = 0 , c = 0 , d = 0; 
		while(n--){
			string re; cin >> re; 
			if(re == s1)a++;
			if(re == s2)b++;
			if(re == s3)c++;
			if(re == s4)d++;
		}
			cout << s1 << " x " << a << endl;
			cout << s2 << " x " << b << endl;
			cout << s3 << " x " << c << endl;
			cout << s4 << " x " << d << endl; 
	}
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
 #include<string.h>
int main()
{
   int i;
  char k[100];
  scanf("%s",k);
  for(i=0;i<strlen(k);i++)
  {
      printf("%c",(k[i]=='9')?'1':'9');
  }
 
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n,m;cin >> n >> m;
    vector<int> path[n+1];
    vector<int> h(n+1);
    for(int i=0; i<n-1+m; i++){
        int a,b;cin >> a >> b;
        path[a].push_back(b);
        h[b]++;
    }
    queue<int> q;
    vector<int> par(n+1);
    for(int i=1; i<=n; i++){
        if(h[i]==0){
            q.push(i);
            par[i]=0;
        }
    }
    while(!q.empty()){
        int now=q.front();q.pop();
        for(auto next: path[now]){
            h[next]--;
            if(h[next]==0){
                q.push(next);
                par[next]=now;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << par[i] << endl;
    }
    return 0;
}

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

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

    int N;
    cin >> N;

    vector<ll> a(N);

    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll m = *max_element(a.begin(), a.end());

    ll x = pow(10, 10);

    ll ans;

    for(int i = 0; i < N; i++) {
        if(a[i] == m) continue;
        if(x > abs(a[i] - (m + 1) / 2)) {
            ans = a[i];
            x = abs(a[i] - (m + 1) / 2);
        }
    }

    cout << m << " " << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  N=N%10;
  if(N==2||N==4||N==5||N==7||N==9){
    cout<< "hon" <<endl;
  }
  if(N==0||N==1||N==6||N==8){
    cout<< "pon" <<endl;
  }
  if(N==3){
    cout<< "bon" <<endl;
  }
}

Measured memory_bytes: 3624
n,k = map(int,input().split())
mod = 10**9+7

fact = [1]*(n+1)
ans = 0
for i in range(1,n+1):
    fact[i] = fact[i-1]*i
    fact[i] %= mod
invfact = [1] * (n+1)
invfact[-1] = pow(fact[-1],mod-2,mod)
for i in range(n-1,0,-1):
    invfact[i] = (invfact[i+1]*(i+1))%mod
def C(x,y):
    if x<=y:return 1
    return fact[x]*invfact[y]*invfact[x-y]%mod


for i in range(min(k+1,n)):
    ans += C(n,i)*C(n-1,n-i-1)
    ans %= mod
print(ans)
        
        
    

Measured memory_bytes: 44268
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

stack<int> S1; // x-point, area
stack<P> S2; // x-point, area

int main() {

    string s;
    cin >> s;
    int f, area;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '_') continue;
        else if (s[i] == '\\') 
            S1.push(i);
        else if (s[i] == '/') {
            if (S1.empty()) continue;
            f = S1.top(); S1.pop();
            area = i - f;
            while (!S2.empty()) {
                if (f < S2.top().first) {
                area += S2.top().second;
                S2.pop();
                }
                else break;
            }
            S2.push(make_pair(f, area));
        }
    }
    vector<int> v;
    int area_sum = 0;
    int si = S2.size();
    for (int i = 0; i < si; i++) {
        area = S2.top().second;
        v.push_back(area);
        S2.pop();
        area_sum += area;
    }
    reverse(v.begin(), v.end());
    cout << area_sum << '\n';
    cout << v.size();
    for (int i = 0; i < v.size(); i++) {
        cout << ' ' << v[i];
    }
    cout << '\n';
}
        





Measured memory_bytes: 3308
def input_from_console():
    n, k = map(int, input().split())
    s = input()
    return n, k, s


def main():
    n, k, s = input_from_console()
    rep = s[k - 1].lower()
    print(s[:k - 1] + rep + s[k:])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
 
int main() {
	int n,min,max,hold1;
	long long sum;
	sum = 0;
	max = -1000000;
	min = 1000000;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> hold1;
		if(hold1 >= max){
			max = hold1;
		}
		if(hold1 <= min){
			min = hold1;
		}
		sum += hold1;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 3072