akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    getchar();
    char ara[x][y];
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            scanf(" %c",&ara[i][j]);
        }
    }
 for(int i=0;i<y;i++){
        int f=0;
        for(int j=0;j<x;j++){
            if(ara[j][i]=='.' || ara[j][i]==0) f=1;
            else {
                f=0;
                break;
            }
        }
        if(f==1){
            for(int j=0;j<x;j++){
                ara[j][i]=0;
            }
        }
    }
    for(int i=0;i<x;i++){
        int f=0;
        for(int j=0;j<y;j++){
            if(ara[i][j]=='.' || ara[i][j]==0 ) f=1;
            else {
                f=0;
                break;
            }
        }
        if(f==1){
            for(int j=0;j<y;j++){
                ara[i][j]=0;
            }
        }
    }
    for(int i=0;i<x;i++){
        int flag=0;
        for(int j=0;j<y;j++){
             if(ara[i][j]!=0){
                 printf("%c",ara[i][j]);
                 flag=1;
             }
        }
        if(flag==1) printf("\n");
    }
}

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

int main() {
	int N; cin >> N;
	int L[2 * N];
	for (int i = 0; i < 2 * N; i++) {
		cin >> L[i];
	}
	sort(L, L + 2 * N);
	int ans = 0;
	for (int i = 0; i <= 2 * N - 2; i += 2) {
		ans += L[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m) cin >> x[i];
    sort(all(x));
    vector<int> s;
    rep(i,m-1) {
        int temp = x[i+1] - x[i];
        s.push_back(temp);
    }
    sort(all(s), greater<int>());
    ll ans = 0;
    rep(i,s.size()) {
        if(i<n-1) continue;
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoder.B
{
    public class Program
    {
        public static int H { get; private set; }
        public static List<int> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            H = inputs[0];
            A = CR.GetIntegers().ToList();

            return A.Sum() >= H ? "Yes" : "No";
        }
    }
}


Measured memory_bytes: 19296
#include <iostream>
using namespace std;
string a;
int m, s;
int main() {
	int i, j;
	cin>>a;
	for(i=1; i<a.size()-1; i+=2) {
		m = i/2 + 1;
		for(j=0; j<m; j++) if(a[j] != a[m+j]) break;
		if(j==m) s = i+1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = input()
N = int(N)
stN = str(N)
p = input().split()
p_l = [int(s) for s in p]

p_sort = sorted(p_l,reverse=True)
#print(p_sort)
for i in range(0,N-1):
    x = p_sort.pop()
    y = p_sort.pop()
    z = (x+y)/2
    p_sort.append(z)
    #print(p_sort)

print(p_sort[0])

Measured memory_bytes: 21256
let lcs x y =
  let m = String.length x in
  let n = String.length y in
  let dp = Array.make_matrix (m+1) (n+1) 0 in
  let rec doit = function
    | (i, _) when i > m -> dp.(m).(n)
    | (i, j) when j > n -> doit (i + 1, 1)
    | (i, j) ->
      dp.(i).(j) <- if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1 else if dp.(i-1).(j) > dp.(i).(j-1) then dp.(i-1).(j) else dp.(i).(j-1);
      doit (i, j + 1)
  in doit (1, 1)

let () =
  let q = read_int () in
  let rec doit i =
    if i < q then begin
      let x = read_line () in
      let y = read_line () in
      Printf.printf "%d\n" (lcs x y);
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 18500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string N;
  cin>>N;
  rep(i,3){
    if(N.at(i)=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }else if(i==2){
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	cout<< max(a*c, max(a*d, max(b*c, b*d)));
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    string S,T;
    int Q;
    cin >> S >> Q;

    rep(i, 0, Q){
        int qr;
        cin >> qr;
        if(qr==2){
            int F;
            char C;
            cin >> F >> C;
            if(F==1){
                T+=C;
            }else{
                S+=C;
            }
        }else{
            swap(S, T);
        }
        
    }
    reverse(T.begin(), T.end());
    T+=S;
    cout << T << endl;
    return 0;
}


Measured memory_bytes: 1128
N=int(input())
A=[int(i) for i in input().split()]
P=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]%P
Q=[0 for i in range(N)]
I=[inv(i) for i in range(1,N+2)]
U=[0 for i in range(N+2)]
Fact=[0 for i in range(N+1)]
Fact[0]=1
for i in range(N):
    Fact[i+1]=((i+1)*Fact[i])%P
for i in range(N+1):
    U[i+1]=(U[i]+I[i])%P
for j in range(N):
    Q[j]=(U[j+1]+U[N-j]-1)%P
ans=0
for j in range(N):
    ans+=A[j]*Q[j]
    ans=ans%P
print((ans*Fact[N])%P)


Measured memory_bytes: 23168
s = input()
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n,k=gets.split.map(&:to_i)
as=gets.split.map(&:to_i)
check=[-1]*n
check[0]=0
i=0
to=0
d=0
while true
  i+=1
  to=as[to]-1
  if i==k
    puts to+1
    exit
  end
  if check[to]>=0
    d=i-check[to]
    break
  else
    check[to]=i
  end
end
m=(k-check[to])%d
puts check.index(check[to]+m)+1


Measured memory_bytes: 28976
#include<stdio.h>
int main(void){
	int a,b,c,k,i;
  	int count;
  	count = 0;
  	scanf("%d",&a);
  	scanf("%d",&b);
    scanf("%d",&k);
  if (a > b){
    c = a;
  }else{
    c = b;
  }
  for(i = 100; i >= 1 ; i--){
    if (a%i == 0 && b%i == 0){
      count = count + 1;
      if (count == k){
        printf("%d",i);
        break;
      }
    }
   }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  if (n%2 == 0) {
    for (int i = 0; i < n; i+=2) {
      if (a[i] != i+1 || a[i+1] != i+1 || a[i] == 0 || a[i+1] == 0) {
	dump(0);
	return 0;
      }
    }
  }
  else {
    if (a[0] != 0) {
      dump(0); 
      return 0;
    }
    for (int i = 1; i < n; i+=2) {
      if (a[i] != i+1 || a[i+1] != i+1 || a[i] == 0 || a[i+1] == 0) {
	dump(0);
	return 0;
      }
    }
  }
  ll res = 1;
  ll mod = 1e9+7;
  for (int i = 0; i < n/2; i++) {
    res *= 2;
    if (res >= mod) res %= mod;
  }
  dump(res);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	string s;
	cin >> s;
	int temp = 0;
	int ans = 0;
	for (int i = 0; i < 3; i++){
		if (s[i] == 'R') temp++;
		else temp = 0;
		ans = max(ans, temp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner

import scala.util.control.Breaks

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val x = sc.nextInt()
    val y = sc.nextInt()


    if (y % 2 != 0) {
      println("No")
    } else if (2 * x <= y && y <= 4 * x) {
      println("Yes")
    } else {
      println("No")
    }

  }

}


Measured memory_bytes: 55284
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    ll n; cin>>n;
    string s;
    int c0=0, c1=0, c2=0, c3=0;
    for(int i=0; i<n; i++){
        cin>>s;
        if(s=="AC")c0++;
        else if(s=="WA")c1++;
        else if(s=="TLE")c2++;
        else if(s=="RE")c3++;
    }
    cout<<"AC x "<<c0<<endl;
    cout<<"WA x "<<c1<<endl;
    cout<<"TLE x "<<c2<<endl;
    cout<<"RE x "<<c3<<endl;


    return 0;
}

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

using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

int main() {
    ll H, W, K, i, j;
    cin >> H >> W >> K;
    char A[H][W];
    ll ret[H][W];
    ll done[H] = {};
    for(i = 0; i < H; i++) {
        for(j = 0; j < W; j++) {
            ret[i][j] = 0;
        }
    }
    ll now = 1;
    for(i = 0; i < H; i++) {
        for(j = 0; j < W; j++) {
            cin >> A[i][j];
            if(A[i][j] == '#') {
                ret[i][j] = now++;
            }
        }
    }
    for(i = 0; i < H; i++) {
        ll ok = 0;
        for(j = 0; j < W; j++) {
            if(ret[i][j] != 0) {
                done[i] = 1;
                ok = 1;
                for(ll h = j - 1; h >= 0; h--) {
                    if(ret[i][h] != 0) break;
                    ret[i][h] = ret[i][j];
                }
                for(ll h = j + 1; h < W; h++) {
                    if(ret[i][h] != 0) break;
                    ret[i][h] = ret[i][j];
                }
            }
        }
        if(ok == 0 && i != 0 && done[i - 1] != 0) {
            for(j = 0; j < W; j++) {
                ret[i][j] = ret[i - 1][j];
            }
            done[i] = 1;
        }
        if(done[i] == 1) {
            for(ll h = i - 1; h >= 0; h--) {
                if(done[h] == 1) break;
                for(j = 0; j < W;j++){
                    ret[h][j] = ret[h + 1][j];
                }
            }
        }
    }
    for(i = 0; i < H;i++){
        for(j = 0; j < W;j++){
            cout << ret[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
n=int(input())
w=list(map(int,input().split()))
sa=[]
w1=[]
w2=[]
for i in range(n):
  w1=w[:i]
  w2=w[i:]
  sa.append(abs(sum(w1)-sum(w2)))
  w1=[]
  w2=[]
print(min(sa))

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> a(N), x(N), y(N), z(N);
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      x.at(i) = x.at(i-1);
      y.at(i) = y.at(i-1);
      z.at(i) = z.at(i-1);
    }
    bool flag = true;
    int cnt = 0;
    if (A.at(i) == x.at(i)) {
      cnt++;
      x.at(i)++;
      flag = false;
    }
    if (A.at(i) == y.at(i)) {
      cnt++;
      if (flag) {
        y.at(i)++;
        flag = false;
      }
    }
    if (A.at(i) == z.at(i)) {
      cnt++;
      if (flag) z.at(i)++;
    }
    a.at(i) = cnt;
  }
  long long ans = 1;
  for (int i = 0; i < N; i++) {
    ans = ans * a.at(i) % 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pa;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
int getgcd(int x,int y){return !x?y:getgcd(y%x,x);}
const int maxn=1e4+5,mod=998244353;
int n,cnt0,cnt1;
char A[maxn],B[maxn];
int fac[maxn],ifac[maxn],f[maxn];
int main(){
	scanf("%s",A+1);
	scanf("%s",B+1);
	n=strlen(A+1);
	rep(i,1,n){
		if(A[i]=='1'&&B[i]=='0')cnt0++;
		if(A[i]=='1'&&B[i]=='1')cnt1++;
	}
	fac[0]=1;rep(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	rep(i,0,n)ifac[i]=power(fac[i],mod-2,mod);
	f[0]=1;
	rep(i,1,cnt0)rep(j,1,cnt1)f[j]=(f[j]+1ll*i*f[j-1])%mod;
	int ans=0;
	rep(j,0,cnt1)ans=(ans+1ll*f[j]*ifac[cnt0+j])%mod;
	ans=1ll*ans*fac[cnt0+cnt1]%mod;
	printf("%lld\n",1ll*ans*fac[cnt0]%mod*fac[cnt0]%mod*fac[cnt1]%mod);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


ll n;
ll m;

int main(){
  cin>>n;
  rep(i,5){
    ll a;
    cin>>a;
    m = max(m,(n+a-1)/a);
  }

  cout<<5+m-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

int N;
#define MV 10
#define INF 0x7F7F7F7F
int G[MV][MV];
bool input() {
    scanf("%d", &N);
    if (N == 0) return false;
    memset(G, 0x7F, sizeof(G));
    for (int i = 0; i < N; i++) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        G[a][b] = G[b][a] = c;
        G[a][a] = 0;
        G[b][b] = 0;
    }
    return true;
}

void solve() {
    for (int k = 0; k < MV; k++) {
        for (int i = 0; i < MV; i++) {
            for (int j = 0; j < MV; j++) {
                if (G[i][k] == INF || G[k][j] == INF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
#ifdef DEBUG
    for (int i = 0; i < MV; i++) {
        for (int j = 0; j < MV; j++) {
            if (G[i][j] == INF) {
                cout << setw(5) << "x";
            } else {
                cout << setw(5) << G[i][j];
            }
        }
        cout << endl;
    }
#endif
    int index = 0, min1 = INF; 
    for (int i = 0; i < MV; i++) {
        bool NOSUCHTOWN = true;
        for (int j = 0; j < MV; j++) {
            if (G[i][j] != INF) {
                NOSUCHTOWN = false;
                break;
            }
        }
        if (NOSUCHTOWN) break;
        int total = 0;
        for (int j = 0; j < MV; j++) {
            if (G[i][j] == INF) break;
            total += G[i][j];
        }
        if (total < min1) {
            index = i;
            min1 = total;
        }
    }
    printf("%d %d\n", index, min1);
}

int main() {
    while (input()) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define first fi
#define second se
#define MOD 1000000007
#define MAXN 200005
#define endl "\n"
#define readln(x) getline(cin, x);
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
ll fpow(ll x, ll n, ll mod){if (n==0) return 1%mod; ll u = fpow(x, n/2, mod); u = (u*u)%mod; if (n%2==1)u = (u*x)%mod;return u;}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
 
ll N, a[MAXN], freq[MAXN];

int main(){
    //freopen("data.txt","r",stdin);
    cin >> N;
    for (int i = 1; i<=N; i++){
        cin >> a[i];
        freq[a[i]]++;
    }
    ll total = 0;
    for (int i = 1; i<=N; i++){
      	if (freq[i] >= 2){
          total  += ((freq[i])*(freq[i]-1))/2;
        }
    }
    for (int i = 1; i<=N; i++){
        ll temp = total;
        temp -= ((freq[a[i]])*(freq[a[i]]-1))/2;
        temp += ((freq[a[i]]-1)*(freq[a[i]]-2))/2;
      	if (temp < 0) cout << 0 << endl;
        else cout << temp << endl;
    }
 
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,k;
	cin>>n>>k;
	int ans = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if( x >= k ) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    string S;

    cin >> S;
/*
    for(int i=0;i<10;i++){
        cout << S[i] << endl;
    }
*/
    //if(S[3]=='7'){
        S[3]='8';
    //}

    cout << S <<endl;

    return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    string s[n];
    rep(i, n) { cin >> s[i]; }
    ll c[4] = {};
    rep(i, n) {
        if (s[i] == "AC") {
            c[0]++;
        }
        if (s[i] == "WA") {
            c[1]++;
        }
        if (s[i] == "TLE") {
            c[2]++;
        }
        if (s[i] == "RE") {
            c[3]++;
        }
    }

    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    return 0;
}



Measured memory_bytes: 6752
n = int(input())
s = input()
left = 0
right = n-1
ans = 0
while left!=right:
    if left+1 == right:
      if s[left]=="W" and s[right]=="R":
        ans += 1
        print(ans)
        exit()
      else:
        print(ans)
        exit()
    if s[left]!="W":
        left += 1
    else:
        if s[right]!="R":
            right -= 1
        else:
            right -= 1
            left += 1
            ans += 1
  #  print(left,right,ans)
print(ans)

Measured memory_bytes: 9416
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

lint ok_num(lint n, lint num, lint seven, lint five, lint three, lint zero, lint depth)
{
    if (num > n)
        return 0;
    if (depth == 9)
    {
        if (seven && five && three)
            return 1;
        else
            return 0;
    }

    lint out = 0;

    if (zero)
    {
        out += ok_num(n, num, seven, five, three, zero, depth + 1);
    }

    out += ok_num(n, num * 10 + 7, 1, five, three, 0, depth + 1);
    out += ok_num(n, num * 10 + 5, seven, 1, three, 0, depth + 1);
    out += ok_num(n, num * 10 + 3, seven, five, 1, 0, depth + 1);

    return out;
}

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

    std::cout << ok_num(n, 0, 0, 0, 0, 1, 0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a1,b1,c1,i;
	char a[100],b[100],c[100];
	scanf("%s %s %s",a,b,c);
	a1=strlen(a);
	b1=strlen(b);
	c1=strlen(c);
	if(a[a1-1]==b[0]&&b[b1-1]==c[0]) printf("YES\n");
	else printf("NO\n");
	return 0;
}	

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
ll modpow(ll a,ll n,ll mod){
	ll res=1;
	while(n){
		if(n&1)(res*=a)%=mod;
		(a*=a)%=mod;
		n>>=1;
	}
	return res;
}
int main(){
	ll n;
	cin>>n;
	string x;
	cin>>x;
	// V<ll> res(n+1,0);
	// for(ll i=1;i<=n;i++){
	// 	ll now=i,cnt=0;
	// 	while(now){
	// 		now%=__builtin_popcountll(now);
	// 		cnt++;
	// 	}
	// 	res[i]=cnt;
	// }
	ll cnt=0;
	V<ll> two(n+1,0);
	for(int i=0;i<n;i++){
		if(x[i]=='1')cnt++;
		two[i+1]=cnt;
	}
	ll d=cnt;
	ll a=0,b=0;
	for(int i=0;i<n;i++){
		if(x[i]=='1')a+=modpow(2,n-i-1,d+1);
		a%=(d+1);
	}
	if(d-1>1){
			for(int i=0;i<n;i++){
		if(x[i]=='1')b+=modpow(2,n-i-1,d-1);
		b%=(d-1);
	   }
	}
	for(int i=0;i<n;i++){
		ll t;
		if(x[i]=='1')t=cnt-1;
		else t=cnt+1;
		if(t==0){
			cout<<0<<"\n";
			continue;
		}
		if(t==1){
			cout<<1<<"\n";
			continue;
		}
		ll tmp=0;
		if(t==d+1){
			  tmp=a;
			  tmp+=modpow(2,n-i-1,d+1);
			  tmp%=t;
		}else{
			 tmp=b;
			tmp-=modpow(2,n-i-1,d-1);
			tmp+=d-1;
			tmp%=t;
		}
		ll ans=1;
		while(tmp){
			ans++;
			tmp%=__builtin_popcountll(tmp);
		}
		cout<<ans<<"\n";
	}
	
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n;
   cin>>n;
   int a,b;
   cin>>a>>b;
   long long int sum=0;
   for(int i=1;i<=n;i++)
   {
      int t=i;
      int dig=0;
      while(t)
      {
        dig=dig+t%10;
        t=t/10;
      }
      if(dig<=b && dig>=a)
      { 
        sum+=i;
      }
   }
   cout<<sum;

 return 0;
}








Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s,k,p,q,cn,l;
    vector<int>v;
     vector<int>v1;
      vector<int>v2;
      cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
        v1.push_back(s);
    }
    for(int i=0;i<n;i++)
    {
        cin>>k;
        v2.push_back(k);
    }
    sort(v.begin(),v.end());
    cn=0;
    do{
    cn++;
    if(v1==v)
    {
        p=cn;
    }
    if(v2==v)
    {
        q=cn;
    }
    }while(next_permutation(v.begin(),v.end()));
    if(p>=q)
    {
        cout<<p-q<<endl;
    }
    else
        cout<<q-p<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static boolean echo(int N, String str) {
        if (N % 2 == 1) return false;
        for (int i = 0; i < N / 2; i++) {
            if (str.charAt(i) != str.charAt(N / 2 + i)) return false;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String S = in.next();
        System.out.println(echo(N, S) ? "Yes" : "No");
        in.close();
    }
}



Measured memory_bytes: 21844
package main

import (
  "fmt"
)

func min(a, b int) int {
  if a < b {
    return a
  }
  return b
}

func max(a, b int) int {
  if a < b {
    return b
  }
  return a
}

func main() {
  var a, b, c int
  fmt.Scan(&a, &b, &c)
  minv := min(a, min(b, c))
  maxv := max(a, max(b, c))
  mid := a + b + c - (minv + maxv)
  fmt.Println(minv, mid, maxv)
}



Measured memory_bytes: 1120
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,d; cin>>n>>d;
    int ans=0;
    if(n<=d) ans=1;
    else {

        if (n % (2 * d + 1) != 0) ans = n / (2 * d + 1) + 1;
        else ans = n / (2 * d + 1);
    }
    cout<<ans<<endl;
    return  0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
const ld PI = 3.14159265358979323846;

int n;
ld x[1005], y[1005], X, Y, d, e;

ld dist(ld a, ld b) {
    return a * a + b * b;
}

int main() {
    cout.precision(20);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        X += x[i];
        Y += y[i];
    }
    X /= n;
    Y /= n;
    double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        for (int j = 1; j < n; j++) {
            e = dist(X - x[j], Y - y[j]);
            if (d < e) {
                d = e;
                f = j;
            }
        }
        X += (x[f] - X) * P;
        Y += (y[f] - Y) * P;
        P *= 0.999;
    }
    cout << sqrt(d) << "\n";
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<char> ans;
    ll cnt=0;
    while(N>0){
        N--;
        ll num=N%26;
        char ss='a';
        REP(i,num) ss++;
        ans.push_back(ss);
        cnt++;
        N/=26;
    }
    REP(i,ans.size()){
        cout<<ans[ans.size()-i-1];
    }
    cout<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
const int N=100+5;
ll A,B;
void input()
{
	A=read<ll>(),B=read<ll>();
}
void work()
{
	ll ans=0;
	ll d=59;
	while(~d&&!(((A^B)>>d)&1))d--;
	ll E=A;
	E|=1ll<<d;
//	E&=(((1ll<<60)-1)^((1ll<<d)-1));
	ll F=A|((1ll<<(d+1))-1);
	//cout<<E<<' '<<F<<endl;
	d--;
	while(~d&&!((B>>d)&1))d--;
	ll G=B;
	G|=((1ll<<(d+1))-1);
	//cout<<A<<' '<<G<<endl;
	//cout<<E<<' '<<F<<endl;
	if(G>=E)write(F-A+1,'\n');
	else write(G-A+1+F-E+1,'\n');
}
int main()
{
	
	input();
	work();
	return 0;
}



Measured memory_bytes: 256
a,b,m = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
br = list(map(int,input().split(" ")))
A = min(ar) + min(br)
for i in range(m):
    l = list(map(int,input().split(" ")))
    B = (ar[l[0]-1] + br[l[1]-1]) - l[2]
    if A > B:
        A = B
print(A)

Measured memory_bytes: 18736
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	char a,b;
	cin>>a>>b;
	cout<<(a==b?'H':'D')<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back 
#define f first
#define s second
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9;
//const ll INF = 1e18;
const ll mod = 1000000007;
// const ll mod = 998244353;

bool fir(pii a){
	return a.f == 0 || a.s == 0;
}
void solve(int tc){
	string a, b;
	cin >> a >> b;

	vector<vector<pair<int, pii>>> dp(a.length() + 1, vector<pair<int, pii>>(b.length() + 1, {-1, {0, 0}}));
	dp[0][0] = {0, {0, 0}};
	for(int i = 0; i < a.length(); i++)
		for(int j = 0; j < b.length(); j++){
			if(a[i] == b[j]){
				dp[i+1][j+1] = max(dp[i+1][j+1], {dp[i][j].f + 1, {i, j}});
			}

			dp[i+1][j] = max(dp[i+1][j], {dp[i][j].f, {i, j}});
			dp[i][j+1] = max(dp[i][j+1], {dp[i][j].f, {i, j}});
		}

	pair<int, pii> an = {0, {0, 0}};
	for(int i = 0; i <= a.length(); i++)
		for(int j = 0; j <= b.length(); j++)
			an = max(an, {dp[i][j].f, {i, j}});

	string s;
	pii cur = an.s;
	while(!fir(cur)){
		int i = cur.f;
		int j = cur.s;
		pii prev = dp[i][j].s;
		if(prev == make_pair(i-1, j-1)){
			//assert(a[i-1] == b[j-1]);
			s += a[i-1];
		}
		cur = prev;
	}
	reverse(all(s));
	cout << s << "\n";	
}

int main(){
	/*ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);*/
	
	int tc = 1;
	//cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);

	return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e6 + 1;

ll fact[MAX_N];

ll power(ll x, ll n) {
  ll res = 1ll;
  while (n > 0) {
    if (n & 1) {
      (res *= x) %= MOD;
    }
    (x *= x) %= MOD;
    n >>= 1;
  }
  return res % MOD;
}

ll inverse(ll n) {
  return power(n, MOD - 2);
}

ll nCr(ll n, ll r) {
  return ((fact[n] * inverse(fact[n - r])) % MOD * inverse(fact[r])) % MOD;
}


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

  CIN(H, W, A, B);

  fact[0] = 1ll;
  FOR(i, 1, MAX_N) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
  
  ll ans = 0ll;
  REP(hi, H - A) {
    ans += nCr(B + hi - 1, hi) * nCr(W - B + H - hi - 2, H - hi - 1);
    debug(W + H - B - hi - 2);
    debug(W - B - 1);
    debug(ans);
    cout << endl;
    ans %= MOD;
  }

  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi a(n);
    rep(i,n)cin>>a[i];
    int sum=32;
    bool ans=false;
    rep(j,30){
      rep(i,n){
	sum-=(sum-1)%5;
	cout<<sum<<endl;
	sum-=min(sum,a[i%n]);
	cout<<sum<<endl;
	if(sum==0){
	  ans=true;
	  break;
	}
      }
      if(ans)break;
    }
  }
}

Measured memory_bytes: 2992
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll x, ans=0;
	cin >> x;
	ans+=1000*(x/500);
	x%=500;
	ans+=5*(x/5);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int main(){
    ll n,ans = 0;
    cin>>n;
    vector<ll>bitcnt(60,0);
    rep(i,n){
        ll a;
        cin>>a;
        rep(j,60){
            if(a & (1LL << j)){
                bitcnt[j]++;
            }
        }
    }
    rep(i,60){
        ll standbit =  (n - bitcnt[i]) * bitcnt[i];
        ans += ((1LL << i)%MOD * (standbit%MOD))%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){
  
  int n;
  cin >> n;
  
  int ans = MOD;
  REP(i,n-1){
    int a = i+1;
    int b = n - a;
    
 //   debug(a);
   // debug(b);
    
    int sum = 0;
    while(a != 0 || b != 0){
      sum += a%10;
      sum += b%10;
      a /= 10;
      b /= 10;
    }
 //   debug(sum);
    ans = min(sum,ans);
    
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : x : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Double]
  print . (* (180 / pi)) . atan $ if 2 * x <= a ^ 2 * b then (a * b ^ 2) / (2 * x) else 2 * (a ^ 2 * b - x) / (a ^ 3)

unsafeSignedDecimal :: T.Text -> Double
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> fromIntegral n



Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
int main(void){
  string s; int n; ll ans=0;
  cin >> s;
  n = s.size();
  FOR(i,0,1<<(n-1)){
    int dgt = 1; ll tmp=0;
    tmp = s[0]-'0';
    while(dgt<n){
      if(  ((i>>(dgt-1))&1)==1  ){
        ans += tmp; //cout << tmp << endl;
        tmp = 0;
      }
      tmp *= 10;
      tmp += (s[dgt]-'0');
      dgt++;
    }
    ans += tmp; //cout << tmp << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*****************************************************

@author: blue_is_love
Compiled On: 25th May 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e3+7;

int pow(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x);
        y >>= 1;
        x = (x * x);
    }
    return r;
}


int n, v[55];
bool vis[55];

int left(int k)
{
    if(k==0)
        return 0;
    int ans = 0, s = 0;
    for(int i=0;i<min(k, n);i++){
        s += v[i];
        int kk = i+1;
        vector<int> x;
        for(int j=0;j<=i;j++)
        {
            if(v[j]<0)
                x.pb(v[j]);
        } 
        sort(x.begin(), x.end());
        // reverse(x.begin(), x.end());
        int ts = s;
        ans = max(ans, s);
        // cout<<ts<<" ";
        for(int j=0;j<x.size();j++)
        {
            ts -= x[j];
            kk++;
            // cout<<ts<<" "<<kk<<endl;
            
            if(kk<=k)
                ans = max(ans, ts);
            else
                break;
        }
    }
    return ans;
}

int right(int k)
{
    if(k==0)
        return 0;
    int ans = 0, s = 0;
    for(int i=n-1;i>=max(0ll, n-k);i--){
        s += v[i];
        int kk = n-i;
        vector<int> x;
        for(int j=i;j<n;j++)
        {
            if(v[j]<0)
                x.pb(v[j]);
        } 
        sort(x.begin(), x.end());
        // reverse(x.begin(), x.end());
        int ts = s;
        ans = max(ans, s);
        for(int j=0;j<x.size();j++)
        {
            ts -= x[j];
            kk++;
            // cout<<ts<<" "<<kk<<endl;
            if(kk<=k)
                ans = max(ans, ts);
            else
                break;
        }
    }
    return ans;
}

void solve()
{
	int k; cin>>n>>k;
    // int v[n];
    for(int i=0;i<n;i++)
        cin>>v[i];

    int ans = 0;
    // cout<<right(k)<<endl;
    for(int i=0;i<=k;i++)
    {
        int tans = left(i)+right(k-i);
        // cout<<tans<<" ";
        ans = max(ans, tans);
    }
    int x = 0;
    for(int i=0;i<n;i++)
        if(v[i]>0)
            x+=v[i];
    if(ans > x)
        ans = x;
    cout<<ans;
}


signed main()
{
    fast;

    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	auto V=vecin<ll>(N);
	ll sum=0;
	REP(i,N){
		sum += V[i]/2LL;
		if(i<N-1 && V[i]%2LL && V[i+1]){
			sum++;
			V[i+1]--;
		}
	}
	out(sum);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,wgt;
	cin>>n>>wgt;
	int inp[n][2];
	for(int i=0;i<n;i++) cin>>inp[i][0]>>inp[i][1];
	int dp[wgt+1][n];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) dp[inp[i][0]][i] = inp[i][1];
	int ans = 0;
	for(int i=1;i<=wgt;i++){
		for(int j=0;j<n;j++){
			int nw = i + inp[j+1][0];
			if(nw<=wgt && j<n-1) dp[nw][j+1] = max(dp[nw][j+1],dp[i][j] + inp[j+1][1]);
			if(j<n-1) dp[i][j+1] = max(dp[i][j+1],dp[i][j]);
			ans = max(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

int main() {
    int r, d, x_2000;
    cin >> r >> d >> x_2000;
    int x[11];
    x[0] = x_2000;
    for (int i = 1; i < 11; i++) {
        x[i] = r * x[i-1] - d;
        cout << x[i] << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (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 i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define INF (((ll)1<<31)-1)

class segtree{
public:
  int Node;
  vector<ll> table;
  segtree(int);
  int ope(const int,const int);
  void update(int index,const int value){ // index is 0-indexed.
    index += Node; // query function
    table[index] = value;//update section
    while(index > 0){
      index /= 2;
      table[index] = ope(table[2*index],table[2*index+1]);
    }
  }
  int find(int l, int r);
};
int segtree::find(int l,int r){ // l,r is 0-indexed.
    if(l == r) return table[r+Node];
    l += Node; r += Node;
    int ans = INF;
    for(; l <= r;l >>=1, r >>=1){
      if(r == l){ans=ope(ans,table[l]); return ans;}
      if(r%2 == 0) ans=ope(ans,table[r]),--r;
      if(l%2) ans=ope(ans,table[l]),++l;
    }
    return ans;
}
segtree::segtree(int Max_Node){  // initialize
  Node = 2;
  while(Node < Max_Node)
    Node *= 2;
  table.resize(2*Node);
  for(int i = Node;i < Node*2; i++)
    table[i] = INF; // initialize
  for(int i= Node-1; i > 0; i--)
    table[i] = ope(table[i*2],table[i*2+1]);
}

int segtree::ope(const int a,const int b){
  return min(a,b);
}

int main()
{
	int n,q;
	cin >> n >> q;
	
	segtree seg(n);
	
	//SHOW1d(seg.table,(seg.Node*2));
	
	REP(i,q)
	{
		int a,b,c;
		cin >> a >> b >> c;
		
		if(a)
		{
			cout << seg.find(b,c) << endl;
		}
		else
		{
			seg.update(b,c);
		//	SHOW1d(seg.table,(seg.Node*2));
		}
	}
	
	return 0;
}

Measured memory_bytes: 4920