akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;

long long a[MAXN];

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

int main() {
    
    int n, k;
    scanf("%d%d", &n, &k);// don't forget &
    
    for (int i = 1; i <= n; i++) {
        a[i] = a[i - 1] + i;
    }
    int ans = 0;
    for (int i = k; i <= n + 1; i++) {
        long long mi = a[i - 1];
        long long mx = a[n] - a[n - i];
        ans = add(ans, mx - mi + 1);
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int x;
    cin >> x;
    cout << 10-x/200 << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;


ll N;
string s;
ll cnt[100];
ll tmp_count[100];
int main(){
  cin >> N;
  rep(i,26){
    cnt[i] = 1001001001;
  }
  rep(i,N){
    cin >> s;
    rep(j,26){
      tmp_count[j] = 0;
    }
    rep(j,s.size()){
      tmp_count[s[j]-'a']++;
    }
    rep(j,26){
      cnt[j] = min(cnt[j],tmp_count[j]);
    }
  }
  rep(i,26){
    rep(j,cnt[i]){
      cout << char('a'+i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 892
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;
const ll int MD = 998244353 ;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	int a,b;
	cin>>a>>b;
	cout<<(a^b);	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int h,w,a,b,z=0;
    cin>>h>>w>>a>>b;
    rep(i,h){
        if(i<b) z=1;
        else z=0;
        rep(j,w){
            if(j<a) cout<<(0+z)%2;
            else cout<<(1+z)%2;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,h,w; cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<vector>
#include<climits>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    vector<long long int> v(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    long long int arr[n];
    arr[0] = 0;
    for(long long int j=1;j<n;j++)
    {
        long long int min = LLONG_MAX;
        long long int t = k;
        long long int i = j-1;
        while(i>=0 && t)
        {
            if((abs(v[j]-v[i])+arr[i])<min)
            {
                min = (abs(v[j]-v[i])+arr[i]);
            }
            t--;
            i--;
        }
        arr[j] = min;
    }
    cout<<arr[n-1]<<endl;
}



Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			long intSum = 0;
			String strN = insBR.readLine();
			int n = Integer.parseInt(strN);
			long[] intA = new long[n];
			String[] strA = insBR.readLine().split(" ");
			for(int i = 0;i < n ;i++){
				try{
					intA[i] = Integer.parseInt(strA[i]);
				}catch(NumberFormatException e){
					e.printStackTrace();;
				}
			}
			for(int i = 0; i < intA.length; i++){
				intSum += intA[i];
			}
			for(int i = 0; i < intA.length - 1; i++){
				for(int j = intA.length -1;i < j; j--){
					if(intA[j] < intA[i]){
						long intAct = intA[i];
						intA[i] = intA[j];
						intA[j] = intAct;
					}
				}
			}
			System.out.println(intA[0] + " " + intA[intA.length-1] + " " + intSum);
		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}
}



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

int main(){
  string s;
  cin >> s;
  char t = s.at(0);
  char u;
  if (s.at(0) == s.at(1)){
    u = s.at(2);
  }
  else {
    u = s.at(1);
  }
  int tc = 0;
  int uc = 0;
  for (int i = 0; i < 4; i++){
    if (s.at(i) == u){
      uc++;
    }
    else if (s.at(i) == t) {
      tc++;
    }
  }
  if (tc == 2 && uc == 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
  int n, m;

  while (cin >> n){
    if (n == 0){
      break;
    }
    char bucket[256];
    for (int i = 0; i < 256; i++){
      bucket[i] = i;
    }
    for (int i = 0; i < n; i++){
      char c, d;
      cin >> c >> d;
      bucket[c] = d;
    }
    cin >> m;

    for (int i = 0; i < m; i++){
      char c;
      cin >> c;
      cout << bucket[c];
    }
    cout << endl;
  }
  return 0;
}

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

int main() { 
  int n;
  cin >> n;
  ll res = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) continue;
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    res += i;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int maxn=4e5+10;
const double inf=1e9;
typedef long long ll;
typedef pair<int,int>pr;
const ll mod=1e9+7;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a;
        a=a*a;
        b>>=1;
    }
    return ans;
}
int a[maxn];
int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  string s;
  cin>>n>>s;
  if(n>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}
/*
9 111 92
150 254 268 417 798 704 701 927 128
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 100;
const int INF = 0x3f3f3f3f;
ll a[N];
ll ma[N],mi[N],ret;
int n;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++)scanf("%d",&a[i]);
	
	priority_queue<int>q;
	ll sum = 0;
	
	for(int i=1;i<=2*n;i++) {
		q.push(-a[i]);
		sum += a[i];
		
		if(q.size()>n)sum += q.top(),q.pop();
		if(i>=n)ma[i] = sum;
	}
	
	while(!q.empty())q.pop();
	sum = 0;
	
	for(int i=3*n;i>n;i--) {
		q.push(a[i]);
		sum += a[i];
		
		if(q.size()>n)sum -= q.top(),q.pop();
		if(i<=2*n+1)mi[i] = sum;
	}
	ret = ma[n] - mi[n+1];
	for(int i=n+1;i<=2*n;i++) {
		ret = max(ret,ma[i] - mi[i+1]);
	}
	cout<<ret<<endl;
	return 0;
}

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

int main() {
  int A,B,i,count=0,N;
  cin>>A>>B;
  
  N=B-A+1;
  
  for(N=A;N-1<B;N++){
  	if(N%10==N/10000&&N%100/10==N%10000/1000){
      count++;
    }
  }
  cout<<count<<endl;
}

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

int n,max_weight;

int main() {
  scanf("%d%d", &n, &max_weight);
  double weight[n];
  double value[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%lf%lf", &weight[i], &value[i]);
  }
  double dp[n + 1][max_weight + 1];//上からn個目までの価値の最大値
  //初期化
  for (size_t i = 0; i <= max_weight; i++) {
    for (size_t j = 0; j <= n; j++) {
      dp[j][i] = 0;
    }
  }
  //DPなう
  for (size_t i = 0; i < n; i++) {
    for (size_t remain = 0; remain <= max_weight; remain++) {
      dp[i + 1][remain] = fmax(dp[i + 1][remain], dp[i][remain]);
      if(remain >= weight[i]){
        dp[i + 1][remain - (int)weight[i]] = fmax(dp[i][remain] + value[i], dp[i + 1][remain - (int)weight[i]]);
      }
    }
  }
  //最大値の算出
  double max_value;
  for (size_t i = 0; i <= max_weight; i++) {
    max_value = fmax(dp[n][i], max_value);
  }
  //出力
  printf("%lld", (long long int)max_value);
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[3000][3000];
ll b[5000]; //RAM-RAM!!
ll min(ll a1,ll b1,ll c1)
{
    
    return min(b1,min(a1,c1)); //RAM-RAM!!
    
}
int main() 
{
ll n,x,y;
cin>>n>>x>>y;
    ll i=1;
    while(i<=n)
    {
        ll j=i+1;
        while(j<=n)
        {
            ll way1=abs(j-i);
            
            ll way2=abs(i-x)+1+abs(j-y);
            
            ll way3=abs(i-y)+1+abs(j-x);
            
            
            a[i][j]=min(way1,way2,way3);
            b[a[i][j]]++; 
            
                       
            
            
            j++;
        }
        
        i++;
    }
    

    i=1;
    while(i<=n-1)
    {
        cout<<b[i]<<"\n"; //RAM-RAM!!
        i++;
    }
    
    
    return 0;
}

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

typedef std::pair<int, int> pii;

namespace IO {
	const int lim = 1 << 20 | 50;

	char buf[lim + 5], *S, *T;

	inline char gc() {
		if (S == T) {
			T = (S = buf) + fread(buf, 1, lim, stdin);
			if (S == T) return EOF;
		}
		return *S++;
	}

	inline int read() {
		int x; bool f; char c;
		for (f = 0; (c = gc()) < '0' || c > '9'; f = c == '-');
		for (x = c ^ '0'; (c = gc()) >= '0' && c <= '9'; x = x * 10 + c - '0');
		return f ? -x : x;
	}
}

const int MN = 1e5 + 5, MV = 5e5 + 5;

std::map<pii, int> mp;

int n, m, dist[MV], vn;

bool vis[MV];

std::deque<int> q;

std::vector<int> G[MV];

void solve() {
	memset(dist, 0x3f, sizeof dist);
	dist[1] = 0; q.push_back(1);
	for (; !q.empty(); ) {
		int u = q.front(); q.pop_front();
		if (vis[u]) continue; vis[u] = 1;
		for (unsigned int i = 0; i < G[u].size(); ++i) {
			int v = G[u][i];
			if (vis[v] || (dist[u] + (u <= n)) >= dist[v]) continue;
			dist[v] = dist[u] + (u <= n);
			if (u <= n) q.push_back(v);
			else q.push_front(v);
		}
	}
}

int main() {
	vn = n = IO::read();

	for (m = IO::read(); m; --m) {
		int x = IO::read(), y = IO::read(), c = IO::read();
		if (mp.find(pii(x, c)) == mp.end()) {
			mp[pii(x, c)] = ++vn;
			G[vn].push_back(x);
			G[x].push_back(vn);
		}
		if (mp.find(pii(y, c)) == mp.end()) {
			mp[pii(y, c)] = ++vn;
			G[vn].push_back(y);
			G[y].push_back(vn);
		}
		x = mp[pii(x, c)];
		y = mp[pii(y, c)];
		G[x].push_back(y);
		G[y].push_back(x);
	}

	solve();

	printf("%d\n", dist[n] == 0x3f3f3f3f ? -1 : dist[n]);

	return 0;
}
/*
8 11
1 3 1
1 4 2
2 3 1
2 5 1
3 4 3
3 6 3
3 7 3
4 8 4
5 6 1
6 7 5
7 8 5
*/

Measured memory_bytes: 57216
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T>& v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2>& p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2>& p)
{
	istream >> p.first >> p.second;
	return istream;
}

template<typename T>
istream& operator>>(istream &istream, vector<T>& a)
{
	for (auto &it : a)
		istream >> it;
	return istream;
}

// Utility functions.

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}

//////////////////// START CODE HERE ///////////////////////////


void solve(int tc)
{
	int x;
	cin >> x;
	if (x == 0)
		cout << 1;
	else
		cout << 0;
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


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

using namespace std;

class Calc{
public:
  string s;
  string::iterator it;
  
  Calc(string s) : s(s) {
    it = s.begin();
  }
  
  int fact(){
    int res = 0;
    if(*it == '('){
      ++it;
      res = exp();
      ++it;
    }else{
      while(isdigit(*it)){
        res *= 10;
        res += (*it-'0');
        ++it;
      }
    }
    return res;
  }
  
  int term(){
    int res = fact();
    while(*it == '*' || *it == '/'){
      if(*it == '*'){
        ++it;
        res *= fact();
      }else{
        ++it;
        res /= fact();
      }
    }
    return res;
  }

  int exp(){
    int res = term();
    while(*it == '+' || *it == '-'){
      if(*it == '+'){
        ++it;
        res += term();
      }else{
        ++it;
        res -= term();
      }
    }
    return res;
  }
};

int main(){
  int N;
  cin >> N;
  while(N--){
    string s;
    cin >> s; s.resize(s.size()-1);
    Calc calc(s);
    cout << calc.exp() << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; // 998'244'353LL
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll A;
double B;

signed main(){
    cin >> A >> B;
    cout << A * (ll)floor(B * 100 + 1e-2) / 100 << endl;
}


Measured memory_bytes: 3812
#include <iostream>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  int *like = new int[M+1];
  
  for (int i = 0; i <= M; i++) like[i] = 0;
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      like[A]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= M; i++) {
    if (like[i]==N) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define forab(i,a,b) for(ll i = a; i < b; i++)
#define forn(n) for(ll i = 0; i < n; i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define endl "\n"

typedef long long ll;
typedef vector<int> vi;
typedef pair<ll, ll> pi;

template<typename T>
void print(T nums) {
	for(auto& num: nums) {
		cout << num << " ";
	}
	cout << "\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL_PROJECT
	(void) freopen("input.txt", "r", stdin);
#endif
	double d, t, s;
	cin >> d >> t >> s;
	double T = d/s;
	if(T <= t) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}

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

int main()
{
  int r, c;
  cin >> r >> c;
  int data[r][c];
  int rsum;
  for(int i = 0; i < r; i++)
  {
    rsum = 0;
    for(int j = 0; j < c; j++)
    {
      int pool;
      cin >> pool;
      rsum += pool;
      data[i][j] = pool;
      cout << data[i][j] << " ";
    }
    cout << rsum << endl;
  }
  int csum;
  int total = 0;
    for(int j = 0; j < c; j++)
    {
      csum = 0;
      for(int i = 0; i < r; i++)
      {
        csum += data[i][j];
        total += data[i][j];
      }
      cout << csum << " ";
    }
  cout << total << endl;
}


Measured memory_bytes: 3120
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoderBeginnerContest179
{
    class Program
    {
        static void Main(string[] args)
        {
            // 課題B - Go to Jail(2020/9/19)

            int cnt = int.Parse(Console.ReadLine());
            string[] result;

            //List<string[]> iptList = new List<string[]>();
            int result1, result2;
            int matchCnt = 0;



            //var valueDict = new Dictionary<string, int>();

            for (int i = 0; i < cnt; i++)
            {
                //iptList.Add(Console.ReadLine().Split(' '));
                result = Console.ReadLine().Split(' ');

                result1 = int.Parse(result[0]);
                result2 = int.Parse(result[1]);

                if (result1 == result2) matchCnt++;
                else matchCnt = 0;

                if(matchCnt == 3)
                {
                    Console.Write("Yes");
                    return;
                }


            }

            Console.Write("No");


            //if(getStr.Equals("s")) Console.Write(str + "es");
            //else Console.Write(str + "s");

        }
    }
}


Measured memory_bytes: 27476
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll v=1000;
		REP(i, N-1) {
			if(A[i]<A[i+1]) {
				ll s = v/A[i];
				v = s*A[i+1]+(v-s*A[i]);
			}
//			DD(v);
		}
		cout<<v<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var S = sc.ReadStr();
        var K = sc.ReadLong();
        var count1 = S.TakeWhile(c => c == '1').Count();
        var ans = '1';
        var x = S.Skip(count1).FirstOrDefault();
        if (x != default(char))
        {
            ans = x;
        }
        if (K <= count1)
        {
            ans = '1';
        }
        Console.WriteLine(ans);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    scanf("%d %d\n",&n,&m);
    char a[100][100],w;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%c",&a[i][j]);
            // cout<<a[i][j];
        }
        scanf("\n");
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int ans=0;
            if(a[i+1][j]=='#')ans++;
            if(a[i-1][j]=='#')ans++;
            if(a[i-1][j-1]=='#')ans++;
            if(a[i-1][j+1]=='#')ans++;
            if(a[i+1][j-1]=='#')ans++;
            if(a[i+1][j+1]=='#')ans++;
            if(a[i][j-1]=='#')ans++;
            if(a[i][j+1]=='#')ans++;
            if(a[i][j]=='#'){
                cout<<'#';
            }
            else{
                cout<<ans;
            }
        }
        cout<<endl;
    }
	return 0;
}

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

using namespace std;

int main(void) {
    int i, j, N, K, len, zero, m;
    string s;
    cin >> N >> K >> s;
    vector<int> d;
    len = s.length();
    d.push_back(1);
    for (i=0;i<len-1;i++) {
        if (s[i] != s[i+1]) d.push_back(i+2);
    }
    zero = d.size();
    for (j=zero;j<=zero+2*K+1;j++) d.push_back(len+1);
    m = 1;
    for (j=0;j<zero;j++) {
        // for (j=i+1;j<zero && j-i <= K+1;j++) {
        //     m = max(m,d[j]-d[i]);
        // }
        if (s[d[j]-1] == '1') {
            m = max(m,d[j+2*K+1]-d[j]);
        } else {
            m = max(m,d[j+2*K]-d[j]);
        }
    }
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    bool turn = true;
    while (a > 0 && c > 0) {
        if (turn) c -= b;
        else a -= d;
        turn = !turn;
    }

    if (c <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

void
solver(int n)
{
    int i, j;

    if (n>81) {
        printf("No\n");
        return;
    }
    for(i=9; i>0; i--) {
        if (n%i==0) {
            j = n / i;
            if (j<10) {
                printf("Yes\n");
                return;
            }
        }
    }
    printf("No\n");
}

int
main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    solver(n);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
int main() {
  int n, odd, even;
  cin >> n;
  vi ocnt(100001);
  vi ecnt(100001);
  rep(i,n/2){
    cin >> odd;
    ocnt.at(odd) ++;
    cin >> even;
    ecnt.at(even) ++;
  }
  
  odd=0, even=0;
  int odd2=0, even2=0, oddc=0, evenc=0;
 
  rep(i,100001){
    if (i == 0 ) continue;
    if(odd2 <= ocnt.at(i) && odd >= ocnt.at(i)){
      odd2 = ocnt.at(i);
    }
    else if(odd < ocnt.at(i)){
      odd2 = odd;
      odd = ocnt.at(i);
      oddc = i;
    }
    if(even2 <= ecnt.at(i) && even >= ecnt.at(i)){
      even2 = ecnt.at(i);
    }
    else if(even < ecnt.at(i)){
      even2 = even;
      even = ecnt.at(i);
      evenc = i;
    }
  }
  
  int ans = 0 ;
  if (oddc==evenc) ans = max(odd+even2,odd2+even);
  else ans = odd+even;
      
  cout << n-ans << endl;  
  return 0;
}

Measured memory_bytes: 1152
N = int(input())
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

lst = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    w = w%2
    lst[u].append([v, w])
    lst[v].append([u, w])
# print (lst)
ans = [-1] * (N + 1)
def dfs(x): #xについてつながりを見る
    # if ans[x] != -1: #既に見ているとき
    #     return ans[x]
    for i in lst[x]: #xからのつながりを見る
        # print (i)
        if ans[i[0]] == -1: #移動先をまだ見ていないとき
            if i[1] == 0: #距離が偶数のとき
                ans[i[0]] = ans[x] #移動先と移動前は同じ
                dfs(i[0])
            else: #距離が奇数のとき
                ans[i[0]] = (ans[x] + 1) % 2
                dfs(i[0])
    return 

ans[1] = 0
dfs(1)
for i in ans[1:]:
    print (i)

Measured memory_bytes: 82292
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,sum=0,res=0;
string S,T;
int main(){
    cout << fixed << setprecision(18);
    cin>>S>>T;
    IFYes(T.substr(0,S.size())==S);
}


Measured memory_bytes: 3620
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


n = int(input())

z = []

f = sorted(factorization(n), key=lambda x: x[1], reverse=True)
# print(f)
for i in range(len(f)):
    if f[i][1] < 0:
        f[i][1] = -1 * f[i][1]

for i in range(len(f)):
    for j in range(1, f[i][1] + 1):
        if f[i][0] == 1:
            continue
        f[i][1] -= j
        if f[i][1] >= 0:
            z.append(f[i][0] ** j)
# print(z)
print(len(z))

Measured memory_bytes: 9452
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#define LOCAL 0
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
    string s;
    cin>>s;
    int n=s.size(),zero=0;
    rep(i,n){
      if(s[i]=='0')++zero;
    }
    int one=n-zero;
    cout<<min(zero,one)*2<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
//#include<>

int main(void){
    int A, B, T;

    scanf("%d %d %d", &A, &B, &T);
    double time=1;
    double i=2;
    int bisnum=0;
    /*if(A<T){
        while(time<T+0.5){
            time = A*i;
            bisnum = bisnum + B;
            i++;
        }
        printf("%d\n", bisnum);
    }else{
       printf("0\n");
    } */

    while(time<T+0.5){
        if((int)time%A == 0){
            bisnum = bisnum + B;

        }
        time++;
    }
    printf("%d\n", bisnum);
    return 0;
}

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

int main(){
	ll r,d,x0; cin >> r >> d >> x0;
	vl x(11); x[0] = x0; 
	rep(i,10){
		x[i+1] = r*x[i] - d;
	}
	rep(i,10)cout << x[i+1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long
const int L=520233;
char s[L];
int n,ans,flag,a[L],b[L],p[L],totp;
vector<int> S[L],T[L];
pair<int,int> o[L];int toto;
int C[L];
void add(int o,int w){for(;o<=n;o+=(o&(-o)))C[o]+=w;}
int query(int o){int res=0;for(;o;o-=(o&(-o)))res+=C[o];return res;}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i)S[a[i]=s[i]-'a'].push_back(i);
	for(int i=0;i<26;++i)flag+=(S[i].size()&1);
	if(flag>1)return puts("-1"),0;
	for(int i=0;i<26;++i)
	{
		for(int j=(S[i].size()>>1)-1;~j;--j)p[++totp]=S[i][j];
		if(S[i].size()&1)b[(n>>1)+1]=i;
	}
	sort(p+1,p+totp+1);
	for(int i=1;i<=totp;++i)b[i]=b[n-i+1]=a[p[i]];
	for(int i=1;i<=n;++i)T[b[i]].push_back(i);
	ll ans=0;
	for(int i=0;i<26;++i)for(int j=0;j<(int)S[i].size();++j)o[++toto]=make_pair(T[i][j],S[i][j]);
	for(int i=1;i<=n;++i)add(i,1);
	sort(o+1,o+toto+1);
	for(int i=toto;i;--i)
	{
		ans+=o[i].first-query(o[i].second);
		add(o[i].second,-1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 38388
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
//#include<unordered_map>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-12;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

























const int maxn = 1e5 + 5;
LL f[maxn];


int main() {
#ifdef LOCAL
	fileopen();
#endif
	int n, C;
	scanf("%d%d", &n, &C);
	memset(f, 63, sizeof(f));
	f[0] = 0;
	for (int i = 1; i <= n; i++) {
		int w, v;
		scanf("%d%d", &w, &v);
		for (int i = maxn - 3; i >= v; i--)if (f[i - v] + w <= C) {
			f[i] = min(f[i], f[i - v] + w);
		}
	}
	LL ans = 0;
	for (int i = 0; i <= maxn - 3; i++)if (f[i] <= C)ans = max(ans, (LL)i);
	printf("%lld\n", ans);

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>

int main(){
	int n, b, c, t, f;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		b = c = f = 0;
		for(int j = 0; j < 10; j++){
			scanf("%d", &t);
			if(b < t){
				b = t;
			}else{
				if(c < t){
					c = t;
					if(b < c){
						t = b;
						b = c;
						c = t;
					}
				}else{
					f = 1;
				}
			}
		}

		if(f){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      long sum = 0;
      int num = Integer.parseInt(input.nextLine());    	

      for (int i = 1; i <= num; i++) {
          if (i % 3 != 0 && i % 5 != 0) {
          	sum += i;
          }
      }
      
      System.out.println(sum);
    }
}

Measured memory_bytes: 35572
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag, N, x, y, M, K,H,W;
	sum = 0;
	flag = 0;
	cin >> H >> W;
	cin >> N;
	vector<ll>a(N);
	REP(i, 0, N) {
		cin >> a[i];
	}
	vector<int>A;
	int ans[101][101];
	REP(i, 0, N) {
		REP(j, 0, a[i]) {
			A.push_back(i + 1);
		}
	}
	REP(i, 0, H*W) {
		if ((i / W) % 2 == 0) {
			ans[i / W][i%W] = A[i];
		}
		else {
			ans[i / W][W-1-i%W] = A[i];
		}
	}
	REP(i, 0, H) {
		REP(j, 0, W) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	

	return 0;
}













Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    string s;
    cin >> n >> s;
    vector<int> cnt(3, 0);
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') ++cnt[0];
        if(s[i] == 'G') ++cnt[1];
        if(s[i] == 'B') ++cnt[2];
    }
    ll ans = (ll)n * (n - 1) * (n - 2) / 6;
    for(int i = 0; i < 3; ++i){
        ans -= (ll)cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6;
        int a = (i + 1) % 3, b = (i + 2) % 3;
        ans -= (ll)cnt[a] * (cnt[a] - 1) / 2 * cnt[b];
        ans -= (ll)cnt[b] * (cnt[b] - 1) / 2 * cnt[a];
    }
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(s[i] == s[j])    continue;
            int len = j - i;
            if(j + len >= n)    break;
            int k = j + len;
            if(s[k] != s[i] && s[k] != s[j])    --ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //エラーの出ないエラーを起こした時にデバッグできる
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(){
  int  x, y;
  cin >> x >> y;
  
  for (int i = 0; i < x+1; i++){
    for (int j = 0; j < x+1; j++){
      if((i+j == x) && (2*i + 4*j == y)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
    
}

Measured memory_bytes: 3668
// ABC059B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	if (A.size() < B.size()) {
		cout << "LESS" << endl;
		return 0;
	}

	for (int i = 0; i < A.size(); i++) {
		if (A[i] > B[i]) {
			cout << "GREATER" << endl;
			return 0;
		} else if (A[i] < B[i]) {
			cout << "LESS" << endl;
			return 0;
		}
	}

	cout << "EQUAL" << endl;

	return 0;
}


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

int main(){
   
    string str1,str2;
    int size;
    cin >> str1 >> str2;
    size = str1.size();

    if(str2.size()-size != 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<size; i++){
        if(str1.at(i)!=str2.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int m[101][101];

int main(){
  int i,j,k,l,p[101],n,a;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=10000000;
      for(k=i;k<=j-1;k++){
	a=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(a<m[i][j]){
	  m[i][j]=a;
	}
      }
    }
  }
  printf("%d\n",m[1][n]);
}
    
  



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] a=new long[n];
		for(int i=0;i<n;i++)a[i]=sc.nextLong();
		long sum=0;
		long cost1=0;
		long cost2=0;
		//+-+-の順番のコスト
		for(int i=0;i<n;i++){
			if(i%2==0 && sum+a[i]<=0){
				cost1+=-(sum+a[i]-1);
				sum=1;
			}else if(i%2!=0 && sum+a[i]>=0){
				cost1+=sum+a[i]+1;
				sum=-1;
			}else{
				sum+=a[i];
			}
		}
		sum=0;
		//-+-+の順番のコスト
		for(int i=0;i<n;i++){
			if(i%2==0 && sum+a[i]>=0){
				cost2+=sum+a[i]+1;
				sum=-1;
			}else if(i%2!=0 && sum+a[i]<=0){
				cost2+=-(sum+a[i]-1);
				sum=1;
			}else{
				sum+=a[i];
			}
		}
		System.out.println(Math.min(cost1, cost2));
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	string s="";
	cin >> n;
	if(n==0) s="0";
	while(n!=0){
		if(n%2!=0){
			s="1"+s;
			n--;
		}
		else s="0"+s;
		n/=-2;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol n, d, x, y, ans = 0;
  cin >> n >> d;
  rep(i, n){
    cin >> x >> y;
    if(x * x + y * y <= d * d){
      ans ++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636