akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
const ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
const ll INF = 1e+18;
const ld EPS = 1e-12L;
const ld PI = acos(-1.L);
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n, a, b;
  cin >> n >> a >> b;
  if(a>b) swap(a, b);
  ll s = abs(a-b);
  if(s&1){
    print(min((a+b-1)/2, (n-a+n-b+1)/2));
  }else{
    print(s/2);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long infty = 1e18;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  vector<vector<pair<int, int>>> grha(n);
  vector<vector<pair<int, int>>> grhb(n);
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    grha[u].push_back({a, v});
    grha[v].push_back({a, u});
    grhb[u].push_back({b, v});
    grhb[v].push_back({b, u});
  }
  vector<long long> dsta(n);
  for (int i = 0; i < n; i++) {
    if (i == s) {
      dsta[i] = 0;
    } else {
      dsta[i] = infty;
    }
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> prqa;
  prqa.push({0, s});
  while (!prqa.empty()) {
    pair<long long, int> crr = prqa.top();
    prqa.pop();
    long long crrd = crr.first;
    int crrv = crr.second;
    if (crrd > dsta[crrv]) {
      continue;
    }
    for(auto nxt : grha[crrv]) {
      long long nxtd = crrd + nxt.first;
      int nxtv = nxt.second;
      if (nxtd >= dsta[nxtv]) {
        continue;
      }
      prqa.push({nxtd, nxtv});
      dsta[nxtv] = nxtd;
    }
  }
  vector<long long> dstb(n);
  for (int i = 0; i < n; i++) {
    if (i == t) {
      dstb[i] = 0;
    } else {
      dstb[i] = infty;
    }
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> prqb;
  prqb.push({0, t});
  while (!prqb.empty()) {
    pair<long long, int> crr = prqb.top();
    prqb.pop();
    long long crrd = crr.first;
    int crrv = crr.second;
    if (crrd > dstb[crrv]) {
      continue;
    }
    for(auto nxt : grhb[crrv]) {
      long long nxtd = crrd + nxt.first;
      int nxtv = nxt.second;
      if (nxtd >= dstb[nxtv]) {
        continue;
      }
      prqb.push({nxtd, nxtv});
      dstb[nxtv] = nxtd;
    }
  }
  vector<long long> ret(n);
  long long minv = 1e18;
  for(int i = n - 1; i >= 0; i--) {
    minv = min(minv, dsta[i] + dstb[i]);
    ret[i] = (long long)1e15 - minv;
  }
  for (int i = 0; i < n; i++) {
    cout << ret[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 17396
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int K, X;
    cin >> K >> X;
    cout << ((X <= K*500) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	char n[10];
	void solve(){
		scanf("%s",n);
		for(int i=0;i<(int)strlen(n);++i){
			if(n[i]=='7'){
				printf("Yes");
				return;
			}
		}
		printf("No");
		return;
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  string s;
  cin >> n;
  cin >> s;
  vector<int> left(n,0);
  vector<int> right(n,0);
  FOR(i,1,n){
	if(s[i-1]=='W'){
      left[i] = left[i-1] + 1;
    }else{
      left[i] = left[i-1];
    }
  }
  FORD(i,n-2,0){
    if(s[i+1]=='E'){
      right[i] = right[i+1] + 1;
    }else{
      right[i] = right[i+1];
    }
  }
  int res = n;
  REP(i,n){
    chmin(res,left[i]+right[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
const double PI = acos(-1.0);
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main () {
     int n ;
     cin >> n;
     vector<int>a(n);
     rep(i,n)cin >>a[i];
     vector<int>b(n);
     rep(i,n) b[i] =abs(a[i]);
     sort(b.begin(),b.end());
     int cnt=0;
     rep(i,n){
          if(a[i]<0) cnt++;
     }
     ll ans = 0;
     rep(i,n) ans+=b[i];
     if(cnt%2==0) cout << ans <<endl;
     else cout << ans - 2*b[0] <<endl;
}

Measured memory_bytes: 3984
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);

void solve() {
    int n;cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for (int i = 1; i <= test; i++) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

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

int binarySearch(std::vector<int> s, int x) {
  int n = (int)s.size(), l = 0, r = n, m;
  while (l < r) {
    m = (l + r) / 2;
    if (s[m] == x)
      return m;
    else if (x < s[m])
      r = m;
    else
      l = m + 1;
  }
  return -1;
}

std::vector<int> *read() {
  int n;
  std::cin >> n;
  std::vector<int> *s = new std::vector<int>(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> s->at(i);
  }
  return s;
}

int main() {
  std::vector<int> s = *read(), t = *read();
  int count = 0;
  for (int i = 0; i < (int)t.size(); i++) {
    if (binarySearch(s, t[i]) >= 0) {
      count++;
    }
  }
  std::cout << count << std::endl;
}



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


int main() {
    int H, A;
    cin >> H >> A;
    int ans = 0;
    while (H > 0) {
        H -= A;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 1e16;
    rep(i, 0, 2){
        int now = 1;
        if(i == 1) now = -1;
        int sum = 0;
        int cnt = 0;
        rep(j, 0, n){
            sum += a[j];
            if(now == -1){
                if(!(sum < 0)){
                    cnt += sum + 1;
                    sum = -1;
                }
            }else{
                if(!(sum > 0)){
                    cnt += -sum + 1;
                    sum = 1;
                }
            }
            now *= -1;
        }
        ans = min(ans, cnt);
    }
    o(ans);
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] list = new int [5];
//		int[] list = {29,20,7,35,120};
		//総和
		int sum = 0;
		//余剰時間
		int surplus = 0;
		//最低ロス時間
		int min = 0;


		for(int i = 0 ; i < 5 ; i++) {
			// 余剰時間を初期化
			surplus = 0;

			//Scannerで取ってきたものをlistに挿入
			list[i] = Integer.parseInt(sc.next());

			// listの総和を表す
			sum += list[i];

			// 下一桁を求め、差分を取って余剰時間を求める。
			if(list[i] / 100 != 0  && list[i] >= 100) {
				list[i] = list[i] % 100;

			}
			if(list[i] / 10 != 0 && list[i] >= 10) {
				list[i] = list[i] % 10;

			}
			if(list[i] != 0) {
				surplus = 10 -list[i];
//				System.out.println("C: " + surplus);
			}
			//余剰時間を総和に追加
			sum += surplus;
//			System.out.println("SUM: " + sum);


//			一番時短効果のある注文を特定する
			if(i == 0 && list[i] != 0) {
				min = list[i];
			}else if(list[i] < min && list[i] != 0) {
				min = list[i];
			}

		}
//		System.out.println("総和+余剰時間: " + sum);
// 時短ぶん引く
			if(min != 0) {
				sum = sum -(10 - min);
			}

		System.out.println(sum);

	}



}


Measured memory_bytes: 21844
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int n, x;
vector<int> a;

int main() {
	cin >> n >> x;
	if (n == 1) {
		cout << "Yes" << endl << 1 << endl;
		return 0;
	}
	if (n == 2 && x == 2) {
		cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
		return 0;
	}
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	a.resize(2 * n - 1);
	for (int i = 0; i < 2 * n - 1; i++) {
		a[i] = -1;
	}
	if (x < 2 * n - 2) {
		a[n - 2] = 2 * n - 1;
		a[n - 1] = 1;
		a[n] = x;
		a[n + 1] = x + 1;
		int cnt = 2;
		for (int i = 0; i < 2 * n - 1; i++) {
			if (cnt == x) {
				cnt++;
			}
			if (cnt == x + 1) {
				cnt++;
			}
			if (a[i] == -1) {
				a[i] = cnt;
				cnt++;
			}
		}
	}
	else {
		a[n - 2] = 1;
		a[n - 1] = 2 * n - 1;
		a[n] = x;
		a[n + 1] = x - 1;
		int cnt = 2;
		for (int i = 0; i < 2 * n - 1; i++) {
			if (cnt == x - 1) {
				cnt++;
			}
			if (cnt == x) {
				cnt++;
			}
			if (a[i] == -1) {
				a[i] = cnt;
				cnt++;
			}
		}
	}
	for (int i = 0; i < 2 * n - 1; i++) {
		cout << a[i] << endl;
	}
	//cin >> n;
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main(void)
{
    int n,i;
 
    cin >> n;
 
    vector<ll> T(n);
 
    for(i=0;i<n;i++)cin >> T[i];
    

    for(i=0;i<n;i++){
        if(T[i] == 0LL){
            cout << 0 << endl;
            return 0;
        }
    }
 
    ll a = 1LL, MAX = 1000000000000000000LL;
 
    for(i=0;i<n;i++){
        if(MAX / a < T[i]){
            a = -1LL;
            break;
        }
        a *= T[i];
    }
 
    cout << a << endl;

    return 0;
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll x;
    cin >> x;

    ll ans = x / 11;
    ans *= 2;
    x %= 11;
    if(x > 0){
        ++ ans;
        x -= 6;
        if(x > 0) ++ ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long rez = 0, n;
	cin>>n;
	string str;
	cin>>str;
	int leftR = 0, leftG = 0, leftB = 0;
	if(str[0] =='R')
		leftR++;
	else if(str[0] == 'G')
		leftG++;
	else
		leftB++;
		
	for(int i = 1; i < n ; i++){
		for(int j = i + 1;j < n; j++){
			if(str[i] == 'G'){
				if(str[j] == 'R'){
					int diff = j - i;
					if(i < diff)
						rez+=leftB;
					else{
						if(str[i - diff] == 'B')
							rez+=leftB - 1;
						else
							rez += leftB;
					}
				}
				else if(str[j] == 'B'){
					int diff = j - i;
					if(i < diff)
						rez += leftR;
					else{
						if(str[i - diff] == 'R')
							rez+= leftR - 1;
						else
							rez += leftR;
					}
				}
				else
					continue;
			}
			else if(str[i] == 'R'){
				if(str[j]=='G'){
					int diff = j - i;
					if(i < diff)
						rez+=leftB;
					else{
						if(str[i - diff] == 'B')
							rez+= leftB - 1;
						else
							rez += leftB;
					}
				}
				else if(str[j]=='B'){
					int diff = j - i;
					if(i < diff)
						rez+=leftG;
					else{
						if(str[i - diff] == 'G')
							rez += leftG - 1;
						else
							rez += leftG;
					}	
				}
				else
					continue;
			}
			else{
				if(str[j]=='G'){
					int diff = j - i;
					if(i < diff)
						rez+=leftR;
					else
					{
						if(str[i - diff] == 'R')
							rez+=leftR - 1;
						else
							rez+= leftR;
					}
				}
				else if(str[j]=='R'){
					int diff = j - i;
					if(i < diff)
						rez+=leftG;
					else{
						if(str[i - diff] == 'G')
							rez+=leftG-1;
						else
							rez+=leftG;
					}
				}
				else
					continue;
			}
		}
		if(str[i] =='R')
			leftR++;
		else if(str[i] == 'G')
			leftG++;
		else
			leftB++;
		
	}
	cout<<rez<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for( int i=0; i<n; i++){
        cin >> a[i];
    }
    double sum;
    for( int i=0; i<n; i++){
        sum += 1.0/a[i];
    }
    cout << 1.0/sum << endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int l[100001], r[100001];
int dp[100001] = {};

int main(void) {
	int q;

	cin >> q;
	FOR(i, 1, q) {
		cin >> l[i] >> r[i];
	}

	for(int i=3;i<=100000;i+=2) {
		FOR(t, 2, i-1) {
			if (i%t == 0) {
				break;
			}
			if (((i + 1) / 2) % t == 0&&((i+1)/2)>t) {
				break;
			}
			if (t == i-1) {
				dp[i] = 1;
			}
		}
	}
	FOR(i, 1, 100000) {
		dp[i] += dp[i - 1];
	}
	FOR(i, 1, q) {
		cout << dp[r[i]] - dp[l[i] - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
import sys
import numpy as np
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n,m,x=map(int,readline().split())

lst=[]
cnt=0
ans=100000000
for _ in range(n):
	a=list(map(int,readline().split()))
	lst.append(a)
	
for i in range(1,2 ** n):
    bag = []
    #print("pattern {}: ".format(i), end="")
    for j in range(n):
      if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行    		
      	bag.append(lst[j])  # フラグが立っていたら bag に果物を詰め
    #print(bag)
    cab=np.array(bag)
    sum=np.sum(cab,axis=0)
    
    cnt=0
    for k in range(m):
    	#print(sum[k+1])
    	if sum[k+1]>=x:
    		cnt+=1
    	if cnt==m:
    		ans=min(ans,sum[0])
    		
if ans==100000000:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 27292
#include <iostream>
#include <map>
#include <set>
#include <string>


using namespace std;


int main()
{
	set<string> dictionary;
	
	
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		string cmd, str;
		
		cin >> cmd;
		cin >> str;
		if (cmd == "insert") 
			dictionary.insert(str);
		else if (cmd == "find")
		{
			if (dictionary.find(str) != dictionary.end())
				cout << "yes";
			else
				cout << "no";
			cout << endl;
		}	
	}
}


Measured memory_bytes: 32176
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(void) {

    int n;
    int q = 0, p = 0, e = 0,g = 0;
    string s;
    // 検索先の文字列
    string a = "A"; // 検索文字列 // AC
    string w = "W"; // WA
    string t = "T"; // TLE
    string r = "R"; // RE

    cin >> n;


    for (int i = 0; i < n; i++) {

        cin >> s;

        
        if (s.find_first_of("A") == 0) {
            
            q++;

        }

        if (s.find_first_of("W") == 0) {

            p++;

        }

        if (s.find_first_of("T") == 0) {

            e++;

        }

        
        if (s.find_first_of("R") == 0) {

            g++;

        }


    }


    cout << "AC x " << q << endl;
    cout << "WA x " << p << endl;
    cout << "TLE x " << e << endl;
    cout << "RE x " << g << endl;

    
    return 0;
}



Measured memory_bytes: 3196
#include <stdio.h>

int main(){
	char a[4];
	if(scanf("%s",a)==EOF){return 0;}
	for(int i=0; i<3; i++){
		if(a[i]=='7'){printf("Yes\n"); return 0;}
	}
	printf("No\n");
	return 0;
	
}

Measured memory_bytes: 1664
#include <stdio.h>
int a[100000], b[100000], par[100000], root_cnt[100000];
int root(int x){
    if(par[x] == x){return x;}
    return par[x] = root(par[x]);
}

int unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry){
        return 0;
    }
    par[rx] = ry;
    return 1;
}

int same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry){
        return 1;
    }
    return 0;
}

long long int ans[100000];
int main(void){
    long long int n, m;
    int i, j, k;
    scanf("%lld%lld", &n, &m);
    for(i = 0; i < m; i++){
        scanf("%d%d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
    }

    for(i = 0; i < n; i++){
        par[i] = i;
        root_cnt[i] = 1;
    }

    ans[m-1] = n*(n-1)/2;
    root_cnt[root(b[m-1])] += root_cnt[root(a[m-1])];
    root_cnt[root(a[m-1])] = 0;
    unite(a[m-1], b[m-1]);//bのrootにaが統合される
    if(m-2 >= 0){
        ans[m-2] = n*(n-1)/2 - 1;
    }
    for(i = m-2; i >= 0; i--){
        if(same(a[i], b[i])){
            ans[i-1] = ans[i];
        }else{
            ans[i-1] = ans[i] - root_cnt[root(b[i])] * root_cnt[root(a[i])];
            root_cnt[root(b[i])] += root_cnt[root(a[i])];
            root_cnt[root(a[i])] = 0;
            unite(a[i], b[i]);//bのrootにaが統合される
            
            
        }
    }

    for(i = 0; i < m; i++){
        printf("%lld\n",ans[i]);
    }
}

Measured memory_bytes: 4264
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int N;
    cin >> N;
    vector<i64> m(N + 1, 0), v(N);
    for(i64 &x : v) {
        cin >> x;
        m[x]++;
    }
    i64 S = 0;
    for (i64 x : m) {
        S += (x * (x - 1)) / 2;
    }
    for(int i = 0; i < N; i++) {
        i64 ans = S;
        ans -= m[v[i]] - 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
// author: Saman Mahdanian
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

using namespace std;
typedef pair <int, int> pii;

#ifdef LOCAL
	#define local if (true)
#else
	#define local if (false)
#endif

const int N = 1000;
int nx, ny, m, mxn;
set <int> g[N];
bool mark[N];

void cerr_vertex (int);
void cerr_graph ();

vector <int> getPath (int, int);
void reversePath (vector <int> &);

int main() {
	cin >> nx >> ny >> m;
	for (int i = 0; i < m; i++) {
		int xi, yi;
		cin >> xi >> yi;
		g[xi << 1].insert(yi << 1 | 1);
	}
	mxn = max(nx << 1, ny << 1 | 1) + 2;

	for (int i = 0; i < nx; i++)
		g[nx << 1].insert(i << 1);
	for (int i = 0; i < ny; i++)
		g[i << 1 | 1].insert(ny << 1 | 1);

	int ans = 0;
	vector <int> lastPath;
	do {
		lastPath = getPath(nx << 1, ny << 1 | 1);
		if (lastPath.empty() == false) {
			ans++;
			reversePath(lastPath);
		}
		
		local {
			cerr << "iteration#" << ans << ": ";
			for (int v: lastPath) 
				cerr_vertex(v);
			cerr << endl;
			cerr_graph();
		}
	} while (lastPath.empty() == false);
	cout << ans << endl;
}

int __destination;
vector <int> __path;
bool getPathDFS (int);
vector <int> getPath (int s, int t) {
	__path.clear();
	__destination = t;
	fill (mark, mark + mxn, false);
	getPathDFS(s);
	reverse (__path.begin(), __path.end());
	return __path;
}
bool getPathDFS (int v) {
	mark[v] = true;
	if (v == __destination) {
		__path.push_back(v);
		return true;
	}
	for (int u: g[v])
		if (!mark[u])
			if (getPathDFS(u)) {
				__path.push_back(v);
				return true;
			}
	return false;
}

void reversePath (vector <int> &path) {
	for (int i = 0; i < int(path.size()) - 1; i++) {
		int v = path[i];
		int u = path[i + 1];
		g[v].erase(u);
		g[u].insert(v);
	}
}

void cerr_vertex (int v) {
	cerr << "(" << v << "," << ((v & 1)? "Y":"X") << (v >> 1) << ") ";
}

void cerr_graph () {
	cerr << "Graph_G: " << endl;
	for (int i = 0; i < mxn; i++) {
		cerr << "   "; 
		cerr_vertex(i);
		cerr << ": ";
		for (int j: g[i])
			cerr_vertex(j);
		cerr << endl;
	}
	cerr << endl;
}

// SamMHD :: Mar6-2019 :: Another For the FIRST Time...


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

using namespace std;

int n, m, k;

int main() {
    cin >> n >> m >> k;
    if (n == k || m == k || (k % n == 0) || (k % m == 0)) {
        cout << "Yes";
        return 0;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            long long x = (i * j) + ((n - i) * (m - j));
            if (x == k) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}


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

int **A = new int*[2];
int N;

int dfs(int d, int sum, int h, int w) {
	if (d == N)
		return sum;
	else {
		int he = 0, wi = 0;
		if (h+1 < 2 && w < N) he = dfs(d+1, sum+A[h+1][w], h+1, w);
		if (h < 2 && w+1 < N) wi = dfs(d+1, sum+A[h][w+1], h, w+1);
		return max(he, wi);
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < 2; i++)
		A[i] = new int[N];
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < N; j++)
			cin >> A[i][j];
	int sum = A[0][0];
	sum += dfs(0, 0, 0, 0);
	cout << sum << endl;
	for (int i = 0; i < 2; i++)
		delete[] A[i];
	delete[] A;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ld, int> P;
ld INF = 100000000000.0;

int N;
ld Graph[1100][1100];

ld dijkstra() {
  ld res[1100];
  for (int i = 0; i < 1100; i++) {
    res[i] = INF;
  }
  priority_queue<P,vector<P>,greater<P>> Q;
  Q.push(make_pair((ld)0,0));
  while (!Q.empty()) {
    P p = Q.top();
    Q.pop();
    if (res[p.second] <= p.first) {
      continue;
    }
    res[p.second] = p.first;
    for (int i = 0; i < N+2; i++) {
      if (p.first + Graph[p.second][i] < res[i]) {
        
        Q.push(make_pair(p.first + Graph[p.second][i],i));
      }
    }
  }
  return res[N+1];
}

int main() {
  ld sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < 1100; i++) {
    for (int j = 0; j < 1100; j++) {
      Graph[i][j] = INF;
    }
  }
  cin >> N;
  vector<ld> x;
  vector<ld> y;
  vector<ld> r;
  x.push_back(sx);
  y.push_back(sy);
  r.push_back((ld)0);
  for (int i = 0; i < N; i++) {
    ld xx,yy,rr;
    cin >> xx >> yy >> rr;
    x.push_back(xx);
    y.push_back(yy);
    r.push_back(rr);
  }
  x.push_back(tx);
  y.push_back(ty);
  r.push_back((ld)0);
  for (int i = 0; i < N+2; i++) {
    for (int j = 0; j < N+2; j++) {
      if (i == j) {
        continue;
      }
      ld dis = sqrt( ((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j])) );
      if (dis - r[i] - r[j] <= (ld)0) {
        Graph[i][j] = 0;
      } else {
        Graph[i][j] = dis - r[i] - r[j];
      }
    }
  }
  ld ans = dijkstra();
  cout << setprecision(120) << ans << endl;
  return 0;
}

Measured memory_bytes: 38864
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#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 <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

vector<long long> a;
vector<vector<long long> > memo;

long long solve(int i, int j)
{
    if(j - i == 1)
        return 0;
    if(memo[i][j] != -1)
        return memo[i][j];

    long long ans = INF;
    for(int k=i+1; k<j; ++k)
        ans = min(ans, solve(i, k) + solve(k, j));
    ans += accumulate(a.begin() + i, a.begin() + j, 0LL);

    return memo[i][j] = ans;
}

int main()
{
    int n;
    cin >> n;
    a.resize(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    memo.assign(n, vector<long long>(n+1, -1));
    cout << solve(0, n) << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  int ans = v[0];
  rep(i, 1, n) { ans = __gcd(ans, v[i]); }

  cout << ans << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL A[100001];
LL B[100001];
map<int, int> C;

int main(){
    int N, M; cin >> N >> M;
    LL ans = 0;
    for (int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    B[0] = 0;
    for (int i = 1; i <= N; ++i)
        B[i] = B[i-1] + A[i];

    for (int i = 0; i <= N; ++i)
        C[B[i] % M]++;
    
    for (auto x : C){
        ans += (LL)x.second * (x.second - 1) / 2; 
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 4736
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h],
    }

    let mut dist = vec![vec![1000_000_000; h*w]; h*w];
    for i in 0..h*w {
        dist[i][i]=0;
    }

    for y in 0..h {
        for x in 0..w {
            if s[y][x] == '#' {
                continue;
            }
            for &(dx, dy) in [(0, 1), (0, -1), (1, 0), (-1, 0)].iter() {
                let cx = x as i64 + dx;
                let cy = y as i64 + dy;

                if !(cx >= 0 && cx < w as i64 && cy >= 0 && cy < h as i64) {
                    continue;
                }

                if s[cy as usize][cx as usize] == '.' {
                    let f = (cy * w as i64 + cx) as usize;
                    let t = y * w + x;
                    dist[f][t] = 1;
                    dist[t][f] = 1;
                }
            }
        }
    }

    for k in 0..h*w {
        for i in 0..h*w {
            for j in 0..h*w {
                dist[i][j] = std::cmp::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    let mut ans = 0;
    for i in 0..h*w {
        for j in 0..h*w {
            if dist[i][j] != 1000_000_000 {
                ans = std::cmp::max(ans, dist[i][j]);
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
def main():
    N, M = map(int, input().split())
    l = [[0, 0] for _ in range(N)]
    for i in range(N):
        l[i] = list(map(int, input().split()))

    l.sort()

    ans = 0
    for i, j in l:
        for _ in range(j):
            if M < 1:
                return ans
            else:
                M -= 1
                ans += i
    return ans


if __name__ == "__main__":
    ans = main()
    print(ans)

Measured memory_bytes: 27820
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int a[N];
 
signed main() {
    IOS;
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    int s = 0;
    for(int i = 1; i <= n-k; i++)   
        s += a[i];
    cout << s;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {

	int s;
	int h, m;
	scanf("%d", &s);
	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;
	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<pair<char, ll>> RLE(const string &S) {
    ll cnt = 0;
    vector<pair<char, ll>> res;
    for (ll i = 0; i < (ll) S.size(); i++) {
        cnt++;
        if (i == (ll) S.size() - 1) {
            res.emplace_back(S[i], cnt);
            break;
        }
        if (S[i] != S[i + 1]) {
            res.emplace_back(S[i], cnt);
            cnt = 0;
        }
    }
    return res;
}


void Main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = RLE(S).size();
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2500
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

static const int N = 16;


int main(int argc, char *argv[])
{
    char s[N], t[N];

    scanf("%s%s", s, t);
    if (strncmp(s, t, strlen(s)) == 0) {
        puts("Yes");
    }
    else {
        puts("No");
    }

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1708
// C.cpp
// Created on 2017-01-28 20:33

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <queue>
#include <vector>
#define f(i,st,ed) for(int i=st;i<=ed;i++)
#define fd(i,st,ed) for(int i=st;i>=ed;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
inline int read(){char ch=getchar();int ret=0,f=1;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();return ret*f;}

int main(){
	//freopen("C.in","r",stdin);
	//freopen("C.out","w",stdout);

	ll n;scanf("%lld",&n);
	printf("%lld\n",n/11ll*2ll+(n%11ll?((n%11ll)>6ll?2ll:1ll):0ll));
	return 0;
}


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

#define ll              long long
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             (int)(1e18)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,j,n)      for(int i=j;i<n;i++)
#define all(p)          p.begin(),p.end()
#define ub(a,b)         upper_bound(all(a),b)
#define lb(a,b)         lower_bound(all(a),b)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
}
const double pi = 3.1415926535897;
int32_t main()
{
	run();
	double x = 2, r;
	cin >> r;
	cout << ps(x * pi * r , 2) << endl;
	return 0;
}

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

int main(){

    vector<int> a[5];

    rep(i,3){
        int t,s;
        cin >> t >> s;
        a[t].push_back(s);
        a[s].push_back(t);
    }

    for(int i=1;i<5;i++){
        if(a[i].size()>2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;



    return 0;
}

Measured memory_bytes: 256
import bisect

def main():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in [0] * N]
    CD = [list(map(int, input().split())) for _ in [0] * N]

    AB.sort()
    CD.sort()
    ab = list(map(list, zip(*AB)))
    ans = 0
    for c, d in CD:
        x = bisect.bisect_left(ab[0], c)
        if x:
            y = [(j, i) for i, j in enumerate(ab[1][:x]) if j < d]
            if y:
                maxy = max(y)
                ab[1][maxy[1]] = float('inf')
                ans += 1
    print(ans)

main()


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

using namespace std;

int main()
{
	int n;
	string s;
	long long r, b, g;
	int i, j;
	long long k,ans;

	cin >> n >> s;

	r=b=g=0;
	for (i=0;i<n;++i)
	{
		if (s[i]=='R')	++r;
		if (s[i]=='B')	++b;
		if (s[i]=='G')	++g;
	}

	ans = r*b*g;
	for (i=0;i<n;++i)
	{
		for (j=i+1;j<n;++j)
		{
			k = 2*j-i;
			if (k<n)
			{
				if ((s[i]!=s[j])&&(s[j]!=s[k])&&(s[k]!=s[i]))
					--ans;
			}
		}
	}

	cout << ans << endl;

	return(0);
}


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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

long long arr[3001];
long long res[3001][3001];

void findRes(int a, int b) {
    if (res[a][b] != 0) return;
    if (a == b) {
        res[a][b] = arr[a];
        return;
    }
    findRes(a, b - 1);
    findRes(a + 1, b);
    res[a][b] = max(arr[b] - res[a][b - 1], arr[a] - res[a + 1][b]);
}

void solve() {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    findRes(1, n);
//    for (int i = 1; i <= n; i++) {
//        for (int j = 1; j <= n; j++) cout << res[i][j] << " ";
//        cout << endl;
//    }
    cout << res[1][n];
}

int main()
{
    //rwFile();
    solve();
}


Measured memory_bytes: 70144
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    vl a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    if(count(all(a),a[1]) == 2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
while True :
    n = int(input())
    if n == 0 :
        break
    
    S = 1
    for i in range(n) :
        S *= (i+1)
    
    ans = 0
    while True :
        if S % 10 != 0 :
            break
        else :
            S = S // 10
            ans += 1
    print(ans)


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

long long dp[105][100005];

int main(){
    int n,w; cin>>n>>w;
    vector<int> a(n),v(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>v[i];
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j+a[i]<=w) dp[i+1][j+a[i]]=max(dp[i+1][j+a[i]],dp[i][j]+v[i]);
        }
    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 79360
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;

        if(A>=B){
            ans += A;
            A -= 1;
        }
        else if(A<B){
            ans += B;
            B -= 1;
        }

        if(A>=B){
            ans += A;
            A -= 1;
        }
        else if(A<B){
            ans += B;
            B -= 1;
        }
        System.out.println(ans);        
    }
}

Measured memory_bytes: 21716
/*************************************************************************
    > File Name: a.cpp
# File Name: a.cpp
# Author : xiaobuxie
# QQ : 760427180
# Email:760427180@qq.com
# Created Time: 2019年09月01日 星期日 19时58分14秒
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<map>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define pq priority_queue<int,vector<int>,greater<int> >
ll gcd(ll a,ll b){
    if(a<b) return gcd(b,a);
    return b==0?a:gcd(b,a%b);
}
int main(){
    string s1,s2;
    cin>>s1>>s2;
    int ans=0;
    for(int i=0;i<3;++i) ans+=s1[i]==s2[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scanText() string {
	sc.Scan()
	return sc.Text()
}

type Point struct {
	x, y, d int
}

func main() {
	sc.Split(bufio.ScanWords)
	h, w := scanInt(), scanInt()
	maze := make([]string, h)
	for i := 0; i < h; i++ {
		maze[i] = scanText()
	}

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

	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if maze[y][x] == '#' {
				continue
			}

			dd := make([][]int, h)
			for i := 0; i < h; i++ {
				dd[i] = make([]int, w)
				for j := 0; j < w; j++ {
					dd[i][j] = math.MaxInt64
				}
			}

			queue := make([]Point, 0)
			queue = append(queue, Point{x: x, y: y, d: 0})
			for len(queue) > 0 {
				nowP := queue[0]
				queue = queue[1:]

				if max < nowP.d {
					max = nowP.d
				}
				if dd[nowP.y][nowP.x] < math.MaxInt64 {
					continue
				}

				dd[nowP.y][nowP.x] = nowP.d
				for i := 0; i < 4; i++ {
					nextX, nextY := nowP.x+dx[i], nowP.y+dy[i]
					if nextX < 0 || nextX >= w || nextY < 0 || nextY >= h {
						continue
					}
					if maze[nextY][nextX] == '#' || dd[nextY][nextX] < math.MaxInt64 {
						continue
					}

					queue = append(queue, Point{x: nextX, y: nextY, d: nowP.d + 1})

				}
			}
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 5504
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=100005;

vl fact(M);

void Init(){
	fact[0]=1;
	for(ll i=1;i<M;i++) fact[i]=fact[i-1]*i%mod;
}

int n,m;

int main(){
	cin>>n>>m;
	Init();
	ll res=fact[n]*fact[m]%mod;
	if(abs(n-m)==1) cout<<res<<endl;
	else if(n==m) cout<<(res*2)%mod<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int main()
{
    FASTIO
   /* 
   double start_time = clock();
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  #endif
    */
    int n,k;
    cin >> n >> k;
    vector<int> H(n+10, 0);
    for(int i = 0; i < n; i++) cin >> H[i];

      vector<int> ans(n+5, INF);
    ans[0] = 0;
    for(int i = 0; i < n; i++){
      for(int j = 1; j <= k && (i+j) < n; j++){
      ans[i+j] = min(ans[i+j], ans[i] + abs(H[i+j] - H[i]));
    }
  }
    cout << ans[n-1]<<endl;

     //double end_time = clock();
  //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
   
    return 0;
}

Measured memory_bytes: 1024