akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
S = [[int(i) for i in input().split()] for j in range(N)]
C = [[int(i) for i in input().split()] for j in range(M)]

for i in range(N):
    minlength = float("inf")
    nearpoint = 0
    for j in range(M):
        if minlength > abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1]):
            minlength = abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1])
            nearpoint = j+1
    print(nearpoint)

Measured memory_bytes: 3064
//@formatter:off
#include<bits/stdc++.h>
#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 rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int to[40][100010];
ll sum[40][100010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    int x, m;
    cin >> n >> x >> m;
    n--;
    rep(i, m) {
        sum[0][i] = to[0][i] = (ll) i * i % m;
    }
    rep(k, 39) {
        rep(i, m) {
            to[k + 1][i] = to[k][to[k][i]];
            sum[k + 1][i] = sum[k][i] + sum[k][to[k][i]];
        }
    }
    int now = x;
    ll ans = x;
    rep(i, 40) {
        if (n >> i & 1) {
            ans += sum[i][now];
            now = to[i][now];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 50540
#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 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int x[100010];
    rep(i, N) cin >> x[i];
    int ans = INF;
    rep(i, N - K + 1) {
        int cost1 = abs(0 - x[i]) + abs(x[i] - x[K - 1 + i]);
        int cost2 = abs(0 - x[K - 1 + i]) + abs(x[K - 1 + i] - x[i]);
        ans = min(ans, min(cost1, cost2));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define  vi vector<int>
#define pb push_back
//#define int long long
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define pi pair<int,int>
#define F first
#define S second
using namespace std;
 
//int mod=(int)(1e9+7);
 
void solve()
{   
	char ch;
	cin>>ch;
	if(ch <= 'Z' && ch >='A')
		cout<<"A"<<endl;
	else cout<<"a"<<endl;
}
 
signed main()
{ boost;
 //cout<<fixed<<setprecision(14 );
  // int t;cin>>t;
  // for(int i=1;i<=t;i++)
  solve();
 // cout<<"Case #"<<i<<": "<<solve()<<endl;
 
return 0;
}

Measured memory_bytes: 3636
#include<cassert>
#include<set>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, K;

struct Jewel {
    LL value;
    int color;
    Jewel(LL value_, int color_) {
	value = value_;
	color=  color_;
    }
    bool operator<(const Jewel &y) const {
	return value != y.value ? value > y.value : color < y.color;
    }
};

VI G[100011];
const LL INF = 1LL<<60;
int C[100011];

void MAIN() {
    scanf("%d%d", &N, &K);
    REP (i, N) {
	int c, v;
	scanf("%d%d", &c, &v);
	c--;
	G[c].push_back(v);
    }

    vector<Jewel> J;
    multiset<Jewel> X, Y, Z;
    REP (k, K) if (!G[k].empty()) {
	VI &v = G[k];
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	REP (t, 2) J.emplace_back(v[0] + v[1], k);
	for (int a=2; a<(int)v.size(); a++) J.emplace_back(v[a]*2, k);

	Y.emplace(v[0]+v[1], k);
	if (v.size() >= 3u) {
	    Z.emplace(((LL)v[0]+v[1]+v[2])*2, k);
	}
    }
    sort(J.begin(), J.end());

    LL min_value = INF;
    LL min_pair = INF;
    LL sum = 0;
    for (int i=0; i<N; i++) {
	LL value = J[i].value;
	int color = J[i].color;
	LL ans = -2;

	if (C[color] == 0) {
	    if (!X.empty()) {
		amax(ans, sum + X.begin()->value);
	    }
	    if (!Y.empty()) {
		amax(ans, sum - min_value + Y.begin()->value * 2);
	    }
	    if (!Z.empty()) {
		amax(ans, sum - min_pair + Z.begin()->value);
	    }

	    Y.erase(Y.find(J[i]));
	    if (G[color].size() >= 3u) {
		Jewel key(((LL)G[color][0] + G[color][1] + G[color][2])*2, color);
		Z.erase(Z.find(key));
	    }
	} else {
	    ans = sum + value;;
	    if (C[color] == 1) {
		for (int p=2; p<(int)G[color].size(); p++) {
		    X.insert(Jewel(G[color][p]*2, color));
		}
		amin(min_pair, value * 2);
	    }
	    if (C[color] >= 2) {
		X.erase(X.find(J[i]));
		amin(min_value, value);
	    }
	}
	C[color]++;
	sum += value;

	printf("%lld\n", ans/2);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 22252
#include<stdio.h>

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int tot=1;
	for(int i=1; i<=n; i++){
		if((tot*2)<=(tot+k)){
		tot*=2;
		}
		else{
			tot+=k;
		}
	}
	printf("%d\n", tot);
	return 0;
}

Measured memory_bytes: 1732
module Main where

import Control.Applicative
import Control.Monad
import Data.List

f p (a, b) = p - ((abs a + abs b) - abs (a + b))

main :: IO ()
main = do
    getLine
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = zipWith (-) (as ++ [0]) (0:as)
    let p = sum $ fmap abs bs
    let cs = zip bs (tail bs)
    mapM_ print $ fmap (f p) cs

Measured memory_bytes: 23804
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238463;
int main()
{
    long long int n, sum = 0;
    int m;
    cin >> n >> m;
    int a[m];
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if (sum <= n)
    {
        cout << n - sum;
    }
    else
    {
        cout << "-1";
    }

    return 0;
}

Measured memory_bytes: 3656
N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = [(p+1)/2 for p in P]
ans = s = sum(Q[:K])
for i in range(K, N):
    s += Q[i] - Q[i-K]
    ans = max(ans, s)
print(ans)

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int>> dp(n,vector<int>(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i(1);i<n;++i){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i];
	}
	int ans = max(dp[n-1][0],dp[n-1][1]);
	ans = max(ans,dp[n-1][2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N =pow(10,9)+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll tot=0;
    for(int i=0; i<n; i++){
        cin >> a.at(i);
        tot += a.at(i);
    }
    ll ans=0;
    tot%=N;
    for(int i=0; i<n; i++){
        tot -= a.at(i);
        if(tot<0) tot+=N;
        ans = (ans+a.at(i)*tot)%N;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = x - (k - 1); i <= x + (k - 1); i++) {
        cout << i;
        if (i != x + (k - 1)) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        (n, d): (usize, usize),
        mut points: [(i64, i64); n],
    }
    let mut result = 0;
    for point in points {
        let x = point.0;
        let y = point.1;
        let distance = (((x * x) + (y * y)) as f64).sqrt();
        if distance <= d as f64 {
            result += 1;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 7868
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int abs(int a,int b){
	return (a>b)?a:b;
}
int main(){
	fast_io
	int a,b,x; cin>>a>>b>>x;
	if(x<=a+b and x>=a) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b, n;
	
	while (cin >> a >> b >> n){
		int sum = 0;
		for (int i = 0; i < n; i++){
			a *= 10;
			sum += (a / b) % 10;
			a %= b;
		}
		cout << sum << endl;
	}
	return (0);
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int ,int> P;

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e5+7;
int dp[MAXN];
int a[MAXN];
int main() {
        ll n;
        while(cin>>n)
                cout<<(ll)n*(n-1)/2<<endl;
        return 0;
}




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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);

    rep(i, n) cin >> h[i];
    sort(ALL(h));

    int minv = 1e9;
    rep(i, n - k + 1)
    {
        minv = min(minv, h[i + k - 1] - h[i]);
    }

    OP(minv);
    return 0;
}

Measured memory_bytes: 640
import sys
from bisect import bisect_right
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    left = 0
    right = A[-1]
    while right - left > 1:
        mid = (left + right) // 2
        idx = bisect_right(A, mid)
        cnt = 0
        for i in range(idx, N):
            if A[i] % mid == 0:
                cnt += A[i] // mid - 1
            else:
                cnt += A[i] // mid
        if cnt > K:
            left = mid
        else:
            right = mid
    print(ceil(right))



if __name__ == "__main__":
    main()


Measured memory_bytes: 94032
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
using namespace std;
int main()
{
    rj
    ll a,b=100,c,i,cnt=0;
    cin>>a;
    while(b<a)
    {
       c=b/100;
       b+=c;
       cnt++;
    }
    cout<<cnt<<endl;



    return 0;
}


Measured memory_bytes: 3692
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
a = l()
b = l()
num = sum(b)-sum(a)
cnt1 = 0
cnt2 = 0
for i in range(N):
    if a[i] > b[i]:
        cnt1 += a[i]-b[i]
    if a[i] < b[i]:
        cnt2 += math.ceil((b[i]-a[i])/2)
if cnt1 > num or cnt2 > num:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 78028
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;


int main() {
	
	int n;
	cin >> n;
	vector<int> t(n+1), x(n+1), y(n+1);
	t[0] = 0, x[0] = 0, y[0] = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i] >> x[i] >> y[i];
	}

	bool exist = true;
	for (int i = 1; i <= n ; ++i) {
		int move = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
		int time = t[i] - t[i-1];
		if (move % 2 == time % 2 && time >= move) {
			
		}
		else exist = false;
	}
	if (exist) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
typedef long long ll;
const int MAXN = 100 + 5;

int n;
ll k;
char s[MAXN*3];
bool need[MAXN*3];

inline void chk(void)
{
	for(int i=2; i<=n; ++i)
		if(s[i]!=s[i-1]) return;
	printf("%lld",k*n/2ll);
	exit(0);
}

int main(void)
{
	scanf("%s%lld",s+1,&k);
	n=strlen(s+1);
	chk();
	
	for(int i=1; i<=n; ++i) s[i+n]=s[i+n*2]=s[i];
	for(int i=2; i<=n*3; ++i)
	{
		if(s[i]==s[i-1])
		{
			need[i]=1;
			while((s[i]==s[i-1] || s[i]==s[i+1]) && s[i]<'z') ++s[i];
			while((s[i]==s[i-1] || s[i]==s[i+1]) && s[i]>'a') --s[i];
		}
	}
	
	ll ans=0;
	for(int i=1; i<=n; ++i) ans += need[i];
	for(int i=1; i<=n; ++i) ans += (k-2)*need[i+n];
	for(int i=1; i<=n; ++i) ans += need[i+n*2];
	
	printf("%lld",ans);
	return 0;
}

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

answers = []
for l in range(2):
  sum = 0
  answer = 0
  for i in range(n):
    sum += a[i]
    if (i + l) % 2 == 0:
      if sum >= 0:
        answer += abs(sum) + 1
        sum = -1
    else:
      if sum <= 0:
        answer += abs(sum) + 1
        sum = 1
  answers.append(answer)

print(min(answers))

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

int a, b, c, k;

int main() {
  int ans, now, i;
  cin >> a >> b >> c >> k;
  ans = a + b + c;
  ans -= max(a, max(b, c));
  now = max(a, max(b, c));
  for(i = 0; i < k; ++i) now *= 2;

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

struct edge{
  ll to, cost;
  edge(){}
  edge(ll t, ll c){to = t; cost = c;}
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N, vector<edge>(0));
  bool ans = true;
  for(int i = 0; i < M; i++){
    ll L, R, D;
    cin >> L >> R >> D;
    L--; R--;
    G.at(L).push_back(edge(R, D));
    G.at(R).push_back(edge(L, -1 * D));
  }

  vll x(N, INF);
  vector<bool> flag(N, false);

  for(int i = 0; i < N; i++){
    if(flag.at(i)) continue;
    queue<ll> que;
    que.push(i);
    flag.at(i) = true;
    x.at(i) = 0;
    while(!que.empty()){
      ll v = que.front(); que.pop();
      for(int j = 0; j < G.at(v).size(); j++){
        ll vv = G.at(v).at(j).to;
        ll cc = G.at(v).at(j).cost;
        if(flag.at(vv)){
          if(x.at(vv) != x.at(v) + cc){
            ans = false;
            break;
          }
        }
        else{
          flag.at(vv) = true;
          x.at(vv) = x.at(v) + cc;
          que.push(vv);
        }
      }
      if(!ans) break;
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
int a[1005],n,k,tot;
int main(){
	cin >> n >> k;
	for (int i = 0;i < n; ++ i){
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i = 0;i < k; ++ i){
		tot += a[i];
	}
	cout << tot<< endl;
	return 0;
} 

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int l[60];
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  sort(l,l + n, greater<int>());
  int sum = 0;
  for (int i = 0; i < k; i++){
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if n%2 != 0:
    print('No')
else:
    for a,b in zip(s[0:],s[int(len(s))//2:]):
        if a == b:
            pass
        else:
            print('No')
            break
    else:
        print('Yes')

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String[] array = sc.nextLine().split("[\\s]");
            int n1 = Integer.parseInt(array[0]);
            int n2 = Integer.parseInt(array[1]);

            int num = n1 + n2;
            System.out.println(Integer.toString(num).length());
        }
        sc.close();

    }

}

Measured memory_bytes: 17724
from sys import stdin
input = stdin.buffer.readline

def main():
    mod = 998244353
    n, k = map(int, input().split())

    lr = [(0, 0)] * k
    for i in range(k):
        l, r = map(int, input().split())
        lr[i] = (l, r+1)

    # Cumulative Sum
    dp = [0] * (n + 1)
    dp[0] = 1
    dp[1] = -1
    for i in range(n):
        dp[i] += dp[i-1]
        dp[i] %= mod
        for l, r in lr:
            if i + l < n:
                dp[i + l] += dp[i]
                dp[i + l] %= mod
                if i + r < n:
                    dp[i + r] -= dp[i]
                    dp[i + r] %= mod

    print(dp[n-1])

main()

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    int point[200][3] = {};
    rep(i, n) rep(j, 3) cin >> point[i][j];

    rep(i, n) rep(j, 3) {
        int tmp = point[i][j];
        bool flag = false;
        rep(k, n) {
            if(point[k][j] == tmp && i != k) {
                point[k][j] = 0;
                flag = true;
            }
        }
        if(flag) point[i][j] = 0;
    }

    rep(i, n) {
        cout << point[i][0]+point[i][1]+point[i][2] << '\n';
    }
    return 0;
}


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

struct BIT {
    int n;
    vector<int> v;

    BIT(int n) : v(n+1) {
        this->n = n;
    }

    void add(int a, int x) {
        for (int i = a; i <= n; i += i & -i)
            v[i] += x;
    }

    int sum(int a) {
        int res = 0;
        for (int i = a; i > 0; i -= i & -i)
            res += v[i];
        return res;
    }
};

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

    int N; cin >> N;
    vector<int> a(N);
    int maxA = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        maxA = max(maxA, a[i]);
    }
    long long ml = (1LL + N) * N / 2;

    int low = 0, high = maxA+1;
    while (high - low > 1) {
        int mid = (low + high) / 2;

        BIT bit(N*2+2);
        int cs = N+1;
        long long res = 0;
        bit.add(cs, 1);
        for (int i = 0; i < N; i++) {
            cs += a[i] < mid ? -1 : 1;
            res += bit.sum(cs);
            bit.add(cs, 1);
        }

        if (res >= (ml+1)/2)
            low = mid;
        else
            high = mid;
    }
    cout << low << "\n";
}

Measured memory_bytes: 1420
n = int(input())

ac = wa = tle = re = 0
for i in range(n):
    tmp = input()
    if tmp == "AC":
        ac += 1
    elif tmp == "WA":
        wa += 1
    elif tmp == "TLE":
        tle += 1
    elif tmp == "RE":
        re += 1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)




Measured memory_bytes: 9224
X, N = map(int, input().split())
line = list(map(int, input().split()))
notLine = [i for i in range(-100, 201) if i not in line]
left = -1
right = len(notLine)
while abs(right - left) > 1:
    middle = (right + left) // 2
    if notLine[middle] >= X:
        right = middle
    else:
        left = middle
#print(notLine[left], notLine[right])
if X - notLine[left] <= notLine[right] - X:
    print(notLine[left])
else:
    print(notLine[right])


Measured memory_bytes: 9196
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
int _min(int x, int y) {return x < y ? x : y;}
int _max(int x, int y) {return x > y ? x : y;}
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}

int a[110000], b[110000];

int main() {
	int n = read();
	for(int i = 1; i <= n; i++) {
		int x = read();
		if(i & 1) a[(i + 1) / 2] = x;
		else b[i / 2] = x;
	} sort(a + 1, a + n / 2 + 1), sort(b + 1, b + n / 2 + 1);
	int max1 = 0, p1, max2 = 0, p2, max3 = 0, p3, max4 = 0, p4, cc = 1;
	for(int i = 2; i <= n / 2 + 1; i++) {
		if(a[i] == a[i - 1]) cc++;
		else {
			if(cc > max1) max2 = max1, max1 = cc, p2 = p1, p1 = a[i - 1];
			else if(cc > max2) max2 = cc, p2 = a[i - 1];
			cc = 1;
		}
	} cc = 1;
	for(int i = 2; i <= n / 2 + 1; i++) {
		if(b[i] == b[i - 1]) cc++;
		else {
			if(cc > max3) max4 = max3, max3 = cc, p4 = p3, p3 = b[i - 1];
			else if(cc > max4) max4 = cc, p4 = b[i - 1];
			cc = 1;
		}
	} if(p1 != p3) printf("%d\n", n - max1 - max3);
	else {
		printf("%d\n", _min(n - max1 - max4, n - max3 - max2));
	}
	return 0;
}

Measured memory_bytes: 512
import math

a,b=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

count=0

if a>=2:
    count+=combinations_count(a,2)

if b>2:
    count+=combinations_count(b,2)

print(count)

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, k, r, s, p;
string t;
map<char,int> score;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k >> r >> s >> p >> t;
	score['r'] = p;
	score['s'] = r;
	score['p'] = s;

	int ans = 0;

	for(int i=0; i<n; i++){
		if (i<k || t[i] != t[i-k]) {
			ans += score[t[i]];
			continue;
		}
		for(char c:{'s', 'r', 'p'}) {
			if (c != t[i] && i+k < n && c != t[i+k]) {
				t[i] = c;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];

		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		int m = 0;
        int[] b = new int[n];
        Arrays.fill(b, 0);
		StringBuilder result = new StringBuilder();
		for(int i = n; i > 0; i-- ){
		    int sum = 0;
		    for(int j = i + i; j <= n; j = j + i){
                sum = sum + b[j - 1];
		    }
		    if(sum%2 != a[i - 1]){
    		    m++;
    		    b[i - 1] = 1;
    		    if(result.length() != 0) result.append(" ");
    		    result.append(String.valueOf(i));
    		}
		}
		
		// 出力
		System.out.println(m);
		System.out.println(result);
	}

}


Measured memory_bytes: 87292
#include<iostream>
using namespace std;
int main(void){
	int n,m,temp=0;
	int a[1000]={0};
	
	cin>>n>>m;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<=m;i++){
		for(int j=0;j<n-1;j++){
			if(a[j]%i>a[j+1]%i){
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	
	for(int i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
int main(){
    while (1) {
        int n;
        scanf("%d",&n);
        if (n==0) {
            return 0;
        }
        int m,count=0,i;
        char s[1000001];
        scanf("%d",&m);
        scanf("%s",s);
        int x=0;
        for (i=0; i<m; i++) {
            if (x%2) {
                if (s[i]=='O') {
                    x++;
                }else{
                    if (x>=2*n+1) {
                        count+=x/2-n+1;
                    }
                    x=1;
                }
            }else{
                if (s[i]=='I') {
                    x++;
                }else{
                    if (x>=2*n+1) {
                        count+=x/2-n;
                    }
                    x=0;
                }
            }
        }
        printf("%d\n",count);
    }
}
/*時間切れ
 
#include <stdio.h>
int main(){
    while (1) {
        int n;
        scanf("%d",&n);
        if (n==0) {
            return 0;
        }
        int m,i,j,count=0;
        scanf("%d",&m);
        char s[m+1];
        scanf("%s",s);
        for (i=0; i+2*n<m; i++) {//基準
            int flag=1;
            for (j=0; j<2*n+1; j++) {//比較対象
                if (j%2) {
                    if (s[i+j]!='O') {
                        flag=0;
                        break;
                    }
                }else{
                    if (s[i+j]!='I') {
                        flag=0;
                        break;
                    }
                }
            }
            if (flag) {
                count++;
            }
        }
        printf("%d\n",count);
    }
}*/

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

int main()
{
  int64_t N, r = 0, g = 0, b = 0;
  string S;
  cin >> N >> S;
  int64_t ans = (N * (N - 1) * (N - 2)) / 6;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'R')
      r++;
    else if (S.at(i) == 'G')
      g++;
    else
      b++;
  }
  // 3つとも同じ
  if (r >= 3)
    ans -= (r * (r - 1) * (r - 2)) / 6;
  if (g >= 3)
    ans -= (g * (g - 1) * (g - 2)) / 6;
  if (b >= 3)
    ans -= (b * (b - 1) * (b - 2)) / 6;
  // 2つが同じ
  if (r >= 2)
    ans -= ((r * (r - 1)) / 2) * (g + b);
  if (g >= 2)
    ans -= ((g * (g - 1)) / 2) * (r + b);
  if (b >= 2)
    ans -= ((b * (b - 1)) / 2) * (r + g);

  for (int i = 0; i <= N - 2; i++)
  {
    for (int j = 1; j < N; j++)
    {
      if (i + 2 * j >= N)
        break;
      if (S.at(i) != S.at(i + j) && S.at(i) != S.at(i + 2 * j) && S.at(i + j) != S.at(i + 2 * j))
        ans--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//12:15~
const int mod=1e9+7;
const llint big=1e16+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	string str;cin>>str;
	if((str[0]==str[1]||str[2]==str[3])&&str[1]==str[2]){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long R;
	cin >> R;
	double L = 2 * R *  M_PI;
	printf("%.9f\n", L);
	return 0;
}

Measured memory_bytes: 3808
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let N = rl().parse::<i64>().unwrap();

    let mut m = 1_i64;
    let mut s = 0_i64; // sum of 1..m
    while s + m < N {
        s += m;
        m += 1;
    }

    // このとき sum(1..m) < N <= sum(1..m + 1) となる。
    assert!(s < N && s + m >= N);

    let d = s + m - N;
    assert!(0 <= d && d <= N);

    // 1 + 2 + ... + m - d = N なので、解くべき集合は:

    for x in 1..m + 1 {
        if x == d {
            continue;
        }

        println!("{}", x);
    }
    return;
}


Measured memory_bytes: 4352
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007;

void main() {
    int w, h, x, y;
    scan(w, h, x, y);
    auto ans = 1.0 * w * h / 2;
    auto b = 2*x == w && 2*y == h ? 1 : 0;
    writefln("%.10f %s", ans, b);
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> X(n);
    copy_n(istream_iterator<int>(cin), n, X.begin());
    int avg = accumulate(X.begin(), X.end(), 0) / (double)n + 0.5;
    int64_t ans = 0;
    for (const auto &x: X)
        ans += (x - avg) * (x - avg);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, a, b = 0;
	
	scanf("%d", &n);
	
	for(a = 1; a <= n; a++){
		if((a < 10) || (a >= 100 && a < 1000) || 
		   (a >= 10000 && a < 100000)){
			b++;
		}
	}
	
	printf("%d", b);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  string ans;
  while(N>0) {
    N--;
    ans.push_back('a'+N%26);
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout<<ans<<endl;
}



Measured memory_bytes: 3632
N = int(input())
s = list(input())

a_z_list = [""] * 26
for i in range(65,65+26):
    a_z_list[i - 65] = chr(i)

a_z_list *= 2

ans = []

for i in s:
    ans.append(a_z_list[ord(str(i)) -65 + N ])

print("".join(ans))

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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
const int MAX = 1e5 + 9;
ll arr[MAX], n,dp[MAX];
int main() {
    fast();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    dp[1]=abs(arr[1]-arr[0]);
    for (int j = 2; j < n; ++j) {
        dp[j]=min(dp[j-1]+abs(arr[j]-arr[j-1]),dp[j-2]+abs(arr[j]-arr[j-2]));
    }
    cout<<dp[n-1];
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int n_max = 0;
  int x = 0;
  for(int i=0; i<n; i++){
    if(s.at(i) == 'I') x += 1;
    else x -= 1;
    n_max = max(n_max, x);
  }
  
  cout << n_max << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    set<int> s;
    int x;
    rep(i, n) {
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 3604
program panasonic2020b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: h,w
    
    read*, h,w
    if (h==1 .or. w==1) then
        print'(i0)', 1
    else
        print'(i0)', h*w - (h*w)/2
    end if
end program panasonic2020b

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

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

using namespace std;

int main() {
	  char c;
	  cin >> c;
	  if('a' <= c && c <= 'z'){
		  cout << "a";
	  }else{
		  cout << "A";
	  }
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cassert>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>

using namespace std;

typedef long long ll;

const int N = 100 + 5;

int n, m;
int b[N], ans[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  while (n) {
    bool ok = false;
    for (int i = n; i >= 1; i--) {
      if (b[i] == i) {
        ok = true;
        n--;
        ans[++m] = i;
        for (int j = i; j <= n; j++) {
          b[j] = b[j+1];
        }
        break;
      }
    }
    if (!ok) {
      puts("-1");
      return 0;
    }
  }
  for (int i = m; i >= 1; i--) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  string S;
  cin >> N >> S;
  vector<long long> v[3];
  char a[3] = {'R', 'G', 'B'};
  rep(i, N) {
    if(S[i] == a[0]) v[0].push_back(i);
    if(S[i] == a[1]) v[1].push_back(i);
    if(S[i] == a[2]) v[2].push_back(i);
  }
  long long ans = v[0].size() * v[1].size() * v[2].size();

  rep(i, N) {
    for(long long j = i+1; j< N; j++) {
      if(S[i] != S[j]) {
        if((i + j) % 2 == 0) {
          if(S[i] != S[(i+j)/2] && S[j] != S[(i+j)/2]) {
            ans--;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
int main (void){

    int a,b,c,d,e,k,ans;

    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);

        if(b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k&&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&e-c<=k&&e-d<=k){

            puts("Yay!\n");

    }else{

        puts(":(\n");

    }

    return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int n, m, k;
char s[20][maxn];
int cnt[15], tmp[15];

int main() {
    n=read(), m=read(), k=read();
    for(int i=0; i<n; ++i) scanf("%s", s[i]);
    int mi=inf;
    for(int ss=0; ss<1<<n; ++ss) {
        memset(cnt,0,sizeof(cnt));
        int f=1, c=0;
        for(int j=0; j<m; ++j) {
            memset(tmp,0,sizeof(tmp));
            int now=0;
            for(int i=0; i<n; ++i) {
                tmp[now]+=s[i][j]=='1';
                if(tmp[now]>k) { f=0; break; }
                if(cnt[now]+tmp[now]>k) {
                    c++;
                    memset(cnt,0,sizeof(cnt));
                }
                if(ss>>i&1) now++;
            }
            if(!f) break;
            for(int i=0; i<=now; ++i) cnt[i]+=tmp[i];
        }
        if(f) mi=min(mi,c+__builtin_popcount(ss));
    }
    printf("%d\n", mi);
}

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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    int i;
    for(i = 0; i < m; i++) {
        cin >> b[i];
    }
    int j;
    for(i = 0; i < n; i++) {
        for(j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int cnt = 0;
    int ans = 0;
    for(i = 0; i < n; i++) {
        for(j = 0; j < m; j++) {
            ans += a[i][j] * b[j];
        }
        if (ans + c > 0) {
            cnt++;
        }
        ans = 0;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
  int A,B;
  cin >> A >> B;

  int ans{};
  for (auto i = A; i <= B; ++i) {
    if (i%100 == (i/10000)+((i/1000)%10)*10) ++ans;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    }
}


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

int main()
{
    string S;
    int K;
    cin >> K >> S;
    if (S.length() <= K)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int d[200][2];

int main()
{
  int n;
  cin >> n;
  
  for(int i=0;i<n;i++)
    for(int j=0;j<2;j++)
      cin >> d[i][j];
 
  int cnt=0;
  for(int i=0;i<n;i++){
    if(d[i][0]==d[i][1]){
      ++cnt;
      if(cnt==3){
        cout << "Yes";
        return 0;
      }
    }
    else if(d[i][0]!=d[i][1])
      cnt=0;
  }
  
  cout << "No";
  return 0;
}

    
  


Measured memory_bytes: 3580
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int i;
  int t=0,x=0,y=0;
  
  for(i=0;i<n;++i){
    int nt,nx,ny;
    scanf("%d%d%d",&nt,&nx,&ny);
    int dt = nt-t, dx = x-nx, dy = y-ny;
    
    int sum = dx+dy;
    if(sum<0) sum = -sum;
    
    if(sum>dt || (dt-dx-dy)%2){
      puts("No");
      return 0;
    }
    t=nt, x=nx, y=ny;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1636
# -*- coding:utf-8 -*-

"""解説
https://www.youtube.com/watch?v=nCHz87GMdpo



"""

def solve2():
    """ 全探索O(F**2) """
    A, B, C, D, E, F = list(map(int, input().split()))

    # 水をx, 砂糖をyとする
    sugars = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            y = i*C + j*D
            if y <= F:
                # 作れる砂糖の量y[g]をメモする
                sugars.append(y)

    water = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                # 作れる水の量x[g]をメモする
                water.append(x)
    
    sugars.sort()
    water.sort()

    # 濃度
    concent = 0
    for x in water:
        for y in sugars:
            if x+y > F:
                break
            if x+y > 0 and y/(x+y) <= E/(100+E):
                if y/(x+y) >= concent:
                    concent = y/(x+y)
                    ans = "{} {}".format(x+y, y)
    print(ans)


def solve():
    """ WA """
    A, B, C, D, E, F = list(map(int, input().split()))

    # dp[i] := 砂糖水i[g]のときに作れる最大の濃度
    # 配るDP
    dp= [0]*(F+1)

    for i in range(0, F+1):
        if i+100*A <= F:
            concent = (dp[i]*i)/(i+100*A)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*A] = max(dp[i+100*A], concent)
        if i+100*B <= F:
            concent = (dp[i]*i)/(i+100*B)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*B] = max(dp[i+100*B], concent)
        if i+C <= F:
            concent = (dp[i]*i+C)/(i+C)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+C] = max(dp[i+C], concent)
        if i+D <= F:
            concent = (dp[i]*i+D)/(i+D)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+D] = max(dp[i+D], concent)
    
    print(dp)
    return
    max_concent = max(dp)
    print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))



if __name__ == "__main__":
    solve2()


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

int main() {
  long long N; cin >> N;
  long long h[N]; for (long long i = 0; i < N; i++) cin >> h[i];
  
  long long dp[N];
  for (long long i = 0; i < N; i++){
    if (i > 1) dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i == 1) dp[1] = abs(h[1] - h[0]);
    if (i == 0) dp[0] = 0;
  }
  cout << dp[N - 1] << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
  int m, n_min, n_max;
  int p[200];
  
  while(cin >> m >> n_min >> n_max, m) {
    for (int i = 0; i < m; i++) {
      cin >> p[i];
    }
    sort(p, p+m);

    int gap = 0;
    int ans;
    for(int i = n_max; i >= n_min; i--) {
      if(gap < p[m-i] - p[m-i-1]) {
        gap = p[m-i] - p[m-i-1];
        ans = i;
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
  int A, B, N, planA;

  cin >> N >> A >> B;
  planA = N * A;
  
  if (planA >= B) {
    cout << B << endl;
  }
  else{
    cout << planA << endl;
  }
}

Measured memory_bytes: 256