akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    set<string> Set;
    
    cin >> N;
    for (int n = 0; n < N; ++n) {
        string S;
        cin >> S;
        Set.emplace(S);
    }
    
    cout << Set.size() << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int d = 1;
	while (N--) {
		d = min(d * 2, d + K);
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    int p[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }

    int ans = 1;
    int tmp = p[0];
    for (int i = 1; i < n; i++){
        if (tmp >= p[i]){
            ans += 1;
            tmp = p[i];
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i<n;i++)
int main() {
  int  r, g, b;
  cin >> r >> g  >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0) {cout << "YES" << endl;}
  else {cout << "NO" << endl;}
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 1e2+9;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 998244353;

int n,m,t;


int main()
{
	scanf("%d%d%d",&n,&m,&t);
	int cnt = (0.5+t)/n;
	int ans = cnt*m;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
ans=0
for i in range(N):
    a=N//10**4
    b=N//10**3-10*a
    c=N//10**2-100*a-10*b
    d=N//10**1-1000*a-100*b-10*c
    e=N//10**0-10000*a-1000*b-100*c-10*d
    N=N-1
    if A<= a+b+c+d+e <=B:
     ans=ans+N+1


print(ans)


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

using namespace std;

void solve()
{
	string str;
	cin >> str;
	vector<string> data;
	bool eggFlag = false;
	bool chickenFlag = false;
	string temp = "";
	for (int i = 0; i < str.size(); ++i)
	{
		if (str[i] == 'e')
		{
			if (eggFlag)
			{
				data.push_back(temp);
				temp.clear();
			}
			else if (!eggFlag)
			{
				eggFlag = true;
				chickenFlag = false;
			}
			temp += "egg";
			i += 2;
		}
		else
		{
			if (chickenFlag)
			{
				data.push_back(temp);
				temp.clear();
			}
			else if (!chickenFlag)
			{
				eggFlag = false;
				chickenFlag = true;
			}
			temp += "chicken";
			i += 6;
		}
	}
	data.push_back(temp);
	int maxLen = 0;
	for (int i = 0; i < data.size(); ++i)
	{
		maxLen = max(maxLen, (int)data[i].size());
	}
	for (int i = 0; i < data.size(); ++i)
	{
		if (data[i].size() == maxLen)
		{
			if (data[i][data[i].size() - 1] == 'g')
			{
				cout << "egg" << endl;
			}
			else
			{
				cout << "chicken" << endl;
			}
			return;
		}
	}
}

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

Measured memory_bytes: 1224
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
counter=Counter(A)
sum_res=sum(A)
for i in range(Q):
  b,c=map(int,input().split())
  sum_res-=counter[b]*b
  sum_res+=counter[b]*c
  counter[c]+=counter[b]
  counter[b]=0
  print(sum_res)

Measured memory_bytes: 24168
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<ll> a(X),b(Y),c(Z);
  rep(i,X){
    cin >> a[i];
  }
  rep(i,Y){
    cin >> b[i];
  }
  rep(i,Z){
    cin >> c[i];
  }
  vector<ll> ab,ans;
  rep(i,X){
    rep(j,Y){
      ab.pb(a[i]+b[j]);
    }
  }
  sort(All(ab));
  for(ll i=0;i<K && i<X*Y;i++){
    for(ll j=0;j<K && j<Z;j++){
      ans.pb(ab[ab.size()-1-i]+c[Z-1-j]);
    }
  }
  sort(All(ans));
  for(ll i=0;i<K;i++){
    cout << ans[ans.size()-1-i] << endl;
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int n;
	cin >> n;
	
	for (int i = 0; i <= n; i += 4) {
		if ((n - i) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


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

void coinSort(int* coins, const int count);
int dp_coin(const int target, const int* coins, const int coinCount);

int main()
{
	int value;
	int coin_val;
	int i, ans;
	int* coins;
	
	scanf("%d %d", &value, &coin_val);
	coins = (int *)malloc(sizeof(int) * coin_val);
	
	for (i = 0; i < coin_val; ++i)
	{
		scanf("%d", &coins[i]);
	}
	
	coinSort(coins, coin_val);
	ans = dp_coin(value, coins, coin_val);
	
	printf("%d\n", ans);
	
  finallize:
	free(coins);
	return 0;
}

void coinSort(int* coins, const int count)
{
	int i, j, tmp_swap;
	
	for(i = count - 1; i >= 0; --i) {
		for(j = 0; j < i; ++j) {
			if(coins[j] > coins[j + 1]) {
				coins[j] =  coins[j] + coins[j + 1];
				coins[j + 1] = coins[j] - coins[j + 1];
				coins[j] = coins[j] - coins[j + 1];
			}
		}
	}
}
int dp_coin(const int target, const int* coins, const int coinCount)
{
	int currentValue;
	int mtx[target];
	int i;
	
	for(i = 0; i <= target; ++i) {
		mtx[i] = i;
	}
	
	for(i = 1; i < coinCount; ++i) {
		for(currentValue = 0; currentValue <= target - coins[i]; ++currentValue) {
			if (mtx[currentValue] + 1 < mtx[currentValue + coins[i]]) {
				mtx[currentValue + coins[i]] = mtx[currentValue] + 1;
			}
		}
	}
	
	return mtx[target];
}

Measured memory_bytes: 792
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 4010
string a, b;
int n, x[N], y[N], l[N], r[N], d[N];

ll solve(){
	rep(i, n) x[i] = a[i]-'0';
	rep(i, n) y[i] = b[i]-'0';
	{
		int p;
		rep(i, n) if(y[i]) p = i;
		p -= n;
		rep(i, n){
			if(y[i]) p = i;
			l[i] = p;
		}
		rep(i, n){
			if(y[i]){
				p = i;
				break;
			}
		}
		p += n;
		for(int i = n-1; i >= 0; i--){
			if(y[i]) p = i;
			r[i] = p;
		}
	}
	ll res = INF;
	rep(i, n+1){
		rep(j, n) if(y[j]) x[j] |= 2;
		ll rr = i;
		rep(j, n) rr += (x[j]%2!=y[j]);
		mset(d, 0);
		rep(j, n){
			if(x[j]%2!=y[j] && !(x[j]&2)){
				int k = j-l[j], v = r[j]-j-i;
				d[k-1] = max(d[k-1], v);
			}
		}
		for(int j = n-1; j >= 0; j--) d[j] = max(d[j], d[j+1]);
		int rrr = INF;
		rep(j, n) rrr = min(rrr, d[j]+j);
		rr += 2*rrr;
		res = min(res, rr);

		x[n] = x[0];
		rep(j, n) x[j] = x[j+1];
	}
	return res;
}

int main(){
	cin>>a>>b;
	n = a.size();
	if(a==b){
		cout<<0<<endl;
		return 0;
	} else if(b==string(n, '0')){
		cout<<-1<<endl;
		return 0;
	}
	ll res = INF;
	res = min(res, solve());
	reverse(all(a)); reverse(all(b));
	res = min(res, solve());
	cout<<(res==INF?-1:res)<<endl;
	return 0;
}


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

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

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  
  int cnt = 0;
  for (int i=0; i<n; i++) {
    if (a.at(i) >= (double)sum/(4*(double)m)) cnt++;
  }
  if (cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define ll long long int
#define uul unsigned long long int
#define ui uint64_t
#define max(a,b) (a>b)?a:b
#define min(a,b) (a<b)?a:b
#define ma 1000000007

int main()
{


    ll n,i,j,k,s=0;
    cin>>n;
    ll l[n+5];
    for(i=0;i<n;i++)
    {
        cin>>l[i];
    }
    sort(l,l+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if( (l[i]<(l[j]+l[k])) && (l[j]<(l[i]+l[k])) && (l[k]<(l[j]+l[i])))
                    s++;
                else
                {
                    break;
                }
                
            }
        }
    }
    cout<<s<<endl;
    return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;
int main(){
    int n,m,L=0,R=pow(10,5)+1,tmpL,tmpR;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        cin>>tmpL>>tmpR;
        if(tmpL>R){
            cout<<"0"<<endl;
            return 0;
        }
        if(tmpR<L){
            cout<<"0"<<endl;
            return 0;
        }
        if(tmpL>L){
            L=tmpL;
        }
        if(tmpR<R){
            R=tmpR;
        }
        //cout<<L<<" "<<R<<endl;        
    }
    cout<<R-L+1<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll mod = 998244353;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define S second
#define F first
#define M_PI 3.14159265358979323846

ll sqr(ll n) {
	return n*n;
}

ll gcd(ll a, ll b) {
	while(b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

bool prime(int n) {
	int i = 2;
	while (i*i <= n) {
		if (n % i == 0) return false;
		i++;
	}
	return true;
}
ll binpow(ll a, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 != 0) return binpow(a, n-1)*a; else {
		ll b = binpow(a, n/2);
		return b*b;
	}
}

void solve() {
	int n, x;
	cin >> n;
	vector<int> ans(n+1);

	for (int i = 0; i < n-1; i++) {
		cin >> x;
		ans[x]++;
	}

	for (int i = 1; i <= n; i++)
		cout << ans[i] << endl;
}
 
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

	return 0;
}

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

int main(int argc, char const *argv[])
{
	ll n; cin >> n;
	rep(i, 1000000) {
		if (i * i > n) {
			printf("%d\n", (i - 1) * (i - 1));
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],ans;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(&a[1],&a[n+1]);reverse(&a[1],&a[n+1]);
	for(int i=1;i<=n;++i)
		if(i+1>a[i+1])
		{
			for(int j=i+1;a[j]==i;++j)ans^=1;
			ans|=(a[i]-i)&1;
			ans?puts("First"):puts("Second");
			return 0;
		}
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
#define NIL -1

struct Node{int parent,left,right;};

struct Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2 ? h1:h2);
}


int getSibling(int u){
  if(T[u].parent==NIL)return NIL;
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL)
    return T[T[u].parent].left;
   if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL)
      return T[T[u].parent].right;
   return NIL;
}

void print(int u){
  int deg=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left!=NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL){
    printf("root\n");
  }else if(T[u].left==NIL && T[u].right==NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++)T[i].parent=NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL)T[l].parent=v;
    if(r!=NIL)T[r].parent=v;
  }

  for(i=0;i<n;i++)if(T[i].parent==NIL)root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)print(i);

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int dp[3005][3005],n,q,val[3005],now[3005][3005],inv2;
int qpow(int x,int y)
{
	int res=1;
	while(y)
	{
		if(y&1)res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}
signed main()
{
	inv2=qpow(2,mod-2);
	scanf("%lld%lld",&n,&q);
	for(int i=1;i<=n;++i)scanf("%lld",&val[i]);
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			dp[i][j]=(val[i]<val[j]?1:0);
		}
	}
	int mx=qpow(2,q);
	while(q--)
	{
		int x,y;
		scanf("%lld%lld",&x,&y);
		for(int i=1;i<=n;++i)
		{
			now[x][i]=(dp[x][i]+dp[y][i])%mod*inv2%mod;
			now[i][x]=(dp[i][x]+dp[i][y])%mod*inv2%mod;
			now[y][i]=now[x][i];
			now[i][y]=now[i][x];
		}
		now[x][y]=now[y][x]=(dp[x][y]+dp[y][x])*inv2%mod;
		for(int i=1;i<=n;++i)
    {
			dp[x][i]=now[x][i];dp[i][x]=now[i][x];
			dp[y][i]=now[y][i];dp[i][y]=now[i][y];
		}
		swap(val[x],val[y]);
	}
	int res=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			res+=mx*dp[j][i]%mod;
			if(res>=mod)res-=mod;
		}
	}
	cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 141312
#include <iostream>

using namespace std;

int main() {
	unsigned long long int x;
	cin >> x;
	
	long long int result;
	if (x % 11 == 0) {
		result = (x / 11)*2;
	} else if (x % 11 <= 6) {
		result = (x / 11)*2 + 1;
	} else {
		result = (x / 11)*2 + 2;
	}
	
	cout << result;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    multiset<int> colors;
    for (auto a : A) {
        auto it = colors.lower_bound(a);
        if (it != colors.begin()) {
            --it;
            colors.erase(it);
        }
        colors.insert(a);
    }
    cout << colors.size() << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <cstdio>
using namespace std;
int main(){
  int n, p[31] = {0}, i, res;
  p[0] = 1;
  p[1] = 1;
  p[2] = 2;
 
 
  while(scanf("%d", &n) && n){
    for(i=3;i<=n;i++)
      p[i] = p[i-1]+p[i-2]+p[i-3];
    res=(p[n]+3649)/3650;
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 2612
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	string s;
	cin >> s;

	vector<int> a;
	char prev = -1;

	each(c, s) {
		if (prev != c) {
			if (c == 'W') {
				a.push_back(0);
			}else{
				a.push_back(1);
			}
		}
		prev = c;
	}

	cout << a.size() - 1 << endl;

	
	return 0;
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,temp,pal,counter=0;
  cin >> A >> B;
  int i,j;
  for(i=A;i<=B;i++){
    temp = i;
    pal = 0;
    for(j=4;j>=0;j--){
      pal += (temp%10)*pow(10,j);
      temp /= 10;
    }
    if(pal == i){
      counter++;
    }
  }
  cout << counter << endl;
}
  

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

int main()
{
    int x,n;
    vector<bool> p(200, false);
    cin >> x >> n;
    for (size_t i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        p[input] = true;
    }
    if (!p[x])
    {
        cout << x << endl;
    }
    else
    {
        for (size_t i = 1; i < 200; i++)
        {
            if (!p[x-i])
            {
                cout << x-i << endl;
                break;
            }
            else if (!p[x+i])
            {
                cout << x+i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int ans=a[0];
    for(int i=1;i<n;i++){
        ans+=max(0,a[i]-a[i-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();

		StringTokenizer st = new StringTokenizer(str," ");

		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		if (a < b && b < c) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24088
X,N = map(int, input().split())
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y

P = intlist(input().split())

if X not in P:
    print(X)
else:

    for i in range(N):
        if X-i-1 not in P:
            print(X-i-1)
            break
        if X+i+1 not in P:
            print(X+i+1)
            break

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

const int N = 100 + 20;
int n, a[N], ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			for (int k = j + 1; k < n; k++)
				if (a[i] < a[j] && a[k] > a[j] && a[i] + a[j] > a[k])
					ans++;
	cout << ans << "\n";
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n;
int a[2005],vis[2005];
int gcd(int a, int b){
    return a == 0 ? b:gcd(b%a,a);
}
vector<int> dfs(int u){
    vector<vector<int> > pos;
    for (int i = 1; i <= n; i++){
        if ((a[i] == 1 || gcd(a[u],a[i]) != 1) && vis[i] == 0){
            //printf("%d -> %d: gcd(%d,%d) is %d\n",u,i,a[i],a[u],gcd(a[i],a[u]));
            vis[i] = 1;
            pos.push_back(dfs(i));
        }
    }
    int NUM = pos.size();
    int ct[NUM];
    memset(ct,0,sizeof(ct));
    priority_queue<ii> pq;
    for (int i = 0; i < NUM; i++){
        pq.push({pos[i][0],i});
    }
    vector<int> ans;
    if (u != 0) ans.push_back(a[u]);
    while (pq.size()){
        ii cur = pq.top(); pq.pop();
        ans.push_back(cur.first);
        int id = cur.second;
        if (ct[id] != pos[id].size()-1){
            pq.push({pos[id][++ct[id]],id});
        }
    }
    return ans;
}
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for (auto x : dfs(0)) printf("%d ",x);

}


Measured memory_bytes: 768
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push_back


#define MOD 1000000009LL
#define EPS 1e-8

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if(b-a==c-b){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}


    return 0;
}

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

int main(void){
    int N,M; cin >> N >> M;
    vector<string> A(N),B(M);
    for(int i = 0; i < N; i++)cin >> A[i];
    for(int j = 0; j < M; j++)cin >> B[j];
    
    
    for(int i = 0; i <= N - M ; i++){
        for(int j = 0; j <= N - M ; j++){
           
           bool ok = true;
           
           for(int a = 0; a < M; a++){
               for(int b = 0; b < M; b++){
                   if(A[i+a][j+b]!=B[a][b])ok = false;
               }
           } 
           
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }    
        }
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3644
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
ans = "A"
for l in range(len(N)):
    c = N[l].split(",")
    if c[0] == ans:
        ans = c[1]
    elif c[1] == ans:
        ans = c[0]
print(ans)



Measured memory_bytes: 5564
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
		cin >> H[i];
	bool ans = true;
	for (int i = 0; i < N-1; i++)
	{
		if (H[i] <= H[i+1])
			continue ;
		else if (H[i]-1 <= H[i+1])
			H[i+1]++;
		else
			ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 640
n,q = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n-1)]
px = [list(map(int,input().split())) for i in range(q)]

child = [[] for _ in range(n)]
for a,b in ab:
    a -= 1
    b -= 1
    child[a].append(b)
    child[b].append(a)
# print(child)

p_val = [0] * n
for p,x in px:
    p_val[p-1] += x

ans = [p_val[0]]+[0]*(n-1)
stack = [0]
visited = [0] * n
while stack:
    s = stack.pop()
    visited[s] = 1
    for c in child[s]:
        if visited[c]:
            continue
        stack+=[c]
        ans[c] = ans[s]+p_val[c]
print(*ans)



Measured memory_bytes: 125700
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

ll i, j, q;
ll n, m, p, k, t, s, v;
ll a, b, c, d;
ll x, y, z, l, r;
ll one = 1, zero = 0, ans = 0;
ll mod = 1000000007;
ll ii;
ll INF = 223372036854775807;
ll ln1, ln2, lnc;
ll a1, a2, a3, a4, a5, a6, a7, a8, a9;
string st1, st2, st3;
char ch1, ch2, ch3;

int main() {
	int t;
	ifstream fin("Text.txt");

	cin >> n;
	map<ll, ll>vc;
	f0(i, n) {
		cin >> a;
		vc[a] = 1;
		a1 = max(a1, a);
	}
	map<ll, ll>::iterator it,it2,it3;
	a2 = vc[a1 / 2];
	if (a2) {
		cout << a1 << " " << (a1 / 2) << endl;
	}
	else {
		it = vc.find(a1 / 2);
		it2 = it;
		it3 = it;
		it3++;
		while (it3 != vc.end() && !it3->second)
			it3++;
		while (it2 != vc.begin() && !it2->second) {
			it2--;
		}
		if (it3 == vc.end()) {
			it3 = it;
		}
		cout << a1 << " " << ( a1 - it3->first > it2->first ? it3->first : it2->first);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_N = 1000;
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

int W, H, N;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
bool fld[MAX_N * 2 + 6][MAX_N * 2 + 6];

int compress(int *x1, int *x2, int w)
{
  vector<int> xs;

  for (int i = 0; i < N; i++) {
    xs.push_back(x1[i]);
    if (0 <= x1[i] - 1) xs.push_back(x1[i] - 1);
    xs.push_back(x2[i] - 1);
    if (x2[i] < w) xs.push_back(x2[i]);
  }

  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());

  for (int i = 0; i < N; i++) {
    x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
    x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
  }

  return xs.size();
}

void solve()
{
  W = compress(X1, X2, W);
  H = compress(Y1, Y2, H);

  memset(fld, false, sizeof fld);
  for (int i = 0; i < N; i++) {
    for (int y = Y1[i]; y < Y2[i]; y++) {
      for (int x = X1[i]; x < X2[i]; x++) {
        fld[y][x] = true;
      }
    }
  }

  // for (int y = 0; y < H; y++) {
  //   for (int x = 0; x < W; x++) {
  //     printf("%s", fld[y][x] ? "#" : ".");
  //   }
  //   printf("\n");
  // }

  int ans = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (fld[y][x]) continue;

      ans++;

      queue<pair<int, int> > que;
      que.push(make_pair(x, y));

      while (!que.empty()) {
        int sx = que.front().first, sy = que.front().second;
        que.pop();

        for (int i = 0; i < 4; i++) {
          int tx = sx + dx[i], ty = sy + dy[i];

          if (tx < 0 || W <= tx || ty < 0 || H <= ty) continue;
          if (fld[ty][tx]) continue;

          que.push(make_pair(tx, ty));
          fld[ty][tx] = true;
        }
      }
    }
  }

  printf("%d\n", ans);
}

int main()
{
  while (true) {
    scanf("%d%d", &W, &H);
    if (W == 0 && H == 0) break;

    scanf("%d", &N);

    for (int i = 0; i < N; i++) {
      scanf("%d%d%d%d", X1 + i, Y1 + i, X2 + i, Y2 + i);
    }

    solve();
  }
  return 0;
}


Measured memory_bytes: 6632
import decimal
n = int(input())

cum = [[0]*50 for i in range(50)]

l = []
for i in range(n):
    x = decimal.Decimal(input())
    x *= 10**9
    x = int(x)
    
    two = 0
    while x%2 == 0:
        x //= 2
        two += 1
    five = 0
    while x%5 == 0:
        x //= 5
        five += 1
    cum[two][five] += 1
    l.append((two,five))

for i in range(48,-1,-1):
    for j in range(48,-1,-1):
        cum[i][j] += cum[i][j+1]+cum[i+1][j]-cum[i+1][j+1]

ans = 0
for i,j in l:
    x = max(18-i,0)
    y = max(18-j,0)
    if x <= i and y <= j:
        ans += cum[x][y]-1
    else:
        ans += cum[x][y]
print(ans//2)

Measured memory_bytes: 24272
import java.util.Scanner;

public class Main{
	
    public static void main(String[] agrs){
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        int c = cin.nextInt();
        System.out.println(a + b >= c ? "Yes" : "No");
    }
    
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ABetweenTwoIntegers {
public:
	void solve(istream& in, ostream& out) {
        int a, b, c;
        in >> a >> b >> c;
        if(a <= c && c <= b) out << "Yes" << endl;
        else out << "No" << endl;
	}
};

int main() {
	ABetweenTwoIntegers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,1,n) cin>>ara[i];

	m=ara[1];

	while(true)
    {
        if(!arr[m]){
            arr[m]=1;
            count++;
            if(arr[2]) break;
            m=ara[m];
        }
        else{
            cout<<"-1"<<endl,exit(0);
        }

    }

    cout<<count<<endl;

}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt();
    int ans = -1;
    for (int i=A; i<B*100+1; i++){
       if ((int)(i*0.08) == A && (int)(i*0.1) == B) {
         ans = i;
         break;
       }
    }
    System.out.println(ans);
  }
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

/* 二項係数 C(n,k) mod p を計算 */
const int MAX = 100010;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  string s;
  cin >> s;

  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  FOR(j, 1, N+1){
    dp[1][j] = 1;
  }

  vector<vector<ll>> sum(N+1, vector<ll>(N+1, 0));
  FOR(j, 1, N+1){
    sum[1][j] = j;
  }

  FOR(i, 2, N+1){
    FOR(j, 1, N-i+2){
      if ( s[i-2] == '<'){
        dp[i][j] = sum[i-1][j] % MOD;
      }else{
        dp[i][j] = (sum[i-1][N-i+2] - sum[i-1][j] +  MOD) %MOD;
        dp[i][j] %= MOD;
      }
      sum[i][j] = sum[i][j-1] + dp[i][j] % MOD;
      sum[i][j] %= MOD; 
    }
  }

  cout << dp[N][1]%MOD << endl;
}

Measured memory_bytes: 141184
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static long [][]dp;
	static int H, W;
	static int []bit;
	static List<int []> list = new ArrayList<int []>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		if(W == 1) {
			if(K == 1) {
				System.out.println(1);
			}else {
				System.out.println(0);
			}
			System.exit(0);
		}
		long mod = 1000000007;
		dp = new long[H + 1][W];
		dp[0][0] = 1;
		bit = new int[W - 1];
		rec(0);
		int l = list.size();
		for(int i = 1; i <= H; i++) {
			for(int j = 0; j < l; j++) {
				int []b = list.get(j);
				long []c = swap(dp[i - 1], b);
				for(int k = 0; k < W; k++) {
					dp[i][k] += c[k];
					dp[i][k] %= mod;
				}
			}
		}
		System.out.println(dp[H][K - 1]);
//		for(int i = 0; i <= H; i++) {
//			for(int j = 0; j < W; j++) {
//				System.out.print(dp[i][j] + " ");
//			}
//			System.out.println();
//		}
//		for(int i = 0; i < l; i++) {
//			int []b = list.get(i);
//			for(int j : b) {
//				System.out.printf("%d ", j);
//			}
//			System.out.println();
//		}
	}
	static void disp(long []a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
	static long[] swap(long []a, int []b) {
		long []c = new long[W];
		System.arraycopy(a, 0, c, 0, W);
		for(int i = 0; i < W - 1; i++) {
			if(b[i] == 1) {
				c[i] = a[i + 1];
				c[i + 1] = a[i];
			}
		}
		return c;
	}
	static void rec(int k) {
        if(k == bit.length) {
        	addBit();
            return;
        }
        rec(k + 1);
        bit[k] = 1;
        rec(k + 1);
        bit[k] = 0;
    }
	static void addBit() {
		int l = bit.length;
		for(int i = 1; i < l; i++) {
			if(bit[i - 1] == 1 && bit[i] == 1) {
				return;
			}
		}
		int []vBit = new int[l];
		System.arraycopy(bit, 0, vBit, 0, l);
		list.add(vBit);
		return;
	}
}

Measured memory_bytes: 23764
A = input()

for i in range(1 << len(A) - 1):
    ans_number = int(A[0])
    ans_sentense = A[0]
    for j in range(len(A) - 1):
        if ((i >> j)& 1) == 1:
            ans_number += int(A[j + 1])
            ans_sentense += "+" + A[j + 1]
        else:
            ans_number -= int(A[j + 1])
            ans_sentense += "-" + A[j + 1]
    if ans_number == 7:
        break
print(ans_sentense + "=7")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		if(a+b>=10) {
			System.out.println("error");
		}else {
			System.out.println(a+b);
		}

	}

}


Measured memory_bytes: 21200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
ll dp[(1<<18)+5][3];
ll a[maxn];
int n;
void init()
{
    for(int i = 1; i < (1<<n); ++i)
    {
        //cout<<a[i]<<endl;
        if(a[i] >= a[0])
         {
             dp[i][1] = i;
             dp[i][0] = 0;
         }
         else
         {
             dp[i][1] = 0;
             dp[i][0] = i;
         }
    }
}
int main()
{
     while(cin>>n)
     {
         for(int i = 0; i < (1<<n); ++i)
                scanf("%lld",a+i);

         init();
         int cnt = 2;
         for(int i = 2; i < (1<<n); ++i)
         {
             if(cnt == i){cnt *= 2; continue;}
             for(int j = 0; (1<<j) < i; ++j)
             {
                 int res = (1<<j);
                 if(res & i)
                 {
                     if(dp[i][1] == dp[i^res][1])
                     {
                         if(a[dp[i][0]] < a[dp[i^res][0]])
                            dp[i][0] = dp[i^res][0];
                     }
                     else
                     {
                         if(a[dp[i][1]] > a[dp[i^res][1]])
                         {
                             if(a[dp[i][0]] < a[dp[i^res][1]])
                                dp[i][0] = dp[i^res][1];
                         }
                         else
                         {
                             if(a[dp[i][1]] > a[dp[i^res][0]])
                             {
                                 dp[i][0] = dp[i][1];
                             }
                             else
                                dp[i][0] = dp[i^res][0];
                             dp[i][1] = dp[i^res][1];
                         }
                     }
                 }
             }
         }
             ll pre = 0;
         for(int i = 1; i < (1<<n); ++i)
         {
             //cout<<dp[i][1]<<"   "<<dp[i][0]<<endl;
             pre = max(pre,a[dp[i][1]] + a[dp[i][0]]);
             printf("%lld\n",pre);
         }

     }
}
















Measured memory_bytes: 14976
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i <= n-2 and a[i]+1 == a[i+1]:
        ans += c[a[i]-1]
print(ans)



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

int main()
{
	string s,t,s1;
	int ans=-1000;
	cin>>s>>t;
	if (t.size()>s.size())
	{
		cout <<"UNRESTORABLE";
		return 0;
	}
	for(int j=0;j<s.size()-t.size()+1;j++)
	{
		int f=0;
		s1=s.substr(j,t.size());
		for(int i=0;i<t.size();i++)
		{
			if(s1[i]!=t[i])
			f=1;
		}
		if(f==0)
		{
			for(int i=0;i<s.size();i++)
			{
				if(s[i]=='?') s[i]='a';
			}
			cout<<s;
			return 0;
		}
	}
	for(int i=s.size()-t.size();i>=0;i--)
	{
		int F=1;
		if(t[0]==s[i]||s[i]=='?')
		{
			F=0;
			for(int j=i;j<i+t.size();j++)
			{
				if(!(s[j]==t[j-i]||s[j]=='?'))
				{
					F=1;
					break;
				}	
			}
		}
		if(F==0)
		{
			ans=i;
			break;
		}
	}
	if(ans==-1000)
	{
		cout<<"UNRESTORABLE";
		return 0;
	}
	for(int i=ans;i<ans+t.size();i++)
	{
		s[i]=t[i-ans];
	}
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='?') s[i]='a';
	}
	cout<<s;
	return 0;
}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N, M;
    cin >> N >> M;
    priority_queue<double> val;
    rep(i, N){
        double a;
        cin >> a;
        val.push(a);
    }
    rep(i, M){
        double op = val.top();
        val.pop();
        op /= 2;
        //cout << op << endl;
        val.push(op);
    }
    ll ans = 0;
    while(!val.empty()){
        ans += (ll) val.top();
        val.pop();
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 1400
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

std::vector<std::string> solve(long n, const std::vector<std::string>& strings)
{
  std::vector<std::string> result;
  std::map<std::string, long> map;
  long max = 0;
  for (const auto& s : strings) {
    auto it = map.lower_bound(s);
    if (it == map.end() || it->first != s) {
      it = map.insert(it, std::make_pair(s, 0));
    } else {
      it->second += 1;
    }
    max = std::max(max, it->second);
  }
  for (const auto& p : map) {
    if (p.second == max) result.push_back(p.first);
  }
  return result;
}

int main()
{
  long n;
  std::cin >> n;
  std::vector<std::string> strings(n);
  for (auto& s : strings) {
    std::cin >> s;
  }

  const auto vv = solve(n, strings);
  std::cout << std::setprecision(20);
  for (auto& v : vv) {
    std::cout << v << std::endl;
  }
}


Measured memory_bytes: 29300