akhauriyash/Code-Regression huggingface dataset:
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FAST   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
   int n,k; cin>>n>>k;
   cout<<n-k+1;
} 
int main()
{   
   FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main (String [] args){
//		String [][] boad = new String[4][4];
		String s1 = sc.next();
		if(s1.equals("A")){
			s1 = "T";
		}else if(s1.equals("T")){
			s1 = "A";
		}
		
		if(s1.equals("G")){
			s1 = "C";
		}else if(s1.equals("C")){
			s1 = "G";
		}
			
	System.out.println(s1);
	System.out.flush();
//		BigDecimal xx1 = new BigDecimal(Integer.parseInt(sc.next()));
//		double c = 0;
//		System.out.println();
//		System.out.flush();
		sc.close();
	}
}

Measured memory_bytes: 21844
import math
fact = math.factorial
n, m = [int(i) for i in input().split()]

def dog_monk(n,m):
    diff = abs(n-m)
    if diff > 1:
        return 0
    elif diff == 1:
        return fact(m) * fact(n)
    elif diff == 0:
        return 2 * fact(m) * fact(n)

print(dog_monk(n,m) % (10 ** 9 + 7))


Measured memory_bytes: 5164
import math

n = int(input())

m = n

for i in range(1, math.floor(n ** 0.5) + 1):
    if n % i == 0:
        l = len(str(i))
        ll = len(str(n // i)) 
        if m > max(l, ll):
            m = max(l, ll)

print(m)

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
    int n;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    
    sort(a,a+n,greater<ll>());
    
    int cc=0;
    ll b[2];
    
    rep(i,n){
        if(a[i]==a[i+1] && cc==0){
            b[0]=a[i];
            a[i+1]=0;
            cc=1;
        }
        if(a[i]==a[i+1] && cc==1){
            b[1]=a[i];
            cout<<b[0]*b[1]<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  int[] a = new int[4];
  while (in.hasNext()) {
	for (int i = 0; i < a.length; i++) {
	  a[i] = in.nextInt();
	}
	int hit = 0;
	int blow = 0;
	for (int i = 0; i < 4; i++) {
	  int num = in.nextInt();
	  for (int j = 0; j < a.length; j++) {
		if (a[j] == num) {
		  if (i == j) {
			hit++;
		  } else {
			blow++;
		  }
		}
	  }
	}
	System.out.println(hit + " " + blow);
  }
}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<double,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

mint dp[25][2100000];

int main(){
    int n;
    cin >> n;
    int field[23][23];
    rep(i,n)rep(j,n)cin>>field[i][j];
    rep(i,25)rep(j,2100000)dp[i][j]=0;
    dp[0][0] = 1;
    for(int bit=1;bit<(1<<n);bit++){
        int i = __builtin_popcount(bit);
        for(int j=0;j<n;j++){
            if((bit>>j)&1 && field[i-1][j]==1){
                dp[i][bit]+=dp[i-1][(1<<j)^bit];
            }
        }
    }
    cout << dp[n][(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 410368
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P; //Point
typedef pair<P,P> L; //Line, Segment

const double INF = 1e9;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
 
namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}
double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }
double area(vector<P> v){
  double sum = 0.0;
  int n = v.size();
  for(int i=0;i<n;i++) sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
  return fabs(sum) / 2;
};

double ang(double a,double b,double c){
  return acos((c*c-a*a-b*b)/(2.0*a*b));
}
double ang(P a,P b,P c){
  return ang(a-b,b-c,c-a);
}

vector<P> v;
int n,S[111];
struct star{
  vector<P> v;
  int k;

  void set(int rank,const vector<P> &t){
    k = rank;
    v = t;
    double st=0.0,ed=10000.0;
    while( fabs(st-ed) > EPS ){
      double h = (st+ed)/2.0;
      for(int i=0;i<10;i++){
        v[i] = t[i]*h;
      }
      double ar = area(v);
      if( ar < S[rank]+0.5 ) {
        st = h;
      } else {
        ed = h;
      }
    }    
  }

  void view(){
    cout << "rank " << k<< "area " << area(v) << endl;
    for(int i=0;i<10;i++){
      cout << v[i] << endl;
    }
  }

};

star Star[111];
int main(){
  v.push_back( P(-10.00, -6.48) );
  v.push_back( P(-10.79, -8.91) );
  v.push_back( P(-13.34, -8.91) );
  v.push_back( P(-11.28, -10.41) );
  v.push_back( P(-12.07, -12.84) );
  v.push_back( P(-10.00, -11.34) );
  v.push_back( P(-7.93, -12.84) );
  v.push_back( P(-8.72, -10.41) );
  v.push_back( P(-6.66, -8.91) );
  v.push_back( P(-9.21, -8.91) );
  /*
  v.push_back( P(0,2.5) );
  v.push_back( P(-1,0) );
  v.push_back( P(-3,0) );
  v.push_back( P(-2,-0.5) );
  v.push_back( P(-2,-2) );
  v.push_back( P(0,-0.5) );
  v.push_back( P(2,-2) );
  v.push_back( P(2,-0.5) );
  v.push_back( P(3,0) );
  v.push_back( P(1,0) );
  */
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",&S[i]);
  
  for(int i=0;i<n;i++){
    Star[i].set(i,v);
    // Star[i].view();
  }

  double ue = -4999.0,mg=-4999.0;
  double nue = -4999.0;
  for(int i=0;i<n;i++){
    //cout << ue << " " <<mg << " " << nue << endl;
     printf("%d\n",i+1);
    double l,r,u,s;
    l = s = INF;
    r = u = -INF;
    for(int j=0;j<10;j++){
      l = min( l, Star[i].v[j].real() );
      r = max( r, Star[i].v[j].real() );
      u = max( u, Star[i].v[j].imag() );
      s = min( s, Star[i].v[j].imag() );
    }
    double w = fabs(r-l);
    // cout << "mg " << mg << " "<< w << endl;
    if( mg + w > 4999.0 ) {
      mg = -4999.0;
      ue = nue;
    }
    if( fabs( ue - nue ) < EPS ){
      //  cout << "in "<< endl;
      nue = ue + fabs(u-s)+1.0;
    }
    double mx = mg - l;
    double my = ue - s;
    for(int j=0;j<10;j++){
      Star[i].v[j].real() += mx;
      Star[i].v[j].imag() += my;
      printf("%.8lf %.8lf\n",Star[i].v[j].real(),Star[i].v[j].imag());
    }
    mg += w+1.0;
  }

}

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

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

  rep(i, N) {
    int a; cin >> a;
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
      cout << "DENIED\n";
      return 0;
    }
  }
  cout << "APPROVED\n";

  return 0;
}


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

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

#define forup(i,a,b) for(int i=(a); i<(b); ++i)
#define fordn(i,a,b) for(int i=(a); i>(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)

#define gi(x) scanf("%d",&x)
#define gl(x) cin>>x
#define gd(x) scanf("%lf",&x)
#define gs(x) scanf(" %s",x)

#define D(x) cout << #x << " : " << x << endl

#define fs first
#define sc second

#define pb push_back
#define mp make_pair

const int inf=numeric_limits<int>::max();
const LL linf=numeric_limits<LL>::max();

const int max_n=101, max_w=100001;

int n, w, weight[max_n];
LL value[max_n], dp[max_n][max_w];

LL f(int idx, int wt){

    if(wt < 0 || n == idx)
        return dp[idx][0] = 0;

    if(dp[idx][wt])
        return dp[idx][wt];

    return dp[idx][wt] = (wt>=weight[idx])?(max(f(idx+1,wt),value[idx]+f(idx+1, wt-weight[idx]))):f(idx+1,wt);
}

int main() {
    gl(n>>w);
    rep(i,n){
        gl(weight[i]>>value[i]);
    }
    
    cout << f(0,w) << endl;

    return 0;
}

Measured memory_bytes: 76288
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  set<char> se;
  for(int i=0;i<s.size();i++){
    se.insert(s[i]);
  }
  int cnt=0;
  for(char c:se){
    cnt++;
  }
  if(cnt==s.size())
    cout<<"yes";
  else
    cout<<"no";
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pl = pair<ll, int>;

void Main() {
	int n;
	cin >> n;
	string ans = "pphbhhphph";
	cout << ans[n%10] << "on" << endl;
	return;
}

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


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
	int cnt,n;
	unsigned int i,w,h[101],sa[5];
	while(scanf("%d",&n),n!=0){
		for(i=0;i<=n;i++)scanf("%d",&h[i]);
		sa[0]=h[1]-h[0];
		sa[1]=h[i-1]-h[i-2];
		sa[2]=h[(i-1)/2]-h[(i-1)/2-1];
		sa[3]=h[(i-1)/2+1]-h[(i-1)/2];
		if(sa[0]==sa[1] || sa[1]==sa[2] || sa[1]==sa[3])sa[4]=sa[1];
		if(sa[0]==sa[2] || sa[0]==sa[3])sa[4]=sa[0];
		for(i=1;i<=n;i++){
			if(h[i]-h[i-1]!=sa[4]){
				cnt++;
				if(cnt>1)w=h[i-1];
				if(h[i+1]-h[i]==sa[4])w=h[i-1];
				if(i==n && w<1)w=h[i];
			}
		}
		printf("%d\n",w);
		cnt=w=0;
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

const int MAX_N = int(1e6) + 10;


struct fenwick{
  int lim;
  int *tree;
  fenwick(int _lim){
      lim=_lim;
      tree=new int[lim];
  }
  void init(){
    for(int i=0;i<lim;i++){
      tree[i]=0;
    }
  }
  void update(int x){
    while(x<lim){
      tree[x]+=1;
      x+=x&(-x);
    }
  }
  int query(int x){
    int ans=0;
    while(x>0){
      ans+=tree[x];
      x-=x&(-x);
    }
    return ans;
  }
  int _query(int k){
    int low=1;
    int high=500000;
    int ans=0;int x=k;
    while(low<=high){
      int mid=low+(high-low)/2;
      if(query(mid)>=x){
        ans=mid;
        high=mid-1;
      }else{
        low=mid+1;
      }
    }
    return ans;
  }
};
int a[500005];
int main() {

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

  int x=1;
  int maxi=1;

  for(int i=n-1;i>=1;i--){
    if(a[i]>=a[i+1]){
      x=x+1;
    }else{
      x=1;
    }
    maxi=max(x,maxi);
  }

  cout<<maxi-1<<endl;


   return 0;
}
   


Measured memory_bytes: 640
#include <stdio.h>

using namespace std;

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



Measured memory_bytes: 2608
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() {return sz;}
};

int H, W;
string S[405];

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

int main() {
	cin >> H >> W;
	rep (i, H) cin >> S[i];

	V<int> listb ,listw;
	rep (i, H) rep (j, W) {
		if (S[i][j] == '#') listb.pb(j + i * W);
		else listw.pb(j + i * W);
	}

	UnionFind uf(H * W);
	rep (i, listb.size()) {
		int y = listb[i] / W;
		int x = listb[i] % W;
		vector<int> koho;
		rep (j, 4) {
			int ny = y + dy[j];
			int nx = x + dx[j];
			if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.') {
				koho.pb(ny * W + nx);
			}
		}
		
		if (koho.size()) rep (j, koho.size() - 1) uf.unionSet(koho[0], koho[j + 1]);
	}

	ll ans = 0;
	rep (i, listb.size()) {
		int y = listb[i] / W;
		int x = listb[i] % W;
		rep (j, 4) {
			int ny = y + dy[j];
			int nx = x + dx[j];
			if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '.') {
				ans += uf.size(ny * W + nx);
				break;
			}
		}
	}

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


Measured memory_bytes: 4744
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    if H==1 or W==1:
        print(1)
    else:
        x1 = H // 2
        x0 = H - x1
        y1 = W // 2
        y0 = W - y1
        print(x1*y1+x0*y0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  sort(a.begin(), a.end());
  for(int i = 0; i < k; ++i) {
    ans += a[i];
  }
  cout << ans << '\n';
  return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

struct edge {
  ll from, to, cost;
  edge(int f, int t, int c) : from(f), to(t), cost(c) {}
};

typedef pair<long long, int> P; // firstは最短距離、secondは頂点の番号
vector<edge> es[100001];

int main() {

  ll K;
  cin >> K;

  REP(i, K) {
    int to = (i + 1) % K;
    es[i].emplace_back(edge(i, to, 1));
  }

  REP(i, K) {
    int to = (i * 10) % K;
    es[i].emplace_back(edge(i, to, 0));
  }

  vll d(K, (1 << 30));
  d[1] = 0;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(P(0, 1));

  while (!pq.empty()) {
    P p = pq.top();
    pq.pop();

    if (d[p.second] < p.first)
      continue;

    for (auto e : es[p.second]) {
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        pq.push(P(d[e.to], e.to));
      }
    }
  }

  cout << d[0] + 1 << endl;

  return 0;
}


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

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        H: usize,
        W: usize,
        C: [chars; H],
    }
    for i in 0..H{
        for j in 0..W{
            print!("{}",C[i][j]);
        }
        println!("");
        for j in 0..W{
            print!("{}",C[i][j]);
        }
        println!("");
    }
}

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

int main( int argc, char *argv[] )
{
    int a, b, c, k;

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

    if( a >= k ) {
        printf( "%d\n", k );
        exit( 0 );
    }
    if( a+b >= k ) {
        printf( "%d\n", a );
        exit( 0 );
    }

    k -= a+b;
    printf( "%d\n", a-k );
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    string s;
    cin>>s;
    for(int i=0;i < 3;i++)
    {
        if(s.at(i)==s.at(i+1)){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


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

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



Measured memory_bytes: 3624
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    return S,


def solve(S):
    if S[0] != "A":
        return "WA"
    c_index = -1
    for i in range(2, len(S)-1):
        if S[i] == "C":
            if c_index >= 0:
                return "WA"
            c_index = i
    if c_index == -1:
        return "WA"
    for i in range(1, len(S)):
        if i == c_index:
            continue
        elif S[i].lower() != S[i]:
            return "WA"
    return "AC"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 8892
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s; int N=s.size();
  int64_t ans=1;
  map<char,int64_t>M;
  M[s.at(0)]=1;
  for(int i=1;i<N;i++){
  if(!M.count(s.at(i))){
  M[s.at(i)]=1;ans+=i;
  }else{
  ans+=(i-M.at(s.at(i)));
    M.at(s.at(i))++;
  }
  }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int n,ans=0,ans1=0;
	cin>>a;
	n=a.size();
	for(int i=0;i<n;i++)
	{
		if(i%2==0&&a[i]=='0') ans++;
		if(i%2==1&&a[i]=='1') ans++;
		if(i%2==0&&a[i]=='1') ans1++;
		if(i%2==1&&a[i]=='0') ans1++;
	}
	cout<<min(ans,ans1);
	return 0;
}

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

int main(){
  char s;
  
  cin >> s;
  
  if(s=='a'||s=='i'||s=='u'||s=='e'||s=='o')
  {
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
inline double sq(double a) { return a*a; }

struct MST {
    typedef double weight;
    static const weight INF = 1e100;
    static const int N = 128;

    int n, r, no[N], prev[N], mark[N], temp[N];
    vector<int> comp[N];
    weight g[N][N], cost, mcost[N];
    
    void init(int _n) {
        n = _n;
        rep(i, n) rep(j, n) g[i][j] = INF;
    }

    void add_edge(int u, int v, weight w) { g[u][v] = w; }

    bool rec(int v, int s) {
        bool found = false;
        if(mark[v]) {
            found = true;
            memcpy(temp, no, sizeof(temp));
            for(;;) {
                cost += mcost[v];
                v = prev[v];
                if(v==s) break;
                while(comp[v].size()) {
                    no[comp[v].back()] = s;
                    comp[s].push_back(comp[v].back());
                    comp[v].pop_back();
                }
            }
            rep(j, n) if(j!=r && no[j]==s) {
                rep(i, n) if(no[i]!=s && g[i][j]<INF) g[i][j] -= mcost[temp[j]];
            }
        }
        mark[v] = 1;
        rep(i, n) if(no[i]!=no[v] && prev[no[i]]==v) {
            if(!mark[no[i]] || i==s) found |= rec(i, s);
        }
        return found;
    }

    weight solve(int _r) {
        r = _r;
        rep(i, n) {
            no[i] = i;
            comp[i].clear();
            comp[i].push_back(i);
        }
        cost = 0;
        for(;;) {
            memset(prev, -1, sizeof(prev));
            rep(i, n) mcost[i] = INF;
            rep(i, n) rep(j, n) if(j!=r && no[i]!=no[j] && g[i][j]<INF) {
                if(g[i][j] < mcost[no[j]]) {
                    mcost[no[j]] = g[i][j];
                    prev[no[j]] = no[i];
                }
            }
            memset(mark, 0, sizeof(mark));
            bool stop = true;
            rep(i, n) if(i!=r && !mark[i] && comp[i].size()) {
                if(rec(i, i)) stop = false;
            }
            if(stop) {
                rep(i, n) if(prev[i]>=0) cost += mcost[i];
                return cost;
            }
        }
    }
} mst;

int N, M;
double v[128][128];

double dot(int a, int b) {
    double s = 0;
    rep(i, N) s += v[a][i]*v[b][i];
    return s;
}

double norm(int a) { return dot(a, a); }

int main() {
    scanf("%d%d", &N, &M);
    rep(i, M) rep(j, N) scanf("%lf", v[i]+j);
    mst.init(M+1);
    rep(i, M) mst.add_edge(M, i, norm(i));
    rep(i, M) rep(j, M) if(i!=j) {
        if(norm(i)==0) mst.add_edge(i, j, norm(j));
        else mst.add_edge(i, j, norm(j)-sq(dot(i, j))/norm(i));
    }
    printf("%.9f\n", mst.solve(M));
    return 0;
}

Measured memory_bytes: 0
package main

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

func main() {

    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    A, err := strconv.Atoi(strings.Split(scanner.Text(), " ")[0])
    if err != nil {
	fmt.Println(err)
	return
    }
    B, err := strconv.Atoi(strings.Split(scanner.Text(), " ")[1])
    if err != nil {
	fmt.Println(err)
	return
    }
    C, err := strconv.Atoi(strings.Split(scanner.Text(), " ")[2])
    if err != nil {
	fmt.Println(err)
	return
    }

    if (A == 5|| A == 7)&&(B == 5|| B == 7)&&(C == 5|| C == 7)&&(A+B+C == 17) {
	fmt.Println("YES")
    } else {
	fmt.Println("NO")
    }
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){

    int a,b,i;
    cin>>a>>b;
    if(a==b){
        for(i=1;i<=a;i++){
            cout<<a;
        }
    }
    else if(a>b){
        for(i=1;i<=a;i++){
            cout<<b;
        }
    }
    else{
        for(i=1;i<=b;i++){
            cout<<a;
        }
    }
    }






Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

vector<vector<long long>>v;

vector<long long>tsort(long long n) {
	vector<long long>mon(n + 1), ans;
	stack<long long>s;
	for (long long i = 1; i <= n; ++i) {
		for (auto j : v[i]) { ++mon[j]; }
	}
	for (long long i = 1; i <= n; ++i) {
		if (mon[i] == 0) { s.push(i); }
	}
	while (s.size()) {
		long long mmon = s.top();
		s.pop();
		ans.push_back(mmon);
		for (auto i : v[mmon]) {
			--mon[i];
			if (mon[i] == 0) { s.push(i); }
		}
	}
	return ans;
}

int main() {
	long long a, b;
	cin >> a >> b;
	vector<long long>aa(a + b - 1), bb(a + b - 1);
	map<long long, long long>fi;
	v.resize(a + 1);
	for (int i = 0; i < a + b - 1; ++i) { cin >> aa[i] >> bb[i]; }
	for (int i = 0; i < a + b - 1; ++i) { v[aa[i]].push_back(bb[i]); }
	auto mon = tsort(a);
	for (int i = 0; i < a; ++i) { fi[mon[i]] = i; }
	vector<long long>anss(a + 1, mon[0]);
	anss[mon[0]] = 0;
	for (int i = 0; i < a + b - 1; ++i) {
		if (fi[anss[bb[i]]] < fi[aa[i]]) { anss[bb[i]] = aa[i]; }
	}
	for (long long i = 1; i <= a; ++i) { cout << anss[i] << endl; }
}

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

int main(){
  int N,countR=0,count=0;
  string S;
  cin >> N >> S;
 for(int i=0;i<N;i++){
   if(S.at(i)=='R'){
     countR++;
   }
 }
  string T;
 for(int i=0;i<N;i++){
   if(i<countR){
     T.push_back('R');
   }
   else{
     T.push_back('W');
   }
 }
  for(int i=0;i<N;i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }
  cout << count/2 << endl;
}
     

Measured memory_bytes: 3920
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<ll> bb(n);
    rep(i,n){
        ll le=-1;
        ll ri=n;
        while(ri-le>1){
            ll mid=(ri+le)/2;
            if(a[mid]<b[i]){
                le=mid;
            }
            else{
                ri=mid;
            }
        }
        bb[i]=le+1;
    }
    vector<ll> cc(n);
    rep(i,n){
        ll le=-1;
        ll ri=n;
        while(ri-le>1){
            ll mid=(ri+le)/2;
            if(b[mid]<c[i]){
                le=mid;
            }
            else{
                ri=mid;
            }
        }
        cc[i]=le+1;
    }
    vector<ll> s(n+1);
    s[0]=0;
    rep(i,n){
        s[i+1]=s[i]+bb[i];
    }
    ll ans=0;
    rep(i,n){
        ans+=s[cc[i]];
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int n,d;
  cin>>n>>d;
  int a[n],b[n];
  for(i=0;i<n;i++){
     cin>>a[i]>>b[i];
  }
  int ans=0;
  for(j=0;j<n;j++){
   if(sqrt(pow(a[j],2)+pow(b[j],2))<=d) ans++;
   }
cout<<ans<<endl;
   return 0;
      }

Measured memory_bytes: 5184
#include<stdio.h>
#include <string.h>

struct dice{
    int d[6],tmp[6];
};
struct dice dice1;

void init(int n[6]){
   int i;
  for(i=0;i<6;i++){
       dice1.d[i]=n[i];
       }
   }
void rooldice(char c){
  int i;
  for(i=0;i<6;i++){
      dice1.tmp[i]=dice1.d[i];
  }
 if(c=='N'){
dice1.d[0]=dice1.tmp[1];
dice1.d[1]=dice1.tmp[5];
dice1.d[2]=dice1.tmp[2];
dice1.d[3]=dice1.tmp[3];
dice1.d[4]=dice1.tmp[0];
dice1.d[5]=dice1.tmp[4];
}
else if(c=='E'){
dice1.d[0]=dice1.tmp[3];
dice1.d[1]=dice1.tmp[1];
dice1.d[2]=dice1.tmp[0];
dice1.d[3]=dice1.tmp[5];
dice1.d[4]=dice1.tmp[4];
dice1.d[5]=dice1.tmp[2];
}
else if(c=='W'){
dice1.d[0]=dice1.tmp[2];
dice1.d[1]=dice1.tmp[1];
dice1.d[2]=dice1.tmp[5];
dice1.d[3]=dice1.tmp[0];
dice1.d[4]=dice1.tmp[4];
dice1.d[5]=dice1.tmp[3];
}
else if(c=='S'){
dice1.d[0]=dice1.tmp[4];
dice1.d[1]=dice1.tmp[0];
dice1.d[2]=dice1.tmp[2];
dice1.d[3]=dice1.tmp[3];
dice1.d[4]=dice1.tmp[5];
dice1.d[5]=dice1.tmp[1];
}
else if(c=='R'){
dice1.d[0]=dice1.tmp[0];
dice1.d[1]=dice1.tmp[3];
dice1.d[2]=dice1.tmp[1];
dice1.d[3]=dice1.tmp[4];
dice1.d[4]=dice1.tmp[2];
dice1.d[5]=dice1.tmp[5];
}
}

int main( void )
{
int n[6];
int q;
int i,j;
int up,front;
    
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init(n);
    scanf("%d",&q);
    for(i=0;i<q;i++){
    
        scanf("%d %d",&up,&front);
    
        for (j=0; j<4; j++) {
        rooldice('S');
        if (dice1.d[0]==up)
        {break;
        }
    
        }
    
        if(!0){
        
            while (1) {
            
                rooldice('W');
            
                if(dice1.d[0]==up){
                break;
            }
        }
    
        }
    
        for(j=0;j<4;j++){
        rooldice('R');
        if(dice1.d[1]==front){
            break;
        }
    }
    printf("%d\n",dice1.d[2]);
}
return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
#define PRINT_ENTER() cout << endl;

int main() {
    long long n; cin >> n;
    std::map<string, int> m;
    vector<string> strBuf(n);
    int maxcount = 0;
    REP(i, n){
        string s; cin >> s;
        m[s]++;
        if(m[s] > maxcount){
            maxcount = m[s];
            strBuf.clear();
            strBuf.emplace_back(s);
        }
        else if(m[s] == maxcount){
            strBuf.emplace_back(s);
        }
    }
    sort(strBuf.begin(), strBuf.end());
    for(const auto& str : strBuf){
        cout << str << '\n';
    }
    return 0;
}

Measured memory_bytes: 26752
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

int gcd(int a, int b) {
    return b ? gcd (b, a % b) : a;
}

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
//    freopen(NAME".out", "w", stdout);

    int k;
    scanf("%d", &k);
    ll ans = 0LL;

    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                ans += (ll) gcd(a, gcd(b, c));
            }
        }
    }

    printf(lld"\n", ans);

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3812
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
int a[100000];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  bool f = true;
  if (n % 2 == 0) rep(i, n) f &= a[i] == i / 2 * 2 + 1;
  if (n % 2 == 1) rep(i, n) f &= a[i] == (i + 1) / 2 * 2;
  if (f){
    ll s = 1, nn = n / 2, b = 2;
    while (nn){
      if (nn & 1) s = s * b % mod;
      b = b * b % mod;
      nn >>= 1;
    }
    cout << s << endl;
  }
  else cout << 0 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=3e5;
int a[MAXN+1]={-1},segMax[4*(MAXN+1)],segSum[4*(MAXN+1)];

void build(int v, int tl,int tr)
{
    if(tl==tr)
    {
        segMax[v]= a[tr];
        segSum[v]= a[tr];
        return ;
    }
    int tm= (tr+tl)/2;
    build(2*v+1, tl, tm);
    build(2*v+2, tm+1, tr);
    segMax[v] = max( segMax[2*v+1], segMax[2*v+2]);
    segSum[v] = segSum[2*v+1]+  segSum[2*v+2];
}

int query(int v  , int  tl ,int tr ,int l, int r)
{
    if( tl>=l && tr<=r )
        return    segMax[v];
    if(tl>r || tr<l)
        return INT_MIN;
    int tm    =  tl +   (tr-tl)  /2;
    int left=query(2*v+1,tl,tm,l,r);
    int right=query(2*v+2,tm+1,tr,l,r);
    return max(left,right);
}
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return 0;
    if (l == tl && r == tr) {
        return segSum[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2+1, tl, tm, l, min(r, tm))
           + sum(v*2+2, tm+1, tr, max(l, tm+1), r);
}
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        segMax[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2+1, tl, tm, pos, new_val);
        else
            update(v*2+2, tm+1, tr, pos, new_val);
        segMax[v] = max(segMax[v*2+1] , segMax[v*2+2]);
    }
}
signed main()
{
    int n,k;
    cin>>n>>k;
    int b[n];
    for(int i=0;i<n;i++)cin>>b[i];
    int max_=*max_element(b,b+n);
    build(0,0,max_);

    int ans=0;
    for(int i=0;i<n;i++)
    {
        int l=max(0LL,b[i]-k);
 		int r=b[i]+k;
        int res=query(0,0,max_,l,r);
        ans=max(ans,res+1);
        update(0,0,max_,b[i],res+1);
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 24668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=4010;
ll n,ans;
char s[N];
ll r[N],g[N],b[N];
int main()
{
	scanf("%lld%s",&n,s+1);
	for(ll i=n;i>=1;--i){
		r[i]=r[i+1];
		g[i]=g[i+1];
		b[i]=b[i+1];
		switch(s[i]){
			case 'R':++r[i];break;
			case 'G':++g[i];break;
			case 'B':++b[i];break;
		}
	}
	for(ll i=1;i<n;++i){
		for(ll j=i+1;j<=n;++j){
			if(s[i]=='R'&&s[j]=='G'||s[i]=='G'&&s[j]=='R'){
				ans+=b[j+1];
				if(j*2-i<=n){
					if(s[j*2-i]=='B') --ans;
				}
			}
			if(s[i]=='R'&&s[j]=='B'||s[i]=='B'&&s[j]=='R'){
				ans+=g[j+1];
				if(j*2-i<=n){
					if(s[j*2-i]=='G') --ans;
				}
			}
			if(s[i]=='G'&&s[j]=='B'||s[i]=='B'&&s[j]=='G'){
				ans+=r[j+1];
				if(j*2-i<=n){
					if(s[j*2-i]=='R') --ans;
				}
			}
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3940
from functools import lru_cache


N, X = [int(elem) for elem in input().split()]


h_burger = [None] * (N + 1)
h_burger[0] = 1
for i in range(1, N + 1):
    h_burger[i] = 3 + 2 * h_burger[i - 1]

@lru_cache(None)
def num_patti(l, x):
    if x == 0:
        return 0
    elif l == 0:
        return 1
    else:
        if x <= h_burger[l - 1] + 1:
            return num_patti(l - 1, x - 1)
        elif x == h_burger[l - 1] + 2:
            return num_patti(l - 1, h_burger[l - 1]) + 1
        else:
            return num_patti(l - 1, h_burger[l - 1]) + 1 \
                 + num_patti(l - 1, x - h_burger[l - 1] - 2)


print(num_patti(N, X))

Measured memory_bytes: 42224
// 全探索やね
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)
	SS := make([]string, N)
	for i, c := range []rune(S) {
		SS[i] = string(c)
	}
	ans := 0
	for i := 0; i < 1000; i++ {
		tmp := 0
		ss := stringfy(i)
		for _, sv := range SS {
			if ss[tmp] == sv {
				tmp++
			}
			if tmp == 3 {
				ans++
				break
			}
		}
	}
	fmt.Println(ans)
}

func stringfy(x int) []string {
	ss := fmt.Sprintf("%03d", x)
	ret := make([]string, len(ss))
	for i, c := range []rune(ss) {
		ret[i] = string(c)
	}
	return ret
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD = 1000000007;


long long modpow(long long a,long long n,long long MOD){
    int ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}

long long modinv(long long a, long long MOD) {
    return modpow(a, MOD - 2, MOD);
}

int main() {
    int X,Y;cin >> X >> Y;
    ll res = 0;
    ll fact[X] = {};
    fact[0] = 1;
    fact[1] = 1;
    for (int i = 2;i < X;i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    ll cmb = 0;
    for (int i = 0;i <= X;i++){
        if ((X - i) != (Y - (2 * i)) * 2) continue;
        ll b = Y - (2 * i);
        cmb = (fact[b + i] * modinv(fact[i],MOD) % MOD * modinv(fact[b],MOD) % MOD);
        cmb %= MOD;
        if (cmb < 0) cmb += MOD;
        res += cmb;
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 8064
<?php

    $s = in();
    $n = strlen($s);

    if (is_palindrome($s)) {
        $left = substr($s, 0, ($n - 1) / 2);
        $right = substr($s, (($n + 3) / 2) - 1);
        if (is_palindrome($left) && is_palindrome($right)) {
            yes();
        } else {
            no();
        }
    } else {
        no();
    }

    function is_palindrome($s) {  // 回文か
        return $s == strrev($s);
    }
    
    /**
    * お手伝い関数さんたち
    */
    function in() {
        return trim(fgets(STDIN));
    }
    function in_int() {
        return (int)in();
    }
    function in_vals() {
        return explode(' ', in());
    }
    function in_ints() {
        return array_map('intval', in_vals());
    }
    function out($s) {
        echo $s . PHP_EOL;
    }
    function yes() {
        out('Yes');
    }
    function no() {
        out('No');
    }
    function factorial($n) { // 階乗
        if ($n > 0) {
            return $n *= factorial($n - 1);
        }
        return 1;
    }



Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 驍ｨ・ｶ陝・ｽｾ陋滂ｽ､雎弱ｅ・∫ｹｧ繝ｻ笆ｽ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
  int N; cin>>N;
  vector<int> A(N);
  rep(i,N){
    cin>>A[i];
  }
  //配列の作成
  int count = 0 ;//操作回数
  int flag = 1;
    while(flag){
      flag = 0;
      for(int i = N-1 ; i >= 0; i--){
        int v=A[i];
        if(v<A[i-1]){
          A[i]=A[i-1];
          A[i-1]=v;
          flag = 1;
          count ++;
        }
      } 
    }
    rep(i,N){
      if(i) cout<<" ";
      cout<<A[i];
    }
    cout<<endl;
    cout<<count<<endl;
}



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

int main() {
  int N,R,K;
  long long ans;
  ans=100000000;
  cin>>N;
  int X[N];
  for(int i=0;i<N;i++){
    cin>>X[i];
  } 
 
  for(int i=1;i<101;i++){
    R=0;
    for(int j=0;j<N;j++){
      R+=(X[j]-i)*(X[j]-i);
    }
   if(R<ans){
     ans=R;
   }
  }
  cout <<ans<< endl;
}


Measured memory_bytes: 256
import collections

N=int(input())

Pair = [()]

for i in range(N):
	numst = str(i + 1)
	Pair.append((numst[0], numst[-1:]))

Pair = collections.Counter(Pair)
count = 0
for k1, v1 in Pair.items():
	for k2, v2 in Pair.items():
		if not k1 or not k2:
			continue
		elif k1[0]==k2[1] and k1[1]==k2[0]:
			count += v1*v2
print(count)

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

int gcd(int x, int y) {
	return (y == 0 ? x : gcd(y, x % y));
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(1000001);
	for (int i = 0; i < n ; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}

	bool isPairwise = true;
	for (int i = 2; i < 1000001; i++) {
		int same_divisor = 0;
		for (int j = i; j < 1000001; j += i) {
			same_divisor += cnt[j];	
		}
		if (same_divisor > 1) {
			isPairwise = false;
			break;
		}
	}
	if (isPairwise) {
		cout << "pairwise coprime\n";
		return 0;
	}

	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);		
	}
	if (g == 1) {
		cout << "setwise coprime\n";
		return 0;
	}
	cout << "not coprime\n";
	
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[2][n];
  for (int i=0; i<2; i++) {
    for (int j=0; j<n; j++) {
      cin>>a[i][j];
    }
  }
  int cnt[2][n];
  for (int i=0; i<2; i++) {
    for (int j=0; j<n; j++) {
      cnt[i][j] = 0;
    }
  }
  cnt[0][0] = a[0][0];
  for (int i=0; i<2; i++) {
    for (int j=0; j<n; j++) {
      if (i > 0) {
        cnt[i][j] = max(cnt[i-1][j] + a[i][j], cnt[i][j]);
      }
      if (j > 0) {
        cnt[i][j] = max(cnt[i][j-1] + a[i][j], cnt[i][j]);
      }
    }
  }
  cout<<cnt[1][n-1]<<endl;
}

Measured memory_bytes: 256
def judge(x):
  return 1 if x <= X else 0

N, X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = [0] * (N + 1)
for n in range(1, N + 1):
  D[n] = D[n - 1] + L[n - 1]
print(list(map(judge, D)).count(1))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int main(){
  int N;
  cin >> N;
  int a[N];
  int b[N];
  rep(i,N){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b,b+N,greater<int>());
  int m = b[0];
  rep(i,N){
    if(a[i] == m) cout << b[1] << endl;
    else cout << m << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
es = [{} for i in range(N)]
for l,r,d in src:
    es[l-1][r-1] = d
    es[r-1][l-1] = -d

dist = [None] * N
for i in range(N):
    if dist[i] is not None: continue
    dist[i] = 0
    stack = [i]
    while stack:
        v = stack.pop()
        for to,d in es[v].items():
            if dist[to] is not None:
                if dist[to] != dist[v]+d:
                    print('No')
                    exit()
                continue
            dist[to] = dist[v]+d
            stack.append(to)
print('Yes')

Measured memory_bytes: 92172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bitset<1000010>pk;
vector<ll>udd;
void eos(ll x)
{
    ll g,h,f;
    pk.set();
    pk[0]=pk[1]=0;
    for(h=4;h<=x;h+=2)pk[h]=0;
    udd.push_back(2);
    for(g=3;g<=x;g+=2)if(pk[g]){
        for(h=g*g,f=2*g;h<=x;h+=f)pk[h]=0;
        udd.push_back(g);
    }
}
int main()
{
    eos(1e6+7);
    int g,h,nt,re=0;
    ll q,x;
    scanf("%lld",&q);
    for(g=0;udd[g]*udd[g]<=q;g++){
        x=udd[g];
        nt=0;
        while(q%x==0){
            q/=x;
            nt++;
        }
        for(h=1;h<=nt;nt-=h,h++)
            re++;
    }
    if(q!=1)re++;
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 4176