akhauriyash/Code-Regression huggingface dataset:
<?php
  	fscanf(STDIN, '%d', $card_num);
	$input = rtrim(fgets(STDIN));
	$cards = explode(' ',$input);
	rsort($cards);

	foreach($cards as $key => $value){
      	$result += $key % 2 == 0 ? $value : -$value;
    }
	echo $result;

Measured memory_bytes: 4604
N,K = map(int,input().split())
S = list(input())
if S[K-1] == "A":S[K-1] = "a"
if S[K-1] == "B":S[K-1] = "b"
if S[K-1] == "C":S[K-1] = "c"
print("".join(S))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  vector<vector<P>> syougen(N, vector<P>(0));
  vector<int> Snum(N);
  REP(i, N) {
    cin >> Snum[i];
    REP(j, Snum[i]) {
      int a, b;
      cin >> a >> b, a--;
      syougen[i].push_back(P(a, b));
    }
  }
  ll ans = -1;
  int lim = 1 << 1;
  for (int i = 0; i < (1 << N ); i++) {
    bool t = true;
    for (int j = 0; j < N; j++) {
      int a = i & (1 << j);
      if (a == 0) continue;
      REP(k, syougen[j].size()) {
        int b = i & 1 << syougen[j][k].first;
        b = min(1, b);
        if (b != syougen[j][k].second) {
          t = false;
          break;
        }
      }
    }
    if (t) {
      ll num = 0;
      for (int j = 0; j < N; j++) {
        int a = i & (1 << j);
        if (a != 0) num++;
      }
      ans = max(ans, num);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
inputs = sys.stdin.readlines()

n, q = map(int, inputs[0].split())
edges = [tuple(map(int, inputs[1+i].split())) for i in range(n-1)]
weights = [tuple(map(int, inputs[n+i].split())) for i in range(q)]

tree = [[] for _ in range(n)]
for x, y in edges:
    tree[x-1].append(y-1)
    tree[y-1].append(x-1)

val = [0] * n
for p, w in weights:
    val[p-1] += w

stack, parents = [0], [0] * n
while stack:
    x = stack.pop()
    for y in tree[x]:
        if y == parents[x]:
            continue
        parents[y] = x
        stack.append(y)
        val[y] += val[x]

print(*val)

Measured memory_bytes: 137116
## coding: UTF-8
N,M = map(int,input().split())

if(N % 2 == 1):
    pairs = []
    s = 2
    g = N
    for i in range(M):
        pairs.append([s, g])
        s += 1
        g -= 1
elif(N % 4 != 0):
    MAX = int(N/2) - 1
    half = int(MAX/2)
    pairs = []
    s = 1
    g = N
    for i in range(half):
        pairs.append([s, g])
        s += 1
        g -= 1
    g -= 1
    for i in range(half):
        pairs.append([s, g])
        s += 1
        g -= 1
else:
    odd_pairs = int(N/4)
    even_pairs = odd_pairs - 1
    pairs = []
    s = 1
    g = N
    for i in range(odd_pairs):
        pairs.append([s, g])
        s += 1
        g -= 1
    g -= 1
    for i in range(even_pairs):
        pairs.append([s, g])
        s += 1
        g -= 1







for i in range(M):
    print('{} {}'.format(pairs[i][0], pairs[i][1]))
#print(pairs)


Measured memory_bytes: 81372
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000
#define int long long 
struct edge { int from, to, cost; };

edge es[2010]; // 辺

int d[1010];   // 最短距離
int V, E;

// s番目の頂点から各頂点への最短距離を求める
bool shortest_path(int s) {
    for (int i = 0; i < V; i++) d[i] = INF2;
    d[s] = 0;
    int cnt = 0;
    int prev = d[V - 1];
    while (true) {
        bool update = false;
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != INF2 && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (!update) break;
        cnt++;
        if(cnt == V) prev = d[V - 1];
        if(cnt > V * 2 && prev != d[V - 1]) {
            cout << "inf" << endl;
            return false;
        } else if(cnt > V * 2) return true;
        //prev = d[V - 1];
    }
    return true;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    rep(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es[i] = {a, b, -c};
    }
    if(!shortest_path(0)) return 0;
    cout << -d[V - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

vector<vector<int>> v;
vector<bool> visited;
int n;

int dfs(int idx, int c) {
    int ans = 0;
    // printf("idx:%d, c:%d\n", idx, c);

    if (c == n) {
        return 1;
    }
    for (int i = 0; i < n; i++) {
        if (v[idx][i] == 1 && visited[i] == false) {
            visited[i] = true;
            ans += dfs(i, c + 1);
            visited[i] = false;
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;

    v.resize(n, vector<int>(n, 0));
    visited.resize(n, false);
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--;
        b--;
        v[a][b] = v[b][a] = 1;
    }

    visited[0] = true;
    int ans = dfs(0, 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a != 1 && b != 1){
        cout << 1 << endl;
    }
        if(a != 2 && b != 2){
        cout << 2 << endl;
    }
        if(a != 3 && b != 3){
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll a[200005],p[200005][2];
void solve(){
	ll n,sum=0,val1=0,val2=0;
	string s;
	cin>>n>>s;
	for(ll i=0;i<n;i++)
	if(s[i]=='1')
	sum++;
	p[0][1]=1;
	for(ll i=1;i<200005;i++)
	p[i][1]=(p[i-1][1]*2)%(sum+1);
	if(sum>1){
		p[0][0]=1;
		for(ll i=1;i<200005;i++)
		p[i][0]=(p[i-1][0]*2)%(sum-1);
	}
	for(ll i=0;i<n;i++)
	if(s[i]=='1'){
		if(sum>1)
		val1=(p[n-i-1][0]+val1)%(sum-1);
		val2=(p[n-i-1][1]+val2)%(sum+1);
	}
	for(ll i=0;i<n;i++)
	if(s[i]=='0'){
		ll cur=(val2+p[n-i-1][1])%(sum+1);
		cout<<a[cur]+1<<"\n";
	}
	else{
		if(sum==1)
		cout<<"0\n";
		else{
			ll cur=(val1-p[n-i-1][0])%(sum-1);
			if(cur<0)
			cur+=sum-1;
			cout<<a[cur]+1<<"\n";
		}
	}
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for(ll i=1;i<200005;i++){
		ll x=i,sum=0;
		while(x>0){
			if(x&1)
			sum++;
			x>>=1;
		}
		a[i]=1+a[i%sum];
	}
    ll qc=1;
    //cin>>qc
    for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 8456
N,K = map(int,input().split()) 
A = [int(i)-1 for i in input().split()]
now = 0

while K:
    if K % 2: 
        now = A[now]
    tmp = A[:]
    for i in range(N):
        tmp[i] = A[A[i]]
    A = tmp[:]
    K //= 2
print(now + 1)

Measured memory_bytes: 168760
#include <stdio.h>

int main() {
	int L, R, d, sum = 0;
	scanf("%d %d %d", &L, &R, &d);
	for (int i = L; i <= R; i++) {
		if (i % d == 0) {
			sum += 1;
		}
	}
	printf("%d", sum);
	return 0;
	
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
int n;
int dp[100005][3];
struct lol
{
    int a,b,c;
};
vector<lol> ac;
int solve(int index,int last)
{
    if(index==n) return 0;
    int &ret = dp[index][last];
    if(~ret) return ret;
    if(index==0 && last==0)
    {
        int x = solve(index+1,0)+ac[index].a;
        int y = solve(index+1,1)+ac[index].b;
        int z = solve(index+1,2)+ac[index].c;
        ret = max(max(x,y),z);
    }
    else
    {
        if(last==0)
        {
            int y = solve(index+1,1)+ac[index].b;
            int z = solve(index+1,2)+ac[index].c;
            ret = max(y,z);
        }
        else if(last==1)
        {
            int x = solve(index+1,0)+ac[index].a;
            int z = solve(index+1,2)+ac[index].c;
            ret = max(x,z);
        }
        else
        {
            int x = solve(index+1,0)+ac[index].a;
            int y = solve(index+1,1)+ac[index].b;
            ret = max(x,y);
        }
    }
    return ret;
}
int main()
{
    zzz;
    cin>>n;
    ac.resize(n);
    for(int i=0;i<n;++i) cin>>ac[i].a>>ac[i].b>>ac[i].c;
    memset(dp,-1,sizeof dp);
    cout<<solve(0,0);
}


Measured memory_bytes: 7296
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {

  double x1, y1, x2, y2, xq, yq;

  char c;

  while( cin >> x1 >> c >> y1 >> c >> x2 >> c >> y2 >> c >> xq >> c >> yq ) {

    x2 -= x1;
    y2 -= y1;
    xq -= x1;
    yq -= y1;
    double rq = sqrt( xq * xq + yq * yq );
    double aq = atan2( yq, xq );
    double a2 = atan2( y2, x2 );
    aq -= ( aq - a2 ) * 2;

    cout << fixed << setprecision(8) << rq * cos( aq ) + x1 << " " << rq * sin( aq ) + y1 << endl;

  }

  return 0;

}

Measured memory_bytes: 1348
def main():
    h, w = map(int, input().split())
    grid = [list(input()) for _ in [0]*h]
    grid = [[grid[j][i] for j in range(h)] for i in range(w)]
    ans = 0
    for i in range(w-1):
        same = [[0]*(h+1) for _ in [0]*(h+1)]
        for j in range(h-1, -1, -1):
            for k in range(h-1, -1, -1):
                same[j][k] += same[j+1][k+1]+(grid[i][-j-1] == grid[i+1][-k-1])
        dp = [[10**10]*(h+1) for _ in [0]*(h+1)]
        dp[0][0] = same[0][0]
        for j in range(h+1):
            for k in range(h+1):
                if j != 0:
                    dp[j][k] = min(dp[j][k], dp[j-1][k]+same[j][k])
                if k != 0:
                    dp[j][k] = min(dp[j][k], dp[j][k-1]+same[j][k])
        ans += dp[h][h]
    print(ans)


main()


Measured memory_bytes: 128092
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut h = read::<usize>();
    let mut w = read::<usize>();
    let mut ans = h * w;
    for _ in 0..2 {
        {
            let d1 = w / 3;
            let d2 = (w - d1) / 2;
            let d3 = w - d1 - d2;
            ans = std::cmp::min(
                ans,
                h * ([d1, d2, d3].iter().max().unwrap() - [d1, d2, d3].iter().min().unwrap()),
            );
        }
        let d1 = w / 2;
        let d2 = w - d1;
        for i in 1..h {
            let a1 = i * w;
            let a2 = (h - i) * d1;
            let a3 = (h - i) * d2;
            ans = std::cmp::min(
                ans,
                [a1, a2, a3].iter().max().unwrap() - [a1, a2, a3].iter().min().unwrap(),
            );
        }
        std::mem::swap(&mut h, &mut w);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int N = 100010;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int S;
int f(int n){
	int cnt = 0;
	while(n){
		n/=10;
		cnt++;
	}
	return cnt;
}
ll fastPower(ll a , ll b){
	if(!b)return 1ll;
	ll re = fastPower(a,b/2);
	re = (re*re)%MOD;
	if(b&1)return (re*a)%MOD;
	return re;
}
ll SH(ll t){
	return (fastPower(10,t)-fastPower(10,t-1)+MOD)%MOD;
}
ll an = 0;
vector<int> dv;
int main() {
	cin >> S;
	int idx = 1;
	int sum = 0;
	for(int i = 1; i < 10000000;++i){
		if(idx < i)
			sum = 0,idx = i;
		while(sum+f(idx)<=S){
			sum += f(idx);
			idx++;
		}
		if(sum == S)an++;
		sum -= f(i);
	}
	an = (an +(S/8))%MOD;
	for(int i = 1 ; i * i <= S ; ++i){
		if(S%i==0){
			dv.pb(i);
			if(S/i != i)
				dv.pb(S/i);
		}
	}
	sort(dv.begin(),dv.end());
	dv.resize(unique(dv.begin(),dv.end())-dv.begin());
	for (int i = 0; i < dv.size(); ++i){
		if(dv[i] >= 8  && S%dv[i]==0){
			an = (an + SH(dv[i])-S/dv[i]+MOD)%MOD;
		}
	}
	cout << an << endl;
	return 0;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ios>
#include <iostream>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val) { //usage: int dp[10][10]; Fill(dp,INF);
    std::fill((T *) array, (T *) (array + N), val);
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------

bool checkNoko() {

}

int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    int A, B, C, D, E, F;
    double maxRate = -1;
    int maxSugWat = 0;
    int maxSug = 0;
    cin >> A >> B >> C >> D >> E >> F;

    for (int i = 1; 100 * A * i <= F; i++) {
        int wA = 100 * A * i;
        int rem1 = F - wA;
        for (int j = 0; 100 * B * j <= rem1; j++) { //重さ超えないように
            int wB = 100 * B * j;
            int rem2 = rem1 - wB;

            int sugerLim = (A * i + B * j) * E; //溶け残らない最大の量

            if (wA + wB + sugerLim > F) //そこまで入れると重さを超えるなら
                sugerLim = F - wA - wB;


            for (int k = 0; C * k <= sugerLim; k++) { //砂糖が溶け残らない間
                int wC = C * k;

                //D
                int l = (sugerLim-wC) / D;

                int suger = wC + D * l;
                int allWeight = wA + wB + wC + D * l;

                if (allWeight == 0)
                    continue;
                if(wA+wB<suger)
                    continue;

                double tmp = (double) suger / (double) allWeight;
                if (maxRate < tmp) {
                    maxRate = tmp;
                    maxSugWat = allWeight;
                    maxSug = suger;
                }

            }
        }
    }

    cout << maxSugWat << " " << maxSug << endl;
}

Measured memory_bytes: 256
import itertools
N, X, Y = map(int, input().split())

D = Y-X
L = list(itertools.combinations(range(1,N+1), 2))

ans = [0] * N
for l in L:
    x, y = l[0], l[1]
    index = 0
    if x > Y or y < X:
        index = y-x
    elif x > X or y < Y:
        org = y-x
        oth = abs(X-x) + abs(Y-y) + 1
        if org > oth:
            index = oth
        else:
            index = org
    else:
        index = y-x - D+1
    
    ans[index] += 1

for i in range(1,N):
    print(ans[i])

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

char F[102][102];

void DFSapple(int Y,int X)
{
	if(F[Y][X]!='@')
		return;

	F[Y][X] = '.';
	
	DFSapple(Y-1,X  );
	DFSapple(Y  ,X+1);
	DFSapple(Y+1,X  );
	DFSapple(Y  ,X-1);
}	

void DFSpersimmon(int Y,int X)
{
	if(F[Y][X]!='#')
		return;

	F[Y][X] = '.';
	
	DFSpersimmon(Y-1,X  );
	DFSpersimmon(Y  ,X+1);
	DFSpersimmon(Y+1,X  );
	DFSpersimmon(Y  ,X-1);
}	

void DFSorange(int Y,int X)
{
	if(F[Y][X]!='*')
		return;

	F[Y][X] = '.';
	
	DFSorange(Y-1,X  );
	DFSorange(Y  ,X+1);
	DFSorange(Y+1,X  );
	DFSorange(Y  ,X-1);
}	

int main()
{
	while(true){
		int N,M;
		cin >> N >> M;
		if(N==0&&M==0)
			break;

		for(int y=1;y<=N;y++)
			for(int x=1;x<=M;x++)
				cin >> F[y][x];

		int cnt = 0;
		for(int y=1;y<=N;y++)
			for(int x=1;x<=M;x++)
				if(F[y][x]=='@'){
					cnt++;
					DFSapple(y,x);
				}

		for(int y=1;y<=N;y++)
			for(int x=1;x<=M;x++)
				if(F[y][x]=='#'){
					cnt++;
					DFSpersimmon(y,x);
				}

		for(int y=1;y<=N;y++)
			for(int x=1;x<=M;x++)
				if(F[y][x]=='*'){
					cnt++;
					DFSorange(y,x);
				}

		cout << cnt << endl;
	}

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

const ll  INF = 1e18 + 5;

int main()
{
    ll n, space; cin >> n >> space;
    vll w(n + 1), v(n + 1);
    ll s = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        s += v[i];
    }
        
    
    vvll state(n+1, vll(s+1, INF));
    state[0][0] = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= s; j++)
        {
            state[i][j] = min(state[i - 1][j], (( j >= v[i]) ?(state[i - 1][j - v[i]] + w[i]):INF));
        }

    vll laststate = state[n]; ll res;
    
    for(int i = s; i > -1; i--)
    {
        if(laststate[i] <= space)
        {
            res = i;
            break;
        }
    }
    cout << res << endl;
}

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

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

const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;

ll a[100001];
ll b[100001];

int main(void){
    ll n; cin >> n;
    for(int i = 0;i < n + 1;i++)cin >> a[i];
    for(int i = 0;i < n;i++)cin >> b[i];
    ll ans = 0;
    for(int i = 0;i < n;i++){
        if(b[i] <= a[i])ans += b[i];
        else{
            ans += a[i];
            if(b[i] - a[i] <= a[i+1]){
                a[i+1] -= b[i] - a[i];
                ans += b[i] - a[i];
            }else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

int N;

int main() {
	scanf("%d", &N);
	int sum = (N / 2) * (N / 2 + (N % 2));
	printf("%d\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
N = len(S)
if S[-1] == '1' or S[0] == '0' or S[:-1] != S[:-1][::-1]:
    print(-1); exit()
S = ['-'] + S

def solve(S):
    prev = 1
    graph = []
    for i in range(1, N//2 + 1):
        if S[i] == '0':
            continue
        for x in range(prev, i):
            print(x, i)
        prev = i
    for x in range(prev, N):
        print(x, N)

graph = solve(S)


Measured memory_bytes: 6312
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){ return (a%m + b%m+2*m)%m;}

ll mul(ll a, ll b, ll m = MOD){ return ((a%m+m)*(b%m+m))%m;}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 3000+5;

int n;
bool vis[N][N];
long double memo[N][N];
long double p[N];

long double DP(int pos, int needed){
	if(pos == -1){
		return needed == 0;
	}
	if(vis[pos][needed]) return memo[pos][needed];
	long double ans = (1-p[pos])*DP(pos-1,needed);
	if(needed > 0){
		ans += p[pos]*DP(pos-1,needed-1);
	}
	vis[pos][needed] = true;
	return memo[pos][needed] = ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		cin >> p[i];
	}
	long double ans = 0.0;
	for(int i = (n+1)/2; i <= n; i++){
		ans += DP(n-1,i);
	}
	cout << setprecision(11) << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 150400
package main

import "fmt"

const mod int = 1000000007

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)

	m := make(map[rune]int, 26)
	for _, ss := range s {
		m[ss]++
	}

	var ans = 1
	for _, mm := range m {
		ans = ans * (mm + 1) % mod
	}
	ans--
	fmt.Println(ans)
}


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

typedef long long int ll;
typedef long double ld;
const ll MAX=1e5+5;
const ll INF=1e15+2;

#define pb push_back
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi pair<ll,ll>

ll n,k;
ll a[102];
ll dp[MAX];


int main()
{
    
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
        
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>=a[j])
                dp[i]=dp[i]|(!dp[i-a[j]]);
        }
    }
    
    if(dp[k])
        cout<<"First";
    else cout<<"Second";    
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int[] nums = new int[3];
		for (int i = 0; i < 3; i++) nums[i] = in.nextInt();
		
		int fives = 0, sevens = 0;
		for (int i = 0; i < 3; i++) {
			if (nums[i] == 5) fives++;
			if (nums[i] == 7) sevens++;
		}
		
		if (sevens == 1 && fives == 2) System.out.println("YES");
		else System.out.println("NO");
	}
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<lint> red(A), green(B), nul(C);
    rep(i, A) cin >> red[i];
    rep(i, B) cin >> green[i];
    rep(i, C) cin >> nul[i];
    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    vector<lint> last(X + Y);
    rep(i, X) last.push_back(red[i]);
    rep(i, Y) last.push_back(green[i]);
    rep(i, C) last.push_back(nul[i]);
    sort(last.rbegin(), last.rend());
    lint ans = 0;
    rep(i, X + Y) ans += last[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[3];
    bool b[3]={0};
    scanf("%s",a);
    for(int i=0;i<3;i++)
        b[a[i]-'a']=1;
    if(b[0]&&b[1]&&b[2])
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s1, s2;
    cin >> s1 >> s2;
    if (s2.substr(0,s1.size()) == s1) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll powMod(ll n, ll p, ll mod) {
	ll res = 1;
	for (n %= mod; p; p >>= 1) {
		if (p & 1) (res *= n) %= mod;
		(n *= n) %= mod;
	}
	return res;
}
const constexpr ll mod = 1000000007;
ll n,x,h[200001],ans=0,r=1;
int main() {
	cin>>n;
	for (ll i = 1; i < n + 1; ++i) {
		h[i]=(h[i-1]+powMod(i,mod-2, mod))%mod;
	}
	for (ll i = 1; i < n + 1; ++i) {
		cin>>x;
		(ans+=x*(h[i]+h[n-i+1]-1+mod))%=mod;
		(r*=i)%=mod;
	}
	print(ans * r % mod);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int dice[7];
  int i,j,k,l;
  int q,ue,mae;
  int patan[7][4]={{0,0,0,0},{2,3,5,4},{6,3,1,4},{6,5,1,2},{2,1,5,6},{1,3,6,4},{2,4,5,3}};
  dice[0]=0;
    for(i=1;i<=6;i++){
    scanf("%d",&dice[i]);
  }
  scanf("%d",&q);
   for(i=0;i<q;i++){
     scanf("%d %d",&ue,&mae);
     for(k=1;k<=6;k++){
       if(dice[k]==ue)break;
     }
     for(l=1;l<=6;l++){
       if(dice[l]==mae)break;
     }
     for(j=0;j<4;j++){
       if(patan[k][j]==l)break;
     }
     if(j==3){
       printf("%d\n",dice[patan[k][0]]);
      continue;
     }
     printf("%d\n",dice[patan[k][j+1]]);
   }
   return 0;
}

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

int main()
{
    ll n, a[100], m = 1000;
    cin >> n;
    rep(i, n) cin >> a[i];

    rep(i, n - 1)
    {
        if (a[i] < a[i + 1])
        {
            m += floor(m / a[i]) * (a[i + 1] - a[i]);
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3616
package main

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

func main() {

	sc := NewScanner()
	N, A := sc.NextInt(), sc.NextInt()

	f := 1
	for ; f < A; f *= 2 {

	}

	ans := 0.0
	for i := 1; i <= N; i++ {
		//fmt.Println(f)
		for f >= 2 && i*f >= 2*A {
			f /= 2
		}

		ans += 1.0 / float64(N) * 1.0 / float64(f)
	}
	fmt.Println(ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	while(sc.hasNext()){
    		new aoj0038().doIt();
    	}
    }
    class aoj0038{
    	String check(int cnt[]){
    		if(cnt[2] == 1)return "four card";
    		else if(cnt[1] == 1 && cnt[0] == 1)return "full house";
    		else if(cnt[1] == 1)return "three card";
    		else if(cnt[0] == 2)return "two pair";
    		else if(cnt[0] == 1)return "one pair";
    		return "null";
    	}
    	void doIt(){
    		int a[] = new int [18];
    		int cnt[] = new int [3];
    		boolean st = true;
    		String str[] = sc.next().split(",");
    		for(int i = 0;i < 5;i++){
    			a[Integer.parseInt(str[i]) - 1]++;
    		}
    		for(int i = 0;i < 13;i++){
    			if(a[i] == 2)cnt[0]++;
    			else if(a[i] == 3)cnt[1]++;
    			else if(a[i] == 4)cnt[2]++;
    		}
    		for(int i = 0;i < 13;i++){
    			if(a[i] == 1 && a[i+1] == 1 && a[i+2] == 1
    					&& a[i+3] == 1 && a[(i+4)%13] == 1){
    				System.out.println("straight");
    				st = false;
    			}
    		}
    		if(st)System.out.println(check(cnt));
    	}
    }
}

Measured memory_bytes: 25740
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;
  int[char] k;
  foreach (e; s) {
    k[e]++;
  }
  if (k.keys.length == 3) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

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

ll INF = 1000000000000001;

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

    ll len = 1;
    ll temp = 26;
    ll n_temp = n;

    while (n_temp > temp) {
        n_temp -= temp;
        len++;
        temp *= 26;
    }

    n--;
    temp = 26;
    string s[len];
    for (int i=len; i>0; i--) {
        s[i-1] = (char)('a' + (n % temp));
        n /= 26;
        n--;
    }

    // cout << s << endl;
    rep(i, len) cout << s[i];

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    for (int i = a; i <= b; i++)
    {
        if (i < (a + c) || i > (b - c))
        {
            printf("%d\n", i);
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 3000;
const int MAX_W = 3000;

int dp[MAX_N + 1][MAX_W + 1];
int w[MAX_N];
int v[MAX_N];

int solve(int n, int W, int s){
  fill(dp[0], dp[MAX_N+1], 0);
  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(!(j < s && s < j + w[i]) && j + w[i] <= W){
        dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
      }
    }
  }
  int res = 0;
  for(int i=0;i<=W;i++) res = max(res, dp[n][i]);
  return res;
}


main(){
  int n, t, s;
  while(cin >> n >> t >> s){
    for(int i=0;i<n;i++){
      cin >> v[i] >> w[i];
    }
    cout << solve(n, t, s) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N;
	cin >> N;
	N %= 10;
	if (N == 3) {
		cout << "bon\n";
	} else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon\n";
	} else {
		cout << "hon\n";
	}

	return 0;
}

Measured memory_bytes: 3652
A , B = input().split(" ")
num1 = int(A)
num2 = int(B)
def gcd(num1,num2):
    if num1%num2 == 0:
        # Base case
        return num2
    else:
        # Iterative case
        return gcd(num2,num1%num2)
lcm = (num1*num2)//gcd(num1,num2)
print(lcm)

Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String numStr = sc.next();
		
		int num = 0;
		num = '1' == numStr.charAt(0) ? num += 1 : num;
		num = '1' == numStr.charAt(1) ? num += 1 : num;
		num = '1' == numStr.charAt(2) ? num += 1 : num;
		
		System.out.println(num);
	}
}

Measured memory_bytes: 22740
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;
 
int main(){
	long long n;
	cin >> n;
	long long sum=0,sum_3=0,sum_5=0,sum_15=0;
	for(long long i=1;i<=n;i++){
		sum+=i;
		if(i%3==0)sum_3+=i;
		if(i%5==0)sum_5+=i;
		if(i%15==0)sum_15+=i;
	}
	sum=sum-sum_3-sum_5+sum_15;
	cout << sum << endl;
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint h(n);
    REP(i,n)cin >> h[i];
    int ans = 0;
    REP(i,n){
        while(h[i]>0){
            int here = i;
            while(here<n&&h[here]>0){
                h[here]--;
                here++;
            }
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

M, D = IL()
MM, DD = IL()
if M == MM:
  print(0)
else:
  print(1)

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

void solve(int N, std::string S){
    vector<int> R_count(N,0);
    vector<int> G_count(N,0);
    vector<int> B_count(N,0);
    int r_count=0;
    int g_count =0;
    int b_count=0;
    for (int i=0;i<N;i++){
        if (S[i] == 'R') r_count++;
        if (S[i] == 'G') g_count++;
        if (S[i] == 'B') b_count++;
        R_count[i] = r_count;
        G_count[i] = g_count;
        B_count[i] = b_count;
    }
    ll count = 0;
    if (N<=2) {printf("0\n"); return ; }
    for (int i=0;i<N-2;i++){
        for (int j=i+1;j<N-1;j++){
            if (S[i] != S[j]){
                if (S[i] != 'R' && S[j] != 'R'){
                    count += R_count[N-1] - R_count[j];
                    if ( (2*j-i<N) && (S[2*j-i] == 'R') ){
                        count -=1;
                    }
                }else if(S[i] != 'G' && S[j] != 'G'){
                    count += G_count[N-1] - G_count[j];
                    if ( (2*j-i<N) && (S[2*j-i] == 'G') ){
                        count -=1;
                    }
                }else{
                    count += B_count[N-1] - B_count[j];
                    if ( (2*j-i<N) && (S[2*j-i] == 'B') ){
                        count -=1;
                    }

                }
            }
        }
    }
    printf("%lld\n",count);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>

int main()
{
    int n, a[101], b[101],i,j,p,b4p,ans=0;
        scanf("%d",&n);
        for (i = 0; i < n; i++)
            scanf("%d", &a[i]);
        for (i = 0; i < n; i++)
            scanf("%d", &b[i]);
        for (i = 0; i < n; i++)
        {
            p = 0;
            for (j = 0; j <= i; j++)
                p += a[j];
            for (j = 0; j <= (n-1-i); j++)
                p += b[n - 1 - j];
            if (p > ans)
                ans = p;
        }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 888
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));
  if($n > $m){
    if($n == "13" && $m == "1"){
      echo "Bob";
    }else{
      echo "Alice";
    }
  }else if($n == $m){
    echo "Draw";
  }else{
    if($m == "13" && $n == "1"){
      echo "Alice";
    }else{
      echo "Bob";
    }
  }

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

typedef long long ll;
const ll mod =1e9+7;
const int maxn = 1e5+5;
ll a[maxn];
ll b[maxn];

ll C[maxn];
ll inv[maxn];
ll ex[maxn];
int n,k;
void getinv()
{
	inv[1] = 1;
	for (int i = 2; i <= n; ++i) 
	{
		inv[i] = (long long)(mod-mod/i) * inv[mod%i]%mod;	
		inv[i] = (inv[i]%mod+mod)%mod;
	}
	
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
	if(b==0) 
	{
		x=1;y=0;
		return;
	}
	exgcd(b,a%b,y,x);
	y-=a/b*x;
}
void getex()
{
	ex[1] = 1;
	for(int i=2;i<=n;i++)
	{
		ll x=0,y=0;
		exgcd(i,mod,x,y);
		ex[i] = x;
	}
}

void getC()
{
	memset(C,0,sizeof(C));
	C[n-k+1] = 1;
	ll beg = k-1, end = 1;
	for(int i=n-k;i>=1;i--)
	{
		ll x=0,y=0;
		beg++;
		C[i] = (C[i+1]%mod*beg%mod*inv[end]%mod)%mod;
		end++;
	}
	/* 
	for(int i=1;i<=n;i++)
	{
		cout<<C[i]<<" ";
	}cout<<"\n";
	*/ 
}

bool cmp(ll a,ll b)
{
	return a>b;
}
int main()
{

	while(cin>>n>>k)
	{
	
		memset(b,0,sizeof(b));
		getinv();
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		sort(a+1,a+1+n,cmp);
		getC();
		ll ans = 0;
		for(int i=1;i<=n;i++)
		{
			b[i] = (C[i]%mod - C[n+1-i]%mod)%mod;
		}
		for(int i=1;i<=n;i++)
		{
			ans = (ans%mod + a[i]*b[i]%mod)%mod;
		}
		
		cout<<ans<<"\n";
	}
 } 
 
 /*
 10 5
 1000000000 999999999 999999998 999999997 999999996 123456789 111111111 9 8 7
 */

Measured memory_bytes: 3328
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] numWA = new int[N];
    boolean[] AC = new boolean[N];
    for (int i = 0; i < M; i++) {
      int p = scanner.nextInt() - 1;
      boolean s = scanner.next().equals("AC");
      if (s) {
        AC[p] = true;
      } else if (!AC[p]) {
        numWA[p]++;
      }
    }

    int numAC = 0;
    int penalty = 0;
    for (int i = 0; i < N; i++) if (AC[i]) numAC++;
    for (int i = 0; i < N; i++) if (AC[i]) penalty += numWA[i];
    System.out.printf("%d %d\n", numAC, penalty);
  }
}


Measured memory_bytes: 65156
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#define pii pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
/*
f[l,r,xl,xr]:
	in range [l,r], l and r were the first values vomitted
	l is counted xl times
	r is counted xr times
	f is the minimum possible sum of the contribution of values in range (l,r) ? 
*/
const int N=20;
map<pii,ll> mp[N][N];
int n;
int a[N];
ll dfs(int l,int r,int xl,int xr) {
	if(r==l+1) return 0;
	if(mp[l][r].count(MP(xl,xr))) return mp[l][r][MP(xl,xr)];
	ll ans=1e18;
	for(int k=l+1;k<r;++k)
		ans=min(ans,dfs(l,k,xl,xl+xr)+dfs(k,r,xl+xr,xr)+(xl+xr)*(ll)a[k]);
	return mp[l][r][MP(xl,xr)]=ans;
}
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(a[i]);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
	return 0;
}

Measured memory_bytes: 16640
def main():
    N = int(input())
    A = [int(c) for c in input().split()]

    prod = 1
    for i in A: prod *= i
    frac = []
    for i in A:
        frac.append(prod // i)
    denom = sum(frac)
    return prod / denom

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<iomanip>

const double PI = acos(-1.0);

int main(void) {
	double a, b, c;
	std::cin >> a >> b >> c;

	std::cout << std::fixed << std::setprecision(15) << '\n';

	std::cout << a * b * sin(c*PI/180) / 2.0 << '\n'; 

	std::cout << sqrt(a * a + b * b - 2 * a * b * cos(c*PI/180)) + a + b << '\n';
	
	std::cout << b * sin(c*PI/180) << '\n';

	return 0;
}



Measured memory_bytes: 3476
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    int N = S.size();

    int cnt = 0;
    rep(i,N) {
        if (S[i]!=T[i]) cnt++;
    }

    cout << cnt << ln;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define maxn 5009
#define mod 1000000007
using namespace std;
char s[maxn];
int f[maxn][maxn*2];
inline void upd(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int main(){
  int n,m;
  scanf("%d%s",&n,s);
  m=strlen(s);
  f[0][0]=1;
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n+m;j++)
      if(f[i][j]) upd(f[i+1][max(0,j-1)],f[i][j]),upd(f[i+1][j+1],f[i][j]*2%mod);
  long long ans=1;
  for(int i=1;i<=m;i++) ans=ans*500000004%mod;
  printf("%lld",ans*f[n][m]%mod);
  return 0;
}


Measured memory_bytes: 193792
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())

if A <= B:
    B += W*T
    A += V*T
    if A >= B:
        ans = "YES"
    else:
        ans = "NO"
else:
    B -= W*T
    A -= V*T
    if A <= B:
        ans = "YES"
    else:
        ans = "NO"
print(ans)

Measured memory_bytes: 61640