akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int H;
int A[500000];

int L(int i){
        return 2*i;
}
int R(int i){
        return 2*i+1;
}
void maxHeapify(int i){
        int Large,swap;
        int l=L(i);
        int r=R(i);
        if(l<=H&&A[l]>A[i]) {
                Large=l;
        }
        else{
                Large=i;
        }
        if(r<=H&&A[r]>A[Large]) {
                Large=r;
        }
        if(Large!=i) {
                swap=A[i];
                A[i]=A[Large];
                A[Large]=swap;
                maxHeapify(Large);
        }
}
/*void buildmaxHeap(A[]){
   for(int i=H/2;i>1;i--){
    maxHeapify( A[],i)
   }*/
int main(){
        int i;
        scanf("%d",&H);
        for (i=1; i<=H; i++) {
                scanf("%d",&A[i]);
        }
        for(i=H/2; i>=1; i--){
          maxHeapify(i);
        }

                for(i=1; i<=H; i++) {
                        printf(" %d",A[i]);
                }
        printf("\n");
        return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;

  vector<string> vs(h);
  for (int i = 0; i < h; ++i) {
    cin >> vs[i];
  }

  for (int i = 0; i < h; ++i) {
    cout << vs[i] << '\n';
    cout << vs[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n, m;
    cin >> n >> m;
    multiset<int> s;
    for (int i = 0; i < n; ++i) {
        int el;
        cin >> el;
        s.insert(el);
    }
    for (int i = 0; i < m; ++i) {
        auto it = s.end();
        --it;
        int el = *it;
        s.erase(it);
        s.insert(el / 2);
    }
    int64_t sum = 0;
    els(s) {
        sum += el;
    }
    cout << sum << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 4992
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main() {
  int n,i,j,k,c,u,v,minv,M[MAX][MAX],d[MAX],vis[MAX];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) {
    for(j = 0 ; j < n ; j++) {
      M[i][j] = INFTY;
    }
  }

  for(i = 0 ; i < n ; i++) {
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++) {
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  for(i = 0 ; i < n ; i++) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1) {
    minv = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++) {
      if(minv > d[i] && !vis[i]) {
	u = i;
	minv = d[i];
      }
    }

    if(u == -1)
      break;
    vis[u] = 1;
    for(v = 0 ; v < n ; v++) {
      if(!vis[v] && M[u][v] != INFTY) {
	if(d[v] > d[u] + M[u][v]) {
	  d[v] = d[u] + M[u][v];
	}
      }
    }
  }

  for(i = 0 ; i < n ; i++) {
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }
  return 0;
}



Measured memory_bytes: 2112
import sys
from collections import deque

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def paint_col(adj, cols, i, col):
    nxt = deque([i])

    while nxt:
        u = nxt.popleft()
        cols[u] = col
        for child in adj[u]:
            if cols[child] == 0:
                nxt.append(child)

def solve():
    n, m = map(int, sys.stdin.readline().split())
    adj = [[] for i in range(n)]

    for i in range(m):
        s, t = map(int, sys.stdin.readline().split())
        adj[s].append(t)
        adj[t].append(s)

    cols = [0] * n
    col = 1

    for i in range(n):
        if cols[i] == 0:
            paint_col(adj, cols, i, col)
            col += 1

    q = int(sys.stdin.readline())

    for i in range(q):
        s, t = map(int, sys.stdin.readline().split())

        if cols[s] == cols[t]:
            ans = 'yes'
        else:
            ans = 'no'

        print(ans)

if __name__ == '__main__':
    solve()

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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    string S;
    cin>>S;

    for (ll i = S.length()-2; i >= 0; i--) {
        if (i % 2 == 0) continue;
        bool flag = false;
        for (ll s = 0; s < i / 2; s++)
            if (S[s] != S[(i+1)/2+s]) {
                flag = true;
                break;
            }

        if (!flag) {
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}

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

const long long INF=1LL<<60;

vector<long long> h(110010);
vector<long long> dp(110010,INF);


int main(){
  int N,K;
  cin>>N>>K;
  for(int i=0; i<N; i++){
    cin>>h.at(i);
  }
  dp.at(0)=0;
  for(int i=0; i<N; i++){
    for(int j=1; j<=K; j++){
      dp.at(i+j)=min(dp.at(i+j),dp.at(i)+abs(h.at(i)-h.at(i+j)));
    }
  }
  cout<<dp.at(N-1)<<endl;
}
  



Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string s;
  int N_AC=0;
  int N_WA=0;
  int N_TLE=0;
  int N_RE=0;
	for (int i = 0; i < N; i++) {
		cin >> s;
        if (s=="AC") N_AC++;
        else if (s=="WA") N_WA++;
        else if (s=="TLE") N_TLE++;
        else if (s=="RE") N_RE++;
	}
cout << "AC x " << N_AC << endl;
cout << "WA x " << N_WA << endl;
cout << "TLE x " << N_TLE << endl;
cout << "RE x " << N_RE << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

bool g[777][777];
int n,x[777],bc,wc;

bool dfs(int v, int c){
	int i;
	x[v] = c;
	if(c>0){
		++bc;
	}else{
		++wc;
	}
	for(i=0; i<n; ++i){
		if(!g[v][i]){
			continue;
		}
		if(x[i]==c){
			return false;
		}else if(x[i]==0 && (!dfs(i,-c))){
			return false;
		}
	}
	return true;
}

bool dp[777][777];

int main(void){
	int m,a,b,cnt,i,j,ans=INF;
	fill(g[0],g[777],true);
	fill(dp[0],dp[777],false);
	dp[0][0] = true;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		g[i][i] = false;
	}
	for(i=0; i<m; ++i){
		cin >> a >> b; --a; --b;
		g[a][b] = false;
		g[b][a] = false;
	}
	for(i=0; i<n; ++i){
		if(x[i]){
			for(j=0; j<=n; ++j){
				dp[i+1][j] = dp[i][j];
			}
			continue;
		}
		bc = 0; wc = 0;
		if(!dfs(i,1)){
			cout << "-1" << endl;
			return 0;
		}
		for(j=bc; j<=n; ++j){
			if(dp[i][j-bc]){
				dp[i+1][j] = true;
			}
		}
		for(j=wc; j<=n; ++j){
			if(dp[i][j-wc]){
				dp[i+1][j] = true;
			}
		}
	}
	for(j=0; j<=n; ++j){
		if(dp[n][j]){
			ans = min(ans,(j*(j-1))/2 + ((n-j)*(n-j-1))/2);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
N = int(input())
A = [int(i) for i in input().split()]
List = [0 for i in range(N)]
Sum = 0
for i in range(1,N-1,2):
    Sum += A[i]
List[0] = sum(A)-(2*Sum)
for i in range(1,N):
    List[i] = 2*A[i-1]-List[i-1]

for i in List:
    print(i,end=" ")

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 998244353
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;


template<typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template<int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) { if ((x = x_ % mod + mod) >= mod) x -= mod; }
    ModInt& operator+=(ModInt rhs) { if ((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt& operator-=(ModInt rhs) { if ((x -= rhs.x) < 0) x += mod; return *this; }
    ModInt& operator*=(ModInt rhs) { x = (unsigned long long) x * rhs.x % mod; return *this; }
    ModInt& operator/=(ModInt rhs) { x = (unsigned long long) x * rhs.inv().x % mod; return *this; }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) { s << a.x; return s; }
    friend istream& operator>>(istream& s, ModInt<mod>& a) { s >> a.x; return s; }
};

using mint = ModInt<998244353>;

mint fact[202020];
mint factinv[202020];

mint fallingfact(int n, int p) {
    return fact[n] * factinv[n - p + 1];
}

void init() {
    fact[0] = 1;
    for (int i = 1; i < 202020; i++) {
        fact[i] = fact[i - 1] * i;
    }
    factinv[202020 - 1] = fact[202020 - 1].inv();
    for (int i = 202020 - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1);
    }
    assert(factinv[0] == 1);
}

mint ncr(int n, int r) {
    return fact[n] * factinv[r] * factinv[n - r];
}

map<pair<int, int>, mint> memo;

// sum_{x=1^k} x^m
mint powsum(int k, int m) {
    if (memo.count({k, m})) {
        return memo[{k, m}];
    }
    mint ret = 0;
    for (int i = 2; i <= m + 1; i++) {
        ret += ncr(m + 1, i) * powsum(k, m + 1 - i);
    }
    ret = ret + 1 - pow(mint(k + 1), m + 1);
    ret /= -(m + 1);
    return memo[{k, m}] = ret;
}

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

    mint zo;

    if(s%2==1){
        init();
        mint a=powsum(s,n-1);
        mint b=powsum((s-1)/2,n-1);
        b*=(mint)pow((mint)2,n);
        zo=a-b;
    }
    else{
        init();
        mint a=powsum(s/2,n-1);
        mint b=powsum(s,n-1);
        a*=(mint)pow((mint)2,n);
        zo=a-b;
    }
    
    mint r=(pow((mint)(s+1),n)-pow((mint)(s+1),n-1));
    r=r/(mint)2;
    cout<<r+zo<<endl;

}



Measured memory_bytes: 4904
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 2e5 + 10;
const LL inf = 1e18;

int n;
LL E, t, a[N], dp[N], pre[N];

int main() {
	cin >> n >> E >> t;
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);
	dp[0] = 0;
	pre[0] = inf;
	for (int i = 1, j = 1; i <= n; ++i) {
		dp[i] = inf;
		while (2 * (a[i] - a[j]) > t) ++j;
		dp[i] = min(dp[i], dp[j - 1] + t);
		dp[i] = min(dp[i], 2 * a[i] + pre[j - 1]);
		pre[i] = min(pre[i - 1], dp[i - 1] - 2 * a[i]);
	}
	printf("%lld\n", dp[n] + E);
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define maxn 200001
using namespace std;
typedef long long LL;

int n;
int h[maxn];
int v[maxn];
LL tree[4*maxn];

void update(int tx, int ty, int q, LL val, int id) {
	if(q < tx || ty < q)
		return;
	tree[id] = max( tree[id] , val );
	if(tx == ty)
		return;
	int mid = (tx + ty) >> 1;
	update(tx, mid, q, val, id*2);
	update(mid+1, ty, q, val, id*2+1);
}

LL query(int tx, int ty, int qx, int qy, int id) {
	if(qy < tx || ty < qx)
		return 0;
	if(qx <= tx && ty <= qy)
		return tree[id];
	int mid = (tx + ty) >> 1;
	return max( query(tx,mid,qx,qy,id*2) , query(mid+1,ty,qx,qy,id*2+1) );
}

int main() {
	scanf("%d",&n);
	for( int i = 1 ; i <= n ; i++ )
		scanf("%d",&h[i]);
	for( int i = 1 ; i <= n ; i++ )
		scanf("%d",&v[i]);
	for( int i = 1 ; i <= n ; i++ ) {
		LL val = query(1,n,1,h[i],1) + v[i];
		update(1,n,h[i],val,1);
	}
	printf("%lld\n",tree[1]);
	return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,as,bs;
cin>>a>>b;
a-=1;
if (a%4==0) as=a;
if (a%4==3) as=0;
if (a%4==1) as=1;
if (a%4==2) as=a+1;
if (b%4==0) bs=b;
if (b%4==3) bs=0;
if (b%4==1) bs=1;
if (b%4==2) bs=b+1;
long long print=bs^as;
cout<<print<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll c[51][51];

void comb_table(int n){
	rep(i,n+1){
		rep(j,i+1){
			if(j==0||j==i){
				c[i][j]=1LL;
			}else{
				c[i][j]=(c[i-1][j-1]+c[i-1][j]);
			}
		}
	}
}

signed main(){
	int n,a,b; cin>>n>>a>>b;
	vector<double> v(n); rep(i,n) cin>>v[i]; sort(RALL(v));
	double ave=0.0;	rep(i,a) ave+=v[i];	ave/=a;
	int is_a=0, cnt=0; comb_table(n);
	rep(i,n){
		if(v[i]==v[a-1]){
			is_a++;
			if(i<a) cnt++;
		}
	}
	ll ans=0LL;
	cerr<<is_a SP cnt<<endl;
	if(cnt==a){
		for(int i=a;i<=b;i++) ans+=c[is_a][i];
	}else{
		ans=c[is_a][cnt];
	}
	cout<<ave<<endl<<ans<<endl;
	return 0;
}


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

int main()
{
	int x;
	int sum=0;
	
	cin >> x;
	
	for(int i=0;;i++)
	{
		sum+=i;
		if(sum>=x)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define F 44
  
int fibonacci(int n){
  int i;
  int a = 1, b = 1, temp = 1;
  
  for(i = 2; i <= n; i++){
    temp = a + b;
    a = b;
    b = temp;
  }
  return temp;
}
  
int main(){
  int i, n;
  
  scanf("%d", &n);
  printf("%d\n", fibonacci(n));
  
  return 0;
}

Measured memory_bytes: 596
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int h = cin.NextInt();
			int w = cin.NextInt();
			var s = new List<List<char>>();
			var dp = new List<List<int>>();
			for (int i = 0; i < h; i++)
			{
				s.Add(cin.Next().ToArray().ToList());
				var x = new List<int>();
				for (int j = 0; j < w; j++) x.Add(0);
				dp.Add(x);
			}
			dp[0][0] = s[0][0] == '.' ? 0 : 1;
			for (int j = 1; j < w; j++)
			{
				if (s[0][j] == '#' && s[0][j - 1] == '.') dp[0][j] = dp[0][j - 1] + 1;
				else dp[0][j] = dp[0][j - 1];
			}
			for (int i = 1; i < h; i++)
			{
				if (s[i][0] == '#' && s[i - 1][0] == '.') dp[i][0] = dp[i - 1][0] + 1;
				else dp[i][0] = dp[i - 1][0];
			}
			for (int i = 1; i < h; i++)
			{
				for (int j = 1; j < w; j++)
				{
					int x = dp[i - 1][j];
					int y = dp[i][j - 1];
					if (s[i][j] == '#')
					{
						if (s[i - 1][j] == '.') x++;
						if (s[i][j - 1] == '.') y++;
					}
					dp[i][j] = Math.Min(x, y);
				}
			}
			Console.WriteLine(dp[h - 1][w - 1]);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int 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 (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

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

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

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

typedef long long int lli;
typedef long int li;

long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}

long long max(long long a, long long b){
    if(a > b) return a;
    else return b;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<long long> in(n);
    for(auto &it : in) cin >> it;
    for(int i = 0; i < k; i++){
        vector<long long> dp(n + 1);
        for(int j = 0; j < n; j++){
            dp[max(0ll, j - in[j])] += 1;
            dp[min((long long)n, j + in[j] + 1)] -= 1;
        }    
        bool b = 1;
        for(int j = 0; j < n; j++){
           if(j != 0) dp[j] += dp[j - 1];
           in[j] = dp[j];
           if(in[j] != n) b = 0;
        }
        if(b == 1) break;
    }
    for(int i = 0; i < n; i++){
        cout << in[i] << ' ';
    }
    cout << '\n';
}   

/*
    check for corner cases.
    When using log check for zeros.
    Use queues and stacks if they are helping.           
                            
    (___)           
    . . )____________ 
   _|__/\           |\
  (o_o_) \__________| \
           /|     ||   )     
          < |     ||  
*/



Measured memory_bytes: 6368
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;


int main(){
	//ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	ll res=0,ans=0;
	ll t,I,O,T,J,L,S,Z;
	cin>>I>>O>>T>>J>>L>>S>>Z;
	t=(J%2)+(L%2)+(I%2);
	if(t>=2&&J!=0&&L!=0&&I!=0){
		res+=3;
		J--;
		L--;
		I--;
	}
	res+=O;
	res+=(I/2)*2;
	res+=(J/2)*2;
	res+=(L/2)*2;
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] b = new int[n-1];
	for (int i=0; i<n-1; i++) b[i] = sc.nextInt();
	int count = b[0];
	for (int i=0; i<n-2; i++)
	    count += Math.min(b[i],b[i+1]);
	count += b[n-2];
	System.out.print(count);
    }
}


Measured memory_bytes: 35972
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int x, a, b;
   std::cin >> x >> a >> b;
   Int t = x - a;
   Int res = t - t / b * b;
   printf("%ld\n", res);
}


Measured memory_bytes: 256
for e in iter(input,'0 0'):
 r=int(e.split()[0])
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=c if c>r//2 else r-c
  a=max(a,b)
 print(a)


Measured memory_bytes: 6916
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <stdio.h>
 
using namespace std;
 
int dat[200010];
int a, b;
 
int main(void) {
	scanf("%d %d", &a, &b);
  	for (int i = 1;i <= a;i ++) {
      scanf("%d", &dat[i]);
    }
  	sort(&dat[1], &dat[1]+a);
  	long sum = 0;
  	for (int i = 1;i <= a-b;i ++) {
    	sum += dat[i];
    }
  	printf("%ld", sum);
  	return 0;
}

Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll get(ll s, ll t, ll x) {
	ll a = min(s, t);
	ll b = max(s, t);
	if (x < a) {
		return b - x;
	}
	else if (b < x) {
		return x - a;
	}
	else {
		ll ans = b - a;
		ans += min(x - a, b - x);
		return ans;
	}
}
vector<ll> arr[2];
vector<ll> find(ll x, int k) {
	vector<ll> res;
	ll left = 0, right = arr[k].size() - 1;
	while (left <= right) {
		ll mid = left + right >> 1;
		if (arr[k][mid] < x) left = mid + 1;
		else right = mid - 1;
	}
	if (0 <= left && left <= arr[k].size() - 1)
		res.push_back(arr[k][left]);
	if (0 <= right && right <= arr[k].size() - 1)
		res.push_back(arr[k][right]);
	return res;
}
int main(void) {
	ll s, t, q; scanf("%lld %lld %lld", &s, &t, &q);
	vector<ll> arr_s, arr_t;
	for (ll i = 0, x; i < s; i++) {
		scanf("%lld", &x);
		arr[0].push_back(x);
	}
	for (ll i = 0, x; i < t; i++) {
		scanf("%lld", &x);
		arr[1].push_back(x);
	}
	sort(arr[0].begin(), arr[0].end());
	sort(arr[1].begin(), arr[1].end());
	for (ll i = 0, x; i < q; i++) {
		scanf("%lld", &x);
		vector<ll> vs = find(x, 0);
		vector<ll> vt = find(x, 1);
		ll ans = 5e10;
		for (auto i : vs) {
			for (auto j : vt) {
				ll tmp = get(i, j, x);
				ans = min(ans, tmp);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}
	



Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	
	int ans = 0;
	for(int i=3;i<=N;i+=2){
		
		int v = i;
		int cnt = 0;
		for(int j=1;j*j<=v;j++){
			if(i % j != 0) continue;
			cnt++;
			if(j != i / j) cnt++;
		}
		if(cnt == 8) ans++;
		
	}
	
	cout << ans << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    int N;
    int A[100];
    cin >> N;
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
        }
        
    for(int i = 0;i < N; i++){
        if(i == N-1){
            printf("%d\n",A[i]);
            }else{
                printf("%d ",A[i]);
            }
    }

    for(int i = 1; i < N; i++){
        int v = A[i];
        int j;
        j = i-1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int a = 0; a < N; a++){
            if(a == N-1){
            printf("%d\n",A[a]);
            }else{
                printf("%d ",A[a]);
            }
        }
    }
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  vi a(n);
  for (int &i : a)
    cin >> i;
  int ans = 0;
  vi l(n + 1), r(n + 1);
  for (int i = 0; i < n; i++)
    l[i + 1] = __gcd(l[i], a[i]);
  for (int i = n-1; i >= 0; i--)
    r[i] = __gcd(r[i + 1], a[i]);
  for (int i = n - 1; i >= 0; i--)
    ans = max(ans, __gcd(l[i], r[i + 1]));
  cout << ans << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 5540
A, B = map(int, input().split())
C = [2,3,4,5,6,7,8,9,10,11,12,13,1]

if C.index(A) > C.index(B):
    print("Alice")
elif C.index(A) < C.index(B):
    print("Bob")
else:
    print("Draw")

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[110];
int main(){
	scanf("%s",s);
	int flag=1;
	for(int i=0;s[i];i++){
		char c=s[i];
		if(i%2==0)flag&=c=='R'||c=='U'||c=='D';
		else flag&=c=='L'||c=='U'||c=='D';
	}
	puts(flag?"Yes":"No");
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

  if (a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
    return 0;
  }

  if (0 < a) {
    cout << "Positive" << endl;
    return 0;
  }

  if ((b - a + 1) % 2 == 0) {
    cout << "Positive" << endl;
  } else {
    cout << "Negative" << endl;
  }
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 998244353
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 4005;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int dp[MAX_N][MAX_N], ok[MAX_N][MAX_N];
int tma[2*MAX_N], tmb[2*MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = len(s);
    dp[0][0] = 1;
    vi apos, bpos;
    rep(i,n){
        if(s[i] == '0'){
            apos.pb(i+1), apos.pb(i+1);
        }else if(s[i] == '1'){
            apos.pb(i+1), bpos.pb(i+1);
        }else{
            bpos.pb(i+1), bpos.pb(i+1);
        }
    }
    rep(i,len(apos)+1){
        rep(j,len(bpos)+1){
            ok[i][j] = INF;
        }
    }
    ok[0][0] = 0;
    rep(i,len(apos)+1){
        rep(j,len(bpos)+1){
            if(i > 0){
                cmn(ok[i][j], max(ok[i-1][j] + 1, apos[i-1]));
            }
            if(j > 0){
                cmn(ok[i][j], max(ok[i][j-1] + 1, bpos[j-1]));
            }
        }
    }
    rep(i,len(apos)+1){
        rep(j,len(bpos)+1){
            if(i < len(apos) && ok[i+1][j] <= i+j+1){
                dp[i+1][j] = add(dp[i+1][j], dp[i][j]);
            }
            if(j < len(bpos) && ok[i][j+1] <= i+j+1){
                dp[i][j+1] = add(dp[i][j+1], dp[i][j]);
            }
        }
    }
    int ans = 0;
    rep(i,2*n+1){
        ans = add(ans, dp[i][2*n-i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 123776
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M,Q;
int a[MAXN],pos[MAXN],reserve[MAXN];
bool vis[MAXN];
vector<int> v;
void Solve() {
    read(N);read(M);read(Q);
    v.pb(0);
    for(int i = 1 ; i <= Q ; ++i) {read(a[i]);}
    for(int i = Q ; i >= 1 ; --i) {
	if(!vis[a[i]]) {
	    v.pb(a[i]);
	    vis[a[i]] = 1;
	}
    }
    for(int i = 1 ; i <= M ; ++i) {
	if(!vis[i]) v.pb(i);
    }
    for(int i = 1 ; i <= M ; ++i) pos[v[i]] = i;
    int p = M;
    while(p > 1 && v[p - 1] < v[p]) --p;
    if(p == 1) {puts("Yes");return;}
    for(int i = Q ; i >= 1 ; --i) {
	if(a[i] == v[1]) reserve[1]++;
	else {
	    if(reserve[pos[a[i]] - 1]) {
		reserve[pos[a[i]] - 1]--;
		reserve[pos[a[i]]]++;
	    }
	}
    }
    int res = 0;
    for(int i = p - 1 ; i <= M ; ++i) {
	res += reserve[i];
    }
    if(res >= N) {puts("Yes");return;}
    else {puts("No");return;}
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 2040
N = int(input())
A = list(map(int, input().split()))

m = min(A)

while True:
  flag = False
  temp = m
  for i in range(len(A)):
    if A[i] % m > 0 and (A[i] % m) < temp:
      temp = A[i] % m
      flag = True
  if flag == False:
    break
  else:
    m = temp
print(m)

Measured memory_bytes: 14252
n = gets.to_i
s = n.times.map{gets.chomp}

jn = ["AC", "WA", "TLE", "RE"]
jud = Hash.new(-1)
jn.each{|e| jud[e] += 1}
s.each{|e| jud[e] += 1}

jn.each do |e|
  puts "#{e} x #{jud[e]}"
end

Measured memory_bytes: 20676
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int h, w, a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> h >> w >> a >> b;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cout << (char)('0' + ((i < b) ^ (j < a)));
		}
		cout << "\n";
	}
	return 0;
}




Measured memory_bytes: 1280
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,C;cin>>n>>C;
  vvl d(C,vl(C));
  rep(i,C){
    rep(j,C)cin>>d[i][j];
  }
  vvl c(n,vl(n));
  rep(i,n){
    rep(j,n){
      cin>>c[i][j];
      c[i][j]--;
    }
  }
  vvl data(3);
  rep(i,n){
    rep(j,n)data[(i+j+2)%3].push_back(c[i][j]);
  }
  vector<vector<P> > MIN(3);
  rep(i,3){
    rep(j,C){
      ll sum=0;
      for(auto x:data[i]){
        sum+=d[x][j];
      }
      MIN[i].push_back(make_pair(sum,j));
    }
  }
  //rep(i,3){
    //rep(j,MIN[i].size())cout<<MIN[i][j].first<<" "<<MIN[i][j].second<<" ";
    //cout<<endl;
  //}
  rep(i,3)sort(MIN[i].begin(),MIN[i].end());
  ll ans=INF;
  rep(i,3){
    rep(j,3){
      rep(k,3){
        if(MIN[0][i].second==MIN[1][j].second||MIN[1][j].second==MIN[2][k].second||MIN[2][k].second==MIN[0][i].second)continue;
        ans=min(ans,MIN[0][i].first+MIN[1][j].first+MIN[2][k].first);
      }
    }
  }
  cout<<ans<<endl;
}
    
    

Measured memory_bytes: 4588
#include <stdio.h>
#include <stdlib.h>

typedef struct Node* NodePointer;

struct Node {
  NodePointer next[5];
};

int conv(char c) {
  switch(c) {
  case '\0':return 0;
  case 'A': return 1;
  case 'C': return 2;
  case 'G': return 3;
  case 'T': return 4;
  }
  return -1;
}

NodePointer makeNode() {
  int i;
  NodePointer p;
  p = malloc(sizeof(struct Node));
  for(i = 0; i < 5; ++i) {
    p->next[i] = NULL;
  }
  return p;
}
    
void insert(NodePointer p, char* s) {
  int a;
  a = conv(*s);
  if(p->next[a] == NULL) p->next[a] = makeNode();
  if(a != 0) insert(p->next[a], s+1);
}

int find(NodePointer p, char* s) {
  int a;
  a = conv(*s);
  if(p->next[a] == NULL) return 0;
  if(a == 0) return 1;
  return find(p->next[a], s+1);
}

int main() {
  int n;
  char s[100], t[100];
  NodePointer head;

  head = makeNode();
  scanf("%d", &n);
  while(n--) {
    scanf("%s %s", s, t);
    if(s[0] == 'i') {
      insert(head,t);
    } else {
      if(find(head,t))
        printf("yes\n");
      else
        printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 14000
class Atcoder:


    def Contest0901(self):
        lines = []
        for i in range(3):
            line = input()
            if line:
                lines.append(line)
            else:
                break
        return lines[0][0] + lines[1][1] + lines[2][2]


if __name__ == '__main__':
    atcoder = Atcoder()
    output = atcoder.Contest0901()
    print(output)

Measured memory_bytes: 3060
def main():
    n, kk = map(int, input().split())

    mod = 10**9+7
    fact = [1, 1]
    for i in range(2, 2*10**5+1):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r, mod=10**9+7):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    ans = [1]

    for k in range(1, n):
        ans.append(nCr(n-1, k)*nCr(n, k) % mod)

    print(sum(ans[:min(kk+1, n)]) % mod)


main()


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n - 1);
    vector<int> ans(n);

    for (int i = 0; i < n - 1; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < n - 1; i++)
    {
        ans[a[i] - 1]++;
    }

    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4844
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

long long size(int n){
  return (long long)pow(2,n+2)-3;
}

long long p(int n){
  return (long long)pow(2,n+1)-1;
}

long long f(int n, long long x){
  //printf("f(%d, %lld) called\n",n,x);
  if (n==0){
    return 1;
  } else if (x==0){
    return 0;
  } else if (x<=size(n-1)){
    return f(n-1, x-1);
  } else if (x==size(n-1)+1){
    return (long long)p(n-1)+1;
  } else if (x<2*size(n-1)+2){
    return p(n-1)+1+f(n-1, x-size(n-1)-2);
  } else if (x==2*size(n-1)+2){
    return p(n);
  } else {
    return -1;
  }
}

int main(){

  int N;
  long long X;
  scanf("%d", &N);
  scanf("%lld", &X);
  long long ans = f(N, X-1);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
N,D=reads()
count=0
for i in range(N):
    X,Y=reads()
    if(X**2+Y**2<=D**2):
        count+=1
print(count)

Measured memory_bytes: 9612
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int *> P;
typedef pair<long long,int>PP;
int main(){
  int n,k;
  cin>>n;
  int l,sum=0,mx=0;
  for(int i=0;i<n;i++){
    cin>>l;
    if(l>mx){
      mx=l;
    }
    sum+=l;
  }
  sum-=mx;
  if(sum>mx){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return(0);
}


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

long long a[200000],l[200000];

signed main()
{
	ios::sync_with_stdio(0);
	
	long long n,i;
	long long ans=0;
	
	cin >> n;
	
	for(i=1; i<=n; i++)
		cin >> a[i];
		
	for(i=1; i<=n; i++)
		l[i]=max(a[i],l[i-1]);
		
	for(i=1; i<=n; i++)
		ans+=l[i]-a[i];
		
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6712
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	string S;
	cin >> S;

	int cnt = 0;
	long long ans = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'W') {
			ans += i - cnt;
			cnt += 1;
		}
	}

	cout << ans << endl;

	return 0;
}

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

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

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

    for(auto str : s) cout << str;
    return 0;
}

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

char in[120];
pair<pair<string,int>,int> p[110];
int main(){
  int a;scanf("%d",&a);
  for(int i=0;i<a;i++){
    int t;scanf("%s%d",in,&t);
    string tmp=in;
    p[i]=make_pair(make_pair(in,-t),i);
  }
  std::sort(p,p+a);
  for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}


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

dp = [0 for _ in range(n)]
dp[0] = 1000

kabu = [0 for _ in range(n)]

for i in range(1,n):
    kabu[i-1] = dp[i-1] // a[i-1] 
    oturi = dp[i-1] - kabu[i-1]*a[i-1]
    dp[i] = max(kabu[i-1]*a[i]+oturi, dp[i-1])

print(dp[-1])

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for(int i = 0; i < n; i++) cin >> l.at(i);

	int d = 0;
	int cnt = 1;
	for(int i = 0; i < n; i++) {
		d += l.at(i);
		if(d > x) break;
		else cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define loop(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  string S;
  int ans=700;
  cin>>S;
  if(S[0]=='o') ans+=100;
  if(S[1]=='o') ans+=100;
  if(S[2]=='o') ans+=100;
  cout<<ans<<endl;
}

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

int main(){
    ll m,n,a[100000];
    cin>>m>>n;
    ll num=1,ans=0;
    if(m==2){
        int x[2]={};
        rep(i,n){
            cin>>a[i];
            x[(i-a[i]+2)%2]++;
        }
        cout<<min(x[0],x[1])<<endl;
        return 0;
    }
    rep(i,n){
        cin>>a[i];
        if(i&&a[i-1]==a[i])num++;
        else{
            ans+=num/2;
            num=1;
        }
    }
    cout<<ans+num/2<<endl;
}


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

    int s[27] = {};
    rep(i, 4){
        char c;
        cin >> c;
        s[c-'A']++;
    }

    sort(s, s+27);

    if(s[26] == 2 && s[25] == 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

const int maxn = 1e5;

int n, k;
int a[maxn];

int main(void) {
  scanf("%d%d", &n, &k);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    ans = __gcd(ans, a[i]);
  }
  if (k <= *max_element(a, a + n) && k % ans == 0) {
    puts("POSSIBLE");
  } else {
    puts("IMPOSSIBLE");
  }
}


Measured memory_bytes: 512
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
l=[lnii() for i in range(m)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

uf=UnionFind(n)
for a,b, in l:
  a-=1
  b-=1
  if uf.same(a,b)==False:
    uf.union(a,b)

ans=0
roots=uf.roots()
for i in uf.roots():
  ans=max(ans,uf.size(i))
print(ans)

Measured memory_bytes: 107604
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (a, b, c, d) = toTuple(readInts())
print([a * c, a * d, b * c, b * d].max()!)

Measured memory_bytes: 13608
s = str(input())
n = len(s)
tmp = 753
ans = 0
for i in range(n-2):
    a = int(s[i:i+3])
#    print(a)
    if abs(tmp-ans)>abs(tmp-a):
        ans = a
#        print(ans)

print(abs(tmp-ans))

Measured memory_bytes: 3060
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long[] kaijo;
	 static long[] kaiinv;
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        int[] m = new int[26];
	        for(int i=0;i<N;i++) {
	        	m[c[i]-'a']++;
	        }
	        long ans=1;
	        for(int i=0;i<26;i++) {
	        	ans=ans*(m[i]+1)%mod;
	        }
	        ans=(ans-1)%mod;
	        
	        System.out.println(ans);
	 }

}

Measured memory_bytes: 28416
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

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

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

const int M = 2e5 + 1;
vi graph[M];
int counter[M], visited[M] = {0}, lazy[M] = {0};

void dfs(int curr, int val) {
	val += lazy[curr];
	counter[curr] = val;
	visited[curr] = 1;
	for (int next : graph[curr]) {
		if (not visited[next]) dfs(next, val);
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, q; cin >> n >> q;
	For(i,0,n-1) {
		int a,b; cin >> a >> b;
		graph[a].pb(b); graph[b].pb(a);
	}
	For(i,0,q) {
		int p,x; cin >> p >> x;
		lazy[p] += x;
	} 
	dfs(1,0);
	For(i,1,n+1) cout << counter[i] << ' ';
	return 0;
}

Measured memory_bytes: 23424