akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

ll N,M,K,H,W;

vector<ll> v;
int main(){
	cin >> H >> W;
	vector<vector<ll>> dp(H, vector<ll> (W, 0LL));
	char s;
	dp[0][0] = 1;
	REP(i, H){
		REP(j, W){
			cin >> s;
			if(s == '#') continue;
			if(j > 0) dp[i][j] += dp[i][j-1]%MOD;
			if(i > 0) dp[i][j] += dp[i-1][j]%MOD;
			dp[i][j]%MOD;
       //   	cout << dp[i][j] << " ";
		}
     // cout << "\n";
	}
	cout << dp[H-1][W-1]%MOD ;
	return 0;
}
//345263555



Measured memory_bytes: 8064
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	int x,y,t;
	int c=0, h=0;
	while(~scanf("%d,%d,%d", &x, &y, &t)){
		if(x==y)h++;
		if(x*x+y*y==t*t)c++;
	}
	cout<<c<<endl<<h<<endl;
	
	return 0;
}

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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)

	

	int32_t main()
	{

	  

	  int x;
	  cin >> x;
	  int base=100,interest=1,ans=0;

	  while(base+interest<x)
	  {
	  	ans++;
	  	base=(base+interest);
	  	interest=base/100;
	  }

	  cout<<ans+1;

	}

Measured memory_bytes: 3604
H, W = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]

C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]

D = 80 * (H + W) + 1
D2 = D * 2

dp = [[0] * W for _ in range(H)]

dp[0][0] |= 1 << (D + C[0][0])
dp[0][0] |= 1 << (D - C[0][0])

for h in range(H):
    for w in range(W):
        c = C[h][w]
        if h >= 1:
            dp[h][w] |= dp[h - 1][w] << c
            dp[h][w] |= dp[h - 1][w] >> c
        if w >= 1:
            dp[h][w] |= dp[h][w - 1] << c
            dp[h][w] |= dp[h][w - 1] >> c

ans = D2
tmp = dp[H - 1][W - 1]

for i in range(D2):
    if (tmp >> i) & 1:
        ans = min(ans, abs(i - D))

print (ans)

Measured memory_bytes: 20340
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    string s;cin >> s;
    if(s[s.size()-1]!='s')cout << s+'s' << endl;
    else cout << s+"es" << endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
    {
        cout << "bust" << endl;
    }
    else if (a + b + c <= 21)
    {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int a,b,c,r[201];
int dep[201][201];
bool used[201];
int N,M,R;
long long ans=0;
long long inf=1000000007;

void dfs(int c,int las,int dist)
{
  if(c==R+1)
    {
      if(ans>dist) ans=dist;
      return;
    }
  for(int i=1;i<=R;i++)
    {
      if(!used[i])
	{
	  used[i]=true;
	  if(las==-1)dfs(c+1,i,0);
	  else {
	    dfs(c+1,i,dist+dep[r[las]][r[i]]);
	  }
	  used[i]=false;
	}
    }
}
void floyd()
{
  for(int k=1;k<=N;k++)
    {
      for(int i=1;i<=N;i++)
	{
	  for(int j=1;j<=N;j++)
	    {
	      dep[i][j]=min(dep[i][j],dep[i][k]+dep[k][j]);
	    }
	}
    }
}
int main()
{
  cin >> N >> M >> R;
  for(int i=1;i<=R;i++)
    {
      cin >> r[i];
    }
  for(int i=1;i<=N;i++)
    {
      for(int j=1;j<=N;j++)
	{
	  if(i!=j)dep[i][j]=inf;
	}
    }
  for(int i=1;i<=M;i++)
    {
      cin >> a >> b >> c;
      if(dep[a][b]>c){dep[a][b]=dep[b][a]=c;}
    }
  floyd();
  ans=inf;
  dfs(1,-1,0);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	string s; cin >> s;
	int ans = 0;
	int g = 1, p = 0;
	for (int i = 1; i < s.size(); ++i) {
		if (g > p&&s[i]=='p')++p;
		else if (g > p&&s[i] == 'g') {
			++p;
			++ans;
		}
		else if (g == p && s[i] == 'p') {
			++g;
			--ans;
		}
		else ++g;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
using namespace std;

int main()
{
	
	int n;
	cin>>n;
    cout<<n*(n+1)/2<<endl;
	return 0;
	
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int a,b,c,swap;
    scanf("%d %d %d",&a,&b,&c);
    swap = a;
    a = b;
    b = swap;
//    printf("%d %d %d %d\n",a,b,c,swap1);
    swap = a;
    a = c;
    c = swap;
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

db xs,ys,xt,yt;
int n;
db dist[1010][1010];
bool vis[1010];

struct barrier {
    db x,y,r;
} b[1010];

struct node {
    int id;
    db dist;
    node(int i,db d) : id(i),dist(d){}
    bool operator<(const node& rhs) const {
        return dist>rhs.dist;
    }
};

db dist1(barrier& bar,db x,db y) {
    db dx=bar.x-x,dy=bar.y-y;
    return max(sqrt(dx*dx+dy*dy)-bar.r,0.0);
}

db dist2(barrier& lhs,barrier& rhs) {
    db dx=lhs.x-rhs.x,dy=lhs.y-rhs.y;
    return max(0.0,sqrt(dx*dx+dy*dy)-lhs.r-rhs.r);
}

int main() {
    scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%lf%lf%lf",&b[i].x,&b[i].y,&b[i].r);
        dist[0][i]=dist[i][0]=dist1(b[i],xs,ys);
        dist[n+1][i]=dist[i][n+1]=dist1(b[i],xt,yt);
        dist[0][n+1]=dist[n+1][0]=sqrt((xs-xt)*(xs-xt)+(ys-yt)*(ys-yt));
    }

    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            dist[i][j]=dist[j][i]=dist2(b[i],b[j]);
        }
    }
    db ans=0.0f;
    priority_queue<node> pq;
    pq.push(node(0,0.0));
    memset(vis,0,sizeof(vis));
    while (!pq.empty()) {
        node cur=pq.top();//printf("cur:%d %.5f\n",cur.id,cur.dist);
        pq.pop();
        if (vis[cur.id]) continue;
        vis[cur.id]=true;
        if (cur.id==n+1) {
            ans=cur.dist;
            break;
        }
        for (int i=1;i<=n+1;i++) {
            if (i!=cur.id&&!vis[i]) {
                pq.push(node(i,cur.dist+dist[cur.id][i]));
            }
        }
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 16492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

using PII = pair<int,int>;

// 素数列挙 (エラトステネスの篩)
vector<bool> primes_create(ll n){
  vector<bool> primes(n+1, true);
	primes[0] = primes[1] = false;
  for(ll i=2L; i*i<=n; ++i){
		ll ix = i + i;
		while(ix <= n){
			primes[ix] = false;
			ix += i;
		}
  }
  return primes;
}

int main(){
	vector<bool> primes = primes_create(100000+1);
	vi C(primes.size());//Cumulative sum
	rp(n, 1, primes.size()) C[n] += C[n-1] + (primes[n] && (n+1)%2==0 && primes[(n+1)/2]);

	// rpz(i,primes.size()){printf("%d\n",C[i]);}puts("");//

	int Q; cin>>Q;
	vi ans(Q);
	rpz(i, Q){
		int l,r; cin>>l>>r;
		cout<< C[r] - C[l] + (C[l]!=C[l-1]) <<endl;
	}
}

Measured memory_bytes: 1408
n, m = map(int, input().split())

par = [-1]*n
num = [0]*n

def find(x):
    if par[x]<0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def union(x, y):
    p,q=find(x), find(y)
    if p==q:
        return
    if p>q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p

def size(x):
    return -par[find(x)]

def same(x,y):
    return find(x)==find(y)

lst=[]
for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    lst.append((a,b))

ans=0

for i in range(m):
    L=lst[:i]+lst[i+1:]
    par=[-1]*n
    for l in L:
        union(l[0],l[1])
    if [p<0 for p in par].count(1)>1:
        ans+=1

print(ans)

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

int main() {
  int N,D,X;
  cin>>N>>D>>X;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int a=0;
  for(int i=1;i<=D;i++){
    for(int j=0;j<N;j++){
      for(int k=1;k<=D;k++){
      if(i==1+(k-1)*A.at(j)){
        a++;
      }
    }
  }
  }
  cout<<a+X<< endl;
}
      
      



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,c;
const int maxn=1e5+100;
int x[maxn],v[maxn];
int sa[maxn],sb[maxn];
int maxv=0;
priority_queue < int > q;
void solve(){
	memset(sa,0,sizeof(sa));
	memset(sb,0,sizeof(sb));
	for (int i=1;i<=n;i++){
		sa[i]=sa[i-1]+v[i]-(x[i]-x[i-1]);
	}
	x[n+1]=c;
	for (int i=n;i>=1;i--){
		sb[i]=sb[i+1]+v[i]-((c-x[i])-(c-x[i+1]));
	}
//	for (int i=1;i<=n;i++) cout << sa[i] << ' ';
//	cout << endl;
	for (int i=1;i<=n;i++){
		maxv=max(maxv,sa[i]);
	}
//	cout << "maxv=" << maxv << endl;
	while (!q.empty()) q.pop();
	q.push(0);
	for (int i=n;i>=1;i--){
		int u=q.top();
//		cout << "u=" << u << endl;
		maxv=max(maxv,u+sa[i]-x[i]);
//		cout << "max=" << maxv << endl; 
		q.push(sb[i]);
	}
}
signed main(){
	cin >> n >> c;
	for (int i=1;i<=n;i++){
		cin >> x[i] >> v[i];
	}
	solve();
//	cout << maxv << endl;
	for (int i=1;i<=n;i++) x[i]=c-x[i];
	for (int i=1;i<=n/2;i++){
		swap(x[i],x[n-i+1]);
		swap(v[i],v[n-i+1]);
	}
	solve();
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 4472
N, K = gets.split.map(&:to_i)
v_list = gets.split.map(&:to_i)

comb_list = []
(0..([N, K].min)).each do |a|
  (0..([N, K].min - a)).each do |b|
    max_drop_count = K - a - b
    comb_list.push([a, b, max_drop_count])
  end
end

ans = -(2 << 60)
comb_list.each do |(a, b, drop_c)|
  nums = []
  nums = nums + v_list.take(a) if a > 0
  nums = nums + v_list[-b..-1] if b > 0
  nums.sort!
  while drop_c > 0 && !nums.empty? && nums[0] < 0
    nums.shift
    drop_c -= 1
  end
  sum = nums.reduce(0, &:+)
  ans = sum if sum > ans
end
puts ans


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

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

    // printf("%d\n", 'A');
    // printf("%d\n", 'Z');

    string S;
    cin >> S;
    for (int i = 0; i < (int)S.size(); ++i)
    {
        int c = (S[i] + N);
        if(c > 90) {
            c -= 26;
        }

        printf("%c", c);
    }
    cout << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
int main()
{
    fast;
  
    string s;
    cin>>s;
    string s1 = "";
    string s2 = "";
    ll i,op = 0;
    ll q;
    cin>>q;
    while(q--)
    {
    	ll ti;
    	cin>>ti;
    	if(ti==1) op++;
    	else
    	{
    		ll fi;
    		char c;
    		cin>>fi>>c;
    		if(fi==1)
    		{
    			if(op&1) s2 += c;
    			else s1 += c;
    		}
    		else
    		{
    			if(op&1) s1 += c;
    			else s2 += c;
    		}
    	}
    }
    string ans;
    if(op&1)
    {
    	reverse(all(s));
    	reverse(all(s2));
    	ans = s2 + s + s1;
    }
    else
    {
    	reverse(all(s1));
    	ans = s1 + s + s2;
    }
    cout<<ans;
}

Measured memory_bytes: 1300
from collections import deque

n,m = map(int,input().split())
tree = [[] for _ in range(n)]

for i in range(m):
  a,b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
  
depth = [-1] * n
prev = [-1] * n

q = deque([0])
depth[0] = 0

while len(q) > 0:
  pos = q.popleft()
  for i in tree[pos]:
    if depth[i] == -1:
      depth[i] = depth[pos] + 1
      prev[i] = pos
      q.append(i)
      
print('Yes')
for i in range(1,n):
  ans = prev[i] + 1
  print(ans)

Measured memory_bytes: 34864
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


int main() {

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

	int n, w;
	cin >> n >> w;

	vector<long long> dp(w+1);
	for (int i = 0; i <= w; i++) {
		dp[i] = 0;
 	}

	for (int i = 0; i < n; i++) {
		int in_w, in_v;
		cin >> in_w >> in_v;
		for (int j = w; j >= in_w; j--) {
			dp[j] = max(dp[j], dp[j-in_w]+in_v);
		}
	}
	cout << dp[w] << endl;

	return 0;
}

Measured memory_bytes: 1024
H,W,M=map(int,input().split())
L=[0 for _ in range(H)]
C=[0 for _ in range(W)]
B={}
for _ in range(M):
    a,b=map(int,input().split())
    B[str(a)+","+str(b)]=0
    L[a-1]+=1
    C[b-1]+=1

LM=max(L)
CM=max(C)

l=[]
c=[]
for j in range(H):
    if L[j]==LM:
        l.append(j)

for k in range(W):
    if C[k]==CM:
        c.append(k)

ans=LM+CM-1

for a in l:
    for b in c:
        if str(a+1)+","+str(b+1) not in B:
            ans=LM+CM
            break
    if ans==LM+CM:
        break
print(ans)

Measured memory_bytes: 194592
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    string s; cin >> s;
    int n = SZ(s);
    string t = "";
    REP(i, n) if(s[i] != 'x') t+= s[i];
    string t2 = t;
    Reverse(t2);
    if(t != t2){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    int i = 0, j = n - 1;
    while(i < j){
        if(s[i] == s[j]){
            i++;
            j--;
        }
        else if(s[i] == 'x'){
            ans++;
            i++;
        }else{
            ans++;
            j--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef tuple<int, int, int, int> T;

int n;
string s[50]; int c[50];
int l[50];
int dp[51][2][21];	//dp[str type(0～n-1)][prefix(0), suffix(1)][len]

signed main() {
	int i, j, k;
	
	cin >> n;
	rep(i, n) { cin >> s[i] >> c[i]; l[i] = s[i].length(); }
	
	int INF = 1e+16;
	rep(i, n) rep(j, 2) rep(k, 21) dp[i][j][k] = INF;
	
	priority_queue<T, vector<T>, greater<T>> que;
	
	rep(i, n) {
		que.push(T(c[i], i, 0, l[i]));
	}
	
	while (!que.empty()) {
		T now = que.top(); que.pop();
		int cst = get<0>(now);
		int type = get<1>(now);
		int flag = get<2>(now);
		int len = get<3>(now);
		
		//len文字の部分が既に回文？
		bool heno = true;
		if (flag == 0) {
			rep(i, len) {
				if (s[type][l[type] - len + i] != s[type][l[type] - 1 - i]) {
					heno = false;
					break;
				}
			}
		}
		else {
			rep(i, len) {
				if (s[type][i] != s[type][len - 1 - i]) {
					heno = false;
					break;
				}
			}
		}
		
		if (heno) {
			cout << cst << endl;
			return 0;
		}
		
		if (dp[type][flag][len] <= cst) continue;
		dp[type][flag][len] = cst;
		
		//遷移
		rep(i, n) {
			if (flag == 0) {
				if (len >= l[i]) {
					rep(j, l[i]) {
						if (s[type][l[type] - len + j] != s[i][l[i] - 1 - j]) {
							break;
						}
					}
					if (j == l[i]) {
						que.push(T(cst + c[i], type, flag, len - l[i]));
					}
				}
				else {
					rep(j, len) {
						if (s[type][l[type] - len + j] != s[i][l[i] - 1 - j]) {
							break;
						}
					}
					if (j == len) {
						que.push(T(cst + c[i], i, !flag, l[i] - len));
					}
				}
			}
			else {
				if (len >= l[i]) {
					rep(j, l[i]) {
						if (s[type][len - 1 - j] != s[i][j]) {
							break;
						}
					}
					if (j == l[i]) {
						que.push(T(cst + c[i], type, flag, len - l[i]));
					}
				}
				else {
					rep(j, len) {
						if (s[type][len - 1 - j] != s[i][j]) {
							break;
						}
					}
					if (j == len) {
						que.push(T(cst + c[i], i, !flag, l[i] - len));
					}
				}
			}
		}
	}
	
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a+b>=10) {
        cout << "error" << endl;
    } else {
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint dp[200100][6];
lint inf=123456789012345678LL;
lint a[200100];
int main()
{
	int n;
	cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,200100) rep(j,6) dp[i][j]=inf;
	dp[0][0]=0;
	rep(i,n){
		//0を入れる
		REP(j,1,5){
			dp[i+1][3]=min(dp[i+1][3],dp[i][j]+a[i]);
		}
		dp[i+1][0]=min(dp[i+1][0],dp[i][0]+a[i]);
		//奇数を入れる
		rep(j,3){
			dp[i+1][1]=min(dp[i+1][1],dp[i][j]+(a[i]+1)%2);
		}
		//偶数を入れる
		lint co=a[i]%2;if(a[i]==0L) co=2;
		dp[i+1][2]=min(dp[i+1][2],min(dp[i][0],dp[i][2])+co);
		dp[i+1][4]=min(dp[i+1][2],min(dp[i][4],dp[i][1])+co);
	}
	lint out=inf;
	rep(i,5) out=min(out,dp[n][i]);
	cout<<out<<endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#define N 1000005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, ans, fac[N] = {1, 1}, inv[N] = {1, 1}, fin[N] = {1, 1};
int main()
{
	ll i;
	cin >> n;
	for (i = 2; i <= n; i++) {
		fac[i] = fac[i - 1] * i % M;
		inv[i] = inv[M % i] * (M - M / i) % M;
		fin[i] = fin[i - 1] * inv[i] % M;
	}
	for (i = (n + 1) / 2; i < n; i++) {
		ans = (ans + fac[i] * fac[i - 1] % M * fin[i * 2 - n]) % M;
	}
	cout << (fac[n] - ans + M) % M;
    return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = numeric_limits<int>::max();
const ll INF_LL = numeric_limits<ll>::max();

void solve() {
    int items;
    int capacity;
    cin >> items >> capacity;

    vector<int> w(items+1), v(1+items);
    for (int i = 1; i <= items; i++) {
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(items + 1, vector<ll>(100001, INF_LL/2));
    // dp[k][s] - минимальный вес при первых k пердметах и ценности s
    for (int i = 0; i <= items; i++)
        dp[i][0] = 0;

    for (int k = 1; k <= items; k++) {
        for (int s = 1; s <= 100000; s++) {
            if (v[k] <= s) {
                dp[k][s] = min(dp[k - 1][s], dp[k - 1][s - v[k]] + w[k]);
            } else {
                dp[k][s] = dp[k - 1][s];
            }
        }
    }
    for (int i = 100000; i >= 0; i--)
        if (dp[items][i] <= capacity) {
            cout << i;
            break;
        }
}

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

    solve();
    return 0;
}


Measured memory_bytes: 80256
n, k = gets.chomp.split(" ").map(&:to_i)
arr = Array.new(n,0)
(0..k-1).each do
    d = gets.chomp.to_i
    a = gets.chomp.split(" ").map(&:to_i)
    (0..d-1).each do |e|
       arr[a[e]-1] = 1
    end
end
count = 0
(0..n-1).each do |f|
    if arr[f] == 0
        count += 1
    end
end
puts count

Measured memory_bytes: 14348
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N;
	cin >> N;
	vll d(N + 1);
	repn(i, N) cin>> d[i];
	sort(++d.begin(), d.end());
	ll M = N / 2;
	cout << d[M + 1] - d[M] << endl;

}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

const int MOD = 1e9+7;
const int MAXR = 510000;

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint COM(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    mint m; int n; cin >> m >> n;
    cout << modpow(m,n) << endl;
    return 0;
}


Measured memory_bytes: 15068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

int n;
long double dp[301][301][301] = {{{0.0L}}};

long double dfs(int c1, int c2, int c3)
{
    if(c1 == 1 && c2 == 0 && c3 == 0)
        return n;
    if(dp[c1][c2][c3] > 0.0L)
        return dp[c1][c2][c3];
    long double exp = 0.0L, den = (long double)(c1 + c2 + c3);
    if(c1 > 0)
        exp += dfs(c1-1, c2, c3)*(long double)c1/den;
    if(c2 > 0)
        exp += dfs(c1+1, c2-1, c3)*(long double)c2/den;
    if(c3 > 0)
        exp += dfs(c1, c2+1, c3-1)*(long double)c3/den;
    dp[c1][c2][c3] = exp + (n - den)/den + 1;
    return dp[c1][c2][c3];
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if(x == 1)
            c1++;
        else if(x == 2)
            c2++;
        else
            c3++;
    }
    cout << setprecision(15) << dfs(c1, c2, c3) << endl;
}

Measured memory_bytes: 212944
# -*- coding: utf-8 -*-

import sys
import copy
import math

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

N = int(input())
H = [int(x) for x in input().split()]

ans = 0
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0


print(ans)


Measured memory_bytes: 14764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;

namespace AtCoderApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var nstr = Console.ReadLine();
            var N = long.Parse(nstr);

            var hashset = new HashSet<string>();
            for (long i = 0; i < N; i++)
            {
                var input = Console.ReadLine();
                hashset.Add(input);
            }
            Console.WriteLine(hashset.Count);
        }
    }
}


Measured memory_bytes: 46964
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct UnionFind {
    vector<int> par;
    int n, cnt;
    UnionFind(const int& x = 0) {init(x);}
    void init(const int& x) {par.assign(cnt=n=x, -1);}
    inline int find(const int& x) {return par[x] < 0 ? x : par[x] = find(par[x]);}
    inline bool same(const int& x, const int& y) {return find(x) == find(y);}
    inline bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return false;
        --cnt;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    inline int count() const {return cnt;}
    inline int count(int x) {return -par[find(x)];}
};

const int MAX = 100100;

int main() {
	int N, K, L;
	cin >> N >> K >> L;
	UnionFind uf1(N), uf2(N), uf3(N);
	for (int i = 0; i < K; i++) {
		int p, q;
		cin >> p >> q;
		--p; --q;
		uf1.unite(p, q);
	}
	for (int i = 0; i < L; i++) {
		int p, q;
		cin >> p >> q;
		--p; --q;
		uf2.unite(p, q);
	}
	vector<pair<pii, int> > P(N);
	for (int i = 0; i < N; i++) {
		P[i].second = i;
		P[i].first = pii(uf1.find(i), uf2.find(i));
	}
	sort(P.begin(), P.end());
	vector<int> ans(N);
	int i = 0;
	while (i < N) {
		int ni = i+1;
		while (ni < N) {
			if (P[i].first != P[ni].first) break;
			++ni;
		}
		for (int j = i; j < ni; j++) {
			ans[P[j].second] = ni-i;
		}
		i = ni;
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] ;
		if (i < N-1) cout << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>
int main(void){
     long long int n,a[200000]={0},sum = 0,sunuke = 0,araiguma = 0,min = 10000000000;
    scanf("%lld", &n);
    for(int i = 0; i< n; i++){
        scanf("%lld",&a[i]);
        sum += a[i];
    }
    for(int j = 0; j < n-1; j++){
        sunuke +=a[j];
        araiguma = sum - sunuke;

        if(min > sunuke-araiguma && sunuke-araiguma >0){
            min = sunuke - araiguma;
        }else if(min > araiguma-sunuke && araiguma-sunuke >0){
            min = araiguma - sunuke;
        }else if(sunuke == araiguma){
            min = 0;
            break;
        }
    }
    if(min == 10000000000){
        min = 0;
    }
    printf("%lld", min);
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N;
	vector<int> a;
	
	void ans() {
		cin >> N;
		a.resize(N);
		int sum = 0;
		REP(i, N) {
			cin >> a[i];
			sum += a[i];
		}
		double ave = sum / (double)N;
		int res = N - 1;
		double min = abs(a[N - 1] - ave);
		for (int i = N - 2;i >= 0;i--) {
			if (abs(ave - a[i]) <= min) {
				min = abs(ave - a[i]);
				res = i;
			}
		}
		cout << res << "\n";
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.ans();
	
	return 0;
}

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

//Do not get frustrated over WA. Check for edge cases and runtime errors :)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    double x = (a + b) / 0.18;
    ll ans = x, lim = 0;
    bool ok = true;
    while ((ll)(ans * 0.08) != a || (ll)(ans * 0.1) != b) {
        ans++;
        lim++;
        if (lim > 1e6) {
            ok = false;
            break;
        }
    }
    if (ok) cout << ans;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;

int f[100001];
     
     
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        f[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    while(q--){
        ll u,v;
        cin>>u>>v;
        //unionn(v,u);
        sum+=(v-u)*f[u];
        f[v]+=f[u];
        f[u]=0;
        cout<<sum<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 4488
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <iomanip>
#include <sstream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int maxx=-99999999;
    int minn=99999999;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin>>x.at(i);
        maxx=max(maxx, x.at(i));
        minn=min(minn, x.at(i));
    }
    int ans = 99999999;
    for(int i=minn; i<=maxx; i++){
        int preans=0;
        for(int j=0; j<n; j++){
            preans+=pow(x.at(j)-i, 2.0);
        }
        ans=min(ans, preans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int N;
ll v[100005];

int main(){
  ios::sync_with_stdio(false);
  cin >> N;
  rep(i,N){
    cin >> v[i];
  }

  ll ret = 0;
  rep(i,N-1){
    if(v[i]%2==1 && v[i+1]>0){
      ret++;
      v[i]--;
      v[i+1]--;
    }
  }
  rep(i,N){
    ret += v[i]/2;
  }

  cout << ret << endl;
  return 0;
}



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

int main(){
	int n;
	cin>>n;
	int flag;
	long long int m=1e+9+7;
	//素数リストを作る
	vector<int> p={2};
	for (int i = 3; i <=n; i++) {
		flag=0;
		for (int j = 0; j < p.size(); j++) {
			if (i%p[j]==0) {
				flag=1;
				break;
			}
		}
		if (flag==0) {
			p.push_back(i);
		}
	}
	//答えの計算
	long long int ans=1;
	long long int div;
	long long int nump;
	//素数ごとに個数の計算
	for (int i = 0; i < p.size(); i++) {
		div=p[i];
		nump=0;
		while (n/div>0) {
			nump+=n/div;
			div*=p[i];
		}
		ans*=nump+1;
		ans%=m;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int M=1e6;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
char s[N];
int nxt[N][3],a[3],b[N];
int main()
{
    int n;read(n);
    scanf("%s",s+1);
    for(re int i=n;i>=1;i--)
    {
        if(s[i]=='R') b[i]=0;
        else if(s[i]=='G') b[i]=1;
        else b[i]=2;
    }
    for(re int i=n;i>=1;i--)
    {
        nxt[i][0]=a[0];
        nxt[i][1]=a[1];
        nxt[i][2]=a[2];
        a[b[i]]++;
    }
    ll ans=0;
    for(re int i=1;i<=n;i++)
    {
        for(re int j=i+1;j<=n;j++)
        {
            if(b[i]==b[j]) continue;
            re int k;
            for(k=0;k<3;k++)
            {
                if(k!=b[i]&&k!=b[j]) break;
            }
            ans+=nxt[j][k];
            if(2*j-i<=n) if(b[2*j-i]==k) ans--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int r;
  std::cin >> r;
  cout(3 * r * r);
}


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


void solve(long long N){
    ll maxv;
    for(maxv = 1; maxv * (maxv + 1) / 2 < N; ++maxv){
    }
    set<ll> removed;
    ll tmp = maxv * (maxv + 1) / 2;
    for(ll i = maxv; i >= 1 && tmp > N; --i){
        if(tmp - i >= N){
            removed.insert(i);
            tmp -= i;
        }
    }
    assert(tmp == N);
    for(ll i = 1; i <= maxv; ++i){
        if(removed.count(i) == 0){
            cout << i << endl;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 0x3f3f3f3f;
const int N = 100+10;

int a[N], b[N];

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(false); cout.tie(false);
    int n;
    cin >> n;
    for(int i = 0; i < n-1; ++i) cin >> b[i];
    a[n-1] = b[n-2];
    for(int i = n-2; i >= 0; --i) {
        if(i-1 >= 0) {
            if(b[i-1] >= b[i]) a[i] = b[i];
            else a[i] = b[i-1];
        } else a[i] = b[i];
    }
    ll sum = 0;
    for(int i = 0; i < n; ++i) sum += a[i];
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int n;

int main(){
    cin >> n;
    long long va = 100000;
    rep(i, n){
        va *= 1.05;
        if(0 < va - (va / 1000 * 1000) && va - (va / 1000 * 1000) < 1000)
            va = va / 1000 * 1000 + 1000;
    }
    cout << va << endl;
}

Measured memory_bytes: 3092
"use strict";
function main(input) {
    let line = input.split(/\r?\n/g);
    let S = new Set(line[0].slice(0, line.length + 1));
    console.log(1 < S.size ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20808
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
import std.bigint, std.functional;

void main() {
  auto I = readln.split.to!(long[]);
  auto A = cast(real)(I[0]);
  auto B = cast(real)(I[1]);
  auto C = cast(real)(I[2]);

  bool solve() {
    return A + B + 2f*(A.sqrt*B.sqrt) < C;
  }

  writeln(solve() ? "Yes" : "No");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		
		int n = Integer.parseInt(strs[0]);
		int x = Integer.parseInt(strs[1]);
		int t = Integer.parseInt(strs[2]);
		
		System.out.println((int)(Math.ceil((double)n/x)*t) );
		
	}
}


Measured memory_bytes: 32664
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	string s;
	cin >> s;
	set<char> se;
	for (int i = 0; i < s.length();i++) {
		se.insert(s[i]);
	}

	if ((se.find('N') != se.end()) ^ (se.find('S') != se.end())) {
		cout << "No" << endl;
		return 0;
	}
	if ((se.find('E') != se.end()) ^ (se.find('W') != se.end())) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}



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

int main(){
  int n, d; cin >> n >> d;
  int pts[10][10];
  for (int i = 0; i < n; i++){
    for (int j = 0; j < d; j++){
      cin >> pts[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < i; j++){
      int sum = 0;
      for (int k = 0; k < d; k++){
        sum += (pts[i][k] - pts[j][k]) * (pts[i][k] - pts[j][k]);
      }
      for (int k = 1; k * k <= sum; k++){
        if (k * k == sum){
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Luck Manipulator
// 2013/05/12
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, a, b, c, x;
	int[] ys;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			a=sc.nextInt();
			b=sc.nextInt();
			c=sc.nextInt();
			x=sc.nextInt();
			ys=new int[n];
			for(int i=0; i<n; i++){
				ys[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int frame, at;
		for(frame=0, at=0; frame<=10000; frame++){
			if(x==ys[at]){
				at++;
				if(at==n){
					break;
				}
			}
			x=(a*x+b)%c;
		}
		println(at==n?""+frame:"-1");
		// debug(frame, at,at==n);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 29868
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	int odd_count = (n+1)/2;
	cout<<setprecision(14)<<1.0*odd_count/n<<endl;
	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Parking
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  printf("%d\n", min(n * a, b));
  return 0;
}


Measured memory_bytes: 256
N, M = [int(n) for n in input().split()]
X = sorted([int(n) for n in input().split()])

answer = 0

if N >= M:
    pass
else:
    diff = []
    for i in range(len(X) - 1):
        diff.append(X[i+1] - X[i])

    diff = list(reversed(sorted(diff)))
    s = 0
    for i in range(N - 1):
        s += diff[i]
    answer = X[-1] - X[0] - s

print(answer)

Measured memory_bytes: 13832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????
		//?????°?????£?¨?
		int a,b;
		String str;

		//????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();

		//??????
		String[] st = str.split(" ");

		 a = Integer.parseInt(st[0]);
		 b = Integer.parseInt(st[1]);

		 /*for(int i=0;i<st.length;i++){
		 System.out.println("st["+i+"]="+st[i]); //?????????????´??¢????
		 }*/

		 if(a<-1000||b<-1000||a>1000||b>1000){
			 System.out.println("a,b?????????-1000~1000??§??\???.???????????????.");
			 System.exit(0);
		 }

		 if(a>b) System.out.println("a > b");

		 else if(a<b) System.out.println("a < b");

		 else if(a==b) System.out.println("a == b");
	}

}

Measured memory_bytes: 24072
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::intptr_t;
using usize = std::uintptr_t;

auto main() -> i32 {
	char c;
	scanf("%c", &c);
	puts(c <= 'Z' ? "A" : "a");
	return 0;
}


Measured memory_bytes: 1540