akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = 0;
        
        if(a>b){
            d = a;
            a = b;
            b = d;
        }
        if(b>c){
            d = b;
            b = c;
            c = d;
        }
        if(a>b){
            d = b;
            b = a;
            a = d;
        }
        
        System.out.println(a + " " + b + " " + c);
        
    }
}



Measured memory_bytes: 26352
def main():
    s = input()
    t = input()

    # sがtの長さにおいて一致している最大の文字数を特定
    max_counter = 0

    for i in range(len(s)-len(t)+1):
        counter = 0
        for j in range(len(t)):
            if s[i+j] == t[j]:
                counter += 1
        if counter > max_counter:
            max_counter = counter

    answer = len(t) - max_counter
    print(answer)


if __name__ == "__main__":
    main()


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

int main(){
  int x,t;
  cin >> x >> t;
  cout << max(0,x-t) << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];

    int cnt = 0;
    int ans = 0;
    int l = 0, r = 0;
    while (l < N) {
        while (r + 1 < N && H[r] >= H[r + 1]) {
            r++;
        }
        ans = max(ans, r - l);
        l++;
        if (l > r) r++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int i, N;
	scanf("%d", &N);
	
	long long L[87] = {2, 1};
	for (i = 2; i <= N; i++) L[i] = L[i-1] + L[i-2];
	printf("%lld\n", L[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
char mem[214514];
char t[214514];
char c[214514];
string s[214514];
int l[214514],r[214514];
double a[214514];
double sum[214514];
pair<int,int> b[214514];
signed main(){
	ic(n) ic(k)
	rep(0,i,n){
		cin>>a[i];
		a[i]=(a[i]+1)/2;
	}
	rep(0,i,k){
		sum[0]+=a[i];
	}	
	rep(1,i,n-k+1){
		sum[i]=sum[i-1]-a[i-1]+a[k+i-1];
	}
	double ss=maxi(sum,0,n-k+1);
	printf("%.12f\n",ss);
}	
	

Measured memory_bytes: 6912
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int a[100],n;
  int sm;
  while(cin>>n){
    for(i=0;i<n;i++)
      cin>>a[i];
    do{
      h=0;
      for(i=1;i<n;i++){
	if(a[i-1]>a[i]){
	  swap(a[i-1],a[i]);
	  h=1;
	}
      }
    }while(h);
    sm=0;
    for(i=0;i<n;i++)
      sm+=a[i]*(n-i);
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll v,w,t;
  ll a,b;cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  if(b<a){
    swap(a,b);
  }
  a += (v-w)*t;
  if(a >= b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3672
function main(input) {
    let [X, N, ...ps] = input.trim().split(/[\s\n]/).map(Number)
    
    let down = X
    let up = X

    let changed = false
    do {
        changed = false
        for(const p of ps) {
            if(down === p) {
                down--
                changed = true
            }

            if(up === p) {
                up++
                changed = true
            }
        }
    } while(changed)

    const d = Math.abs(down - X)
    const u = Math.abs(up - X)
    
    if(d === u || d < u) {
        console.log(down)
    } else {
        console.log(up)
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll K,S;
  cin>>K>>S;
  ll ans=0;
  for(ll i=0;i<=K;i++){
    for(ll j=0;j<=K;j++){
      if(S-i-j>=0 && S-i-j<=K){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

template <typename T> class BinaryIndexedTree { // 1-indexed
  int N;
  std::vector<T> bit;

public:
  BinaryIndexedTree(int n) : N(n), bit(n + 1, 0) {}

  void add(int index, T num) {
    for (int x = index; x <= N; x += x & -x)
      bit[x] += num;
  }

  T sum(int index) {
    int ret = 0;
    for (int x = index; x > 0; x -= x & -x)
      ret += bit[x];
    return ret;
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  auto aa = a;
  sort(aa.begin(), aa.end());
  int right = n, left = -1;
  while (right - left > 1) {
    int mid = (right + left) / 2;
    int med = aa[mid];
    auto b = a;
    for (auto &x : b) {
      if (x < med)
        x = -1;
      else
        x = 1;
    }
    for (int i = 1; i < n; ++i) {
      b[i] += b[i - 1];
    }
    BinaryIndexedTree<int> BIT(300001);
    ll num = 0;
    BIT.add(100001, 1);
    for (auto x : b) {
      num += BIT.sum(x + 100001);
      BIT.add(x + 100001, 1);
    }
    // cout << med << " " << num << endl;
    ll m = ((ll(1 + n) * n) / 2);
    if (num >= m / 2 + m % 2) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << aa[left] << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			
			int [][]A = new int [2][N];
			
			for(int i = 0;i<N;i++)A[0][i] = scan.nextInt();
			for(int i = 0;i<N;i++)A[1][i] = scan.nextInt();
			
			int max = 0;
			
			for(int i =0;i<N;i++) {//i番目の１で下にずれる
				int goukei = 0;
				goukei+=A[0][0];
				for(int j = 0;j<i;j++) {//iが0なら計算する必要ないi-1までやる
					goukei+=A[0][j+1];
				}
				goukei+=A[1][i];
				
				for(int j = i;j<N-1;j++) {//iがN-1なら必要ない、Nー1−1までやる。
					goukei+=A[1][j+1];
				}
				
				if(max<goukei)max= goukei;
				
			}
			
			
			System.out.println(max);
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
struct E
{
    int u,v;
    double w;
} e[50010005];
int a[10005];
double x[10005],y[10005];
int cmp(E x,E y)
{
    return x.w>y.w;
}
int findx(int x)
{
    if(a[x]==x) return x;
    return a[x]=findx(a[x]);
}
int main()
{
    int m,n,i;
    while (scanf("%d%d",&n,&m)!=-1)
    {
        for (i=1; i<=n; i++)
            a[i]=i;
        for (i=1; i<=n; i++)
            scanf("%lf%lf",&x[i],&y[i]);
        int u,v;
        double sum=0.0;
        for (i=0; i<m; i++)
        {
            scanf("%d%d",&u,&v);
            e[i].u=u;
            e[i].v=v;
            e[i].w=sqrt((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v]));
            sum+=e[i].w;
        }
        sort(e,e+m,cmp);
        double s=0;
        for (i=0; i<m; i++)
        {
            int x=findx(e[i].u);
            int y=findx(e[i].v);
            if (x!=y)
            {
                a[x]=y;
                s+=e[i].w;
            }
        }
        printf("%.3f\n",sum-s);
    }
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string c1, c2;
  cin >> c1;
  cin >> c2;

  string ans = "YES";
  REP(i, 3){
    if(c1[i] != c2[2-i])
      ans = "NO";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int kelipatan,batas1,batas2;
	scanf("%d %d %d", &kelipatan,&batas1,&batas2);
	int temp=batas2/kelipatan;
	if(temp*kelipatan>=batas1){
		printf("OK\n");
	}
	else printf("NG\n");
	return 0;
}

Measured memory_bytes: 1664
/// You just can't beat the person who never gives up
/// ICPC next year


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
void offset(vector<int>&a,int x) {
    for(int i = 0; i < sz(a);i++) {
        a[i] = x;
    }
}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};


// auto cmp = [](pair<int,int>a,pair<int,int>b) {if(a.first==b.first)return a.second>b.second;
//      else return a.first > b.first;
//  };
//  multiset<pair<int,int>,decltype(cmp)>fc(cmp);
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash> safe_map;
};

const int MAXN = 2e5+ 10;

#define int long long
bool cmps(vi p1,vi p2) {
    return p1.size() > p2.size();
}
int32_t main() {
    fio
    int k;
    cin >> k;
    int x = 7;
    int rem = x % k;
    for (int i = 0; i < 1e7; ++i) {
        if(rem == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        rem = (rem*10+7)%k;
    }
    cout << -1 << endl;

    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n;
vector<int> h;

int main()
{
    cin >> n;
    h.resize(n);
    bool f = true;

    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    for (int i = n-1; i > 0; --i){
        if (h[i] >= h[i-1]) continue;
        if (h[i-1] - h[i] == 1) --h[i-1];
        else {
            f = false;
            break;
        }
    }

    if (f) printf("Yes\n");
    else printf("No\n");

    return 0;
}
        


Measured memory_bytes: 640
#include<stdio.h>
#include <algorithm>
#include <boost/foreach.hpp>
using namespace std;

int main(){
  int i,a[100000],box[100000]={},n,b;
  long long int flag=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  sort(a,a+n,greater<int>());
  b=n-1;

  for(i=0;i<n;i++){
    if(a[i]!=b)
      flag=0;
    if(i%2==1)
      b-=2;
  }
  if(flag)
    for(i=0;i<n/2;i++){
      flag*=2;
      flag%=1000000007;
    }
  printf("%lld\n",flag);
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int x =min(N*A,B);
  cout << x << endl;
  return 0;
}
  

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

int main(){
	string s;
	int ans = 0;
	while(cin >> s){
		int i = 0, size = s.size()/2;
		for(i;i < size && s[i] == s[s.size()-i-1];i++);
		if(i == size)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3148
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        if (h == 1 || w == 1) {
            System.out.println("1");
        } else if (h % 2 == 0 || w % 2 == 0) {
            System.out.println(h * w / 2);
        } else if (h % 2 == 1 && h % 2 == 1) {
            System.out.println((h / 2 + 1) * (w / 2 + 1) + (h / 2) * (w / 2));
        }
    }
}

Measured memory_bytes: 35648
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 2003;

int b[N][N];
int w[N][N];
int M;

int sum(int x, int y, int n, int m, int s[N][N]){
	if(x>=M) x-=M;
	if(y>=M) y-=M;
	if(x+n<=M && y+m<=M) return s[x][y] - s[x+n][y] - s[x][y+m] + s[x+n][y+m];
	if(x+n>M){
		int k = x+n-M;
		return sum(x,y,n-k,m,s) + sum(0,y,k,m,s);
	}
	if(y+m>M){
		int k = y+m-M;
		return sum(x,y,n,m-k,s) + sum(x,0,n,k,s);
	}
	assert(0);
}

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, K;
	
	cin>>n>>K;
	M = K*2;
	for(int i=0;i<n;++i){
		int x,y;
		string c;
		cin>>x>>y>>c;
		x%=M;
		y%=M;
		if(c=="W") w[x][y]++;
		else b[x][y]++;
	}
	
	for(int i=M-1;i>=0;i--)
	for(int j=M-1;j>=0;j--){
		b[i][j] = b[i][j] + b[i+1][j] + b[i][j+1] - b[i+1][j+1];
		w[i][j] = w[i][j] + w[i+1][j] + w[i][j+1] - w[i+1][j+1];
	}
	
	int ans = 0;
	for(int i=0;i<M;++i)
	for(int j=0;j<M;++j){
		int cb = sum(i,j,K,K,b) + sum(i+K,j+K,K,K,b);
		int cw = sum(i+K,j,K,K,w) + sum(i,j+K,K,K,w);
		ans = max(ans, cb+cw);
	}
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 31616
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

N,M=map(int,input().split())
A=[0]+list(map(int,input().split()))
dp=[[0 for i in range(2**N)] for j in range(M+1)]

dp[0][0]=g1[2**N-1]

for i in range(1,M+1):
    for j in range(2**N):
        dp[i][j]=dp[i-1][j]
        for k in range(N):
            if j>>k &1==0 and 2**N-A[i]-j>=2**k-1:
                dp[i][j]=(dp[i][j]+((-1)*((g1[2**N-A[i]-j]*g2[2**N-A[i]+1-(j+2**k)])%mod)*((dp[i-1][j+2**k]+g1[2**N-1-j-2**k])*2**k)%mod)%mod)%mod

#for i in range(M+1):
    #print(dp[i])
print((dp[M][0]*pow(2,N,mod))%mod)


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

int main(){
    int X; cin>>X;
    int ans = 1;
    if(X == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i=2;i<=X;i++){
        int tmp = i;
        int tmp2 = i;
        while(tmp<=X){
            tmp *= tmp2;
            if(X>=tmp) ans = max(tmp,ans);
        }
    }
    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 256
def is_same(si, sj):
    for i in range(M):
        for j in range(M):
            if gridsA[sj + j][si + i] != gridsB[j][i]:
                return False
    return True


N, M = map(int, input().split())
gridsA = [input() for _ in range(N)]
gridsB = [input() for _ in range(M)]

if N == M:
    if is_same(0, 0):
        print('Yes')
    else:
        print('No')
else:
    for i in range(N - M):
        for j in range(N - M):
            if is_same(i, j):
                print('Yes')
                exit()
    print('No')


Measured memory_bytes: 3064
n, k = map(int, input().split())
R, S, P = map(int, input().split())
t = input()

score = 0

for i in range(k):
    aa = t[i::k]
    before = ''
    for ja in aa:
        if ja==before:
            before = ''
            continue
        else:
            if ja=='s':
                score += R
            elif ja=='p':
                score += S
            else:
                score += P
            before = ja

print(score)

Measured memory_bytes: 3316
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 c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();

        if (e-a<=k) System.out.println("Yay!");
        else System.out.println(":(");


    }
}



Measured memory_bytes: 21716
N,A,B,C,D = map(int, input().split())
S = input()

ans = "Yes"
if C < D:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    for i in range(B-1, D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
else:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    flag = True
    for i in range(B-2, D-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = False
    if flag:
        ans = "No"
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> VL;
typedef set<ll> SL;
typedef pair<ll, ll> p2;
const ll M = 1000000007;
const ll M2= 998244353;

void solve()
{
	ll a; cin>>a;
	ld b; cin>>b;
	ll ans=round(b*100);
	cout<<(a*ans)/100;
		
}
 
int main()
{
    IOS
    int _=1;
    //cin>>_;
    while(_--)
    {
	    solve();
    }
    
    return 0;
}


Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			String[] dataArray = data.split(" ");

			int index = 0;
			for (index = 0; index <= dataArray.length; index++) {
				if (dataArray[index].equals("0")) {
					break;
				}
			}

			System.out.println(index + 1);
		}
	}
}

Measured memory_bytes: 35688
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main()
{
    char s[27];
    scanf("%s", s);
    bool flag = false;
    int i, j;
    for (i=0; i<=strlen(s)-2; i++)
    {
        for (j=i+1; j<=strlen(s)-1; j++)
        {
            if (s[i] == s[j]) {
                flag = true;
                break;
            }
        }
        if (flag == true) {
            break;
        }
    }
    if (flag == false) {
        printf("yes\n");
    } else {
        printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
	long long int n,tmp,min=1000000000000,max=-1000000000000;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>tmp;
		if(max < tmp-min) max = tmp - min;
		if(min > tmp) min = tmp;
	}
	cout<<max<<endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    int m1,m2,m3;
    m1=0;
    m2=0;

    rep(i,n){
        cin >> a[i];
        if(a[i]>=m1){
            m3=m1;
            m1=a[i];
            m2=m3;
        }
        else if(a[i]>=m2){
            m2=a[i];
        }
    }

    rep(i,n){
        if(a[i]==m1){
            cout << m2 << endl;
        }
        else{
            cout << m1 << endl;
        }
    }
    

    return 0;
}

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

int main() {
	string s, t = "";
	cin >> s;
	int r = 0, l = s.length() - 1, c = 0;
	while (r < l) {
		if (s[r] == s[l]) {
			r++;
			l--;
		} else if (s[r] == 'x') {
			r++;
			c++;
		} else if (s[l] == 'x') {
			l--;
			c++;
		} else {
			c = -1;
			break;
		}
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 512
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 100, W = 1e5;
LL dp[N + 5][W + 5];
LL w[N + 5], v[N + 5];

LL calc(int x,int y) {
	if(x == -1) return 0;
	LL &res = dp[x][y];
	if(res != -1) return res;
	res = calc(x - 1,y);
	if(w[x] <= y) res = max(res, calc(x - 1,y - w[x]) + v[x]);
	return res;
}

void hora(int tc) {
	int n,ww;
	cin>>n>>ww;
	for(int i = 0;i < n;i++) cin>>w[i]>>v[i];
	memset(dp,-1,sizeof dp);
	cout<<calc(n - 1,ww)<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,b,ans=1000000000000011;
  cin >> n;
  for(int64_t a=1;a*a<=n;a++){
    if(n%a==0){
      b=n/a;
      ans=min(ans,a+b-2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<x;
const int maxn=5+2e3;
struct edge
{
    int v;
    int w;
    int next;
}e[maxn<<1];

priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
int head[maxn];
int cnt;
bool vis[maxn];
unsigned F[maxn<<1];
int ans[maxn<<1];

void add(int u,int v,int w)
{
    cnt++;
    e[cnt].v=v;
    e[cnt].w=w;
    e[cnt].next=head[u];
    head[u]=cnt;
}

int main()
{
    int n,x,y;
    cin>>n>>x>>y;

    for(int i=1;i<n;i++)
    {
        add(i,i+1,1);
        add(i+1,i,1);
    }

    add(x,y,1);
    add(y,x,1);
    
    for (int i=1;i<n;i++)
    {
        for (int i=1;i<=n;i++) F[i]=INT_MAX;   
        memset(vis,0,sizeof(vis));
        F[i]=0;
        q.push(make_pair(0,i));
        while (!q.empty())
        {
            int x=q.top().second;
            q.pop();   
            if (vis[x]) continue;
            vis[x]=1;

            for (int j=head[x];j;j=e[j].next) 
            {
                if(F[e[j].v]>F[x]+e[j].w)
                {
                    F[e[j].v]=F[x]+e[j].w;
                    q.push(make_pair(F[e[j].v],e[j].v));
                }
            }
        }

        for (int j=i+1;j<=n;j++)
            if (F[j]!=INT_MAX)
                ans[F[j]]++;

    }

    for (int i=1;i<n;i++)
        cout<<ans[i]<<'\n';
    return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int a[3] = {},b[3] = {};
    bool f[4][4] = {};
    for (int i = 0; i < 3; i++) {
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        f[a[i]][b[i]] = true;
        f[b[i]][a[i]] = true;
    }
    const int N = 3;
    vector<int> v = {0,1,2,3};
    string ans = "NO";
    do {
        int cnt = 0;
        if (f[v[0]][v[1]]) {
            cnt++;
        }
        if (f[v[1]][v[2]]) {
            cnt++;
        }
        if (f[v[2]][v[3]]) {
            cnt++;
        }
        if (cnt == 3) {
            ans = "YES";
        }
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

    cout << ans << endl;

    return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
int x, a, b;
cin >> x >> a >> b;
if(abs(x - a) < abs(x - b)) print('A');
else print('B');

 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,K;
    cin >> N >> K;

    vector<int> I(N);

    for(int i=0;i<N;i++){
        int a;
        cin >> a;

        I.at(a-1)++;
    }

    int ans=0;

    sort(I.begin(),I.end());

    for(int i=0;i<N-K;i++){
        ans += I.at(i);
    }

    cout << ans <<endl;
    
}

Measured memory_bytes: 4048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBuildingsAreColorful solver = new BBuildingsAreColorful();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBuildingsAreColorful {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long res = Long.MAX_VALUE;
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            for (int i = 0; i < 1 << n; i++) {
                int cntBit = 0;
                // 立ってるbit数の確認
                for (int j = 0; j < n; j++) if ((i & 1 << j) != 0) cntBit++;
                if (cntBit < k) continue;

                // 一回ごとの費用が必要
                long cmp = 0;
                long maxHeight = 0;
                for (int j = 0; j < n; j++) {
                    if ((i & 1 << j) != 0) {
                        // bitが立ってる
                        if (maxHeight < a[j]) {
                            maxHeight = a[j];
                        } else {
                            maxHeight += 1;
                            cmp += maxHeight - a[j];
                        }
                    } else {
                        maxHeight = Math.max(maxHeight, a[j]);
                    }
                }
                res = Math.min(cmp, res);
            }
            out.println(res);

        }

    }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 1e5 + 5;
int arr[N][3], memo[N][3];

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

	int n;
	cin >> n;

	rep(i, 0, n)
		rep(j, 0, 3)
			cin >> arr[i][j];

	for(int i = n - 1; i >= 0; i--)
	{
		for(int j = 2; j >= 0; j--)
		{
			int a = -1, b = -1;
			rep(k, 0, 3)
			{
				if (k == j)
					continue;
				if (a == -1)
					a = k;
				else
					b = k;
			}

			memo[i][j] = arr[i][j] + memo[i+1][a];
			memo[i][j] = max(memo[i][j], arr[i][j] + memo[i+1][b]);
		}
	}

	cout << max(memo[0][0], max(memo[0][1], memo[0][2])) << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
#define int long long

int nC2(int n){
    return n * (n-1) / 2;
}

signed main(){
    int n;
    cin >> n;
    map<string, int> mp;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    int res = 0;
    for (auto i = mp.begin(); i != mp.end(); ++i) {
        res += nC2(i->second);
    }
    cout << res << endl;
}

Measured memory_bytes: 11136
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f;
const int maxn = 55;
const ll mod = 1e9+7;

double a[maxn];

int main(){
    int n;
    scanf("%d",&n);
    if(n<3200){
        puts("red");
    }else {
        getchar();
        char c;
        while((c=getchar())!=EOF)putchar(c);
    }
    return 0;
}


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

int main(){
  int x, y, z, k;
  long long a[1000];
  long long b[1000];
  long long c[1000];
  cin >> x >> y >> z >> k;
  for(int i = 0; i < x; i++){
    cin >> a[i];
  }
  for(int i = 0; i < y; i++){
    cin >> b[i];
  }
  for(int i = 0; i < z; i++){
    cin >> c[i];
  }
  sort(a, a + x, greater<long long>());
  sort(b, b + y, greater<long long>());
  sort(c, c + z, greater<long long>());
  vector<long long> v;
  for(int i = 0 ; i < x; i++){
    for(int j = 0; j < y ; j++){
      for(int l = 0; l < z; l++){
        if((i + 1) * (j + 1) * (l + 1) <= k) v.push_back(a[i]+b[j]+c[l]);
      }
    }
  }
  sort(v.begin(), v.end(), greater<long long>());
  for(int i = 0; i < k ; i++){
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) cout << c << endl;
    else if (a != b && a != c) cout << a << endl;
    else cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector < long long > factors(long long n)
{
    vector < long long > v;
    long long i,count=0;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i*i==n)
                v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}
bool isprime(long long n)
{
    long long i,count=0;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i*i==n)
                count++;
            else
                count+=2;
        }
    }
    if(count==2)
        return 1;
    else
        return 0;
}
int main() {
    long long a,b,i,count=0;
    cin>>a>>b;
    long long c=__gcd(a,b);
    vector < long long > v=factors(c);
    for(i=0;i<v.size();i++)
    {
        if(isprime(v[i]))
            count++;
    }
    cout<<count+1;


    return 0;
}

Measured memory_bytes: 384
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = next(), k = next();
  var p = nexts(n);
  var a = xArray(0,n+1);
  for(var i = 1; i <= n; i++){
    a[i] = a[i-1] + (p[i-1]+1) / 2;
  }
  var ans = 0;
  for(var i = k; i <= n; i++){
    var t = a[i] - a[i-k];
    if(ans < t)ans = t;
  }
  return ans;
}

Measured memory_bytes: 39112
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int n, m;
const int INF = 2000000005;
int coins[21];
int dp[50005];
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> coins[i];
	for (int i = 0; i < 50005; i++) dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j+coins[i] <= n; j++) {
			dp[j + coins[i]] = min(dp[j + coins[i]], dp[j] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 500;
int range[MAX_N + 1][MAX_N + 1];

int main()
{
	memset(range, 0, sizeof(range));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M, Q; cin >> N >> M >> Q;
	rep (i, M){
		int L, R; cin >> L >> R;
		++range[L][R];
	} // end rep

	for (int i = 1; i <= MAX_N; ++i){
		for (int j = 1; j <= MAX_N; ++j){
			range[i][j] += range[i][j-1];
		} // end for
	} // end for
	for (int i = 1; i <= MAX_N; ++i){
		for (int j = 1; j <= MAX_N; ++j){
			range[i][j] += range[i-1][j];
		} // end for
	} // end for

	rep (i, Q){
		int p, q; cin >> p >> q;
		int res = range[q][q] - range[p-1][q] - range[q][p-1] + range[p-1][p-1];
		cout << res << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    int n;
    cin>>n;
    string str;
    int r=0,b=0,g=0;
    cin>>str;
    int l=0;
    int ans=0;
    for(auto i:str){
      if(i=='R') r++;
      if(i=='G') g++;
      if(i=='B') b++;
      for(int j=l+1;2*j-l<n;j++)
      {
        int k=j-l+j;
        if(i!=str[j]&& str[j]!=str[k] && i!=str[k])
          ans--;
      }
      l++;
    }
    cout<<r*b*g+ans;
  }
  //time("");
  return 0;
}

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


int main(void){
  int n;cin>>n;
  vector<int> a(n+10);
  r(i,n){cin>>a.at(i);}

  int temp=a.at(0);
  int cnt=1;int ans=0;
  while(cnt<n){
    if(temp==2){ans=-1;break;}
  //  cout<<temp<<endl;
    temp=a.at(temp-1);
    cnt++;
  }
  if(ans==-1)cout<<cnt<<endl;
  else cout<<-1<<endl;


return 0;

}


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

using namespace std;

#define Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define fr first
#define sc second
#define pb push_back
#define PI acos(-1.0)
#define print(num,ans) cout<<setprecision(num)<<fixed<<ans


int main()
{
    Speed;
    ll x,y;
    cin>>x>>y;
    cout<<ceil((double)x/y);

    return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
q = int(input())
now = [0 for i in range(10 ** 5)]
for num in lis:
    now[num-1] += 1
ans = 0
for i in range(10 ** 5):
    ans += now[i] * (i+1)
  # print(ans)
for turn in range(q):
    b,c = map(int,input().split())
    num = now[b-1]
    now[b-1] = 0
    now[c-1] += num
    print(ans-b*num+c*num)
    ans -= b*num
    ans += c*num
  #     print(now)

Measured memory_bytes: 83540
/* Author : Pranav Deshmukh
            PICT,Pune
   Purpose: Atcoder Practice
   Stay Focused!
*/

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)       int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(arr,n,type) type *arr=new type[n];
#define fo(i,n)        for(int i=0;i<n;i++)
#define mod             pow(10,9)+7
#define inf             1e18
#define endl            "\n"
#define ff              first
#define ss              second
#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> >

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
    c_p_c();
    dipi(n);
    if (n % 1000 == 0) {
        cout << "0" << endl;
    }
    else if (n <= 1000)
        cout << 1000 - n << endl;
    else
        cout << (1000 - (n % 1000)) << endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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

        a = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        List<String> ret = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w - 1; j++) {
                if(a[i][j] % 2 == 0) {
                    continue;
                }
                a[i][j+1] += 1;
                ret.add(String.format("%d %d %d %d", i+1, j+1, i+1, j+2));
            }
        }
        for (int i = 0; i < h - 1; i++) {
            if(a[i][w-1] % 2 == 0) {
                continue;
            }
            a[i+1][w-1] += 1;
            ret.add(String.format("%d %d %d %d", i+1, w, i+2, w));
        }
        System.out.println(ret.size());
        ret.forEach(System.out::println);
    }
}


Measured memory_bytes: 171384
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int  length = s.size();
    if(s[length-1]=='s')
    {
        s+="es";
    }
    else
    {
        s+="s";
    }

    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int N;
string S;
int lr[200000];
vector<int> l, r;

int main(){
	cin >> N >> S;
	for(int i=2*N-1; i>=0; i--){
		if(S[i] == 'W'){
			if(i%2 == 1) l.PB(i);
			else r.PB(i);
		}
		else{
			if(i%2 == 0) l.PB(i);
			else r.PB(i);
		}
	}
	if(l.size() != r.size()){
		cout << 0 << endl;
		return 0;
	}
	sort(r.begin(), r.end());
	LL ans = 1;
	for(int i=0; i<N; i++){
		int s = r.end() - upper_bound(r.begin(), r.end(), l[i]);
		s -= i;
		if(s <= 0){
			cout << 0 << endl;
			return 0;
		}
		ans *= s;
		ans %= MOD;
		ans *= i+1;
		ans %= MOD;
	}
	cout << ans << endl;
}

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



int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3,y3,x4,y4;
  int a=x2-x1;
  int b=y2-y1;
  x3=x2-b;
  y3=y2+a;
  x4=x1-b;
  y4=y1+a;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;

}


Measured memory_bytes: 3620
n = list(map(int,input().split()))
ans1 = n[0] - n[2]
ans2 = (n[0] + n[1]) -  n[2]

if ans1 <= 0:
    ans1 = 0

if ans1 > 0:
    ans2 = n[1]
elif ans2 <= 0:
    ans2 = 0

print(ans1,ans2)


Measured memory_bytes: 2940
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      	char[] s_chars = sc.next().toCharArray();
      
      int count = 0;int memo  = 0;
      for(int i = 0;i < n;i++){
      	if(s_chars[i]=='I'){count++;}
        else{count--;}
        memo = Math.max(memo,count);
      }
		System.out.print(memo);
      
    }
}

Measured memory_bytes: 21844