akhauriyash/Code-Regression huggingface dataset:
// Problem : C - XYZ Triplets
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define plii pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
int cal(int x,int y,int z)
{
	return x*x+y*y+z*z+z*y+x*y+z*x;
}
mlli ans;
void init()
{
	for(int i=1;i<100;i++){
		for(int j=1;j<100;j++){
			for(int k=1;k<100;k++){
				int temp=cal(i,j,k);
				if(temp>10000)break;
				else ans[temp]++;
			}
		}
	}
}
void solve(){
	int  n;
	rd(n);
	rep(i,1,n+1){
		pp(ans[i]);
	}
	return;	
}


int32_t main() {
    // fint{
    	init();
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 4172
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        news=[]
        p=self._parents
        y=p[x]
        while y>=0:
            news.append(x);x,y=y,p[y]
        if len(news)!=1:
            for P in news:p[P]=x
        return x

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
n,m=map(int,input().split())
uf=UnionFind(n,1)
for i in range(m):
    a,s=map(int,input().split())
    uf.unite(a,s)
print(uf.group_count()-1)

Measured memory_bytes: 10800
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;
#define PI acos(-1)
int main()
{

      int t=1;

     while(t--){

        ll n,m;
        ll a, b, c;
        cin >>a>>b>>c;
        ll r = c - (a+b);
        if(a+b>=c){
            cout << "No" << endl;continue;
        }
        r = r*r;

         if(4*a*b<r){
            cout << "Yes" << endl;
         }
         else cout << "No" << endl;

     }

    return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())

    count = 0
    for i in range(1, N+1, 2):
        tmp = 0
        for j in range(1, i+1):
            if i%j == 0:
                tmp += 1
        if tmp == 8:
            count += 1
    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	string a,b,c; cin>>a>>b>>c;
	if(a[a.size()-1]==b[0] and b[b.size()-1]==c[0]) cout<<"YES";
	else cout<<"NO";
}


Measured memory_bytes: 3576
#include <stdio.h>

int main()
{
    int n;
    int cards[4][13];
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            cards[i][j] = 0;
        }
    }
    char s[4] = {'S', 'H', 'C', 'D'};

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        char mark;
        int number;
        scanf(" %c %d", &mark, &number);
        for (int j = 0; j < 4; j++)
        {
            if (s[j] == mark)
                cards[j][number - 1] = 1;
        }
    }

    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 13; j++)
            if (!cards[i][j])
            {
                printf("%c %d\n", s[i], j + 1);
            }
    }

    return 0;
}


Measured memory_bytes: 2736
// ABC171 B
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int N, K;  //N種類がp円で売られている。K種類買う
  cin >> N >> K;
  int sum = 0;
  
  vector<int> price(N);
  for (int i = 0; i < N; i++){
    cin >> price.at(i);
  }

  // Main loop
  // 価格でソート
  sort(price.begin(), price.end());
  for (int i = 0; i < K; i++){
    sum += price.at(i);
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005

ii a[MAXN];

int main()
{
    _io
    int n, k; cin >> n;
    FOR(i, 1, n)
    {
        cin >> a[i].fi;
        a[i].se = i;
    }
    sort(a+1, a+1+n);
    FOR(i, 1, n)
        cout << a[i].se << ' ';
}


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

# i個のカードまで使って和がjの組み合わせ
dp = [[0 for i in range(50*50+1)] for j in range(51)]
dp[0][0] = 1

for i in range(n):
    for j in range(n-1, -1, -1):
        for k in range(50*50+1):
            if k+xl[i] < 50*50+1:
                dp[j+1][k+xl[i]] += dp[j][k]
ans = 0
for i in range(1,n+1):
    ans += dp[i][i*a]

print(ans)


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	ll N, M, ans;
	
	cin >> N >> M;
	
	if(M >= 2 * N){
		ans = N;
		M -= N * 2;
	}else{
		ans = M / 2;
		M = 0;
	}
	
	if(M >= 4)
		ans += M / 4;
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, d int
	fmt.Fscan(r, &n, &d)

	dist := func(x, y int) float64 {
		return math.Sqrt(float64(x*x + y*y))
	}

	var ans int
	for i := 0; i < n; i++ {
		var x, y int
		fmt.Fscan(r, &x, &y)
		if dist(x, y) <= float64(d) {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6020
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

N=int(input())
lst=list(map(int,input().split()))
average=Decimal(str(sum(lst)/len(lst))).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
_lst=[(i-average)**2 for i in lst]
print(sum(_lst))

Measured memory_bytes: 5204
N = int(input())
A = [int(i) for i in input().split()]

q = max(A)
p = q//2
tmp = p+1
for i in range(N):
    if q != A[i]:
        if tmp > abs(A[i]-p):
            tmp = abs(A[i]-p)
            ans = A[i]

print(q, ans)


Measured memory_bytes: 14064
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	ll n ,x , t;
	cin >> n >> x >> t ;
	if( n%x==0){
		cout << (n/x)*t << endl;
	}
	else cout <<(n/x+1)*t << endl;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


vector<vector<char>> a(1005, vector<char>(1005, ' '));
vvll dp(1005, vll(1005, 0));

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

    rep(i, H) {
        rep(j, W) {
            cin >> a[i + 1][j + 1];
        }
    }
    dp[1][1] = 1;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (a[i][j] == '#') continue;
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;

        }
    }

    cout << dp[H][W] << endl;
}

Measured memory_bytes: 9216
import unittest

class TestFunc(unittest.TestCase):
    def test_1(self):
        self.assertEqual(fun(5,8,[50,30,40,10,20]),2)
	self.assertEqual(fun(3,2,[100,50,200]),1)
        self.assertEqual(fun(10,100,[7,10,4,5,9,3,6,8,2,1]),2)
        self.assertEqual(fun(5,2,[1,2,3,2,4]),1)

def fun(n,t,a):
    aa = []
    b = None
    s = None
    for i in range(n):
	if b!=None:
            if s==None:
		if b<a[i]:
                    s = a[i]
                else:
                    b = a[i]
            elif s<=a[i]:
                s = a[i]
            elif s>b:
                aa.append(s-b)
		if b>a[i]:
                    b = a[i]
		s = None
	else:
            b = a[i]

    if b!=None and s!= None and s-b>0:
	aa.append(s-b)

    c = aa[0]
    ans = 1
    for i in range(1,len(aa)):
	if c<aa[i]:
            c = aa[i]
            ans = 1
	elif c==aa[i]:
            ans += 1

    return ans


if __name__=='__main__':
    #unittest.main()                                                                                                                                                              

    n,t = [int(x) for x in raw_input().split(" ")]
    a = [int(x) for x in raw_input().split(" ")]
    print(fun(n,t,a))


Measured memory_bytes: 12992
# -*- coding: utf-8 -*-
#ARC65C
import copy
import sys
#import math

tmp = int(input())

ans=0
if(tmp==100000):
	ans=90909
elif(tmp>=10000):
	ans+=tmp-9999
	ans+=900
	ans+=9
elif(tmp>=1000):
	ans+=900
	ans+=9
elif(tmp>=100):
	ans+=tmp-99
	ans+=9
elif(tmp>=10):
	ans+=9
else:
	ans+=tmp

print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum;

int main()
{
	fast;
	cin>>n>>m;
	for(int i=m-n+1;i<=m-1;i++)
		cout<<i<<sp;
	fo(i,m,n+m-1)
	cout<<i<<sp;



}



/*     cd onedrive\desktop\kod
cls


*/

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

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

    string s,t;
    cin >> s >> t;

    int n = t.size(), m = s.size(); 
  
    int ans = INT_MAX; 
  
    // Traverse the string S2 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
  
        // From every index in S2, check the number of 
        // mis-matching characters in substring of 
        // length of S1 
        for (int j = 0; j < n; j++) { 
            if (t[j] != s[i + j]) { 
                minRemovedChar++; 
            } 
        } 
  
        // Take minimum of prev and current mis-match 
        ans = min(minRemovedChar, ans); 
    } 

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 3560
lines = readlines(chomp: true).map{|line| line.split(' ')}
n = lines[0][0].to_i
d = lines[0][1].to_i

count = 0
(1).upto(n) do |i|
	point = lines[i]
	s = Math.sqrt(point[0].to_i**2 + point[1].to_i**2)
	if (s <= d) then
		count = count + 1
	end
end

print count
return

Measured memory_bytes: 55740
from collections import Counter
S = [i for i in str(input())]
c = Counter(S)
m = c.most_common()

n = len(S) // 3
if len(S) == 1:
  print('YES')
elif len(S) == 2:
  if len(m) == 2:
    print('YES')
  else:
    print('NO')
elif len(m) < 3:
  print('NO')
else:
  if len(S) % 3 == 0:
    if (m[0][1]==n) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  elif len(S) % 3 == 1:
    if (m[0][1]==n+1) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  else:
    if (m[0][1]==n+1) and (m[1][1]==n+1) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')

Measured memory_bytes: 10096
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  if(500*n>=m){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
}

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

const int N = 2e5 + 10;
int a[N], n;
long long ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if(a[0] != 0)
		return cout << -1, 0;
		
	for (int i = 1; i < n; i++)
		if(a[i + 1] > a[i] + 1)
			return cout << -1, 0;
	
	for (int i = 1; i < n; i++){
		if(a[i] == a[i - 1] + 1)
			ans++;
		else
			ans += a[i];
	}
	
	cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<ll> C(N - 1), S(N - 1), F(N - 1);
  REP(i, N - 1)
  cin >> C[i] >> S[i] >> F[i];
  REP(i, N)
  {
    ll t = 0;
    for (int j = i; j < N - 1; j++)
    {
      if (t < S[j])
        t = S[j];
      else
      {
        if (t % F[j] != 0)
          t = t - (t % F[j]) + F[j];
      }
      t += C[j];
    }
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll moddiv(ll lcm, ll a, ll M){
    return lcm * modinv(a, M) % M;

}

ll modpow(int a, int b) {
  ll ans = 1;
  ll x = a;
  int y = b;
  while (y) {
    if (y & 1) {
      ans *= x;
      ans %= MOD;
    }
    x *= x;
    x %= MOD;
    y >>= 1;
  }
  return ans;
}

int main(){
    int N, A[10000], c[1000001] = {};
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        int x = A[i];
        for (int j = 2; j * j <= x; j++) {
            int e = 0;
            while (x % j == 0) {
                x /= j;
                e++;
            }
            c[j] = max(c[j], e); //今までループしたAiのと今のAiで因数の個数を比べる
        }
        if (x > 1) { //ここに引っかかるのは素数の場合
            c[x] = max(c[x], 1);
        }
    }

    ll lcm = 1;
    for (int i = 2; i <= 1000000; i++) {
        if (c[i] > 0) {
            lcm *= modpow(i, c[i]);
            lcm %= MOD;
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += moddiv(lcm, A[i], MOD);
        ans %= MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 4224
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define xrange(i, a, b) for(int i=(a); i<=(b); ++i)
#define rrange(i, a, b) for(int i=(a); i>=(b); --i)
#define read(i) scanf("%d", &i);

using namespace std;

int main() {

   	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

#ifdef LOCAL_DEFINE
    freopen("in", "rt", stdin);
#endif

    // solution Here
    int n, A, B; cin >> n >> A >> B;

    int res = abs(A - B) - 1;

    if(res & 1){
        cout << "Alice" << endl;
    }

    else cout << "Borys" << endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << #x << " = " << x << endl

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n, l;
	cin >> n >> l;
	string s[n];
	for(int i=0; i<n; i++)
		cin >> s[i];
	sort(s, s+n);
	for(int i=0; i<n; i++)
		cout << s[i];
	cout << '\n';
	
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    ll h[n];
    ll ans,count;
    ans = count = 0;
    for(int i = 0;i < n;i++){
        cin >> h[i];
        if(i > 0 && h[i] <= h[i-1]){
            count++;
        }else{
            ans = max(ans,count);
            count = 0;
        }
    }
    ans = max(ans,count);
    cout << ans << endl;
    //cin >> n;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
m_root=int(m**0.5)
div_l=[]
ans=0

for i in range(1,m_root + 1):
    if m%i == 0:
        div_l.append(i)
        div_l.append(m//i)

if m//n in div_l:
    ans = m//n
else:
    div_l.append(m//n)
    div_l.sort()
    ans = div_l[div_l.index(m//n) - 1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int k, x;
	cin >> k >> x;
	yorn(500 * k >= x);
	return 0;
}

Measured memory_bytes: 256
x,y,z,k = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

AB = []
for a in A:
	for b in B:
		AB.append(a+b)

AB.sort(reverse=True)
C.sort(reverse=True)

#print(AB)
#print(C)

ABC = []

if len(AB) < k:
	p = len(AB)
else:
	p = k

if len(C) < k:
	q = len(C)
else:
	q = k

for i in range(p):
	for j in range(q):
		ABC.append(AB[i]+C[j])

ABC.sort(reverse=True)
#print(ABC)

for i in range(k):
	print(ABC[i])

Measured memory_bytes: 158940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	cout <<(X - A) % B << endl;
}

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

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

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N)cin >> A[i];
	sort(A.begin(), A.end());

	ll res = 0;
	vector<pair<ll, ll>> way;
	if (A.front() <= 0 && 0 <= A.back()) {
		ll minus = A.front();
		ll plus = A.back();
		FOR(i, 1, N - 1) {
			if (A[i] >= 0) {
				way.push_back({ minus,A[i] });
				minus -= A[i];
			}
			else {
				way.push_back({ plus,A[i] });
				plus -= A[i];
			}
		}
		way.push_back({ plus,minus });
		res = plus - minus;
	}
	else if (0 < A.front()) {
		way.push_back({ A.front(), A[N - 2] });
		ll minus = A.front() - A[N - 2];
		ll plus = A.back();
		FOR(i, 1, N - 2) {
			way.push_back({ minus, A[i] });
			minus -= A[i];
		}
		way.push_back({ plus,minus });
		res = plus - minus;
	}
	else {
		way.push_back({ A.back(), A[1] });
		ll minus = A.front();
		ll plus = A.back() - A[1];

		FOR(i, 2, N - 1) {
			way.push_back({ plus,A[i] });
			plus -= A[i];
		}
		way.push_back({ plus,minus });
		res = plus - minus;
	}

	cout << res << endl;
	for (auto p : way)cout << p.first << " " << p.second << endl;
	return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
int h,w,a[60][60];
int check[60][60],d[60][60];
int dx[4] = {0,1,0,-1},dy[4] = {1,0,-1,0};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    int cnt = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char tmp;
            cin >> tmp;
            if(tmp=='#'){ a[i][j] = 1;cnt++;}
            d[i][j] = 100000;
        }
    }
    if(a[0][0]){
        cout << "-1" << '\n';
        return 0;
    }
    d[0][0] = 0;
    priority_queue<pair<int,pair<int,int> > > q;
    q.push(mp(0,mp(0,0)));
    while(!q.empty()){
        auto x = q.top();
        q.pop();
        int cx = x.second.first;
        int cy = x.second.second;
        if(check[cx][cy]) continue;
        check[cx][cy] = 1;
        for(int i=0;i<4;i++){
            int tmpx = cx+dx[i];
            int tmpy = cy+dy[i];
            if(tmpx>=0 && tmpx<h && tmpy>=0 && tmpy<w){
                if(d[tmpx][tmpy]>(d[cx][cy]+1) && !a[tmpx][tmpy]){
                    d[tmpx][tmpy] = d[cx][cy]+1;
                    q.push(mp(-d[tmpx][tmpy],mp(tmpx,tmpy)));
                }
            }
        }
    }
    if(d[h-1][w-1]>=100000) cout << "-1" << '\n';
    else cout << (h*w-d[h-1][w-1]-cnt-1) << '\n';
    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let c: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut xv = vec![a, b, c];
    xv.sort();
    let s1 = xv[2] - xv[1];
    let s2 = (xv[2] - (xv[0] + s1)) / 2;
    let s3 = if (xv[2] - (xv[0] + s1)) % 2 == 0 {
        0
    } else {
        2
    };
    let ans = s1 + s2 + s3;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

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

int main() {
  int n, sx;
  scanf("%d %d", &n, &sx);
  int g = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    g = gcd(g, abs(sx - x));
  }
  printf("%d\n", g);
}


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

#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()

using LL   =  long long;
using pii  =  pair <int, int>;
using vii  =  vector <pii>;

const int INF = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n, tot, x, y, z;
    cin>>n>>tot;

    for(x = 0; x <= n; x++)
    {
        for(y = 0; y <= n; y++)
        {
            z = n - (x+y);
            if(z >= 0 and 10000*x + 5000*y + 1000*z == tot)
            {
                cout<<x<<" "<<y<<" "<<z<<" ";
                return 0;
            }
        }
    }

    cout<<"-1 -1 -1\n";
    return 0;
}


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

const int maxn=1e5+100;
const int MOD=1e9+7;

typedef long long ll;

ll dpc[maxn],dp1[maxn],dp2[maxn],dp3[maxn];
string s;
char c[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin>>s;
	for(int i=1;i<=(int)s.size();i++) c[i]=s[i-1];
	int n=(int)s.size();
	dpc[0]=1;
	for(int i=1;i<=n;i++){
		if(c[i]=='?') dpc[i]=(dpc[i-1]*3)%MOD;
		else dpc[i]=dpc[i-1];
	}
	for(int i=1;i<=n;i++){
		if(c[i]=='?') dp1[i]=(dp1[i]+dp1[i-1]*3)%MOD;
		else dp1[i]=(dp1[i]+dp1[i-1])%MOD;
		if(c[i]=='A'||c[i]=='?') dp1[i]=(dp1[i]+dpc[i-1])%MOD;
	}
	for(int i=1;i<=n;i++){
		if(c[i]=='?') dp2[i]=(dp2[i]+dp2[i-1]*3)%MOD;
		else dp2[i]=(dp2[i]+dp2[i-1])%MOD;
		if(c[i]=='B'||c[i]=='?') dp2[i]=(dp2[i]+dp1[i-1])%MOD;
	}
	for(int i=1;i<=n;i++){
		if(c[i]=='?') dp3[i]=(dp3[i]+dp3[i-1]*3)%MOD;
		else dp3[i]=(dp3[i]+dp3[i-1])%MOD;
		if(c[i]=='C'||c[i]=='?') dp3[i]=(dp3[i]+dp2[i-1])%MOD;
	}
	cout<<dp3[n]<<endl;
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int r;
  cin >> r;
  print(3 * r*r);
  
  
    
 return 0;
}


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

using namespace std;
int a[200050],n,k;
bool check(int mid)
{
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>mid) ans+=a[i]/mid;
		if(ans>k) return 0;
	}
	return 1;
}
int main()
{
	
	cin>>n>>k;
	int l=1,r=-1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		r=max(a[i],r);
	}
	int ans=0;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		{
			r=mid-1;
			ans=mid;
		}
		else l=mid+1;
	}
	cout<<ans;
	return 0;
} 


Measured memory_bytes: 4280
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

use proconio::input;

fn bound<F: Fn(isize) -> bool>(min: isize, max: isize, f: F) -> isize {
    let mut ok = min;
    let mut ng = max;
    while (ng - ok).abs() > 1 {
        let mid = (ok + ng) / 2;
        if f(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok
}

fn main() {
    input! {
        n: usize,
        k: isize,
        mut a: [isize; n],
    }
    let ans = bound(1000000000, 0, |x| {
        let cnt: isize = a.iter().map(|y| (y + x - 1) / x - 1).sum();
        cnt <= k
    });
    println!("{}", ans);
}


Measured memory_bytes: 5368
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    char arr[10000];
    int sum =0;
    int i;
    scanf("%s",arr);
    for(i = 0;i < strlen(arr)/2;i++){
        if(arr[i]!=arr[strlen(arr)-i-1]){
            sum++;
            //cout<<arr[i]<<' '<<arr[strlen(arr)-i-1]<<endl;
        }
    }
    cout<<sum;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N;

int q(vint v){
    cout<<"?";
    rep(i,v.size())cout<<" "<<v[i]+1;
    cout<<endl;
    string s;cin>>s;
    if(s=="Red")return 1;
    return 0;
}

signed main(){
    cin>>N;

    vint v(N);
    iota(all(v),0);

    int ql=q(v);
    int qr=ql^1;

    int l=0;
    int r=N;
    while(r-l>1){
        int mid=(l+r)/2;
        iota(all(v),mid);
        if(q(v)==ql)l=mid;
        else r=mid;
    }

    vint ans(2*N);
    iota(all(v),r);
    for(int i=0;i<r;i++){
        v[N-1]=i;
        ans[i]=q(v);
    }

    for(int i=r+N-1;i<2*N;i++){
        v[N-1]=i;
        ans[i]=q(v);
    }

    v.clear();
    for(int i=0;i<l;i++)v.pb(i);
    for(int i=r+N;i<2*N;i++)v.pb(i);
    v.pb(-1);
    for(int i=r;i<r+N-1;i++){
        v[N-1]=i;
        ans[i]=q(v);
    }

    cout<<"! ";
    rep(i,ans.size()){
        if(ans[i])cout<<"R";
        else cout<<"B";
    }
    cout<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 85 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ii M[MAX][MAX];
int st[MAX][MAX][3*MAX*MAX];

ll solve(int H, int W)
{
    memset(st, 0, sizeof st);

    int diff = abs(M[1][1].first - M[1][1].second);

    st[1][1][diff] = 1;

    for (int i = 1; i <= H; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            for (int d = 0; d < 2*MAX*MAX; ++d)
            {
                if (st[i][j][d] == 0)
                    continue;

                if (i < H)
                {
                    int diff = abs(M[i + 1][j].first - M[i + 1][j].second);

                    st[i + 1][j][d + diff] = 1;
                    st[i + 1][j][abs(d - diff)] = 1;
                }

                if (j < W)
                {
                    int diff = abs(M[i][j + 1].first - M[i][j + 1].second);

                    st[i][j + 1][d + diff] = 1;
                    st[i][j + 1][abs(d - diff)] = 1;
                }
            }
        }
    }

//    for (int i = 1; i <= H; ++i)
//        for (int j = 1; j <= W; ++j)
//            for (int d = 0; d < 2*MAX*MAX; ++d)
 //               if (st[i][j][d])
  //                  cout << "(" << i << ", " << j << ") = " << d << endl; 
    int ans = 2*MAX*MAX;

    for (int d = 0; d < 2*MAX*MAX; ++d)
        if (st[H][W][d])
        {
            ans = d;
            break;
        }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            cin >> M[i][j].first;

    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            cin >> M[i][j].second;

    auto ans = solve(H, W);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 612096
#include <bits/stdc++.h>
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0), cout.tie(0)
using namespace std;
#define ll long long
const int mod = 1'000'000'007;
int main()
{
	fastio;
	string s;
	cin>>s;
	int l=s.size();
	if(s[l-1]!='s')cout<<s<<'s'<<'\n';
	else cout<<s<<"es"<<'\n';
	return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  int c = 0;
  while (n--) {
    int d, dd;
    cin >> d >> dd;
    if (d == dd) {
      ++c;
      if (c == 3) {
        cout << "Yes";
        return 0;
      }
    } else c = 0;
  }
  cout << "No";

  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100010;
int a[maxn];
int n,num=0,ex=0;
long long sum=0;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
bool pan(){
	int g=0,num=0;sum=0;
	for(int i=1;i<=n;i++){
		sum+=a[i]-1;
		if(a[i]&1) num++;
		if(a[i]==1) ex=1;
	}
	if(ex==1) return sum%2;
	if((n-num)&1) return 1;
	if(num==1){
		for(int i=1;i<=n;i++)
		if(a[i]&1) a[i]--;
		for(int i=1;i<=n;i++)
		g=gcd(g,a[i]);
		for(int i=1;i<=n;i++)
		a[i]=a[i]/g;
		return pan()^1;
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	if(pan()) puts("First");
	else puts("Second"); 
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int a,b;
    cin>>a>>b;
    cout<<(max(max((a+b),(a-b)),(a*b)));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b;
	double c;
	double d;
	cin >> a >> b;
	c = (a + b) / 2.0;
	cout << ceil(c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
int H,W;
int ans=100000;
vector<string> field;
bool seen[110][110];
void dfs(int h,int w){
    string s;
    seen[h][w]=true;
    if(field[0][0]=='#') s+='a';
    for(int dir=0; dir<4;dir++){
        int nh=h+dx[dir];
        int nw=w+dy[dir];

        if(nh<0 || nh>=H ||nw<0 || nw>=W) continue;
        if(field[nh][nw]=='#'){
            s+='a';
           
        }
        if(seen[nh][nw]) continue;

        dfs(nh,nw);
       
    } 
    
    if(s.size()<ans) ans=s.size(); 
}


int main(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n, m;
vector<pair<int, int>> key;

//inputします
void input() {
	cin >> n >> m;
	key.resize(m);
	ff(i, 0, m) {
		cin >> key[i].first >> key[i].second;
	}
}

//ライブラリ置き場



//main
int main() {
    input();
	int l = 1;
	int r = n;
	int ans = r-l + 1;
	ff(i, 0, m) {
		l = max(key[i].first, l);
		r = min(key[i].second, r);
		ans = r-l + 1;
		if (r - l < 0) {
			ans = 0;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    string str, ans;

	cin >> str;

	if (str == "Sunny") {
		ans = "Cloudy";
	} else if (str == "Cloudy") {
		ans = "Rainy";
	} else {
		ans = "Sunny";
	}

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

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

Measured memory_bytes: 588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
	string s;
	cin >> s;
	int cnt_1 = 0;
	int cnt_0 = 0;
	rep(i,s.size()) {
		if(s[i] == '1') cnt_1++;
		else ++cnt_0;
	}
	int ans = min(cnt_0,cnt_1)*2;
	cout << ans << endl;
	
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int h,w;cin>>h>>w;
  REP(i,h){
  	string s;cin>>s;
    cout<<s<<endl;
    cout<<s<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	bool flag=true;
	while(n--)
	{
		int x;
		cin>>x;
		if(!(x&1))
		{
			if(x%3==0 || x%5==0)
			{
				continue;
			}
			flag=false;
		}
	}
	if(flag)
	cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){
    
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i+=2){
        ll cnt = 0;
        for(ll j = 1; j <= i; j++){
            if(i % j == 0)cnt++;
        }
        if(cnt == 8)ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

#define M 1000'000'007
int s;
ll dp[2009][2009];

int main() {
    scanf("%d", &s);
    reps(i, s) repc2(j, 3, s) dp[i][j] = (1 + dp[i][j - 3] + dp[i][j - 1]) % M;
    printf("%lld\n", (dp[s][s] - dp[s][s - 1] + M) % M);
    return 0;
}

Measured memory_bytes: 35220
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    set <int> have[26];
    for (int i = 0; i < n; i++) {
        have[s[i] - 'a'].insert(i);
    }
    int q, t, l, r;
    cin >> q;
    char c;
    while (q--) {
        cin >> t >> l;
        --l;
        if (t == 1) {
            cin >> c;
            have[s[l] - 'a'].erase(l);
            s[l] = c;
            have[c - 'a'].insert(l);
        }
        else {
            cin >> r;
            --r;
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                auto it = have[i].lower_bound(l);
                if (it != have[i].end() && *it <= r) ++ans;
            }
            cout << ans << '\n';
        }
    }
}


Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
vector<int>g[200009];
int n,q,counter[200009];
void dfs(int p,int s) {
	for(int i=0;i<g[s].size();i++)
		if(g[s][i]!=p) {
			counter[g[s][i]]+=counter[s];
			dfs(s,g[s][i]);
		}
}
int main() {
	scanf("%d%d",&n,&q);
	int x,y;
	for(int i=0;i<n-1;i++) {
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i=0;i<q;i++) {
		scanf("%d%d",&x,&y);
		counter[x]+=y;
	}
	dfs(-1,1);
	for(int i=1;i<=n;i++) printf("%d ",counter[i]);
	return 0;
}

Measured memory_bytes: 26624
from collections import defaultdict
from bisect import bisect_left, bisect, insort_left, insort
INF = 10000
def lcs(s1, s2):
    c = defaultdict(list)
    for i, s in enumerate(s1):
        c[s].append(i)
    for s in set(s2):
        c[s].append(INF)
    def g(li, a):
        for i in li:
            if i >= a:
                return i
        return -1
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx == INF:
                break
            dp[i] = min(cur_idx, chr_idx + 1)
            bgn_idx = cur_idx
        else:
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx != INF:
                dp.append(chr_idx + 1)
    return len(dp)
def solve():
    N = int(input())
    for _ in range(N):
        x = input()
        y = input()
        print(lcs(x, y) if len(x) > len(y) else lcs(y, x))
solve()



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

int main(void){
  while(1){
    int stone[50];
    for(int k = 0 ; k < 50 ; k++){stone[k] = 0;}

    int bowl;
    int n, p;  // n???????£?????????°???p????°????????????°
    cin >> n;
    cin >> p;

    if(n == 0 && p == 0){return 0;}

    bowl = p;

    bool flg = true;
    int i;
    int ans;

    for(i = 0 ; flg ; i = (i+1) % n){

      if(bowl == 0){
        bowl = bowl + stone[i];
        stone[i] = 0;
      }else{
        stone[i] ++;
        bowl--;
      }

      if(bowl == 0){
        for(int j = 0 ; j < n ; j++){
          if(stone[j] == p){
            flg = false;
            ans = j;
          }
        }
      }

    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3012