akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string o, e;
    cin >> o >> e;

    for (int i = 0; i < o.size(); i++) {
        cout << o[i];
        if (i < e.size()) cout << e[i];
    }
    cout << endl;

    return 0;
}

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

#define SAFE_DELETE( x ) { if ( x ){ delete x; x = NULL; } }

struct tCell{
	tCell() : x( 0.0 ), prev( NULL ), next( NULL ){}

	double x;
	tCell *prev, *next;
};

class MyArray{
public:
	MyArray() : mSize( 0 ), head( NULL ), tail( NULL ){
		head = new tCell;
		tail = new tCell;
		head->next = tail;
		tail->prev = head;
	}
	~MyArray(){
		for ( int i = mSize; i > 0; --i ){
			tCell* it = tail->prev;
			it->prev->next = it->next;
			it->next->prev = it->prev;
			SAFE_DELETE( it );
		}
		mSize = 0;
		SAFE_DELETE( tail );
		SAFE_DELETE( head );
	}

	void push( int x ){
		tCell* it = new tCell;
		it->x = x;
		it->prev = tail->prev;
		it->next = tail;
		it->prev->next = it;
		it->next->prev = it;
		++mSize;
	}
	double pop(){
		tCell* it = tail->prev;
		double ret = it->x;
		it->prev->next = it->next;
		it->next->prev = it->prev;
		SAFE_DELETE( it );
		--mSize;
		return ret;
	}
	double& ref(){
		return tail->prev->x;
	}

private:
	int mSize;
	tCell *head, * tail;
};

int getFigure( string& s ){
	bool minus = false;
	int ret = 0;
	if ( s[ 0 ] == '-' ){
		minus = true;
		s.erase( 0, 1 );
	}
	while ( s[ 0 ] >= '0' && s[ 0 ] <= '9' ){
		ret = ret * 10 + static_cast< int >( s[ 0 ] - '0' );
		s.erase( 0, 1 );
	}
	s.erase( 0, 1 );

	return minus ? -ret : ret;
}

int main(){
	string s;

	while ( getline( cin, s ) ){
		MyArray* stack = new MyArray();
		while( s.size() ){
			if ( ( s[ 0 ] >= '0' && s[ 0 ] <= '9' ) ||
				 ( s[ 0 ] == '-' && s[ 1 ] >= '0' && s[ 1 ] <= '9' ) ){
				stack->push( getFigure( s ) );
			}else{
				double t = stack->pop();
				switch ( s[ 0 ] ){
					case '+': stack->ref() += t; break;
					case '-': stack->ref() -= t; break;
					case '*': stack->ref() *= t; break;
					case '/': stack->ref() /= t; break;
					default : break;
				}
				s.erase( 0, 2 );
			}
		}

		cout << setprecision( 6 ) << setiosflags( ios::fixed );
		cout << stack->ref() << endl;

		delete stack;
	}

	return 0;
}

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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int get_m(string s) {
    if (s.size() == 1) return s[0]-'0';
    vector<string> v;
    rep(i, s.size()) {
        if (s[i] != '*') {
            string tmp = "";
            tmp += s[i];
            v.push_back(tmp);
        }
        else {
            string last = v[v.size()-1];
            v.pop_back();
            int num1 = stoi(last);
            int num2 = (s[i+1]-'0');
            int tmp = num1*num2;
            v.push_back(to_string(tmp));
            i++;
        }
    }
    if (v.size() == 1) {
        return stoi(v[0]);
    }
    int ret = 0;
    for (int i=1; i<v.size(); i+=2) {
        if (i == 1) {
            ret += stoi(v[i-1])+stoi(v[i+1]);
        }
        else {
            ret += stoi(v[i+1]);
        }
    }
    return ret;
}

int get_l(string s) {
    if (s.size() == 1) return s[0]-'0';
    int ret = -1;
    for (int i=1; i<s.size(); i+=2) {
        int num2 = s[i+1]-'0';
        if (i == 1) {
            int num1 = s[i-1]-'0';
            if (s[i] == '+') ret = num1 + num2;
            else ret = num1 * num2;
        }
        else {
            if (s[i] == '+') ret += num2;
            else ret *= num2;
        }
    }
    return ret;
}

int main() {
    string s;
    cin >> s;
    int ans;
    cin >> ans;
    int m = get_m(s);
    int l = get_l(s);
    string ret = "";
    if (m == ans) {
        if (l == ans) {
            ret = "U";
        }
        else {
            ret = "M";
        }
    }
    else if (l == ans) {
        ret = "L";
    }
    else {
        ret = "I";
    }
    cout << ret << endl;
}



Measured memory_bytes: 3312
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int a, b, c,d;
	cin >> a >> b >> c>>d;
	string ans = "No" ;
	if (abs(c - a) <= d)
	{
		cout << "Yes" << endl;
		
	}
	else
	{
		if (abs(b - a) <= d&&abs(c - b) <= d)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << ans << endl;
		}
	}



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
	string S; cin >> S; int N = S.size(); 
	int dp[200010][5] = {}; // i文字目までを切り分けて最後がj文字
	dp[1][1] = 1; 
	for(int i = 2; i <= N; i++){
		for(int j = 1; j < 5; j++){
			if(i < j) continue; 
			if(i == j){
				dp[i][j] = 1; continue; 
			}
			for(int k = 1; k < 5; k++){
				if(i < j+k) continue; 
				if(j != k) dp[i][j] = max(dp[i][j], dp[i-j][k] + 1); 
				else if(S.substr(i-j-k, k) != S.substr(i-j, j)) dp[i][j] = max(dp[i][j], dp[i-j][k] + 1); 
			}
		}
 	}
	int ans = max({dp[N][1], dp[N][2], dp[N][3], dp[N][4]}); 
	cout << ans << endl; 
}

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


int main(){
  ll n;cin >> n;
  ll a=0,w=0,t=0,r=0;
  rep(i,n){
    string s;cin >> s;
    if( s == "AC" ) a++;
    if( s == "WA" ) w++;
    if( s == "TLE" ) t++;
    if( s == "RE" ) r++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n,m;
  cin>>n>>m;
  bool ok[n];
  rep(i,n)ok[i]=true;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    ok[a]=!ok[a];
    ok[b]=!ok[b];
    }
  bool ans=true;
  rep(i,n)ans&=ok[i];
  if(ans)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
} 


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

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

void dfs(int depth, int m, vector<vector<int> > &v, vector<int> &a, int *ans, int prev)
{
    if (depth == 0)
    {
        int sum = 0;
        rep(i, v.size())
        {
            if (a[v[i][1]] - a[v[i][0]] == v[i][2])
            {
                sum += v[i][3];
            }
        }
        *ans = max(*ans, sum);
    }
    else
    {
        rep2(i, prev, m+1)
        {
            a[a.size() - depth] = i;
            dfs(depth - 1, m, v, a, ans, i);
        }
    }
    return;
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> v(q, vector<int>(4, 0));
    rep(i, q)
    {
        cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
        --v[i][0]; // a
        --v[i][1]; // b
    }
    vector<int> a(n);
    int ans(0);
    dfs(n, m, v, a, &ans, 1);

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  int mn = 0;
  int mx = 101;
  rep(i,n) {
    cin >> x.at(i);
    mn = min(x.at(i), mn);
    mx = max(x.at(i), mx);
  }
  
  long long min_loss =  std::numeric_limits<long long>::max();
  for (int p = mn; p <= mx; p++) {
    long long loss = 0;
    for (int j = 0; j < n; j++) {
      loss += (x.at(j) - p) * (x.at(j) - p);
    }
    min_loss = min(loss, min_loss);
  }
  
  cout << min_loss << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define L long
#define endl "\n"
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int freq[1000];

int main()
{   
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        freq[(int)s[i]]++;
    }
    for (int i = 0; i < s.length(); i++)
    {
        if (freq[(int)s[i]] % 2 != 0)
        {
            cout<< "No";
            return 0;
        }
    }
    cout<< "Yes";
    
    return 0;
}

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

int main() {
    long long int n, a_x, a_y, a_h;
    cin >> n;
    long long int x[n], y[n], h[n];
    for(int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> h[i];
    for(int cx = 0; cx <= 100; ++cx) {
        for(int cy = 0; cy <= 100; ++cy) {
            bool flag = true;
            long long int H;
            for(int i = 0; i < n; ++i) {
                if(h[i] > 0) {
                    H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                    break;
                }
            }
            for(int i = 0; i < n; ++i) {
                if(h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), 0LL)) {
                    flag = false;
                    break;
                }
            }
            
            if(flag) {
                a_x = cx;
                a_y = cy;
                a_h = H;
                goto endloop;
            }
        }
    }
    endloop:

    cout << a_x << " " << a_y << " " << a_h << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int W, H, N, x[110], y[110], a[110];
	int x_min = 0, x_max = 1000, y_min = 0, y_max = 1000;

	cin >> W >> H >> N;
	x_max = W;
	y_max = H;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	for (int i = 0; i < N; i++) {
		if (a[i] == 1) {
			if (x_min < x[i]) {
				x_min = x[i];
			}
		}
		if (a[i] == 2) {
			if (x_max > x[i]) {
				x_max = x[i];
			}
		}
		if (a[i] == 3) {
			if (y_min < y[i]) {
				y_min = y[i];
			}
		}
		if (a[i] == 4) {
			if (y_max > y[i]) {
				y_max = y[i];
			}
		}
	}
	if (x_min > x_max || y_min > y_max) {
		cout << 0 << endl;
	}
	else {
		cout << (x_max - x_min) * (y_max - y_min) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  int tmp = n;
  int sum = 0;
  while(tmp){
    sum += tmp % 10;
    tmp /= 10;
  }
  if(n % sum == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long

int max(int a, int b){
	return a >= b ? a : b;
}

signed main(){
	int H, W, N, i, j, k, ans = 0;
	scanf("%lld%lld", &H, &W);
	N = max(H, W);
	char **s = (char **)malloc(sizeof(char *) * (3 * N + 2));
	for(i = 0; i <= 3 * N + 1; i++){
		s[i] = (char *)malloc(sizeof(char) * (3 * N + 2));
		for(j = 0; j <= 3 * N + 1; j++){
			s[i][j] = '.';
		}
	}
	for(i = N + 1; i <= N + H; i++){
		scanf("%s", &s[i][N + 1]);
		s[i][N + W + 1] = '.';
	}
	int **A = (int **)malloc(sizeof(int *) * (3 * N + 2));
	for(i = 0; i <= 3 * N + 1; i++){
		A[i] = (int *)malloc(sizeof(int) * (3 * N + 2));
		for(j = 0; j <= 3 * N + 1; j++){
			A[i][j] = 0;
		}
	}
	for(i = 1; i <= 3 * N + 1; i++){
		for(j = 1; j <= 3 * N + 1; j++){
			A[i][j] = A[i - 1][j - 1];
			if(s[i][j] == '#'){
				A[i][j]++;
			}
		}
	}
	for(i = N + 1; i <= 2 * N; i++){
		for(j = N + 1; j <= 2 * N; j++){
			if(s[i][j] == '#'){
				for(k = 1; i + k <= 2 * N && j + k <= 2 * N; k++){
					if(s[i + k][j + k] == '#'){
						ans += A[i][j + 2 * k] - A[i - k - 1][j + k - 1];
						ans += A[i + 2 * k][j] - A[i + k - 1][j - k - 1];
					}
				}
			}
		}
	}
	for(i = 0; i <= 3 * N + 1; i++){
		for(j = 0; j <= 3 * N + 1; j++){
			if(j < 3 * N + 1 - j){
				char tmp = s[i][j];
				s[i][j] = s[i][3 * N + 1 - j];
				s[i][3 * N + 1 - j] = tmp;
			}
			A[i][j] = 0;
		}
	}
	for(i = 1; i <= 3 * N + 1; i++){
		for(j = 1; j <= 3 * N + 1; j++){
			A[i][j] = A[i - 1][j - 1];
			if(s[i][j] == '#'){
				A[i][j]++;
			}
		}
	}
	for(i = N + 1; i <= 2 * N; i++){
		for(j = N + 1; j <= 2 * N; j++){
			if(s[i][j] == '#'){
				for(k = 2; i + k <= 2 * N && j + k <= 2 * N; k++){
					if(s[i + k][j + k] == '#'){
						ans += A[i - 1][j + 2 * k - 1] - A[i - k][j + k];
						ans += A[i + 2 * k - 1][j - 1] - A[i + k][j - k];
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9344
n = int(input())
s = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    if s[i] == 'AC':
        ac += 1
    elif s[i] == 'WA':
        wa += 1
    elif s[i] == 'TLE':
        tle += 1
    else:
        re += 1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))


Measured memory_bytes: 16316
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2.0 << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  long n,l;
  cin  >> n >> l;
  vector<string> v(n);

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

  sort(v.begin(),v.end());

  for (int i = 0; i < n; ++i)
  {
    cout << v[i]; 
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int a,b; cin >> a >> b;
  cout << abs(b-((b-a)*(b-a+1))/2);
 
 return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int n, flag = 1, ans = 0;

int main() {
	scanf("%d", &n);
	for (register int i = 1; i <= n; i++) {
		if (i == 10) { flag = 0; }
		if (i == 100) { flag = 1; }
		if (i == 1000) { flag = 0; }
		if (i == 10000) { flag = 1; }
		if (i == 100000) { flag = 0; }
		ans += flag;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int solve(int w, int h) {
    vector<string> s(h);
    queue<int> queX;
    queue<int> queY;
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int x, y;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '@') {
                queX.push(i);
                queY.push(j);
                s[i][j] = '#';
                break;
            }
        }
    }
    int xmove[4] = {0, 0, -1, 1};
    int ymove[4] = {1, -1, 0, 0};
    int ans      = 0;
    while (!queX.empty() && !queY.empty()) {
        x = queX.front();
        y = queY.front();
        queX.pop();
        queY.pop();
        ans++;

        for (int i = 0; i < 4; i++) {
            if (x + xmove[i] >= 0 && x + xmove[i] < h && y + ymove[i] >= 0 && y + ymove[i] < w) {
                if (s[x + xmove[i]][y + ymove[i]] == '.') {
                    queX.push(x + xmove[i]);
                    queY.push(y + ymove[i]);
                    s[x + xmove[i]][y + ymove[i]] = '#';
                }
            }
        }
    }
    return ans;
}

int main() {
    int w, h;
    vector<int> ans;
    while (1) {
        cin >> w >> h;
        if (!w && !h)
            break;
        ans.push_back(solve(w, h));
    }
    for (int a : ans) cout << a << endl;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int len;
char a[105];
int main()
{
	scanf("%s",a);
	len=strlen(a);
	printf("%c%d%c",a[0],len-2,a[len-1]);
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<list>
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<iterator>
#include<map>
#include<limits>
#include<iomanip>
#include<ctime>
#include<cmath>
 
const int INF=2147483647;
const long long MOD=1e9+7;
 
using namespace std;




int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    long long k;
    cin>>n>>k;
    vector<long long> vi(100001,0);
    for(int i=1; i<=n; i++){
        int x,y;
        cin>>x>>y;
        //cout<<x<<vi[x]<<endl;
        vi[x]+=y;
    }
    
    long long ct=0;
    for(int i=0; ct<k; i++){
        ct+=vi[i];
        if(ct>=k){
            cout<<i;
            return 0;
        }
    }
    
    
   
    
    
    
    return 0;
    
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s.size() % 2 == 0){
		s.erase(s.size()-2);
	}else{
		s.erase(s.size()-1);
	}
	while(s.size() > 0){
		string b = s.substr(s.size()/2);
		string f = s;
		f.erase(f.size()/2);
		// cerr << b  << " " << f << endl;
		if(f == b){
			cout << s.size() << endl;
			return 0;
		}else{
			s.erase(s.size()-2);
		}
	}
	return 1;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] a = new double[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextDouble();
		}
		
		double sum = 0;
		double ans = 0;
		
		for (int i = 0; i < a.length; i++) {
			sum += 1/a[i];
		}
		
		ans = 1/sum;
		System.out.println(ans);
		
		sc.close();
	}
}


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

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

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
                                                                       
    int k; cin >> k;
    int array[k]; REP(i, k) cin >> array[i];

    sort(array, array + k);
    cout << array[k/2] - array[k/2 - 1];
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}

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

int main(){
  int N,ans=0,n=1;
  int V[50],C[50],S[50];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>V[i];
  }
  for(int i=0;i<N;i++){
    cin>>C[i];
  }
  for(int i=0;i<N;i++){
    S[i]=V[i]-C[i];
  }
  std::sort(S,S+N);
  if(S[N-1]<0){
    cout<<"0"<<endl;
  }
  else{
    while((S[N-n]>0)&&(N-n>=0)){
      ans=ans+S[N-n];
      n++;
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
char s; 
int main(){	
    cin>>a>>b;
    for(int i=0;i<=a+b;i++){
    	cin>>s;
    	if(i!=a){
    		if(s<'0'||s>'9'){
    			cout<<"No"<<endl;
    			return 0;
    		}
		}
    	else{
    		if(s!='-'){
    			cout<<"No"<<endl;
    			return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;


int main()
{
    int N,K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    
    for(int i=0; i<N-K; i++){
        if(A[i]<A[i+K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }




    return 0;
}

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

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

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

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish{
    ll time;
    ll taste;
};
int main()
{
    string S, T;
    cin >> S >> T;

    bool ok = false;
    for (ll i = 0; i < S.size(); i++)
    {
        if (S.substr(i) + S.substr(0, i) == T) {
            ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3580
/*
csc -debug A.cs && mono --debug A.exe <<< "6 4 3"
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var A = cin.NextInt();
        var B = cin.NextInt();
        var C = cin.NextInt();
        System.Console.WriteLine(Math.Max(C - (A - B), 0));
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 13140
n,m = map(int,input().split())
switch = []
for i in range(m):
    switch.append([i for i in map(int,input().split())])
amari = [i for i in map(int,input().split())]
a = 0
for i in range(2**n) :
    cnt = []
    for j in range(n):
        if ((i >> j)& 1) :
            p = j + 1
            cnt.append(p)

    ans = 0
    for h in range(m):
        count = 0
        for p in range(switch[h][0]) :
            if switch[h][p+1] in cnt :
                count += 1
        if count % 2 == amari[h] : ans += 1
    if ans == m:
        a += 1
print(a)

Measured memory_bytes: 3064
from collections import deque

n = int(input())

a = list(map(str, input().split()))
b = deque()
for i in range(n):
  if i % 2 == 0:
    #後ろに追加する場合
    b.append(a[i])
  else:
    b.appendleft(a[i])
    
    
    
if n % 2 != 0:
  b.reverse()
  
print(" ".join(b))

Measured memory_bytes: 26564
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {

  double d = 100;
  double x;

  cin >> x;

  for(uint i=1; ;i++){
    d = floor(d*1.01);
    if(x <= d){
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3244
import sys

N, M = map(int, sys.stdin.readline().rstrip().split())
Hs = list(map(int, sys.stdin.readline().rstrip().split()))

isnice = [True] * N

for j in range(M):
    Aj, Bj = map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split())
    if Hs[Aj] == Hs[Bj]:
        isnice[Aj] = isnice[Bj] = False
    elif Hs[Aj] < Hs[Bj]:
        isnice[Aj] = False
    else:
        isnice[Bj] = False

print(sum(isnice))

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

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

  int c,t;
  bool flag = false;
  int min = 1001;//取りうるコストの最大値より1大きい値
  for(int i = 0;i < N;i++){

    cin >> c >> t;

    if(t <= T and c < min){
      min = c;
      flag = true;//少なくとも条件を満たすものが存在する
    }


  }

  if(flag)cout << min << endl;
  else cout << "TLE" << endl;


}

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

int main()
{
    int i, N;
    int ans = 0;
    cin >> N;
    vector<int> data(N);
    for (i = 0; i < N; i++)
    {
        int min;
        cin >> data.at(i);
        if (i == 0)
        {
            ans++;
            min = data.at(i);
        }
        else
        {
            if (min >= data.at(i))
            {
                ans++;
                min = data.at(i);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#define N 100001
#define white 0
int n, q, m, iro = 1, qpt1 = 0, qpt2 = 0;
int color[N], Q[N];

typedef struct _list {
  int val;
  struct _list *next;
} list;

list *p, *G[N];

void null(int n) {
  for ( int i = 0; i < n; ++i ) G[i] = NULL;
}

list *add_list(list *node, int val) {
  p = (list*)malloc(sizeof(list));
  p->val = val;
  p->next = node;
  return p;
}

void enq(int u) {
  Q[++qpt1] = u;
}

int deq(void) {
  int u = Q[++qpt2];
  return u;
}

void bfs(int s) {
  int u;
  list *e;
  enq(s);

  while ( qpt1 != qpt2 ) {
    u = deq();
    for ( e = G[u]; e != NULL; e = e->next ) {
      if ( color[e->val] == white ) { //A[u][v]をLinearSearchにしてvがuの隣接リストに存在するなら1をかえす。
        color[e->val] = iro;
        enq(e->val);
      }
    }
  }
  ++iro;
}

int main(void) {
  int s_in, t_in, s_out, t_out;
  scanf("%d%d", &n, &m);
  for ( int i = 0; i < n; ++i ) {
    color[i] = white;
  }
  null(n);
  for ( int i = 0; i < m; ++i ) {
    scanf("%d%d", &s_in, &t_in);
    G[s_in] = add_list(G[s_in], t_in);
    G[t_in] = add_list(G[t_in], s_in);
  }
  scanf("%d", &q);
  int Print[q];
  int f;
  for ( int i = 0; i < q; ++i ) {
    scanf("%d%d", &s_out, &t_out);
    if ( color[s_out] == white && color[t_out] == white ) bfs (s_out);
    if ( color[s_out] == color[t_out] && color[s_out] != white ) {
     f = 1;
    }
    else {
     f = 0;
   }
   Print[i] = f;
  }
  for ( int i = 0; i < q; ++i ) printf("%s\n", (Print[i]) ? "yes" : "no");
}



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

vector<int> arr;

const int maxn =  1e9+5;
int cost(int y){
	
	int sum = 0;
	for(int x : arr){
		sum+=pow((x-y),2);
	}
	return sum;
}

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

	int mx = -100;
	int mn = 100;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		mx = max(mx,x);
		mn = min(mn,x);
		arr.push_back(x);
	}
	int res = maxn;
	//cout<<mn<<" "<<mx<<endl;
	for(int i = mn;i < mx;i++){
		res = min(cost(i),res);
	}
	if(mn==mx) cout<<0;
	else cout<<res;
}

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

int main(){
	int a[5],k;
	for(int i=0;i<5;i++){
		cin >> a[i] ;
	}
	for(int i=1;i<5;i++){
		for(int j=0;j<5-i;j++){
			if(a[j]<a[j+1]){
				k=a[j]; a[j]=a[j+1]; a[j+1]=k;
			}
		}
	}
	for(int i=0;i<4;i++){
		cout << a[i] <<" " ;
	}
	cout << a[4] << "\n";
return 0;
}

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

int a, b, c, d, e, f, a1, a2, b1, b2;
double num, mx = 0;
vector<int> w1, w2;
bool v1[3005], v2[3005];
void u(int p) {
	if (p > f || v1[p]) return;
	v1[p] = 1;
	w1.push_back(p);
	u(p + a * 100);
	u(p + b * 100);
}

void g(int p) {
	if (p > f || v2[p]) return;
	v2[p] = 1;
	w2.push_back(p);
	g(p + c);
	g(p + d);
}

int main()
{
	int i, j;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	u(0);
	g(0);
//	for (i =0; i < w1.size(); i++) {
//		cout << w1[i] <<endl;
//	}
	for (i = 1; i<w1.size(); i++) {
		for (j = 0; j < w2.size(); j++) {
			if (w1[i] + w2[j] > f) continue;
			if (w2[j] * 100 <= e * w1[i]) {
//				num = (double)(w2[j]) / (w1[i] + w2[j]);
				b1 = w1[i] + w2[j];
				b2 = w2[j];
				if (b2 * a1 > a2 * b1 || a1 == 0) {
//					mx = num;
					a1 = b1;
					a2 = b2;
				}
			}
		}
	}
	cout << a1 << " " << a2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#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,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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; }
const int INF = INT_MAX;
const int MOD = 1000000007;

int main() {
    int D, G;
    cin >> D >> G;
    vi p(D), c(D);
    rep(i, D) cin >> p[i] >> c[i];
    int ans = INF;
    rep(bit, 1<<D) {
        int n = 0;
        int point = 0;
        int rest_max = -1;
        rep(i, D) {
            if (bit & (1<<i)) {
                n += p[i];
                point += 100*(i+1) * p[i] + c[i];
            } else {
                rest_max = i;
            }
        }
        if (point < G) {
            int s = 100 * (rest_max + 1);
            int need = ((G-point) + s - 1) / s;
            if (need >= p[rest_max]) continue;
            n += need;
        }
        chmin(ans, n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  string S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
  int K;
  cin >> K;
  int count = 0;
  int n = 1;
  while(count < S.length()){
   if(S[count] == ',' && S[count + 1] == ' '){
     count += 2;
     n++;
   }
    else if(n == K) {
      cout << S[count];
      count++;
    }
    else count++;
  }
  
  return 0;
}


Measured memory_bytes: 256
grid = [list(map(int,input().split())) for i in range(3)]


if (grid[0][0] - grid[1][0]) == (grid[0][1] - grid[1][1]) == (grid[0][2] - grid[1][2]) and (grid[0][0]-grid[0][1]) == (grid[1][0]-grid[1][1]) == (grid[2][0] - grid[2][1]) and(grid[0][0] - grid[2][0]) == (grid[0][1] - grid[2][1]) == (grid[0][2] - grid[2][2]) and  (grid[0][0]-grid[0][2]) == (grid[1][0]-grid[1][2]) == (grid[2][0] - grid[2][2]):

    print('Yes')

else:
    print('No')

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

#define si(n) scanf("%d",&n)
#define MAX 1000006
typedef long long ll;


#define NL cout<<"\n";
#define ALL(a) a.begin(), a.end()
#define DBG(a) cout<< #a <<" --> "<<(a)<<endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)


int main()
{
    ll s;
    cin>>s;
    ll a =ceil(sqrt(s));
    ll b =ceil(sqrt(s));
//    DBG(a);
//    DBG(b);
    ll ab =a*b;
//    DBG(ab);
    ab-=s;
    assert(ab<=1e9);
    cout<<"0 0 "<<a<<" "<<ab<<" "<<1<<" "<<b<<"\n";
}


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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    set<ll> s;
    map<ll,vector<ll>> od;
    
    for (int i = 0; i < n; i++) {
        od[-a[i]+i+1].push_back(i);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += od[a[i]+i+1].size()-distance(od[a[i]+i+1].begin(),lower_bound(od[a[i]+i+1].begin(),od[a[i]+i+1].end(),i));
    }
    std::cout << ans << std::endl;
}

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

int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  int64_t S=N/(A+B);
  int64_t M=N%(A+B);
  if(M>=A) M=A;
  
  cout<<A*S+M<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string S;
int main(){
    cin >> S;
    if(S == "ooo"){
        cout << 1000 << endl;
    }else if(S == "oox" || S == "oxo" || S == "xoo"){
        cout << 900 << endl;
    }else if(S == "oxx" || S == "xox" || S == "xxo"){
        cout << 800 << endl;
    }else{
        cout << 700 << endl;
    }
    return 0;
}

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

int main() {
  typedef long long ll;
  ll k, a, b;
  cin >> k >> a >> b;
  if(b < a + 2) {
    cout << k + 1 << endl;
  } else {
    ll ans = a;
    k -= (a - 1);
    ans += (k / 2) * (b - a);
    ans += (k % 2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int num,nums[5];
  int i,j,k;

  scanf("%d",&num);
  do{
    nums[0]=num/10000;
    nums[1]=num/1000%10;
    nums[2]=num/100%10;
    nums[3]=num/10%10;
    nums[4]=num%10;
    
    for(i=0;i<5;i++) putchar(nums[i]<5?'*':' ');
    putchar('\n');
    for(i=0;i<5;i++) putchar(nums[i]>=5?'*':' ');
    putchar('\n');
    puts("=====");
    for(j=0;j<5;j++){
      for(i=0;i<5;i++) putchar(nums[i]%5==j?' ':'*');
      putchar('\n');
    }
  }while(scanf("%d",&num)!=EOF && putchar('\n'));
  return 0;
}

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

using namespace std;

#define ll long long
#define pii pair<int,int>

int main()
{
    int n;
    cin>>n;
    ll ans =0;
    for(int i =1;i<n;i++)
    {
        ans += (n-1)/i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
def main():
    S = int(input())
    a = [S]
    i = 0
    while True:
        i += 1
        if a[i - 1] % 2 == 0:
            a_ = a[i - 1] / 2
        else:
            a_ = 3 * a[i - 1] + 1
        if a_ in a:
            print(i + 1)
            return
        a.append(a_)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	long long int a=1000000,b=-1000000,c=0,n,m;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> m;
		if (m < a){
			a = m;
		}
		if (m>b){
			b = m;
		}
		c = c + m;
	}

	cout << a << " " << b << " " << c << endl;
	return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main()
{
  int N;
  cin >> N;
  double v[N];
  for(int i = 0; i < N; i++) cin >> v[i];

  sort(v,v + N);

  for(int i = 0; i < N - 1; i++){
    v[i + 1] = (v[i] + v[i + 1]) / 2;
  }

  cout << v[N - 1];


}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

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

	int n, k; cin >> n >> k;
	vector<int> a(n);
	int max_a = -1;
	rep(i, n) {
		cin >> a[i];
		max_a = max(max_a, a[i]);
	}
	int GCD = a[0];
	REP(i, 1, n) GCD = gcd(GCD, a[i]);
	bool flag = false;
	for(int i = max_a; i > 0; i -= GCD) if(i == k) flag = true;

	cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

#pragma warning(disable: 4996)

#define MAX_N 500000

using namespace std;

int N, C;

int v[MAX_N], dp[MAX_N + 7];

int main()
{
	scanf("%d", &N);

	dp[N] = 1;

	for (int i = (N + 2) / 2; i > 1; i--)
	{
		dp[i] = dp[2 * i - 1] + 2 * dp[2 * i] + dp[2 * i + 1];
	}

	for (int i = 2; i <= N; i++)
	{
		C += dp[i] * i;
	}

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

	sort(v, v + N);

	for (int i = 0; i < N; i++)
	{
		if (i) { printf(" "); }

		printf("%d", v[i]);
	}

	printf("\n");

	printf("%d\n", C);

	return 0;
}

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

int main(){
    int K,N;
    cin>>K>>N;
    vector<int> A(N),a(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    for(int i=0;i<N-1;i++){
        a.at(i)=A[i+1]-A[i];
    }
    a.at(N-1)=K+A.at(0)-A.at(N-1);
    sort(a.begin(),a.end());
    
    cout<<K-a.at(N-1)<<endl;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        // 累積和
        // W向いている人の数
        int[] cnt = new int[n + 1];
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            cnt[i + 1] = cnt[i];
            if (s[i] == 'W')
            {
                cnt[i + 1]++;
            }
        }

        // 自分より西にいて西を向いている人が
        //  cnt[i-1]人
        // 自分より東にいて東を向いている人が
        //  (N-i)-(cnt[N]-cnt[i])人
        int ans = n;
        for (int i = 1; i <= n; ++i)
        {
            ans = Math.Min(ans, cnt[i - 1] + (n - i) - (cnt[n] - cnt[i]));
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13280
a = gets.to_i
 b = gets.to_i
 c = gets.to_i
 d = gets.to_i
 e = gets.to_i
 k = gets.to_i

sum1 = b - a
sum2 = c - a
sum3 = d - a
sum4 = e - a
sum5 = c - b
sum6 = d - b
sum7 = e - d
sum8 = d - c
sum9 = e - c
sum10 = e - d

if sum1 <= k && sum2 <= k && sum3 <= k && sum4 <= k && sum5 <= k && sum6 <= k && sum7 <= k && sum8 <= k && sum9 <= k && sum10<= k
puts "Yay!"
else
puts ":("
end

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
void absorb( int &x, int n ){
    x = ( x * n ) % mod ;
    if( x < 0 ) x += mod ;
}



signed main(){
    int n, k ; cin >> n >> k ;
    vector<int> a(n) ;
    for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;    
    sort( all(a) ) ;
    int res = 1 ;
    if( a[n-1] <= 0 && (k&1)){
        reverse( all(a) ) ;
        for( int i = 0 ; i < k ; i++ ){
            absorb( res, a[i] ) ;
        }
        cout << res ;
    }
    else{
        int len = k, left = 0, right = n - 1 ;
        if( k & 1 ){
            absorb( res, a[right] ) ;
            right-- ;
            len-- ;
        }
        while( len > 0 ){
            int f = a[left] * a[left+1] ;
            int s = a[right] * a[right-1] ;
            if( f > s ){
                f %= mod ;
                absorb( res, f ) ;
                left += 2 ;
                len -= 2 ;
            }
            else{
                s %= mod ;
                absorb( res, s ) ;
                right -= 2 ;
                len -= 2 ;
            }
        }
        cout << res ;
        
    }
    return 0 ;   
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n,k;
  cin >> n >> k;
  vector<long> h(n);
  rep(i,n) cin >> h.at(i);
  sort(h.begin(),h.end());
  long ans = 1e12;
  for(int i = 0; i+k-1 < n; i++){
    ans = min(ans, h.at(i+k-1)-h.at(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
n=int(input())
M=10**6
l=[]
p=[1]*M
for i in range(2,M):
  if p[i]:
    l+=[i]
    for j in range(2*i,M,i): p[j]=0
d={}
for k in l:
  while n%k<1: n//=k; d[k]=d.get(k,0)+1
a=0
for i in d.values():
  t=c=0
  while t+c<i: c+=1; t+=c
  a+=c
print(a+(n>1))

Measured memory_bytes: 20088
def judge(ps):
    sorted_ps = sorted(ps.copy())
    count = 0
    if ps == sorted_ps:
        return True

    for i,p in enumerate(ps):
        if p != sorted_ps[i]:
            count += 1
        if count > 2:
            return False

    if count == 2:
        return True


N = int(input())
ps = list(map(int, input().split()))

if judge(ps):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>

int main() {
    long long int n,c;
    std::cin >> n >> c;
    long long int tx, tv;
    std::vector<std::pair<long long int, long long int>> v;
    v.push_back(std::make_pair(0,0));
    for (long long int i = 0; i < n; i++) {
        std::cin >> tx >> tv;
        v.push_back(std::pair<long long int, long long int> {tx,tv});
    }

    std::vector<long long> f,g,h;
    f.resize(n+1);
    f.push_back(0);
    for (long long i = 0; i < n; i++) {
        f[i+1] = f[i] + v[i+1].second - v[i+1].first + v[i].first;
    }
    g.resize(n+1);
    h.resize(n+1);
    g[0] = f[0];
    h[0] = f[0];
    for (long long i = 0; i < n; i++) {
        g[i+1] = std::max(g[i], f[i+1]);
        h[i+1] = std::max(h[i], f[i+1] - v[i+1].first);
    }

    long long cache = v[n].second - (c - v[n].first) * 2;
    long long ret = std::max(std::max(cache + g[n-1], cache + (c - v[n].first) + h[n-1]), static_cast<long long>(0));
    for (long long b = n - 1; b > 0; b--) {
        cache += v[b].second - v[b+1].first * 2 + v[b].first * 2;
        ret = std::max(ret, g[b-1] + cache);
        ret = std::max(ret, cache + (c - v[b].first) + h[b-1]);
    }
    ret = std::max(ret, g[n]);

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 4208
#include<stdio.h>


int main(){

  int a, min1=10000, min2;
  int i;

  for(i=0;i<3;i++){
    scanf("%d", &a);
    if(min1>=a){
      min2=min1;
      min1=a;
    }else if(min2>=a) min2=a;
  }

  printf("%d\n", min1+min2);

  return 0;
}


Measured memory_bytes: 128