akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K; cin >> N >> K;
	if (K % 2 == 1) {
		ll x = N / K;
		cout << x * x * x << "\n";
	}
	else {
		ll x = N / K;
		ll ans = x * x * x;
		ll y = (N + K / 2) / K;
		ans += y * y * y;
		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;

  string ans = "";
  if (n == 0) ans = "0";
  while (n != 0) {
    if (n % 2 != 0) {
      n--;
      ans = '1' + ans;
    } else {
      ans = '0' + ans;
    }
    n /= -2;
  }

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


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include <atcoder/all>
using namespace atcoder;

int main(){
   int n,m; cin>>n>>m;
   vector<int> a(n),b(m);
   rep(i,0,n)cin>>a[i];
   rep(i,0,m)cin>>b[i];
   auto v=convolution(a,b);
   rep(i,0,n+m-1)cout<<v[i]<<endl;
   return 0;
}

Measured memory_bytes: 19068
S = list(input())
SL = len(S)
L = len(S)
i = 1
while len(S)>1 and i<len(S):
  if int(S[i]) != int(S[i-1]):
    S.pop(i-1)
    S.pop(i-1)
    i-=1
  else:
    i+=1
  if i==0:
    i+=1
print(L-len(S))

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    vector<unsigned int> A(26, 0), B(26, 0);
    for (char c = 'a'; c <= 'z'; c++)
    {
        A[c - 'a'] = count(S.begin(), S.end(), c);
        B[c - 'a'] = count(T.begin(), T.end(), c);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for (int i = 0; i < 26; i++)
    {
        if (A[i] != B[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
#include <iostream>

using namespace std;

int main(){
	int a,b,ans=0;
	cin >> a>> b;
	if (a>b) {
		ans+=a;a--;
	}else{
		ans+=b;b--;
	}
	if (a>b) {
		ans+=a;a--;
	}else{
		ans+=b;b--;
	}
	cout << ans;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    println!("{}", std::cmp::min(a + b, std::cmp::min(b + c, c + a)));
}


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

using namespace std;

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

#define chmax(a,x) a=max(a,x)

vector<bool> F[5];

void dump() {
  rep(j, 10) {
    rep(i, 5) {
      if(j>=int(F[i].size())) cout << 0;
      else cout << F[i][j];
    }
    cout << endl;
  }
}

bool eraser(int idx) {
  
  rep(i, 5) {
    if((int)F[i].size() <= idx) { return false; }
    if(!F[i][idx]) { return false; }
  }
  
  rep(i, 5)
    F[i].erase(F[i].begin()+idx);
  
  rep(i, 5) {
    while(1) {
      if(!F[i].empty() && !F[i].back()) { F[i].pop_back(); }
      else { break; }
    }
  }
  
  return true;
}

int main() {
  
  for(int N; cin>>N && N;) {
    rep(i, 5) F[i].clear();
    rep(i, N) {
      int type, len, pos; cin >> type >> len >> pos; pos --;
      if(type == 1) {
	int mx = -1;
	REP(i, pos, pos+len) { chmax(mx, int(F[i].size())); }
	REP(i, pos, pos+len) {
	  REP(j, F[i].size(), mx) {
	    F[i].push_back(false);
	  }
	  F[i].push_back(true);
	}
	eraser(mx);
      }
      else {
	rep(i, len) { F[pos].push_back(true); }
	int cnt = 0;
	rep(i, len) { if(!eraser((int)F[pos].size()-1-cnt)) cnt++; }
      }
    }
    int sum = 0;
    rep(i, 5) rep(j, F[i].size()) sum += F[i][j];
    cout << sum << endl;
  }
  return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ


//ソートされたA[left~mid]とA[mid+1~right]をくっつける関数
void merge(double* A, int left, int mid, int right, double* B){
    int i,j,k;
    double tmp;

    //kは一時的な配列Bの現在の添字、iは前半A[left~mid]、jは後半A[mid+1~right]を指す添字
    k=left; i=left; j=mid+1;
    while(k<=right){
        if(j>right) tmp=A[i++]; //前半のみにデータがある
        else if(i>mid) tmp=A[j++]; //後半のみにデータがある
        else if(A[i]<=A[j]) tmp=A[i++]; //前半の方が小さい
        else tmp=A[j++]; //後半の方が小さい

        B[k++]=tmp;
    }
    for(i=left;i<=right;i++) A[i]=B[i]; //元の配列に戻す
}

//A[left]~A[right]までの配列を昇順にマージソートする関数
void merge_sort(double* A, int left, int right, double*B){
    int mid;

    if(left<right){
        mid=(left+right)/2;
        merge_sort(A,left,mid,B); //A[left]~A[mid]までを再帰的にソート
        merge_sort(A,mid+1,right,B); //A[mid+1]~A[right]までを再帰的にソート
        merge(A,left,mid,right,B); //分割した二つをくっつける
    }
}

int main(void){
    int N;
    scanf("%d",&N);

    //v[0]~v[N-1]に格納する
    double* v;
    NEW(v,N);
    for(int i=0;i<N;i++){
        scanf("%lf",&v[i]);
    }

    //マージソート用の仮配列
    double* u;
    NEW(u,N);
    //vをマージソート
    merge_sort(v,0,N-1,u);
    free(u);

    for(int i=0;i<=N-2;i++){
        v[i+1]=(v[i]+v[i+1])/2;
    }

    double ans=v[N-1];
    printf("%lf\n",ans);

    return 0;
}

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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
 fastIO();
 long long n , m , free = 0, sum = 0;
 
 cin>>n>>m;
 long long arr[m];
 
 for(int i=0; i<m; i++)
 {
 	cin>>arr[i];
 	sum+=arr[i];
 }
 if(sum>n)
 {
 	free = -1;
 	cout<<free<<endl;
 }
 else
 {
 	free = n - sum;
 	cout<<free << endl;
 }

return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>

int main(void)
{
	int x;
	int a;
	int b;
	int n;
	int c;
	
	scanf("%d", &x);
	
	a = 2;
	b = 2;
	c = 2;
	n = 0;
	while(a * a <= x){
		a = c;
		b = c;
		while(b * a <= x){
			b = b * a;
			if(n < b){
				n = b;
			}
		}
		c++;
	}
	if(x <= 3){
		n = 1;
	}
	
	printf("%d\n", n);
	
	return(0);
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    string s;
    cin >> s;
    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s << newl;

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
int ok[ohara];

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);

    cin>>n>>d;
    ans=(n%(2*d+1)==0 ? n/(2*d+1) : n/(2*d+1)+1 );
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
/*
注意范围！
short范围：-32768~32767
unsigned short范围：0~65535
int范围：-2147483648~2147483647
uint范围：0~4294967295
INT范围：-9223372036854775808~9223372036854775807
UINT范围：0~18446744073709551615
float范围：-3.4e38～3.4e38，精度：6~7位
double范围：-1.7e308~1.7e308，精度：15~16位
ldouble范围：-1.2e4932~1.2e4932，精度：18~19位
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
using namespace __gnu_cxx;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

inline INT cfun(INT dishu,INT zhishu)
{
	if(zhishu==0)return 1;
	else if(zhishu%2)
	{
		INT ds=cfun(dishu,zhishu/2);
		ds=ds*ds%Mod;
		ds=ds*dishu%Mod;
		return ds;
	}
	else
	{
		INT ds=cfun(dishu,zhishu/2);
		ds=ds*ds%Mod;
		return ds;
	}
}

int n,a[100007],dd;
int hv[100007];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
	{
		scanf("%d",&a[i]);
		hv[a[i]]++;
	}
	int lnc;
	for(int i=1;i<=n;i++)
		if(hv[i]==2)
			lnc=i;
	for(int i=0;i<=n;i++)
		if(a[i]==lnc)
		{
			dd+=i;
			break;
		}
	for(int i=n;i>=0;i--)
		if(a[i]==lnc)
		{
			dd+=n-i;
			break;
		}
	INT aa=1,bb=1;
	for(int i=1;i<=n+1;i++)
	{
		aa=aa*(n-i+2)%Mod*cfun(i,Mod-2)%Mod;
		printf("%I64d\n",(aa-bb+Mod)%Mod);
		bb=bb*(dd-i+1)%Mod*cfun(i,Mod-2)%Mod;
	}
	return 0;
}


Measured memory_bytes: 7424
#include<stdio.h>

 int main(){
       int r,c,i,j,sumc[105],sumr[105],rc[105][105],sumtotal=0;
       scanf("%d%d",&r,&c);
       for(i=0;i<r;i++){
             for(j=0;j<c;j++){
                     scanf("%d",&rc[i][j]);
                     }
             }
       
       for(i=0;i<r;i++){
             for(j=0;j<c;j++){
                   sumr[j]+=rc[i][j];
                   }
             }
       for(i=0;i<r;i++){
             for(j=0;j<c;j++){
                   sumc[i]+=rc[i][j];
                   }
             }

       
       for(i=0;i<r;i++){
             for(j=0;j<c;j++){
                     printf("%d ",rc[i][j]);
                     }
             printf("%d\n",sumc[i]);
             }

       for(i=0;i<c;i++){
             printf("%d ",sumr[i]);
             sumtotal+=sumr[i];
             }
       printf("%d\n",sumtotal);
       return 0;
       }
   






Measured memory_bytes: 2056
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;

    if (a == b) {
        cout << c;
    } else if (a == c) {
        cout << b;
    } else {
        cout << a;
    }

    return 0;
}


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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int l,r,d;
  scanf("%d%d%d",&l,&r,&d);

  int count = 0;
  for(int i = l; i < r+1; ++i){
    if(i % d == 0)count ++;
  }

  printf("%d",count);

  return 0;
}


Measured memory_bytes: 1632
#include<iostream>
#include<numeric>
#include<algorithm>
#include<vector>
#include<set>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int const MAXN = 2e5;
int P[MAXN];

int main() {
  int N = getZ();
  for(int i = 0; i < N; ++i) P[i] = getZ();
  std::vector<int> ix(N);
  std::iota(ix.begin(), ix.end(), 0);
  std::sort(ix.begin(), ix.end(), [&](int l, int r){ return P[l] > P[r]; });
  int64_t ans = 0;
  std::multiset<int> S;
  S.insert(-1); S.insert(-1); S.insert(N); S.insert(N);
  for(auto i: ix) {
    int64_t p = P[i];
    auto it = S.lower_bound(i);
    int il1 = *--it, il2 = *--it;
    it = S.upper_bound(i);
    int ir1 = *it++, ir2 = *it;
    ans += p*((il1-il2)*(ir1-i) + (i-il1)*(ir2-ir1));
    S.insert(i);
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
using namespace std;
int M, W;
int BM[12], BW[12];
int DP[13][1 << 12];
int main()
{
	while (true){
		scanf("%d%d", &M, &W);
		if (M == 0 && W == 0)break;
		for (int i = 0; i < M; i++){
			scanf("%d", &BM[i]);
		}
		for (int i = 0; i < W; i++){
			scanf("%d", &BW[i]);
		}
		for (int i = 0; i <= 12; i++)for (int j = 0; j < (1 << 12); j++)DP[i][j] = 0;
		for (int i = 1; i <= M; i++){
			for (int j = 0; j < (1 << W); j++){
				DP[i][j] = DP[i - 1][j];
				for (int k = 0; k < W; k++){
					if ((j >> k) & 1){
						DP[i][j] = max(DP[i][j], DP[i - 1][j - (1 << k)] + abs(BM[i - 1] - BW[k])*(abs(BM[i - 1] - BW[k]) - 30)*(abs(BM[i - 1] - BW[k]) - 30));
					}
					else DP[i][j] = DP[i][j];
				}
			}
		}
		int ans = 0;
		for (int j = 0; j < (1 << W); j++)ans = max(ans, DP[M][j]);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1400
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		if(p>=b)ret++;
	}
	printf("%d\n",ret);
}

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

int main(){
    string s;
    cin >> s;
    bool X=false, Y=false;
    for (char c : s) {
        if (c == 'C') X = true;
        if (X&&(c == 'F')) Y = true;
    }
    if (Y) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int t;
  while(cin>>t && t > 0){
    int p1 = 0, p2 = 0;
    while(t > 0){
      int a = 0, b = 0;
      cin >> a >> b;
      if(a < 0 || a > 9 || a < 0 || a > 9){
        continue;
      }
      if(a > b){
        p1 += a + b;
      }
      else if(a < b){
        p2 += a + b;
      }
      else{
        p1 += a;
        p2 += b;
      }
      t--;
    }
    cout << p1 << " " << p2 << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
import itertools
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
a = [0,1,2,3,4,5,6,7,8]
b = a[:n]
c = list(itertools.permutations(b))
ans = []
for i in range(len(c)):
    x = 0
    for j in range(n-1):
        y = ((z[c[i][j]][0]-z[c[i][j+1]][0])**2+(z[c[i][j]][1]-z[c[i][j+1]][1])**2)**0.5
        x += y
    ans.append(x)
print(sum(ans)/len(c))

Measured memory_bytes: 9332
#include<stdio.h>
int main(void)
{
	int n,a,c=0,max=0,i;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &a);
		if(a==1)
		{
			c++;
			if(max<c)
			max=c;
		}
		else
		c=0;
	}
	max++;
	printf("%d\n", max);
	
	return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val ST = Array.fill(2)(sc.next)

    ST(0).zipWithIndex.map {
      case (s: Char, i: Int) => "%c%c".format(s, ST(1)(i))
    }.mkString("")
  }
}


Measured memory_bytes: 27472
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <map>
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int maxN = 20;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;
char s[maxN << 1];
LL res = 0;
map<pair<ull, ull>, int> mp;

int main() {

	n = ri();
	scanf("%s", s+1);
	
	int mask = (1 << n) - 1;
	rep (st, 0, mask) {
		ull s = 0, t = 0;
		rep (i, 1, n) { 
			if (st >> (i-1) & 1) s = s * 131ull + ::s[i];
			else t = t * 131ull + ::s[i];
		}
		mp[make_pair(s, t)]++;
	}
	rep (st, 0, mask) {
		ull s = 0, t = 0;
		For (i, 0, n) { 
			if (st >> i & 1) s = s * 131ull + ::s[n*2-i];
			else t = t * 131ull + ::s[n*2-i];
		}
		res += mp[make_pair(s, t)];
	}
	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 33024
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		double max=sc.nextDouble();
		double min=max;


		while(sc.hasNext())
		{
			double h =sc.nextDouble();
			if(h>max)
				max=h;
			if(h<min)
				min=h;
		}
		System.out.println(max-min);
	}
}

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

int main() {
  string str;
  cin>>str;
  
  int zero = 0,one = 0;
  for(int i = 0;str[i] != '\0';i++){
    if(i % 2 == 0){
      if(str[i] == '0'){
        zero++;  
      }else{
        one++;
      }
    continue;
    }
      if(str[i] == '0'){
        one++;  
      }else{
        zero++;
      }
  }
  
  int ans = 0;
  if(zero < one)ans = zero; else ans = one;
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 512
S = input()
chrs = set(S)

if len(chrs) == 1:
    ans = 0
else:
    ans = len(S)
    for c in chrs:
        cnt = 0
        cur = S
        while True:
            new = ""
            for i in range(len(cur) - 1):
                if cur[i] == c or cur[i + 1] == c:
                    new += c
                else:
                    new += "*"
            cnt += 1
            if len(set(new)) == 1:
                break
            cur = new

        if cnt < ans:
            ans = cnt

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ld long double
using namespace std;

#define int long long int
#define ps psuh_back()
#define fi first
#define so second

signed main()
{
    int n,i,f,s;
    cin>>n;
    int m[10][10];
    for(i=0;i<=9;i++) for(int j=0;j<=9;j++) m[i][j]=0;
//    map<pair<int,int> > m;
    for(i=1;i<=n;i++)
    {
        int t=i;
        s = i%10;
        f=s;
        while(t) {f=t%10;t/=10;}
        m[f][s]++;
    }

        //for(i=1;i<=9;i++) for(j=1;j<=9;j++) if(m.find({i,j})==m.end()) m[{i,j}]=0;
    int res=0;
    for(i=1;i<=9;i++)
    {
        for(int j=i;j<=9;j++) res+=(i!=j?2:1)*m[i][j]*m[j][i];
    }
    cout<<res;
}


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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {


    int a,b,c,d,e;
    int limit;
    int ra,rb,rc,rd;
    int count=0;
    cin >> a>> b>> c>> d>> e>> limit;
    ra = b-a;
    rb = c-b;
    rc = d-c;
    rd = e-d;

    if(ra > limit) count++;
    if(rb > limit) count++;
    if(rc > limit) count++;
    if(rd > limit) count++;
    if(ra+rb > limit)count++;
    if(rb+rc > limit)count++;
    if(rc+rd > limit)count++;
    if(ra+rb+rc > limit)count++;
    if(rb+rc+rd > limit)count++;
    if(ra+rb+rc+rd > limit)count++;

    if(count)  cout << ":(" << endl;
    if(!count) cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    string ans = "";
    rep(i,2*n){
        if(i % 2 == 0) ans += s[i/2];
        else ans += t[i/2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[7],n,g;
  for(;;){
    cin>>n;
    if(n==0)
      break;
    memset(a,0,sizeof(a));
    for(i=0;i<n;i++){
      cin>>g;
      if(g<10)
	a[0]++;
      else if(g<20)
	a[1]++;
      else if(g<30)
	a[2]++;
      else if(g<40)
	a[3]++;
      else if(g<50)
	a[4]++;
      else if(g<60)
	a[5]++;
      else
	a[6]++;
    }
    for(i=0;i<7;i++)
      cout<<a[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N, M;
    cin >> N >> M;
    
    vector<string> A(N);
    vector<string> B(M);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }


    for(int i = 0; i < N-M+1; i++) {
        for(int j = 0; j < N-M+1; j++) {

            if (A[i][j] != B[0][0]) continue;

            bool flag = false;
            REP(k, M) {
                REP(l, M) {
                    if (B[k][l] != A[i+k][j+l]) {
                        flag = true;
                    }
                }
                if (flag == true) {
                    break;
                }
            }
            if (flag == true) {
                continue;
            }

            // cout << i << j  << endl;
            
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll m,N,dp[100001][3],h[100002],a[100001],b[100001],c[100001];
  cin >> N;
  REP(i,N)cin >> a[i+1] >> b[i+1] >> c[i+1];
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  for(int i=1;i<=N;i++){
    dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2] = max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
  }
  cout << max(dp[N][0],max(dp[N][1],dp[N][2])) << endl;
  return 0;
}



Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		Arrays.sort(h);
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < n - k + 1; i++) {
			ans = Math.min(ans, h[i + k - 1] - h[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 31424
#include <bits/stdc++.h>
using namespace std; 
int main(){
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e;
if(a==0){
cout<<1;
}
if(b==0){
cout<<2;
}
if(c==0){
cout<<3;
}
if(d==0){
cout<<4;
}
if(e==0){
cout<<5;
}

}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m,x,y,z;
ll res;
ll xi,yi,zi;
int main()
{
	cin >>n>>m>>x>>y;
	z=x*y/__gcd(x,y);
	res=m-n+1;
	xi=res,yi=res,zi=res;
	xi-=(x-(n%x))%x;
	xi-=m%x;
	yi-=(y-(n%y))%y;
	yi-=m%y;
	zi-=(z-(n%z))%z;
	zi-=m%z;
	xi=max(xi,(ll)0),yi=max(yi,(ll)0),zi=max(zi,(ll)0);
	//cout <<xi<<" "<<yi<<" "<<zi<<" ##\n";
	if (xi) xi=(xi-1)/x+1;
	if (yi) yi=(yi-1)/y+1;
	if (zi) zi=(zi-1)/z+1;
	//cout <<xi<<" "<<yi<<" "<<zi<<" ##\n"; 
	cout <<res-xi-yi+zi;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	string a, b;
  	cin >> a >> b;
  	for(int i = 0; i < b.size(); i++)
      cout << a[i] << b[i];
  	if( b.size() != a.size() )
      cout << a[a.size() - 1];
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, ans = 0;
    cin >> n;
    vector<ll> v, v1, v2;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v1.pb(x);
    }
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v2.pb(x);
    }
    for(ll i = 0; i < n; i++)
    {

        ll x = v1[i], y = v2[i];
        v.pb(x-y);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    for(ll i = 0; i < n; i++)
    {

        if(v[i] < 0) break;
        ans+=v[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			Console.WriteLine(new string(cin.ReadLine.Select(c => c == '?' ? 'D' : c).ToArray()));
		}
	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}

Measured memory_bytes: 28724
Q = 10**9+7
def getInv(N):#Qはmod
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv
modfunctional = [1]*(2*10**5+1)
modinv = getInv(10**5+1)
modinvfunctional = [1]*(10**5+1)
for i in range(10**5):
    modinvfunctional[i+1] = (modinvfunctional[i]*modinv[i+1])%Q
for i in range(2*10**5):
    modfunctional[i+1] = (modfunctional[i]*(i+1))%Q
H, W, A, B = map( int, input().split())
ans = 0
for i in range(B+1, W+1):
    ans += (modfunctional[i+H-A-2]*modinvfunctional[i-1]*modinvfunctional[H-A-1]%Q)*(modfunctional[A+W-i-1]*modinvfunctional[A-1]*modinvfunctional[W-i]%Q)%Q
    ans %= Q
print(ans)


Measured memory_bytes: 18804
#include <bits/stdc++.h>
using namespace std;
const int mx =10000;
vector<int> g[mx];
int a[mx];
bool dfs(int u,int par){
    bool re=(par!=0&&a[u]>=a[par]);
    for(auto v: g[u]){
        if(v==par)continue;
        re|=!dfs(v,u);
    }
    return re;
}
int main (){
    int n,u,v;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
    }
    for(int i=0;i<n-1;i++){
        scanf("%d %d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i=1;i<=n;i++){
        if(dfs(i,0)){
            printf("%d ",i);
        }
    }
    return 0;
}

Measured memory_bytes: 768
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

//using pll = pair<long, long>;
//using W_graph = vector<vector<pll>>;

int main() {

	long A, B; cin >> A >> B;
	if (1 <= A && A <= 9 && 1 <= B && B <= 9) cout << (A * B) << endl; else cout << -1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> v;
    rep(i, 1, n) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int ans = 0;
    sort(v.begin(), v.end());
    rep(i, 0, k - 1)ans += v[i];
    cout << ans;
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    if(n%2!=0){
        rep(i,m){
            cout << n/2-i << " " << n/2+i+1 << endl;
        }
    }
    else{
        rep(i,m){
            if(i*2<=m-1){
            cout << n/2-i << " " << n/2+i+1 << endl;
            }
            else{
            cout << n/2-i-1 << " " << n/2+i+1 << endl;
                
            }
        }
    }
    

    return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int ans;
int main(){
	scanf("%d",&n);
	rep(i,n){
		int a; scanf("%d",&a);
		if(ans+1 == a) ans++;
	}
	if(ans == 0) puts("-1");
	else printf("%d\n",n-ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin, n, m;
    vector<bool> ac(n, false);
    vector<int> wa(n, 0);
    for (auto _ : Range(m)) {
        int p;
        string s;
        cin, p, s;
        p--;
        if (s == "AC") {
            ac[p] = true;
        } else {
            if (!ac[p]) {
                wa[p]++;
            }
        }
    }
    int a = 0, w = 0;
    for (auto i : Range(n)) {
        if (ac[i]) {
            a += ac[i];
            w += wa[i];
        }
    }
    print(a, w);
    return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if(a + b == c + d){
        cout << "Balanced" << endl;
    }
    else if(a + b > c + d){
        cout << "Left" << endl;
    }
    else{
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

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

vector<bool> prime_enum(int n){
    vector<bool> is_prime(n, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(ll i = 2; i < n; i++){
        if(!is_prime[i]) continue;
        for(ll j = 2; i * j < n; j++){
            is_prime[i * j] = false;
        }
    }
    return is_prime;
}

void Main(){
	int h,w; cin >> h >> w;
	vector<vector<bool>> board(h, vector<bool>(w, false));
	rep(i,h){
		rep(j,w){
			int t; cin >> t;
			board[i][j] = t % 2;
		}
	}
	vector<tuple<int,int,int,int>> ans;
	for(int i = 0; i < h; i++){
		int start = 0;
		int end = w-1;
		int step = 1;
		if(i % 2){
			start = w-1;
			end = 0;
			step = -1;
		}
		int j = start;
		while(j != end){
			if(board[i][j]){
				ans.push_back(make_tuple(i,j,i,j+step));
				board[i][j+step] = !board[i][j+step];
			}
			j += step;
		}
		if(board[i][end] && i < h-1){
			ans.push_back(make_tuple(i,end,i+1,end));
			board[i+1][end] = !board[i+1][end];
		}

	}
	cout << ans.size() << endl;
	for(auto [a,b,c,d]: ans){
		cout << a+1 << ' ' << b+1 << ' ' << c+1 << ' ' << d+1 << endl;
	}
}

Measured memory_bytes: 5352
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
            if(A[j]<=x){
            i++;
            t=A[i];A[i]=A[j];A[j]=t;
            }
        }
    t=A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}

int main(){
    int i,q;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);

    q=partition(0,n-1);

     for(i=0;i<n;i++){
        if(i)printf(" ");
        if(i==q)printf("[");
        printf("%d",A[i]);
        if(i==q)printf("]");
     }
printf("\n");
return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const int inf = 1<<29;
int broke[100010];

int main(){
    int n,l,i,j;
    vector<pair<int,int> > vp;

    scanf("%d %d",&n,&l);
    rep(i,n){
        int a; scanf("%d",&a);
        vp.push_back(make_pair(a,i));
    }

    sort(rall(vp));

    int tsum = 0;
    rep(i,vp.size()){
        int t, id = vp[i].second;
        if( id == 0 ){
            t = broke[1];
        }
        else if( id == n-1 ){
            t = broke[n-2];
        }
        else{
            t = max(broke[id-1], broke[id+1]);
        }
        int tt = tsum - t + vp[i].first;
        //printf("id=%d, tt = %d, tsum=%d, t = %d\n",id,tt,tsum,t);
        if( l > tt ){
            tsum += l - tt;
            broke[id] = tsum;
        }
        else{
            broke[id] = l + t - vp[i].first;
        }
    }

    //debug
    /*
    rep(i,n){
        printf("broke[%d] : %d\n",i,broke[i]);
    }
    */

    printf("%d\n",tsum);

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


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

    while(true){
        c -= b;
        if(c <= 0){
            pr("Yes");
            break;
        }
        a -= d;
        if(a <= 0){
            pr("No");
            break;
        }

    }

    return 0;
}



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

using ll = long long;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i=0; i<n; i++)
#define ALL(c) c.begin(), c.end()

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H.at(i);
    sort(ALL(H));
    reverse(ALL(H));
    int cnt = 0;
    ll sum = 0ll;
    rep(i, N){
        if(cnt < K) cnt++;
        else sum += H.at(i); 
    }
    cout << sum << endl;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 100005;
ll dp[maxn][2];
vector<int>g[maxn];
void dfs(int now, int pre) {
	ll m0 = 1, m1 = 1;
	for (auto &i : g[now]) {
		if (i ^ pre) {
			dfs(i, now);
			m0 *= (dp[i][0] + dp[i][1]) % mod;
			m0 %= mod;
			m1 *= dp[i][0] ;
			m1 %= mod;
		}
	}
	dp[now][0] = m0;
	dp[now][1] = m1;
	//cout << now <<' '<<dp[now][0] <<' '<<dp[now][1] << endl;
}
void go() {
	int n;
	cin >> n;
	f(n-1) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1, 0);
	cout << (dp[1][0] + dp[1][1]) % mod << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 18808
s = input()
count = 0
if s[0] == 'A' and s[2:len(s)-1].count('C') == 1:
  for i in range(1,len(s)):
    if s[i].islower() == False:
      if s[i] == 'C':
        count += 1
      else:
        print('WA')
        exit()
      if 1 < count:
        print('WA')
        exit()
  print('AC')
else:
  print('WA')

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

#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9 + 7;
//typedef unsigned long long u64;

int main()
{
	IOS;
	int t = 1;
	//cin >> t;
	while (t--)
	{
		string s, t;
		cin >> s >> t;
		bool fl = true;
		for(int i = 0; i < s.length(); i++)
		{
			if(s[i] != t[i])
			{
				fl = false;
				break;
			}
		}
		if(fl)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3652
s = gets.chomp

l = s.length

if (s == s.reverse) && (s[0..(l -1)/2 -1] == s[0..(l -1)/2 - 1].reverse)  && (s[(l + 3)/2 - 1..-1] == s[(l + 3)/2 - 1..- 1].reverse)
  puts 'Yes'
else
  puts 'No'
end

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

int main(){
   
    int N;
    cin>>N;
    vector<pair<string,pair<int,int>>> S(N);
    for(int i=0;i<N;i++){
        string a;
        int b;
        cin>>a>>b;
        S[i].first=a;
        S[i].second.first=-b;
        S[i].second.second=i+1;
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N;i++){
        cout<<S[i].second.second<<endl;;
    }
}


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

int main()
{
	int a, b, c;
  cin >> a >> b >> c;
  if(a== b && b == c)
    cout << "No";
  else if(a== b || b == c || c == a)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
long long dist[100005];
int N;
int rest0,rest1,rest2;
int val;
int main()
{
    cin>>N;
    while(N--){cin>>val;rest0+=(val%4==0);rest2|=(val%4==2);rest1+=((val%4)%2==1);}
    cout<<(rest1-(!rest2)<=rest0 ? "Yes":"No");
    return 0;
}

Measured memory_bytes: 256