akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
//using namespace __gnu_pbds;

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

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n;
   cin >> n;
   string s = "RGB" , t;
   cin >> t;
   vector<vector<int>> sum(3 , vector<int>(n));
   for(int i = 0 ; i < 3 ; ++i){
      for(int j = 0 ; j < n ; ++j){
         sum[i][j] = (t[j] == s[i]);
         if(j)sum[i][j] += sum[i][j - 1];
      }
   }

   ll ans = 0;
   for(int i = 0 ; i < n ; ++i){
      for(int j = i + 1 ; j < n ; ++j){
         if(t[i] == t[j])continue;
         int k = -1;
         for(int l = 0 ; l < 3 ; ++l){
            if(s[l] != t[i] && s[l] != t[j])
               k = l;
         }
         ans += sum[k][n - 1] - sum[k][j];
         int d = j - i;
         if(j + d < n)ans -= (sum[k][j + d] - sum[k][j + d - 1]);
      }
   }

   cout << ans << "\n";
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n,m;

void input(){
    cin >> n >> m;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans;
    if(n==1){
        if(m==1){
            cout << 1 << endl;
            return 0;
        }
        else{
            cout << m-2 << endl;
            return 0;
        }
    }
    else if(m == 1){
        cout << n-2 << endl;
        return 0;
    }
    else{
        cout << n*m - (2*(m+n)-4) << endl;
        return 0;
    }
}

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

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

    int M = 100010;

    int N, C;
    cin >> N >> C;

    int Chan[C][M] = {};
    
    for(int i = 0; i < N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        Chan[c][s]++;
        Chan[c][t]--;
    }

    for(int i = 0; i < C; i++){
        for(int j = 1; j < M; j++){
            Chan[i][j] += Chan[i][j - 1];
        }
    }

    for(int i = 0; i < C; i++){
        for(int j = 1; j < M; j++){
            if(Chan[i][j - 1] == 0 and Chan[i][j] == 1){
                Chan[i][j - 1]++;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < M; i++){
        int cnt = 0;
        for(int j = 0; j < C; j++){
            cnt += (Chan[j][i] > 0);
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define pii pair < int , int >
#define Endl '\n'

#pragma GCC optimize("Ofast")

using namespace std;
using namespace __gnu_pbds;

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

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const int FFTM = 998244353;

const int SX[4] = {0 , 1 , -1 , 0};
const int SY[4] = {1 , 0 , 0 , -1};
const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

typedef cc_hash_table< int, int, hash<int>, equal_to<int>, direct_mask_range_hashing<int>, hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("gotham.in", "r", stdin);
//    freopen("gotham.out", "w", stdout);
#endif
    int r, g, b;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    while(g <= r)g *= 2, k--;
    while(b <= g)b *= 2, k--;
    if (k >= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3652
use proconio::{input, fastout};
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        q: usize,
        arr: [(usize, usize); q],
    }

    let mut primes = vec![2, 3, 5, 7, 11, 13, 17, 19];
    'a: for i in 10..49_999 {
        let c = i*2 + 1;
        for p in &primes {
            if c % p == 0 { continue 'a; }
        }
        primes.push(c);
    }

    let mut primeset: HashSet<usize> = HashSet::with_capacity(100_000);
    for &p in &primes { primeset.insert(p); }
    let mut cnt: Vec<usize> = vec![0; 100_000];
    for &p in &primes {
        let idx = 2*p-1;
        if primeset.contains(&idx) {
            for i in idx..100_000 { cnt[i] += 1; }
        }
    }
    for &(l, r) in &arr {
        let ans = cnt[r] - cnt[l-1];
        println!("{}", ans);
    }
}


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

int main() {
    int n, q;
    cin >> n;
    set<int> st;
    st.insert(0);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        vector<int> em;
        for (int j : st) em.emplace_back(j + x);
        for (int j : em) st.insert(j);
    }
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        cout << (st.count(x) ? "yes" : "no") << endl;
    }
}



Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>

template <typename T>
class UnionFindTree
{
public:
    UnionFindTree(T size = 0)
    {
        if (size == 0)
            return;

        unitedSize.resize(size + 1, 1);
        rank.resize(size + 1);
        parents.resize(size + 1);
        for (T i=0; i<size; ++i)
        {
            //最初は自分自身が親
            parents[i] = i;
            rank[i] = 0;
        }
    }

    // 一方の根をもう一方の根の子にする
    bool Union(T x, T y)
    {
        x = FindRoot(x);
        y = FindRoot(y);
        if (x == y)
            return false;

        //ノードごとの rank を記憶しておき rank が低い方を高い方の子にする
        //例: 6-4-7 / 2-5, Union(6, 2)の場合 2 を 6 の子にする
        if (rank[x] < rank[y])
        {
            parents[x] = y;
            unitedSize[y] += unitedSize[x];
            // 子を増やした方の rank を更新
            if (rank[y] == rank[x])
                rank[y]++;
        }
        else
        {
            parents[y] = x;
            unitedSize[x] += unitedSize[y];
            // 子を増やした方の rank を更新
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    T FindRoot(T x)
    {
        if (parents[x] == x)
            return x;

        // root にたどり着くまで
        while (parents[x] != x)
        {
            // x の親の親 を x の親とする
            T parent = parents[x];
            parents[x] = parents[parent];
            x = parents[x];
        }

        return x;
    }

    bool IsUnited(T a, T b)
    {
        return FindRoot(a) == FindRoot(b);
    }

    T GetUnitedSize(T x)
    {
        return unitedSize[FindRoot(x)];
    }

private:
    std::vector<T> parents;
    std::vector<T> rank;
    std::vector<T> unitedSize;
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    std::vector<std::pair<int, int>> connection(M);
    UnionFindTree<int> intactTree(N);
    for (int i=0; i<M; ++i)
    {
        int ai, bi;
        std::cin >> ai >> bi;
        intactTree.Union(ai, bi);
        connection[i] = {ai, bi};
    }

    int result = 0;
    for (int i=0; i<M; ++i)
    {
        UnionFindTree<int> brokenTree(N);
        for (int j=0; j<M; ++j)
        {
            //i番目のconnectionはなかったことにする
            if (i == j)
                continue;

            brokenTree.Union(connection[j].first, connection[j].second);
        }

        if (brokenTree.GetUnitedSize(0) < N)
            result++;
    }
    std::cout << result;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

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


main(){
  int n;
  while(cin>>n && n){
    int pos[n][2];
    int maxx=0,maxy=0,minx=0,miny=0;
    pos[0][0]=0;//y
    pos[0][1]=0;//x
    REP(i,1,n){
      int tn,d;
      cin>>tn>>d;
      pos[i][0]=pos[tn][0]+dy[d];
      pos[i][1]=pos[tn][1]+dx[d];
      maxx=max(maxx,pos[i][0]);
      maxy=max(maxy,pos[i][1]);
      miny=min(miny,pos[i][1]);
      minx=min(minx,pos[i][0]);
    }
    cout << maxy-miny+1 <<" " << maxx-minx+1<< endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    // Your code here!
    int num[5];
    
    for(int i= 1; i < 6; i++){
        scanf("%d",&num[i]);
        if(num[i] == 0){
            printf("%d\n",i);
            return 0;
        }
    }
}


Measured memory_bytes: 1736
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String str = scan.next();
    
    if(str.substring(str.length() - 1).equals("s")){
      str += "es";
    } else {
      str += "s";
    }
    
    System.out.println(str);	
  }
}

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

using namespace std;

typedef long long ll;

#define N 2000010

int n, h, w;

struct node {
    int r, c, a;

    node() {}

    node(int r, int c, int a) : r(r), c(c), a(a) {}

    void input() {
        scanf("%d %d %d", &r, &c, &a);
    }

    bool operator<(const node &other) const {
        return a > other.a;
    }
} a[N];

int fa[N], sze[N], cnt[N];

void Init() {
    for (int i = 1; i <= h + w; ++i) {
        fa[i] = i, sze[i] = 1, cnt[i] = 0;
    }
}

int find(int x) {
    return x == fa[x] ? fa[x] : fa[x] = find(fa[x]);
}

void merge(int x, int y) {
    x = find(x), y = find(y);
    if (x != y) {
        if (sze[x] > sze[y]) swap(x, y);
        fa[y] = x;
        sze[x] += sze[y];
    }
}

int main() {
#ifdef LOCAL_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    while (scanf("%d %d %d", &n, &h, &w) != EOF) {
        Init();
        for (int i = 1; i <= n; ++i) {
            a[i].input();
        }
        sort(a + 1, a + 1 + n);
        ll res = 0;
        for (int i = 1; i <= n; ++i) {
            int r1 = find(a[i].r);
            int r2 = find(h + a[i].c);
            if (r1 == r2) {
                if (sze[r1] > cnt[r1]) {
                    res += a[i].a;
                    cnt[r1]++;
                }
            } else {
                if (sze[r1] + sze[r2] > cnt[r1] + cnt[r2]) {
                    merge(r1, r2);
                    res += a[i].a;
                    cnt[find(r1)] = cnt[r1] + cnt[r2] + 1;
                }
            }
        }
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<int> graph[100];
int dist[100]={0};
int main(){
  int n;
  cin >> n;

  for(int i=0;i<n;++i){
    int u,k;
    cin >> u >> k;
    for(int i=0;i<k;++i){
      int v;
      cin >> v;
      graph[u-1].push_back(v-1);
    }
    dist[i] = -1;
  }

  queue<int> q;
  q.push(0);
  dist[0] = 0;
  while(!q.empty()){
    auto v = q.front();q.pop();
    for(auto next_v:graph[v]){
      if(dist[next_v]==-1){
        dist[next_v] = dist[v]+1;
        q.push(next_v);
      }
    }
  }
  for(int i=0;i<n;++i){
    cout << i+1 << " " << dist[i] << endl;
  }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
  	char c; cin >> c;
  	if(islower(c))
  		cout << "a\n";
  	else
  		cout <<"A\n";
  }
}



Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String newLine;
        int ppl, snackKind, havingSnackTotal, treated;
        boolean hasSnack[];

        ppl = scan.nextInt();
        snackKind = scan.nextInt();
        newLine = scan.nextLine();
        
        hasSnack = new boolean[ppl];
        for(int i = 0; i < hasSnack.length; i++) {
            hasSnack[i] = false;
        }

        for(int k = 0; k < snackKind; k++) {
            havingSnackTotal = scan.nextInt();
            newLine = scan.nextLine();
            
            for(int p = 0; p < havingSnackTotal; p++) {
                hasSnack[scan.nextInt() - 1] = true;
            }
            newLine = scan.nextLine();
        }

        treated = 0;
        for(int i = 0; i < hasSnack.length; i++) {
            if(!hasSnack[i]) {
                treated++;
            }
        }
        System.out.println(treated);
        scan.close();
        return;
    }
}

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

int main(){
  
  int H, W, i, j;
  cin >> H >> W;
  
  vector<vector<char>> table(H , vector<char>(W));
  for(i = 0; i < H; i++)
    for(j = 0; j < W; j++)
      cin >> table.at(i).at(j);
  
  vector<bool> row_h(H, false);
  vector<bool> row_w(W, false);
  
  for(i = 0; i < H; i++)
    for(j = 0; j < W; j++){
      	if(table.at(i).at(j) == '#'){
          row_h.at(i) = true;
          break;
        }
    }
   for(i = 0; i < W; i++)
    for(j = 0; j < H; j++){
      	if(table.at(j).at(i) == '#'){
          row_w.at(i) = true;
          break;
        }
    }
  for(i = 0; i < H; i++){
    int flag = 0;
    for(j = 0; j < W; j++){
      if(row_h.at(i) == true && row_w.at(j) == true){
        cout << table.at(i).at(j);
        flag = 1;
      }
    }
    if(flag == 1)
      cout << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n+1],c=0;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=2;i<n;i++)
    {
        if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))
            c++;
    }
    printf("%d\n",c);
    return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e6 + 5;
const ll INF = 1e17 + 7 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n;
int a[N];
int prime[N];

unordered_map<int, int> max_map;

ll power(ll a , ll b , ll mod){
    ll ret = 1ll; a %= mod;
    for( ; b ; ret = ret * (b&1 ? a : 1ll) % mod , a = a * a % mod , b >>= 1ll);
    return ret;
}

// Function to find the smallest prime factors
// of numbers upto MAX
void sieve()
{
    prime[0] = prime[1] = 1;
    for (int i = 2; i < N; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < N ; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

// Function to return the LCM modulo M
ll lcmModuloM()
{

    for (int i = 1; i <= n; i++) {
        int num = a[i];
        unordered_map<int, int> temp;

        // Temp stores mapping of prime factor to
        // its power for the current element
        while (num > 1) {

            // Factor is the smallest prime factor of num
            int factor = prime[num];

            // Increase count of factor in temp
            temp[factor]++;

            // Reduce num by its prime factor
            num /= factor;
        }

        for (auto it : temp) {

            // Store the highest power of every prime
            // found till now in a new map max_map
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }

    ll ans = 1;

    for (auto it : max_map) {

        // LCM is product of primes to their highest powers modulo M
        ans = (ans * power(it.first, it.second , mod)) % mod;
    }

    return ans;
}

void solve(int testCase){

    scanf("%d" , &n);

    sieve();

    for(int i = 1 ; i <= n ; i ++){
            scanf("%d" , &a[i]);
    }

    ll lcm = lcmModuloM();

    ll ans = 0;
    for(int i = 1 ; i <= n ; i ++){
            ans += lcm * power(a[i] , mod - 2 , mod) % mod;
            ans %= mod;
    }

    printf("%lld\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <cassert>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi a(n);
    for (int &x : a) cin >> x;
    int prev = a[0] - 1;
    for (int &x : a) {
        if (prev > x) {
            cout << "No";
            return 0;
        } else if (prev < x) {
            prev = x - 1;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	 int a[26]={},n;
	 string S;
	 char b[26];
	 for (int i = 0; i < 26; i++) {
		 b[i] = 'a' + i;
	 }
	 while (cin >> S) {
		 for (int i = 0; i < S.size(); i++) {
			 if (S[i] >= 'a'&&S[i] <= 'z') {
				 n = S[i] - 'a';
				 a[n]++;
			 }
			 else if (S[i] >= 'A'&&S[i] <= 'Z') {
				 n = S[i] - 'A';
				 a[n]++;
			 }
		 }
	 }
	 for (int i = 0; i < 26; i++) {
		 cout << b[i] << " " << ':' << " " << a[i] << endl;
	 }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(auto& x:d)
    cin >> x;
  int ans = 0;
  for(auto i=0;i<n;++i){
    for(auto j=0;j<i;++j){
      ans += d.at(j)*d.at(i);
    }
  }
  cout << ans << endl;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll l, r;
  cin >> l >> r;
  if(r - l > 2019) {
    puts("0");
    return 0;
  }
  ll ans = 2018;
  repLRE(i, l, r - 1) {
    repLRE(j, i + 1, r) { chmin(ans, (i*j)%2019); }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
uint32 k;
void trans(int32 &x, int32 &y) {
	x %= k * 2;
	y %= k * 2;
	if (y >= k) {
		y -= k;
		if (x >= k) {
			x -= k;
		}
		else {
			x += k;
		}
	}
	return;
}

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n >> k;
	std::vector<int32> x(n), y(n);
	std::vector<char> c(n);
	rep(i, 0, n)
		std::cin >> x[i] >> y[i] >> c[i];
	std::vector<std::vector<int64>> m(k*2, std::vector<int64>(k * 3, 0));
	rep(i, 0, n) {
		if (c[i] == 'W') x[i] += k;
		trans(x[i], y[i]);
		++m[y[i]][x[i]];
		++m[y[i] + k][x[i] + k];
		--m[y[i] + k][x[i]];
		--m[y[i]][x[i] + k];
	}
	rep(i, 0, k * 2) {
		rep(j, 1, k * 3) {
			m[i][j] += m[i][j - 1];
		}
	}
	rep(i, 1, k * 2) {
		rep(j, 0, k * 3) {
			m[i][j] += m[i - 1][j];
		}
	}
	int64 ans = 0;
	rep(i, 0, k) {
		rep(j, 0, k) {
			ans = std::max(ans, m[i][j] + m[i + k][j + k] + m[i][j + 2 * k]);
		}
	}
	rep(i, 0, k) {
		rep(j, k, k*2) {
			ans = std::max(ans, m[i][j] + m[i + k][j - k] + m[i + k][j + k]);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 48896
defmodule Main do

  def main do
    [a, b] = IO.gets("") |> String.trim() |> String.split(" ")
    a = String.to_integer(a)

    multiplication(a, b) |> IO.puts()
  end

  @doc """
  Multiplication

  ## Examples

      iex> Multiplication3.multiplication(198, "1.10")
      217
      iex> Multiplication3.multiplication(1, "0.01")
      0
      iex> Multiplication3.multiplication(1000000000000000, "9.99")
      9990000000000000

  """
  def multiplication(a, b) do
    b = b |> String.codepoints() |> Enum.reject(& &1 == ".") |> Enum.join |> String.to_integer()
    (a * b) |> div(100)
  end

end

Measured memory_bytes: 31184
#include <iostream>
#include <vector>

using namespace std;

int H, W;

int a[505][505];

vector<int> V1, V2, V3, V4;

int main(void) {

	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
		}
	}

	int K, L;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (a[i][j] % 2 == 0) { continue; }
			else {
				a[i][j]--;
				if (j <= W - 1) { a[i][j + 1]++; K = i; L = j + 1; }
				else if (i <= H - 1 && j == W) { a[i + 1][j]++; K = i + 1; L = j; }
				else { continue; }
			}
			V1.push_back(i); V2.push_back(j); V3.push_back(K); V4.push_back(L);
		}
	}

	cout << V1.size() << endl;
	for (int i = 0; i < (int)V1.size(); i++) {
		cout << V1[i] << " " << V2[i] << " " << V3[i] << " " << V4[i] << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 5220
#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;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll x,a,b;
    cin >> x >> a >> b;
    x-=a;
    while(x>=b)
    {
        x-=b;
    }
    cout << x << endl;
}


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

using namespace std;

int main(void) {
    int i, A_index, Z_index;
    char c;
    string s;
    // get input ----------------------------------------
    cin >> s;
    // search first A index and last Z index ------------
    A_index = -1;
    Z_index = -1;
    for(i = 0; i < s.size(); i++) {
        c = s[i];
        if(c == 'A' && A_index == -1) {
            A_index = i;
        } else if(c == 'Z') {
            Z_index = i;
        }
    }
    // disp answer ---------------------------------------
    cout << Z_index - A_index + 1 << endl;
    return 0;
}




Measured memory_bytes: 640
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    memo = [0] * (n + 1)
    for _ in range(k):
        flag = True
        for i, aa in enumerate(a):
            bf = (i - aa if i - aa >= 0 else 0)
            af = (i + aa + 1 if i + aa < n else n)
            memo[bf] += 1
            memo[af] -= 1
        for i in range(n):
            memo[i + 1] += memo[i]
            a[i] = memo[i]
            if a[i] != n:
                flag = False
            memo[i] = 0
        if flag:
            break
    print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 98308
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DHandstand2 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        map<P, int> cnt;
        FOR(i, 1, N) {
            int n = i;
            int b = n % 10;
            while (n >= 10) {
                n /= 10;
            }
            int a = n;
            if (b == 0) continue;
            cnt[{a, b}]++;
        }

        int res = 0;
        FOR(i, 1, N) {
            int n = i;
            int b = n % 10;
            while (n >= 10) {
                n /= 10;
            }
            int a = n;
            if (b == 0) continue;
            res += cnt[{b, a}];
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DHandstand2 solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
	int N, K, A[100010], B[100010];
	cin >> N >> K;
	long ans=0;
	for(int i=0; i<N; ++i){
	    cin >> A[i] >> B[i];
	    if((A[i]|K) == K) ans += B[i];
	}
	for(int x=0; x<31; ++x){
	    if(K&(1<<x)){
	        int L=K;
	        long now=0;
	        L &= ~(1<<x);
	        for(int y=0; y<x; ++y) L |= (1<<y);
	        for(int i=0; i<N; ++i) if((A[i]|L) == L) now += B[i];
	        ans=max(ans, now);
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;
#define ll long long
using vt = ll;
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007
int main() {
	int n, k, ans = 0;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h.at(i);
	sort(h.begin(), h.end());
	rep(i, n) {
		if (h.at(n - 1 - i) >= k) ans++;
		else break;
	}
	cout << ans;
}

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

using namespace std;

const int INF = 1e9;

vector< vector<int> > g;

bool dfs(int cur, vector<int>& used, vector<int>& cycle) {
	if (used[cur] == 1) {
		cycle[cur] = true;
		return true;
	}
	used[cur] = 1;
	for (int nex : g[cur]) {
		if (dfs(nex, used, cycle)) {
			cycle[cur] = true;
			return true;
		}
	}
	used[cur] = 2;
	return false;
}

int solve(int cur, vector<int>& cycle, vector<int>& grundy) {
	if (grundy[cur] != INF) return grundy[cur];
	set<int> s;
	for (int nex : g[cur]) {
		if (cycle[nex]) continue;
		int x = solve(nex, cycle, grundy);
		s.insert(x);
	}
	int res = 0;
	while (s.find(res) != s.end()) res++;
	return grundy[cur] = res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	g.resize(n);
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		p--;
		g[p].push_back(i);
	}
	vector<int> used(n, 0), cycle(n, false);
	for (int i = 0; i < n; i++) {
		if (used[i]) continue;
		dfs(i, used, cycle);
	}
	int x = -1, cnt = 0;
	bool ans = true;
	vector<int> grundy(n, INF);
	for (int i = 0; i < n; i++) {
		if (cycle[i]) {
			cnt++;
			int y = solve(i, cycle, grundy);
			if (x == -1) {
				x = y;
				ans = false;
			} else if (x != y) {
				ans = true;
				break;
			}
		}
	}
	if (!ans) ans = (cnt % 2 == 0);
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 22784
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)>=c) cout<<"Yes";
    else cout<<"No";
    WAIT;
    rt0;
}

Measured memory_bytes: 504
//AnkitCode99 (DP)....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;

using namespace std;

const ll sz=1e5+5;

int main()
{
    fast;

    string s,t;
    cin>>s>>t;
    if(s==t.substr(0,(ll)s.length()))
        cout<<"Yes\n";
    else
        cout<<"No\n";


}//Goodbye...

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll MOD = 1e9 + 7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  ll x[n], y[m];
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int j = 0; j < m; j++) cin >> y[j];
  ll sumx  = 0, sumy = 0;
  for (int i = 1; i < n; i++) {
    sumx += (ll)i * (ll)(n - i) * (x[i] - x[i - 1]);
    sumx %= MOD;
  }
  for (int i = 1; i < m; i++) {
    sumy += (ll)i * (ll)(m - i) * (y[i] - y[i - 1]);
    sumy %= MOD;
  }
  cout << (sumx * sumy) % MOD << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    char c;
    string ans;
    bool flag = true;
    for(c = 'a' ; c <= 'z' && flag ; c++){
        for(int i = 0 ; i < s.size() ; i++){
            if(c == s[i]){
                ans = "None";
                break;
            }
            if(i == s.size() - 1){
                ans = c;
                flag = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> i2;
typedef pair<ll,ll> ll2;

ll n;

ll arr[100000];

bool larger(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    
    return (num>2);
}

bool smaller(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    
    return (num<2);
}

bool works(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    return (num==2);
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    cin >> n;
    
    for (ll i = 0; i < n; i++) cin >> arr[i];
    
    ll s, l;
    
    ll lo = 1;
    ll hi = 1e14;
    
    while (hi > lo)
    {
        ll mid = (lo+hi)/2;
        if (smaller(mid)) lo = mid+1; //needs more
        else hi = mid;
    }
    
    s = lo;
    
    lo = 1;
    hi = 1e14;
    
    while (hi > lo)
    {
        ll mid = (lo+hi+1)/2;
        if (larger(mid)) hi = mid-1;
        else lo = mid;
    }
    
    l = lo;
    
    if (works(s) && works(l)) cout << min(s,l) << ' ' << max(s,l) << '\n';
    else cout << -1 << '\n';

    
    
    return 0;
    
}




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

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;





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

    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b==c+d)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
}



Measured memory_bytes: 256
x, y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
int arr[102];
int tmp[5];

int main(){
    int N, prev, curr, diff = 0, diffn, res, idx;
    bool flag;
    for (; ;) {
        scanf("%d", &N);
        if (N == 0) break;
        res = -1;
        if (N < 5) {
            for (int i = 0; i <= N; i++) scanf("%d", &arr[i]);
            for (int i = 0; i <= N; i++) {
                idx = 0;
                for (int j = 0; j <= N; j++) {
                    if (j == i) continue;
                    tmp[idx++] = arr[j];
                }
                flag = true; diff = tmp[1]-tmp[0];
                for (int j = 2; j < N; j++) if (tmp[j]-tmp[j-1] != diff) { flag = false; break; }
                if (flag) { res = arr[i]; break; }
            }
            printf("%d\n", res);
        }

        else if (N >= 5) {
            map<int, int> m;
            scanf("%d", &prev);
            arr[0] = prev;
            for (int i = 1; i <= N; i++) {
                scanf("%d", &curr);
                diff = curr - prev;
                arr[i] = curr; prev = curr;
                if (m.find(diff) == m.end()) m.insert({diff, 1});
                else m[diff]++;
            }
            diffn = 0;
            for (map<int, int>::iterator it = m.begin(); it != m.end(); it++)
                if (it->second > diffn) diff = it->first, diffn = it -> second;

            flag = false;
            for (int i = 1; i < N; i++) {
                if ((arr[i]-arr[i-1] != diff && arr[i+1] - arr[i] != diff) || arr[i]-arr[i-1] == 0) {
                    printf("%d\n", arr[i]); flag = true; break;
                }
            }
            if (!flag) {
                if (arr[1] - arr[0] != diff) printf("%d\n", arr[0]);
                else printf("%d\n", arr[N]);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2824
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  double r;
  cin >> r;

  cout << 2 * r * 3.141;
  return 0;
}


Measured memory_bytes: 3736
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N; cin >> N;
	vector<long long>A(10010, 0);
	for (long long i = 1; i <= 100; i++) {
		for (long long j = 1; j <= 100; j++) {
			for (long long k = 1; k <= 100; k++) {
				if (i * i + j * j + k * k + i * j + j * k + k * i <= N) A.at(i * i + j * j + k * k + i * j + j * k + k * i)++;
			}
		}
	}
	for (long long i = 1; i <= N; i++) {
		cout << A.at(i) << endl;
	}
}

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

int main() {
   int N,M;
   cin >> N >> M;

   vector<int> P(M),dist(0);
   for(int i = 0; i < M; i++) {
       cin >> P.at(i);
   }


   if(N >= M) cout << 0 << endl;
    else {
        sort(P.begin(),P.end());
        for(int i = 0; i < M - 1; i++) {
            int d = P.at(i + 1) - P.at(i);
            dist.push_back(d); 
        }
        int ans = 0;
        sort(dist.begin(),dist.end());
        for(int i = 0; i < M - N;i++) {
            ans += dist.at(i);
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 1276
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
input = sys.stdin.readline
from heapq import*
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j]>A[i][k]+A[k][j]:
                print(-1)
                exit()
res = 0
for i in range(N-1):
    for j in range(i+1, N):
        for k in range(N):
            if k==i or k == j:
                continue
            if A[i][j]==A[i][k]+A[k][j]:
                break
        else:
            res += A[i][j]
print(res)


Measured memory_bytes: 44124
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long long ll;
typedef double lf;
typedef long long ll;
// const int mod = 1000000007;
const int mod = 998244353;

// vector<string> Qs(max_n);

bool check(vector<pll> ps){
    ll h = 0;
    for(auto p:ps){
        ll b = h + p.first;
        if(b < 0) return false;
        h = h + p.second;
    }

    return true;
}

void Main(){
    ll N;
    string s;
    sll(N);
    vector<pll> ls, rs;
    ll total = 0;
    rep(i, N){
        cin >> s;
        ll h = 0, b = 0;
        for(auto c:s){
            if(c=='(') h++; else h--;
            b = min(b, h);
        }
        if(h>=0) ls.emplace_back(b, h);
        else rs.emplace_back(b-h, -h);
        total += h;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());

    if(check(ls) && check(rs) && total == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    

}

int main(){
    Main();

    return 0;

}

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

int main() {
    int n,sum=0;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    int m;
    cin>>m;
    for (int j=0;j<m;j++){
        int a,b;
        cin>>a>>b;
        cout<<sum-arr[a-1]+b<<endl;
    }

	return 0;
}


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

int main() {
	long n,m,i,j,k,ans,cur,res,mod=1000000007;
	string s;
	cin >> n >> s;
	ans=0;
	vector<long> r(n+1,0),g(n+1,0),b(n+1,0);
	for(i=0; i<n; i++){
		if(s[i]=='R'){
			r[i+1]=r[i]+1; g[i+1]=g[i]; b[i+1]=b[i];
		}else if(s[i]=='G'){
			r[i+1]=r[i]; g[i+1]=g[i]+1; b[i+1]=b[i];
		}else{
			r[i+1]=r[i]; g[i+1]=g[i]; b[i+1]=b[i]+1;
		}
	}
	
	
	ans=0;
	for(j=1; j<n-1; j++){
		cur=0;
		if(s[j]=='R'){
			cur+=g[j]*(b[n]-b[j]);
			cur+=(g[n]-g[j])*b[j];
			//cout << cur << endl;
			for(i=1; i<=min(j,n-j-1); i++){
				if(s[j-i]!=s[j+i] && s[j-i]!='R' && s[j+i]!='R'){
					cur--;
				}
			}
		}else if(s[j]=='G'){
			cur+=r[j]*(b[n]-b[j]);
			cur+=(r[n]-r[j])*b[j];
			//cout << cur << endl;
			for(i=1; i<=min(j,n-j-1); i++){
				if(s[j-i]!=s[j+i] && s[j-i]!='G' && s[j+i]!='G'){
					cur--;
				}
			}
		}else{
			cur+=g[j]*(r[n]-r[j]);
			cur+=(g[n]-g[j])*r[j];
			//cout << cur << endl;
			for(i=1; i<=min(j,n-j-1); i++){
				if(s[j-i]!=s[j+i] && s[j-i]!='B' && s[j+i]!='B'){
					cur--;
				}
			}
		}
		ans+=cur;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3680
#include <cstdio>

int a[110];
#define cabs(_x) ((_x) < 0 ? (-(_x)) : (_x))
int main()
{
	int n, sum = 0; scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", a + i), sum += a[i];
	int minn = 0x7fffffff, minpos = 0;
	for (int i = 0; i < n; ++i)
		minn > cabs(sum - n * a[i]) ? minn = cabs(sum - n * a[i]), minpos = i : 0;
	printf("%d\n", minpos);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int n,x;
	cin>>n>>x;
	if(x==1||x==2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	int a[n*2];
	for(int i=(2*n)/2-1,j=0;j<2*n-1;j++,i=(i+1)%(2*n-1)){
		a[i]=x;
		if(x++==2*n-1)x=1;
	}
	cout<<"Yes"<<endl;
	r(i,2*n-1)cout<<a[i]<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b,c,d,e,f;
	cin >>a>>b>>c>>d>>e>>f;


	double con = 0.0;
	int water = 0,sugar = 0;
	for(int w = 0; w <=30; w++){
		for(int x = 0; x <= 30; x++){
			for(int y = 0; y <= ceil((double)f/c); y++){
				for(int z = 0; z <= ceil((double)f/d); z++){
					int water_weight = a*w+b*x, sugar_weight = c*y+d*z;
					int total = 100*water_weight + sugar_weight;
					if(total <= f && sugar_weight <= water_weight*e){
						if(con < (double)sugar_weight/total){
							con = (double)sugar_weight/total;
							water = 100*water_weight;
							sugar = sugar_weight;
						}
					}
				}
			}
		}
	}
 	if(con == 0) water = 100*a;

	cout << water+sugar << " " << sugar << endl;

	return 0;
}

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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

modint<> nCr(int n,int r){
	modint<> ret = 1;
	for(int i = 0;i < r;i++) ret = ret * modint<>(n - i) / modint<>(i + 1);
	return ret;
}

modint<> dp[2010][2010],sum[2010][2010];

signed main(){
	int n,d,x;
	while(cin >> n >> d >> x,n){
		for(int i = 0;i <= min(n,d);i++){
			for(int j = 0;j <= n;j++) dp[i][j] = sum[i][j] = 0;
		}
		dp[0][0] = 1;
		for(int i = 1;i <= n;i++) sum[0][i] = 1;
		for(int i = 0;i < min(n,d);i++){
			for(int j = 0;j <= n;j++){
				dp[i + 1][j] = sum[i][j] - sum[i][max(0ll,j - x + 1)];
				sum[i + 1][j + 1] = sum[i + 1][j] + dp[i + 1][j];
			}
		}
		// for(int i = 0;i <= n;i++){
		// 	for(int j = 0;j <= n;j++) cout << dp[i][j] << " ";
		// 	cout << endl;
		// }
		modint<> ans = 0;
		for(int i = 1;i <= min(n,d);i++){
			ans += dp[i][n] * nCr(d,i);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 66200