akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll a;
	char b[5];
	scanf("%ld %s", &a, b);
	printf("%ld\n", a * (b[0] - '0') + a * (10*(b[2] - '0') + b[3] - '0') / 100);
	return 0;
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に

int main()
{
    ll N; cin >> N;
    VI A(N);
    rep(i,N){
        cin >> A.at(i);
    }
    ll ans=0;
    ll sum=0;
    sum+=abs(A.at(0));
    sum+=abs(A.at(N-1));
    rep(i,N-1){
        sum+=abs(A.at(i)-A.at(i+1));
    }
    rep(i,N){
        if(i==0){
            cout << sum-abs(A.at(0))-abs(A.at(1)-A.at(0))+abs(A.at(1)) << endl;
        }
        else if(i==N-1){
            cout << sum-abs(A.at(N-1))-abs(A.at(N-1)-A.at(N-2))+abs(A.at(N-2)) << endl;
        }
        else{
            cout << sum-abs(A.at(i-1)-A.at(i))-abs(A.at(i+1)-A.at(i))+abs(A.at(i-1)-A.at(i+1)) << endl;
        }
    }
}

Measured memory_bytes: 1664
import java.util.Arrays;
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] A = new long[n];
        for(int i=0;i<n;i++) A[i]=sc.nextLong();
        Arrays.sort(A);
        sc.close();
        long[] sum = new long[n];
        sum[0]=A[0];
        for(int i=1;i<n;i++) sum[i]=sum[i-1]+A[i];
        int res = 1;
        for(int i=n-1;i>=1;i--){
            if(A[i]<=2*sum[i-1]) res++;
            else break;
        }        
        System.out.println(res);
	}
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	ll ans = 0;
	cin >> n;
	vector <int> a(n+1);
	for (int i=1; i<=n; i++) {
		int x; cin >> x;
		if (i+x <= n) a[i+x] ++;
		if (i-x >= 1) ans += a[i-x];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3976
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {


        

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            for(int i = 0; i <= N - 2; i++)
            {
                int dif = h[i + 1] - h[i];
                if(dif >= 1)
                {
                    h[i + 1]--;
                }
                else if(dif < 0)
                {
                    Console.WriteLine("No");
                    return;
                }
                
            }


            Console.WriteLine("Yes");

        }
    }
}

Measured memory_bytes: 28124
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
    string s;
	cin >> s;
    int ans = -1;
    char prev = 0;
    for(char c : s){
        if(c != prev){
            prev = c;
            ans++;
        }
    }
    cout << ans << endl;
	return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w, k;
  cin >> h >> w >> k;
  
  vector<vector<char>> a(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<vector<int>> x(h, vector<int>(w));
  vector<bool> exist(h, false);
  int now = 1;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(exist.at(i) && a.at(i).at(j) == '#') x.at(i).at(j) = 1;
      if(a.at(i).at(j) == '#') exist.at(i) = true;
    }
  }
  
  for(int i = 0; i < h; i++){
    if(exist.at(i)){
      x.at(i).at(0) = now;
      for(int j = 1; j < w; j++){
        x.at(i).at(j) += x.at(i).at(j - 1);
      }
      now = x.at(i).at(w - 1) + 1;
    }
  }
  
  for(int i = 1; i < h; i++){
    if(exist.at(i - 1) == true && exist.at(i) == false){
      for(int j = 0; j < w; j++){
        x.at(i).at(j) = x.at(i - 1).at(j);
      }
      exist.at(i) = true;
    }
  }
  for(int i = h - 2; i >= 0; i--){
    if(exist.at(i + 1) == true && exist.at(i) == false){
      for(int j = 0; j < w; j++){
        x.at(i).at(j) = x.at(i + 1).at(j);
      }
      exist.at(i) = true;
    }
  }
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(j) cout << " ";
      cout << x.at(i).at(j);
    }
    cout << "\n";
  }
}

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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n"
#define loop(n) for (ll i = 0; i < n; i++)
#define loop2(n) for (ll i = 0; i < n; i += 2)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
int Mint = INT_MAX;
ll Mlong = LLONG_MAX;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(ll a, ll b) {
    if (b == 1)return a;
    if (b == 0) return 1;
    return a * pow(a, b - 1);
}

int n;
int operation = 0;

int counti = 0;


int solve(int s) {
    if(s==0)
        return 0;
    if(s==1)
        return 2;
    if(s==2)
        return 4;



    //cout << s << endl;
    operation++;
    return solve(s-1)+solve(s-2);
}

int main() {
    fast();
    int a, b;
    cin>>a>>b;
    int total=0;
    for (int i = 0; i <b ; ++i) {
        int h;cin>>h;
        total+=h;
    }
    if(total>=a)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

void ABC173D()
{
	int N;
	cin >> N;
	vi A(N);
	for (auto& x : A)
		cin >> x;
	sort(A.begin(), A.end(), greater<int>());


	ll sum = 0;
	int j = 0;
	int c = 1;
	for (int i = 1; i < N; ++i)
	{
		sum += A[j];
		--c;
		if (c == 0)
		{
			c = 2;
			++j;
		}
	}
	cout << sum << endl;
}

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



Measured memory_bytes: 4044
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (register ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 5e2 + 10 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f;
}

ll n;

ll ans[maxn][maxn];

void dfs(ll l, ll r, ll id)
{
	if(l == r) return ;
	ll mid = (l + r) >> 1;
	rep(i, l, mid) rep(j, mid + 1, r) ans[i][j] = ans[j][i] = id;
	dfs(l, mid, id + 1), dfs(mid + 1, r, id + 1);
	return ;
}

signed main()
{
	scanf("%lld", &n);
	dfs(1, n, 1);
	rep(i, 1, n) rep(j, i + 1, n) printf("%lld%c", ans[i][j], " \n"[j == n]);
	return 0;
}

Measured memory_bytes: 2432
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val a = str()
	val b = str()

	(0..a.length-b.length).map {i->
		val c = a.substring(i,i+b.length)
		b.indices.count {c[it]!=b[it]}
	}.min().let{println(it)}
}


Measured memory_bytes: 38872
ini=map(int, raw_input().split())
list=map(int, raw_input().split())

list.append(ini[1])
list.sort()

sa=[]
for i in range(len(list) - 1):
    sa.append(list[i+1]-list[i])
while True:
    sa.sort()
    amari=[]
    ch=0
    for i in range(len(sa)):
        ama=sa[i]%sa[0]
        if ama==0:
            amari.append(sa[0])
        else:
            amari.append(ama)
            ch=1
    if ch==0:
        break
    else:
        sa=amari

sa.sort()
print(sa[0])


Measured memory_bytes: 15252
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
typedef long long ll;
const double PI = acos(-1);
using namespace std;

int main(void){
    int N;
    string S,T;
    cin>>N>>S>>T;
    REP(i,N){
        cout<<S[i]<<T[i];
    }
    cout<<endl;
}




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

int main() {
    int H,W;
    int i,j;
    int h,w;

    cin >> H>>W ;
    char S[H][W];
    int count;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cin >> S[i][j];
        }
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(S[i][j]=='.'){
                //cout << "at"<< i<<j <<endl;
                count=0;
                for(h=i-1;h<=i+1;h++){
                    for(w=j-1;w<=j+1;w++){
                        if(-1<h && h<H && -1<w && w<W){
                            if(S[h][w]=='#'){
                                //cout << "found #" << h << w << endl;
                                count++;
                            }
                        }
                    }
                }
                S[i][j]=count+'0';
                //cout<< S[i][j]<<endl;
            }
        }
    }
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            cout<< S[i][j] << flush;
        }
        cout<<endl;

    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    mp[temp] += 1;
  }
  vector<int> num;
  for (auto x : mp) {
    num.push_back(x.second);
  }
  sort(num.begin(), num.end());
  int ans = 0;
  if (num.size() > k) {
    for (int i = 0; i < num.size() - k; i++) {
      ans += num[i];
    }
  }
  cout << ans << endl;
}

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

struct point {
	int x, y, id;
} p[100005];

vector< pair<int, pair<int, int> > > q;

bool cmpx(point a, point b) {
	if (a.x != b.x) return a.x > b.x;
	else return a.y > b.y;
}

bool cmpy(point a, point b) {
	if (a.y != b.y) return a.y > b.y;
	else return a.x > b.x;
}

int up[100005];

int Find(int x) {
	if (up[x] < 0) return x;
	int root = Find(up[x]);
	up[x] = root;
	return root;
}

void Union(int x, int y) {
	if (Find(x) == Find(y)) return;
	if (up[x] < up[y]) {
		up[x] += up[y];
		up[y] = x;
	} else {
		up[y] += up[x];
		up[x] = y;
	}
}

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

	int n; cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> p[i].x >> p[i].y;
		p[i].id = i;
	}
	sort(p+1, p+1+n, cmpx);
	for (int i=1; i<n; i++) q.push_back(make_pair(p[i].x - p[i+1].x, make_pair(p[i].id, p[i+1].id)));
	sort(p+1, p+1+n, cmpy);
	for (int i=1; i<n; i++) q.push_back(make_pair(p[i].y - p[i+1].y, make_pair(p[i].id, p[i+1].id)));
	sort(q.begin(), q.end());
	for (int i=0; i<100001; i++) up[i] = -1;
	long long ans = 0;
	for (int i=0; i<q.size(); i++) {
		int u = q[i].second.first, v = q[i].second.second;
		if (Find(u) != Find(v)) {
			Union(Find(u), Find(v));
			ans += q[i].first;
		}
	}
	cout << ans;
}


Measured memory_bytes: 6004
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a[100100] = {0};
  cin >> n;
  rep(i,n){
    int t;
    cin >> t;
    a[t]++;
  }
  int s = a[0]+a[1];
  int ma = 0;
  REP(i,1,100001){
    s += a[i+1];
    ma = max(ma,s);
    s -= a[i-1];
  }
  cout << ma << endl;
  return 0;
}


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

int main() {

	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<int> l(q), r(q);
	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
	}

	vector<int> acNum(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		acNum[i] += acNum[i - 1];
		if (i == 1) continue;
		if (s[i - 2] == 'A' && s[i - 1] == 'C') {
			acNum[i]++;
		}
	}

	for (int i = 0; i < q; i++) {
		cout << acNum[r[i]] - acNum[l[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;
ll lps[200005];
void cal(vector<ll> pat,vector<ll> text)
{
    lps[0]=0;
    ll len=0;
    ll i=1,n=pat.size();
    while(i<n)
    {
        if(pat[len]==text[i])
        {
            ++len;
            lps[i]=len;
            ++i;
        }
        else
        {
            if(len)
                len=lps[len-1];
            else
            {
                lps[i]=0;
                ++i;
            }
        }
    }
}
vector<ll> kmp(vector<ll> pat,vector<ll> text)
{
    int n=text.size();
    int m=pat.size();
    vector<ll>ans;
    int i=0,j=0;
    while(i<n)
    {
        if(pat[j]==text[i])
        {
            ++i;
            ++j;
        }
        if(j==m)
        {
            ans.pb(i-j);
            j=lps[j-1];
        }
        else if(i<n && pat[j]!=text[i])
        {
            if(j)
                j=lps[j-1];
            else
                ++i;
        }

    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
        ll n,m,i,j;
        cin>>n;
        ll arr[n+1],brr[n+1];
        for(i=0;i<n;i++)
            cin>>arr[i];
        for(i=0;i<n;i++)
            cin>>brr[i];
        vector<ll> v1,v2;
        for(i=0;i<n;i++)
        {
            v1.pb(arr[i]^arr[(i+1)%n]);
            v2.pb(brr[i]^brr[(i+1)%n]);
        }
        for(i=0;i<n-1;i++)
            v1.pb(v1[i]);
            cal(v2,v2);
        vector<ll> ans=kmp(v2,v1);
        for(i=0;i<ans.size();i++)
        {
            ll k=ans[i];
            ll x=brr[0]^arr[k];
            cout<<k<<" "<<x<<"\n";
        }
    }
}


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

string o, e;

int main() {
	cin >> o >> e;
	for (int i = 0; i < e.size(); i++) {
		cout << o[i] << e[i];
	}
	if (o.size() != e.size()) {
		cout << o[o.size()-1];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc114/tasks/abc114_d

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// http://tutuz.hateblo.jp/entry/2018/12/22/125205
ll dp[110][101];
int main() {
    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 2; i <= n; i++) {
        int tmp = i;
        for (int j = 2; j <= i; j++) {
            while (tmp % j == 0) {
                cnt[j]++;
                tmp /= j;
            }
        }
    }
    dp[0][1] = 1;
    for (int i = 0; i <= n; i++) {
        for (int have = 0; have <= 75; have++) {
            for (int take = 1; take <= cnt[i] + 1; take++) {
                if (have * take <= 75) {
                    dp[i + 1][have * take] += dp[i][have];
                }
            }
        }
    }
    cout << dp[n][75] << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_N=10;
const int INF=0x3f3f3f3f;
int dist[MAX_N][MAX_N];

int main(){

    int N;
    while((cin>>N)&&N>0){
        memset(dist, 0x3f, sizeof(dist));
        int u,v,w;
        for(int i=0; i<MAX_N; i++) dist[i][i]=0;
        int max_n=0;
        for(int i=0; i<N; i++){
            scanf("%d %d %d", &u, &v, &w);
            dist[u][v]=dist[v][u]=w;
            max_n=max(max_n, max(u,v)+1);
        }
        for(int i=0; i<max_n; i++){
            for(int j=0; j<max_n; j++){
                for(int k=0; k<max_n; k++)
                    dist[j][k]=min(dist[j][k], dist[j][i]+dist[i][k]);
            }
        }
        int res=INF;
        int min_ele=0;
        for(int i=0; i<max_n; i++){
            int tmp=0;
            for(int j=0; j<max_n; j++)
                tmp+=dist[i][j];
            if(tmp<res){
				res=tmp;
				min_ele=i;
			}
        }
        cout<<min_ele<<" "<<res<<endl;
    }

}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,A,B,x[100000],c;
bool Awin(){
	cin>>N>>A>>B;
	rep(i,N) cin>>x[i];
	rep(i,N) if(x[i]>min(A,B)) c++;
	if(A>B){
		if(c) return 1;
	}else if(A<B){
		if(c>1) return 0;
		if(c==1){
			int a=0,j=-1;
			rep(i,N){
				if(x[i]>A) j=i;
				else a^=x[i]%(A+1);
			}
			if(a<=A&&x[j]-A<=a&&a<x[j]) return 1;
			else return 0;
		}
	}
	int a=0;
	rep(i,N) a^=x[i]%(min(A,B)+1);
	return a;
}
int main(){
	if(Awin()) puts("Hanako");
	else puts("Jiro");
}

Measured memory_bytes: 3480
import sys
readline = sys.stdin.readline

# 作れる水の量を全探索（せいぜい30種類）
# 各水の量に対して、溶かせる砂糖の最大値は決まる（DPする）
# 最大値とすることができる砂糖に最も近づいたら割合を求め、答えの最大値を更新する

A,B,C,D,E,F = map(int,readline().split())
max_rate = -1
ans_water = 0
ans_sugar = 0
for a in range(30):
  for b in range(30):
    if a * A * 100 + b * B * 100 >= F:
      continue
    water = a * A * 100 + b * B * 100
    if water == 0:
      continue
    max_sugar = water * E // 100 # 溶ける砂糖の最大値
    if max_sugar + water > F:
      max_sugar = F - water
      
    dp = [False] * (max_sugar + 1)
    dp[0] = True
    for i in range(len(dp)):
      if dp[i]:
        if i + C >= len(dp):
          break
        dp[i + C] = True
    
    for i in range(len(dp)):
      if dp[i]:
        if i + D >= len(dp):
          break
        dp[i + D] = True
        
    for i in range(len(dp) - 1, -1, -1):
      if dp[i]:
        rate = (i * 100) / (water + i)
        break
    if rate >= max_rate:
      max_rate = rate
      ans_water = water
      ans_sugar = i
    
print(ans_water + ans_sugar,ans_sugar)

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

#define MAXN 100*1000 + 5

int fact[MAXN], inv[MAXN], arr[MAXN];
const int mod = 1000*1000*1000 + 7;

int mul(int a, int b) {
	return (1LL * a * b) % mod;
}

int mpow(int a, int n) {
	if(n == 0) return 1;
	int x = mpow(a, n/2);
	x = mul(x, x);
	if(n % 2) x = mul(x, a);
	return x;
}

void add_self(int& a, int b) { a += b; if(a >= mod) a -= mod; }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	fact[0] = 1;
	for(int i = 1; i < MAXN; i++) {
		fact[i] = mul(i, fact[i-1]);
		inv[i] = inv[i-1];
		add_self(inv[i], mpow(i, mod-2));
	}
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	
	int ans = 0;
	for(int i = 1; i < n; i++) {
		int dist = arr[i+1] - arr[i];
		add_self(ans, mul(dist, inv[i]));
	}
	
	ans = mul(ans, fact[n-1]);
	cout << ans << endl;
}


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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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



int main() {
	fastio();

	ll n; cin >> n;
	string s; cin >> s;

	ll ans = 1;
	f(i, 0, n - 2) {
		if (s[i + 1] != s[i]) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1e9 + 7;
ll dp[410][410];

int main() {
    int n, c;
    cin >> n >> c;
    VL a(n), b(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];

    dp[0][c] = 1;

    REP(i,n){
        FOR(x,a[i],b[i]){
            ll s = 0;
            FORR(j,c,0){
                s = (s * x + dp[i][j]) % mod;
                dp[i+1][j] = (dp[i+1][j] + s) % mod;
            }
        }
    }
    
    cout << dp[n][0] << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin>>s>>t;
    if(s.size()>t.size()){cout<<"GREATER"<<endl;return 0;}
    else if(s.size()<t.size()){cout<<"LESS"<<endl;return 0;}
    else{
        for(int i=0;i<s.size();i++){
            if(s[i]>t[i]){cout<<"GREATER"<<endl;return 0;}
            else if(s[i]<t[i]){cout<<"LESS"<<endl;return 0;}
        }
    }
    cout<<"EQUAL"<<endl;
}


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


int main(){
	ll n;
	cin>>n;
	ll x=n;
	ll k=1;
	ll ans=0;
	rep(i,1,n+1){
		if(i>=1 &&i<=9) ans++;
		if(i>=100 && i<=999)ans++;
		if(i>=10000 && i<=99999)ans++;
	}
	cout<<ans++;
}

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

int main(void)
{
  int a, b;
  char s[11], t[11], u[11];
  scanf("%10s%10s%d%d%10s", s, t, &a, &b, u);
  (*(strcmp(s, u) == 0 ? &a : &b))--;
  printf("%d %d\n", a, b);
}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}


int main()
{
    map<llint, int> m;
    llint a, b, c, d;
    ci >> a >> b >> c >> d;

    llint tmp = __lcm(c, d);
    
    co << b - a + 1 - ((b / c) + (b / d)) + ((a - 1) / c) + ((a - 1) / d) + (b / tmp) - ((a - 1) / tmp) << en;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<queue>
#include<vector>
#include<list>
#include<stack>
using namespace std;
typedef long long ll;

int main()
{
	int a,b;
	cin >> a >> b;
	if ((a+b)%2)
		cout << "IMPOSSIBLE";
	else
		cout << (a + b)/2;
	return 0;
}

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

int fib(int n)
{
    int sum = 0;
    for(int lp1=1;lp1<=n;lp1++)
    {
       sum = sum + lp1; 
    }
    cout << sum << endl;
}

int main() {
    
    int k = 0;
    cin >> k;
    fib(k);

}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dpa[3010][3010];
int dpb[3010][3010];

int main(){
  int N, T; cin >> N >> T;
  int a[N], b[N];
  rep(i, N){
    cin >> a[i] >> b[i];
  }
  rep(i, N){
    rep(j, T){
        if(j>=a[i]) dpa[i+1][j]= max(dpa[i][j], dpa[i][j-a[i]]+b[i]);
        else dpa[i+1][j] = dpa[i][j];
    }
  }
  rep(i, N){
    rep(j, T){
      if(j>=a[N-1-i]) dpb[i+1][j] = max(dpb[i][j], dpb[i][j-a[N-1-i]]+b[N-1-i]);
      else dpb[i+1][j] = dpb[i][j];
    }
  }
  int ans = 0;
  rep(i, N){
    rep(j, T){
      ans = max(dpa[i][j]+dpb[N-i-1][T-1-j]+b[i], ans);
    }
  }
  cout << ans << endl;
}     

    

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define oo 2000000000
const int N = 200010;
int main(){
	string s;
	cin >> s;
	if(s.size() < 4){
		puts("No"); 
		return 0;
	}
	if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int D;
int C[26];
int S[365][26];

int64_t evaluate(const vector<int> &T) {
  int64_t res = 0;
  vector<int> last(26);
  for (int i = 0; i < T.size(); ++i) {
    res += S[i][T[i] - 1];
    last[T[i] - 1] = i + 1;
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  return res;
}

int64_t evaluate_avg(const vector<int> &T) {
  int64_t res = 0;
  vector<int> last(26);
  for (int i = 0; i < T.size(); ++i) {
    res += S[i][T[i] - 1];
    last[T[i] - 1] = i + 1;
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  for (int i = T.size(); i < min((int) T.size() + 10, D); ++i) {
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  return res;
}

int main() {
  cin >> D;
  for (int i = 0; i < 26; ++i) cin >> C[i];
  for (int i = 0; i < D; ++i) for (int j = 0; j < 26; ++j) cin >> S[i][j];

  vector<int> T;
  for (int _ = 0; _ < D; ++_) {
    pair<int64_t, int> best = make_pair(numeric_limits<int64_t>::min(), 0);
    for (int n = 1; n <= 26; ++n) {
      T.push_back(n);
      best = max(best, make_pair(evaluate_avg(T), n));
      T.pop_back();
    }
    assert(best.second);
    T.push_back(best.second);
  }

  for (int i = 0; i < D; ++i) cout << T[i] << endl;

  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>                                                
#define int long long                                                   
#define double long double                                              
#define INF 1e18                                                        
#define MOD 1000000007                                                  
using namespace std;                                                    
signed main() {                                                         
  string s; cin >> s;                                                   
  for (int i = 0; i < s.length(); i++) {                                
    if ((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R')) {   
      cout << "No" << endl;                                             
      return 0;                                                            
    }                                                                   
  }                                                                     
  cout << "Yes" << endl;                 
  return 0;
}                                                                       
                                                                        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll t,n,a,b,c,d,dp[N],cnt;
map<ll,ll> mp;
ll dfs(ll x)
{
	if(x==0)
	{
		return 0;
	}
	ll cc;
	if(mp.count(x))
	{
		if(dp[mp[x]]<LINF)
		{
			return dp[mp[x]];
		}
	}
	else
	{
		mp[x]=cnt++;
		cc=cnt-1;
	}
	if(x<LINF/d)
	{
		dp[cc]=x*d;
	}
	dp[cc]=min(dp[cc],(x%2)*d+a+dfs(x/2));//向下取2倍数
	dp[cc]=min(dp[cc],(x%3)*d+b+dfs(x/3));//向下取3倍数
	dp[cc]=min(dp[cc],(x%5)*d+c+dfs(x/5));//向下取5倍数
	dp[cc]=min(dp[cc],(2-(x%2))*d+a+dfs((x+1)/2));//向上取2倍数
	dp[cc]=min(dp[cc],(3-(x%3))*d+b+dfs((x+2)/3));//向上取3倍数
	dp[cc]=min(dp[cc],(5-(x%5))*d+c+dfs((x+4)/5));//向上取5倍数
	return dp[cc];
}
int main(){
	scanf("%lld",&t);
	while(t--)
	{
		mp.clear();
		cnt=0;
		memset(dp,127,sizeof(dp));
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		printf("%lld\n",dfs(n));
	}
	return 0;
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define int long long
#define fi first
#define se second

const int maxn=2e3+10;
int n;
pii a[maxn];
int f[maxn][maxn]; /// f[i][j]

main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    forinc(i,1,n){
        cin>>a[i].fi;a[i].se=i;
    }
    sort(a+1,a+n+1,greater<pii> ());
    forinc(i,1,n) forinc(j,0,i){
        int pos=a[i].se;
        int ty1=j;
        int ty2=min(n,n-(i-j)+1);
        if(j==0) f[i][j]=f[i-1][j]+a[i].fi*(ty2-pos);
        else if(j==i) f[i][j]=f[i-1][j-1]+ a[i].fi*(pos-ty1);
        else f[i][j]=max(f[i-1][j]+a[i].fi*(ty2-pos),f[i-1][j-1]+ a[i].fi*(pos-ty1));
    }
    int ret=0;
    forinc(i,0,n) ret=max(ret,f[n][i]);
    cout<<ret;
}


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

int rooms[4][3][10];


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

    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin >> b>>f>>r>>v;
        rooms[b-1][f-1][r-1]+=v;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<" "<< rooms[i][j][k];
                if(k==9)cout<<endl;
            }
        }
        if(i==3)break;
        cout<<"####################"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	c := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&c[i])
	}

	for i := 0; i < h; i++ {
		fmt.Println(c[i])
		fmt.Println(c[i])
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(long long N, long long D, std::vector<std::vector<long long>> X){
	ll c = 0;
	REP(i, N) {
		REP(j, N) {
			if (i==j) continue;
			double dist = 0;
			REP(d, D) {
				double absn = abs(X[i][d] - X[j][d]);
				dist += double(pow(absn, 2));
			}
			dist = sqrt(dist);
			if (floor(dist) == dist) c++;
		}
	}
	c /= 2;
	cout << c << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

vector<vector<int> > adj(20);
map<string, int> memo;

int dfs(const string &str) {
    map<string, int>::iterator it;
    if(str.size() <= 1) return str.size();
    if((it = memo.find(str)) != memo.end()) return it->second;

    int ans = str.size();
    for(int i = 0; i < str.size(); ++i) {
        for(int j = 0; j < adj[i].size(); ++j) {
            if(adj[i][j] >= str.size()) continue;
            if(adj[i][j] < i) continue;
            if(str[i] == str[adj[i][j]]) {
                ans = min(ans, dfs(str.substr(0, i) + str.substr(i+1, adj[i][j]-(i+1)) + str.substr(adj[i][j]+1)));
            }
        }
    }

    memo[str] = ans;
    return ans;
}


int main() {
    for(int i = 0; i < 20; ++i) {
        int x = i % 4;
        int y = i / 4;

        for(int dx = -1; dx <= 1; ++dx) {
            for(int dy = -1; dy <= 1; ++dy) {
                if(dx == 0 && dy == 0) continue;
                int xx = x + dx, yy = y + dy;
                if(0 <= xx && xx < 4 && 0 <= yy && yy < 5) {
                    adj[i].push_back(yy*4 + xx);
                }
            }
        }
    }

    int N;
    cin >> N;
    while(N--) {
        string s;
        for(int i = 0; i < 20; ++i) {
            char c;
            cin >> c;
            s += c;
        }

        cout << dfs(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
def f(i):
    global ans
    if i == n:
        c = [0] * m
        for i in range(n):
            if t[i] == 1:
                for j in range(m):
                    if i + 1 in S[j]:
                        if c[j] == 0:
                            c[j] = 1
                        else:
                            c[j] = 0
        if c == p:
            ans += 1
        return
    f(i + 1)
    t[i] = 1
    f(i + 1)
    t[i] = 0

n, m = map(int, input().split())
S = []
ans = 0
for _ in range(m):
    s = list(map(int, input().split()))
    S.append(s[1 :])
p = list(map(int, input().split()))
t = [0] * n

f(0)
print(ans)

Measured memory_bytes: 3064
import fractions
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = a[i]//2
wa=[]
for i in range(n):
    p=a[i]
    f=0
    while p%2==0:
        p=p//2
        f+=1
    wa.append(f)
if max(wa)!=min(wa):
    print(0)
    exit()
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)#aの要素をすべて2で割った数列の最小公倍数
#にぶんたんさく(lcmをｘ倍してｍを超えないようなギリギリのｘ)
bottom = 0
top = m+1#m//2くらいで十分だけど大きめにとる
while top - bottom > 1:
    middle = (top+bottom )//2
    if lcm * middle <= m:
        bottom = middle
    else:
        top = middle



print(( bottom+1)//2)


Measured memory_bytes: 16348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = long.Parse(Console.ReadLine());
			var heights = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

			var sums = new long[n];
			var diffs = new long[n];

			for(var i = 0; i < n; i++)
			{
				sums[i] = i + heights[i];
				diffs[i] = i - heights[i];
			}

			var sumsDictionary = new Dictionary<long, long>();
			var diffsDictionary = new Dictionary<long, long>();

			for(var i = 0; i < n; i++)
			{
				if(!sumsDictionary.ContainsKey(sums[i]))
				{
					sumsDictionary.Add(sums[i], 0);
				}
				sumsDictionary[sums[i]]++;

				if(!diffsDictionary.ContainsKey(diffs[i]))
				{
					diffsDictionary.Add(diffs[i], 0);
				}
				diffsDictionary[diffs[i]]++;
			}

			long count = 0;

			foreach(var sumsPair in sumsDictionary)
			{
				if(diffsDictionary.ContainsKey(sumsPair.Key))
				{
					count += sumsPair.Value * diffsDictionary[sumsPair.Key];
				}
			}

			Console.WriteLine(count);
		}
	}
}


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

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

    string s;
    cin>>s;
    ll res = 0;
    deque<char> st;
    FOR(i,0,s.size()){
      if(st.empty()){
        st.push_back(s[i]);
      }
      else if(st.back() != s[i]){
        res += 2;
        st.pop_back();
      }
      else{
        st.push_back(s[i]);
      }
    }
    cout<<res<<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;

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

    vector<int> L(N);
    rep(i,N) cin >> L[i];

    sort(L.begin(), L.end());
    ll ans = 0;
    rep(b,N) rep(a,b) {
        int ab = L[a] + L[b];
        int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
        int l = b + 1;
        ans += r - l;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 200010, inf = 1e9;
int n, q;
struct sgst {
	int v[maxn<<1];
	void chmin(int &v, int val) { v = min(v, val); }
	void init() {
		fill(v, v+n+n, n-1);
	}
	void modify(int l, int r, int x) {
		l += n, r += n;
		for (;l < r;l>>=1, r>>=1) {
			if (l&1) chmin(v[l++], x);
			if (r&1) chmin(v[--r], x);
		}
	}
	int query(int i) {
		int res = inf;
		for (i += n;i;i>>=1)
			res = min(res, v[i]);
		return res;
	}
}t1, t2;
ll res;
void paint() {
	int a, x;
	cin >> a >> x;
	--x;
	if (a == 1) {
		int ed = t1.query(x);
		res += ed - 1;
		t1.modify(x, x+1, 0);
		t2.modify(0, ed, x);
	}
	else {
		int ed = t2.query(x);
		res += ed - 1;
		t2.modify(x, x+1, 0);
		t1.modify(0, ed, x);
	}
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> q;
	t1.init(), t2.init();
	while (q--) 
		paint();
	cout << (ll)(n-2) * (ll)(n-2) - res << '\n';
}


Measured memory_bytes: 6708
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((int)1e9)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define N 100005
int n, a, b;
ll h[N], tmp[N];
bool solve(ll moves) {
    ll val = 0;
    FOR0(i, n) {
        tmp[i] = (h[i] - 1)/b + 1 >= moves ? h[i] - b*moves: 0; 
        if(tmp[i] > 0) val += (tmp[i] - 1)/(a-b) + 1;
    }
    return val <= moves;
}
int main() {
    SYNC
    cin >> n >> a >> b;
    FOR0(i, n) cin >> h[i];
    ll l = 0, r = 1e15;
    while(l < r) {
        ll mid = (l + r) >> 1;
        if(solve(mid)) {
            r = mid ;
        } else {
            l = mid + 1;
        }
    }
    cout << l;
}

Measured memory_bytes: 1792
#include<cstdio>
#define maxn 100005
#define LL long long
using namespace std;
int n,a[maxn];
int gcd(int a,int b)
{
	if(!b) return a;
	return gcd(b,a%b);
}
bool dfs(int a[])
{
	if(n==1) return false;
	int cnte=0,cnto=0,poso=-1;
	for(int i=1;i<=n;i++)
		if(a[i]%2) cnto++,poso=i;
		else cnte++;
	if(cnte%2) return true;
	else if(cnto>1) return false;
	else
	{
		if(a[poso]==1)
		{
			LL tmp=0;
			for(int i=1;i<=n;i++) tmp+=1ll*(a[i]-1);
			return tmp%2;
		}
		a[poso]--;
		int g=a[1];
		for(int i=2;i<=n;i++) g=gcd(g,a[i]);
		for(int i=1;i<=n;i++) a[i]/=g;
		return dfs(a)^1;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%s\n",dfs(a)?"First":"Second");
}


Measured memory_bytes: 512
n=int(input())
h=list(map(int,input().split()))

dp = [float("inf")]*n #最小値求めるのでinfで初期化
dp[0]=0

for i in range(1,n):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i-2>=0:
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(0);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
	int w,d;
	while(cin>>w>>d,w){
		VI(a,w);
		VI(b,d);
		int ans=0;
		rep(i,w){
			rep(j,d){
				if(a[i]==b[j]){
					ans+=a[i];
					a[i]=0;
					b[j]=0;
					break;
				}
			}
		}
		ans+=accumulate(all(a),0);
		ans+=accumulate(all(b),0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    cout << !x;
}


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

void swap(int&x,int&y)
{
  int tmp=x;
  x=y;
  y=tmp;
}

int main()
{
  int x,y;
  cin >> x >> y;
  while(!(x==0&&y==0))
    {
      if(x>y)
	swap(x,y);
      cout << x << " " << y << endl;
      cin >> x >> y;
    }

  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	getchar();
	map<string,int>mm;
	while(n--){
		char s[100];
		scanf("%s",s);
		mm[s]=1;
	}
	printf("%d\n",mm.size());
}

Measured memory_bytes: 19352
if __name__ == "__main__":
    while 1:
        m,nmin,nmax = list(map(int,input().strip().split()))
        if m == nmin == nmax ==0:break
        points = []
        for _ in range(m):points.append(int(input()))
        ans = 0
        diff = 0
        for i in range(nmin,nmax+1):
            if diff < points[i-1] - points[i]:
                ans = i
                diff = points[i-1] - points[i]
            elif diff == points[i-1] -points[i] and i > ans :ans =i
        print(ans)

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

using namespace std;


typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> c(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];cin>>b[i];cin>>c[i];
    }
    for(int i=1;i<n;i++)
    {
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(a[i-1],c[i-1]);
        c[i]+=max(b[i-1],a[i-1]);
    }
    cout<<max(a[n-1],max(b[n-1],c[n-1]));
}


Measured memory_bytes: 2560