akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  if (n % max(h, w) != 0)
    cout << n / max(h, w) + 1 << endl;
  else
    cout << n / max(h, w) << endl;
  return 0;
}

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

int main(){
    int n, cnt = 0;
    cin >> n;
    for (int i = 0; ; i++){
        if (cnt <= n){
            cnt += 1000;
        } else {
            break;
        }
    }
    if (n%1000 == 0){
        cnt -= 1000;
    }
    cout << cnt-n << endl;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

// 累積和（2次元）
template <class T>
class cumulativeSum
{
private:
    int ny, nx;
    vector<vector<T> > sum;
public:
    cumulativeSum(const vector<vector<T> >& a)
    {
        ny = a.size();
        nx = a[0].size();
        sum.assign(ny+1, vector<T>(nx+1, 0));
        for(int i=0; i<ny; ++i){
            for(int j=0; j<nx; ++j){
                sum[i+1][j+1] = a[i][j] + sum[i][j+1] + sum[i+1][j] - sum[i][j];
            }
        }
    }
    T getSum(int y1, int x1, int y2, int x2)
    {
        y1 = max(y1, 0);
        x1 = max(x1, 0);
        y2 = min(y2, ny-1);
        x2 = min(x2, nx-1);
        if(y1 > y2 || x1 > x2)
            return 0;
        return sum[y2+1][x2+1] - sum[y1][x2+1] - sum[y2+1][x1] + sum[y1][x1];
    }
};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int> > s(h, vector<int>(w, 0));
    int ey, ex;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            char c;
            cin >> c;
            if(c == 'E'){
                ey = y;
                ex = x;
            }
            else if(c == 'o'){
                s[y][x] = 1;
            }
        }
    }
    cumulativeSum<int> cs(s);

    int up    = ey;
    int down  = h - 1 - ey;
    int left  = ex;
    int right = w - 1 - ex;
    vector<vector<vector<vector<int> > > > dp(up+1, vector<vector<vector<int> > >(down+1, vector<vector<int> >(left+1, vector<int>(right+1, 0))));
    int ans = 0;
    for(int u=0; u<=up; ++u){
        for(int d=0; d<=down; ++d){
            for(int l=0; l<=left; ++l){
                for(int r=0; r<=right; ++r){
                    ans = max(ans, dp[u][d][l][r]);

                    int y1 = max(ey - u, d);
                    int y2 = min(ey + d, h - 1 - u);
                    if(ex - 1 - l >= r)
                        dp[u][d][l+1][r] = max(dp[u][d][l+1][r], dp[u][d][l][r] + cs.getSum(y1, ex - 1 - l, y2, ex - 1 - l));
                    if(ex + 1 + r <= w - 1 - l)
                        dp[u][d][l][r+1] = max(dp[u][d][l][r+1], dp[u][d][l][r] + cs.getSum(y1, ex + 1 + r, y2, ex + 1 + r));

                    int x1 = max(ex - l, r);
                    int x2 = min(ex + r, w - 1 - l);
                    if(ey - 1 - u >= d)
                        dp[u+1][d][l][r] = max(dp[u+1][d][l][r], dp[u][d][l][r] + cs.getSum(ey - 1 - u, x1, ey - 1 - u, x2));
                    if(ey + 1 + d <= h - 1 - u)
                        dp[u][d+1][l][r] = max(dp[u][d+1][l][r], dp[u][d][l][r] + cs.getSum(ey + 1 + d, x1, ey + 1 + d, x2));
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 32384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>
#include <deque>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  ll N, K;
  std::cin >> N >> K;
  std::vector< ll > vv(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vv[i];
  }

  ll ans = -INF;
  for (ll i = 0; i <= K; i++) {
    ll score = 0LL;
    for (ll j = 0; j <= K - i; j++) {
      for (ll m = 0; m <= K - i - j; m++) {
	if (i+j > N) continue;
	std::deque<ll> que;
	std::vector<ll> va;
	for (ll x = 0; x < N; x++) {
	  que.push_back(vv[x]);
	}
	for (ll x = 0; x < i; x++) {
	  va.push_back(que.front());
	  que.pop_front();
	}
	for (ll x = 0; x < j; x++) {
	  va.push_back(que.back());
	  que.pop_back();
	}
	std::sort(va.begin(), va.end());
	auto it = std::upper_bound(va.begin(), va.end(), 0LL);
	ll start_idx = std::min((ll)(it - va.begin()), m);
	score = std::accumulate(va.begin() + start_idx, va.end(), 0LL);
	//print(score, va);
	ans = std::max(ans, score);
      }
    }
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	map<string,int>mp;
	string s,ss,t;
	int a,b;
	cin>>s>>t>>a>>b;
	mp[s]=a;
	mp[t]=b;
	cin>>ss;
	mp[ss]--;
	cout<<mp[s]<<" "<<mp[t];
 	return 0;
}

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

#define mod 1000000007

long rec(char **grid, int h, int w, int i, int j, long **mem)
{
  if(i==h-1&&j==w-1)
    return 1;
  if(i>=h or j>=w)
    return 0;
  if(mem[i][j]!=-1)
    return mem[i][j];
  if(grid[i][j]=='#')
  {
  	mem[i][j]=0;
  	return mem[i][j];
  }
  long a=rec(grid,h,w,i+1,j,mem);
  long b=rec(grid,h,w,i,j+1,mem);
  mem[i][j]=(a%mod+b%mod)%mod;
  return mem[i][j];
}

int main(){
  int h,w;
  cin>>h>>w;
  char **grid=new char*[h];
  for(int i=0;i<h;i++)
  {
    grid[i]=new char[w];
    for(int j=0;j<w;j++)
      cin>>grid[i][j];
  }
  long **mem=new long*[h];
  for(int i=0;i<h;i++)
  {
    mem[i]=new long[w];
    for(int j=0;j<w;j++)
      mem[i][j]=-1;
  }
  cout<<rec(grid,h,w,0,0,mem);
  
  /*long dp[h+1][w+1];
  for(int i=0;i<=h;i++)
    dp[i][0]=0;
  for(int j=0;j<=w;j++)
    dp[0][j]=0;
  for(int i=1;i<=h;i++)
  {
    for(int j=1;j<=w;j++)
    {
      if(i==1&&j==1)
      {
        dp[i][j]=1;
        continue;
      }
      if(grid[i-1][j-1]=='#')
        dp[i][j]=0;
      else
      {
        dp[i][j]=(dp[i-1][j])%mod+(dp[i][j-1])%mod;
        dp[i][j]=(dp[i][j])%mod;
      }
    }
  }
  cout<<dp[h][w];*/
}

Measured memory_bytes: 9216
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h> 
#include <stack>
#include <bitset>
#include <map>
#include <cmath>
#include <climits>
#include <queue>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
	int k;
	string str;
	cin >> k >> str;
	if (str.size() > k) cout << str.substr(0, k) << "..." << endl;
	else cout << str << endl;
}

Measured memory_bytes: 3568
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	vpii up, down;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int closed_start = 0;

		int balance = 0;
		for (int i = 0; i < sz(s); i++)
		{
			if (s[i] == ')')
			{
				if (balance > 0)
					balance--;
				else
					closed_start++;
			}
			else
			{
				balance++;
			}
		}
		if (balance >= closed_start)
			up.emplace_back(closed_start, balance);
		else
			down.emplace_back(closed_start, balance);

	}
	sort(all(up));
	sort(all(down), [](const pii& l, const pii& r) { return l.second > r.second; });
	vpii a(up);

	for (auto& x : down)
		a.push_back(x);
	int balance = 0;
	for (auto& p : a)
	{
		balance -= p.first;
		if (balance < 0)
		{
			cout << "No";
			return 0;
		}
		balance += p.second;
	}
	cout << (balance == 0 ? "Yes" : "No");




	return 0;
}


Measured memory_bytes: 26788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int MAXN = 100000 + 5;
int pre[MAXN];
vector<int> st[MAXN];
int N, M;
int w[MAXN];
int cfind(int x) {
  if (pre[x] != x) pre[x] = cfind(pre[x]);
  return pre[x];
}
void cunion(int a, int b) {
  int h1 = cfind(a);
  int h2 = cfind(b);
  pre[h1] = h2;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  iota(pre, pre + N + 1, 0);
  for (int i = 0; i < N; ++i) {
    cin >> w[i];
  }

  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    cunion(a, b);
  }
  unordered_set<int> rts;
  for(int i = 0; i < N; ++i) {
    const int rt = cfind(i);
    auto &sst = st[rt];
    rts.insert(rt);
    sst.push_back(w[i]);
  }

  const int sn = rts.size();
  // cerr << "sn:  " << rts.size() << endl;
  
  if (sn == 1) {
    cout << 0;
    return 0;
  }
  for(auto &line: st) sort(line.begin(), line.end());
  ll sum = 0;
  vector<int> cs;
  for(auto c: rts) {
    sum += st[c][0];
    cs.insert(cs.end(), st[c].begin() + 1, st[c].end());
  }
  sort(cs.begin(), cs.end());
  if (cs.size() + 2 < sn) {
    cout << "Impossible";
    return 0;
  }
  for(int i = 0; i < sn - 2; ++i) {
    sum += cs[i];
  }
  cout << sum;
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> dp(n, 1e9);
    for (int& it : a)
        cin >> it;
    dp[0] = 0;
    for (int i = 1; i < n; i++)
        for (int j = 1; j <= min(k, i); j++)
            dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]);
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3972
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    
    sum_A = sum(A)
    sub_sum = A[0]
    ret = abs(sum_A-2*sub_sum)
    for a in A[1:-1]:
        sub_sum += a
        if abs(sum_A-2*sub_sum) < ret:
            ret = abs(sum_A-2*sub_sum)
            
    print(ret)
    
solve()

Measured memory_bytes: 24812
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  RL(A);
  std::vector<std::string> cand(26); // cand[i] = (i で終わる最短文字列)
  for(int i=0;i<26;i++)cand[i] = 'a'+i;

  auto shortest=[&]() -> std::string const& {
    int jmin=0;
    for(int j=1;j<26;j++){
      if(cand[j].size() < cand[jmin].size()) jmin=j;
      else if(cand[j].size() == cand[jmin].size() && cand[j] < cand[jmin]) jmin=j;
    }
    return cand[jmin];
  };

  for(auto a:A){
    int i = a-'a';
    cand[i] = shortest() + a;
  }
  P(shortest());
  return 0;
}


Measured memory_bytes: 1004
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=1005;

//a 1*2
//b 2*1
int n,m,a,b,s,sa,sb;
char g[N][N];

void puta(int x,int y){ --a,g[x][y]='<',g[x][y+1]='>'; }
void putb(int x,int y){ --b,g[x][y]='^',g[x+1][y]='v'; }

void put1(){
	if(n&1){
		for(int j=1;j+1<=m;j+=2)if(a)puta(n,j);
	}
	if(m&1){
		for(int i=1;i+1<=n;i+=2)if(b)putb(i,m);
	}
	for(int i=1;i+1<=n;i+=2){
		for(int j=1;j+1<=m;j+=2){
			if(a>=2){
				puta(i,j),puta(i+1,j);
			}else if(b>=2){
				putb(i,j),putb(i,j+1);
			}else if(a){
				puta(i,j);
			}else if(b){
				putb(i,j);
			}
		}
	}
}

void puta2(int x,int y){ 
	if(x>=n-2&&y>=m-2)return;
	--a,g[x][y]='<',g[x][y+1]='>'; 
}

void putb2(int x,int y){ 
	if(x>=n-2&&y>=m-2)return;
	--b,g[x][y]='^',g[x+1][y]='v'; 
}

void put2(){
	int x=n-2,y=m-2;
	g[x][y]='<',g[x][y+1]='>',g[x][y+2]='^';
	g[x+1][y]='^',g[x+1][y+1]='.',g[x+1][y+2]='v';
	g[x+2][y]='v',g[x+2][y+1]='<',g[x+2][y+2]='>';
	a-=2,b-=2;

	if(n&1){
		for(int j=1;j+1<=m;j+=2)if(a>0)puta2(n,j);
	}
	if(m&1){
		for(int i=1;i+1<=n;i+=2)if(b>0)putb2(i,m);
	}
	for(int i=1;i+1<=n;i+=2){
		for(int j=1;j+1<=m;j+=2){
			if(a>=2){
				puta2(i,j),puta2(i+1,j);
			}else if(b>=2){
				putb2(i,j),putb2(i,j+1);
			}else if(a){
				puta2(i,j);
			}else if(b){
				putb2(i,j);
			}
		}
	}
}

int main(int argc,char *argv[]){
	cin>>n>>m>>a>>b;	
	s=n*m/2,sa=n*(m/2),sb=m*(n/2);
	rep(i,1,n)rep(j,1,m)g[i][j]='.';
	if(a+b>s){
	}
	else if(a+b==s&&a%2!=sa%2){
		if(n*m%2==1){
			if(n*m>=9)put2();
		}
	}else {
		put1();
	}
	if(a==0&&b==0){
		puts("YES");
		rep(i,1,n){
			rep(j,1,m)putchar(g[i][j]);
			puts("");
		}
	}else puts("NO");
	return 0;
}




Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  ll min_diff = INF, min_id;
  for (int i = 0; i < N; i++) {
    if (abs(N * a[i] - sum) < min_diff) {
      min_diff = abs(N * a[i] - sum);
      min_id = i;
    }
  }
  cout << min_id << endl;
  return 0;
}

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

int main() {
	string N;
	cin >> N;
  	
  	if( N.size() % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  	
  	for(int i = 0; i < N.size()-1; i+=2){
      if(N.at(i) != 'h' || N.at(i+1) != 'i'){
        cout << "No" << endl;
        return 0;
      }
    }
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int s[110]={0};
    int a[110]={0};
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int maxx=a[0];
    for(int i=0;i<n;i++)
        if(a[i]>maxx) maxx=a[i];
    for(int i=1;i<=maxx;i++)
        for(int j=0;j<n;j++)
            s[i]+=(a[j]-i)*(a[j]-i);
    int minn=s[1];
    for(int i=1;i<=maxx;i++)
        if(s[i]<minn) minn=s[i];
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    double r;
    scanf("%lf", &r);

    double s = r * r * 3.141592653589;
    double l = 2 * r * 3.141592653589;
   

    printf("%8.6f %8.6f\n",s,l);
    
    
    return 0;
}


Measured memory_bytes: 2136
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    ll ans = N * (N - 1)/2 + M * (M - 1) / 2;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> data;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;

        data.push_back(tmp);

    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int count = 0;
        for (int j = 0; j < i; j++) {
            if (data[i] >= data[j]) {
                count++;
//                cout << "i = " << i << "j = " << j << endl;
            }
        }
        if (count == i) {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
  let n: i32 = read();
  let a: i32 = read();
  
  println!("{}", n*n-a);
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
long long int a[1000000];
int x;
void build(int n){
    long long int temp;
    int top=n,l=n*2,r=n*2+1;
    if(a[r]>a[n]&&r<=x)top=r;
    if(a[l]>a[top]&&l<=x)top=l;
    if(top!=n){
        temp=a[top];
        a[top]=a[n];
        a[n]=temp;
        build(top);
    }
}
int main(){
    scanf("%d",&x);
    for(int i=1;i<=x;i++){
        scanf("%lld",&a[i]);
        a[i*2]=a[i*2+1]=0;
    }
    for(int i=x/2;i>0;i--){
        build(i);
    }
    for(int i=1;i<=x;i++){
        printf(" %lld",a[i]);
    }
    printf("\n");
}

Measured memory_bytes: 10392
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
for i in range(n):
  if a[i] >= b[i]:
    count += b[i]
  else:
    count += min(b[i], a[i]+a[i+1])
    a[i+1] = max(0, a[i+1]-(b[i]-a[i]))
print(count)

Measured memory_bytes: 19116
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double pi = acos(-1) ;
signed main(){
    fastio
    int r ;
    cin >> r ;
    double ans = r * pi * 2.0 ;
    cout << fixed << setprecision(9) << ans << endl;
    return 0; 
}

Measured memory_bytes: 3800
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int a[5];
    rep(i, 5) cin >> a[i];
    int k;
    cin >> k;
    rep(i, 4){
        for (int j = i + 1; j < 5; j++){
            if (a[j] - a[i] > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
<?php
while(list($n, $x) = explode(" ", trim(fgets(STDIN)))){
    if($n == 0 && $x == 0){
        return 1;
    }
    $count = 0;
    for($i = 1; $i <= $n; $i++){
        for($j = 1; $j <= $n; $j++){
            for($k = 1; $k <= $n; $k++){
                if($i > $j && $j > $k &&  $i + $j + $k == $x){
                    $count += 1;
                }
            }
        }
    }
    echo $count.PHP_EOL;
}

Measured memory_bytes: 15148
N = int(input())
R = [[int(a) for a in input().split()] for _ in range(N)]
B = [[int(c) for c in input().split()] for _ in range(N)]

B.sort()
used = [0]*N

for i in range(N):
    y = -1
    idx = -1
    for j in range(N):
        if R[j][0] < B[i][0] and R[j][1] < B[i][1] and used[j] == 0:
            if R[j][1] > y:
                y = R[j][1]
                idx = j
                
    if idx >= 0:
        used[idx] = 1
        
print(sum(used))

Measured memory_bytes: 3064
MOD = 100000007
r, c, a1, a2, b1, b2 = map(int, input().split())
dx = abs(a1 - b1)
dy = abs(a2 - b2)
cnt = 1
if dx * 2 == r:cnt *= 2
if dy * 2 == c:cnt *= 2
dx = min(dx, r - dx)
dy = min(dy, c - dy)

dp = [[0] * (dx + 2) for _ in range(dy + 2)]
dp[0][1] = 1
for y in range(1, dy + 2):
    for x in range(1, dx + 2):
        dp[y][x] = (dp[y - 1][x] + dp[y][x - 1]) % MOD
print(dp[dy + 1][dx + 1] * cnt % MOD)


Measured memory_bytes: 15516
import Data.List hiding (find)
import Data.Array as A
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Graph
import Control.Monad
import Control.Monad.ST

type DP s = STUArray s Int Int

--DFS
dp_i :: DP s -> Graph -> Vertex -> Int -> ST s Int
dp_i dparr graph v0 n | graph A.! v0 == [] = return 0
                      | otherwise = do
   let vs = graph A.! v0
   forM_ vs $ \v -> do
     dpv0 <- readArray dparr v0
     dpv <- readArray dparr v
     dpv' <- if dpv == 0 then dp_i dparr graph v n >> readArray dparr v else return dpv
     writeArray dparr v0 $ max dpv0 (dpv'+1)
   dpv0' <- readArray dparr v0
   return dpv0'

solve :: [Edge] -> Int -> Int -> ST s Int
solve ls n m = do
  let graph = buildG (1,n) ls
  dparr <- newArray (1,n) 0
  list <- forM [1..n] $ \v0 -> dp_i dparr graph v0 n
  debug <- forM [1..n] $ readArray dparr
  let ans = maximum list
  return ans

main :: IO ()
main = do
  [n,m] <- map read.words <$> getLine
  ls <- replicateM m $ do
    (x:y:e) <- map read.words <$> getLine
    return (x,y)
  putStrLn $ show $ runST $ solve ls n m


Measured memory_bytes: 91644
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,p = readInts()
print((a*3 + p)//2)


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

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

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string n; cin>>n;
    int N=n.size();
    int k; cin>>k;
    vector<vector<int>> dpv(N,vector<int>(k+1,0)),dpi(N,vector<int>(k+1,0));
    dpv[0][1]=1; dpi[0][1]=n[0]-'0'-1; dpi[0][0]=1;
    for(int i=1;i<N;i++){
        if(n[i]=='0'){
            rep(j,k+1){
                dpv[i][j]=dpv[i-1][j];
                if(j==0){
                    dpi[i][0]=dpi[i-1][0];
                    continue;
                }
                dpi[i][j]=dpi[i-1][j-1]*9+dpi[i-1][j];
            }
        }
        else{
            rep(j,k+1){
                if(j==0){
                    dpi[i][0]=dpi[i-1][0];
                    continue;
                }
                dpv[i][j]=dpv[i-1][j-1];
                dpi[i][j]=dpi[i-1][j]+dpi[i-1][j-1]*9;
                dpi[i][j]+=dpv[i-1][j-1]*(n[i]-'0'-1)+dpv[i-1][j];
            }
        }
    }
    cout<<dpi.back()[k]+dpv.back()[k]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
typedef long long ll;
using namespace std;
int main(void)
{
	string s;
	cin>>s;
	if(s[1]=='B')cout<<"ARC";
	else cout<<"ABC";
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
Created on Sat Jan  5 10:49:47 2019

@author: Yamazaki Kenichi
"""

H,W,K = map(int, input().split())
mod = 10**9 +7
a = [1,1,2,3,5,8,13,21]
T = [[-1 for i in range(9)] for i in range(H+1) ]
def n(h,k):
    if T[h][k] != -1:
        return T[h][k]
    res = 0
    if h == 1:
        if k == 1 or k == 2:
            T[h][k] = a[W-k]
            return a[W-k]
        else:
            T[h][k] = 0
            return 0
    res += n(h-1,k)*(a[k-1] * a[W-k])
    if k != 1:
        res += n(h-1,k-1)*(a[k-1-1] * a[W-k])
    if k != W:
        res += n(h-1,k+1)*(a[k-1] * a[W-k-1])
    T[h][k] = res
    return res % mod
ans = n(H,K)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
using namespace	std;
int main() {
  int H[100], W[100];
  int counter =	100;
  for (int i=0; i <= 100; i++) {
    cin >> H[i] >> W[i];
    if (H[i] ==	0 && W[i] == 0) {
      counter =	i;
      break;
    }
  }
  for (int i=0;i <= counter-1; i++) {
    for(int j=1; j <= H[i]; j++) {
      for (int k=1; k <= W[i]; k++) {
	cout <<	"#";
      } 
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
int main(){
int max=0,n,k,a[100010],b[100010],i;
while(1){
scanf("%d %d\n",&n,&k);
if(n==0 && k==0){
break;
}
for(i=0;i<n;i++){
scanf("%d\n",&a[i]);
}
b[0]=0;
for(i=0;i<n;i++){
b[i+1]=b[i]+a[i];
}
for(i=k;i<=n;i++){
if(max<b[i]-b[i-k]){
max=b[i]-b[i-k];
}
}
printf("%d\n",max);
max=0;
}
return 0;
}


Measured memory_bytes: 2492
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int arr[] = new int[n];
        for(int i = 0;i < n;i++)arr[i] = scan.nextInt();
        for(int i = n-1;i >= 0;i--){
            if(i != n-1)System.out.print(" ");
            System.out.print(arr[i]);
        }
        System.out.println();

        scan.close();
    }

    

}


Measured memory_bytes: 26268
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define dblout(x) cout << setprecision(x) << fixed;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 998244353;
const int MAXN = 2e5 + 5;

ll dp[MAXN], suff[MAXN];

void cp()
{
    int n, k;
    cin >> n >> k;
    vector<pi> arr(k);
    for(pi &x : arr)
        cin >> x.ff >> x.ss;
    dp[n] = suff[n] = 1;
    for(int i = n - 1; i >= 1; i--)
    {
        for(int j = 0; j < k; j++)
        {
            int l = i + arr[j].ff;
            int r = i + arr[j].ss;
            r = min(r, n);
            if(l <= r)
                dp[i] = (dp[i] + suff[l] - suff[r + 1] + mod) % mod;
        }
        suff[i] = (dp[i] + suff[i + 1]) % mod;
    }
    cout << dp[1] << endl;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int a=0,b=0,c=0;
    
    ll ans=1;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    for(int i=0;i<N;i++){
        if(a==b&&b==c){
            if(A[i]==a){
                ans*=3;
                a++;
            }else ans=0;
        }else if(a==b){
            if(A[i]==a){
                ans*=2;
                a++;
            }else if(A[i]==c){
                ans*=1;
                c++;
            }else ans=0;
        }else if(b==c){
            if(A[i]==a){
                ans*=1;
                a++;
            }else if(A[i]==b){
                ans*=2;
                b++;
            }else ans=0;
        }else{
            if(A[i]==a){
                a++;
            }else if(A[i]==b){
                b++;
            }else if(A[i]==c){
                c++;
            }else ans=0;
        }
        
        ans%=mod;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ; cin >> n;
	vector<ld>x(n),y(n);
	rep(i,0,n){
		cin >> x[i] >> y[i];
	}
	ld ans = 0 ;
	rep(i,0,n){
		rep(j,0,i){
			ans+=hypot(x[i]-x[j],y[i]-y[j]);
		}
	}
	ans*=2;
	cout << fixed << setprecision(12) << ans/n << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int X;
    cin >> X;
    
    for(int i=1;i<=100000;i++){
        if(100*i <= X && X <= 105*i){
            cout << 1 << endl;
            return 0;
        }    
    }
    cout << 0 << endl;

}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = (1LL<<31)-1;
const int mod = 1e9 + 7;

struct SegmentTree {
  vector<int> sum;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz <<= 1;
    sum.resize(2*sz-1, 0);
  }
  void update(int k, int x) {
    k += sz-1;
    sum[k] += x;
    while(k > 0) {
      k = (k-1) / 2;
      sum[k] = sum[2*k+1] + sum[2*k+2];
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sum[k];
    return query(a, b, 2*k+1, l, (l+r)/2)
      + query(a, b, 2*k+2, (l+r)/2, r);
  }
  int query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, q;
  cin >> n >> q;
  SegmentTree seg(n);
  rep(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if(com == 0) seg.update(x-1, y);
    else cout << seg.query(x-1, y) << endl;
  }

  return 0;
}

Measured memory_bytes: 4928
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, m = map(int, input().split())
    path = [0] * n
    for _ in range(m):
        a, b = map(int, input().split())
        path[a - 1] += 1
        path[b - 1] += 1
    for p in path: print(p)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62212
#include <stdio.h>
int main() {
  
long long int a, b, n;
scanf("%lld", &a);
scanf("%lld", &b);
scanf("%lld", &n);

long long int x = b - 1;
long long int t = 2;
long long int maxnum = -1;
long long int tmp = 0;

if (x < n){
 tmp = a * x / b - x / b * a;
 if (maxnum < tmp){
   maxnum = tmp;
 }
} 
x = n;
tmp = a * x / b - x / b * a;
if (maxnum < tmp){
  maxnum = tmp;
}

printf("%lld", maxnum);

}

Measured memory_bytes: 1732
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])

    num=1
    while num < n:
        num *= 2
    num-=1
    inf=10**9+1

    m=num+n
    segtree=[inf]*m
    for i in range(num,m):
        segtree[i] = ab[i - num][0]
    for i in range(num-1,-1,-1):
        j=2*i+1
        if j>=m:
            segtree[i]=inf
        elif j+1>=m:
            segtree[i]=segtree[j]
        else:
            segtree[i] = min(segtree[j], segtree[j + 1])

    #探す
    def search(s):
        i=0
        while i < num:
            k = 2 * i + 1
            if k+2<=m:
                if segtree[k+1] <= s:
                    i = k + 1
                    continue
            if k+1<=m:
                if segtree[k] <= s:
                    i = k
                    continue
            return - 1
        return i - num
    
    #更新
    def update_good(i, s):
        while True:
            if segtree[i] > s:
                segtree[i] = s
                i = (i - 1) // 2
                continue
            break
    
    def update_bad(i):
        while i!=0:
            k=(i - 1) // 2
            if i % 2 == 1:
                if m > i + 1:
                    temp=min(segtree[i+1],segtree[i])
                    if segtree[k]<temp:
                        segtree[k] = temp
                        i = k
                        continue
                else:
                    segtree[k] = segtree[i]
                    i = k
                    continue
            else:
                temp=min(segtree[i-1],segtree[i])
                if segtree[k]<temp:
                    segtree[k] = temp
                    i = k
                    continue
            break

    cnt = 0
    for i in range(n):
        a,b=ab[i][0],ab[i][1]
        if a > b:
            t = search(b)
            if t <= i:
                print("No")
                return 0
            update_good(num + i, a)
            segtree[num + t] = a
            update_bad(num + t)
            ab[i][0], ab[t][0] = ab[t][0], a
            cnt+=1
    if cnt <= n - 2:
        print("Yes")
    else:
        print("No")
    
main()

Measured memory_bytes: 26976
n, t = map(int,input().split())
a = []
for i in range(0, n, 1):
    wk = list(map(int,input().split()))
    if wk[1] <= t:
        a.append(wk[0])
if len(a) > 0:
    print(min(a))
else:
    print("TLE")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
    int d;
    cin >> d;
    if (d == 22) {
        cout << "Christmas Eve Eve Eve";
    }
    if (d == 23) {
        cout << "Christmas Eve Eve";
    }
    if (d == 24) {
        cout << "Christmas Eve";
    }
    if (d == 25) {
        cout << "Christmas";
    }
}

Measured memory_bytes: 256
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):      #s[i]
    for d in range(n):
        j = i + d       #s[j]　s[i]etcこれらは等間隔となるが
        k = j + d       #s[k]　この時点でi!=j, j!=k, i!=k
        if k >= n:break #kが一番大きいが、n以上になることはない
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1    #等間隔でRGB揃っているものを引く

print(ans)


Measured memory_bytes: 68280
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

typedef struct{
    int a;
    int b;
} War;

int compare(const void *b1, const void *b2){ // 昇順
    if(((War*)b1)->b > ((War*)b2)->b) return 1;
    else if(((War*)b1)->b < ((War*)b2)->b) return -1;
    else return 0;
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    
    War data[m];
    F(i,0,m){
        scanf("%d%d",&(data[i].a),&(data[i].b));
    }
    
    qsort(data,m,sizeof(War),compare);

    int rem_num=0;
    F(j,0,m){
        if(data[j].b != 0){
            F(k,j+1,m){
                if(data[k].a<data[j].b){
                    data[k].a=0;
                    data[k].b=0;
                }
            }
            rem_num++;
        }
    }
    printf("%d\n",rem_num);
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, ans; cin >> A >> B;
    ans = (A*B) - ((A + B) - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    let abc = read_vec::<i32>();
    let r = abc[2] - (abc[0] - abc[1]);
    if r >= 0 {
        println!("{}", r);   
    } else {
        println!("0");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

int main() {
  
    int n;
    cin >> n;
    vector<pair<int, int>> vp(n);
    REP(i,n) {
        cin >> vp[i].first >> vp[i].second;
    }

    for (int i=0; i<=n-3; i++) {
        if (vp[i].first == vp[i].second && vp[i+1].first == vp[i+1].second && vp[i+2].first == vp[i+2].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1e9+7;
ll jc[200010],inv[200010];
ll qp(ll a,ll b,ll mod){
	ll ans=1;
	while(b){
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll getInv(ll x,ll p){
	return qp(x,p-2,p);
}
ll n,a,b,ans;
int main(){
	cin>>n>>a>>b;
	if(n==2){
		puts("0");
		return 0;
	}
	ans=qp(2,n,mod);
	ans--;
	ll tmp1=1,tmp2=1;
	for(ll i=n;i>=n-a+1;i--){
		tmp1=tmp1*i%mod;
		tmp1=tmp1*getInv(n-i+1,mod)%mod;
	}
	for(ll i=n;i>=n-b+1;i--){
		tmp2=tmp2*i%mod;
		tmp2=tmp2*getInv(n-i+1,mod)%mod;
	}
	ans-=tmp1;ans-=tmp2;
	ans=(ans%mod+mod)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main()
{
	int n, k;
	cin >> n >> k;

	vi x(n);
	REP(i, n)cin >> x[i];

	SORT(x);

	int min = INT_MAX;


	REP(i, n - k + 1) {
		int d = abs(x[i]) + abs(x[i + k -1] - x[i]);
		if (d < min) min = d;
		d = abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]);
		if (d < min) min = d;
	}

	cout << min << endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

int main(){
  ll i,N,w,a=-1,b;
  cin>>N>>w>>w;
  rep(i,N-1)cin>>a;
  cin>>b;
  if(a<0){cout<<labs(w-b)<<endl;}
  else{cout<<max(labs(a-b),labs(w-b))<<endl;}
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int inp;
    cin >> inp;
    a[i] = inp;
    sum += inp;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (4 * m * a[i] >= sum) ++cnt;

  if (cnt >= m)
    cout << "Yes\n";
  else
    cout << "No\n";
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    if (s.length() == 2) {
      System.out.println(s);
    } else {
      System.out.println(reverseString(s));
    }

  }

  static String reverseString(String s) {
    StringBuffer str = new StringBuffer(s);
    return str.reverse().toString();
  }

}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  for(double i = 1; i < 50000.0; i++){
    if(i * 1.08 >= N){
      if(i * 1.08 - N >= 1.0){
        cout << ":(" << endl;
        break;
      }else{
        int x = i;
        cout << x << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256