akhauriyash/Code-Regression huggingface dataset:
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int n, k, c;
string s;
int l[N], r[N];

int main(){
    Speedforce
    //fop("", "")
    cin >> n >> k >> c;
    cin >> s;
    int cnt1 = 0, cnt2 = 1;
    for(int i = 0;cnt2 <= k && i < n;i ++){
        if(!cnt1 && s[i] == 'o'){
            l[cnt2] = i;
            cnt1 = c;
            cnt2 ++;
            continue;
        }
        cnt1 = max(0, cnt1 - 1);
    }
    cnt1 = 0, cnt2 = k;
    for(int i = n - 1;cnt2 && i >= 0;i --){
        if(!cnt1 && s[i] == 'o'){
            r[cnt2] = i;
            cnt1 = c;
            cnt2 --;
            continue;
        }
        cnt1 = max(0, cnt1 - 1);
    }
    vector <int> ans;
    for(int i = 1;i <= k;i ++){
        //cout << l[i] << " " << r[i] << endl;
        if(l[i] == r[i]){
            ans.pb(l[i]);
        }
    }
    for(int i = 0;i < ans.size();i ++){
        cout << ans[i] + 1 << "\n";
    }
}


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

int main()
{
    string s;
    int sum = 0;
    cin >> s;
    for(int i=0; i<s.length(); i++)
    {
        sum = sum + (s[i] - '0');
    }
    if(sum%9 == 0)
    {
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3704
#include<stdio.h>
#define MAX 100000 /* 最大値を定義 */
#define SENTINEL 2000000000
/*カードの構造体の宣言*/
struct Card{
char suit;
int value;
};

struct Card LEFT[MAX/2+2],RIGHT[MAX/2+2];

void merge(struct Card A[], int n, int left,int mid,int right){
int i,j,k;//適当な変数を用意
int n1= mid-left;//真ん中ー左端
int n2=right-mid;//右側ー中央
for(i=0;i<n1;i++) LEFT[i]=A[left+i];//左側の配列
for(i=0;i<n2;i++) RIGHT[i]=A[mid+i];//右側の配列
LEFT[n1].value=RIGHT[n2].value=SENTINEL;
i=j=0;
//左側から右側までの処理をする
for(k=left;k<right;k++){
//左右の数値を比較する
if(LEFT[i].value<=RIGHT[j].value){
A[k]=LEFT[i++];}
else{
A[k]=RIGHT[j++];
}
}
}

void mergesort(struct Card A[],int n,int left,int right){
int mid;//真ん中の部分の処理をする(中央値）
if(left+1<right){
mid =(left+right)/2;
mergesort(A,n,left,mid);
mergesort(A,n,mid,right);//右と左を分けて考える
merge(A,n,left,mid,right);
}
}

//前後2つの部分配列の処理をする
int partition(struct Card A[],int n,int p,int r){
int i,j;//さっきの変数i、jの処理をする
struct Card t,x;//構造体の変数t,xを宣言
x =A[r];
i=p-1;
for(j=p;j<r;j++){
if(A[j].value<= x.value){//xの値とj番目の数値の比較
i++;
//入れ替えにつての処理する
t=A[i];A[i]=A[j];A[j]=t;
}
}
//i+1とr番目の順序を入れ替える
t=A[i+1];A[i+1]=A[r];A[r]=t;
return i+1;
}

void quicksort(struct Card A[],int n,int p,int r){
int m;
if(p<r){
m=partition(A,n,p,r);
quicksort(A,n,p,m-1);
quicksort(A,n,m+1,r);
}
}

//実装させるためのメインメソッド
int main(){
int n,i,v;
struct Card A[MAX],B[MAX];
char S[10];
int stable =1;//安定か否か判定するstable
scanf("%d",&n);
for(i=0;i<n;i++){//n番目の要素までをfor文で回す
scanf("%s %d",S,&v);
A[i].suit=B[i].suit=S[0];
A[i].value=B[i].value=v;
}
mergesort(A,n,0,n);
quicksort(B,n,0,n-1);
for(i=0;i<n;i++){
//マージソートとクイックソートの結果を調べる
if(A[i].suit != B[i].suit)
stable=0;//一致していないときは0とする
}
if(stable==1) printf("Stable\n");
else printf("Not stable\n");
for(i=0;i<n;i++){
printf("%c %d\n",B[i].suit,B[i].value);
}
return 0;
}


Measured memory_bytes: 4080
N = int(input())
nums = input().split(" ")
a = [0]
for i in range(1, N+1):
    a.append(int(nums[i-1]))

b = [0 for i in range(N+1)]
multiple_list = [[] for i in range(N+1)]
for i in range(1,N+1):
    for j in range(i, N+1, i):
        multiple_list[j].append(i)

count = 0
for i in range(N, 0, -1):
    if a[i] == 1:
        b[i] = 1
        count+=1
        for num in multiple_list[i]:
            a[num] = 1 - a[num]

print(count)
for i in range(1,N+1):
    if b[i] == 1:
        print(i, end=" ")
if count != 0:
    print()


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

int main(){
	
	int m,d;
	string week[7]={
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday"
	};
	int month[13]={
		-1,3,6,0,3,5,1,3,6,2,4,0,2
	};
	while(cin>>m>>d,m){
		cout<<week[(month[m]+d)%7]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1192
#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,i,factorial;
    factorial=1;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        factorial=factorial*i;


    }
    printf("%lld\n",factorial);
    return 0;

}

Measured memory_bytes: 596
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	string s; cin >> s;
	int n = SZ(s);

	bool is_removable = false;

	for (int i = 0; i + 2 < n; i += 2)
	{
		if (s[i] != s[i + 2])
		{
			is_removable = true;
			break;
		}
	}

	if (!is_removable)
	{
		for (int i = 1; i + 2 < n; i += 2)
		{
			if (s[i] != s[i + 2])
			{
				is_removable = true;
				break;
			}
		}
	}

	if (!is_removable)
		cout << "Second" << endl;

	else
	{
		int rm;
		if (s.front() == s.back())
			rm = n - 3;
		else
			rm = n - 2;

		if (rm & 1)
			cout << "First" << endl;
		else
			cout << "Second" << endl;
	}
}


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

int main()
{
    int n;
    cin >> n;
    int a[100001];
    int s = 0,ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    while(s<n){
        int c = a[s];
        int f = 0;
        while(s < n && a[s] == c){
            s++;
            f++;
        }
        ans += f % 2;
    }
    cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    if(N%10==7 || (N%100)/10==7 || N/100==7) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }

const int INF = 1000000000;
char maze[50][51];
int sx,sy;
int gx,gy;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int d[60][60];
int h,w;

int bfs(){
    rep(i,0,h) rep(j,0,w) d[i][j]=INF;
    queue<P> que;
    d[sx][sy]=0;
    que.push(P(sx,sy));

    while(que.size()){
        P p=que.front(); que.pop();
        if(p.first==gx&&p.second==gy) break;
        rep(i,0,4){
            int nx=p.first+dx[i], ny=p.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&d[nx][ny]==INF&&maze[nx][ny]!='#'){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gx][gy];
}
 

int main() {
    cin>>h>>w;
    int white=0,black=0;
    rep(i,0,h) rep(j,0,w){
        cin>>maze[i][j];
        if(maze[i][j]=='.') white++;
        else black++;
    } 
    sx=0,sy=0,gx=h-1,gy=w-1;
    int ans=bfs();
    //cout<<black<<" "<<white<<" "<<ans<<endl;
    if(ans==INF) cout<<-1<<endl;
    else cout<<white-ans-1<<endl;

 /*   rep(i,0,h){
        rep(j,0,w){
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }
*/
}

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

using namespace std;

int main() {
  int h[10];
  for (int i=0;i<10;i++) scanf("%d", &h[i]);
  sort(h, h+10);
  for (int i=0;i<3;i++) printf("%d\n", h[10-i-1]);
  return 0;
}

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

int main(){
    int cnt=0;
    string W;
    string T;
    cin >> W;
    transform (W.begin (), W.end (), W.begin (), ::toupper);
    while(1){
        cin >> T;
        if(T == "END_OF_TEXT")
            break;
        transform (T.begin (), T.end (), T.begin (), ::toupper);
        if (W==T)
            cnt++;    
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int x = i, sum = 0;
        while (x) {
            sum++;
            x /= 10;
        }
        if (sum % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vector<double> p(N+1, 0);
  for(int i = 1; i <= N; i++){
    cin >> p.at(i);
  }

  vector<vector<double>> dp(N+1, vector<double>(N+1, 0));
  dp.at(1).at(0) = 1 - p.at(1);
  dp.at(1).at(1) = p.at(1);
  for(int i = 2; i <= N; i++){
    for(int j = 0; j <= i; j++){
      dp.at(i).at(j) += dp.at(i-1).at(j)*(1-p.at(i));
      if(j >= 1) dp.at(i).at(j) += dp.at(i-1).at(j-1) * p.at(i);
    }
  }

  cout << fixed << setprecision(10);
  double result = 0;
  for(int i = N/2+1; i <= N; i++){
    result += dp.at(N).at(i);
  }
  cout << result << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    char s;cin >> s;
    if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o'){
        COUT("vowel");
    }else{
        COUT("consonant");
    }
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
w, v = [0]*(N+1), [0]*(N+1)
for i in range(N):
  w[i+1], v[i+1] = map(int, input().split())
  
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1,N+1):
  for j in range(1,W+1):
    if j < w[i]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j])
print(dp[N][W])

Measured memory_bytes: 120044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N, K; cin >> N >> K;
  ll ans = 0;
  ll maxi = N;
  ll mini = 0;
  for(ll k=0; k<=N; k++){
    if(k>=K-1) {
      ans += maxi+1-mini;
      ans %= mod;
    }
    maxi += N-k-1;
    mini += k+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>

using namespace std;

int main()
{string S;
 cin >> S;
 
 int cnt1 = 0;
 int cnt2 = 0;
 
 for(int i = 0; i < S.size(); i++)
 {if(S[i] == '0'){cnt1++;}
  else if(S[i] == '1'){cnt2++;}}
 
 cout << 2 * min(cnt1,cnt2) <<endl;

 return 0;
}

Measured memory_bytes: 512
N = gets.to_i
a_list = gets.split.map(&:to_i)

forward_gcd_list = Array.new(N)
gcd = nil
a_list.each.with_index do |a, i|
  gcd = gcd ? gcd.gcd(a) : a
  forward_gcd_list[i] = gcd
end

backward_gcd_list = Array.new(N)
gcd = nil
a_list.reverse.each.with_index do |a, i|
  gcd = gcd ? gcd.gcd(a) : a
  backward_gcd_list[N - 1 - i] = gcd
end

ans = N.times.map do |n|
  forward_gcd = n > 0 ? forward_gcd_list[n - 1] : nil
  backward_gcd = n < N - 1 ? backward_gcd_list[n + 1] : nil
  [forward_gcd, backward_gcd].compact.reduce { |acc, a| acc.gcd(a) }
end.max
puts ans


Measured memory_bytes: 14348
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll a(N);
    for(ll i=0;i<N;i++)cin>>a[i];
    
    ll A=0,B=0;
    for(ll i=0;i<N;i++){
        if(a[i]%2==1)A++;
        if(a[i]%4==0)B++;
    }
    if(A<=B || (A==B+1 && A+B==N))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


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


int main()
{
	map<int ,int >a;
	int z=0,n,k,c,i,p[200001];
	scanf("%d %d",&k,&n);
	for(i=0;i<k;i++)
	{
		scanf("%d",&c);
		a[c]++;
	}
	map<int,int>::const_iterator iter;
	for(iter=a.begin();iter!=a.end();iter++)
	{
		p[z++]=iter->second;
	}
	if(z<=n)
	printf("0\n");
	else 
	{
		sort(p,p+z);
		for(i=z-1;i>=z-n;i--)
		k-=p[i];
		printf("%d\n",k);
	}
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),b(n);
	map<int,int> ma,mb;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ma[a[i]]++;
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
		mb[b[i]]++;
	}
	vector<pair<int,int>> v;
	for(auto &p:mb){
		if(ma.count(p.first)){
			v.push_back({min(p.second,ma[p.first]),p.first});
			if(p.second+ma[p.first]>n){
				cout << "No" << endl;
				return 0;
			}
			p.second-=v.back().first;
		}
	}
	sort(v.rbegin(), v.rend());
	int sum=0;
	for(int i=0;i<v.size();i++){
		sum+=v[i].first;
	}
	map<int,vector<int>> mv;
	if(v.size()&&v[0].first*2>sum){
		// cout << "No" << endl;
		// return 0;
		int cnt=0;
		for(auto p:mb){
			if(p.first==v[0].second)continue;
			if(p.second>0)cnt+=p.second;
			// cout << p.first << " " << p.second << endl;
		}
		// cout << v[0].first << " " << sum << " " << cnt << endl;
		if(2*v[0].first-sum>cnt){
			cout << "No" << endl;
		}
		else{
			cout << "Yes" << endl;
			int noko=2*v[0].first-sum;
			vector<int> free;
			for(auto &p:mb){
				if(p.first==v[0].second)continue;
				while(p.second>0){
					mv[v[0].second].push_back(p.first);
					// cout << v[0].second << " " << p.first << endl;
					noko--;
					p.second--;
					free.push_back(v[0].second);
					if(noko==0)break;
				}
				if(noko==0)break;
			}
			vector<int> vv;
			for(int i=0;i<v.size();i++){
				if(i==0){
					for(int j=0;j<sum-v[0].first;j++){
						vv.push_back(v[i].second);
					}
				}
				else{
					for(int j=0;j<v[i].first;j++){
						vv.push_back(v[i].second);
					}
				}
			}
			int uo=sum-v[0].first;
			for(int j=0;j<vv.size();j++){
				mv[vv[j]].push_back(vv[(j+uo)%vv.size()]);
			}
			for(auto p:mb){
				for(int j=0;j<p.second;j++){
					free.push_back(p.first);
				}
			}
			for(int i=0;i<n;i++){
				if(mv[a[i]].size()){
					cout << mv[a[i]].back() << " ";
					mv[a[i]].pop_back();
				}
				else{
					cout << free.back() << " ";
					free.pop_back();
				}
			}
			cout << endl;
		}
		return 0;
	}
	cout << "Yes" << endl;
	vector<int> free;
	vector<int> vv;
	if(v.size()){
		for(int i=0;i<v.size();i++){
			if(0){
				for(int j=0;j<sum-v[0].first;j++){
					vv.push_back(v[i].second);
				}
			}
			else{
				for(int j=0;j<v[i].first;j++){
					vv.push_back(v[i].second);
				}
			}
		}
		int uo=v[0].first;
		for(int j=0;j<vv.size();j++){
			mv[vv[j]].push_back(vv[(j+uo)%vv.size()]);
		}
	}
	for(auto p:mb){
		for(int j=0;j<p.second;j++){
			free.push_back(p.first);
		}
	}
	for(int i=0;i<n;i++){
		if(mv[a[i]].size()){
			cout << mv[a[i]].back() << " ";
			mv[a[i]].pop_back();
		}
		else{
			cout << free.back() << " ";
			free.pop_back();
		}
	}
	cout << endl;
}

Measured memory_bytes: 47608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();

        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (s.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}


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

int main() {
   int a,b,c;
  string s;
  cin>>a;
  bool t=0;
  
  for(int i=1;i<10;i++){
  	for(int j=1;j<10;j++){
    	if(a==i*j){
        	t =1;
        }
    }
  }
  
  
  if(t)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
}

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

int main() {
    int n, sum = 0;

    cin >> n;

    int t = n;
    //10 > 120
    while (t > 0) {
        sum += t % 10;
        t /= 10;
    }

    if (n % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    int x;
    cin >> x;
    if (x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
}



Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;

int main(){
    bool isPrime[100005];
    ll primeCount[100005];
    for(int i = 0; i < 100005; i++){
        isPrime[i] = true;
        primeCount[i] = 0;
    }
    for(int i = 2; i < 100005; i++){
        for(int j = i * 2; j < 100005; j+= i){
            isPrime[j] = false;
        }
    }
    for(int i = 2; i < 100005; i++){
        if(i % 2 == 1 && isPrime[i] && isPrime[(i + 1) / 2]){
            primeCount[i] = primeCount[i - 1] + 1;
        }else{
            primeCount[i] = primeCount[i - 1];
        }
    }
    ll Q;
    cin >> Q;

    for(ll i = 0; i < Q; i++){
        ll l ,r;
        cin >> l >> r;
        //cout << primeCount[r] << "," << primeCount[l - 1] << endl;
        cout << primeCount[r] - primeCount[l - 1] << endl;
    }

}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{

    long double m=0.0,A=0.0;
    int n;
    cin >> n;
    while(n!=0){

        int s[n];
        for (int i = 0; i<n; i++){
            cin >> s[i];
            m += s[i];
        }
        m /= n;
        for (int i = 0; i <n; i++){
            // cout << (s[i]-m)*(s[i]-m) << endl;
            A += ((s[i]-m)*(s[i]-m));
            // cout << A << "A"<<endl;
        }
        A /= n;
        printf("%7Lf\n",sqrtl(A));
        m=0.0;
        A=0.0;
        cin >> n;
    }

    return 0;
}


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

int main(){
  int a[5];
  int total = 0;
  int res = 10;
  for (int i=0;i<5;i++){
    cin >> a[i];
    total += (((a[i]-1)/10)+1) * 10;
    res = min((a[i]-1)%10,res);
  }
  total -= (9 - res);
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  ll n,k; cin>>n>>k;
  ll ans = 0;
  if(n<abs(n-k)){
    ans = n;
  }else{
    ans = n%k;
    chmin(ans, abs(ans-k));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxm=100000+10,maxn=300000+10;
int tree[maxm],ans[maxm];
int h[maxm],go[maxm*20],nxt[maxm*20],ask[maxm*20][3];
int h2[maxm],g2[maxn],n2[maxn];
int i,j,k,l,t,n,m,tot,top;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void add2(int x,int y){
	g2[++tot]=y;
	n2[tot]=h2[x];
	h2[x]=tot;
}
int lowbit(int x){
	return x&-x;
}
void change(int x){
	while (x){
		tree[x]++;
		x-=lowbit(x);
	}
}
int query(int x){
	int t=0;
	while (x<=m){
		t+=tree[x];
		x+=lowbit(x);
	}
	return t;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n){
		scanf("%d%d",&j,&k);
		add2(k,j);
	}
	tot=0;
	fo(i,1,m) ans[i]=n;
	fo(i,1,m){
		fo(j,1,m/i){
			ask[++top][0]=i*(j-1);
			ask[top][1]=i*j;
			ask[top][2]=i;
			add(ask[top][1],top);
		}
		top++;
		ask[top][0]=(m/i)*i;
		ask[top][1]=m+1;
		ask[top][2]=i;
		add(m+1,top);
	}
	fo(i,0,m+1){
		t=h[i];
		while (t){
			j=go[t];
			ans[ask[j][2]]-=query(ask[j][0]+1);
			t=nxt[t];
		}
		t=h2[i];
		while (t){
			change(g2[t]);
			t=n2[t];
		}
	}
	fo(i,1,m) printf("%d\n",ans[i]);
}

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;


void solve()
{
    int n;
    cin >> n;
    cout << n+n*n+n*n*n << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<string> S;
  string s;
  for (int i=0; i<N; i++) {
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S. end());
  s = S[0];
  int ans = 1;
  for (int i=1; i<N; i++)
    if (s != S[i]) {
      s = S[i];
      ans++;
    }
  cout << ans << endl;
  return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k, gk[3];
	string t;
	cin >>n >>k  >>gk[0] >>gk[1] >>gk[2] >> t;
	
	ll ans=0;
	rep(i, k){
		string z;
		rep(j, n){
			if(k*j+i >n-1) break;
			z += t[k*j+i];
		}
		int m=sz(z);
		VI dp(3);
	
		rep(j, m){
			VI np(3);
			rep(k, 3){
				if(k!=0) np[0] = max(np[0], dp[k] + (z[j]=='s'? gk[0]: 0));
				if(k!=1) np[1] = max(np[1], dp[k] + (z[j]=='p'? gk[1]: 0));
				if(k!=2) np[2] = max(np[2], dp[k] + (z[j]=='r'? gk[2]: 0));
			}
			swap(dp, np);
		}
		int mx = *max_element(all(dp));
		ans += mx;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 640
from collections import Counter


len_arr = int(input())

arr = [int(input()) for _ in range(0, len_arr)]

counter = Counter(arr)
arr_max = max(counter)

if counter[arr_max] == 1:
    max_index = arr.index(arr_max)
    for i in range(0, len_arr):
        if i == max_index:
            del(counter[arr_max])
            print(max(counter))
        else:
            print(arr_max)

else:
    for _ in range(0, len_arr):
        print(arr_max)

exit(0)


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

int main(){
	double a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		double x = ((e*c-b*f) / (a*e-b*d));
		double y = ((-(d*c)+a*f) / (a*e-b*d));
		if(x == 0)x = 0;if(y == 0)y = 0;
		printf("%.3f %.3f\n", x, y);
	}
    return 0;
}

Measured memory_bytes: 3144
k = [[1,2,4,8],[4,8,1,2],[8,1,2,4],[2,4,8,1]]
m = [[0]*5 for _ in range(5)]

for i in range(9):
    a = input()
    if i%2:
        for j in range(5):
            if a[j] == '1':
                m[i//2][j] |= 4
                m[i//2+1][j] |= 1
    else:
        for j in range(4):
            if a[j] == '1':
                m[i//2][j] |= 2
                m[i//2][j+1] |= 8
y,x,direct = 0,0,0
ans = []
while True:
    for i in range(4):
        if m[y][x] & k[direct][i]:
            d = k[direct][i]
            if   d == 1: y -= 1; direct = 2
            elif d == 2: x += 1; direct = 0
            elif d == 4: y += 1; direct = 3
            else       : x -= 1; direct = 1
            ans.append(direct)
            break
    if not ( x or y ): break
print("".join("RLUD"[e] for e in ans))


Measured memory_bytes: 5572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private final byte MASK_RIGHT = 0x0F;//右4bit数値化用マスク
	private int[][] paper = new int[10][10];//都合の良い方眼紙

	public static void main(String[] args) throws NumberFormatException, IOException {
		new Main().execute();
	}

	private void execute() throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	/**
	 *都合の良い滴下
	 */
	private void droppingInk(int x, int y, int size) {
		sinking(x, y - 1);
		sinking(x - 1, y);
		sinking(x, y);
		sinking(x + 1, y);
		sinking(x, y + 1);
		if (size == 1) {
			return;
		}

		sinking(x - 1, y - 1);
		sinking(x + 1, y - 1);
		sinking(x - 1, y + 1);
		sinking(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		sinking(x, y - 2);
		sinking(x - 2, y);
		sinking(x + 2, y);
		sinking(x, y + 2);
	}

	/**
	 * 床は汚さないようにする
	 */
	private void sinking(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	/**
	 *紙の染みを数え、損害を報告する
	 */
	private void calcResult() {
		int white = 0;//綺麗な部分
		int max = 0;//一番ひどい汚れ
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > max) {
					max = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(max);
	}
}

Measured memory_bytes: 16992
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
const int maxx = 2e5 + 5;

int n, m;
int a[maxx];
struct node{
	int v, cnt;
}b[maxx];

bool cmp(const node &A, const node &B){
	return A.v < B.v;
}

int main(){
	while(scanf("%d", &n) == 1){
		for(int i = 0; i < n; i++){
			scanf("%d", &a[i]);
			b[i].v = a[i];
			b[i].cnt++;
		}
		sort(b, b + n, cmp);
		for(int i = 0; i < n; i++){
			if(a[i] == b[n - 1].v){
				if(b[n - 1].cnt == 1) cout << b[n - 2].v << endl;
				else cout << b[n - 1].v << endl;
			}
			else cout << b[n - 1].v << endl;
		}
	}
	return 0;
}

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

ll a[55],p[55];

ll f(ll N,ll x){
    if(N==0)return 1;
    else if(x==1)return 0;
    else if(x>1&&x<2+a[N-1])return (f(N-1,x-1));
    else if(x==2+a[N-1])return (p[N-1]+1);
    else if(x>2+a[N-1]&&x<3+2*a[N-1])return (p[N-1]+1+f(N-1,x-2-a[N-1]));
    else if(x==3+2*a[N-1])return (2*p[N-1]+1);
}

int main(){
    ll N,X;cin>>N>>X;
    a[0]=1;p[0]=1;
    rep(i,1,N+1){
        a[i]=2*a[i-1]+3;
        p[i]=2*p[i-1]+1;
    }
    cout<<f(N,X)<<endl;
}







Measured memory_bytes: 256
<?php
list($N,$A,$B) = explode(" ",trim(fgets(STDIN)));

$ans = 0;
$i = 0;
while($i < $N){
$t = trim(fgets(STDIN));
if($t < $A || $t >= $B){
++$ans;
}
++$i;
}

echo $ans . PHP_EOL;
?>

Measured memory_bytes: 3704
#include<cstdio>
#include<algorithm>
#include<vector>
#include<limits.h>
#include<queue>
using namespace std;
void shortestPath(const vector<vector<int> >&edges,int start,vector<int>&dist)
{
    int n=edges.size();
    dist.assign(n,INT_MAX);
    dist[start]=0;
    queue<int> q;
    q.push(start);

    while(!q.empty())
    {
        int v=q.front();
        q.pop();
        for(unsigned i=0;i<edges[v].size();i++)
        {
            int u=edges[v][i];
            if(dist[u]==INT_MAX)
            {
                dist[u]=dist[v]+1;
                q.push(u);
            }
        }
    }
}
main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    vector<vector<int> > edges(3*n);
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        u--,v--;
        for(int j=0;j<3;j++)
        {
            edges[3*u+j].emplace_back(3*v+(j+1)%3);
        }
    }
    int s,t;
    scanf("%d%d",&s,&t);
    --s,--t;
    vector<int> dist;
    shortestPath(edges,3*s,dist);
    int ans=dist[3*t];
    if(ans==INT_MAX)puts("-1");
    else printf("%d\n",ans/3);
    return 0;
}

Measured memory_bytes: 17792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) return 0;
    vector<int> c(m);
    for (int i = 0; i < m; i++) {
      cin >> c[i];
    }
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
      cin >> x[i];
    }
    long long inf = 1LL << 60;
    vector<vector<long long>> dp(n + 1, vector<long long>(256, inf));
    dp[0][128] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= 255; j++) {
        if (dp[i][j] == inf) continue;
        for (int k = 0; k < m; k++) {
          int s = min(255, max(0, j + c[k]));
          dp[i + 1][s] = min(dp[i + 1][s], dp[i][j] + 1LL * (s - x[i]) * (s - x[i]));
        }
      }
    }
    long long ans = inf;
    for (int i = 0; i <= 255; i++) {
      ans = min(ans, dp[n][i]);
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 43848
#include <cstdio>
int main()
{
    
    int A,B;
    scanf("%d %d", &A, &B);
    
    if (A==B)
    
    {
        printf("Draw");
    }
    
    else if (A == 1)
    
    {
        printf ("Alice");
    }
    
    else if (B == 1)
    
    {
        printf ("Bob");
    }
    
    else if (A>B)

    {
        printf("Alice");
    }
    
    else 
    {
        printf ("Bob");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

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

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

    int k;
    string s;
    cin>>k>>s;
    if(s.length()<=k) cout<<s;
    else{
        for(int i=0; i<k; i++) cout<<s[i];
        cout<<"...";
    }    

    return 0;
}


Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
ans = 1000
for ai in a:
    ans_i = 0
    while ai % 2 == 0:
        ai //= 2
        ans_i += 1
        if ans_i == ans:
            break
    ans = min(ans, ans_i)
print(ans)


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

const int MAX_N = 55;
vector<pair<int,int>> edges[MAX_N];

vector<int> path, found;
void dfs(int a, int goal, int parent) {
	if(a == goal) {
		found = path;
		return;
	}
	for(pair<int,int> e : edges[a]) {
		int b = e.first;
		if(b == parent) {
			continue;
		}
		path.push_back(e.second); // edge id
		dfs(b, goal, a);
		path.pop_back();
	}
}

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		edges[a].emplace_back(b, i);
		edges[b].emplace_back(a, i);
	}
	int m;
	cin >> m;
	vector<pair<int,int>> paths;
	vector<int> containMe(n - 1);
	// containMe[e] is a mask that represents which paths
	// 								contain edge e
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		found = {-1};
		dfs(a, b, -1);
		assert(found != vector<int>{-1});
		assert(path.empty());
		for(int e : found) {
			containMe[e] |= 1 << i;
		}
	}
	vector<long long> dp(1 << m);
	// dp[mask] - number of ways to paint already-considered edges
	// so that 'mask' would represent satisfied paths
	dp[0] = 1;
	for(int e = 0; e < n - 1; e++) {
		// cout << containMe[e] << endl;
		vector<long long> new_dp(1 << m);
		for(int mask = 0; mask < (1 << m); mask++) {
			new_dp[mask] += dp[mask];
			new_dp[mask | containMe[e]] += dp[mask];
			// dp[mask] -> new_dp[mask]
			// dp[mask] -> new_dp[mask|pathSatisfiedByThisEdge]
		}
		dp = new_dp;
	}
	cout << dp[(1<<m)-1];
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
int main() {
	ios_base::sync_with_stdio(false);
	ll n; string s,t; cin>>n>>s>>t;
	for (ll x=n;x>=0;x--) {
		if (s.substr(n-x,x)==t.substr(0,x)) {
			cout<<2*n-x<<endl;
			return 0;
		}
	}
}

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

int solve(int i) {
    if(dp[i] != -1) return dp[i];
    if(i == 0) return 0;
    else if(i == 1) return abs(h[i] - h[i-1]);
    else return dp[i] = min(abs(h[i] - h[i-1]) + solve(i-1), abs(h[i] - h[i-2]) + solve(i-2));
}

int main() {
    int N;
    cin >> N;
    h.resize(N);
    dp.resize(N);
    for(int i = 0; i < N; i++) cin >> h[i];
    fill(dp.begin(), dp.end(), -1);
    cout << solve(N - 1) << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    string s,t;cin>>s>>t;
    ll ans=0;
    for(int i=0;i < 3;i++)
    {
        if(s[i]==t[i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	ios;
    queue<long long> lun;
	int k;
    cin>>k;
    rep(i,1,10)
    {lun.push(i);
	}
    long long n;
    rep(i,0,k)
    {
	 n=lun.front();
     lun.pop();
     if(n%10!=0)
	{
	 lun.push(10*n+n%10-1);
	}
     lun.push(10*n+n%10);
     if(n%10!=9)
	{
	 lun.push(10*n+n%10+1);
	}
	}
cout<<n<<endl;
return 0;
}

Measured memory_bytes: 1792
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const A = Number.parseInt(inputStr[0]);
  const B = Number.parseInt(inputStr[1]);
  if( A<=9 && B<=9 ){
    console.log(A*B);
  } else {
    console.log(-1);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
s = input()

flag = True
for i in range(len(s)):
    if i == 0:
        pass
    elif i == 1:
        if s[i] == s[i-1]:
            flag = False
            ans = str(i) + ' ' + str(i+1)
            break
    else:
        if s[i] == s[i-1]:
            flag = False
            ans = str(i) + ' ' + str(i+1)
            break
        elif s[i] == s[i-2]:
            flag = False
            ans = str(i-1) + ' ' + str(i+1)
            break

if flag:
    print('-1 -1')
else:
    print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  for(int i=0;i<N;i++){
    if(S[i] != S[N-1-i]) ans++;
  }
  cout << ans/2 << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;
const int Nmax = 1e5 + 5, Mod = 1e9 + 7;

string a;
char b[Nmax];
int n, i, nr, cnt, s[Nmax], X1, X2, pos1, pos2;

int main()
{
  //  freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> a;
    n = a.size();

    for(i=0; i<n; ++i)
        if(a[i] != 'x') b[++cnt] = a[i];

    for(i=1; i<=cnt; ++i)
        if(b[i] != b[cnt-i+1])
        {
            cout << -1 << '\n';
            return 0;
        }

    if(!cnt)
    {
        cout << 0 << '\n';
        return 0;
    }

    if(cnt&1)
    {
        nr = 0; int pos;
        for(i=0; i<n; ++i)
            if(a[i] != 'x')
            {
                ++nr;
                if(nr == cnt/2 + 1) pos = i;
            }

        int j, ans = 0;
        i = j = pos;

        while(i>=0 || j<n)
        {
            if(i>=0 && j<n && a[i] == a[j])
            {
                --i, ++j;
                continue;
            }

            if(i>=0 && a[i] == 'x') --i, ++ans;
                else ++j, ++ans;
        }

        cout << ans << '\n';
        return 0;
    }

    nr = 0;
    for(i=0; i<n; ++i)
        if(a[i] != 'x')
        {
            ++nr;
            if(nr == cnt/2) pos1 = i;
                else if(nr == cnt/2 + 1) pos2 = i;
        }

      int j, ans = 0;
      i = j = (pos1 + pos2) / 2;
        if((pos1&1) != (pos2&1)) ++j;

        while(i>=0 || j<n)
        {
            if(i>=0 && j<n && a[i] == a[j])
            {
                --i, ++j;
                continue;
            }

            if(i>=0 && a[i] == 'x') --i, ++ans;
                else ++j, ++ans;
        }

        cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  int n,y;

  cin >> n >> y;
  bool tf = 0;
  for(int i = 0;i <= n;i++){
    for(int j = 0;j <= n;j++){
      if(10000*i+5000*j+1000*(n-i-j) == y && (n-i-j) >= 0){
        cout << i << " " << j << " " << (n-i-j) << endl;
        tf = 1;
        n = -1;
      }
    }
  }

  if(!tf){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,c;
    cin >>a>>b>>c;
    int m=max(max(a,b),c);
    if(2*m-a-b-c==0) cout << "Yes"<< endl;
    else cout <<"No"<< endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> X;
	vector<int>m(N);
	for (int i = 0; i < N; i++) {
		cin >> m[i]; X -= m[i];
	}
	int mn = *min_element(m.begin(), m.end());
	ans = N + X / mn;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    string str;
    int ans[100] = {0};
    while(getline(cin, str)){
        rep(i,str.size()){
            if(str[i] >= 'A' && str[i] <= 'Z') str[i] = str[i] + 32;
            if(str[i] >= 'a' && str[i] <= 'z'){
                ans[str[i] - 'a']++;
            }
        }
    }
    rep(i,26){
        printf("%c : %d\n", 'a' + i, ans[i]);
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int n,m;
  cin >> n >> m;
  int k[m];
  vector<vector<int>> ss(m);
  int p[m];

  rep(i,m){
    cin >> k[i];
    rep(ii,k[i]){
      int d;
      cin >> d;
      ss[i].push_back(d);
    }
  }

  rep(i,m)cin >> p[i];
  int ans=0;



  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<12> s(tmp);//これで0101010といった数列を2^n個生成してくれる
    int pp=0;
    rep(i,m){
      int d=0;
      for(auto f:ss[i]){
        if(s[f-1])d++;
      }
      if((d+2)%2==p[i])pp++;
    }
    if(pp==m)ans++;
  }

  cout << ans << endl;
}

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

using namespace std;

int main(void) {
	int n;
	while (cin >> n,n) {
		int sum = 0;
		vector<int> data(n);
		for (int i = 0; i < n; ++i) {
			cin >> data[i];
			sum += data[i];
		}
		sort(data.begin(),data.end());
		int res = 0;
		double ave = (double)sum/n;
		for (int i = 0; data[i] <= ave && i < n; ++i) {
			++res;
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{
			  //System.out.println("??\???");
			  String ab = input.readLine();
			  String[] strAry = ab.split(" ");
			  //????????????????????\??????????????°????????????????????§???????????????
			  int a = Integer.parseInt(strAry[0]);
			  //??????strAry??????????????????????????????????????????
			  int b = Integer.parseInt(strAry[1]);
			  int c = Integer.parseInt(strAry[2]);
			  //??????????????°????????????????????§strAry?????????????????????????´?

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


		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }


	}


}

Measured memory_bytes: 24348
#include<iostream>
#include<iterator>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  vector<int> v(n), revenue(n);
  for (int i = 0; i < n; i ++)
    cin >> v.at(i);
  
  int tmp;
  for (int i = 0; i < n; i ++)
  {
    cin >> tmp;
    revenue.at(i) = v.at(i) - tmp;
  }
  
  sort(begin(revenue), end(revenue), greater<int>());
  int sum = 0;
  auto it = begin(revenue);
  while(*it > 0)
  {
    sum += *it;
    it ++;
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256