akhauriyash/Code-Regression huggingface dataset:
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0319?year=2015

#include <bits/stdc++.h>

using namespace std;

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

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        mp[t]++;
    }

    for (int i = 100; i > 0; --i) {
        mp[i - 1] += mp[i];
    }

    int ans = 0;
    while (mp[ans] >= ans) ans++;
    ans--;

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

/*
 * i点以上がmp[i]個あるとする。
 * 累積和的な計算でmp[i]を求める。
 * mp[i]>=iとなるiの最大値が答え。
 *
 */


Measured memory_bytes: 3116
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    
    ans = 0
    for elem in al:
        while elem % 2 == 0:
            ans += 1
            elem //= 2
    print(ans)

if __name__=="__main__":
    solve()


Measured memory_bytes: 4148
w, h, n = map(int, input().split())
r, l, u, d = w, 0, h, 0
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        d = max(d, y)
    else:
        u = min(u, y)
print(max(0, r-l) * max(0, u-d))

Measured memory_bytes: 9132
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = zeros(Int,n)
	for i in 1:n
		a[i] = readline() |> parseInt
	end
	b = sort(a)
	d = Dict{Int,Int}()
	for i in 1:n
		d[b[i]] = i
	end
	diff = 0
	for i in 1:n
		if d[a[i]]%2!=i%2
			diff += 1
		end
	end
	println(diff>>1)
end
main()

Measured memory_bytes: 185200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll INF64 = 1e18;

template <typename T>
string to_string(const vector<T> &v) {
  string ret = "<";
  for (auto it : v)
    ret += to_string(it) + ", ";
  ret.pop_back(); ret.pop_back();
  ret += ">";
  return ret;
}

string to_string(const string &s) {
  return '"' + s + '"';
}

string to_string(bool b) {
  return b ? "true" : "false";
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_print() { cerr << endl; }

template <typename T, typename ...U>
void debug_print(T t, U... u) {
  cerr << " " << to_string(t);
  debug_print(u...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_print(__VA_ARGS__)
const int N = 1e5 + 5;

vector<int> root;
vector<int> sz;
int n, m;

void init() {
  root.resize(n + 1);
  iota(all(root), 0);
  sz.assign(n + 1, 1);
}

int find_root(int x) {
  return x == root[x] ? x : root[x] = find_root(root[x]);
}

void uni(int a, int b) {
  int root_a =find_root(a);
  int root_b =find_root(b);
  if (root_a != root_b) {
    sz[root_a] += sz[root_b];
    root[root_b] = root_a;
  }
}

int main() {
  cin >> n >> m;
  init();
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    uni(a, b);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, sz[find_root(i)]);
  }
  cout << ans << '\n';
  //If you dont need Flush Stream, dont use endl
  return 0;
}


Measured memory_bytes: 4840
#define _USE_MATH_DEFINE
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using ll = long long;
int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double ans = sqrt(a * a + b * b - 2 * a * b * cos(abs((30 * h - 5.5 * m) * M_PI / 180)));
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

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

int main() {
  int H, W;
  string S;

  cin>> H >> W;
  cout << "#";
  for (int i = 0; i < W; i++){
    cout << "#"; //上側の#出力
  }
  cout << "#" <<endl;
  for (int i = 0; i < H; i++){ //縦の読み込み
      cin >> S;
      cout << "#" << S << "#" << endl;
  }
  cout << "#";
  for (int i = 0; i < W; i++){
    cout << "#"; //下側の#の出力
  }
  cout << "#" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define F first
#define S second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lld I64d
#define ii  pair<int,int>
int main()
{
    ios
    ll n,m,i,j,k,num,test=1,pdt=1,sum=0;
    cin>>n;
    ll f[n][10];
    for(j=0; j<n; j++)
    for(i=0; i<10; i++)
        cin>>f[j][i];// cout<<f[j][i]<<" "; cout<<endl;
    ll p[n][11];
    for(i=0; i<n; i++)
        for(j=0; j<11; j++)
        cin>>p[i][j];
    ll fl=-100000000000;
    for(i=1; i<(1<<10); i++){
        ll z[n];
        memset(z, 0, sizeof z);
        for(k=0; k<10; k++)
        {
            if(i&(1<<k)){
                for(j=0; j<n; j++){
                    if(f[j][k])
                        z[j]++;
                }
            }
        }
   //     for(j=0; j<n; j++) cout<<z[j]<<" ";
        ll ans=0;
        for(j=0; j<n; j++)
                    ans+= p[j][z[j]];
        fl= max(fl, ans);
    }
    cout<<fl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, k;
    scanf("%d%d", &n,&k);
    int jwb = 1;
    for (int i=0; i<n; i++){
        if (jwb*2 < jwb+k){
            jwb*=2;
        }
        else{
            jwb+=k;
        }
    }
    printf("%d\n", jwb);
    return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
int main(){
  /*int N,M;
  long long K;
  cin>>N>>M>>K;
  long long A[200001],B[200001];
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<M;i++) cin>>B[i];
  A[N]=99999999999;
  B[M]=99999999999;
  int a=0;
  int b=0;
  int answer=0;
  while(K>0&&(a<N||b<M)){
    if(A[a]<B[b]){
     K-=A[a];
     a++;
    }
    else{
      K-=B[b];
      b++;
    }
    answer++;
  }
  if(K<0) answer--;
  cout<<answer<<endl;*/
  
  long long N;
  cin>>N;
  long long f[10000001];
  long long answer=1;
  for(int i=0;i<=N;i++) f[i]=1;
  for(int i=2;i<=N;i++){
    if(f[i]==1){
      f[i]=2;
      for(int j=2;j*i<=N;j++){
        int k=j;
        int l=2;
        while(k%i==0){
          k/=i;
          l++;
        }
        f[j*i]*=l;
      }
    }
    answer+=i*f[i];
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 81288
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int>B(0,0);
  for(int i=0; i<N-1; i++){
    int b;
    cin >> b;
    B.push_back(b);
  }
  int ans=B[N-2]+B[0], temp=B[N-2];
  for(int i=N-2; i>0; i--){
    ans+=min(B[i], B[i-1]);
  }
  cout << ans << endl;
}

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

int main()
{
	// 入力
	int a, b;
	cin >> a >> b;

	string buf[2];

	for( int i=0 ; i<b ; i++ )	buf[0] += to_string(a);
	for( int i=0 ; i<a ; i++ )	buf[1] += to_string(b);

	sort( buf, buf +2 );

	// 出力
	cout << buf[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int a[200000];
int main() {
    int n, k;
    while (scanf("%d %d",&n,&k)&&n!=0) {
        for (int i=0; i<n; i++) scanf("%d",&a[i]);
        int max=0;
        for (int i=0; i<k; i++) max+=a[i];
        int tmp=max;
        for (int i=0; i<n-k; i++) {
            tmp=tmp-a[i]+a[i+k];
            if (tmp>max) max=tmp;
        }
        printf("%d\n",max);
    }
    return 0;
}

Measured memory_bytes: 1420
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A = inputInt()
	B = inputInt()

	lst = [1,2,3]

	lst.remove(A)
	lst.remove(B)

	print(lst[0])


if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    # bit全探索
    # https://qiita.com/gogotealove/items/11f9e83218926211083a#%E4%BE%8B%E9%A1%8C-1
    L = input()
    L = [int(c) for c in L]



    n = len(L)-1
    # 昇順での探索だよ
    for i in range(2 ** n):
        ans=L[0]
        cnt=L[0]
        s=''

        """        
        10進数表記　2進数表記
        0           000
        1           001
        2           010
        3           011
        4           100
        5           101
        6           110
        7           111
        """

        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                cnt+=L[-j-1]
                s='+'+str(L[-j-1])+s
            else:
                cnt-=L[-j-1]
                s='-'+str(L[-j-1])+s

        if cnt==7:
            print(str(L[0])+s+'=7')
            break



resolve()

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

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  long long x;
  cin >> x;
  for (long long a = -1000; a <= 1000; a++) {
    for (long long b = -1000; b <= 1000; b++) {
      long long A = a * a * a * a * a * 1LL;
      long long B = b * b * b * b * b * 1LL;
      if (A - B == x) {
        cout << a << ' ' << b << '\n';
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3632
def main():
    while True:
        m, f, r = map(int, input().split())
        if m == f == r == -1:
            break
        total = m + f
        if m == -1 or f == -1:
            print('F')
        elif total >= 80:
            print('A')
        elif total >= 65:
            print('B')
        elif total >= 50:
            print('C')
        elif total >= 30:
            if r >= 50:
                print('C')
            else:
                print('D')
        else:
            print('F')
    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
from collections import defaultdict

def combi(m,n):
    child = 1
    mom = 1
    while n != 0:
        child *= m
        mom *= n
        m -= 1
        n -= 1
    return child//mom

def prime(N):
    se = [0,0,1]+[1]*(N-2)
    n = 2
    while n ** 2 <= N:
        if se[n]:
            nn = 2*n
            while nn <= N:
                se[nn] = 0
                nn += n
        n += 1

    return [x for x in range(0,N+1) if se[x]]

P = prime(31622)

N,M = map(int,input().split())

d = defaultdict(int)

for p in P:
    while not(M%p):
        M //= p
        d[p] += 1

if M != 1:
    d[M] += 1

ans = 1
for k,v in d.items():
    ans *= combi(N+v-1,v)
    ans %= 10**9+7

print(ans)

Measured memory_bytes: 3828
N, P = map(int, input().split())
A = map(int, input().split())

even = odd = 0

def fact(n):
    if n == 0: return 1
    return n * fact(n-1)

for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

odd_even = 0
for i in range(odd + 1):
    if i % 2 == 0:
        odd_even += fact(odd)/(fact(i)*fact(odd-i))

if P == 0:
    print(int(2**even * odd_even))
else:
    print(int(2**even * (2**odd - odd_even)))


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

int main(int argc, char const *argv[]) {
	int N , M , K;

	std::cin >> N >> M >> K;

	bool flag = false;

	int count = 0;
	for (size_t i = 0; i <= N; i++) {
		count = i * M;
		for (size_t j = 0; j <= M; j++) {
			if (count == K) {
				std::cout << "Yes" << '\n';
				flag = true;
				break;
			}
			count = count - i + (N-i);
		}
		if (flag) {
			break;
		}
	}
	if (!flag) {
		std::cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(i=1; i<=H; i++){
      for(j=1; j<=W; j++){
	if(i==1)printf("#");
	else if(i==H)printf("#");
	else if(j==1)printf("#");
	else if(j==W)printf("#");
	else printf(".");
	
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import sys

def solve():
    N, K = map(int, input().split())
    S = input()
    point = 0
    if S[0] == "R" and S[1] == "R": point += 1
    for i in range(1, N - 1):
        if S[i] == "L":
            if S[i-1] == "L": point += 1
        else:
            if S[i+1] == "R": point += 1
    if S[N-1] == "L" and S[N-2] == "L": point += 1

    print(min(N-1, point + 2 * K))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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

Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = [ int(i) for i in input().split() ]
at = 0
diff = 1e9
for i in range(len(h)):
    temp = t - h[i] * 0.006
    d = abs(a-temp)
    if d < diff:
        diff = d
        at = i+1
print(at)        


Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
	long long n,s;
	long long x;
	scanf("%lld",&n);
	x=n;
	while(x>0)
	{
		s+=x%10;
		x=x/10;
	}
	if(n%s==0)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;
    vll v(9);
    queue<int> q;
    int x,y,i;
    rep(i,1,9){q.push(i); v[i-1]=i;}
    while(v.size()<2e5)
    {
    	x=q.front(); q.pop(); 
    	i=x%10; y=x*10;
    	if(i!=0)
    	{
    		q.push(y+(i-1)); v.pb(y+(i-1));
    	}
    	q.push(y+i); v.pb(y+i);
    	if(i!=9)
    	{
    		q.push(y+i+1); v.pb(y+i+1);
    	}
    }
    int n;
    cin>>n;
    cout<<v[n-1];
        



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

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int>w(n);

    for(int i = 0; i < n; i++) {
        cin >> w[i];
    }
    vector<int>ans(n);
    for(int t = 0; t < n; t++) {
        int sa = 0;
        int sb = 0;
        for (int i = 0; i <= t; i++)
        {
            sa= sa + w[i];
        }
        for(int i = t+1; i < n; i++) {
            sb = sb + w[i];
        }
        if(sa >= sb){
            ans[t] = sa - sb;
        }
        
        else if (sa < sb){
             ans[t] = sb - sa;
        }
        
    }
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
 
 int main() {
        ff;
        ll n;
        cin>>n;
      
        ll ans=0;
        
        ll p[n+1]={0};
        for(ll i=1;i<=n;i++){
            for(ll j=i;j<=n;j+=i){
               ++p[j];
            }
        }
       
        
        for(ll i=1;i<=n;i++){
      
            ans+=i*(p[i]);
        }
        cout<<ans<<endl;
		
    return 0;
}

            
		
        
           
  


Measured memory_bytes: 81732
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <vector>
using ll = long long;

std::vector<int> vec;
std::priority_queue<int> pq;
int p;

int main() {
    int n, m;
    std::cin >> n >> m;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> p;
        pq.push(p);
    }
    for (int i = 0; i < m; i++) {
        int t = pq.top();
        int e = t / 2;
        pq.pop();
        pq.push(e);
    }
    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1276
def abc():
    s = input().rstrip()
    if s[0] != 'A':
        print('WA')
        return
    if s[2:-1].count('C') != 1:
        print('WA')
        return
    trimed = s.replace('A', '').replace('C', '')
    if trimed != trimed.lower():
        print('WA')
        return

    print('AC')


abc()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string N;
	cin>>N;
	if((N.at(0)==N.at(1)&&N.at(1)==N.at(2))
	 ||(N.at(2)==N.at(3)&&N.at(1)==N.at(2))){
		ce("Yes")
	}else{
		ce("No")
	}
	
}

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

int main() {
  int A,B,C; cin>>A>>B>>C;
  int alph=max(max(A,B),C);
  if(alph == A) cout << alph*10+B+C << endl;
  else if(alph == B) cout << alph*10+A+C << endl;
  else cout << alph*10+A+B << endl;
}


Measured memory_bytes: 256
use std::collections::HashMap;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n:usize,
        sn:[chars;n],
    }
    let mut v = vec![vec![0; n]; 26];
    for j in 0..n {
        for c in &sn[j] {
            v[(*c as u8 - 'a' as u8) as usize][j] += 1;
        }
    }
    let mut ans = String::new();
    for c in b'a'..b'z' + 1 {
        let c = char::from(c);
        let i = c as u8 - 'a' as u8;
        let count = *v[i as usize].iter().min().unwrap();
        ans.push_str(&vec![c; count].into_iter().collect::<String>());
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
// 逆に、全ての橋が壊れている状態から、一つづつ橋ができていった状態について調べる
//
#include <bits/stdc++.h>
using namespace std;

//https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
struct UnionFind {
    vector<int> data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    vector<long long> res(M);
    UnionFind Uset(N);
    res[M - 1] = (long long)N * (N - 1) / 2;
    for (int i = M - 1; i > 0; --i) {
        assert(i >= 0 && i < M);
        if (Uset.find(A[i]) != Uset.find(B[i])) {
            res[i - 1] = res[i] - (long long)Uset.size(A[i]) * Uset.size(B[i]);
        } else {
            res[i - 1] = res[i];
        }
        Uset.unite(A[i], B[i]);
    }
    for (auto &p : res) cout << p << endl;
    return 0;
}

Measured memory_bytes: 3328
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    x=int(input())
    h.append(x)

def check(t):
    c=0
    for i in range(n):
        c+=1+(max(0,h[i]-b*t)-1)//(a-b)
    return t>=c

l=0
r=3+max(h)//b
while r-l>1:
    mid=(r-l)//2+l
    if check(mid):
        r=mid
    else:
        l=mid
ans=l
if check(r):
    ans=r
print(ans)



Measured memory_bytes: 55512
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

ll arr[100005];
ll least[100005];
ll poss[100005];


ll solve(ll n)
{
	memset(least,0,sizeof least);
	memset(poss,0,sizeof poss);

	poss[0] = 1;

	for(ll i = 1; i <= n; i++)
	{
		poss[i] = (poss[i - 1] * 2);
		if(poss[i] >= (1e18)) poss[i] = 1e18;
	}

	ll ret = 0, sum = 0;

	for(ll i = n; i >= 0; i--)
	{
		least[i] = arr[i] + ((least[i + 1] + 1) / 2);

		if(least[i] > poss[i]) return -1;

		sum += arr[i];
	}

	ll nodes = 1;

	for(ll i = 0; i <= n; i++)
	{
		ret += min(nodes,sum);

		nodes -= arr[i];
		sum -= arr[i];

		nodes *= 2;

		if(nodes >= 1e18) nodes = 1e18;
	}

	return ret;
}
int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		for(i = 0; i <= n; i++) slld(arr[i]);

		ans = solve(n);

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


}





Measured memory_bytes: 6124
#include <stdio.h>
int main ()
{
        int number[4];
        scanf("%d %d %d %d %d", &number[0], &number[1], &number[2], &number[3], &number[4]);

        if (number[0]==0){
            printf("1");
        }
        else if (number[1]==0){
            printf("2");
        }
        else if(number[2]==0){
            printf("3");
        }
        else if (number[3]==0){
            printf("4");
        }
        else if (number[4]==0){
            printf("5");
        }
    return 0;
}


Measured memory_bytes: 1652
def resolve():
    n=int(input())
    d=list(map(int,input().split()))
    ss=sorted(d)
    ans=0
    if n%2==0:
        m=n//2-1
        if ss[m]==ss[m+1]:
            ans=0
        else:
            ans=ss[m+1]-ss[m]
    else:
        ans=0
    print(ans)
    
resolve()

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

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	int ans = 1;
	char now = str.at(0);
	for(int i=1; i<n; i++){
		if(str.at(i) == now){
			continue;
		}else{
			now = str.at(i);
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 512
#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(){
int a,b,c;
cin>>a>>b>>c;
int k;
cin>>k;
rep(i,k){
    if(b>=c){
    c=2*c;
    continue;
    }
    if(a>=b){
    b=2*b;
    continue;
    }

}
if(c>b&&b>a){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}

}

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

using namespace std;
typedef long long ll;

const int N = 3010;
double dp[N][N], p[N];
int n;

double solve(int v, int h) {
    if (v == n) {
        if (h >= (n + 1) / 2) return 1.0;
        else return 0.0;
    }
    if (dp[v][h] != -1.0) return dp[v][h];
    double v1 = p[v] * solve(v + 1, h + 1);
    double v2 = (1.0 - p[v]) * solve(v + 1, h);
    return dp[v][h] = v1 + v2;
}

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

    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < N; i++) fill_n(dp[i], N, -1.0);
    double ans = solve(0, 0);
    cout << fixed << setprecision(12) << ans;

	return 0;
}


Measured memory_bytes: 71296
import sys
sys.setrecursionlimit(100000)

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)][::-1]

par, sizes = [-1]*(n+1), [1]*(n+1)
def find(i):
    if par[i] < 0:
        return i
    else:
        par[i] = find(par[i])
        return par[i]

ans = [n*(n-1)//2]
for i in range(m-1):
    a, b = ab[i]
    pa, pb = find(a), find(b)

    if pa != pb:
        ans.append(ans[i] - sizes[pa]*sizes[pb])
        par[pa] = pb
        sizes[pb] += sizes[pa]
    else:
        ans.append(ans[i])
    # print(par, sizes)

for ans_ in ans[::-1]:
    print(ans_)

Measured memory_bytes: 44568
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=3123;
int n,dp[nmax],res;
char s[nmax];
void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    dp[1]=1;
    for(int i=2; i<=n; ++i){
        if(s[i-1]=='<'){
            int tmp=dp[1];
            dp[1]=0;
            for(int j=2,tmp2=0; j<=i; ++j){
                tmp2=dp[j];
                dp[j]=dp[j-1]+tmp;
                if(dp[j]>=MOD)dp[j]-=MOD;
                tmp=tmp2;
            }
        }
        else
            for(int j=i-2; j>0; --j)
                add(dp[j],dp[j+1]);
    }
    for(int i=1; i<=n; ++i)
        add(res,dp[i]);
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn=4e6+6;
const int mod=1e9+7;
typedef long long ll;
ll a[maxn];
int main()
{
	ll n,m,sum1,sum2;
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sum1=0;
	sum2=0;
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]>a[j])
			{
				sum1++;
			}
			else if(a[i]<a[j])
			{
				sum2++;
			}
		}
	}
	printf("%lld\n",((sum1%mod)*((m*(m+1)/2)%mod)%mod+(sum2%mod)*(m*(m-1)/2%mod)%mod)%mod);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}


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

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

    if (N % 2 == 0)
    {
        printf("%f", 0.5);
    }

    else
    {
        float f = (float)(N / 2 + 1) / N;
        printf("%f", f);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  int Q;
  cin >> Q;
  
  vector<vector<int>>BC(Q,vector<int>(2));
  for(int i=0;i<Q;i++){
    cin >> BC[i][0] >> BC[i][1];
  }
  
  vector<int>counter(100001,0);
  
  long long sum = 0;
  for(int i=0;i<N;i++){
    sum += A[i];
    counter[A[i]]++;
  }
  
  for(int i=0;i<Q;i++){
    sum += (BC[i][1] - BC[i][0]) * counter[BC[i][0]];
    cout << sum << endl;
    counter[BC[i][1]] += counter[BC[i][0]];
    counter[BC[i][0]] = 0;
  }
  
  return 0;
}


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

using namespace std;

#define rep(i,m,n) for(long i=m;i<n;i++)


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

    long res=0;
    long num=0;
  vector<long> h(n);
  cin >> h[0];
  rep(i,1,n) {
    cin >> h[i];
   
    if(h[i-1]>=h[i]) {
      res++;
    }
    else {
      num=max(num,res);
      res=0;
    }
    
    
  }
    num=max(num,res);
  
   cout << num << endl;
}

Measured memory_bytes: 1024
cnt = 0
def insertionSort(A, n, g):
    global cnt####スコープ指定
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and  A[j] > v:##後半の条件が付いていてもiを回すのでソートされる
            A[j+g] = A[j]
            j = j - g
            cnt+=1
            A[j+g] = v


def shellSort(A, n):
    tmp = 1
    G=[]
    while tmp<n:
        G.append(tmp)
        tmp*=3
        tmp+=1###なぜ要るのか分からないが
    G.reverse()
    for i in range(len(G)):
        insertionSort(A, n, G[i])

n = int(input())

G1=[]
tmp=1
while tmp<n:
    G1.append(tmp)
    tmp*=3
    tmp += 1
G1.reverse()
A1 =[int(input()) for _ in range(n)]
m = len(G1)
shellSort(A1, n)
print(max(m,1))
if G1:
    print(*G1)
else:
    print(1)
print(cnt)
for a in A1:
    print(a)





Measured memory_bytes: 45524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll mod = 1000000007;

ll pat(int n)
{
    if (n < 1)
    {
        return 1;
    }

    vll ari(n);
    vll nashi(n);
    ari[0] = 1;
    nashi[0] = 1;
    for (int i = 1; i < n; i++)
    {
        ari[i] = nashi[i - 1];
        nashi[i] = ari[i - 1] + nashi[i - 1];
    }

    return ari[n - 1] + nashi[n - 1];
}

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vvll dp(h + 1);
    dp[0] = vll(w + 2, 0);
    dp[0][1] = 1;

    map<int, ll> p;
    for (int i = -7; i < 8; i++)
    {
        p[i] = pat(i);
    }

    for (int i = 1; i <= h; i++)
    {
        dp[i] = vll(w + 2, 0);
        for (int j = 1; j <= w; j++)
        {
            dp[i][j] += dp[i - 1][j] * p[j - 2] * p[w - j - 1];
            dp[i][j] += dp[i - 1][j - 1] * p[j - 3] * p[w - j - 1];
            dp[i][j] += dp[i - 1][j + 1] * p[j - 2] * p[w - j - 2];
            dp[i][j] %= mod;
        }
    }

    cout << dp[h][k] << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
a = [input() for _ in range(n)]

min1 = 1000000
all_white = True
all_black = False
row_exist = [False for _ in range(n)]
row_white = [0 for _ in range(n)]

for i in range(n):
	cnt = 0
	for j in range(n):
		if a[i][j] == "#":
			cnt += 1
			row_exist[j] = True
	if cnt > 0:
		all_white = False
	if cnt == n:
		all_black = True
	row_white[i] = n - cnt

if all_white:
	print(-1)
	sys.exit()
if all_black:
	cnt = 0
	for i in range(n):
		for j in range(n):
			if a[j][i] == ".":
				cnt += 1
				break
	print(cnt)
else:
	ans = 0
	first_min = n
	for i in range(n):
		if row_exist[i]:
			first_min = min(first_min, row_white[i])
		else:
			first_min = min(first_min, row_white[i] + 1)
	ans += first_min
	cnt = 0
	for i in range(n):
		for j in range(n):
			if a[j][i] == ".":
				cnt += 1
				break
	ans += cnt
	print(ans)

Measured memory_bytes: 3316
N=int(input())
A=list(map(int,input().split(' ')))
skip=[0]*N
ans = abs(A[0])
for i in range(N):
    if i != N-1:
        ans += abs(A[i]-A[i+1])
    else:
        ans += abs(A[i])
    if  i==0:
        skip[i] = abs(A[i+1])
    elif i < N-1:
        skip[i]=abs(A[i-1]-A[i+1])
    else:
        skip[i] = abs(A[-2])
for i in range(N):
    if i==0:
        print(ans+skip[i]-abs(A[i])-abs(A[i]-A[i+1]))
    elif i==N-1:
        print(ans+skip[i]-abs(A[-1])-abs(A[-2]-A[-1]))
    else:
        print(ans+skip[i]-abs(A[i]-A[i-1])-abs(A[i+1]-A[i]))

Measured memory_bytes: 60508
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int gcd(int a, int b) { return a ? gcd(b%a ,a) : b;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi gcdL(n), gcdR(n);
    rep(i, n) {
        if (i == 0) {
            gcdL[i] = a[i];
        } else {
            gcdL[i] = gcd(a[i], gcdL[i-1]);
        }
    }
    for (int i = n-1; i >= 0; i--) {
        if (i == n-1) {
            gcdR[i] = a[i];
        } else {
            gcdR[i] = gcd(a[i], gcdR[i+1]);
        }
    }
    int ans = 0;
    rep(i, n) {
        if (i == 0) {
            chmax(ans, gcdR[i+1]);
        } else if (i == n-1) {
            chmax(ans, gcdL[i-1]);
        } else {
            chmax(ans, gcd(gcdL[i-1], gcdR[i+1]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,x;
	cin >> a >> b >> c >> d;
	if (c >= a && c - a <= d)
	{
		cout << "Yes" << endl;
	}else if(c <= a && a -c <= d){
		cout << "Yes" << endl;
	}else{
		if (a >=b)
		{
			x = a;
			a = b;
			b = x;
		}
		if (a >=c)
		{
			x = a;
			a = c;
			c = x;
		}
		if (b >=c)
		{
			x = b;
			b = c;
			c = x;
		}
		if (c-a <= d)
		{
			cout << "Yes" << endl;
		}else if(b-a <= d && c -b <= d){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> > ba;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        ba.push_back(make_pair(b,a));
    }
    sort(ba.begin(),ba.end());
    int l=ba[0].first-1,ans=1;
    for(int i=1;i<m;i++){
        if(l<ba[i].second){
            l=ba[i].first-1;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr int MOD = 1000000007;
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; }

VL prime_decomposition(ll n) {
	ll i = 2;
	VL table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace_back(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace_back(n);
		return table;
	}
}

int main() {
	ll a, b, n;
	cin >> a >> b >> n;

	bool flg = true;
	REP(i, n) {
		if (flg) {
			if (a % 2 == 0) {
				b += a / 2;
				a /= 2;
			} else {
				--a;
				b += a / 2;
				a /= 2;
			}
		}else {
			if (b % 2 == 0) {
				a += b / 2;
				b /= 2;
			} else {
				--b;
				a += b / 2;
				b /= 2;
			}
		}
		//cout << a << " " << b << endl;
		flg = (flg)?false:true;
	}
	cout << a << " " << b << endl;
}

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

using namespace std;

int main() {
    int a, b, c, k, res = 0;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    if (k >= a) res += a, k -= a;
    else res += k, k = 0;

    if (k >= b) k -= b;
    else k = 0;

    if (k >= c) res -= c, k -= c;
    else res -= k, k = 0;

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

Measured memory_bytes: 3828
#include <bits/stdc++.h>
    using namespace std;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    
/*.....................................................................................................................*/

    const ll man=(ll)2e5+5,mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

/*........................................................................................................................*/

signed main()
{
    fast;
    ll a=0;
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    For(i,n)
    {
        if(s[i]!=t[i])a++;
    }
    cout<<a<<endl;
}

Measured memory_bytes: 3788
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt(); sc.nextLine();
		// スペース区切りの整数の入力
		String[] p = new String[n];
		String[] q = new String[n];
		String[] c = new String[n];
		int[] s = new int[n];
		int[] t = new int[n];
		int[] f = {1, 1, 2, 6, 24, 120, 720, 5040};

		p = sc.nextLine().split(" ");
		q = sc.nextLine().split(" ");

		for ( int i=0; i<n; i++ ) {
			c[i] = String.valueOf(i+1);
		}

		per(p, s, c);
		per(q, t, c);

		int df = 0;

		for ( int i=0; i<n-1; i++ ) {
			df = df + ( (s[i]-t[i]) * f[n-i-1] );
		}
		df = Math.abs(df);

		// 出力
		System.out.println(df);
	}

	private static void per(String[] ary, int[] pos, String[] cst){
		String gai = "";
		for ( int j=0; j<ary.length; j++ ) {
			int ps = 0;
			for ( int k=0; k<cst.length; k++ ) {
				if ( gai.contains(cst[k]) ) {
				} else {
					ps++;
					if ( cst[k].equals(ary[j]) ) {
						pos[j] = ps;
						gai = gai.concat(ary[j]);
						continue;
					}
				}
			}
		}
	}
}



Measured memory_bytes: 23764
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T=input()
count=0
RSP={"r" : P, "s" : R, "p" : S}
check=[0 for j in range(N)]
for i in range(N):
    if i<K:
        count+=RSP[T[i]]
        check[i]=1
    else:
        if T[i]!=T[i-K]:
            count+=RSP[T[i]]
            check[i]=1
        else:
            if check[i-K]==0:
                count+=RSP[T[i]]
                check[i]=1
print(count)

Measured memory_bytes: 4212
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a, 
              const pair<int,int> &b) 
{   
    if(a.ff == b.ff){
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff); 
}

int32_t main()
{
    // IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int a,b;
    cin >>  a >> b;
    int cnt = 0;
    for(int i=0;i<2;i++){
        if(a > b){
            cnt += a;
            a--;
        }
        else{
            cnt+=b;
            b--;
        }
    }
    cout << cnt;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}
long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}







int main(){
  int n; cin >> n;
    string S[n];
    for(int i=0; i<n; i++) cin >> S[i];
 
    string ans="";
    for(char c='a'; c<='z'; c++){
        int cnt=50;
        
        for(int i=0; i<n; i++){
 
            int tmp=0;
            for(int j=0; j<S[i].size(); j++){
                if(S[i][j]==c) tmp++;
            }
            cnt=min(cnt,tmp);
        }
        
        for(int i=0; i<cnt; i++) ans+=c;
    }
 
    cout << ans << endl;

}



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

using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define lim 100010
#define mod 1e9+7
#define INF 1e9
#define REP(i,n) for(int i=0;i<n;i++)

int main() {
    int N;
    scanf("%d",&N);
    char S[10001];
    scanf("%s", S);
    for (int i = 0; i < strlen(S); i++){
        if(S[i]+N > 90){
            printf("%c", S[i] + N - 26);
        }else{
            printf("%c", S[i] + N);
        }
        
    }

        return 0;
}

Measured memory_bytes: 384