akhauriyash/Code-Regression huggingface dataset:
#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,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

const int N = 200005;
int S[N],T[N],X[N];
int D[N];

typedef tuple<int,int,int> P;

int main() {
  int n, q;
  while (input(n,q)) {
    vector<P> v;
    REP(i,n) {
      input(S[i],T[i],X[i]);
      S[i] -= X[i];
      T[i] -= X[i];
      v.emplace_back(S[i],0,X[i]);
      v.emplace_back(T[i],1,X[i]);
    }
    inputs(D,q);
    REP(i,q) {
      v.emplace_back(D[i],2,0);
    }
    sort(ALL(v));
    multiset<int> st;
    FOR(it, v) {
      int t, type, x;
      tie(t,type,x) = *it;
      // cout << *it << endl;
      if (type == 0) {
        st.insert(x);
      } else if (type == 1) {
        st.erase(st.find(x));
      } else {
        int ans = st.empty() ? -1 : *st.begin();
        output(ans);
      }
      // cout << t << " " << st << endl;
    }
  }
}


Measured memory_bytes: 21096
N, D = map(int, input().split())
ds = list(map(int, input().split()))
Q = int(input())
querys = list(map(lambda x: int(x) - 1, input().split()))

# ps[i]: i回目の移動後の位置（目的地までの距離）
ps = [0] * (N + 1)
ps[0] = D
for i in range(N):
    ps[i + 1] = min(abs(ps[i] - ds[i]), ps[i])

if ps[N] != 0:
    print('\n'.join(['YES'] * Q))
    exit()

# ms[i]: i番目の移動後にm以下の位置ならば全て、目的地に到達可能であるようなmの最大値
ms = [0] * (N + 1)
for i in range(N)[::-1]:
    if ms[i + 1] + 1 >= ds[i] - ms[i + 1]:
        ms[i] = ms[i + 1] + ds[i]
    else:
        ms[i] = ms[i + 1]

for q in querys:
    if ps[q] <= ms[q + 1]: # 妨害は不可能
        print('NO')
    else:
        print('YES')


Measured memory_bytes: 78768
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  string word = {s1[0], s2[1], s3[2]};
  cout << word << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int A, B; cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << endl;
}



Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0, a[0]]
sb = [0, b[0]]
s = a[0]
for i in range(1, n):
  s += a[i]
  sa.append(s)
s = b[0]
for i in range(1, m):
  s += b[i]
  sb.append(s)
  
ans = 0
books = 0

from bisect import bisect
a_books = bisect(sa, k) - 1
b_books = bisect(sb, k) - 1
if a_books > b_books:
  for i in range(b_books+1):
    books = i
    books += bisect(sa, k-sb[books]) - 1
    ans = max(ans, books)
else:
  for i in range(a_books+1):
    books = i
    books += bisect(sb, k-sa[books]) - 1
    ans = max(ans, books)
print(ans)

Measured memory_bytes: 48948
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 998244353;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
inline ll add(ll a,ll b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline ll sub(ll a,ll b){a-=b;if(a<0)a+=MOD;return a;}
inline ll mul(ll a,ll b){return (a*1ll*b)%MOD;}
ll power (ll base,ll exponent)
{
    ll ans=1;
    base%=MOD;
    exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base)%MOD;
      base=(1LL*base*base)%MOD;
      exponent>>=1;
    }
    return ans;
}
const ll N=2e5+5;
ll dp[N];
ll fac[N];
ll inv[N];
ll ncr(ll n,ll r)
{
    if(r>n||n==0) return 1;
    ll a=fac[n];
    ll b=power(fac[r],MOD-2);
    ll c=b*power(fac[n-r],MOD-2);
    c%=MOD;a*=c;a%=MOD;
    return a;
}
ll dp1[N];
int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n>>m>>k;
     // dp[0]=m;
     fac[0]=1;
     for(i=1;i<N;i++) fac[i]=(i*fac[i-1])%MOD;
     ll ans=0;
     for(i=0;i<=k;i++)
     {
       // cout<<ncr(n-1,i)<<endl;
       ll x=ncr(n-1,i)*m;
       x%=MOD;
       ll y=power(m-1,n-1-i);
       dp[i]=x*y;
       dp[i]%=MOD;
       // cout<<x<<" "<<y<<endl;
       ans+=dp[i];
       ans%=MOD;
     }
     cout<<ans<<endl;
     // cout<<dp[k];
     
     
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

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

#define sz(s) (ll)(s.size())
#define all(x) (x.begin(), x.end())

#define pb push_back
#define pf push_front
#define F first
#define S second
#define ort1 exit(0);
#define nl endl
#define db double

#define TL clock() / (double)CLOCKS_PER_SEC
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const ll INF = 1e12 + 1;
const int N = 1e2 + 9;

int ans;
int a, b, c;
vector<int> v;

int main()
{
    cin >> a >> b >> c;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(v.begin(), v.end());
    ans += abs(v[1] - v[0]) + abs(v[2] - v[1]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3 ## -*- python -*-
k = int(input())

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

Measured memory_bytes: 3060
n = gets.chomp.to_i
w = gets.chomp.split(" ").map(&:to_i)

total_w = w.inject(&:+)
min_d = total_w
1.upto(n - 1) do |t|
  s1 = w.first(t).inject(&:+)
  s2 = total_w - s1
  d = (s1 - s2).abs
  min_d = d if d < min_d
end

puts min_d


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  ll sum=0,cnt=1,max_a=0;
  cin >> s;
  char f;
  vector<ll> a;
  f=s[0];
  for(int i=1;i<s.size();i++){
    if(s[i]!=s[i-1]){
      a.push_back(cnt);
      cnt=0;
    }
    cnt++;
  }
  a.push_back(cnt);
  sum += (a[0]*(a[0]-1))/2;
  for(int i=1;i<a.size();i++){
    sum += (a[i]*(a[i]-1))/2;
    if((f=='<')^(i%2==0)){
      sum += max(a[i],a[i-1]);
    }
  }
  if(s[0]=='>'){
    sum += a[0];
  }
  if(s.back()=='<'){
    sum += a.back();
  }
  cout<< sum<<endl;
}


Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;
const int maxn = 50;
long long get(vector<long long> v){
    int len = v.size();
    long long ops = 0;
    while(true){
        long long sum = 0;
        vector<long long> add(len, 0);
        for(int e = 0; e < len; e++){
            long long now = v[e] / len;
            add[e] -= now;
            ops += now;
            sum += now;
        }
        for(int e = 0; e < len; e++){
            v[e] = (v[e] % len) + add[e] + sum;
        }
        bool ended = true;
        for(int e = 0; e < len; e++)
            ended &= v[e] < len;
        if(ended)
            break;
    }
    return ops;
}
int main(){
    long long k;
    cin >> k;
    long long basicSteps = (k / maxn);
    vector<long long> arr(maxn, 0);
    for(int e = 0; e < maxn; e++)
        arr[e] = basicSteps*maxn - basicSteps*(maxn - 1) + e;
    auto op = [&](int pos){
        for(int e = 0; e < maxn; e++)
            if(e == pos) arr[e] += maxn;
            else arr[e]--;
    };
    for(int e = 0; e < k % maxn; e++)
        op(e);
    cout << maxn << endl;
    for(int e = 0; e < maxn; e++)
        cout << arr[e] << " \n"[e == maxn-1];
    assert(get(arr) == k);
    return 0;
}


Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll x;
    cin >> x;
    ll y = ((x + 10) / 11);
    int ok = 0;
    if ((6 * y + 5 * (y - 1)) >= x || (6 * (y - 1) + 5 * y >= x)) ok = 1;
    cout << 2 * y - ok << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

    int n;
    n = stdInt.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = stdInt.nextInt();
    }

    //bubble sort
    int cnt = 0;
    for (int i = 0; i < n-1; i++) {
      for (int j = n-1; j > i; j--) {
        if (a[j] < a[j-1]) {
          int tmp;
          tmp = a[j];
          a[j] = a[j-1];
          a[j-1] = tmp;
          cnt++;
        }
      }
    }

    for (int i = 0; i < n; i++) {
      System.out.print(a[i]);
      if (i != n-1)
      System.out.print(" ");
    }
    System.out.println();
    System.out.println(cnt);
  }
}


Measured memory_bytes: 26368
#include <iostream>
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main() {
	int a,b;cin>>a>>b;
	long long ans=a;
	ans*=b;
	ans/=gcd(a,b);
	cout<<(long long)a*b/gcd(a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0
for i in range(n):
    for j in range(i):
        ans += bisect.bisect_left(l, l[i]+l[j], j+1, i)-bisect.bisect_right(l, l[i]-l[j], j+1, i)

print(ans)


Measured memory_bytes: 43868
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            final int a = in.nextInt();
            final int b = in.nextInt();
            final int c = in.nextInt();
            final int d = in.nextInt();
            int n = (a > b ? b : a) + (c > d ? d : c);
            out.println(n);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

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

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

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

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

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());

	long long ans = 0;

	if (n % 2 == 0) {
		for (int i = 1; i < n / 2; i++) {
			ans += a[i-1];
		}
		for (int i = 1; i < n / 2; i++) {
			ans += a[i];
		}
		ans += a[n/2-1];
	} else {
		for (int i = 1; i <= n / 2; i++) {
			ans += a[i-1];
		}
		for (int i = 1; i <= n / 2; i++) {
			ans += a[i];
		}
	}

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


Measured memory_bytes: 3700
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, _ := strconv.ParseFloat(sc.Text(), 64)
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	x, y, x2, y2 := nextFloat(), nextFloat(), nextFloat(), nextFloat()
	fmt.Println(math.Sqrt(math.Pow(x-x2, 2) + math.Pow(y-y2, 2)))
}



Measured memory_bytes: 1128
import fractions
a = list(map(int, input().split()))
n = a[1]-a[0]+1
wac = a[1]//a[2]-(a[0]-1)//a[2]


wad= a[1]//a[3]-(a[0]-1)//a[3]

  
lcm = a[2]*a[3]//fractions.gcd(a[2], a[3])
cd =a[1]//lcm-(a[0]-1)//lcm


print(n-wac-wad+cd)


Measured memory_bytes: 5048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')   f=-1;c=getchar();}
    while(isdigit(c))   {x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n,m;
int tot=0;
long long ans[100005],f[100005];
long long sta[100005];
void toss(long long pos,long long v)
{
	if(!pos)	return;
	int t=upper_bound(sta,sta+tot,pos)-sta-1;
	if(t==-1)
	{
		ans[1]+=v;
		ans[1+pos]-=v;
	}
	else
	{
		f[t]+=pos/sta[t]*v;
		toss(pos%sta[t],v);
	}
}
int main()
{
	read(n);
	read(m);
	sta[tot++]=n;
	long long x;
	while(m--)
	{
		read(x);
		while(tot && sta[tot-1]>=x)	tot--;
		sta[tot++]=x;
	}
	f[tot-1]=1;
//	for(int i=0;i<tot;i++)	cout<<sta[i]<<endl;
	for(int i=tot-2;i>=0;i--)
	{
		f[i]+=f[i+1]*(sta[i+1]/sta[i]);
		toss(sta[i+1]%sta[i],f[i+1]);
	}
	ans[1]+=f[0];
	ans[sta[0]+1]-=f[0];
	for(int i=1;i<=n;i++)
	{
		ans[i]+=ans[i-1];
		printf("%lld\n",ans[i]);
	}
	return 0;
}



Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;

using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

bool isGuMozi(string &s, int size) {
  if(size%2!=0) return false;
  
  rep(i, size/2) {
    int a = i;
    int b = size/2+i;

    if(s.at(a)!=s.at(b)) return false;
  }

  return true;
} 

int main() {
  string s;
  cin >> s;
  int size = s.size() - 1;

  while(size>=0) {
    if(isGuMozi(s, size)) {
      cout << size << endl;
      return 0;
    }

    size -= 1;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) cin >> h[i];
  sort(h.begin(), h.end());
  int res = INF;
  for (int i = 0; i < N - K + 1; ++i) {
    res = min(res, h[i + K - 1] - h[i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main { 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true) {
			ArrayList<Data> list = new ArrayList<Data>();
			int n = stdIn.nextInt();
			int q = stdIn.nextInt();
			if(n == 0 && q == 0) break;
			for(int i = 0; i < n; i++) {
				String nm = stdIn.next();
				int c = stdIn.nextInt();
				int y = stdIn.nextInt();
				list.add(new Data(nm,c,y));
			}
			CO:for(int i = 0; i < q; i++) {
				int a = stdIn.nextInt();
				for(int j = 0; j < list.size(); j++) {
					Data tmp = list.get(j);
					if(a <= tmp.year && a > tmp.year - tmp.count) {
						System.out.println(tmp.eraName + " " + (tmp.count-(tmp.year - a)));
						continue CO;
					}
				}
				System.out.println("Unknown");
				
			}
		}
	}
}
class Data {
	String eraName;
	int count;
	int year;
	public Data(String n, int c, int y) {
		eraName = n;
		count = c;
		year = y;
	}
}

Measured memory_bytes: 61540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int ali=0;
  int bob=0;
  for(int i=0; i<N; i++){
    if(i % 2 == 0){
      ali += vec.at(i);
    }else{
      bob += vec.at(i);
    }
  }
  cout << ali-bob << endl;
}

Measured memory_bytes: 256
local s = io.read()
local t = {}
local n = #s
for i = 1, n do
  table.insert(t, s:sub(i, i) == "B")
end
local cnt = 0
local curcnt = 0
for i = n, 1, -1 do
  if t[i] then
    cnt = cnt + curcnt
    t[i] = false
  else
    curcnt = curcnt + 1
  end
end
print(cnt)


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

int main() {
  int n, k;
  cin >> n >> k;
  long double s = 0;
  rep(i, n){
    if(i == k-1) break;
    else{
      int c = 0, d = i+1;
      while(d < k){
        ++c;
        d *= 2;
      }
      long double t = 1.0 / n;
      rep(j, c) t *= 0.5;
      s += t;
    }
  }
  if(n - k + 1 > 0) s += (n - k + 1.0) / n;
  cout << fixed << setprecision(10) << s << endl;
  return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int q;

int main(void) {
  // Here your code !
  scanf("%d", &q);

  priority_queue<ll> left_set;
  priority_queue<ll, vector<ll>, greater<ll>> right_set;

  ll current = 0LL;

  for (int i = 0; i < q; ++i) {
    int type;
    scanf("%d", &type);

    if (type == 1) {
      ll a, b;
      scanf(" %lld %lld", &a, &b);

      current += b;

      if (left_set.empty()) {
        left_set.push(a);
        right_set.push(a);
        continue;
      }

      ll left = left_set.top();
      ll right = right_set.top();

      if (left <= a && a <= right) {
        left_set.push(a);
        right_set.push(a);
      } else if (a < left) {
        right_set.push(left_set.top());
        left_set.pop();

        left_set.push(a);
        left_set.push(a);

        current += left - a;
      } else {  // right < a
        left_set.push(right_set.top());
        right_set.pop();

        right_set.push(a);
        right_set.push(a);

        current += a - right;
      }

    } else {
      ll left = left_set.top();
      printf("%lld %lld\n", left, current);
    }
  }

  return 0;
}


Measured memory_bytes: 4588
#include <stdio.h>
int main(void){
  int n=0,i,a,z;
  char s[200000];
  scanf("%s",s);
  while(s[n]!='\0')n++;
  for(i=0;i<n;i++){
    if(s[i]=='A'){
      a=i;break;
    }
  }
  for(i=n;i>=0;i--){
    if(s[i]=='Z'){
      z=i;break;
    }
  }
  printf("%d",z-a+1);
}

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

signed main(){
	int n;
	cin >> n;
	int sum = 0;
	int prevB = 100000;
	for(int i = 0; i < n; i++){
		int b;
		cin >> b;
		sum += (b < prevB) ? b : prevB;
		prevB = b;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S;cin>>S;
  vector<int> char_set(26,0);
  each(c,S){
    int tmp=(int)c-'a';
    char_set[tmp]++;
  }
  int ans=INF;
  REP(i,0,26){
    if(char_set[i]==0)continue;
    char target=(char)i+'a';
    string S1=S,S2;
    int tmp=0;
    bool flg=false;
    while(!flg){
      flg=true;
      each(c,S1){
        if(c!=target){
          flg=false;
          break;
        }
      }
      if(flg){
        break;
      }
      S2="";
      REP(i,0,S1.size()-1){
        if(S1.at(i)!=target&&S1.at(i+1)!=target){
          S2+='-';
        }
        else{
          S2+=target;
        }
      }
      tmp++;
      S1=S2;

    }
    ans=min(ans,tmp);
  }
  print(ans);

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <unordered_map>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

std::unordered_map<std::string, int> mp;
std::string s[200010], ans[200010];
int n, max, k;

int main()
{
    read(n);
    for (int i = 1; i <= n; ++i)
    {
        std::cin >> s[i];
        ++mp[s[i]];
        max = std::max(max, mp[s[i]]);
    }
    for (int i = 1; i <= n; ++i)
    {
        if (mp[s[i]] == max)
        {
            ans[++k] = s[i];
            mp[s[i]] = 0;
        }
    }
    std::sort(ans + 1, ans + k + 1);
    for (int i = 1; i <= k; ++i)    std::cout << ans[i] << std::endl;
    return 0;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){ if(n>0) initialize(n); }
    void initialize(int n){
        par.resize(n);
        sz.assign(n, 1);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

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

    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    while(Q--){
        int t, a, b;
        cin >> t >> a >> b;
        if(t){
            cout << uf.same(a, b) << endl;
        }else{
            uf.unite(a, b);
        }
    }
    return 0;
}


Measured memory_bytes: 4816
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


ll n;

int main(){
	while(cin>>n,n!=0){
		ll id[4005]={0};
		int a[8000]={0};
		
		rep(i,n){
			ll t1,t2,t3;
			cin>>t1>>t2>>t3;
			a[i]=t1;
			//if(id[t1]>0){
				id[t1]+=t2*t3;
			//}
			/*
			else{
				id[t1]=t2*t3;
			}
			*/
		}
		bool f=true;
		rep(i,4005){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
	return 0;
}

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

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			try{
				String[] strA = insBR.readLine().split(" ");
				int[] intA = new int[strA.length];
				for(int i = 0;i < strA.length ;i++){
					intA[i] = Integer.parseInt(strA[i]);
				}
				if(intA[0] == 0 && intA[1] == 0){
					break;
				}else{
					for(int i = 0;i < intA[0];i++){
						for(int j = 0; j < intA[1];j++){
							System.out.print("#");
						}
						System.out.println();
					}
					System.out.println();
				}
			}catch(IOException e){
				e.printStackTrace();
			}catch(NumberFormatException e){
				e.printStackTrace();
			}
		}
	}

}



Measured memory_bytes: 35300
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC112.A
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            if (n == 1) Console.WriteLine("Hello World");
            else Console.WriteLine(sc.Nextint() + sc.Nextint());
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
# include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
//既存のデータ型の名前をtypedefでllに書き換える
//64ビット以上が保証される
using namespace std;
#include <cmath>
int cnt_digits(ll n){//llは型
  int digits = 0;
  while (n>0){
    n /= 10;
    ++digits;
  }
  return digits;


}

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

  int ans = cnt_digits(N);
  //まず桁数maxである元々のNを答えに置いておく
  for(ll a=1LL;a*a<=N;++a){//LLは整数リテラル、aがlong long型なのでLL型の１
    if(N%a !=0) continue;
    //continueは繰り返し文の処理を飛ばし、ブロックの先頭の位置に戻ってちぎの処理を続ける
    ll b = N/a;
    int c = max(cnt_digits(a),cnt_digits(b));
    //桁数の最小はNの桁数と(aとb)の桁数の最大を比較して小さい方を更新していけばいいので
    ans = min(ans,c);


  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] h = new int[n];
		int twoStep = 0;
		int oneStep = 0;
		for(int i = 0;i < n;i++){
			h[i] = saori.saori_hayami();
		}
		int[] dp = new int[n];
		for(int i = 0;i < n;i++){
			if(i == 0){
				dp[i] = 0;
			} else if(i == 1){
				dp[i] = Math.abs(h[i] - h[i-1]);
			} else {
				twoStep = Math.abs(h[i] - h[i-2]) + dp[i-2];
				oneStep = Math.abs(h[i] - h[i-1]) + dp[i-1];
				if(twoStep < oneStep){
					dp[i] = twoStep;
				} else {
					dp[i] = oneStep;
				}
			}
			
		} 
		System.out.println(dp[n-1]);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22868
//C - Write and Erase: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, x, ans = 0;
    unordered_map<int, bool> cheet;

    cin >> n;
    while(n--) {
        cin >> x;
        if(cheet[x]) cheet[x] = false;
        else cheet[x] = true;
    }  
    for(auto x : cheet) if(cheet[x.fi]) ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=1e7+10;

int k;

int main(){
	cin>>k;
	int val=1,sum=0;
	for(int i=0;i<maxn;i++){
		sum+=7*val%k;
		sum%=k;
		val*=10; val%=k;
		if(sum==0){
			printf("%d\n",i+1);
			return 0;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3760
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int n;
  int max = 50000;
  cin >> n;
  int check;
  check = floor(n);
  for (int i=1;i<=n;i++){
    if (floor(i * 1.08) == n){
      cout << i;
      break;
    }
    if (i == check)
      cout << ":("; 
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[128],b[128];
	int l,r=0;
	while(scanf("%s",s)!=EOF){
		l=strlen(s);
		strcpy(b,s);
		for(int i=0;i<l;i++){
			b[l-(i+1)]=s[i];
		}
		if(strcmp(s,b)==0){
			r++;
		}
		for(int i=0;i<128;i++){
			s[i]=0;
			b[i]=0;
		}
	}
	printf("%d\n",r);
	return 0;
}

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

int main(void){
  string weather;
  cin >> weather;

  if(weather == "Sunny") cout << "Cloudy" << endl;
  if(weather == "Cloudy") cout << "Rainy" << endl;
  if(weather == "Rainy") cout << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        int n,k;
        cin>>n>>k;
        // k=pow(k,2);
        int m=n;
        int c=0;
        while(n--){
            int a,b;
            cin>>a>>b;
            double count=sqrt(pow(a,2)+pow(b,2));
            if(count<=k){
                c++;
            }
        }
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N , Q;
map<ll,vector<ll> > G;
map<ll, bool> used;
vector<ll> cnt;

void cal(ll node){
    rep(i, G[node].size()){
        ll idx = G[node][i];
        if(used[idx]) continue;
        used[idx] = true;
        cnt[idx] += cnt[node];
        cal(idx);
    }
}

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

    cin >> N >> Q;
    
    // はじめは全て0
    rep(i, N){
        cnt.pb(0);
    }
    
    rep(i, N-1){
        ll a, b ;
        cin >> a >> b ;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i, Q){
        ll p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    
    used[0] = true;
    cal(0);
    
    rep(i, N){
        cout << cnt[i] << endl;
    }
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 57072
#include <stdio.h>
int main (void){
	int a;
	int b;
	scanf ("%d%d", &a ,&b);
	if (a < b){
		printf ("a < b\n");
	}
	else if (a > b){
		printf ("a > b\n");
	}
	else {
		printf ("a == b\n");
	}
	return 0;
}

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

int main() {
	long long int N, b = 0, a[100000 * 2] = {}, ans = 0, sum[100000 * 2 + 1] = {}, dif = 0, mini = 1000000000 * 2 + 1;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	for (int i = 0; i < N - 1; i++)
	{
		b = (sum[N] - sum[i + 1]) - sum[i + 1];
		dif = abs(b);
		mini = min(dif, mini);
	}
	cout << mini;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cout<<(#x)<<" is "<<(x)<<endl //to debug values of variables
#define ZINDA cout<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
 
int nDig(lld n)
{
	return floor(log10(n) + 1);
}

//--------------------------------------------------------------------------------
 
int main()
{
    SPEEDUP;
    lld h,i=0;
    cin>>h;

    while(1)
    {
    	if(power(2,i)>h)
    		break;

    	i++;
    }
    //cout<<i<<endl;

    cout<<power(2,i)-1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int r = 0;
    for(int i = a; i <= b; i++){
        int s = i % 10;
        int t = (i / 10000) % 10;
        int u = (i / 10) % 10;
        int v = i / 1000 % 10;
        if( s == t && u == v)
        r++;
    }
    cout << r << endl;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

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

bool used[111111];

int main()
{
	int n;cin >> n;
	vector<int> A(n);
	vector<int> B(n);
	
	REP(i,n){
		cin >> A[i];
		A[i]--;
	}
	REP(i,n){
		cin >> B[i];
		B[i]--;
		used[B[i]] = true;
	}
	
	bool flag = true;
	REP(i,n){
		if(!used[i])flag = false;
	}
	
	if(flag){
		cout << "Yes" << endl;
	}
	
	else{
		cout << "No" << endl;
		REP(i,n){
			cout << 1;
			if(i != n-1)cout << ' ' ;
		}cout << endl;
		REP(i,n){
			if(used[A[i]]){
				cout << 1;
			}
			else{
				cout << 2;
			}
			if(i != n-1)cout << ' ';
		}cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n,k;
    cin>>n>>k;
    vector<double> a(n);
    vector<double> d(n-k+1,0);
    for(int i=0;i<n;i++){
	cin>>a[i];
	a[i]++;
    }
    double sum = 0;
    for(int i=0;i<k;i++){
	sum += a[i]/ 2;
    }
    d[0] = sum;
    for(int i=0;i<n-k;i++){
	sum -= a[i]/2;
	sum += a[i+k]/2;
	d[i+1] = sum;
	//cout<<"OK "<<a[i]<<' '<<a[i+k+1]<<' '<<sum<<endl;
    }
    double e = 0;
    for(auto i:d) e = max(e , i );
    printf("%0.9lf\n",e);
    return 0;
}


Measured memory_bytes: 3328
a, b, m = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = []
for i in range(m):
    x, y, z = map(int, input().split())
    C.append(A[x - 1] + B[y - 1] - z)

min_ = min(min(C), min(A) + min(B))
print(min_)

Measured memory_bytes: 71356
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, m = LI()
ac_set = set()
ac = 0
wa = 0
D = defaultdict(int)
for _ in range(m):
    p, s = LS()
    if s == 'AC':
        if p not in ac_set:
            ac_set.add(p)
            wa += D[p]
            ac += 1
    else:
        if p not in ac_set:
            D[p] += 1


print(ac, wa)



Measured memory_bytes: 60884
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll a, b, c, n=0, k;
	cin >> a >> b >> c >> k;
	vi v(3);
	v[0] = a;
	v[1] = b;
	v[2] = c;
	sort(reall(v));
	rep(i, k) v[0] *= 2;
	rep(i, 3) n += v[i];
	cout << n << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int a, b, c, X;
    cin >> a >> b >> c >> X;
    int ans = 0;
    rep(i, a + 1) {
        rep(j, b + 1) {
            rep(k, c + 1) {
                int total = 500 * i + 100 * j + 50 * k;
                if (total == X) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, A = map(int, raw_input().split())
X = map(int, raw_input().split())

MX = max(X)
Y = [0] + [x - A for x in X]
dp = [[0 for _ in range(2 * N * MX + 1)] for _ in range(N+1)]

for j in range(N+1):
    for t in range(2 * N * MX):
        if j == 0 and t == N * MX:
            dp[j][t] = 1
        elif j >= 1 and t - Y[j] < 0 or t - Y[j] > 2 * N * MX:
            dp[j][t] = dp[j-1][t]
        elif j >= 1 and 0 <= t - Y[j] <= 2 * N * MX:
            dp[j][t] = dp[j-1][t] + dp[j-1][t - Y[j]]
        else:
            dp[j][t] = 0

print dp[N][N*MX] - 1


Measured memory_bytes: 5380