akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]!=s[1] || s[0]!=s[2] || s[1]!=s[2])
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;

   return 0;
}


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

int main()
{
	long long N = 0, ans = 0;
	std::cin >> N;

	std::vector<long long> A(N + 1);
	std::vector<long long> B(N);
	for (int i = 0; i < N+1; i++){
		std::cin >> A[i];
	}
	for (int i = 0; i < N; i++){
		std::cin >> B[i];
	}

	for (int i = 0; i < N; i++){
		int c = std::min(A[i], B[i]);
		B[i] -= c;
		A[i] -= c;
		ans += c;

		c = std::min(A[i + 1], B[i]);
		B[i] -= c;
		A[i + 1] -= c;
		ans += c;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var str = line[0];
	var ans = str.slice(0,3) + '8' + str.slice(4);
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    int c = 0;
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s[i] == '-' && i != a)
        {
            cout << "No" << endl;
            return 0;
        }
        if (s[i] != '-' && i == a)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k) cout << s << '\n';
    else cout << s.substr(0, k) << "...\n";

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
int main()
{
	string a;
	cin >> a;

	if(a == "ABC") {
		cout << " ARC";
	}
	else if (a == "ARC") {
		cout << "ABC";
	}
}


Measured memory_bytes: 3576
h, w = map(int, input().split())
a = [0]*h
for i in range(h):
  a[i] = input()

dp = [[0]*w for i in range(h)]
inf = 10**9+7

dp[0][0] = 1

for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      continue
    else:
      if i > 0:
        dp[i][j] += dp[i-1][j]
        dp[i][j] %= inf
      if j > 0:
        dp[i][j] += dp[i][j-1]
        dp[i][j] %= inf

print(dp[h-1][w-1])


Measured memory_bytes: 43716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n;
    string s, t;
    cin >> n >> s >> t;
    
    //int x[100];
    for(int i=0; i<n; i++){
        cout << s[i] << t[i];
    }
    
    
 
 


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

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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

typedef std::stack<int> IntStack;
typedef std::queue<int> IntQueue;
typedef std::vector<int> IntVector;
typedef std::list<int> IntList;

using namespace std;
  
int main(){
  long long H;
  cin >> H;
  
  int count = 0;
  while(H > 0){
    H = H/2;
    count++;
  }
  
  long long ans = (long long)pow(2.0, (long double)count)-1;
  
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  vector<int> R(N);

  F0R(i, N) {
    int a;
    cin >> a;

    // R
    if (i + a < N) {
      R[i + a]++;
    }
    // L
    if (i - a >= 0) {
      L[i - a]++;
    }
  }

  u64 result = 0;
  F0R(i, N) {
    result += (u64)R[i] * L[i];
  }
  cout << result;
}
#endif


Measured memory_bytes: 4704
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var p = o.a();
  if(n === 1)return p;
  var m = Math.sqrt(p);
  var ans = 1;
  for(var i = 2; i <= m; i++){
    if(p % i === 0){
      var t = 1;
      p /= i;
      while(p % i === 0)t++, p /= i;
      while(t >= n)ans *= i, t -= n;
    }
  }
  return ans;
}

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

cnt = 0
A = []
for u in range(1, N) :
    for v in range(u+1, N+1) :
        if u + v == N + (N % 2 != 1) :
            continue
        else :
            cnt += 1
            A.append((u, v))

print(cnt)
for i in range(cnt) :
    print(*A[i])


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int last[26];
int c[26];
int s[365][26];
int a[365];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<26;i++){
    	cin >> c[i];
    }
    for(int i=0;i<d;i++){
    	for(int j=0;j<26;j++){
    		cin >> s[i][j];
    	}
    }
    for(int i=0;i<d;i++){
    	a[i]=myRand(26)+1;
    }
    int res=0;
    for(int i=0;i<d;i++){
    	res+=s[i][a[i]-1];
    	last[a[i]-1]=i+1;
    	for(int j=0;j<26;j++){
    		res-=c[j]*(i+1-last[j]);
    	}
    }
    for(int i=0;i<1e6;i++){
    	int day,qq;
    	day=myRand(d)+1;
    	qq=myRand(26)+1;
    	int resres=res;
    	int qqq=a[day-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres+=c[qq-1]*(i+1-last[qq-1]);
            resres+=c[qqq-1]*(i+1-last[qqq-1]);
        }
        a[day-1]=qq;
        resres-=s[day-1][qqq-1];
        resres+=s[day-1][qq-1];
        last[qq-1]=last[qqq-1]=0;
        for(int i=0;i<d;i++){
            if(a[i]==qq){
                last[a[i]-1]=i+1;
            }
            if(a[i]==qqq){
                last[a[i]-1]=i+1;
            }
            resres-=c[qq-1]*(i+1-last[qq-1]);
            resres-=c[qqq-1]*(i+1-last[qqq-1]);
        }
        if(resres>=res){

        }
        else{
        	a[day-1]=qqq;
        }
    }
    for(int i=0;i<d;i++){
    	printf("%d\n",a[i]);
    }
}



Measured memory_bytes: 3848
INF = 2 * 10**5 * 10**9
n = int(input())
a = map(int,input().split())
s = [0]
for x in a:
    s.append(s[-1]+x)
ans = INF
p1 = 1
p = 1
p2 = 3
while True:
    p += 1
    if p + 1 >= n:
        break
    while p1 < p and abs(s[p1] - s[p] + s[p1]) > abs(s[p1+1] - s[p] + s[p1 + 1]):
        p1 += 1
    while p2 < n and abs(s[p2] - s[p]  - s[n] + s[p2]) > abs(s[p2+1] - s[p]  - s[n] + s[p2+1]):
        p2 += 1
    ans = min(ans , max(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) -  min(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) )
print(ans)

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

int main(){
	for(int n; cin>>n&&n;){
		vector<int> p(n),j(n-1);
		for(int i=0;i<n;i++) cin>>p[i];
		for(int i=0;i<n-1;i++) cin>>j[i];
		sort(j.begin(), j.end(), greater<int>());
		long long l = accumulate(p.begin(), p.end(), 0);
		for(int i=0; i<n-1; i++){
			if(l*(n-i) >= (l+j[i])*(n-i-1)){
				cout<<l*(n-i)<<endl;
				goto NEXT;
			}
			l += j[i];
		}
		cout<<l<<endl;
		NEXT:;
	}
}

Measured memory_bytes: 3324
/*
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vvvll vector<vector<vector<ll>>>
#define vtype(type) vector<type>
#define vvtype(type) vector<vector<type>>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
struct wall
{
	long long r; ll c;
	bool operator<(const wall& rhs) const {
		if (r != rhs.r) {
			return r < rhs.r;
		}
		else {
			return c < rhs.c;
		}
	}
};

ll const MAX = 5e3 + 5;
vvll G(MAX);
vvvll dp(2, vvll(MAX, vll(MAX)));
vll parent(MAX);
vll ffct(1e6 + 5);
vll color(MAX);

ll const MOD = 998244353;
ll opp(ll x) {
	return (x + 1) % 2;
}


ll mod_p(ll x, ll y) {
	//x %= MOD;
	//y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		int t = s[i] - 'a' + 13;
		t %= 26;
		s[i] = 'a' + t;
	}
	cout << s << endl;
}
*/

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

struct point {
	int x; int y; int color;
};

bool order(point a, point b) { //0:blue 1:red
	return a.x < b.x;
}

point p[205];
bool used[205] = {};

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		p[i] = { x,y,1 };
	}
	for (int i = n; i < n * 2; i++) {
		int x, y;
		cin >> x >> y;
		p[i] = { x,y,0 };
	}
	sort(p, p + n * 2, order);
	int ans = 0;
	for (int i = 0; i < 2 * n; i++) {
		point cur = p[i];
		if (cur.color == 0) {
			int max_y = -100;
			int max_j = -1;
			for (int j = 0; j < i; j++) {
				if (max_y < p[j].y && p[j].color == 1 && used[j] == 0 && p[j].y < p[i].y) {
					max_y = p[j].y;
					max_j = j;
				}
			}
			if (max_j >= 0) {
				ans++;
				used[max_j] = 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
#define MAXN 0x3f3f3f3f
ll a[1005];
ll s[500501];
ll ss[41];
ll kkk[41];
int n,k;
vector<ll> K,S;
int pp=40;
void solve(int pos)
{
    for(int p=pos-1;p>=0;p--)
    {
        int ppp=0;
        for(int i=0;i<K.size();i++)
        {
            if(K[i]>>p&1)
                ppp++;
        }
        if(ppp>=k)
        {
            pp=p;
            kkk[pp]=1;
            break;
        }
    }
    //cout<<pos<<"**"<<pp<<endl;
    if(pos==pp)
        return;
    for(int i=0;i<K.size();i++)
    {
        if(K[i]>>pp&1)
            S.push_back(K[i]);
    }
    K=S;
    S.clear();
    solve(pp);
}
int main()
{
    
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    int po=0;
    for(int i=0;i<n;i++)
    {
        ll sum=0;
        for(int j=i;j<n;j++)
        {
            sum+=a[j];
            K.push_back(sum);
        }
    }
    solve(41);
    ll ssss=1,ans;
    for(int i=0;i<=40;i++)
    {
        if(kkk[i]==1)
            ans+=ssss;
        ssss*=2;
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 6256
w = int(input())
n = int(input())
l = list(range(1,w+1))
for i in range(n):
	a,b = map(int,input().split(','))
	a -= 1
	b -= 1
	l[a],l[b] = l[b],l[a]
for x in l:
	print(x)




Measured memory_bytes: 5596
#include <iostream>    

int main(void)
    {
      int N, D;
      std::cin >> N >> D;
      
      int ans = N / (2 *D +1);
      if (N % (2*D+1) != 0) {
        ans += 1;
      }
      
      std::cout << ans << std::endl;
      
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ll N;
  string S;
  cin >> N;
  cin >> S;
  rep(i,S.size()){
      S[i]-=65;
      S[i]+=N;
      S[i]%=26;
      S[i]+=65;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

x = 0
for i in range(n):
    if i&1 == 0:
        x += a[i]
    else:
        x -= a[i]

m = [0 for i in range(n)]
m[0] = x
for i in range(1, n):
    m[i] = 2*a[i-1] - m[i-1]

m = list(map(str, m))
print(" ".join(m))

Measured memory_bytes: 18452
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main() {
	int N, M; cin >> N >> M;
	vector<vector<P>> d(N, vector<P>());
	vector<string> ans(M);
	for (int i = 0; i < M; i++) {
		int p, y;
		cin >> p >> y;
		p--;
		d[p].push_back({ y,i });
	}
	for (int i = 0; i < N; i++) {
		sort(d[i].begin(), d[i].end());
		string pref = to_string(i + 1);
		while (pref.size() != 6) pref = "0" + pref;
		for (int j = 0; j < d[i].size(); j++) {
			string shi = to_string(j + 1);
			while (shi.size() != 6) shi = "0" + shi;
			string id = pref + shi;
			ans[d[i][j].second] = id;
		}
	}
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 12416
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    rep(i, n) if(h[i] >= k) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args:Array<String>?): Unit {
    while (true) {
        val (m, t, p, r) = readLine()!!.trim().split(' ').map(String::toInt)
        if (m == 0 && t == 0 && p == 0 && r == 0) return
        val teams = Array(t) { Team(it + 1, p) }
        repeat(r) {
            val (time, team, problem, status) = readLine()!!.trim().split(' ').map(String::toInt)
            teams[team - 1].submit(problem, time, status)
        }
        val sorted = teams.sortedDescending()
        val result = Stack<Any>()
        result.push(sorted.first().id)
        for (id in sorted.indices.drop(1)) {
            val team = sorted[id]
            if (result.isEmpty()) {
                result.push(team.id)
            } else if (sorted[id - 1].isSameScore(team)) {
                result.push("=")
                result.push(team.id)
            } else {
                result.push(",")
                result.push(team.id)
            }
        }
        println(result.joinToString(""))
    }
}
class Team(val id: Int, problemSize: Int): Comparable<Team> {
    private val problems = Array(problemSize){History()}
    fun submit(problem: Int, time: Int, status: Int): Unit {
        problems[problem - 1].submit(time, status)
    }
    private fun acCount(): Int = problems.count{it.accepted}
    private fun sumTime(): Int = problems.sumBy{it.acTime}
    fun isSameScore(other: Team): Boolean {
        return acCount() == other.acCount() && sumTime() == other.sumTime()
    }
    override fun compareTo(other: Team): Int {
        return if (acCount() != other.acCount()) acCount().compareTo(other.acCount())
            else if (sumTime() != other.sumTime()) other.sumTime().compareTo(sumTime())
            else id.compareTo(other.id)
    }

    override fun equals(other: Any?): Boolean {
        return when(other){
            is Team -> this.compareTo(other) == 0
            else -> super.equals(other)
        }
    }
}

class History {
    private var submitCount: Int = 0
    private var acceptedTime: Int = -1
    fun submit(time: Int, status: Int): Unit {
        if (acceptedTime == -1){
            if (status == 0){
                acceptedTime = time
            }else {
                submitCount++
            }
        }
    }
    val accepted: Boolean
        get() = acceptedTime != -1
    val acTime: Int
        get() {
            return if (accepted) acceptedTime + 20 * submitCount else 0
        }
}



Measured memory_bytes: 48304
n = int(input())
s = [[i for i in input()] for j in range(n)]
ans = []

for k in set(s[0]):
    if all(k in s[i] for i in range(n)):
        count = s[0].count(k)
        for j in range(1,n):
            count = min(count, s[j].count(k))
        for l in range(count):
            ans.append(k)
print(''.join(sorted(ans)))

Measured memory_bytes: 3064
//     THE ONLY WAY IS UP
 
#include<bits/stdc++.h>
 
#define ll              long long int
#define ld              long double
#define f1(i, a, b)     for(ll i = a; i < b; i++)
#define f2(a, b)        for(auto a : b)
#define ar(v, i)        v[i]
#define ar_(v, i, j)    v[i][j]
#define in_(x)          ll x; cin >> x;
#define ino_(type, x)   type x; cin >> x;
#define pb              push_back
#define nl              "\n"
#define tcase(t)        ll t; cin >> t; f1(z, 0, t)
using namespace std;

int main(){
    in_(k) in_(a) in_(b)
    f1(i, a, b+1){
        if(i%k == 0){
            cout << "OK" << nl;
            return 0;
        }
    }
    cout << "NG" << nl;
}

Measured memory_bytes: 3620
import random
import time
import copy

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    ans = []    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)
        
    random.seed(0)
    while time.time() - start < 1.9:
        cp = ans.copy()
        last_d = [0 for i in range(26)]
        score2 = 0  
        
        idx1 = random.randint(0,25)
        idx2 = random.randint(0,25)
        if random.randint(0,1):
            d1 = random.randint(0,D-1) 
            d2 = random.randint(0,D-1)
            if idx1 == idx2:
                continue
            if random.randint(0,1):
                ans[d1] = idx1
            else:
                ans[d1] = idx1
                ans[d2] = idx2
             
        #2値入れ替え
        elif random.randint(0,1):           
            d1 = random.randint(0,D-8) 
            d2 = random.randint(d1+1,d1+7)
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
            
        #3値入れ替え          
        else:
            d1 = random.randint(0,D-11) 
            d2 = random.randint(d1+1,d1+5)
            d3 = random.randint(d2+1,d2+5) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans = cp.copy()
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 10084
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  long long int N, A, B, bnum;
  
  scanf("%lld %lld %lld", &N, &A, &B);
  if (N % (A + B) >= A)
  {
    bnum = (N / (A + B) + 1) * A;
  }
  else
  {
    bnum = (N / (A + B)) * A + (N % (A + B));
  }
  printf("%lld\n", bnum);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i=0;i<n;i++)l[i]=sc.nextInt();
        Arrays.sort(l);
        long ans = 0;
        for (int i=0;i<n-2;i++){
            for (int j=i+1;j<n-1;j++){
                boolean b3 = true;
                for (int k=j+1;k<n&&b3;k++){
                    if (l[i]+l[j]<=l[k])b3=false;
                    if (l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j])ans++;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 39860
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);


#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
vector<vl> cm(1000000,vl());

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (((n*temp)%SIZE)*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main(){
    ll a,b;
    cin >>a>>b;
    ll sum = a+b;
    if(sum % 3 != 0 || a > 2 *b || b >2*a ){
        cout << 0;
        return 0;
    }
    ll hamle = sum/3;
    ll dif  ;
    if ( a < b)dif = b-a;
    else dif = a-b;
   // cout << dif<<endl;

    dif = dif + (hamle-dif)/2;
    ll res =1;
    //cout << dif<<"\n";
    for (ll i = 1; i <= hamle ; ++i) {
        res=(res*i)%1000000007;

    }

    ll div=1;
    for (ll j = 1; j <=dif ; ++j) {
        div=(div*j)%1000000007;
    }
    for (ll j = 1; j <=hamle-dif ; ++j) {
        div=(div*j)%1000000007;
    }
    ll nn=fast_exp(div,SIZE-2);
    cout << (res *nn)%SIZE;

    return 0;
}





Measured memory_bytes: 23680
import java.util.Scanner;

public class Main {
    public static long upperbound(long x, long y){
        if(x % y == 0)
            return x / y;
        else
            return x / y + 1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a, b;
        a = 1;
        b = 1;
        for(int i = 0; i < n; i++){
            long x = sc.nextLong();
            long y = sc.nextLong();
            long j = Math.max(upperbound(a, x), upperbound(b, y));
            a = x * j;
            b = y * j;
        }
        System.out.println(a + b);
    }
}


Measured memory_bytes: 25188
let inp = readLine()!.split(separator: " ").map { Int($0)! }

let n = inp[0]
let d = inp[1]

var count = 0

for _ in 0..<n {
  let inputs = readLine()!.split(separator: " ").map { Int($0)! }
  let x = inputs[0]
  let y = inputs[1]
  
  if x * x + y * y <= d * d {
    count += 1
  }
}

print(count)

Measured memory_bytes: 8260
n, max = gets.strip.split.map(&:to_i)
result = 0.0

n.times do |i|
  score = i + 1
  count = 0
  loop do
    break if score >= max
    score = score * 2
    count += 1
  end
  result += (1.0 / n * 0.5**count)
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll maxn = 2 * (1e5 + 5);

int main()
{
    ll i, j, k, m, n, t, u, v, p, a[50][102],b[50][102];

    cin>>n>>m;

    ll ans=0;

    ans = (m*(m-1))/2+((n*(n-1))/2);

    cout<<ans<<endl;
    



    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class CoinChangingProblem {
    public int count (int n, int[] coins) {
	int m = coins.length;
	int[] dp = new int[n+1];
	for (int i = 1; i <= n; i++) {
	    dp[i] = 50000;
	}

	for (int i = 0; i < m; i++) {
	    for (int j = coins[i]; j <= n; j++) {
		dp[j] = Math.min(dp[j], dp[j - coins[i]] + 1);
	    }
	}
	return dp[n];
    }
}

public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] input;
	input = scan.nextLine().split(" ");
	int n = Integer.parseInt(input[0]);
	int m = Integer.parseInt(input[1]);
	int[] coins = new int[m];
	input = scan.nextLine().split(" ");
	for (int i = 0; i < m; i++) {
	    coins[i] = Integer.parseInt(input[i]);
	}
	CoinChangingProblem problem = new CoinChangingProblem();
	System.out.println(problem.count(n, coins));
    }
}

Measured memory_bytes: 26652
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> s(n + 1);
	s[0] = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		s[i + 1] = s[i] + a;
	}

	map<ll, ll> mp;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		mp[(s[i - 1] - (i - 1)) % k]++;
		if(i - k >= 0) mp[(s[i - k] - (i - k)) % k]--;
		ans += mp[(s[i] - i) % k];
	}
	cout << ans << endl;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    vi v(n);
    REP(i,n) {
        cin >> v[i];
    }
    sort(RALL(v));
    REP(i,n) {
        if(i%2==0){
            ans += v[i];
        }else{
            sum += v[i];
        }
    }
    cout << ans - sum << endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int x, y;
  cin >> x >> y;
  rep(i, x) {
    int j = x - i;
    int c1 = i * 2 + j * 4;
    int c2 = i * 4 + j * 2;
    if (c1 == y || c2 == y) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vint l(N);
    REP(i,N) cin>>l[i];

    int ans=1e18;
    const int S_MAX=pow(4,N);
    REP(_S,S_MAX){
        int S=_S;
        int lA=0,lB=0,lC=0;
        int cost=0;
        REP(i,N){
            if(S%4==0){
                if(lA>0) cost+=10;
                lA+=l[i];
            }
            if(S%4==1){
                if(lB>0) cost+=10;
                lB+=l[i];
            }
            if(S%4==2){
                if(lC>0) cost+=10;
                lC+=l[i];
            }
            S/=4;
        }
        if(lA>0 and lB>0 and lC>0){
            cost+=abs(lA-A)+abs(lB-B)+abs(lC-C);
            ans=min(ans,cost);
        }
        
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

const int maxn = 200 * 1000 + 218;

int n;
ll partialSums[maxn];
ll rightSums[maxn];
ll leftSums[maxn];

ll PartialSum(int count) {
  return partialSums[count];
}

ll Compute(bool toTheRight, bool odd, int start, int count) {
  ll result = 0;
  ll sum = 0;

  if (!toTheRight) {
    sum = PartialSum(start) - PartialSum(start - count);
    ll weightedSum = rightSums[start] - rightSums[start - count];
    result = sum * (start + 1) - weightedSum;
  }

  if (toTheRight) {
    sum = PartialSum(start + count) - PartialSum(start);
    ll weightedSum = leftSums[n - start] - leftSums[n - start - count];
    result = sum * (n - start + 1) - weightedSum;
  }

  result *= 2;
  if (odd) {
    result -= sum;
  }
  return result;
}

ll Solve(vector<ll> a) {
  int n = a.size();

  for (int i = 0; i < n; ++i) {
    partialSums[i + 1] = partialSums[i] + a[i];
  }

  ll w = 0;
  for (int i = 0; i < n; ++i) {
    w++;
    rightSums[i + 1] = rightSums[i] + a[i] * w;
  }

  w = 0;
  for (int i = n - 1; i >= 0; --i) {
    w++;
    leftSums[n - i] = leftSums[n - i - 1] + a[i] * w;
  }

  ll result = 0;
  for (int k = 0; k + 1 <= n; ++k) {
    int r = n - k - 1;
    int l = k;
    if (r > l) continue;
    
    // Odd case:
    ll current = Compute(true, true, k + 1, r) + Compute(false, false, k, r - 1) + PartialSum(l - r + 1) * 2 * r;
    result = max(result, current);

    if (l == r) continue;
    // Even case:
    current = Compute(true, false, k + 1, r) + Compute(false, true, k, r) + PartialSum(l - r) * (2 * r + 1);
    result = max(result, current);
  }
  return result;
}

int main()
{
  ll l;
  cin >> l >> n;
  vector<ll> tmp(n + 1);
  for (int i = 1; i <= n; ++i) cin >> tmp[i];
  n++;
  tmp.push_back(l);

  vector<ll> a(n);
  for (int i = 0; i < n; ++i) a[i] = tmp[i + 1] - tmp[i];

  ll result = 0;
  result = max(result, Solve(a));
  reverse(a.begin(), a.end());
  result = max(result, Solve(a));

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 10852
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i=n-1; i>=0; i--){
        cin >> a[i];
    }
    for (int i=0; i<n; i++){
        cout << a[i];
        if(i!=n-1){
            cout << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3012
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int32_t main(){
    int n,k,a,b;
    cin>>n>>k;
    b=n%k;
    cout<<min(b,abs(k-b));
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char s[10+5];
    scanf("%s", s);
    int ans=753;
    for(int i=0; i<strlen(s)-2; i++){
        char cpy[3+3];
        strncpy(cpy, s+i, 3);
        // printf("%d\n", atoi(cpy));
        if(ans>abs(753-atoi(cpy)))ans=abs(753-atoi(cpy));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int main()
{ 
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    while((a>=b)||(b>=c)){
        // k == 0 終わり
        if(k==0){
            break;
        }
        
        // 操作
        if(a>=b){
            b*=2;
        }else if(b>=c){
            c*=2;
        }
        k--;
    }
    
    if((a<b)&&(b<c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int cnt[26];
signed main(){
	string w;
	cin>>w;
	rep(i,w.size()){
		cnt[w[i]-'a']++;
	}
	rep(i,26){
		if(cnt[i]%2==1){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}
		
		


Measured memory_bytes: 256
count = gets.chomp.to_i

insert = {}
ans = []

count.times {
  temp = gets.chomp.split(" ")
  if temp[0] == "insert"
    insert[temp[1]] = 0
    next
  end

  if insert.has_key?(temp[1])
    ans << "yes"
  else
    ans << "no"
  end
}

puts ans

Measured memory_bytes: 75948
n , k ,d = map(int,input().split())
n = abs(n)
if(n> k*d):
    print(n - k*d)
    
else:
    
    rem = n%d
    
    if((k - (n//d))%2==0):
        print(rem)
        
    else:
        print(abs(rem - d))
        

Measured memory_bytes: 9076
#include<iostream>
using namespace std;
int main()
{
    int sum=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        sum+=(s[i]-'0');
    }
    if(sum%9==0)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 3716
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()
	M := sc.i()
	K := sc.i()
	A := make([]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = sc.i() + A[i-1]
	}
	B := make([]int, M+1)
	for i := 1; i <= M; i++ {
		B[i] = sc.i() + B[i-1]
	}

	ans := 0
	j := M
	for i := 0; i <= N; i++ {
		if A[i] > K {
			break
		}
		for B[j] > K-A[i] {
			j--
		}
		if ans < i+j {
			ans = i + j
		}
	}

	fmt.Println(ans)

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 7824
using System;
class MainClass
{
	static void Main(string[] args)
	{
      string[] strArr = Console.ReadLine().Split(' ');
      int InitnumOfRow = int.Parse(strArr[0]);
      string strRow="";
      string strOut = "";
      for (int i = 0; i < InitnumOfRow; i++)
      {
        strRow = Console.ReadLine();
        strOut += (strRow + "\r\n"+ strRow + "\r\n");
      }
      Console.WriteLine(strOut);
	}
}

Measured memory_bytes: 13024
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
using ll = long long;

int main(){
  int X,N;
  cin >> X >> N;
  set<int> p;
  int temp;
  for(int i=0;i<N;i++){
    cin >> temp;
    p.insert(temp);
  }

  int ans=-10000;
  int dif=10000;
  for(int i=0;i<=101;i++){
    if(p.count(i)) continue;
    if(abs(X-i)<dif){
      dif=abs(X-i);
      ans=i;
    }
  }

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


Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
  int N=0,m=0,c=0,count=0;
  scanf("%d",&N);
  for(int i=1;i<=N;i++)
  {
   
    for(m=i;m!=0;++c)
    {
      m=m/10;
    }
    if(c%2!=0)
    {
      count++;
    }
    c=0;
  }
  printf("%d ",count);
  return 0;
  }
 

Measured memory_bytes: 3176
import sys
sys.setrecursionlimit(50000)

S = input()
S_len = len(S)

def dd(i):
  if i >= S_len: return True
  for ex in ("dream","dreamer","erase","eraser"):
    length = i + len(ex)
    if ex == S[i:length]:
      if dd(length): return True
  return False

print("YES" if dd(0) else "NO")


Measured memory_bytes: 18956
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	int n[1000] = {};
	for (auto i : s)n[i]++;
	for (int i = 0; i < 1000; i++) {
		if (n[i] && n[i] != 2) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long a, b;
  cin >> a >> b;
  long c = a*b;
  if(a == 1 || b == 1){
    cout << 1 << endl;
    return 0;
  }
  if(c%2 == 0){
    cout << c/2 << endl;
  }else{
    cout << c/2+1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans[500005];
ll x[500005],y[500005],z[100005];
ll dp[100],ma,mi;
char s[100005];

int main(){
	cin>>n;
	if(n%2==0){
		p(n);
	}else{
		p(2*n);
	}

	return 0;

}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)

using ll = long long;
using namespace std;

const int N = 2e5 + 100;
const int K = 5;

int dp[N][K];
char s[N];

bool same(int s1, int l1, int s2, int l2) {
	if (l1 != l2 || !s1) return false;
	for (int i = 0; i < l1; ++i)
		if (s[s1 + i] != s[s2 + i]) return false;
	return true;
}

int main() {
	scanf ("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 0; i < n; ++i)
		for (int k = 0; k < K; ++k) {
			if (i < k) continue;
			for (int j = 1; j < K; ++j)
				if (i + j <= n && !same(i - k + 1, k, i + 1, j))
					dp[i + j][j] = max(dp[i + j][j], dp[i][k] + 1);
		}
	int out = 0;
	for (int k = 0; k < K; ++k)
		out = max(out, dp[n][k]);
	printf("%d\n", out);
	
	return 0;
}


Measured memory_bytes: 7928
#include<stdio.h>
#define N 1000

int main(void){
  int n,i,j,v,u,key;
  int Adj[N][N];
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&v,&u);
    if(u!=0){
      for(j=1;j<=u;j++){
	scanf("%d",&key);
	Adj[v][key]=1;
      }
    } 
    else for(j=1;j<=n;j++){
	Adj[i][j]=0;
      }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",Adj[i][j]);
      if(j<n)printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 2684
m, k = map(int, input().split())
l = int(2 ** (m + 1))
p = 2 ** m
if m == 0 or m == 1:
    if k == 0:
        if m == 0:
            print('0 0')
        else:
            print('0 0 1 1')
    else:
        print('-1')
else:
    if k >= p:
        print('-1')
    else:
        ans = []
        tmp = list(range(p))
        tmp.remove(k)
        ans.extend(tmp)
        ans.append(k)
        ans.extend(list(reversed(tmp)))
        ans.append(k)
        print(*ans)


Measured memory_bytes: 56288
#include<stdio.h>
#define MAX 250
int parent(int);
int left(int);
int right(int);
int main(){
  int a[MAX+1],i,n;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: ",i);
    printf("key = %d, ",a[i]);
    if(parent(i)>=1)
      printf("parent key = %d, ",a[parent(i)]);
    if(left(i)<=n)
      printf("left key = %d, ",a[left(i)]);
    if(right(i)<=n)
      printf("right key = %d, ",a[right(i)]);
    printf("\n");
	}
  return 0;
}
int parent(int x){
  return x/2;
}

int left(int x){
  return 2*x;
}

int right(int x){
  return 2*x+1;
}



Measured memory_bytes: 2112
#include<vector>

std::vector<std::pair<long long, int>> get_prime_factors(long long n) {
    std::vector<std::pair<long long, int>> ret;
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back({i, 1});
            n /= i;
        }
        while (n % i == 0) {
            ret.back().second++;
            n /= i;
        }
    }
    if (n != 1) { ret.push_back({n, 1}); }
    return ret;
}

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n << ":";
    auto v = get_prime_factors(n);
    for (int i = 0; i < v.size(); i++) {
        auto p = v[i];
        for (int j = 0; j < p.second; j++) { cout << " " << p.first; }
    }
    cout << endl;
}


Measured memory_bytes: 3096
import heapq


def main():
    X, Y, Z = map(int, input().split())
    N = X+Y+Z
    P = [None] * N
    for i in range(N):
        A, B, C = map(int, input().split())
        P[i] = (A, B, C)
    P.sort(key=lambda x: x[0] - x[1])
    lsum = [0] * (Z+1)
    lsum[0] = sum(map(lambda x: x[1], P[:Y]))
    h = list(map(lambda x: x[1] - x[2], P[:Y]))
    heapq.heapify(h)
    for i in range(Z):
        heapq.heappush(h, P[Y+i][1] - P[Y+i][2])
        lsum[i+1] = lsum[i] - heapq.heappop(h) + P[Y+i][1]
    # print(lsum)
    rsum = [0] * (Z+1)
    rsum[0] = sum(map(lambda x: x[0], P[N-X:]))
    h = list(map(lambda x: x[0] - x[2], P[N-X:]))
    heapq.heapify(h)
    for i in range(Z):
        heapq.heappush(h, P[N-X-1-i][0] - P[N-X-1-i][2])
        rsum[i+1] = rsum[i] - heapq.heappop(h) + P[N-X-1-i][0]
    # print(rsum)
    ans = 0
    for i in range(Z+1):
        ans = max(lsum[i] + rsum[Z-i], ans)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84312
n = int(input())
H = [int(x) for x in input().split()]

INF = 10**20
dp = [INF] * n
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(1, n - 1):
    dp[i + 1] = min(dp[i] + abs(H[i + 1] - H[i]), dp[i - 1] + abs(H[i + 1] - H[i - 1]))

print(dp[n-1])

Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int result = 0;

		for(int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if (i * 500 + j * 100 + k * 50 == x) {
						result++;
					}
				}
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 23124