akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    ll x, y, cnt;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};



void solve()
{
    long double a,b;
    cin>>a>>b;
    printf("%lld\n",(ll)floor(a*b));
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <math.h>

#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

int main(){
    cin.tie();
    ios::sync_with_stdio(false);
    int n,dp[105]={};

    dp[0]=1;
    rep(i,101){
        if(i>3){
            if(dp[i-4]==1)dp[i]=1;
        }
        if(i>6){
            if(dp[i-7]==1)dp[i]=1;
        }
    }

    cin >> n;

    if(dp[n]==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

def checkDisits(a, b):
    a = str(a)
    b = str(b)
    return max(len(a), len(b))

start_num = int(math.sqrt(N))


for i in range(start_num, 0, -1):
    if N % i == 0:
        a = i
        b = N // i
        break

output = checkDisits(a, b)
print(output)

Measured memory_bytes: 9092
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;


template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

int main() {

    int N;
    cin >> N;

    auto spf = smallest_prime_factors(N);
    
    ll ans = 0;
    
    rep(i, 1, N + 1){
        int j = i;
        map<ll, ll> m;
        while(j != 1){
            if(m.count(spf[j])) m[spf[j]]++;
            else m[spf[j]] = 1;
            j /= spf[j];
        }
        ll x = 1;
        for (auto p : m){
            auto value = p.second;
            x *= (value + 1);
        }
        ans += (ll)i * x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 42332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b;
	cin >> a >> b;
	if(a==1) a+=13;
	if(b==1) b+=13;
	
	if(a<b) cout << "Bob" <<endl;
	else if (a>b) cout << "Alice" << endl;
	else cout << "Draw" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;

int Solve(int n)
{
    int i, o;

    for(i = 1, o = 0; true; )
    {
        n -= i;
        if(n < 0)
            break;
        o ++;
        i ++;
    }

    return o;
}

int main(void)
{
    long long n;
    int i, c, o;

    cin >> n;
    for(i = 2, o = 0; (long long)i * i <= n; i ++)
    {
        for(c = 0; !(n % i); c ++, n /= i)
            ;
        o += Solve(c);
    }
    if(n != 1)
        o ++;
    cout << o << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  int mini = 1, maxi = 100;
  rep(i,n) {
    cin >> x[i];
    mini = min(mini, x[i]);
    maxi = max(maxi, x[i]);
  }
  int ans = 1001001001;
  for (int i = mini; i <= maxi; ++i) {
    int sum = 0;
    rep(j,n) sum += (x[j] - i)*(x[j] - i);
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;

struct SegmentTree{
    int n;
    vector<int> data;
    SegmentTree(int n): n(n), data(n * 2){}
    void set(int i, int x){
        i += n;
        data[i] = x;
        while(i /= 2) data[i] = min(data[i * 2], data[i * 2 + 1]);
    }
    int get(){
        return data[1];
    }
    int operator[](int i){ return data[n + i]; }
};
int main(){
    int h, w;
    cin >> h >> w;
    SegmentTree seg(w);
    map<int, int> s;
    for(int i = 0; i < w; i++) s[i] = i;
    for(int i = 1; i <= h; i++){
        int a, b;
        cin >> a >> b;
        a--;
        auto p = s.lower_bound(a);
        int mx = -1;
        while(p != s.end()){
            const auto [at, start] = *p;
            if(at >= b) break;
            mx = start;
            seg.set(at, INF);
            p = s.erase(p);
        }
        if(mx != -1 && b != w && seg[b] == INF){
            s[b] = mx;
            seg.set(b, b - mx);
        }
        if(seg.get() == INF) puts("-1");
        else cout << seg.get() + i << '\n';
    }
}

Measured memory_bytes: 14076
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,m,l;
    cin >> n >> m >> l;
    int A[n][m];
    int B[m][l];
    int i,j,k;
    long long int c;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin >> B[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j) cout << " ";
            c=0;
            for(k=0;k<m;k++) c += A[i][k]*B[k][j];
            cout << c;
        }
        cout << endl;
    }
    return 0;
}


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

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = (int)(n); i>=1; --i)
#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define clr(v) memset(v, 0, sizeof(v))
#define clr1(v) memset(v, 0xFF, sizeof(v))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef vector<ld> vld;

typedef vector<i64> vi64;

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

void solve() {
  int n;
  cin >> n;
  vi a(n);
  forn(i, n) cin >> a[i];
  i64 r = 0;
  forn(i, n) {
    r += a[i] / 2;
    a[i] %= 2;
    if (a[i] && i + 1 < n && a[i + 1]) {
      r += 1;
      a[i] -= 1;
      a[i + 1] -= 1;
    }
  }
  cout << r << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed; cout.precision(15);
  cerr << fixed; cerr.precision(15);
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  solve();
  return 0;
}


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

int main(){
    int num;    cin>>num;
    int x=num;
    int s=0;

    while(x>0){
        s += x%10;

        x/=10;
    }

    if(num%s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int main()
{
	long long a,b,c,d,N;
	long long ab[4];
	cin >> a >> b >> c >> d;
	ab[0] = a * c; ab[1] = a * d; ab[2] = b * c; ab[3] = b * d; 
	N = ab[0];
	for (int i = 0; i < 4; i++) {
		if (ab[i] > N) {
			N = ab[i];
		}
	}
	cout << N;
	return 0;
}

Measured memory_bytes: 3628
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
typedef vector<ii> vii;
typedef vector<lii> lvii;

#define min_prq(t) priority_queue<t,vector<t>,greater<t>>
#define max_prq(t) priority_queue<t>
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_product() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------


signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	string s;
	cin>>s;
	ll len=s.length();
	if(s[0]==s[len-1]) len--;
	len-=2;
	if(len&1) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
#define ll int
bool vis[(int)1e5 + 5] = {0};
signed main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);

    //freopen("in29.txt", "r", stdin);
    int n;cin >> n;
    vi a(n), b(n);
    vector<pair<int, int>> temp;
    FOR(i, n)cin >> a[i];
    FOR(i, n)cin >> b[i];
    FOR(i, n)temp.pb(mp(b[i], a[i]));
    sort(temp.begin(), temp.end());
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    FOR(i, n){
        temp[i].first = temp[i].second;
        temp[i].second = i;
    }
    sort(temp.begin(), temp.end());

    FOR(i, n){
        if(a[i] > b[i]){
            cout << "No" <<endl;
            return 0;
        }
    }
    FOR(i, n -1){
        if(a[i+1] <= b[i]){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    int cnt = 0;
    int j= 0;
    while(!vis[j]){
        vis[j] = true;
        cnt++;
        j = temp[j].second;
    }
   // debug(cnt);

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


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

string S; cin>>S;

if(S[5]=='1') cout << "TBD" << endl;

else if(S[6]-'0'<=4) cout << "Heisei" << endl;

else cout << "TBD" << endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n, k;
	cin >> n >> k;

	double res = 0;
	rep(i, n) {
		double prob = 1/double(n);
		int point = i+1;
		while(point < k) {
			prob *= 0.5;
			point *= 2;
		}
		res += prob;
	}
	cout << fixed << setprecision(15);
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string o,t;
	cin>>o>>t;
	for(int i=0;i<o.size();i++){
		cout<<o[i];
		if(i<t.size()){
			cout<<t[i];
		}
		else{
		}
	}
	cout<<endl;
}


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

int feb(int n){
  int A[n];
  A[0]=A[1]=1;   
    if(n>=2){
      for (int i=2;i<=n;i++){
         A[i]= A[i-1]+A[i-2];
       }
    }
     return A[n];
  }

int main(void){
	int l;
  	cin>>l;
    cout<<feb(l)<<endl;
	return 0;
}


Measured memory_bytes: 3080
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b
# s = input()

N, D = map(int, input().split())
X = [0]*(N+1)
for i in range(1, N+1):
    X[i] = [0] + list(map(int, input().split()))


def dist(l1, l2):
    res = 0
    for i in range(1, D+1):
        tmp = (l1[i] - l2[i])
        res += tmp * tmp
    return res


#
ans = 0
for i in range(1, N+1):
    for j in range(i+1, N+1):
        tmp = dist(X[i], X[j])
        k = 0
        while k * k <= tmp:
            if k * k == tmp:
                ans += 1
            k += 1
print(ans)


Measured memory_bytes: 38896
package main

import "fmt"

func main() {
	var n, k int
	var r, s, p int
	var T string
	fmt.Scan(&n, &k)
	fmt.Scan(&r, &s, &p)
	fmt.Scan(&T)

	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, 3)
	}

	sum := 0
	for i := 0; i < k; i++ {
		var last int
		for j := i; j < n; j += k {
			// score
			if i != j {
				dp[j][0] = max(dp[j-k][1], dp[j-k][2])
				dp[j][1] = max(dp[j-k][2], dp[j-k][0])
				dp[j][2] = max(dp[j-k][0], dp[j-k][1])
			}
			switch T[j] {
			case 'r':
				dp[j][2] += p
			case 's':
				dp[j][0] += r
			case 'p':
				dp[j][1] += s
			}
			last = j
		}
		sum += max(dp[last][0], max(dp[last][1], dp[last][2]))
	}
	fmt.Println(sum)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 7888
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair<int, int>>PP;
typedef long long ll;
ll inf = 1e9;

int h, w;
int c[10][10];

void wf() {
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	wf();
	int ch[10];
	for (int i = 0; i < 10; i++) {
		ch[i] = c[i][1];
	}
	int a;
	ll ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a;
			if (a != -1) {
				ans += ch[a];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

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

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    string S;
    map<char,bool> alp;

    rep(i,26) alp[(char)('a' + i)] = false;
    cin >> S;

    rep(i, S.size()){
        alp[S[i]] = true;
    }

    rep(i,26){
        if(!alp[(char)('a' + i)]){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
# i は 通し番号
cities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))
pref = cities[0]
counter = 1
for city in cities:
    if pref != city[0]:
        counter = 1
    pref = city[0]
    rank = counter
    number = str(pref).zfill(6) + str(rank).zfill(6)
    city.append(number)
    counter += 1
for i in sorted(cities, key=lambda x: x[2]):
    print(i[3])


Measured memory_bytes: 35376
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;
 
int pow2(int x) {
  return x*x;
}
 
int main() {
  double d;
  cin >> d;
  int dx1000 = floor(d * 1000 + 0.01);
  double md;
  if (dx1000 >= 1000 && dx1000 <= 1414) {
    md = 2.0;
  } else if (dx1000 >= 2000 && pow2(dx1000) <= 4500000) {
    md = 3.0;
  } else {
    md = d * sqrt(2.0);
  }
 
  printf("%.10lf\n", md);
 
  return 0;
}

Measured memory_bytes: 3272
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long
#define ull unsigned long long
#define debug(x) cerr<<#x<<"="<<x<<'\n'
//#define DEBUG

const int MOD=1e9+7;

int a;
string s;
vector<int> res,ans;

int main()
{
	#ifdef DEBUG
	clock_t tStart = clock();
	#endif
	cin>>a>>s;
	for(int ii=0;ii<2;ii++)
		for(int j=0;j<2;j++)
		{
			res.clear();
			res.PB(ii),res.PB(j);
			for(int i=2;i<a;i++)
				if(res[i-1]==0&&s[i-1]=='o') 
					res.PB(res[i-2]);
				else if(res[i-1]==0&&s[i-1]=='x')
					res.PB(res[i-2]^1);
				else if(res[i-1]==1&&s[i-1]=='o')
					res.PB(res[i-2]^1);
				else if(res[i-1]==1&&s[i-1]=='x')
					res.PB(res[i-2]);
//			for(int i=0;i<res.size();i++) cout<<res[i]<<' ';
			if(res[a-1]==0&&s[a-1]=='o'&&res[a-2]!=res[0]) continue;
			if(res[a-1]==0&&s[a-1]=='x'&&res[a-2]==res[0]) continue;
			if(res[a-1]==1&&s[a-1]=='o'&&res[a-2]==res[0]) continue;
			if(res[a-1]==1&&s[a-1]=='x'&&res[a-2]!=res[0]) continue; 
			if(res[0]==0&&s[0]=='o'&&res[a-1]!=res[1]) continue;
			if(res[0]==0&&s[0]=='x'&&res[a-1]==res[1]) continue;
			if(res[0]==1&&s[0]=='o'&&res[a-1]==res[1]) continue;
			if(res[0]==1&&s[0]=='x'&&res[a-1]!=res[1]) continue; 
			ans=res;
			break;
		}
	if(!ans.size()) puts("-1");
	else
	{
		for(int i=0;i<a;i++) 
			if(ans[i]==0) cout<<'S';
			else cout<<'W';
		puts("");
	}
	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
	return 0;
}



Measured memory_bytes: 1400
n = int(raw_input())
S = []
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in xrange(n):
    S.append(raw_input())

res = ''
for alph in alphabet:
    min_encounter = S[0].count(alph)
    if min_encounter == 0:
        continue
    
    for s in S[1:]:
        encounter = s.count(alph)
        min_encounter = min(encounter, min_encounter)
        if min_encounter == 0:
            break

    if min_encounter == 0:
        continue
    res += alph * min_encounter
print res


Measured memory_bytes: 2568
#include <stdio.h>
#include <math.h>

int main() 
{
	long long x,z,i,k;
	double y=100,j;
	scanf("%lld",&x);
	for(i=1;i<=3760;i++)
	{
		 y=y+y*0.01;
		 k=y;
		 y=k;
		if(y>=x)
		  {
		  	printf("%lld",i);
		  	break;
		  }
	}
    return 0;
}








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

using namespace std;

int findSol(int hieght[],int n,int k){
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=1;j<=k;j++){
            dp[i+j] = min(dp[i+j],abs(hieght[i]-hieght[i+j])+dp[i]);
        }
    }
    return dp[n-1];
}

int main(){
    int n,k;
    cin>>n>>k;
    int hieght[n];
    for(int i=0;i<n;i++){
        cin>>hieght[i];
    }
    cout<<findSol(hieght,n,k)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=101, W=1e5+5;
const ll INF=1LL<<60;
ll dp[N][W],n,w,A[N][2];

ll f(int i, int j){
	if(i == n)return j == 0 ? 0 : INF ;
	ll &r=dp[i][j];
	if(r!=-1)return r;
	r=f(i+1,j);
	if(j>=A[i][0])r=min(r,f(i+1,j-A[i][0])+A[i][1]);
	return r;
}

int main(){FIN;mset(dp,-1);
	cin >> n >> w;
	int total = 0;
	fore(x,0,n)cin>>A[x][1]>>A[x][0],total+=A[x][0];
	for(int x=total; x>=0; x--){
		if(f(0,x)<=w){cout<<x<<"\n";exit(0);}
	}
}

Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int W = Integer.parseInt(array[0]);
		int H = Integer.parseInt(array[1]);
		int x = Integer.parseInt(array[2]);
		int y = Integer.parseInt(array[3]);
		int r = Integer.parseInt(array[4]);

		if (x - r < 0 || x + r > W || y + r > H || y - r < 0) {
			System.out.println("No");

		}
		else if (x - r >= 0 && x + r <= W || y - r >= 0 && y + r <= H) {
			System.out.println("Yes");

		}

	}

}

Measured memory_bytes: 26172
# -*- coding: utf-8 -*-
import math

S = int(input())

N = S // 3
R = S % 3
#print(N,R)

ans = 0
for i in range(N):
  tmp_N = N-i
  tmp_R = R+(i*3)
  temp_ans = math.factorial(tmp_N+tmp_R-1) // ( math.factorial(tmp_R)* math.factorial(tmp_N-1) )
  ans += temp_ans % (10**9+7)
  
print( ans % (10**9+7) )

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

int main(){
	ll count=0;
	ll N,M;
	cin>>N>>M;

	vector<ll> A(N);
	vector<pair<ll,ll>> vec(M,pair<ll,ll>());

	for(ll i=0;i<N;i++)
		cin>>A.at(i);

	for(ll i=0;i<M;i++)
		cin>>vec.at(i).second>>vec.at(i).first;

	sort(A.begin(),A.end());
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());

	ll ite=0;



	for(ll i=0;i<M;i++){
		for(ll j=ite ; vec.at(i).second>0 && j<N; j++){
			if(A.at(j)<vec.at(i).first){
				A.at(j)=vec.at(i).first;
				vec.at(i).second--;
				ite++;
			}
			else{
				for(ll k=0;k<N;k++)
					count+=A.at(k);
				cout<<count<<endl;
				return 0;
			}
		}
	}

	for(ll i=0;i<N;i++)
		count+=A.at(i);

	cout<<count<<endl;
	

}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, m){
        int s, t;
        cin >> s >> t;
        a[s - 1]++;
        a[t - 1]++;
    }
    rep(i, 0, n){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  string s, t; cin >> s >> t;
  string ans;
  bool isMatch = false;
  for(int i=s.size()-t.size(); i >= 0 && !isMatch; --i) {
    ans = s;
    for(int j=t.size()-1; j>=0; --j) {
      //printf("compare %c %c\n", s[i+j], t[j]);
      if(s[i+j] == t[j] || s[i+j] == '?') {
        ans[i+j] = t[j];
        isMatch = true;
      } else {
        isMatch = false;
        break;
      }
    }
  }
  if(isMatch) {
    rep(i, ans.size()) {
      if(ans[i] == '?') ans[i] = 'a';
    }
    cout << ans << endl;
  }
  else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;i++){
        cout<<s.at(i)<<t.at(i);
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int N,K,d;
	char str[10];
	bool D[10]={};
	cin>>N>>K;
	for(int i=0;i<K;i++){
		cin>>d;
		D[d]=1;
	}
	int i;
	for(i=N;1;i++){
		sprintf(str,"%d",i);
		bool flag=0;
		for(int j=0;str[j]!='\0';j++){
			if(D[str[j]-'0']) flag=1;
		}
		if(flag==0) break;
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,m;
    cin>>n;
    vector<string> blue(n);
    for (int i = 0;i < n;i++) {
        cin>>blue[i];
    }
    cin>>m;
    vector<string> red(m);
    for (int i = 0;i < m;i++) {
        cin>>red[i];
    }
    int ans = 0;
    auto calc = [&](const string s) {
        int buf = 0;
        for (string t: blue) {
            if (s == t) {
                buf++;
            }
        }
        for (string t: red) {
            if (s == t) {
                buf--;
            }
        }
        return buf;
    };

    for (string t: blue) {
        ans = max(ans,calc(t));
    }
    cout<<ans<<endl;
}

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

int main(){

  long long n, l[100]={2, 1};

  for(int i=2;i<90;i++){
    l[i]=l[i-1]+l[i-2];
  }

  cin>>n;

  cout<<l[n]<<endl;

  return 0;
}


Measured memory_bytes: 256
def checkCard(x, y):
  if x == 1 and y == 13:
    return "Alice"
  elif x == 13 and y == 1:
    return "Bob"
  elif x == 1 and y == 1:
    return "Draw"
  else:
    return ""

a, b = map(int, input().split())
result = checkCard(a,b)
if result == "":
  if a > b:
    print("Alice")
  elif a == b:
    print("Draw")
  else:
    print("Bob")
    
else:
  print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int ans=0;
    int val=0;
    for(int i=1;i<n;i++){
        if(h[i-1]>=h[i]) val++;
        else val=0;
        ans=max(ans,val);
    }
    cout<<ans;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vec;
typedef vector<Vec> DVec;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

#define fi             first
#define se             second
#define pb             push_back
#define INF            LLONG_MAX/3
#define MOD            1000000007
#define bcnt           __builtin_popcount
#define all(x)         (x).begin(),(x).end()
#define uni(x)         x.erase(unique(all(x)),x.end())
#define ub(x,y)        (upper_bound(all(x),y)-x.begin())
#define lb(x,y)        (lower_bound(all(x),y)-x.begin())
#define ssort(x)       sort(all(x))
#define rep(i,n)       repl(i,0,n-1)
#define mkp(x,y)       make_pair(x,y)
#define mmax(x,y)      (x>y?x:y)
#define mmin(x,y)      (x<y?x:y)
#define maxch(x,y)     x=mmax(x,y)
#define minch(x,y)     x=mmin(x,y)
#define exist(x,y)     (find(all(x),y)!=x.end())
#define each(itr,v)    for(auto itr:v)
#define repl(i,a,b)    for(ll i=(ll)(a);i<=(ll)(b);i++)
#define dvec(n1,n2,i)  DVec(n1,Vec(n2,i))
vector<vector<char>> area(102,vector<char>(102));

ll a,b;
int main(){
  cin.sync_with_stdio(false);
  cin >> a >> b;
  rep(i,50)rep(j,100){
    area[i][j] = '#';
    area[i+50][j] = '.';
  }
  a--;b--;

  for(ll i = 1; i<50; i+=2)for(ll j = 1; j < 100; j+=2){
    if(a > 0){
      area[i][j] = '.';
      a--;
    }
    if(b > 0){
      area[i+50][j] = '#';
      b--;
    }
  }
  cout << 100 << ' ' << 100 << endl;
  rep(i,100){
    rep(j,100)cout << area[i][j];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		a := scanInt()
		if a%2 == 1 {
			fmt.Println("first")
			return
		}
	}
	fmt.Println("second")
}


Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int c = 0;
        Scanner sc = new Scanner(System.in);
        Double[] inputData = new Double[8];

        int dataSet = sc.nextInt();
        while ( c < dataSet ) {
            for ( int i = 0; i < 8; i++ ) {
                inputData[i] = sc.nextDouble();
            }

            if ( (inputData[3] - inputData[1]) / (inputData[2] - inputData[0])
                 == (inputData[7] - inputData[5]) / (inputData[6] - inputData[4]) ) {
                System.out.println("YES");
            }
            else {
                System.out.println("NO");
            }
            c++;
        }
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void){
char str[10];
scanf("%s",str);

if(
(str[0]==str[1]&&str[2]==str[3]&&str[0]!=str[2])
||(str[0]==str[2]&&str[1]==str[3]&&str[0]!=str[1])
||(str[0]==str[3]&&str[1]==str[2]&&str[0]!=str[1])
)
printf("Yes");
else
printf("No");

return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;  
  char S[h+1][w+1]={};
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> S[i][j];
    }
  }
  
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      int count = 0;
      if (S[i][j] == '#') {
        cout << '#';
      }
      else {
        if(S[i-1][j-1] == '#') count++;
        if(S[i-1][j] == '#') count++;
        if(S[i-1][j+1] == '#') count++;
        if(S[i][j-1] == '#') count++;
        if(S[i][j+1] == '#') count++;
        if(S[i+1][j-1] == '#') count++;
        if(S[i+1][j] == '#') count++;
        if(S[i+1][j+1] == '#') count++;
        cout << count;
      }
    }
    cout << endl;
  }

}


Measured memory_bytes: 256
r,g,b,n=list(map(int,input().split()))
cnt=0
for i in range(n+1):
        for j in range(n+1):
                z=n-(i*r+j*g)
                if 0<=z and z%b==0:
                        #print(i,j,z)
                        cnt+=1
print(cnt)



Measured memory_bytes: 40812
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

/*==================================================*/

/*==================================================*/

int N, D, M, T;
map<int,int> m;

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>D;
        m[D]++;
    }
    cin>>M;
    REP(i,0,M){
        cin>>T;
        if(m.find(T) != m.end()){
            m[T]--;
            if(m[T] < 0){
                cout<<"NO"<<endl;
                return 0;
            }
        }else{
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,i,r=1,flag=0;;
	cin>>a>>b>>c;
	for(i=1;i<=b;i++)
	{
		r=a*i;
		if(r%b==c)
		{
			cout<<"YES"<<endl;
			flag=1;
			break;
		}
	}
	if(flag==0)cout<<"NO"<<endl;
} 

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

namespace ABC114C
{
    static class MainClass
    {


        public static string[] sft = new string[3] { "3","5", "7" };

        public static void Main(string[] args)
        {


            string N = Console.ReadLine();
            Console.WriteLine(Dfs(int.Parse(N), ""));

            return;


        }


        public static int Dfs(int upper, string st)
        {

            int ans = 0;
            if (st.Equals(string.Empty)) 
            {}else if (long.Parse(st) > upper)
            {
                return 0;
            }

            if (st.IndexOf('3') >= 0 && st.IndexOf('5') >= 0 && st.IndexOf('7') >= 0)
            {
                ans++;
            }

            foreach(string str in sft)
            {
                ans += Dfs(upper,st + str);
            }
            return ans;

        }


        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }




    }

}






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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string S, T;
    cin >> S >> T;
    set<char> apearInS{};
    for (auto c : S) {
        apearInS.insert(c);
    }
    for (auto c : T) {
        if (apearInS.count(c) == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<vector<lint>> NextIndexOf(26, vector<lint>(S.size() + 1, INF));
    for (char c = 'a'; c <= 'z'; c++) {
        int ci = c - 'a';
        for (int i = 0; i < S.size(); i++) {
            if (S[i] == c) NextIndexOf[ci][i] = i;
        }
        for (int i = S.size(); 0 < i; i--) {
            NextIndexOf[ci][i - 1] =
                min(NextIndexOf[ci][i], NextIndexOf[ci][i - 1]);
        }
    }
    // ddump(NextIndexOf);

    lint ans = 0LL;
    lint pos = 0;
    for (int i = 0; i < T.size(); i++) {
        int npos = NextIndexOf[T[i] - 'a'][pos];
        if (npos == INF) {
            ans += S.size();
            npos = NextIndexOf[T[i] - 'a'][0];
        }
        pos = npos;

        pos += 1;
        if (pos == S.size()) {
            ans += S.size();
            pos = 0;
        }
    }
    ans += pos;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

class lct_node {
	lct_node *l, *r, *p;
	int val, sum;

	int pos() {
		if (p && p->l == this) return -1;
		if (p && p->r == this) return 1;
		return 0;
	}
	void update() {
		sum = (l ? l->sum : 0) + val + (r ? r->sum : 0);
	}
	void rot() {
		lct_node *par = p;
		lct_node *mid;
		if (p->l == this) {
			mid = r;
			r = par;
			par->l = mid;
		}
		else {
			mid = l;
			l = par;
			par->r = mid;
		}
		if (mid) mid->p = par;
		p = par->p;
		par->p = this;
		if (p && p->l == par) p->l = this;
		if (p && p->r == par) p->r = this;
		par->update();
		update();
	}
	void splay() {
		while (pos()) {
			int st = pos() * p->pos();
			if (!st) rot();
			else if (st == 1) p->rot(), rot();
			else rot(), rot();
		}
	}

public:
	lct_node(int v = 0) : l(nullptr), r(nullptr), p(nullptr), val(v), sum(v) {}
	void expose() {
		for (lct_node *x = this, *y = nullptr; x; y = x, x = x->p) x->splay(), x->r = y, x->update();
		splay();
	}
	void link(lct_node *x) {
		x->expose();
		expose();
		p = x;
	}
	void cut() {
		expose();
		l->p = nullptr;
		l = nullptr;
		update();
	}
	int find_sum() {
		expose();
		return sum;
	}
	void update_val(int v) {
		expose();
		val += v;
		update();
	}
};

const int MAX = 1e5;

lct_node lct[MAX];

void build(int v, const graph& G) {
	for (auto to : G[v]) {
		lct[to].link(&lct[v]);
		build(to, G);
	}
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	graph G(n);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			G[i].push_back(c);
		}
	}
	build(0, G);
	int q;
	cin >> q;
	while (q--) {
		int com;
		cin >> com;
		if (com == 0) {
			int v, w;
			cin >> v >> w;
			lct[v].update_val(w);
		}
		else {
			int u;
			cin >> u;
			printf("%d\n", lct[u].find_sum());
		}
	}
	return 0;
}



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

using namespace std;

typedef long long ll;

class Point
{
public:
    int x,y;
    Point(int _x=0,int _y=0)
    {
        x=_x;
        y=_y;
    }
};

void compress(vector<Point> &s,vector<Point> &t,vector<int> &posX,vector<int> &posY)
{
    for(int i=0;i<s.size();i++)
    {
        posX.push_back(s[i].x);
        posY.push_back(s[i].y);
    }
    for(int i=0;i<t.size();i++)
    {
        posX.push_back(t[i].x);
        posY.push_back(t[i].y);
    }
    posX.erase(unique(posX.begin(),posX.end()),posX.end());
    posY.erase(unique(posY.begin(),posY.end()),posY.end());
    sort(posX.begin(),posX.end());
    sort(posY.begin(),posY.end());
    for(int i=0;i<s.size();i++)
    {
        s[i].x=lower_bound(posX.begin(),posX.end(),s[i].x)-posX.begin();
        s[i].y=lower_bound(posY.begin(),posY.end(),s[i].y)-posY.begin();
    }
    for(int i=0;i<t.size();i++)
    {
        t[i].x=lower_bound(posX.begin(),posX.end(),t[i].x)-posX.begin();
        t[i].y=lower_bound(posY.begin(),posY.end(),t[i].y)-posY.begin();
    }
}

int main()
{
    int n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>n)
    {
        int x1,y1,x2,y2;
        vector<Point> s,t;
        for(int i=0;i<n;i++)
        {
            cin>>x1>>y1>>x2>>y2;
            s.push_back(Point(x1,y1));
            t.push_back(Point(x2,y2));
        }
        vector<int> posX,posY;
        compress(s,t,posX,posY);

        vector<vector<bool> > mat(4001,vector<bool>(4001));

        for(int i=0;i<n;i++)
        {
            for(int j=s[i].x;j<t[i].x;j++)
            {
                for(int k=s[i].y;k<t[i].y;k++)
                {
                    mat[j][k]=true;
                }
            }
        }

        ll sum=0;
        for(int i=0;i<posX.size();i++)
        {
            for(int j=0;j<posY.size();j++)
            {
                if(mat[i][j])
                {
                    sum+=1LL*(posX[i+1]-posX[i])*(posY[j+1]-posY[j]);
                }
            }
        }
        cout<<sum<<endl;
    }

    return 0;
}



Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  int ans = 0;
  rep(i, n) {
    int a; cin>>a;
    ans += a-1;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;

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

//  scan(n);
  string s;
  scan(s);
  n = s.size();
  int cnt =0;
  char a = '1';
  REP(i, n){
    if(s[i]==a) cnt++;
    if(a=='1') a='0';
    else       a='1';
  }
  cout << min(cnt, n-cnt) << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
#define INF 1<<30

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

    reverse(b, b + n);
    int aa[n] = {}, bb[n] = {};
    aa[0] = a[0]; bb[0] = b[0];
    for (int i = 1; i < n; i++) {
        aa[i] = aa[i - 1];
        aa[i] += a[i];

        bb[i] = bb[i - 1];
        bb[i] += b[i];
    }

    reverse(bb, bb + n);

    for (int i = 0; i < n; i++) cerr << aa[i] << " "; cerr << endl;
    for (int i = 0; i < n; i++) cerr << bb[i] << " "; cerr << endl;

    int ans = -1;
    for (int i = 0; i < n; i++) {
        ans = max(ans, aa[i] + bb[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

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


def main():
    N, K, *A = map(int, read().split())

    counter = Counter(A)
    M = len(counter.keys())
    value = sorted(counter.values())

    ans = 0
    for i in range(M - K):
        ans += value[i]

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 35264
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

#define MAX_H 500001
void maxHeapify(int *in, int &root, int &h) {
	int l_idx = root * 2;
	int r_idx = root * 2 + 1;
	int largest = root;
	if (l_idx <= h && in[l_idx] > in[root]) largest = l_idx;
	if (r_idx <= h && in[r_idx] > in[largest]) largest = r_idx;
	if (largest != root) {
		swap(in[root], in[largest]);
		maxHeapify(in, largest, h);
	}
	return;
}

int main() {
	int h = 0;
	scanf("%d", &h);
	int in[MAX_H] = { 0 };
	for (int i = 1; i <= h; i++) {
		scanf("%d", &in[i]);
	}
	for (int i = h / 2; i >= 1; i--) {
		maxHeapify(in, i, h);
	}
	for (int i = 1; i <= h; i++) {
		printf(" %d", in[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 4684
arr=[]
numbero=list(map(int, input().split()))
for i in range(numbero[0]):
    arr.append(input())
way=[[0 for i in range(numbero[1])] for j in range(numbero[0])]
way[0][0]=1
head=0
whoop=[[0,0]]
while head<len(whoop):
    u=whoop[head][0]
    v=whoop[head][1]
    head+=1
    if u>0:
        if way[u-1][v]==0 and arr[u-1][v]=='.':
            way[u-1][v]=way[u][v]+1
            whoop.append([u-1,v])
    if v>0:
        if way[u][v-1]==0 and arr[u][v-1]=='.':
            way[u][v-1]=way[u][v]+1
            whoop.append([u,v-1])
    if u<numbero[0]-1:
        if way[u+1][v]==0 and arr[u+1][v]=='.':
            way[u+1][v]=way[u][v]+1
            whoop.append([u+1,v])
    if v<numbero[1]-1:
        if way[u][v+1]==0 and arr[u][v+1]=='.':
            way[u][v+1]=way[u][v]+1
            whoop.append([u,v+1])
if way[numbero[0]-1][numbero[1]-1]==0:
    print(-1)
else:
    head=0
    for i in arr:
        head+=i.count('.')
    print(head-way[numbero[0]-1][numbero[1]-1])

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

int main() {
  int64_t X;
  cin>>X;
  bool finished= true;
  for(int64_t i=0;i<120; i++){
    for(int64_t j=0;j<120; j++){
      if(pow(i,5)+pow(j,5)==X){
        cout<<i<<" -"<<j;
        finished= false;
        break;
      }
      else if(pow(i,5)-pow(j,5)==X){
        cout<<i<<" "<<j;
        finished= false;
        break;
      }
    }
    if(finished==false) break;
  }
}


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

int main() {

    string s;
    cin >> s;

    int sum = 0;
    for(int i = 0 ; i < s.size(); i++) {
        if(s[i] == 'o') sum++;
    }

    if(8 - sum <= 15 - s.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256