akhauriyash/Code-Regression huggingface dataset:
"""
クイックソート

6
D 3
H 2
D 1
S 3
D 2
C 1
"""
import copy

MAX = 500000
L = [None] * int(MAX / 2 + 2) 
R = [None] * int(MAX / 2 + 2) 
# 番兵
SENTINEL = "2000000000000"
from pprint import pprint

def quick_sort(A, n, p, r):
    if p < r:
        q = partition(A, n, p, r)
        # pprint(A)
        # z = []
        # for a in A:
        #     z.append(a.mark_num)
        # print(z)
        quick_sort(A, n, p, q-1)
        quick_sort(A, n, q+1, r)

def partition(A, n, p, r):
    # print(n, p, r)
    x = A[r].num
    i = p
    # print(p)
    for k in range(p, r+1):
        if A[k].num <= x:
            tmp = A[i]
            A[i] = A[k]
            A[k] = tmp
            i += 1
            # print(i)
    return i-1

def merge(B, n, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    for i in range(n1):
        L[i] = B[left + i]
    for i in range(n2):
        R[i] = B[mid + i]
    L[n1] = Card("dummy {}".format(SENTINEL))
    R[n2] = Card("dummy {}".format(SENTINEL))
    i = 0
    j = 0
    k = left
    while  k < right:
        if L[i].num <= R[j].num:
            B[k] = L[i]
            i += 1
        elif L[i].num > R[j].num:
            B[k] = R[j]
            j += 1
        k += 1


def merge_sort(B, n, left, right):
    if (left+1) <  right:
        
        mid = int((left + right) / 2)
        # print(A, n, left, mid, right)
        merge_sort(B, n, left, mid)
        merge_sort(B, n, mid, right)
        merge(B, n, left, mid, right)

            

class Card:
    def __init__(self, mark_num):
        self.mark_num = mark_num
        self.num = int(mark_num.split()[1])


if __name__=="__main__":
    n = int(input())
    A = []
    for i in range(n):
        row = input()
        A.append(Card(row))

    B = copy.deepcopy(A)

    quick_sort(A, n, 0, n-1)
    # for a in A:
    #     print(a.mark_num)
    
    # print("======")
    merge_sort(B, n, 0, n)
    # for b in B:
    #     print(b.mark_num)
    # print(" ".join(A_str))

    for i in range(n):
        if A[i].mark_num != B[i].mark_num:
            print("Not stable")
            break
    else:
        print("Stable")
        # print(A[i].mark_num, B[i].mark_num)

    for a in A:
        print(a.mark_num)
    


Measured memory_bytes: 96540
#include<bits/stdc++.h>
using namespace std;
long long N,S,Max=2;
inline bool chck(long long x){
	long long Sum=0;
	for(long long i=N;i;){
		if(i>=x) Sum+=i%x,i/=x;
		else{
			Sum+=i;
			break;
		}
	}
	return Sum==S;
}
int main(){
	scanf("%lld%lld",&N,&S);
	for(long long i=2;i*i<=N;i++)
	 if(chck(i)){
	 	printf("%lld\n",i);
	 	Max=i;
	 	return 0;
	 }
	for(long long i=Max;i*i<=N-S;i++)
	 if((N-S)%i==0)
	  if(chck(i+1)){
	 	 printf("%lld\n",i+1);
	 	 return 0;
	  }
	for(long long i=sqrt(N-S);i>=1;i--)
	 if((N-S)%i==0)
	  if(chck((N-S)/i+1)){
	  	printf("%lld\n",(N-S)/i+1);
	  	return 0;
	  }
	if(N==S) 
	 if(chck(N+1)) {
		printf("%lld\n",N+1);
		return 0;
	}
	puts("-1");
	return 0;
}

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

int main(){
    char cup[3]={1,0,0};
    char from,to,c;

    while(cin>>from){
        cin>>c>>to;
        swap(cup[from-'A'],cup[to-'A']);
    }

    for(int i=0;i<3;i++){
        if(cup[i]==1){
            cout<<char(i+'A')<<endl;
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

ll n, k, a[100010] = {0}, b[100010] = {0}, c[100010] = {0}, sum = 0;

int main(void)
{
  cin >> n >> k;
  FOR(i, 1, n+1) {
    cin >> a[i];
    b[i] = b[i-1]; c[i] = c[i-1];
    if(a[i] < 0) b[i] += a[i];
    else {
      c[i] += a[i];
      sum += a[i];
    }
  }

  ll ans = 0;
  for(int i=1; i+k-1 <= n; i++) {
    ans = max(ans, sum+b[i+k-1]-b[i-1]);
    ans = max(ans, sum-c[i+k-1]+c[i-1]);
  }

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


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a==b && b!=c) || (b==c && b!=a) || (a==c && b!=c))
        cout << "Yes\n";
    else 
        cout << "No\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(auto& i: S) cin >> i;

  struct Bracket {int open, close;};
  vector<Bracket> open, close, both;
  for(auto& s: S) {
    auto o=0, c=0;
    for(auto i: s) {
      if(i=='(') ++o;
      else o ? --o : ++c;
    }
    if(!c) open.push_back({o, c});
    else if(!o) close.push_back({o, c});
    else both.push_back({o, c});
  }

  sort(begin(both), end(both), [](auto& l, auto& r) {return l.close-l.open < r.close-r.open;});
  auto o = 0;
  for(auto& i: open) o += i.open;
  for(auto& i: both) {
    o -= i.close;
    if(o < 0) {cout << "No" << endl; return 0;}
    o += i.open;
  }
  for(auto& i: close) o -= i.close;
  cout << (o ? "No" : "Yes") << endl;
}


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

double x[10], y[10];

int main(){
	int n; cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    vector<int> vec;
    for(int i = 0; i < n; i++)
        vec.push_back(i);
    double res = 0;
    double down = 1;
    for(int i = 1; i <= n; i++)
        down *= i;
    do{
        double sum = 0;
        for(int i = 1; i < n; i++){
            double xdiff = x[vec[i-1]]-x[vec[i]];
            double ydiff = y[vec[i-1]]-y[vec[i]];
            sum += sqrt(xdiff*xdiff + ydiff*ydiff);
        }
        res += sum;
    }while(next_permutation(vec.begin(), vec.end()));
    printf("%.6f\n", res/down);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi num(111111);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  for(int i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    num[a].pb(b);
  }
  ll ans=0;
  priority_queue<ll>que;
  for(int i=1;i<=m;i++){
    for(int j=0;j<num[i].size();j++)
      que.push(num[i][j]);
    if(!que.empty()){
      ans+=que.top();
      que.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6016
import sys
k=1000
N=int(input())
L=list(map(int,input().split()))
i=0
while i<N-1:
  if L[i]<L[i+1]:
    n=L[i]
    break
  i+=1
  if i==N-1:
    print(1000)
    sys.exit()
n=0
for j in range(i,N):
  if j==N-1 and n!=0:
    m=max(L[s:])
    c=k%n
    k=((k//n)*m)+c
    n=0
    break
  if j==N-1 and n==0:
    break
  if L[j]<L[j+1] and n==0:
    n=L[j]
    s=j
  if L[j]>L[j+1] and n!=0:
    m=L[j]
    c=k%n
    k=((k//n)*m)+c
    n=0
print(k)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[4],pre[4],dp[4],m,k,ans=0,fl=0;
	string s;
	ll ma=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[0]>>a[1]>>a[2];
		if(i==0)
		{
			pre[0]=a[0];
			pre[1]=a[1];
			pre[2]=a[2];
		}
		else
		{
			for(int j=0;j<3;j++)
			{
				ma=0;
				for(int k=0;k<3;k++)
				{
					if(j!=k)
					{
						ma=max(pre[k],ma);
					}
				}
				dp[j]=ma+a[j];
			}
			for(int j=0;j<3;j++)
				pre[j]=dp[j];
		}
	}
	ma=0;
	for(int i=0;i<3;i++)
	{
		ma=max(ma,pre[i]);
	}
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;
bool vis[limit],vis2[limit];
vector <int> prime;
void p()
{
    for(int i=4; i<limit; i+=2) vis[i]=1;
    for(int i=3; i*i<=limit; i+=2)
    {
        if(vis[i]==0)
            for(int j=i*i; j<limit; j+=i*2)
                vis[j]=1;
    }
    prime.pb(2);
    for(int i=3; i<limit; i+=2)
        if(vis[i]==0)
            prime.pb(i);
}
void solve(int t)
{
    int i,j,n,m,ck=0;
    scanf("%d",&n);
    int D[n+5];
    for(i=0; i<n; i++)
        scanf("%d", &D[i]);
    m = D[0];
    for(i=1; i<n; i++)
    {
        m = __gcd(m,D[i]);
    }
    if(m>1)
    {
        cout <<"not coprime\n";
        return ;
    }
    for(i=0; i<n; i++)
    {
        if(ck) break;
        if(vis[D[i]]==0 && D[i]>1)
        {
            if(vis2[D[i]])
            {
                ck = 1;
                break;
            }
            vis2[D[i]]=1;
            continue;
        }
        for(j=0; prime[j]*prime[j]<=D[i]+1; j++)
        {
            int ct=0;
            while(D[i]%prime[j]==0)
            {
                ct = 1;
                D[i] /= prime[j];
            }
            if(ct)
            {
                if(vis2[prime[j]])
                {
                    ck = 1;
                    break;
                }
                vis2[prime[j]]=1;
            }
        }
        if(D[i]>1)
            {
                if(vis2[D[i]])
                {
                    ck = 1;
                    break;
                }
                vis2[D[i]]=1;
            }
    }
    if(ck)
    {
        cout <<"setwise coprime\n";
    }
    else
        cout <<"pairwise coprime\n";
    return;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    p();
    int t,tt=1;
 //   cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 10000
#define MOD 1000000007LL
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define PI acos(-1)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};

int dp[262144][51];

signed main() {
    rep(i, 262144) rep(j, 51) { dp[i][j] = INF; }
    dp[0][0] = 0;
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int p = 1;
    rep(i, n) p *= 2;
    rep(i, p) {
        int cnt = 0;
        vi u;
        rep(k, n) {
            if((i >> k) & 1) {
                cnt++;
                u.push_back(k);
            }
        }
        rep(k, n) {
            if((i >> k) & 1) {
                continue;
            }
            int cnt2 = 0;
            rep(j, u.size()) {
                if(u[j] > k) {
                    cnt2++;
                }
            }
            int c;
            if(abs(cnt - k) % 2) {
                c = b[k];
            } else {
                c = a[k];
            }
            rep(j, 51) {
                if(c < j)
                    continue;
                chmin(dp[i | (1 << k)][c], dp[i][j] + cnt2);
            }
        }
    }
    // rep(i, p) {
    //     rep(j, 11) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    int ans = INF;
    rep(i, 51) { chmin(ans, dp[p - 1][i]); }
    if(ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 52480
int b[5];main(i,s){for(s=i=0;i-5&&scanf("%d",b+i);s|=1<<--b[i++]);if(i=*b<0)exit(0);for(s="ccc`cbac"[s]&7;printf("%d\n",s-3?b[i]-s?2:1:3)&&++i-5;);main();}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
 
int main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a < 3200) cout << "red" << endl;
    else cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    string s;
    cin >> s;
    for (int i=0; i<3; i++) {
        if (s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
//itp1_4-b
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
 double r,l,s;
 cin>>r;
 l=M_PI*r*2;
 s=M_PI*r*r;

 printf("%.6f %.6f\n",s,l);
 return 0;
}

Measured memory_bytes: 1240
n = int(input())
l = [0]*n
for i in range(n):
    l[i] = list(map(int,input().split()))

l.sort(key = lambda x:x[1])

cnt = 0
for i in range(n):
    cnt += l[i][0]
    if cnt > l[i][1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 46924
#include <cstdio>
#include <vector>

using namespace std;

const int N = 200'009;

vector<int> g[N];
int f[N];

void dfs(int x, int pa) {
  for (int y : g[x]) {
    if (y == pa) {
      continue;
    }
    f[y] += f[x];
    dfs(y, x);
  }
}

int main() {
  int n, qq;
  scanf("%d%d", &n, &qq);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    f[i] = 0;
  }
  while (qq--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    f[x] += y;
  }
  dfs(0, -1);
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      putchar(' ');
    }
    printf("%d", f[i]);
  }
  putchar('\n');
}


Measured memory_bytes: 23424
n = int(input())
ans = []
for i in range(n):
    ax,ay,bx,by,cx,cy = map(float, input().split(" "))
    a,b,c = 2*(ax-bx),2*(ay-by),(ax+bx)*(ax-bx)+(ay+by)*(ay-by)
    d,e,f = 2*(ax-cx),2*(ay-cy),(ax+cx)*(ax-cx)+(ay+cy)*(ay-cy)
    det = a*e-b*d
    px = (c*e-b*f)/det
    py = (a*f-c*d)/det
    if abs(px) < 1e-4:
        px = 0.0
    if abs(py) < 1e-4:
        py = 0.0
    r = ((ax-px)**2+(ay-py)**2)**(1/2)
    ans.append([px,py,r])
for i in range(n):
    print("{0:.3f}".format(ans[i][0]),"{0:.3f}".format(ans[i][1]),"{0:.3f}".format(ans[i][2]))



Measured memory_bytes: 5676
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);

    int d = a / b;
    int e = a % b;
    double f = (double)a / b;

    printf("%d %d %f\n", d, e, f);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i / 60) % 60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


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

#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int>v;
    f(n) {
        int x;
        cin >> x;
        v.pb(x);
    }
    ll ans = 0;
    map<int,int>mp;
    for (int i = 0 ; i < n ; i++) {
        int x = v[i] - (n - i);
        int tar = i - v[i] - n;
        //cout << x << endl;
        //cout << x <<' '<<tar<< endl;
        if (mp.count(tar)) {
            //cout << tar << endl;
            ans += mp[tar];
        }
        mp[x]++;
    }
    cout << ans << endl;  
}

Measured memory_bytes: 13380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define start int t;cin>>t;while(t--)

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a , b , n;
    cin>>a>>b>>n;
    ll x;
     ll ans=0;
     if(n<b)
     ans = floor((a*n)/b) - a*floor(n/b);
     else{
         ans = floor((a*(b-1))/b) - a*floor((b-1)/b);
     }
     
     std::cout << ans << std::endl;
    
    
    
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define LL long long
#define maxn 200005
using namespace std;
LL a[200005];
int main()
{
    LL k;
    int n;
    cin>>k>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    LL minans=k;
    for(int i=0;i<n-1;i++)
    {
        LL tmpans=a[i]+(k-a[(i+1)%n]);
        minans=min(tmpans,minans);
    }
    minans=min(a[n-1]-a[0],minans);
    cout<<minans;
}


Measured memory_bytes: 1792
#include <iostream>
 using namespace std;
 int main(){
 string S;
 cin >> S;
 int ans = 700;
 if(S[0] == 'o') ans += 100;
 if(S[1] == 'o') ans += 100;
 if(S[2] == 'o') ans += 100;
 cout << ans << endl;
 }


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
  int n;
  int ans = 0;
  scanf("%d",&n);
  vector<int> d(n);
  for (int i=0; i<n; i++) scanf("%d",&d[i]);

  int sum = accumulate(d.begin(), d.end(), 0);
  for (int i=0; i<n; i++) {
    ans += (sum-=d[i])*d[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int a[2][101];
int dp[2][101];
int main() {
    int n;
    cin >> n;
    for (int i=0;i<2;i++) {
        for (int j=0;j<n;j++) {
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    for (int i=0;i<2;i++) {
        for (int j=0;j<n;j++) {
            if (i == 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a[i+1][j]);
            }
            if (j < n) {
                dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a[i][j+1]);
            }
        }
    }
    cout << dp[1][n-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
typedef pair<ll, ll> P;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;
struct item {
	int wght, val;
};

int n, W;
ll dp[101][100005];
vector<item> v;
ll calc(int idx, int wight) {
	if (idx == n)
		return 0;
	ll &ret = dp[idx][wight];
	if (ret != -1)
		return ret;
	ret = calc(idx + 1, wight);
	if (wight - v[idx].wght >= 0)
		ret = max(ret, v[idx].val + calc(idx + 1, wight - v[idx].wght));
	return ret;
}
int main() {
	//freopen("src.txt", "r", stdin);
	memset(dp, -1, sizeof dp);
	cin >> n >> W;
	v.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i].wght >> v[i].val;
	ll ans = calc(1, W);
	if (W - v[0].wght >= 0)
		ans = max(ans, v[0].val + calc(1, W - v[0].wght));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 79104
#include <stdio.h>


int main() {
 

  int n;
  scanf("%d",&n);

  int cnt4=0,cnt2=0;
  //4の倍数
  //4の倍数出ないが、2の倍数/2
  //の合計がn/2より大きい
  for(int i=0;i<n;i++){
    int wk;
    scanf("%d",&wk);
    if(wk%4==0)
      cnt4++;
    else if(wk%2==0)
      cnt2++;
  }

  if(cnt4+cnt2/2>=n/2)
    printf("Yes\n");
  else 
    printf("No\n");

	return 0;
}

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



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

    
    int a,b,c,d; cin >> a >> b >> c >> d;
    int ta = (c+b-1)/b, ao = (a+d-1)/d;
    if(ta <= ao) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn = 3000005;
const int maxm = maxn*2;
const ll inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int f[100005][31];
int a[100005];
int n,l,q;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i = 1;i<=n;i++) cin>>a[i];
    cin>>l>>q;
    for(int i = 1;i<=n;i++) f[i][0] = upper_bound(a+1,a+n+1,a[i]+l) - a - 1;
    for(int j = 1;j<=30;j++) for(int i = 1;i<=n;i++) f[i][j] = f[f[i][j-1]][j-1];
    while(q--) {
        int x,y; cin>>x>>y; if(x>y) swap(x,y);
        int pos = x,ans = 0;
        for(int i = 30;i>=0;i--) {
            if(f[pos][i] < y) {
                ans += 1<<i; pos = f[pos][i];
            }
        }
        cout<<ans + 1<<'\n';
    }
    return 0;
}

Measured memory_bytes: 13312
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

ll L;
int main(){
  cin >> L;
  ll L2=L;
  ll N=1,M=0;
  while (L2>1){
    if (L2%2==1){
      L2--;
      M++;
    }
    L2/=2;
    N++;
    M+=2;
  }
  L2=L;
  ll k=1;
  cout << N << " "<< M << endl;
  while (L2>1){
    if (L2%2==1){
      L2--;
      cout << k << " " << N << " " << L2 << endl;
    }
    L2/=2;
    cout << k << " " << k+1 << " " << 0 << endl;
    cout << k << " " << k+1 << " " << L2 << endl;
    k++;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ostream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T, typename U>
std::ostream& operator << (std::ostream& out, std::pair<T, U> p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T>
std::ostream& operator << (std::ostream& out, std::vector<T> v) {
  out << "[";
  for (int i = 0; i < v.size(); ++i) {
    out << v[i] << (i == (v.size() - 1) ? "" : ", ");
  }
  out << "]";
  return out;
}

int main() {
  int N, K;
  std::vector<int> h;

  cin >> N >> K;
  h.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }

  std::sort(h.begin(), h.end());

  int ans = int(1e9);

  for (int i = 0; i <= N - K; ++i) {
    ans = std::min(ans, h[i + K - 1] - h[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define Pb push_back
#define Mp make_pair
#define ff first
#define ss second
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MOD (ll)1000000007
 
 
signed main()
{
    IOS;
    int k,x;
    cin >> k >> x;
    if(k*500 >= x) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
X = int(input())
bank = 100
result = 0

import math
import decimal

while (True):
    # print("bank = "+str(bank))
    if(bank >= X):
        break
    else:
        tmp = str(bank*0.01)
        tmp = tmp[:tmp.find('.')]
        bank = bank + int(tmp)
        result = result+1

print(result)


Measured memory_bytes: 9892
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    lld k;
    scanf("%lld", &k);
    printf("50\n");
    rep(i, 0, 50){
        lld x = k/50;
        if(i < k%50){
            x += 1;
        }
        printf("%lld ", x*50 - (k-x) + i);
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

bool sorted(vii v)
{
	int sz=v.size();
	rep(i,0,sz-1)if(v[i]!=i)return 0;
	return 1;
}

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
vii a;
rep(i,0,n-1)
{
	int x;
	cin>>x;
	x--;
	a.pb(x);
}

if(sorted(a))
{
	ol("YES");
	return 0;
}

rep(i,0,n-1)
{
	rep(j,i+1,n-1)
	{
		vii v=a;
		swap(v[i],v[j]);
		if(sorted(v))
		{
			ol("YES");
			return 0;
		}
	}
}
ol("NO");
return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d", &a, &b);
  
  if (a<b){
    printf("a < b\n");
  }else if (a>b){
    printf("a > b\n");
  }else if (a==b){
    printf("a == b\n");
  }
  return 0;
}
 

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

#define NO_SIGN -1

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<unordered_set<int>> road(N, unordered_set<int>{});


  for (auto i = 0; i < M; ++i) {
    int A_i, B_i;
    cin >> A_i >> B_i;

    road[A_i - 1].insert(B_i - 1);
    road[B_i - 1].insert(A_i - 1);
  }

  // for (auto i = 0; i < N; ++i) {
  //   cout << i << ":" << endl;
  //   for (auto r:road[i]) {
  //     cout << r << " ";
  //   }
  //   cout << endl;
  // }

  // main procedure
  vector<int> room_sign(N, NO_SIGN);
  deque<int> rooms_to_search;

  room_sign[0] = 0;
  rooms_to_search.push_back(0);

  while(!rooms_to_search.empty()) {
    int searching_room = rooms_to_search.front();
    rooms_to_search.pop_front();
    
    for (auto next_room: road[searching_room]) {
      if (room_sign[next_room] == NO_SIGN) {
        room_sign[next_room] = searching_room + 1;
        rooms_to_search.push_back(next_room);
      }
    }
  }

  // output
  WRITE_N("Yes");
  for (auto i = 1; i < N; ++i) {
    WRITE_N(room_sign[i]);
  }
 

  return 0;
}


Measured memory_bytes: 27296
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    ll MAX_VAL = 10000 * N;
    vec<vec<ll>> dp(N + 1, vec<ll>(MAX_VAL + 100, 1e14 + 5));

    for (int i = 1; i <= N; ++i) {
        dp[i][v[i - 1]] = min(dp[i][v[i - 1]], w[i - 1]);

        for (int j = 0; j <= MAX_VAL; ++j) {
            dp[i][j] = min({dp[i][j], dp[i - 1][j]});

            dp[i][j + v[i - 1]] = min(dp[i][j + v[i - 1]], dp[i-1][j] + w[i - 1]);
        }
    }

    ll ans = 0;

    rep(i, MAX_VAL) if (dp[N][i] <= W) ans = max(ans, i);
    cout << ans << endl;
}


Measured memory_bytes: 800548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
  ll n, k;cin >> n>>k;
  ll a[2010][2010];
  for(int i=0;i<=2000;i++){
    a[i][i]=1;
    a[i][0]=1;
  }
  for(int i=2;i<=2000;i++){
    for(int j=1;j<i;j++){
      a[i][j]=(a[i-1][j-1]+a[i-1][j])%mod;
    }
  }
  for(int i=1;i<=k;i++){
    cout << a[n-k+1][i]*a[k-1][i-1]%mod<<endl;
  }
}

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

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

	int L, R;
	scanf("%d %d", &L, &R);

	int l = L % 2019;
	int r = R % 2019;

	int result = 2019;
	if (L / 2019 != R / 2019) {
		goto finish;
	}
	if (l <= r) {
		for (int i = l; i <= r; i++) {
			for (int j = i + 1; j <= r; j++) {
				result = min(result, i * j % 2019);
				if (result == 0) {
					goto finish;
				}
			}
		}
	} else {
		result = 0;
		goto finish;
	}
finish:
	printf("%d", result % 2019);
	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;


int main() {
  string s,t; cin >> s >> t;
  int ans = 0;
  rep(i,3){
    if(s.at(i) == t.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
A, B = map(int, input().split())

s = [2, 3, 4, 5, 6, 7,  8, 9, 10, 11, 12, 13, 1]
a = s.index(A)
b = s.index(B)

if a > b:
    print('Alice')
elif a == b:
    print('Draw')
else:
    print('Bob')

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int H, W; cin >> H >> W;
    vector<string> m(H); for(int h=0; h<H; ++h){ cin >> m[h]; } // matrix
    
    // LR: Is continue more than 2 ?
    for(int h=0; h<H; ++h){
        for(int w=1; w<W; ++w){
            if( (m[h][w-1]=='#' || m[h][w-1]=='O') &&
                (m[h][w  ]=='#' || m[h][w  ]=='O')    )
            {
                m[h][w-1] = 'O';
                m[h][w  ] = 'O';
            }
        }
    }
    
    // TB: Is continue more than 2 ?
    for(int w=0; w<W; ++w){
        for(int h=1; h<H; ++h){
            if( (m[h-1][w]=='#' || m[h-1][w]=='O') &&
                (m[h  ][w]=='#' || m[h  ][w]=='O')    )
            {
                m[h-1][w] = 'O';
                m[h  ][w] = 'O';
            }
        }
    }
    
    // Is there '#' ?
    bool TF=true;
    for(int h=0; h<H; ++h){
        for(int w=0; w<W; ++w){
            if( m[h][w] == '#' ){ TF=false; }
        }
    }
    cout << (TF ? "Yes":"No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] p = new int[n];
    for(int i=0;i<n;i++)p[i]=sc.nextInt()-1;
    int[] parent = new int[n];
    for(int i=0;i<n;i++)parent[i]=i;
    for(int i=0;i<m;i++){
      int x = sc.nextInt();
      int y = sc.nextInt();
      union(parent,x-1,y-1);
    }
    int cnt = 0;
    for(int i=0;i<n;i++)
      if(find(parent,i)==find(parent,p[i]))cnt++;
    System.out.println(cnt);
  }
  static int find(int[] parent,int x){
    if(parent[x]==x)return x;
    else{
      parent[x]=find(parent,parent[x]);
      return parent[x];
    }
  }
  static void union(int[] parent,int x,int y){
    int xRoot = find(parent,x);
    int yRoot = find(parent,y);
    parent[xRoot]=yRoot;
  }
}

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

int main(){
    string s;
    cin >> s;
    int k;
    k=0;
    if(s[0]==s[1] and s[2]==s[3]){
        k+=1;
    }
    if(s[0]==s[2] and s[1]==s[3]){
        k+=1;
    }
    if(s[0]==s[3] and s[1]==s[2]){
        k+=1;
    }
    

    if(k==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

const int V_MAX = 100000;

void solve(vector<int> graph[], int num[], int lowpt[],int v, int& n) {
	num[v] = n;
	lowpt[v] = n;
	n++;
	for (int i = 0; i < graph[v].size(); i++) {
		if (num[graph[v][i]] == 0) {
			solve(graph, num, lowpt, graph[v][i], n);
			lowpt[v] = min(lowpt[v], lowpt[graph[v][i]]);
		}
		else {
			lowpt[v] = min(lowpt[v], num[graph[v][i]]);
			graph[v].erase(graph[v].begin() + i);
			i--;
		}
	}
}

bool check(vector<int> graph[], int num[], int lowpt[], int v) {
	bool flag = false;
	for (int j = 0; j < graph[v].size(); j++) {
		if (num[v] <= lowpt[graph[v][j]]) {
			flag = true;
		}
	}
	return flag;
}

int main() {
	int v, e;
	vector<int> graph[V_MAX];
	int num[V_MAX] = { 0 };
	int lowpt[V_MAX] = { 0 };
	int child[V_MAX];

	scanf("%d%d", &v, &e);

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

	for (int i = 0; i < e; i++) {
		int s, t;
		scanf("%d%d", &s, &t);
		graph[s].push_back(t);
		graph[t].push_back(s);
	}

	int n = 1;
	solve(graph, num, lowpt, 0, n);

	for (int i = 0; i < v; i++) {
		if (i == 0 && graph[i].size() < 2)continue;
		if (check(graph, num, lowpt, i)) {
			printf("%d\n", i);
		}
	}

	return 0;
}

Measured memory_bytes: 7240
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = ns()
    ans = '0'
    for s in S:
        ans += s + '1'
    print(eval(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll, P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()
 

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1;i*2<n;i++){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  string str;
  cin >> str;
  bool odd = str.size() % 2;
  bool same = str.front() == str.back();
  
  if (odd^same) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 512
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    private final String S;

    AtCoder(FastScanner sc) {
        S = sc.next();
    }

    void solve(PrintWriter out) {
        StringBuilder sb = new StringBuilder(S);
        int cnt = 0;
        for (int i = 0; i < sb.length(); i++) {
            if (sb.charAt(i) != sb.reverse().charAt(i)) cnt++;
        }
        out.println(cnt / 2);
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

char ss[16][99]={
"AKIHABARA",
"AKIHABAR",
"AKIHABRA",
"AKIHABR",
"AKIHBARA",
"AKIHBAR",
"AKIHBRA",
"AKIHBR",
"KIHABARA",
"KIHABAR",
"KIHABRA",
"KIHABR",
"KIHBARA",
"KIHBAR",
"KIHBRA",
"KIHBR"
};

int main(){
	char s[99];
	scanf("%s",s);
	for(int i=0;i<16;i++)if(!strcmp(s,ss[i])){
		puts("YES");
		return 0;
	}
	puts("NO");
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <stack>
#define LL long long
#define MAXN 2010
using namespace std;

const LL P=1000000007;

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN<<1];

int n,m,C;
int g[MAXN],nume;
int dfn[MAXN],low[MAXN],numw;
stack<int> S;
bool instack[MAXN];
int c[MAXN][MAXN],d[MAXN],d0[MAXN],numc;
LL bio[MAXN][MAXN];

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

void tarjan(int x,int pe){
	dfn[x]=low[x]=++numw;
	S.push(x);
	instack[x]=1;
	for(int i=g[x];~i;i=e[i].next)
		if(i^pe){
			if(!dfn[e[i].to]){
				tarjan(e[i].to,i^1);
				if(low[e[i].to]<low[x]) low[x]=low[e[i].to];
				if(low[e[i].to]>=dfn[x]){
					numc++;
					while(S.top()!=e[i].to){
						c[S.top()][numc]=1;
						instack[S.top()]=0;
						d0[numc]++;
						S.pop();
					}
					c[e[i].to][numc]=1;
					instack[e[i].to]=0;
					c[x][numc]=1;
					d0[numc]+=2;
					S.pop();
				}
			}else if(instack[e[i].to] && dfn[e[i].to]<low[x]) low[x]=dfn[e[i].to];
		}
}

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

int gcd(int x,int y){
	if(!y) return x;
	return gcd(y,x%y);
}

LL calc(int x){
	LL res=0;
	for(int i=0;i<x;i++)
		res=(res+getPow(C,gcd(i,x)))%P;
	res=res*getPow(x,P-2)%P;
	return res;
}

LL calc2(int x){
	return bio[C+x-1][C-1];
}

void init(){
	for(int i=0;i<MAXN;i++){
		bio[i][0]=1;
		for(int j=1;j<=i;j++)
			bio[i][j]=(bio[i-1][j-1]+bio[i-1][j])%P;
	}
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	init();
	memset(g,-1,sizeof g);
	scanf("%d%d%d",&n,&m,&C);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		addEdge(u,v);
		addEdge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(!dfn[i]){
			tarjan(i,-1);
			numc++;
			while(!S.empty()){
				c[S.top()][numc]=1;
				d0[numc]++;
				instack[S.top()]=0;
				S.pop();
			}
		}
	LL ans=1;
	for(int x=1;x<=n;x++)
		for(int i=g[x];~i;i=e[i].next)
			if(i&1){
				bool flag=0;
				for(int j=1;j<=numc;j++)
					if(c[x][j] && c[e[i].to][j]){
						d[j]++;
						flag=1;
						break;
					}
				if(!flag) ans=ans*C%P;
			}
	for(int i=1;i<=numc;i++){
		if(d0[i]==1) continue;
		if(d[i]==d0[i]) ans=ans*calc(d0[i])%P;
		else if(d[i]==d0[i]-1) ans=ans*getPow(C,d[i])%P;
		else ans=ans*calc2(d[i])%P;
	}
	printf("%lld\n",ans);
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string str = "Yes";
  if (a != b) {
    str = "No";
  } else if (b != c) {
    str = "No";
  } else if (c != a) {
    str = "No";
  }
  cout << str << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, K;
string S[305];
int ans[305][305];

int main(){
  cin >> H >> W >> K;
  for (int i = 0; i < H; i++) cin >> S[i];

  int now = 1;
  for (int i = 0; i < H; i++){
    int cnt = 0;
    for (int j = 0; j < W; j++){
      if (S[i][j] == '#') cnt++;
    }
    if (cnt == 0) continue;

    for (int j = 0; j < W; j++){
      if (S[i][j] == '#'){
        ans[i][j] = now;
        now++; cnt--;
      }else if (cnt == 0){
        ans[i][j] = now - 1;
      }else{
        ans[i][j] = now;
      }
    }
  }


  for (int i = 0; i < H; i++){
    if (ans[i][0] != 0) continue;
    
    int U = i - 1;
    while (U >= 0){
      if (ans[U][0] != 0) break;
      U--;
    }

    if (U >= 0){
      for (int j = 0; j < W; j++){
        ans[i][j] = ans[U][j];
      }
      continue;
    }

    int D = i + 1;
    while (D < H){
      if (ans[D][0] != 0) break;
      D++;
    }
    for (int j = 0; j < W; j++){
      ans[i][j] = ans[D][j];
    }
  }


  for (int i = 0; i < H; i++){
    cout << ans[i][0];
    for (int j = 1; j < W; j++){
      cout << " " << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

char p[12][7];
int f[12][6];
char memo;
int dx[] = {0,-1,0,1}, dy[] = {-1,0,1,0};

int dfs(int y, int x, int c){
  //  fprintf(stderr, "%d %d %d\n", y, x, c);
  int ret = c;
  bool flag = 0;
  rep(d, 4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny < 0 || nx < 0 || ny >= 12 || nx >= 6 || f[ny][nx]) continue;
    if(p[ny][nx] == memo){
      flag = 1;
      f[ny][nx] = 1;
      //    fprintf(stderr, "%d %d %d\n", ny, nx, 1);
      ret += dfs(ny, nx, 1);
    }else if(p[ny][nx] == 'O'){
      f[ny][nx] = 1;
    }
  }
  //  printf("%d %d %d\n", y, x, ret);
  return ret;
}

void ojama(){
  rep(i, 12) rep(j, 7){
    if(p[i][j] != 'O') continue;
    //    printf("%d %d\n", i, j);
    rep(d, 4){
      int ny = i + dy[d], nx = j + dx[d];
      if(ny < 0 || nx < 0 || ny >= 12 || nx >= 6 || !f[ny][nx]) continue;
      f[i][j] = 1;
      break;
    }
  }
  return;
}

void del(){
  rep(i, 12) rep(j, 6){
    if(!f[i][j]) continue;
    p[i][j] = '.';
  }
  return;
}

void next(){
  /*  rep(i, 12){
    rep(j, 6) printf("%d ", f[i][j]); puts("");
    }*/

  for(int i = 11; i >= 0; i--) rep(j, 6){
      if(p[i][j] != '.') continue;
      for(int k = i; k >= 0; k--){
	if(p[k][j] == '.') continue;
	p[i][j] = p[k][j];
	p[k][j] = '.';
	break;
      }
    }

  /*  rep(i, 12){
    puts(p[i]);
    }*/
  return;
}

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

  while(n--){
    //    puts("in");
    rep(i, 12){
      scanf("%s", p[i]);
    }

    int res = 0;
    while(true){
      //      fprintf(stderr, "%d\n", res);
      int judge = 0;

      rep(i, 12) rep(j, 6){
	memset(f, 0, sizeof(f));
	//	fprintf(stderr, "%d %d\n", i, j);
	if(p[i][j] == '.' || p[i][j] == 'O'|| f[i][j]) continue;
	//	fprintf(stderr, "%d %d\n", i, j);
	memo = p[i][j];
	f[i][j] = 1;
	if(dfs(i, j, 1) >= 4){
	  //	  printf("%d %d\n", i, j);
	  judge = 1;
	  /*	  rep(i, 12){
	    rep(j, 6) printf("%d ", f[i][j]); puts("");
	    }*/
	  del();
	//	fprintf(stderr, "%d\n", judge);
	}
      }
      //     printf("%d\n", judge);
      if(!judge) break;
      //      ojama();
      //      fprintf(stderr, "ojama\n");
      //      del();
      //      fprintf(stderr, "del\n");
      next();
      //      fprintf(stderr, "next\n");
      res++;
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int h[1000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int cnt = 0;
    int max = 0;
    for (int i = 0; i < n; i++) {
        if (max <= h[i]) {
            cnt++;
            max = h[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256